wj-elements 0.0.2 → 0.0.4

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.
Files changed (66) hide show
  1. package/dist/router-links-e0087f84.js +146 -0
  2. package/dist/style.css +2 -2365
  3. package/dist/wj-aside.js +18 -22
  4. package/dist/wj-avatar.js +32 -49
  5. package/dist/wj-badge.js +18 -22
  6. package/dist/wj-breadcrumb.js +53 -103
  7. package/dist/wj-breadcrumbs.js +21 -36
  8. package/dist/wj-button-group.js +24 -36
  9. package/dist/wj-button.js +37 -80
  10. package/dist/wj-card-content.js +16 -18
  11. package/dist/wj-card-controls.js +16 -18
  12. package/dist/wj-card-header.js +16 -20
  13. package/dist/wj-card-subtitle.js +17 -19
  14. package/dist/wj-card-title.js +16 -18
  15. package/dist/wj-card.js +16 -20
  16. package/dist/wj-checkbox.js +24 -46
  17. package/dist/wj-chip.js +21 -39
  18. package/dist/wj-col.js +18 -32
  19. package/dist/wj-color-picker.js +503 -868
  20. package/dist/wj-container.js +18 -20
  21. package/dist/wj-copy-button.js +66 -112
  22. package/dist/wj-dialog.js +43 -67
  23. package/dist/wj-divider.js +16 -20
  24. package/dist/wj-dropdown.js +22 -31
  25. package/dist/wj-element.js +241 -416
  26. package/dist/wj-footer.js +16 -18
  27. package/dist/wj-form.js +16 -18
  28. package/dist/wj-grid.js +17 -21
  29. package/dist/wj-header.js +18 -22
  30. package/dist/wj-icon-picker.js +66 -107
  31. package/dist/wj-icon.js +67 -140
  32. package/dist/wj-img-comparer.js +43 -72
  33. package/dist/wj-img.js +21 -31
  34. package/dist/wj-infinite-scroll.js +49 -84
  35. package/dist/wj-input.js +67 -146
  36. package/dist/wj-item.js +19 -34
  37. package/dist/wj-label.js +19 -21
  38. package/dist/wj-list.js +17 -20
  39. package/dist/wj-main.js +16 -18
  40. package/dist/wj-master.js +331 -462
  41. package/dist/wj-menu-button.js +18 -21
  42. package/dist/wj-menu-item.js +67 -144
  43. package/dist/wj-menu-label.js +17 -21
  44. package/dist/wj-menu.js +20 -24
  45. package/dist/wj-popup.js +714 -1140
  46. package/dist/wj-progress-bar.js +42 -100
  47. package/dist/wj-radio-group.js +27 -38
  48. package/dist/wj-radio.js +24 -46
  49. package/dist/wj-route.js +8 -11
  50. package/dist/wj-router-link.js +19 -22
  51. package/dist/wj-router-outlet.js +71 -135
  52. package/dist/wj-routerx.js +641 -1121
  53. package/dist/wj-row.js +20 -22
  54. package/dist/wj-slider.js +55 -97
  55. package/dist/wj-split-view.js +45 -81
  56. package/dist/wj-store.js +110 -195
  57. package/dist/wj-textarea.js +39 -86
  58. package/dist/wj-thumbnail.js +17 -19
  59. package/dist/wj-toast.js +34 -88
  60. package/dist/wj-toggle.js +24 -42
  61. package/dist/wj-toolbar-action.js +16 -27
  62. package/dist/wj-toolbar.js +21 -26
  63. package/dist/wj-tooltip.js +27 -41
  64. package/dist/wj-visually-hidden.js +16 -18
  65. package/package.json +1 -1
  66. package/dist/router-links-26e4a166.js +0 -204
@@ -1,379 +1,254 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement from "./wj-element.js";
8
- import { r as routerLinks } from "./router-links-26e4a166.js";
1
+ var st = Object.defineProperty;
2
+ var ot = (r, t, e) => t in r ? st(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var A = (r, t, e) => (ot(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ import at from "./wj-element.js";
5
+ import { r as ct } from "./router-links-e0087f84.js";
9
6
  import "./wj-store.js";
10
- var DEFAULT_DELIMITER = "/";
11
- function balanced(open, close, str, index) {
12
- var count = 0;
13
- var i = index;
14
- while (i < str.length) {
15
- if (str[i] === "\\") {
16
- i += 2;
7
+ var z = "/";
8
+ function ut(r, t, e, n) {
9
+ for (var i = 0, s = n; s < e.length; ) {
10
+ if (e[s] === "\\") {
11
+ s += 2;
17
12
  continue;
18
13
  }
19
- if (str[i] === close) {
20
- count--;
21
- if (count === 0)
22
- return i + 1;
23
- }
24
- if (str[i] === open) {
25
- count++;
26
- }
27
- i++;
14
+ if (e[s] === t && (i--, i === 0))
15
+ return s + 1;
16
+ e[s] === r && i++, s++;
28
17
  }
29
18
  return -1;
30
19
  }
31
- function parse(str, options) {
32
- if (options === void 0) {
33
- options = {};
34
- }
35
- var _a, _b;
36
- var tokens = [];
37
- var defaultDelimiter = (_a = options.delimiter, _a !== null && _a !== void 0 ? _a : DEFAULT_DELIMITER);
38
- var whitelist = (_b = options.whitelist, _b !== null && _b !== void 0 ? _b : void 0);
39
- var i = 0;
40
- var key = 0;
41
- var path = "";
42
- var isEscaped = false;
43
- while (i < str.length) {
44
- var prefix = "";
45
- var name = "";
46
- var pattern = "";
47
- if (str[i] === "\\") {
48
- i++;
49
- path += str[i++];
50
- isEscaped = true;
20
+ function ht(r, t) {
21
+ t === void 0 && (t = {});
22
+ for (var e, n, i = [], s = (e = t.delimiter, e ?? z), c = (n = t.whitelist, n ?? void 0), o = 0, u = 0, a = "", h = !1; o < r.length; ) {
23
+ var g = "", m = "", f = "";
24
+ if (r[o] === "\\") {
25
+ o++, a += r[o++], h = !0;
51
26
  continue;
52
27
  }
53
- if (str[i] === ":") {
54
- while (++i < str.length) {
55
- var code = str.charCodeAt(i);
28
+ if (r[o] === ":") {
29
+ for (; ++o < r.length; ) {
30
+ var d = r.charCodeAt(o);
56
31
  if (
57
32
  // `0-9`
58
- code >= 48 && code <= 57 || // `A-Z`
59
- code >= 65 && code <= 90 || // `a-z`
60
- code >= 97 && code <= 122 || // `_`
61
- code === 95
33
+ d >= 48 && d <= 57 || // `A-Z`
34
+ d >= 65 && d <= 90 || // `a-z`
35
+ d >= 97 && d <= 122 || // `_`
36
+ d === 95
62
37
  ) {
63
- name += str[i];
38
+ m += r[o];
64
39
  continue;
65
40
  }
66
41
  break;
67
42
  }
68
- if (!name)
69
- i--;
43
+ m || o--;
70
44
  }
71
- if (str[i] === "(") {
72
- var end = balanced("(", ")", str, i);
73
- if (end > -1) {
74
- pattern = str.slice(i + 1, end - 1);
75
- i = end;
76
- if (pattern[0] === "?") {
45
+ if (r[o] === "(") {
46
+ var w = ut("(", ")", r, o);
47
+ if (w > -1) {
48
+ if (f = r.slice(o + 1, w - 1), o = w, f[0] === "?")
77
49
  throw new TypeError("Path pattern must be a capturing group");
78
- }
79
- if (/\((?=[^?])/.test(pattern)) {
80
- var validPattern = pattern.replace(/\((?=[^?])/, "(?:");
81
- throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + validPattern + ")");
50
+ if (/\((?=[^?])/.test(f)) {
51
+ var p = f.replace(/\((?=[^?])/, "(?:");
52
+ throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + p + ")");
82
53
  }
83
54
  }
84
55
  }
85
- if (name === "" && pattern === "") {
86
- path += str[i++];
87
- isEscaped = false;
56
+ if (m === "" && f === "") {
57
+ a += r[o++], h = !1;
88
58
  continue;
89
59
  }
90
- if (path.length && !isEscaped) {
91
- var char = path[path.length - 1];
92
- var matches = whitelist ? whitelist.indexOf(char) > -1 : true;
93
- if (matches) {
94
- prefix = char;
95
- path = path.slice(0, -1);
96
- }
97
- }
98
- if (path.length) {
99
- tokens.push(path);
100
- path = "";
101
- }
102
- var repeat = str[i] === "+" || str[i] === "*";
103
- var optional = str[i] === "?" || str[i] === "*";
104
- var delimiter = prefix || defaultDelimiter;
105
- if (repeat || optional)
106
- i++;
107
- tokens.push({
108
- name: name || key++,
109
- prefix,
110
- delimiter,
111
- optional,
112
- repeat,
113
- pattern: pattern || "[^" + escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter) + "]+?"
60
+ if (a.length && !h) {
61
+ var y = a[a.length - 1], l = c ? c.indexOf(y) > -1 : !0;
62
+ l && (g = y, a = a.slice(0, -1));
63
+ }
64
+ a.length && (i.push(a), a = "");
65
+ var v = r[o] === "+" || r[o] === "*", E = r[o] === "?" || r[o] === "*", b = g || s;
66
+ (v || E) && o++, i.push({
67
+ name: m || u++,
68
+ prefix: g,
69
+ delimiter: b,
70
+ optional: E,
71
+ repeat: v,
72
+ pattern: f || "[^" + R(b === s ? b : b + s) + "]+?"
114
73
  });
115
74
  }
116
- if (path.length)
117
- tokens.push(path);
118
- return tokens;
75
+ return a.length && i.push(a), i;
119
76
  }
120
- function escapeString(str) {
121
- return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
77
+ function R(r) {
78
+ return r.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
122
79
  }
123
- function flags(options) {
124
- return options && options.sensitive ? "" : "i";
80
+ function J(r) {
81
+ return r && r.sensitive ? "" : "i";
125
82
  }
126
- function regexpToRegexp(path, keys2) {
127
- if (!keys2)
128
- return path;
129
- var groups = path.source.match(/\((?!\?)/g);
130
- if (groups) {
131
- for (var i = 0; i < groups.length; i++) {
132
- keys2.push({
133
- name: i,
83
+ function lt(r, t) {
84
+ if (!t)
85
+ return r;
86
+ var e = r.source.match(/\((?!\?)/g);
87
+ if (e)
88
+ for (var n = 0; n < e.length; n++)
89
+ t.push({
90
+ name: n,
134
91
  prefix: "",
135
92
  delimiter: "",
136
- optional: false,
137
- repeat: false,
93
+ optional: !1,
94
+ repeat: !1,
138
95
  pattern: ""
139
96
  });
140
- }
141
- }
142
- return path;
97
+ return r;
143
98
  }
144
- function arrayToRegexp(paths, keys2, options) {
145
- var parts = paths.map(function(path) {
146
- return pathToRegexp(path, keys2, options).source;
99
+ function ft(r, t, e) {
100
+ var n = r.map(function(i) {
101
+ return Z(i, t, e).source;
147
102
  });
148
- return new RegExp("(?:" + parts.join("|") + ")", flags(options));
103
+ return new RegExp("(?:" + n.join("|") + ")", J(e));
149
104
  }
150
- function stringToRegexp(path, keys2, options) {
151
- return tokensToRegexp(parse(path, options), keys2, options);
105
+ function pt(r, t, e) {
106
+ return dt(ht(r, e), t, e);
152
107
  }
153
- function tokensToRegexp(tokens, keys2, options) {
154
- if (options === void 0) {
155
- options = {};
156
- }
157
- var strict = options.strict, _a = options.start, start = _a === void 0 ? true : _a, _b = options.end, end = _b === void 0 ? true : _b, _c = options.delimiter, delimiter = _c === void 0 ? DEFAULT_DELIMITER : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
158
- return x;
159
- } : _d;
160
- var endsWith = (typeof options.endsWith === "string" ? options.endsWith.split("") : options.endsWith || []).map(escapeString).concat("$").join("|");
161
- var route = start ? "^" : "";
162
- for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
163
- var token = tokens_1[_i];
164
- if (typeof token === "string") {
165
- route += escapeString(encode(token));
166
- } else {
167
- var capture = token.repeat ? "(?:" + token.pattern + ")(?:" + escapeString(token.delimiter) + "(?:" + token.pattern + "))*" : token.pattern;
168
- if (keys2)
169
- keys2.push(token);
170
- if (token.optional) {
171
- if (!token.prefix) {
172
- route += "(" + capture + ")?";
173
- } else {
174
- route += "(?:" + escapeString(token.prefix) + "(" + capture + "))?";
175
- }
176
- } else {
177
- route += escapeString(token.prefix) + "(" + capture + ")";
178
- }
179
- }
180
- }
181
- if (end) {
182
- if (!strict)
183
- route += "(?:" + escapeString(delimiter) + ")?";
184
- route += endsWith === "$" ? "$" : "(?=" + endsWith + ")";
185
- } else {
186
- var endToken = tokens[tokens.length - 1];
187
- var isEndDelimited = typeof endToken === "string" ? endToken[endToken.length - 1] === delimiter : (
108
+ function dt(r, t, e) {
109
+ e === void 0 && (e = {});
110
+ for (var n = e.strict, i = e.start, s = i === void 0 ? !0 : i, c = e.end, o = c === void 0 ? !0 : c, u = e.delimiter, a = u === void 0 ? z : u, h = e.encode, g = h === void 0 ? function(E) {
111
+ return E;
112
+ } : h, m = (typeof e.endsWith == "string" ? e.endsWith.split("") : e.endsWith || []).map(R).concat("$").join("|"), f = s ? "^" : "", d = 0, w = r; d < w.length; d++) {
113
+ var p = w[d];
114
+ if (typeof p == "string")
115
+ f += R(g(p));
116
+ else {
117
+ var y = p.repeat ? "(?:" + p.pattern + ")(?:" + R(p.delimiter) + "(?:" + p.pattern + "))*" : p.pattern;
118
+ t && t.push(p), p.optional ? p.prefix ? f += "(?:" + R(p.prefix) + "(" + y + "))?" : f += "(" + y + ")?" : f += R(p.prefix) + "(" + y + ")";
119
+ }
120
+ }
121
+ if (o)
122
+ n || (f += "(?:" + R(a) + ")?"), f += m === "$" ? "$" : "(?=" + m + ")";
123
+ else {
124
+ var l = r[r.length - 1], v = typeof l == "string" ? l[l.length - 1] === a : (
188
125
  // tslint:disable-next-line
189
- endToken === void 0
126
+ l === void 0
190
127
  );
191
- if (!strict) {
192
- route += "(?:" + escapeString(delimiter) + "(?=" + endsWith + "))?";
193
- }
194
- if (!isEndDelimited) {
195
- route += "(?=" + escapeString(delimiter) + "|" + endsWith + ")";
196
- }
128
+ n || (f += "(?:" + R(a) + "(?=" + m + "))?"), v || (f += "(?=" + R(a) + "|" + m + ")");
197
129
  }
198
- return new RegExp(route, flags(options));
130
+ return new RegExp(f, J(e));
199
131
  }
200
- function pathToRegexp(path, keys2, options) {
201
- if (path instanceof RegExp) {
202
- return regexpToRegexp(path, keys2);
203
- }
204
- if (Array.isArray(path)) {
205
- return arrayToRegexp(path, keys2, options);
206
- }
207
- return stringToRegexp(path, keys2, options);
132
+ function Z(r, t, e) {
133
+ return r instanceof RegExp ? lt(r, t) : Array.isArray(r) ? ft(r, t, e) : pt(r, t, e);
208
134
  }
209
- const assoc = (obj, attr, val) => {
210
- obj[attr] = val;
211
- return obj;
212
- };
213
- const isArray = Array.isArray;
214
- const keys = Object.keys;
215
- const clone = (obj) => obj ? isArray(obj) ? obj.slice(0) : extend({}, obj) : obj;
216
- const pick = (obj, attrs) => attrs.reduce((acc, attr) => obj[attr] === void 0 ? acc : assoc(acc, attr, obj[attr]), {});
217
- const isEqual$1 = (obj1, obj2) => {
218
- const keys1 = keys(obj1);
219
- return keys1.length === keys(obj2).length && keys1.every((key) => obj2[key] === obj1[key]);
220
- };
221
- const extend = Object.assign;
222
- function invariant(condition, format, ...args) {
223
- if (!condition) {
224
- let argIndex = 0;
135
+ const mt = (r, t, e) => (r[t] = e, r), gt = Array.isArray, O = Object.keys, L = (r) => r && (gt(r) ? r.slice(0) : C({}, r)), F = (r, t) => t.reduce((e, n) => r[n] === void 0 ? e : mt(e, n, r[n]), {}), H = (r, t) => {
136
+ const e = O(r);
137
+ return e.length === O(t).length && e.every((n) => t[n] === r[n]);
138
+ }, C = Object.assign;
139
+ function q(r, t, ...e) {
140
+ if (!r) {
141
+ let n = 0;
225
142
  throw new Error(
226
- "Invariant Violation: " + format.replace(/%s/g, () => args[argIndex++])
143
+ "Invariant Violation: " + t.replace(/%s/g, () => e[n++])
227
144
  );
228
145
  }
229
146
  }
230
- function functionDsl(callback) {
231
- let ancestors = [];
232
- const matches = {};
233
- const names = {};
234
- callback(function route(name, options, childrenCallback) {
235
- let routes;
236
- invariant(!names[name], 'Route names must be unique, but route "%s" is declared multiple times', name);
237
- names[name] = true;
238
- if (arguments.length === 1) {
239
- options = {};
240
- }
241
- if (arguments.length === 2 && typeof options === "function") {
242
- childrenCallback = options;
243
- options = {};
244
- }
245
- if (typeof options.path !== "string") {
246
- const parts = name.split(".");
247
- options.path = parts[parts.length - 1];
248
- }
249
- if (childrenCallback) {
250
- ancestors = ancestors.concat(name);
251
- childrenCallback();
252
- routes = pop();
253
- ancestors.splice(-1);
254
- }
255
- push({
256
- name,
257
- path: options.path,
258
- routes: routes || [],
259
- options
147
+ function vt(r) {
148
+ let t = [];
149
+ const e = {}, n = {};
150
+ r(function(u, a, h) {
151
+ let g;
152
+ if (q(!n[u], 'Route names must be unique, but route "%s" is declared multiple times', u), n[u] = !0, arguments.length === 1 && (a = {}), arguments.length === 2 && typeof a == "function" && (h = a, a = {}), typeof a.path != "string") {
153
+ const m = u.split(".");
154
+ a.path = m[m.length - 1];
155
+ }
156
+ h && (t = t.concat(u), h(), g = i(), t.splice(-1)), s({
157
+ name: u,
158
+ path: a.path,
159
+ routes: g || [],
160
+ options: a
260
161
  });
261
162
  });
262
- function pop() {
263
- return matches[currentLevel()] || [];
163
+ function i() {
164
+ return e[c()] || [];
264
165
  }
265
- function push(route) {
266
- const level = currentLevel();
267
- matches[level] = matches[level] || [];
268
- matches[level].push(route);
166
+ function s(o) {
167
+ const u = c();
168
+ e[u] = e[u] || [], e[u].push(o);
269
169
  }
270
- function currentLevel() {
271
- return ancestors.join(".");
170
+ function c() {
171
+ return t.join(".");
272
172
  }
273
- return pop();
173
+ return i();
274
174
  }
275
- function arrayDsl(routes) {
276
- const result = [];
277
- routes.forEach(({ name, children, ...options }) => {
278
- if (typeof options.path !== "string") {
279
- const parts = name.split(".");
280
- options.path = parts[parts.length - 1];
281
- }
282
- result.push(
175
+ function G(r) {
176
+ const t = [];
177
+ return r.forEach(({ name: e, children: n, ...i }) => {
178
+ if (typeof i.path != "string") {
179
+ const s = e.split(".");
180
+ i.path = s[s.length - 1];
181
+ }
182
+ t.push(
283
183
  {
284
- name,
285
- path: options.path,
286
- options,
287
- routes: children ? arrayDsl(children) : []
184
+ name: e,
185
+ path: i.path,
186
+ options: i,
187
+ routes: n ? G(n) : []
288
188
  }
289
189
  );
290
- });
291
- return result;
190
+ }), t;
292
191
  }
293
- const paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g;
294
- const specialParamChars = /[+*?]$/g;
295
- const queryMatcher = /\?(.+)/;
296
- const _compiledPatterns = {};
297
- function compilePattern(pattern) {
298
- if (!(pattern in _compiledPatterns)) {
299
- const paramNames = [];
300
- const re = pathToRegexp(pattern, paramNames);
301
- _compiledPatterns[pattern] = {
302
- matcher: re,
303
- paramNames: paramNames.map((p) => p.name)
192
+ const wt = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g, yt = /[+*?]$/g, X = /\?(.+)/, D = {};
193
+ function Y(r) {
194
+ if (!(r in D)) {
195
+ const t = [], e = Z(r, t);
196
+ D[r] = {
197
+ matcher: e,
198
+ paramNames: t.map((n) => n.name)
304
199
  };
305
200
  }
306
- return _compiledPatterns[pattern];
201
+ return D[r];
307
202
  }
308
- function extractParamNames(pattern) {
309
- return compilePattern(pattern).paramNames;
203
+ function Et(r) {
204
+ return Y(r).paramNames;
310
205
  }
311
- function extractParams(pattern, path) {
312
- const cp = compilePattern(pattern);
313
- const matcher = cp.matcher;
314
- const paramNames = cp.paramNames;
315
- const match = path.match(matcher);
316
- if (!match) {
206
+ function bt(r, t) {
207
+ const e = Y(r), n = e.matcher, i = e.paramNames, s = t.match(n);
208
+ if (!s)
317
209
  return null;
318
- }
319
- const params = {};
320
- paramNames.forEach(function(paramName, index) {
321
- params[paramName] = match[index + 1] && decodeURIComponent(match[index + 1]);
322
- });
323
- return params;
210
+ const c = {};
211
+ return i.forEach(function(o, u) {
212
+ c[o] = s[u + 1] && decodeURIComponent(s[u + 1]);
213
+ }), c;
324
214
  }
325
- function injectParams(pattern, params) {
326
- params = params || {};
327
- return pattern.replace(paramInjectMatcher, function(match, param) {
328
- const paramName = param.replace(specialParamChars, "");
329
- const lastChar = param.slice(-1);
330
- if (lastChar === "?" || lastChar === "*") {
331
- if (params[paramName] == null) {
215
+ function Rt(r, t) {
216
+ return t = t || {}, r.replace(wt, function(e, n) {
217
+ const i = n.replace(yt, ""), s = n.slice(-1);
218
+ if (s === "?" || s === "*") {
219
+ if (t[i] == null)
332
220
  return "";
333
- }
334
- } else {
335
- invariant(
336
- params[paramName] != null,
221
+ } else
222
+ q(
223
+ t[i] != null,
337
224
  "Missing '%s' parameter for path '%s'",
338
- paramName,
339
- pattern
225
+ i,
226
+ r
340
227
  );
341
- }
342
- let paramValue = encodeURIComponent(params[paramName]);
343
- if (lastChar === "*" || lastChar === "+") {
344
- paramValue = paramValue.replaceAll("%2F", "/");
345
- }
346
- return paramValue;
228
+ let c = encodeURIComponent(t[i]);
229
+ return (s === "*" || s === "+") && (c = c.replaceAll("%2F", "/")), c;
347
230
  });
348
231
  }
349
- function extractQuery(qs2, path) {
350
- const match = path.match(queryMatcher);
351
- return match && qs2.parse(match[1]);
232
+ function Tt(r, t) {
233
+ const e = t.match(X);
234
+ return e && r.parse(e[1]);
352
235
  }
353
- function withQuery(qs2, path, query) {
354
- const queryString = qs2.stringify(query, { indices: false });
355
- if (queryString) {
356
- return withoutQuery(path) + "?" + queryString;
357
- }
358
- return path;
236
+ function Lt(r, t, e) {
237
+ const n = r.stringify(e, { indices: !1 });
238
+ return n ? tt(t) + "?" + n : t;
359
239
  }
360
- function withoutQuery(path) {
361
- return path.replace(queryMatcher, "");
240
+ function tt(r) {
241
+ return r.replace(X, "");
362
242
  }
363
- function bindEvent(el, type, fn) {
364
- el.addEventListener(type, fn);
365
- return fn;
243
+ function et(r, t, e) {
244
+ return r.addEventListener(t, e), e;
366
245
  }
367
- function unbindEvent(el, type, fn) {
368
- el.removeEventListener(type, fn);
369
- return fn;
246
+ function rt(r, t, e) {
247
+ return r.removeEventListener(t, e), e;
370
248
  }
371
- class History {
249
+ class Ct {
372
250
  constructor() {
373
- this.handlers = [];
374
- this.checkUrl = this.checkUrl.bind(this);
375
- this.location = window.location;
376
- this.history = window.history;
251
+ this.handlers = [], this.checkUrl = this.checkUrl.bind(this), this.location = window.location, this.history = window.history;
377
252
  }
378
253
  // Set up all inheritable **Backbone.History** properties and methods.
379
254
  // Are we at the app root?
@@ -383,49 +258,32 @@ class History {
383
258
  // Gets the true hash value. Cannot use location.hash directly due to bug
384
259
  // in Firefox where location.hash will always be decoded.
385
260
  getHash() {
386
- const match = this.location.href.match(/#(.*)$/);
387
- return match ? match[1] : "";
261
+ const t = this.location.href.match(/#(.*)$/);
262
+ return t ? t[1] : "";
388
263
  }
389
264
  // Get the cross-browser normalized URL fragment, either from the URL,
390
265
  // the hash, or the override.
391
- getFragment(fragment, forcePushState) {
392
- if (fragment == null) {
393
- if (this._hasPushState || !this._wantsHashChange || forcePushState) {
394
- fragment = decodeURI(this.location.pathname + this.location.search);
395
- const root = this.root.replace(trailingSlash, "");
396
- if (!fragment.indexOf(root))
397
- fragment = fragment.slice(root.length);
398
- } else {
399
- fragment = this.getHash();
400
- }
401
- }
402
- return fragment.replace(routeStripper, "");
266
+ getFragment(t, e) {
267
+ if (t == null)
268
+ if (this._hasPushState || !this._wantsHashChange || e) {
269
+ t = decodeURI(this.location.pathname + this.location.search);
270
+ const n = this.root.replace(St, "");
271
+ t.indexOf(n) || (t = t.slice(n.length));
272
+ } else
273
+ t = this.getHash();
274
+ return t.replace(B, "");
403
275
  }
404
276
  // Start the hash change handling, returning `true` if the current URL matches
405
277
  // an existing route, and `false` otherwise.
406
- start(options = {}) {
407
- this.started = true;
408
- this.options = extend({ root: "/" }, options);
409
- this.location = this.options.location || this.location;
410
- this.history = this.options.history || this.history;
411
- this.root = this.options.root;
412
- this._wantsHashChange = this.options.hashChange !== false;
413
- this._wantsPushState = !!this.options.pushState;
414
- this._hasPushState = this._wantsPushState;
415
- const fragment = this.getFragment();
416
- this.root = `/${this.root}/`.replace(rootStripper, "/");
417
- bindEvent(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl);
418
- this.fragment = fragment;
419
- const loc = this.location;
278
+ start(t = {}) {
279
+ this.started = !0, this.options = C({ root: "/" }, t), this.location = this.options.location || this.location, this.history = this.options.history || this.history, this.root = this.options.root, this._wantsHashChange = this.options.hashChange !== !1, this._wantsPushState = !!this.options.pushState, this._hasPushState = this._wantsPushState;
280
+ const e = this.getFragment();
281
+ this.root = `/${this.root}/`.replace($t, "/"), et(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.fragment = e;
282
+ const n = this.location;
420
283
  if (this._wantsHashChange && this._wantsPushState) {
421
- if (!this._hasPushState && !this.atRoot()) {
422
- this.fragment = this.getFragment(null, true);
423
- this.location.replace(`${this.root}#${this.fragment}`);
424
- return true;
425
- } else if (this._hasPushState && this.atRoot() && loc.hash) {
426
- this.fragment = this.getHash().replace(routeStripper, "");
427
- this.history.replaceState({}, document.title, this.root + this.fragment);
428
- }
284
+ if (!this._hasPushState && !this.atRoot())
285
+ return this.fragment = this.getFragment(null, !0), this.location.replace(`${this.root}#${this.fragment}`), !0;
286
+ this._hasPushState && this.atRoot() && n.hash && (this.fragment = this.getHash().replace(B, ""), this.history.replaceState({}, document.title, this.root + this.fragment));
429
287
  }
430
288
  if (!this.options.silent)
431
289
  return this.loadUrl();
@@ -433,32 +291,27 @@ class History {
433
291
  // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
434
292
  // but possibly useful for unit testing Routers.
435
293
  stop() {
436
- unbindEvent(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl);
437
- this.started = false;
294
+ rt(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.started = !1;
438
295
  }
439
296
  // Add a route to be tested when the fragment changes. Routes added later
440
297
  // may override previous routes.
441
- route(route, callback) {
442
- this.handlers.unshift({ route, callback });
298
+ route(t, e) {
299
+ this.handlers.unshift({ route: t, callback: e });
443
300
  }
444
301
  // Checks the current URL to see if it has changed, and if it has,
445
302
  // calls `loadUrl`.
446
303
  checkUrl() {
447
- const current = this.getFragment();
448
- if (current === this.fragment)
449
- return false;
304
+ if (this.getFragment() === this.fragment)
305
+ return !1;
450
306
  this.loadUrl();
451
307
  }
452
308
  // Attempt to load the current URL fragment. If a route succeeds with a
453
309
  // match, returns `true`. If no defined routes matches the fragment,
454
310
  // returns `false`.
455
- loadUrl(fragment) {
456
- fragment = this.fragment = this.getFragment(fragment);
457
- return this.handlers.some((handler) => {
458
- if (handler.route.test(fragment)) {
459
- handler.callback(fragment);
460
- return true;
461
- }
311
+ loadUrl(t) {
312
+ return t = this.fragment = this.getFragment(t), this.handlers.some((e) => {
313
+ if (e.route.test(t))
314
+ return e.callback(t), !0;
462
315
  });
463
316
  }
464
317
  // Save a fragment into the hash history, or replace the URL state if the
@@ -468,67 +321,52 @@ class History {
468
321
  // The options object can contain `trigger: true` if you wish to have the
469
322
  // route callback be fired (not usually desirable), or `replace: true`, if
470
323
  // you wish to modify the current URL without adding an entry to the history.
471
- update(fragment, options) {
324
+ update(t, e) {
472
325
  if (!this.started)
473
- return false;
474
- if (!options || options === true)
475
- options = { trigger: !!options };
476
- let url = this.root + (fragment = this.getFragment(fragment || ""));
477
- fragment = fragment.replace(pathStripper, "");
478
- if (this.fragment === fragment)
479
- return;
480
- this.fragment = fragment;
481
- if (fragment === "" && url !== "/")
482
- url = url.slice(0, -1);
483
- if (this._hasPushState) {
484
- this.history[options.replace ? "replaceState" : "pushState"]({}, document.title, url);
485
- } else if (this._wantsHashChange) {
486
- this._updateHash(this.location, fragment, options.replace);
487
- } else {
488
- return this.location.assign(url);
326
+ return !1;
327
+ (!e || e === !0) && (e = { trigger: !!e });
328
+ let n = this.root + (t = this.getFragment(t || ""));
329
+ if (t = t.replace(Ut, ""), this.fragment !== t) {
330
+ if (this.fragment = t, t === "" && n !== "/" && (n = n.slice(0, -1)), this._hasPushState)
331
+ this.history[e.replace ? "replaceState" : "pushState"]({}, document.title, n);
332
+ else if (this._wantsHashChange)
333
+ this._updateHash(this.location, t, e.replace);
334
+ else
335
+ return this.location.assign(n);
336
+ if (e.trigger)
337
+ return this.loadUrl(t);
489
338
  }
490
- if (options.trigger)
491
- return this.loadUrl(fragment);
492
339
  }
493
340
  // Update the hash location, either replacing the current entry, or adding
494
341
  // a new one to the browser history.
495
- _updateHash(location, fragment, replace) {
496
- if (replace) {
497
- const href = location.href.replace(/(javascript:|#).*$/, "");
498
- location.replace(`${href}#${fragment}`);
499
- } else {
500
- location.hash = `#${fragment}`;
501
- }
342
+ _updateHash(t, e, n) {
343
+ if (n) {
344
+ const i = t.href.replace(/(javascript:|#).*$/, "");
345
+ t.replace(`${i}#${e}`);
346
+ } else
347
+ t.hash = `#${e}`;
502
348
  }
503
349
  // add some features to History
504
350
  // a generic callback for any changes
505
- onChange(callback) {
506
- this.route(/^(.*?)$/, callback);
351
+ onChange(t) {
352
+ this.route(/^(.*?)$/, t);
507
353
  }
508
354
  // checks if the browser has pushstate support
509
355
  hasPushState() {
510
- if (!this.started) {
356
+ if (!this.started)
511
357
  throw new Error("only available after LocationBar.start()");
512
- }
513
358
  return this._hasPushState;
514
359
  }
515
360
  }
516
- const routeStripper = /^[#\/]|\s+$/g;
517
- const rootStripper = /^\/+|\/+$/g;
518
- const trailingSlash = /\/$/;
519
- const pathStripper = /#.*$/;
520
- class BrowserLocation {
521
- constructor(options = {}) {
522
- this.path = options.path || "";
523
- this.options = extend({
524
- pushState: false,
361
+ const B = /^[#\/]|\s+$/g, $t = /^\/+|\/+$/g, St = /\/$/, Ut = /#.*$/;
362
+ class xt {
363
+ constructor(t = {}) {
364
+ this.path = t.path || "", this.options = C({
365
+ pushState: !1,
525
366
  root: "/"
526
- }, options);
527
- this.locationBar = new History();
528
- this.locationBar.onChange((path) => {
529
- this.handleURL(`/${path || ""}`);
530
- });
531
- this.locationBar.start(options);
367
+ }, t), this.locationBar = new Ct(), this.locationBar.onChange((e) => {
368
+ this.handleURL(`/${e || ""}`);
369
+ }), this.locationBar.start(t);
532
370
  }
533
371
  /**
534
372
  * Get the current URL
@@ -540,46 +378,33 @@ class BrowserLocation {
540
378
  * Set the current URL without triggering any events
541
379
  * back to the router. Add a new entry in browser's history.
542
380
  */
543
- setURL(path, options = {}) {
544
- if (this.path !== path) {
545
- this.path = path;
546
- this.locationBar.update(path, extend({ trigger: true }, options));
547
- }
381
+ setURL(t, e = {}) {
382
+ this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0 }, e)));
548
383
  }
549
384
  /**
550
385
  * Set the current URL without triggering any events
551
386
  * back to the router. Replace the latest entry in broser's history.
552
387
  */
553
- replaceURL(path, options = {}) {
554
- if (this.path !== path) {
555
- this.path = path;
556
- this.locationBar.update(path, extend({ trigger: true, replace: true }, options));
557
- }
388
+ replaceURL(t, e = {}) {
389
+ this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0, replace: !0 }, e)));
558
390
  }
559
391
  /**
560
392
  * Setup a URL change handler
561
393
  * @param {Function} callback
562
394
  */
563
- onChange(callback) {
564
- this.changeCallback = callback;
395
+ onChange(t) {
396
+ this.changeCallback = t;
565
397
  }
566
398
  /**
567
399
  * Given a path, generate a URL appending root
568
400
  * if pushState is used and # if hash state is used
569
401
  */
570
- formatURL(path) {
402
+ formatURL(t) {
571
403
  if (this.locationBar.hasPushState()) {
572
- let rootURL = this.options.root;
573
- if (path !== "") {
574
- rootURL = rootURL.replace(/\/$/, "");
575
- }
576
- return rootURL + path;
577
- } else {
578
- if (path[0] === "/") {
579
- path = path.substr(1);
580
- }
581
- return `#${path}`;
582
- }
404
+ let e = this.options.root;
405
+ return t !== "" && (e = e.replace(/\/$/, "")), e + t;
406
+ } else
407
+ return t[0] === "/" && (t = t.substr(1)), `#${t}`;
583
408
  }
584
409
  /**
585
410
  * When we use pushState with a custom root option,
@@ -589,12 +414,8 @@ class BrowserLocation {
589
414
  * - LocationBar expects all .update() calls to be called without root
590
415
  * - this method is public so that we could dispatch URLs without root in router
591
416
  */
592
- removeRoot(url) {
593
- if (this.options.pushState && this.options.root && this.options.root !== "/") {
594
- return url.replace(this.options.root, "");
595
- } else {
596
- return url;
597
- }
417
+ removeRoot(t) {
418
+ return this.options.pushState && this.options.root && this.options.root !== "/" ? t.replace(this.options.root, "") : t;
598
419
  }
599
420
  /**
600
421
  * Stop listening to URL changes and link clicks
@@ -611,298 +432,182 @@ class BrowserLocation {
611
432
 
612
433
  @private
613
434
  */
614
- handleURL(url) {
615
- this.path = url;
616
- if (this.changeCallback) {
617
- this.changeCallback(url);
618
- }
435
+ handleURL(t) {
436
+ this.path = t, this.changeCallback && this.changeCallback(t);
619
437
  }
620
438
  }
621
- class MemoryLocation {
622
- constructor({ path }) {
623
- this.path = path || "";
439
+ class Pt {
440
+ constructor({ path: t }) {
441
+ this.path = t || "";
624
442
  }
625
443
  getURL() {
626
444
  return this.path;
627
445
  }
628
- setURL(path, options) {
629
- if (this.path !== path) {
630
- this.path = path;
631
- this.handleURL(this.getURL(), options);
632
- }
446
+ setURL(t, e) {
447
+ this.path !== t && (this.path = t, this.handleURL(this.getURL(), e));
633
448
  }
634
- replaceURL(path, options) {
635
- if (this.path !== path) {
636
- this.setURL(path, options);
637
- }
449
+ replaceURL(t, e) {
450
+ this.path !== t && this.setURL(t, e);
638
451
  }
639
- onChange(callback) {
640
- this.changeCallback = callback;
452
+ onChange(t) {
453
+ this.changeCallback = t;
641
454
  }
642
- handleURL(url, options = {}) {
643
- this.path = url;
644
- options = extend({ trigger: true }, options);
645
- if (this.changeCallback && options.trigger) {
646
- this.changeCallback(url);
647
- }
455
+ handleURL(t, e = {}) {
456
+ this.path = t, e = C({ trigger: !0 }, e), this.changeCallback && e.trigger && this.changeCallback(t);
648
457
  }
649
- removeRoot(url) {
650
- return url;
458
+ removeRoot(t) {
459
+ return t;
651
460
  }
652
- formatURL(url) {
653
- return url;
461
+ formatURL(t) {
462
+ return t;
654
463
  }
655
464
  }
656
- const TRANSITION_REDIRECTED = "TransitionRedirected";
657
- const TRANSITION_CANCELLED = "TransitionCancelled";
658
- function runError(router2, transition2, err) {
659
- router2.middleware.forEach((m) => {
660
- m.error && m.error(transition2, err);
465
+ const N = "TransitionRedirected", P = "TransitionCancelled";
466
+ function W(r, t, e) {
467
+ r.middleware.forEach((n) => {
468
+ n.error && n.error(t, e);
661
469
  });
662
470
  }
663
- function transition(options) {
664
- options = options || {};
665
- const router2 = options.router;
666
- const log = router2.log;
667
- const logError = router2.logError;
668
- const path = options.path;
669
- const match = options.match;
670
- const routes = match.routes;
671
- const params = match.params;
672
- const pathname = match.pathname;
673
- const query = match.query;
674
- const id = options.id;
675
- const startTime = Date.now();
676
- log("---");
677
- log("Transition #" + id, "to", path);
678
- log("Transition #" + id, "routes:", routes.map((r) => r.name));
679
- log("Transition #" + id, "params:", params);
680
- log("Transition #" + id, "query:", query);
681
- let resolve2, reject;
682
- const promise = new Promise(function(res, rej) {
683
- resolve2 = res;
684
- reject = rej;
471
+ function k(r) {
472
+ r = r || {};
473
+ const t = r.router, e = t.log, n = t.logError, i = r.path, s = r.match, c = s.routes, o = s.params, u = s.pathname, a = s.query, h = r.id, g = Date.now();
474
+ e("---"), e("Transition #" + h, "to", i), e("Transition #" + h, "routes:", c.map((l) => l.name)), e("Transition #" + h, "params:", o), e("Transition #" + h, "query:", a);
475
+ let m, f;
476
+ const d = new Promise(function(l, v) {
477
+ m = l, f = v;
685
478
  });
686
- promise.then(function() {
687
- log("Transition #" + id, "completed in", Date.now() - startTime + "ms");
688
- }).catch(function(err) {
689
- if (err.type !== TRANSITION_REDIRECTED && err.type !== TRANSITION_CANCELLED) {
690
- log("Transition #" + id, "FAILED");
691
- logError(err);
692
- }
479
+ d.then(function() {
480
+ e("Transition #" + h, "completed in", Date.now() - g + "ms");
481
+ }).catch(function(l) {
482
+ l.type !== N && l.type !== P && (e("Transition #" + h, "FAILED"), n(l));
693
483
  });
694
- let cancelled = false;
695
- const transition2 = {
696
- id,
484
+ let w = !1;
485
+ const p = {
486
+ id: h,
697
487
  prev: {
698
- routes: clone(router2.state.routes) || [],
699
- path: router2.state.path || "",
700
- pathname: router2.state.pathname || "",
701
- params: clone(router2.state.params) || {},
702
- query: clone(router2.state.query) || {}
488
+ routes: L(t.state.routes) || [],
489
+ path: t.state.path || "",
490
+ pathname: t.state.pathname || "",
491
+ params: L(t.state.params) || {},
492
+ query: L(t.state.query) || {}
703
493
  },
704
- routes: clone(routes),
705
- path,
706
- pathname,
707
- params: clone(params),
708
- query: clone(query),
709
- redirectTo: function(...args) {
710
- return router2.transitionTo(...args);
494
+ routes: L(c),
495
+ path: i,
496
+ pathname: u,
497
+ params: L(o),
498
+ query: L(a),
499
+ redirectTo: function(...l) {
500
+ return t.transitionTo(...l);
711
501
  },
712
502
  retry: function() {
713
- return router2.transitionTo(path);
503
+ return t.transitionTo(i);
714
504
  },
715
- cancel: function(err) {
716
- if (router2.state.activeTransition !== transition2) {
717
- return;
718
- }
719
- if (transition2.isCancelled) {
720
- return;
721
- }
722
- router2.state.activeTransition = null;
723
- transition2.isCancelled = true;
724
- cancelled = true;
725
- if (!err) {
726
- err = new Error(TRANSITION_CANCELLED);
727
- err.type = TRANSITION_CANCELLED;
728
- }
729
- if (err.type === TRANSITION_CANCELLED) {
730
- log("Transition #" + id, "cancelled");
731
- }
732
- if (err.type === TRANSITION_REDIRECTED) {
733
- log("Transition #" + id, "redirected");
734
- }
735
- router2.middleware.forEach((m) => {
736
- m.cancel && m.cancel(transition2, err);
737
- });
738
- reject(err);
505
+ cancel: function(l) {
506
+ t.state.activeTransition === p && (p.isCancelled || (t.state.activeTransition = null, p.isCancelled = !0, w = !0, l || (l = new Error(P), l.type = P), l.type === P && e("Transition #" + h, "cancelled"), l.type === N && e("Transition #" + h, "redirected"), t.middleware.forEach((v) => {
507
+ v.cancel && v.cancel(p, l);
508
+ }), f(l)));
739
509
  },
740
510
  followRedirects: function() {
741
- return promise.catch(function(reason) {
742
- if (router2.state.activeTransition) {
743
- return router2.state.activeTransition.followRedirects();
744
- }
745
- return Promise.reject(reason);
511
+ return d.catch(function(l) {
512
+ return t.state.activeTransition ? t.state.activeTransition.followRedirects() : Promise.reject(l);
746
513
  });
747
514
  },
748
- then: promise.then.bind(promise),
749
- catch: promise.catch.bind(promise)
515
+ then: d.then.bind(d),
516
+ catch: d.catch.bind(d)
750
517
  };
751
- router2.middleware.forEach((m) => {
752
- m.before && m.before(transition2);
518
+ t.middleware.forEach((l) => {
519
+ l.before && l.before(p);
753
520
  });
754
- function callNext(i, prevResult) {
755
- let middleware;
756
- let middlewareName;
757
- if (cancelled) {
758
- return;
759
- }
760
- if (i < router2.middleware.length) {
761
- middleware = router2.middleware[i];
762
- middlewareName = middleware.name || "anonymous";
763
- log("Transition #" + id, "resolving middleware:", middlewareName);
764
- let middlewarePromise;
765
- try {
766
- middlewarePromise = middleware.resolve ? middleware.resolve(transition2, prevResult) : prevResult;
767
- invariant(transition2 !== middlewarePromise, "Middleware %s returned a transition which resulted in a deadlock", middlewareName);
768
- } catch (err) {
769
- router2.state.activeTransition = null;
770
- runError(router2, transition2, err);
771
- return reject(err);
772
- }
773
- Promise.resolve(middlewarePromise).then(function(result) {
774
- callNext(i + 1, result);
775
- }).catch(function(err) {
776
- log("Transition #" + id, "resolving middleware:", middlewareName, "FAILED");
777
- router2.state.activeTransition = null;
778
- runError(router2, transition2, err);
779
- reject(err);
780
- });
781
- } else {
782
- router2.state = {
783
- activeTransition: null,
784
- routes,
785
- path,
786
- pathname,
787
- params,
788
- query
789
- };
790
- router2.middleware.forEach((m) => {
791
- m.done && m.done(transition2);
792
- });
793
- resolve2();
794
- }
795
- }
796
- if (!options.noop) {
797
- Promise.resolve().then(() => callNext(0));
798
- } else {
799
- resolve2();
800
- }
801
- if (options.noop) {
802
- transition2.noop = true;
803
- }
804
- return transition2;
521
+ function y(l, v) {
522
+ let E, b;
523
+ if (!w)
524
+ if (l < t.middleware.length) {
525
+ E = t.middleware[l], b = E.name || "anonymous", e("Transition #" + h, "resolving middleware:", b);
526
+ let S;
527
+ try {
528
+ S = E.resolve ? E.resolve(p, v) : v, q(p !== S, "Middleware %s returned a transition which resulted in a deadlock", b);
529
+ } catch (T) {
530
+ return t.state.activeTransition = null, W(t, p, T), f(T);
531
+ }
532
+ Promise.resolve(S).then(function(T) {
533
+ y(l + 1, T);
534
+ }).catch(function(T) {
535
+ e("Transition #" + h, "resolving middleware:", b, "FAILED"), t.state.activeTransition = null, W(t, p, T), f(T);
536
+ });
537
+ } else
538
+ t.state = {
539
+ activeTransition: null,
540
+ routes: c,
541
+ path: i,
542
+ pathname: u,
543
+ params: o,
544
+ query: a
545
+ }, t.middleware.forEach((S) => {
546
+ S.done && S.done(p);
547
+ }), m();
548
+ }
549
+ return r.noop ? m() : Promise.resolve().then(() => y(0)), r.noop && (p.noop = !0), p;
805
550
  }
806
- function intercept(el, fn) {
807
- const cb = delegate(el, "click", function(e, el2) {
808
- if (clickable(e, el2))
809
- fn(e, el2);
551
+ function _t(r, t) {
552
+ const e = Ot(r, "click", function(n, i) {
553
+ It(n, i) && t(n, i);
810
554
  });
811
- return function dispose() {
812
- undelegate(el, "click", cb);
555
+ return function() {
556
+ Nt(r, "click", e);
813
557
  };
814
558
  }
815
- function link(element) {
816
- var _a;
817
- element = { parentNode: element };
818
- const root = document;
819
- while ((element = element.parentNode) && element !== document) {
820
- if (((_a = element.tagName) == null ? void 0 : _a.toLowerCase()) === "a") {
821
- return element;
822
- }
823
- if (element === root) {
559
+ function At(r) {
560
+ var e;
561
+ r = { parentNode: r };
562
+ const t = document;
563
+ for (; (r = r.parentNode) && r !== document; ) {
564
+ if (((e = r.tagName) == null ? void 0 : e.toLowerCase()) === "a")
565
+ return r;
566
+ if (r === t)
824
567
  return;
825
- }
826
568
  }
827
569
  }
828
- function delegate(el, type, fn) {
829
- return bindEvent(el, type, function(e) {
830
- const target = e.target || e.srcElement;
831
- const el2 = link(target);
832
- if (el2) {
833
- fn(e, el2);
834
- }
570
+ function Ot(r, t, e) {
571
+ return et(r, t, function(n) {
572
+ const i = n.target || n.srcElement, s = At(i);
573
+ s && e(n, s);
835
574
  });
836
575
  }
837
- function undelegate(el, type, fn) {
838
- unbindEvent(el, type, fn);
576
+ function Nt(r, t, e) {
577
+ rt(r, t, e);
839
578
  }
840
- function clickable(e, el) {
841
- if (which(e) !== 1)
579
+ function It(r, t) {
580
+ if (qt(r) !== 1 || r.metaKey || r.ctrlKey || r.shiftKey || r.defaultPrevented || t.target || t.getAttribute("data-bypass") !== null)
842
581
  return;
843
- if (e.metaKey || e.ctrlKey || e.shiftKey)
844
- return;
845
- if (e.defaultPrevented)
846
- return;
847
- if (el.target)
848
- return;
849
- if (el.getAttribute("data-bypass") !== null)
850
- return;
851
- const href = el.getAttribute("href");
852
- if (!href || href.length === 0)
853
- return;
854
- if (href[0] === "#")
855
- return;
856
- if (href.indexOf("http://") === 0 || href.indexOf("https://") === 0)
857
- return;
858
- if (href.indexOf("mailto:") === 0)
859
- return;
860
- if (href.indexOf("javascript:") === 0)
861
- return;
862
- return true;
582
+ const e = t.getAttribute("href");
583
+ if (!(!e || e.length === 0) && e[0] !== "#" && !(e.indexOf("http://") === 0 || e.indexOf("https://") === 0) && e.indexOf("mailto:") !== 0 && e.indexOf("javascript:") !== 0)
584
+ return !0;
863
585
  }
864
- function which(e) {
865
- e = e || window.event;
866
- return e.which === null ? e.button : e.which;
586
+ function qt(r) {
587
+ return r = r || window.event, r.which === null ? r.button : r.which;
867
588
  }
868
- function defineLogger(router2, method, fn) {
869
- if (fn === true)
870
- return;
871
- router2[method] = typeof fn === "function" ? fn : () => {
872
- };
589
+ function Q(r, t, e) {
590
+ e !== !0 && (r[t] = typeof e == "function" ? e : () => {
591
+ });
873
592
  }
874
- var qs = {
875
- parse(querystring) {
876
- return querystring.split("&").reduce((acc, pair) => {
877
- const parts = pair.split("=");
878
- acc[parts[0]] = decodeURIComponent(parts[1]);
879
- return acc;
593
+ var Dt = {
594
+ parse(r) {
595
+ return r.split("&").reduce((t, e) => {
596
+ const n = e.split("=");
597
+ return t[n[0]] = decodeURIComponent(n[1]), t;
880
598
  }, {});
881
599
  },
882
- stringify(params) {
883
- return Object.keys(params).reduce((acc, key) => {
884
- if (params[key] !== void 0) {
885
- acc.push(key + "=" + encodeURIComponent(params[key]));
886
- }
887
- return acc;
888
- }, []).join("&");
600
+ stringify(r) {
601
+ return Object.keys(r).reduce((t, e) => (r[e] !== void 0 && t.push(e + "=" + encodeURIComponent(r[e])), t), []).join("&");
889
602
  }
890
603
  };
891
- class Router {
892
- constructor(options = {}) {
893
- this.nextId = 1;
894
- this.state = {};
895
- this.middleware = [];
896
- this.options = extend({
604
+ class Mt {
605
+ constructor(t = {}) {
606
+ this.nextId = 1, this.state = {}, this.middleware = [], this.options = C({
897
607
  location: "browser",
898
- logError: true,
899
- qs
900
- }, options);
901
- defineLogger(this, "log", this.options.log);
902
- defineLogger(this, "logError", this.options.logError);
903
- if (options.routes) {
904
- this.map(options.routes);
905
- }
608
+ logError: !0,
609
+ qs: Dt
610
+ }, t), Q(this, "log", this.options.log), Q(this, "logError", this.options.logError), t.routes && this.map(t.routes);
906
611
  }
907
612
  /**
908
613
  * Add a middleware
@@ -910,11 +615,9 @@ class Router {
910
615
  * @return {Object} router
911
616
  * @api public
912
617
  */
913
- use(middleware, options = {}) {
914
- const m = typeof middleware === "function" ? { resolve: middleware } : middleware;
915
- typeof options.at === "number" ? this.middleware.splice(options.at, 0, m) : this.middleware.push(m);
916
- m.create && m.create(this);
917
- return this;
618
+ use(t, e = {}) {
619
+ const n = typeof t == "function" ? { resolve: t } : t;
620
+ return typeof e.at == "number" ? this.middleware.splice(e.at, 0, n) : this.middleware.push(n), n.create && n.create(this), this;
918
621
  }
919
622
  /**
920
623
  * Add the route map
@@ -922,59 +625,43 @@ class Router {
922
625
  * @return {Object} router
923
626
  * @api public
924
627
  */
925
- map(routes) {
926
- this.routes = Array.isArray(routes) ? arrayDsl(routes) : functionDsl(routes);
927
- const matchers = this.matchers = [];
928
- const dupes = {};
929
- const abstracts = {};
930
- eachBranch({ routes: this.routes }, [], (routes2) => {
931
- let path = routes2.reduce((memo, r) => (
628
+ map(t) {
629
+ this.routes = Array.isArray(t) ? G(t) : vt(t);
630
+ const e = this.matchers = [], n = {}, i = {};
631
+ s({ routes: this.routes }, [], (c) => {
632
+ let o = c.reduce((a, h) => (
932
633
  // reset if there's a leading slash, otherwise concat
933
634
  // and keep resetting the trailing slash
934
- (r.path[0] === "/" ? r.path : `${memo}/${r.path}`).replace(/\/$/, "")
635
+ (h.path[0] === "/" ? h.path : `${a}/${h.path}`).replace(/\/$/, "")
935
636
  ), "");
936
- if (path === "") {
937
- path = "/";
938
- }
939
- const lastRoute = routes2[routes2.length - 1];
940
- if (lastRoute.options.abstract) {
941
- abstracts[path] = lastRoute.name;
637
+ o === "" && (o = "/");
638
+ const u = c[c.length - 1];
639
+ if (u.options.abstract) {
640
+ i[o] = u.name;
942
641
  return;
943
642
  }
944
- if (lastRoute.path === "") {
945
- let matcher;
946
- matchers.some((m) => {
947
- if (m.path === path) {
948
- matcher = m;
949
- return true;
950
- }
643
+ if (u.path === "") {
644
+ let a;
645
+ e.some((h) => {
646
+ if (h.path === o)
647
+ return a = h, !0;
648
+ }), a ? a.routes = c : i[o] && e.push({
649
+ routes: c,
650
+ name: i[o],
651
+ path: o
951
652
  });
952
- if (matcher) {
953
- matcher.routes = routes2;
954
- } else if (abstracts[path]) {
955
- matchers.push({
956
- routes: routes2,
957
- name: abstracts[path],
958
- path
959
- });
960
- }
961
653
  }
962
- matchers.push({
963
- routes: routes2,
964
- name: lastRoute.name,
965
- path
966
- });
967
- if (dupes[path] && lastRoute.path !== "") {
968
- throw new Error(`Routes ${dupes[path]} and ${lastRoute.name} have the same url path '${path}'`);
969
- }
970
- dupes[path] = lastRoute.name;
654
+ if (e.push({
655
+ routes: c,
656
+ name: u.name,
657
+ path: o
658
+ }), n[o] && u.path !== "")
659
+ throw new Error(`Routes ${n[o]} and ${u.name} have the same url path '${o}'`);
660
+ n[o] = u.name;
971
661
  });
972
- function eachBranch(node, memo, fn) {
973
- node.routes.forEach((route) => {
974
- fn(memo.concat(route));
975
- if (route.routes.length) {
976
- eachBranch(route, memo.concat(route), fn);
977
- }
662
+ function s(c, o, u) {
663
+ c.routes.forEach((a) => {
664
+ u(o.concat(a)), a.routes.length && s(a, o.concat(a), u);
978
665
  });
979
666
  }
980
667
  return this;
@@ -986,18 +673,12 @@ class Router {
986
673
  *
987
674
  * @api public
988
675
  */
989
- listen(path) {
990
- const location = this.location = this.createLocation(path || "");
991
- location.onChange((url) => {
992
- const previousUrl = this.state.path;
993
- this.dispatch(url).catch((err) => {
994
- if (err && err.type === TRANSITION_CANCELLED) {
995
- this.location.replaceURL(previousUrl, { trigger: false });
996
- }
997
- return err;
998
- });
999
- });
1000
- return this.dispatch(location.getURL());
676
+ listen(t) {
677
+ const e = this.location = this.createLocation(t || "");
678
+ return e.onChange((n) => {
679
+ const i = this.state.path;
680
+ this.dispatch(n).catch((s) => (s && s.type === P && this.location.replaceURL(i, { trigger: !1 }), s));
681
+ }), this.dispatch(e.getURL());
1001
682
  }
1002
683
  /**
1003
684
  * Transition to a different route. Passe in url or a route name followed by params and query
@@ -1008,11 +689,8 @@ class Router {
1008
689
  *
1009
690
  * @api public
1010
691
  */
1011
- transitionTo(name, params, query) {
1012
- if (this.state.activeTransition) {
1013
- return this.replaceWith(name, params, query);
1014
- }
1015
- return this.doTransition("setURL", name, params, query);
692
+ transitionTo(t, e, n) {
693
+ return this.state.activeTransition ? this.replaceWith(t, e, n) : this.doTransition("setURL", t, e, n);
1016
694
  }
1017
695
  /**
1018
696
  * Like transitionTo, but doesn't leave an entry in the browser's history,
@@ -1024,8 +702,8 @@ class Router {
1024
702
  *
1025
703
  * @api public
1026
704
  */
1027
- replaceWith(name, params, query) {
1028
- return this.doTransition("replaceURL", name, params, query);
705
+ replaceWith(t, e, n) {
706
+ return this.doTransition("replaceURL", t, e, n);
1029
707
  }
1030
708
  /**
1031
709
  * Create an href
@@ -1036,35 +714,23 @@ class Router {
1036
714
  *
1037
715
  * @api public
1038
716
  */
1039
- generate(name, params, query) {
1040
- invariant(this.location, "call .listen() before using .generate()");
1041
- let matcher;
1042
- query = query || {};
1043
- this.matchers.forEach((m) => {
1044
- if (m.name === name) {
1045
- matcher = m;
1046
- }
1047
- });
1048
- if (!matcher) {
1049
- throw new Error(`No route is named ${name}`);
1050
- }
1051
- const url = withQuery(this.options.qs, injectParams(matcher.path, params), query);
1052
- return this.location.formatURL(url);
717
+ generate(t, e, n) {
718
+ q(this.location, "call .listen() before using .generate()");
719
+ let i;
720
+ if (n = n || {}, this.matchers.forEach((c) => {
721
+ c.name === t && (i = c);
722
+ }), !i)
723
+ throw new Error(`No route is named ${t}`);
724
+ const s = Lt(this.options.qs, Rt(i.path, e), n);
725
+ return this.location.formatURL(s);
1053
726
  }
1054
727
  /**
1055
728
  * Stop listening to URL changes
1056
729
  * @api public
1057
730
  */
1058
731
  destroy() {
1059
- if (this.location && this.location.destroy) {
1060
- this.location.destroy();
1061
- }
1062
- if (this.state.activeTransition) {
1063
- this.state.activeTransition.cancel();
1064
- }
1065
- this.state = {};
1066
- this.middleware.forEach((m) => {
1067
- m.destroy && m.destroy(this);
732
+ this.location && this.location.destroy && this.location.destroy(), this.state.activeTransition && this.state.activeTransition.cancel(), this.state = {}, this.middleware.forEach((t) => {
733
+ t.destroy && t.destroy(this);
1068
734
  });
1069
735
  }
1070
736
  /**
@@ -1076,37 +742,20 @@ class Router {
1076
742
  *
1077
743
  * @api public
1078
744
  */
1079
- isActive(name, params, query, exact) {
1080
- const activeRoutes = this.state.routes || [];
1081
- const activeParams = this.state.params;
1082
- const activeQuery = this.state.query;
1083
- let isActive = activeRoutes.some((route) => route.name === name) && (!exact || activeRoutes[activeRoutes.length - 1].name === name);
1084
- isActive = isActive && (!params || keys(params).every((key) => activeParams[key] === params[key]));
1085
- isActive = isActive && (!query || keys(query).every((key) => activeQuery[key] === query[key]));
1086
- return isActive;
745
+ isActive(t, e, n, i) {
746
+ const s = this.state.routes || [], c = this.state.params, o = this.state.query;
747
+ let u = s.some((a) => a.name === t) && (!i || s[s.length - 1].name === t);
748
+ return u = u && (!e || O(e).every((a) => c[a] === e[a])), u = u && (!n || O(n).every((a) => o[a] === n[a])), u;
1087
749
  }
1088
750
  /**
1089
751
  * @api private
1090
752
  */
1091
- doTransition(method, name, params, query) {
1092
- const previousUrl = this.location.getURL();
1093
- let url = name;
1094
- if (url[0] !== "/") {
1095
- url = this.generate(name, params, query);
1096
- url = url.replace(/^#/, "/");
1097
- }
1098
- if (this.options.pushState) {
1099
- url = this.location.removeRoot(url);
1100
- }
1101
- const transition2 = this.dispatch(url);
1102
- transition2.catch((err) => {
1103
- if (err && err.type === TRANSITION_CANCELLED) {
1104
- this.location.replaceURL(previousUrl, { trigger: false });
1105
- }
1106
- return err;
1107
- });
1108
- this.location[method](url, { trigger: false });
1109
- return transition2;
753
+ doTransition(t, e, n, i) {
754
+ const s = this.location.getURL();
755
+ let c = e;
756
+ c[0] !== "/" && (c = this.generate(e, n, i), c = c.replace(/^#/, "/")), this.options.pushState && (c = this.location.removeRoot(c));
757
+ const o = this.dispatch(c);
758
+ return o.catch((u) => (u && u.type === P && this.location.replaceURL(s, { trigger: !1 }), u)), this.location[t](c, { trigger: !1 }), o;
1110
759
  }
1111
760
  /**
1112
761
  * Match the path against the routes
@@ -1115,67 +764,51 @@ class Router {
1115
764
  *
1116
765
  * @api private
1117
766
  */
1118
- match(path) {
1119
- path = (path || "").replace(/\/$/, "") || "/";
1120
- let params;
1121
- let routes = [];
1122
- const pathWithoutQuery = withoutQuery(path);
1123
- const qs2 = this.options.qs;
1124
- this.matchers.some((matcher) => {
1125
- params = extractParams(matcher.path, pathWithoutQuery);
1126
- if (params) {
1127
- routes = matcher.routes;
1128
- return true;
1129
- }
1130
- });
1131
- return {
1132
- routes: routes.map(descriptor),
1133
- params: params || {},
1134
- pathname: pathWithoutQuery,
1135
- query: extractQuery(qs2, path) || {}
767
+ match(t) {
768
+ t = (t || "").replace(/\/$/, "") || "/";
769
+ let e, n = [];
770
+ const i = tt(t), s = this.options.qs;
771
+ return this.matchers.some((o) => {
772
+ if (e = bt(o.path, i), e)
773
+ return n = o.routes, !0;
774
+ }), {
775
+ routes: n.map(c),
776
+ params: e || {},
777
+ pathname: i,
778
+ query: Tt(s, t) || {}
1136
779
  };
1137
- function descriptor(route) {
780
+ function c(o) {
1138
781
  return {
1139
- name: route.name,
1140
- path: route.path,
1141
- params: pick(params, extractParamNames(route.path)),
1142
- options: clone(route.options)
782
+ name: o.name,
783
+ path: o.path,
784
+ params: F(e, Et(o.path)),
785
+ options: L(o.options)
1143
786
  };
1144
787
  }
1145
788
  }
1146
- dispatch(path) {
1147
- const match = this.match(path);
1148
- const query = match.query;
1149
- const pathname = match.pathname;
1150
- const activeTransition = this.state.activeTransition;
1151
- if (activeTransition && activeTransition.pathname === pathname && isEqual$1(activeTransition.query, query)) {
1152
- return activeTransition;
1153
- }
1154
- if (activeTransition) {
1155
- const err = new Error(TRANSITION_REDIRECTED);
1156
- err.type = TRANSITION_REDIRECTED;
1157
- err.nextPath = path;
1158
- activeTransition.cancel(err);
1159
- }
1160
- if (!activeTransition) {
1161
- if (this.state.pathname === pathname && isEqual$1(this.state.query, query)) {
1162
- return transition({
1163
- id: this.nextId++,
1164
- path,
1165
- match,
1166
- noop: true,
1167
- router: this
1168
- });
1169
- }
1170
- }
1171
- const t = transition({
789
+ dispatch(t) {
790
+ const e = this.match(t), n = e.query, i = e.pathname, s = this.state.activeTransition;
791
+ if (s && s.pathname === i && H(s.query, n))
792
+ return s;
793
+ if (s) {
794
+ const o = new Error(N);
795
+ o.type = N, o.nextPath = t, s.cancel(o);
796
+ }
797
+ if (!s && this.state.pathname === i && H(this.state.query, n))
798
+ return k({
799
+ id: this.nextId++,
800
+ path: t,
801
+ match: e,
802
+ noop: !0,
803
+ router: this
804
+ });
805
+ const c = k({
1172
806
  id: this.nextId++,
1173
- path,
1174
- match,
807
+ path: t,
808
+ match: e,
1175
809
  router: this
1176
810
  });
1177
- this.state.activeTransition = t;
1178
- return t;
811
+ return this.state.activeTransition = c, c;
1179
812
  }
1180
813
  /**
1181
814
  * Create the default location.
@@ -1185,284 +818,198 @@ class Router {
1185
818
  *
1186
819
  * @api private
1187
820
  */
1188
- createLocation(path) {
1189
- const location = this.options.location;
1190
- if (typeof location !== "string") {
1191
- return location;
1192
- }
1193
- if (location === "browser") {
1194
- return new BrowserLocation(pick(this.options, ["pushState", "root"]));
1195
- } else if (location === "memory") {
1196
- return new MemoryLocation({ path });
1197
- } else {
1198
- throw new Error("Location can be `browser`, `memory` or a custom implementation");
1199
- }
1200
- }
1201
- log(...args) {
1202
- console.info(...args);
1203
- }
1204
- logError(...args) {
1205
- console.error(...args);
821
+ createLocation(t) {
822
+ const e = this.options.location;
823
+ if (typeof e != "string")
824
+ return e;
825
+ if (e === "browser")
826
+ return new xt(F(this.options, ["pushState", "root"]));
827
+ if (e === "memory")
828
+ return new Pt({ path: t });
829
+ throw new Error("Location can be `browser`, `memory` or a custom implementation");
830
+ }
831
+ log(...t) {
832
+ console.info(...t);
833
+ }
834
+ logError(...t) {
835
+ console.error(...t);
1206
836
  }
1207
837
  }
1208
- function defaultClickHandler(event, link2, router2) {
1209
- if (!link2.hasAttribute("download") && !link2.hasAttribute("data-phone-number")) {
1210
- event.preventDefault();
1211
- router2.transitionTo(router2.location.removeRoot(link2.getAttribute("href")));
1212
- }
838
+ function jt(r, t, e) {
839
+ !t.hasAttribute("download") && !t.hasAttribute("data-phone-number") && (r.preventDefault(), e.transitionTo(e.location.removeRoot(t.getAttribute("href"))));
1213
840
  }
1214
- function interceptLinks(router2, el = document, clickHandler = defaultClickHandler) {
1215
- return intercept(el, (event, link2) => clickHandler(event, link2, router2));
841
+ function Ft(r, t = document, e = jt) {
842
+ return _t(t, (n, i) => e(n, i, r));
1216
843
  }
1217
- const resolved = Promise.resolve();
1218
- let routeElMap = /* @__PURE__ */ Object.create(null);
1219
- let routeComponentMap = /* @__PURE__ */ Object.create(null);
1220
- let router, rootOutlet, rootOutletEl;
1221
- function parseNumber(value) {
1222
- const n = parseFloat(value);
1223
- const isNumeric = value == n;
1224
- return isNumeric ? n : value;
844
+ const Ht = Promise.resolve();
845
+ let $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), j, U, x;
846
+ function Bt(r) {
847
+ const t = parseFloat(r);
848
+ return r == t ? t : r;
1225
849
  }
1226
- class TransitionValue {
1227
- constructor(key, format) {
1228
- this.key = key;
1229
- this.format = format;
1230
- }
1231
- value(transition2) {
1232
- let result = this.getValue(transition2);
1233
- if (result !== void 0) {
1234
- const format = this.format;
1235
- if (format === "number") {
1236
- result = parseNumber(result);
1237
- } else if (typeof format === "function") {
1238
- result = format(result);
1239
- }
850
+ class Wt {
851
+ constructor(t, e) {
852
+ this.key = t, this.format = e;
853
+ }
854
+ value(t) {
855
+ let e = this.getValue(t);
856
+ if (e !== void 0) {
857
+ const n = this.format;
858
+ n === "number" ? e = Bt(e) : typeof n == "function" && (e = n(e));
1240
859
  }
1241
- return result;
860
+ return e;
1242
861
  }
1243
862
  }
1244
- function create(instance) {
1245
- router = instance;
1246
- rootOutlet = instance.options.outlet;
863
+ function kt(r) {
864
+ j = r, U = r.options.outlet;
1247
865
  }
1248
- function destroy() {
1249
- router = null;
1250
- routeElMap = /* @__PURE__ */ Object.create(null);
1251
- routeComponentMap = /* @__PURE__ */ Object.create(null);
1252
- rootOutletEl = null;
866
+ function Qt() {
867
+ j = null, $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), x = null;
1253
868
  }
1254
- function isEqual(obj1, obj2) {
1255
- const keys1 = Object.keys(obj1);
1256
- return keys1.length === Object.keys(obj2).length && keys1.every((key) => obj2[key] === obj1[key]);
869
+ function Vt(r, t) {
870
+ const e = Object.keys(r);
871
+ return e.length === Object.keys(t).length && e.every((n) => t[n] === r[n]);
1257
872
  }
1258
- function getOutlet(el) {
1259
- const renderRoot = el.shadowRoot || el;
1260
- return renderRoot.querySelector(el.constructor.outlet || "wj-router-outlet");
873
+ function Kt(r) {
874
+ return (r.shadowRoot || r).querySelector(r.constructor.outlet || "wj-router-outlet");
1261
875
  }
1262
- function resolveRootOutlet() {
1263
- if (rootOutletEl)
1264
- return rootOutletEl;
1265
- if (!rootOutlet)
876
+ function zt() {
877
+ if (x)
878
+ return x;
879
+ if (!U)
1266
880
  return document.body;
1267
- rootOutletEl = typeof rootOutlet === "string" ? document.querySelector(rootOutlet) : rootOutlet;
1268
- if (!rootOutletEl) {
1269
- throw new Error(`slick-router(wc): Invalid outlet option ${rootOutlet}`);
1270
- }
1271
- return rootOutletEl;
881
+ if (x = typeof U == "string" ? document.querySelector(U) : U, !x)
882
+ throw new Error(`slick-router(wc): Invalid outlet option ${U}`);
883
+ return x;
1272
884
  }
1273
- function getParentEl(transition2, parentIndex) {
1274
- let parent = transition2.routes[parentIndex];
1275
- while (parent) {
1276
- if (parent.options.component) {
1277
- return routeElMap[parent.name];
1278
- }
1279
- parent = transition2.routes[--parentIndex];
885
+ function Jt(r, t) {
886
+ let e = r.routes[t];
887
+ for (; e; ) {
888
+ if (e.options.component)
889
+ return $[e.name];
890
+ e = r.routes[--t];
1280
891
  }
1281
892
  }
1282
- function getChangingIndex(prevRoutes, currentRoutes) {
1283
- let index, prev, current;
1284
- const count = Math.max(prevRoutes.length, currentRoutes.length);
1285
- for (index = 0; index < count; index++) {
1286
- prev = prevRoutes[index];
1287
- current = currentRoutes[index];
1288
- if (!(prev && current) || prev.name !== current.name || !isEqual(prev.params, current.params)) {
1289
- break;
1290
- }
1291
- }
1292
- return index;
893
+ function Zt(r, t) {
894
+ let e, n, i;
895
+ const s = Math.max(r.length, t.length);
896
+ for (e = 0; e < s && (n = r[e], i = t[e], !(!(n && i) || n.name !== i.name || !Vt(n.params, i.params))); e++)
897
+ ;
898
+ return e;
1293
899
  }
1294
- async function runLifeCycle(transition2, routes, prefix, suffix) {
1295
- for (let i = 0; i < routes.length; i++) {
1296
- let result;
1297
- const { route, el } = routes[i];
1298
- const routeMethod = route.options[`${prefix}${suffix}`];
1299
- if (typeof routeMethod === "function") {
1300
- result = await routeMethod(transition2);
1301
- if (result === false) {
1302
- transition2.cancel();
1303
- }
1304
- }
1305
- if (transition2.isCancelled)
900
+ async function I(r, t, e, n) {
901
+ for (let i = 0; i < t.length; i++) {
902
+ let s;
903
+ const { route: c, el: o } = t[i], u = c.options[`${e}${n}`];
904
+ if (typeof u == "function" && (s = await u(r), s === !1 && r.cancel()), r.isCancelled)
1306
905
  break;
1307
- const elMethod = el && el[`${prefix}Route${suffix}`];
1308
- if (typeof elMethod === "function") {
1309
- result = await elMethod.call(el, transition2);
1310
- if (result === false) {
1311
- transition2.cancel();
1312
- }
1313
- }
1314
- if (transition2.isCancelled)
906
+ const a = o && o[`${e}Route${n}`];
907
+ if (typeof a == "function" && (s = await a.call(o, r), s === !1 && r.cancel()), r.isCancelled)
1315
908
  break;
1316
909
  }
1317
910
  }
1318
- function resolveModule(value) {
1319
- return value && value.__esModule ? value.default : value;
911
+ function Gt(r) {
912
+ return r && r.__esModule ? r.default : r;
1320
913
  }
1321
- async function resolveComponents(routes) {
1322
- const result = [];
1323
- for (const route of routes) {
1324
- let el = route.options.reuse ? routeElMap[route.name] : void 0;
1325
- let Component = route.options.component;
1326
- if (!el && Component) {
1327
- if (typeof Component === "function" && !(Component.prototype instanceof HTMLElement)) {
1328
- Component = routeComponentMap[route.name] || (routeComponentMap[route.name] = resolveModule(await Component(route)));
1329
- }
1330
- el = typeof Component === "string" ? document.createElement(Component) : new Component();
1331
- routeElMap[route.name] = el;
1332
- el.$router = router;
1333
- }
1334
- result.push({ el, route });
914
+ async function Xt(r) {
915
+ const t = [];
916
+ for (const e of r) {
917
+ let n = e.options.reuse ? $[e.name] : void 0, i = e.options.component;
918
+ !n && i && (typeof i == "function" && !(i.prototype instanceof HTMLElement) && (i = M[e.name] || (M[e.name] = Gt(await i(e)))), n = typeof i == "string" ? document.createElement(i) : new i(), $[e.name] = n, n.$router = j), t.push({ el: n, route: e });
1335
919
  }
1336
- return result;
920
+ return t;
1337
921
  }
1338
- function applyProperties(transition2, el, properties) {
1339
- if (properties) {
1340
- Object.keys(properties).forEach((key) => {
1341
- const value = properties[key];
1342
- el[key] = value instanceof TransitionValue ? value.value(transition2) : value;
1343
- });
1344
- }
922
+ function V(r, t, e) {
923
+ e && Object.keys(e).forEach((n) => {
924
+ const i = e[n];
925
+ t[n] = i instanceof Wt ? i.value(r) : i;
926
+ });
1345
927
  }
1346
- const removedEls = /* @__PURE__ */ new WeakSet();
1347
- const outletCurrentEl = /* @__PURE__ */ new WeakMap();
1348
- async function renderElements(transition2, activated, changingIndex) {
1349
- const { path, pathname, routes, params, query } = transition2;
1350
- const routeState = { path, pathname, routes, params, query };
1351
- for (let k = 0; k < changingIndex; k++) {
1352
- const route = transition2.routes[k];
1353
- const el = routeElMap[route.name];
1354
- if (el) {
1355
- el.$route = routeState;
1356
- applyProperties(transition2, el, route.options.properties);
1357
- }
1358
- }
1359
- for (let i = 0; i < activated.length; i++) {
1360
- const { el, route } = activated[i];
1361
- if (el) {
1362
- const parentEl = getParentEl(transition2, changingIndex + i - 1);
1363
- const outletEl = parentEl ? getOutlet(parentEl) : resolveRootOutlet();
1364
- if (outletEl) {
1365
- const currentEl = outletCurrentEl.get(outletEl) || outletEl.firstElementChild;
1366
- if (currentEl) {
1367
- outletEl.removeChild(currentEl);
1368
- removedEls.add(currentEl);
1369
- }
1370
- el.$route = routeState;
1371
- applyProperties(transition2, el, route.options.properties);
1372
- outletEl.appendChild(el);
1373
- outletCurrentEl.set(outletEl, el);
1374
- await (el.updateComplete || resolved);
928
+ const nt = /* @__PURE__ */ new WeakSet(), K = /* @__PURE__ */ new WeakMap();
929
+ async function Yt(r, t, e) {
930
+ const { path: n, pathname: i, routes: s, params: c, query: o } = r, u = { path: n, pathname: i, routes: s, params: c, query: o };
931
+ for (let a = 0; a < e; a++) {
932
+ const h = r.routes[a], g = $[h.name];
933
+ g && (g.$route = u, V(r, g, h.options.properties));
934
+ }
935
+ for (let a = 0; a < t.length; a++) {
936
+ const { el: h, route: g } = t[a];
937
+ if (h) {
938
+ const m = Jt(r, e + a - 1), f = m ? Kt(m) : zt();
939
+ if (f) {
940
+ const d = K.get(f) || f.firstElementChild;
941
+ d && (f.removeChild(d), nt.add(d)), h.$route = u, V(r, h, g.options.properties), f.appendChild(h), K.set(f, h), await (h.updateComplete || Ht);
1375
942
  }
1376
943
  }
1377
944
  }
1378
945
  }
1379
- function updateDOMTree(activated, deactivated) {
1380
- let parentElRemoved;
1381
- for (let routeIndex = deactivated.length - 1; routeIndex >= 0; routeIndex--) {
1382
- const { route, el } = deactivated[routeIndex];
1383
- if (!activated.some(({ route: activeRoute }) => activeRoute.name === route.name)) {
1384
- if (el) {
1385
- if (!parentElRemoved && !removedEls.has(el))
1386
- el.remove();
1387
- parentElRemoved = true;
1388
- }
1389
- routeElMap[route.name] = void 0;
1390
- }
946
+ function te(r, t) {
947
+ let e;
948
+ for (let n = t.length - 1; n >= 0; n--) {
949
+ const { route: i, el: s } = t[n];
950
+ r.some(({ route: c }) => c.name === i.name) || (s && (!e && !nt.has(s) && s.remove(), e = !0), $[i.name] = void 0);
1391
951
  }
1392
952
  }
1393
- async function resolve(transition2) {
1394
- const prevRoutes = transition2.prev.routes;
1395
- const changingIndex = getChangingIndex(prevRoutes, transition2.routes);
1396
- const deactivated = [];
1397
- for (let routeIndex = prevRoutes.length - 1; routeIndex >= changingIndex; routeIndex--) {
1398
- const route = prevRoutes[routeIndex];
1399
- deactivated.push({ el: routeElMap[route.name], route });
1400
- }
1401
- await runLifeCycle(transition2, deactivated, "before", "Leave");
1402
- if (transition2.isCancelled)
1403
- return;
1404
- const activated = await resolveComponents(transition2.routes.slice(changingIndex));
1405
- await runLifeCycle(transition2, activated, "before", "Enter");
1406
- if (transition2.isCancelled)
953
+ async function ee(r) {
954
+ const t = r.prev.routes, e = Zt(t, r.routes), n = [];
955
+ for (let s = t.length - 1; s >= e; s--) {
956
+ const c = t[s];
957
+ n.push({ el: $[c.name], route: c });
958
+ }
959
+ if (await I(r, n, "before", "Leave"), r.isCancelled)
1407
960
  return;
1408
- await renderElements(transition2, activated, changingIndex);
1409
- updateDOMTree(activated, deactivated);
1410
- transition2.activated = activated;
1411
- transition2.deactivated = deactivated;
961
+ const i = await Xt(r.routes.slice(e));
962
+ await I(r, i, "before", "Enter"), !r.isCancelled && (await Yt(r, i, e), te(i, n), r.activated = i, r.deactivated = n);
1412
963
  }
1413
- function done(transition2) {
1414
- runLifeCycle(transition2, transition2.deactivated, "after", "Leave");
1415
- runLifeCycle(transition2, transition2.activated, "after", "Enter");
964
+ function re(r) {
965
+ I(r, r.deactivated, "after", "Leave"), I(r, r.activated, "after", "Enter");
1416
966
  }
1417
- const wc = {
1418
- create,
1419
- destroy,
1420
- resolve,
1421
- done
967
+ const ne = {
968
+ create: kt,
969
+ destroy: Qt,
970
+ resolve: ee,
971
+ done: re
1422
972
  };
1423
- let eventPrefix;
1424
- function trigger(name, detail) {
1425
- window.dispatchEvent(new CustomEvent(`${eventPrefix}${name}`, { detail }));
973
+ let it;
974
+ function _(r, t) {
975
+ window.dispatchEvent(new CustomEvent(`${it}${r}`, { detail: t }));
1426
976
  }
1427
- const events = {
1428
- create: function(router2) {
1429
- eventPrefix = router2.options.eventPrefix || "router-";
977
+ const ie = {
978
+ create: function(r) {
979
+ it = r.options.eventPrefix || "router-";
1430
980
  },
1431
- before: function(transition2) {
1432
- trigger("before:transition", { transition: transition2 });
981
+ before: function(r) {
982
+ _("before:transition", { transition: r });
1433
983
  },
1434
- done: function(transition2) {
1435
- trigger("transition", { transition: transition2 });
984
+ done: function(r) {
985
+ _("transition", { transition: r });
1436
986
  },
1437
- cancel: function(transition2, error) {
1438
- if (error.type !== "TransitionRedirected") {
1439
- trigger("abort", { transition: transition2, error });
1440
- }
987
+ cancel: function(r, t) {
988
+ t.type !== "TransitionRedirected" && _("abort", { transition: r, error: t });
1441
989
  },
1442
- error: function(transition2, error) {
1443
- trigger("abort", { transition: transition2, error });
1444
- trigger("error", { transition: transition2, error });
990
+ error: function(r, t) {
991
+ _("abort", { transition: r, error: t }), _("error", { transition: r, error: t });
1445
992
  }
1446
993
  };
1447
- class Routerx extends WJElement {
994
+ class se extends at {
1448
995
  constructor() {
1449
996
  super();
1450
- __publicField(this, "className", "Routerx");
1451
- __publicField(this, "setBreadcrumb", (transition2) => {
1452
- let breadcrumb = [
1453
- ...transition2.routes.filter((obj) => "breadcrumb" in obj.options).map((b, i) => {
1454
- var _a, _b;
997
+ A(this, "className", "Routerx");
998
+ A(this, "setBreadcrumb", (e) => {
999
+ let n = [
1000
+ ...e.routes.filter((i) => "breadcrumb" in i.options).map((i, s) => {
1001
+ var c, o;
1455
1002
  return {
1456
- name: b.options.breadcrumbPath || b.name,
1457
- text: b.options.breadcrumb instanceof Function ? (_b = (_a = b.options).breadcrumb) == null ? void 0 : _b.call(_a, transition2) : b.options.breadcrumb,
1458
- params: { ...b.params, ...transition2.params },
1459
- path: this.router.generate(b.name, { ...b.params, ...transition2.params })
1003
+ name: i.options.breadcrumbPath || i.name,
1004
+ text: i.options.breadcrumb instanceof Function ? (o = (c = i.options).breadcrumb) == null ? void 0 : o.call(c, e) : i.options.breadcrumb,
1005
+ params: { ...i.params, ...e.params },
1006
+ path: this.router.generate(i.name, { ...i.params, ...e.params })
1460
1007
  };
1461
1008
  })
1462
1009
  ];
1463
- transition2.breadcrumbs = breadcrumb;
1010
+ e.breadcrumbs = n;
1464
1011
  });
1465
- __publicField(this, "resetScrollPosition", (transition2) => {
1012
+ A(this, "resetScrollPosition", (e) => {
1466
1013
  window.scrollTo(0, 0);
1467
1014
  });
1468
1015
  }
@@ -1473,55 +1020,28 @@ class Routerx extends WJElement {
1473
1020
  this.isShadowRoot = "open";
1474
1021
  }
1475
1022
  afterDraw() {
1476
- const htmlString = this.outerHTML;
1477
- const parser = new DOMParser();
1478
- const htmlDocument = parser.parseFromString(htmlString, "text/html");
1479
- const rootElement = htmlDocument.querySelector("wj-router");
1480
- const routes = this.parseElement(rootElement).root;
1481
- this.router = new Router({
1023
+ const e = this.outerHTML, s = new DOMParser().parseFromString(e, "text/html").querySelector("wj-router"), c = this.parseElement(s).root;
1024
+ this.router = new Mt({
1482
1025
  outlet: this.outlet || "wj-router-outlet",
1483
- log: false,
1484
- logError: false,
1026
+ log: !1,
1027
+ logError: !1,
1485
1028
  root: "/",
1486
- pushState: true
1487
- });
1488
- this.router.map(routes);
1489
- this.router.use(this.setBreadcrumb);
1490
- this.router.use(wc);
1491
- this.router.use(routerLinks);
1492
- this.router.use(events);
1493
- this.router.use(this.resetScrollPosition);
1494
- this.router.listen();
1495
- interceptLinks(this.router);
1496
- }
1497
- parseElement(element) {
1498
- const obj = {};
1499
- const attributes = element.attributes;
1500
- for (let i = 0; i < attributes.length; i++) {
1501
- const attributeName = attributes[i].name;
1502
- const attributeValue = attributes[i].value;
1503
- if (attributeName === "component" && attributeValue.indexOf(".js") > -1) {
1504
- obj.component = () => import(attributeValue);
1505
- } else {
1506
- if (attributeName !== "shadow") {
1507
- obj[attributeName] = attributeValue;
1508
- }
1509
- }
1510
- }
1511
- const children = [];
1512
- const childElements = Array.from(element.children);
1513
- childElements.forEach((childElement) => {
1514
- children.push(this.parseElement(childElement));
1515
- });
1516
- if (children.length > 0 && element.tagName === "WJ-ROUTE") {
1517
- obj.children = children;
1518
- } else {
1519
- obj.root = children;
1029
+ pushState: !0
1030
+ }), this.router.map(c), this.router.use(this.setBreadcrumb), this.router.use(ne), this.router.use(ct), this.router.use(ie), this.router.use(this.resetScrollPosition), this.router.listen(), Ft(this.router);
1031
+ }
1032
+ parseElement(e) {
1033
+ const n = {}, i = e.attributes;
1034
+ for (let o = 0; o < i.length; o++) {
1035
+ const u = i[o].name, a = i[o].value;
1036
+ u === "component" && a.indexOf(".js") > -1 ? n.component = () => import(a) : u !== "shadow" && (n[u] = a);
1520
1037
  }
1521
- return obj;
1038
+ const s = [];
1039
+ return Array.from(e.children).forEach((o) => {
1040
+ s.push(this.parseElement(o));
1041
+ }), s.length > 0 && e.tagName === "WJ-ROUTE" ? n.children = s : n.root = s, n;
1522
1042
  }
1523
1043
  }
1524
- customElements.get("wj-router") || window.customElements.define("wj-router", Routerx);
1044
+ customElements.get("wj-router") || window.customElements.define("wj-router", se);
1525
1045
  export {
1526
- Routerx
1046
+ se as Routerx
1527
1047
  };