gemi 0.4.9 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,717 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _i, _n, _t, _e, _s, _l, _o, _d, _p, _g, _H_instances, r_fn, R_fn, b_fn, u_fn, m_fn, a_fn, P_fn, E_fn, S_fn, O_fn, k_fn, x_fn, h_fn, f_fn, T_fn, A_fn, y_fn, w_fn, c_fn, C_fn, _a, _i2, _n2, _t2, _e2, _s2, _l2, _b;
13
- var R = class {
14
- constructor(t, r, n, o, c, l) {
15
- __publicField(this, "type", 3);
16
- __publicField(this, "name", "");
17
- __publicField(this, "prefix", "");
18
- __publicField(this, "value", "");
19
- __publicField(this, "suffix", "");
20
- __publicField(this, "modifier", 3);
21
- this.type = t, this.name = r, this.prefix = n, this.value = o, this.suffix = c, this.modifier = l;
22
- }
23
- hasCustomName() {
24
- return this.name !== "" && typeof this.name != "number";
25
- }
26
- }, be = /[$_\p{ID_Start}]/u, Pe = /[$_\u200C\u200D\p{ID_Continue}]/u, M = ".*";
27
- function Re(e, t) {
28
- return /^[\x00-\x7F]*$/.test(e);
29
- }
30
- function v(e, t = false) {
31
- let r = [], n = 0;
32
- for (; n < e.length; ) {
33
- let o = e[n], c = function(l) {
34
- if (!t) throw new TypeError(l);
35
- r.push({ type: "INVALID_CHAR", index: n, value: e[n++] });
36
- };
37
- if (o === "*") {
38
- r.push({ type: "ASTERISK", index: n, value: e[n++] });
39
- continue;
40
- }
41
- if (o === "+" || o === "?") {
42
- r.push({ type: "OTHER_MODIFIER", index: n, value: e[n++] });
43
- continue;
44
- }
45
- if (o === "\\") {
46
- r.push({ type: "ESCAPED_CHAR", index: n++, value: e[n++] });
47
- continue;
48
- }
49
- if (o === "{") {
50
- r.push({ type: "OPEN", index: n, value: e[n++] });
51
- continue;
52
- }
53
- if (o === "}") {
54
- r.push({ type: "CLOSE", index: n, value: e[n++] });
55
- continue;
56
- }
57
- if (o === ":") {
58
- let l = "", s = n + 1;
59
- for (; s < e.length; ) {
60
- let i = e.substr(s, 1);
61
- if (s === n + 1 && be.test(i) || s !== n + 1 && Pe.test(i)) {
62
- l += e[s++];
63
- continue;
64
- }
65
- break;
66
- }
67
- if (!l) {
68
- c(`Missing parameter name at ${n}`);
69
- continue;
70
- }
71
- r.push({ type: "NAME", index: n, value: l }), n = s;
72
- continue;
73
- }
74
- if (o === "(") {
75
- let l = 1, s = "", i = n + 1, a = false;
76
- if (e[i] === "?") {
77
- c(`Pattern cannot start with "?" at ${i}`);
78
- continue;
79
- }
80
- for (; i < e.length; ) {
81
- if (!Re(e[i])) {
82
- c(`Invalid character '${e[i]}' at ${i}.`), a = true;
83
- break;
84
- }
85
- if (e[i] === "\\") {
86
- s += e[i++] + e[i++];
87
- continue;
88
- }
89
- if (e[i] === ")") {
90
- if (l--, l === 0) {
91
- i++;
92
- break;
93
- }
94
- } else if (e[i] === "(" && (l++, e[i + 1] !== "?")) {
95
- c(`Capturing groups are not allowed at ${i}`), a = true;
96
- break;
97
- }
98
- s += e[i++];
99
- }
100
- if (a) continue;
101
- if (l) {
102
- c(`Unbalanced pattern at ${n}`);
103
- continue;
104
- }
105
- if (!s) {
106
- c(`Missing pattern at ${n}`);
107
- continue;
108
- }
109
- r.push({ type: "REGEX", index: n, value: s }), n = i;
110
- continue;
111
- }
112
- r.push({ type: "CHAR", index: n, value: e[n++] });
113
- }
114
- return r.push({ type: "END", index: n, value: "" }), r;
115
- }
116
- function D(e, t = {}) {
117
- let r = v(e);
118
- t.delimiter ?? (t.delimiter = "/#?"), t.prefixes ?? (t.prefixes = "./");
119
- let n = `[^${S(t.delimiter)}]+?`, o = [], c = 0, l = 0, i = /* @__PURE__ */ new Set(), a = (h) => {
120
- if (l < r.length && r[l].type === h) return r[l++].value;
121
- }, f = () => a("OTHER_MODIFIER") ?? a("ASTERISK"), d = (h) => {
122
- let u = a(h);
123
- if (u !== void 0) return u;
124
- let { type: p, index: A } = r[l];
125
- throw new TypeError(`Unexpected ${p} at ${A}, expected ${h}`);
126
- }, T = () => {
127
- let h = "", u;
128
- for (; u = a("CHAR") ?? a("ESCAPED_CHAR"); ) h += u;
129
- return h;
130
- }, Se = (h) => h, L = t.encodePart || Se, I = "", U = (h) => {
131
- I += h;
132
- }, $ = () => {
133
- I.length && (o.push(new R(3, "", "", L(I), "", 3)), I = "");
134
- }, V = (h, u, p, A, Y) => {
135
- let g = 3;
136
- switch (Y) {
137
- case "?":
138
- g = 1;
139
- break;
140
- case "*":
141
- g = 0;
142
- break;
143
- case "+":
144
- g = 2;
145
- break;
146
- }
147
- if (!u && !p && g === 3) {
148
- U(h);
149
- return;
150
- }
151
- if ($(), !u && !p) {
152
- if (!h) return;
153
- o.push(new R(3, "", "", L(h), "", g));
154
- return;
155
- }
156
- let m;
157
- p ? p === "*" ? m = M : m = p : m = n;
158
- let O = 2;
159
- m === n ? (O = 1, m = "") : m === M && (O = 0, m = "");
160
- let P;
161
- if (u ? P = u : p && (P = c++), i.has(P)) throw new TypeError(`Duplicate name '${P}'.`);
162
- i.add(P), o.push(new R(O, P, L(h), m, L(A), g));
163
- };
164
- for (; l < r.length; ) {
165
- let h = a("CHAR"), u = a("NAME"), p = a("REGEX");
166
- if (!u && !p && (p = a("ASTERISK")), u || p) {
167
- let g = h ?? "";
168
- t.prefixes.indexOf(g) === -1 && (U(g), g = ""), $();
169
- let m = f();
170
- V(g, u, p, "", m);
171
- continue;
172
- }
173
- let A = h ?? a("ESCAPED_CHAR");
174
- if (A) {
175
- U(A);
176
- continue;
177
- }
178
- if (a("OPEN")) {
179
- let g = T(), m = a("NAME"), O = a("REGEX");
180
- !m && !O && (O = a("ASTERISK"));
181
- let P = T();
182
- d("CLOSE");
183
- let xe = f();
184
- V(g, m, O, P, xe);
185
- continue;
186
- }
187
- $(), d("END");
188
- }
189
- return o;
190
- }
191
- function S(e) {
192
- return e.replace(/([.+*?^${}()[\]|/\\])/g, "\\$1");
193
- }
194
- function X(e) {
195
- return e && e.ignoreCase ? "ui" : "u";
196
- }
197
- function Z(e, t, r) {
198
- return F(D(e, r), t, r);
199
- }
200
- function k(e) {
201
- switch (e) {
202
- case 0:
203
- return "*";
204
- case 1:
205
- return "?";
206
- case 2:
207
- return "+";
208
- case 3:
209
- return "";
210
- }
211
- }
212
- function F(e, t, r = {}) {
213
- r.delimiter ?? (r.delimiter = "/#?"), r.prefixes ?? (r.prefixes = "./"), r.sensitive ?? (r.sensitive = false), r.strict ?? (r.strict = false), r.end ?? (r.end = true), r.start ?? (r.start = true), r.endsWith = "";
214
- let n = r.start ? "^" : "";
215
- for (let s of e) {
216
- if (s.type === 3) {
217
- s.modifier === 3 ? n += S(s.value) : n += `(?:${S(s.value)})${k(s.modifier)}`;
218
- continue;
219
- }
220
- t && t.push(s.name);
221
- let i = `[^${S(r.delimiter)}]+?`, a = s.value;
222
- if (s.type === 1 ? a = i : s.type === 0 && (a = M), !s.prefix.length && !s.suffix.length) {
223
- s.modifier === 3 || s.modifier === 1 ? n += `(${a})${k(s.modifier)}` : n += `((?:${a})${k(s.modifier)})`;
224
- continue;
225
- }
226
- if (s.modifier === 3 || s.modifier === 1) {
227
- n += `(?:${S(s.prefix)}(${a})${S(s.suffix)})`, n += k(s.modifier);
228
- continue;
229
- }
230
- n += `(?:${S(s.prefix)}`, n += `((?:${a})(?:`, n += S(s.suffix), n += S(s.prefix), n += `(?:${a}))*)${S(s.suffix)})`, s.modifier === 0 && (n += "?");
231
- }
232
- let o = `[${S(r.endsWith)}]|$`, c = `[${S(r.delimiter)}]`;
233
- if (r.end) return r.strict || (n += `${c}?`), r.endsWith.length ? n += `(?=${o})` : n += "$", new RegExp(n, X(r));
234
- r.strict || (n += `(?:${c}(?=${o}))?`);
235
- let l = false;
236
- if (e.length) {
237
- let s = e[e.length - 1];
238
- s.type === 3 && s.modifier === 3 && (l = r.delimiter.indexOf(s) > -1);
239
- }
240
- return l || (n += `(?=${c}|${o})`), new RegExp(n, X(r));
241
- }
242
- var x = { delimiter: "", prefixes: "", sensitive: true, strict: true }, B = { delimiter: ".", prefixes: "", sensitive: true, strict: true }, q = { delimiter: "/", prefixes: "/", sensitive: true, strict: true };
243
- function J(e, t) {
244
- return e.length ? e[0] === "/" ? true : !t || e.length < 2 ? false : (e[0] == "\\" || e[0] == "{") && e[1] == "/" : false;
245
- }
246
- function Q(e, t) {
247
- return e.startsWith(t) ? e.substring(t.length, e.length) : e;
248
- }
249
- function Ee(e, t) {
250
- return e.endsWith(t) ? e.substr(0, e.length - t.length) : e;
251
- }
252
- function W(e) {
253
- return !e || e.length < 2 ? false : e[0] === "[" || (e[0] === "\\" || e[0] === "{") && e[1] === "[";
254
- }
255
- var ee = ["ftp", "file", "http", "https", "ws", "wss"];
256
- function N(e) {
257
- if (!e) return true;
258
- for (let t of ee) if (e.test(t)) return true;
259
- return false;
260
- }
261
- function te(e, t) {
262
- if (e = Q(e, "#"), t || e === "") return e;
263
- let r = new URL("https://example.com");
264
- return r.hash = e, r.hash ? r.hash.substring(1, r.hash.length) : "";
265
- }
266
- function re(e, t) {
267
- if (e = Q(e, "?"), t || e === "") return e;
268
- let r = new URL("https://example.com");
269
- return r.search = e, r.search ? r.search.substring(1, r.search.length) : "";
270
- }
271
- function ne(e, t) {
272
- return t || e === "" ? e : W(e) ? j(e) : z(e);
273
- }
274
- function se(e, t) {
275
- if (t || e === "") return e;
276
- let r = new URL("https://example.com");
277
- return r.password = e, r.password;
278
- }
279
- function ie(e, t) {
280
- if (t || e === "") return e;
281
- let r = new URL("https://example.com");
282
- return r.username = e, r.username;
283
- }
284
- function ae(e, t, r) {
285
- if (r || e === "") return e;
286
- if (t && !ee.includes(t)) return new URL(`${t}:${e}`).pathname;
287
- let n = e[0] == "/";
288
- return e = new URL(n ? e : "/-" + e, "https://example.com").pathname, n || (e = e.substring(2, e.length)), e;
289
- }
290
- function oe(e, t, r) {
291
- return _(t) === e && (e = ""), r || e === "" ? e : K(e);
292
- }
293
- function ce(e, t) {
294
- return e = Ee(e, ":"), t || e === "" ? e : y(e);
295
- }
296
- function _(e) {
297
- switch (e) {
298
- case "ws":
299
- case "http":
300
- return "80";
301
- case "wws":
302
- case "https":
303
- return "443";
304
- case "ftp":
305
- return "21";
306
- default:
307
- return "";
308
- }
309
- }
310
- function y(e) {
311
- if (e === "") return e;
312
- if (/^[-+.A-Za-z0-9]*$/.test(e)) return e.toLowerCase();
313
- throw new TypeError(`Invalid protocol '${e}'.`);
314
- }
315
- function le(e) {
316
- if (e === "") return e;
317
- let t = new URL("https://example.com");
318
- return t.username = e, t.username;
319
- }
320
- function fe(e) {
321
- if (e === "") return e;
322
- let t = new URL("https://example.com");
323
- return t.password = e, t.password;
324
- }
325
- function z(e) {
326
- if (e === "") return e;
327
- if (/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e)) throw new TypeError(`Invalid hostname '${e}'`);
328
- let t = new URL("https://example.com");
329
- return t.hostname = e, t.hostname;
330
- }
331
- function j(e) {
332
- if (e === "") return e;
333
- if (/[^0-9a-fA-F[\]:]/g.test(e)) throw new TypeError(`Invalid IPv6 hostname '${e}'`);
334
- return e.toLowerCase();
335
- }
336
- function K(e) {
337
- if (e === "" || /^[0-9]*$/.test(e) && parseInt(e) <= 65535) return e;
338
- throw new TypeError(`Invalid port '${e}'.`);
339
- }
340
- function he(e) {
341
- if (e === "") return e;
342
- let t = new URL("https://example.com");
343
- return t.pathname = e[0] !== "/" ? "/-" + e : e, e[0] !== "/" ? t.pathname.substring(2, t.pathname.length) : t.pathname;
344
- }
345
- function ue(e) {
346
- return e === "" ? e : new URL(`data:${e}`).pathname;
347
- }
348
- function de(e) {
349
- if (e === "") return e;
350
- let t = new URL("https://example.com");
351
- return t.search = e, t.search.substring(1, t.search.length);
352
- }
353
- function pe(e) {
354
- if (e === "") return e;
355
- let t = new URL("https://example.com");
356
- return t.hash = e, t.hash.substring(1, t.hash.length);
357
- }
358
- var H = (_a = class {
359
- constructor(t) {
360
- __privateAdd(this, _H_instances);
361
- __privateAdd(this, _i);
362
- __privateAdd(this, _n, []);
363
- __privateAdd(this, _t, {});
364
- __privateAdd(this, _e, 0);
365
- __privateAdd(this, _s, 1);
366
- __privateAdd(this, _l, 0);
367
- __privateAdd(this, _o, 0);
368
- __privateAdd(this, _d, 0);
369
- __privateAdd(this, _p, 0);
370
- __privateAdd(this, _g, false);
371
- __privateSet(this, _i, t);
372
- }
373
- get result() {
374
- return __privateGet(this, _t);
375
- }
376
- parse() {
377
- for (__privateSet(this, _n, v(__privateGet(this, _i), true)); __privateGet(this, _e) < __privateGet(this, _n).length; __privateSet(this, _e, __privateGet(this, _e) + __privateGet(this, _s))) {
378
- if (__privateSet(this, _s, 1), __privateGet(this, _n)[__privateGet(this, _e)].type === "END") {
379
- if (__privateGet(this, _o) === 0) {
380
- __privateMethod(this, _H_instances, b_fn).call(this), __privateMethod(this, _H_instances, f_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 9, 1) : __privateMethod(this, _H_instances, h_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 8, 1) : __privateMethod(this, _H_instances, r_fn).call(this, 7, 0);
381
- continue;
382
- } else if (__privateGet(this, _o) === 2) {
383
- __privateMethod(this, _H_instances, u_fn).call(this, 5);
384
- continue;
385
- }
386
- __privateMethod(this, _H_instances, r_fn).call(this, 10, 0);
387
- break;
388
- }
389
- if (__privateGet(this, _d) > 0) if (__privateMethod(this, _H_instances, A_fn).call(this)) __privateSet(this, _d, __privateGet(this, _d) - 1);
390
- else continue;
391
- if (__privateMethod(this, _H_instances, T_fn).call(this)) {
392
- __privateSet(this, _d, __privateGet(this, _d) + 1);
393
- continue;
394
- }
395
- switch (__privateGet(this, _o)) {
396
- case 0:
397
- __privateMethod(this, _H_instances, P_fn).call(this) && __privateMethod(this, _H_instances, u_fn).call(this, 1);
398
- break;
399
- case 1:
400
- if (__privateMethod(this, _H_instances, P_fn).call(this)) {
401
- __privateMethod(this, _H_instances, C_fn).call(this);
402
- let t = 7, r = 1;
403
- __privateMethod(this, _H_instances, E_fn).call(this) ? (t = 2, r = 3) : __privateGet(this, _g) && (t = 2), __privateMethod(this, _H_instances, r_fn).call(this, t, r);
404
- }
405
- break;
406
- case 2:
407
- __privateMethod(this, _H_instances, S_fn).call(this) ? __privateMethod(this, _H_instances, u_fn).call(this, 3) : (__privateMethod(this, _H_instances, x_fn).call(this) || __privateMethod(this, _H_instances, h_fn).call(this) || __privateMethod(this, _H_instances, f_fn).call(this)) && __privateMethod(this, _H_instances, u_fn).call(this, 5);
408
- break;
409
- case 3:
410
- __privateMethod(this, _H_instances, O_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 4, 1) : __privateMethod(this, _H_instances, S_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 5, 1);
411
- break;
412
- case 4:
413
- __privateMethod(this, _H_instances, S_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 5, 1);
414
- break;
415
- case 5:
416
- __privateMethod(this, _H_instances, y_fn).call(this) ? __privateSet(this, _p, __privateGet(this, _p) + 1) : __privateMethod(this, _H_instances, w_fn).call(this) && __privateSet(this, _p, __privateGet(this, _p) - 1), __privateMethod(this, _H_instances, k_fn).call(this) && !__privateGet(this, _p) ? __privateMethod(this, _H_instances, r_fn).call(this, 6, 1) : __privateMethod(this, _H_instances, x_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 7, 0) : __privateMethod(this, _H_instances, h_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 8, 1) : __privateMethod(this, _H_instances, f_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 9, 1);
417
- break;
418
- case 6:
419
- __privateMethod(this, _H_instances, x_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 7, 0) : __privateMethod(this, _H_instances, h_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 8, 1) : __privateMethod(this, _H_instances, f_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 9, 1);
420
- break;
421
- case 7:
422
- __privateMethod(this, _H_instances, h_fn).call(this) ? __privateMethod(this, _H_instances, r_fn).call(this, 8, 1) : __privateMethod(this, _H_instances, f_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 9, 1);
423
- break;
424
- case 8:
425
- __privateMethod(this, _H_instances, f_fn).call(this) && __privateMethod(this, _H_instances, r_fn).call(this, 9, 1);
426
- break;
427
- }
428
- }
429
- __privateGet(this, _t).hostname !== void 0 && __privateGet(this, _t).port === void 0 && (__privateGet(this, _t).port = "");
430
- }
431
- }, _i = new WeakMap(), _n = new WeakMap(), _t = new WeakMap(), _e = new WeakMap(), _s = new WeakMap(), _l = new WeakMap(), _o = new WeakMap(), _d = new WeakMap(), _p = new WeakMap(), _g = new WeakMap(), _H_instances = new WeakSet(), r_fn = function(t, r) {
432
- var _a2, _b2, _c;
433
- switch (__privateGet(this, _o)) {
434
- case 0:
435
- break;
436
- case 1:
437
- __privateGet(this, _t).protocol = __privateMethod(this, _H_instances, c_fn).call(this);
438
- break;
439
- case 2:
440
- break;
441
- case 3:
442
- __privateGet(this, _t).username = __privateMethod(this, _H_instances, c_fn).call(this);
443
- break;
444
- case 4:
445
- __privateGet(this, _t).password = __privateMethod(this, _H_instances, c_fn).call(this);
446
- break;
447
- case 5:
448
- __privateGet(this, _t).hostname = __privateMethod(this, _H_instances, c_fn).call(this);
449
- break;
450
- case 6:
451
- __privateGet(this, _t).port = __privateMethod(this, _H_instances, c_fn).call(this);
452
- break;
453
- case 7:
454
- __privateGet(this, _t).pathname = __privateMethod(this, _H_instances, c_fn).call(this);
455
- break;
456
- case 8:
457
- __privateGet(this, _t).search = __privateMethod(this, _H_instances, c_fn).call(this);
458
- break;
459
- case 9:
460
- __privateGet(this, _t).hash = __privateMethod(this, _H_instances, c_fn).call(this);
461
- break;
462
- }
463
- __privateGet(this, _o) !== 0 && t !== 10 && ([1, 2, 3, 4].includes(__privateGet(this, _o)) && [6, 7, 8, 9].includes(t) && ((_a2 = __privateGet(this, _t)).hostname ?? (_a2.hostname = "")), [1, 2, 3, 4, 5, 6].includes(__privateGet(this, _o)) && [8, 9].includes(t) && ((_b2 = __privateGet(this, _t)).pathname ?? (_b2.pathname = __privateGet(this, _g) ? "/" : "")), [1, 2, 3, 4, 5, 6, 7].includes(__privateGet(this, _o)) && t === 9 && ((_c = __privateGet(this, _t)).search ?? (_c.search = ""))), __privateMethod(this, _H_instances, R_fn).call(this, t, r);
464
- }, R_fn = function(t, r) {
465
- __privateSet(this, _o, t), __privateSet(this, _l, __privateGet(this, _e) + r), __privateSet(this, _e, __privateGet(this, _e) + r), __privateSet(this, _s, 0);
466
- }, b_fn = function() {
467
- __privateSet(this, _e, __privateGet(this, _l)), __privateSet(this, _s, 0);
468
- }, u_fn = function(t) {
469
- __privateMethod(this, _H_instances, b_fn).call(this), __privateSet(this, _o, t);
470
- }, m_fn = function(t) {
471
- return t < 0 && (t = __privateGet(this, _n).length - t), t < __privateGet(this, _n).length ? __privateGet(this, _n)[t] : __privateGet(this, _n)[__privateGet(this, _n).length - 1];
472
- }, a_fn = function(t, r) {
473
- let n = __privateMethod(this, _H_instances, m_fn).call(this, t);
474
- return n.value === r && (n.type === "CHAR" || n.type === "ESCAPED_CHAR" || n.type === "INVALID_CHAR");
475
- }, P_fn = function() {
476
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), ":");
477
- }, E_fn = function() {
478
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e) + 1, "/") && __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e) + 2, "/");
479
- }, S_fn = function() {
480
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "@");
481
- }, O_fn = function() {
482
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), ":");
483
- }, k_fn = function() {
484
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), ":");
485
- }, x_fn = function() {
486
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "/");
487
- }, h_fn = function() {
488
- if (__privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "?")) return true;
489
- if (__privateGet(this, _n)[__privateGet(this, _e)].value !== "?") return false;
490
- let t = __privateMethod(this, _H_instances, m_fn).call(this, __privateGet(this, _e) - 1);
491
- return t.type !== "NAME" && t.type !== "REGEX" && t.type !== "CLOSE" && t.type !== "ASTERISK";
492
- }, f_fn = function() {
493
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "#");
494
- }, T_fn = function() {
495
- return __privateGet(this, _n)[__privateGet(this, _e)].type == "OPEN";
496
- }, A_fn = function() {
497
- return __privateGet(this, _n)[__privateGet(this, _e)].type == "CLOSE";
498
- }, y_fn = function() {
499
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "[");
500
- }, w_fn = function() {
501
- return __privateMethod(this, _H_instances, a_fn).call(this, __privateGet(this, _e), "]");
502
- }, c_fn = function() {
503
- let t = __privateGet(this, _n)[__privateGet(this, _e)], r = __privateMethod(this, _H_instances, m_fn).call(this, __privateGet(this, _l)).index;
504
- return __privateGet(this, _i).substring(r, t.index);
505
- }, C_fn = function() {
506
- let t = {};
507
- Object.assign(t, x), t.encodePart = y;
508
- let r = Z(__privateMethod(this, _H_instances, c_fn).call(this), void 0, t);
509
- __privateSet(this, _g, N(r));
510
- }, _a);
511
- var G = ["protocol", "username", "password", "hostname", "port", "pathname", "search", "hash"], E = "*";
512
- function ge(e, t) {
513
- if (typeof e != "string") throw new TypeError("parameter 1 is not of type 'string'.");
514
- let r = new URL(e, t);
515
- return { protocol: r.protocol.substring(0, r.protocol.length - 1), username: r.username, password: r.password, hostname: r.hostname, port: r.port, pathname: r.pathname, search: r.search !== "" ? r.search.substring(1, r.search.length) : void 0, hash: r.hash !== "" ? r.hash.substring(1, r.hash.length) : void 0 };
516
- }
517
- function b(e, t) {
518
- return t ? C(e) : e;
519
- }
520
- function w(e, t, r) {
521
- let n;
522
- if (typeof t.baseURL == "string") try {
523
- n = new URL(t.baseURL), t.protocol === void 0 && (e.protocol = b(n.protocol.substring(0, n.protocol.length - 1), r)), !r && t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && t.username === void 0 && (e.username = b(n.username, r)), !r && t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && t.username === void 0 && t.password === void 0 && (e.password = b(n.password, r)), t.protocol === void 0 && t.hostname === void 0 && (e.hostname = b(n.hostname, r)), t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && (e.port = b(n.port, r)), t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && t.pathname === void 0 && (e.pathname = b(n.pathname, r)), t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && t.pathname === void 0 && t.search === void 0 && (e.search = b(n.search.substring(1, n.search.length), r)), t.protocol === void 0 && t.hostname === void 0 && t.port === void 0 && t.pathname === void 0 && t.search === void 0 && t.hash === void 0 && (e.hash = b(n.hash.substring(1, n.hash.length), r));
524
- } catch {
525
- throw new TypeError(`invalid baseURL '${t.baseURL}'.`);
526
- }
527
- if (typeof t.protocol == "string" && (e.protocol = ce(t.protocol, r)), typeof t.username == "string" && (e.username = ie(t.username, r)), typeof t.password == "string" && (e.password = se(t.password, r)), typeof t.hostname == "string" && (e.hostname = ne(t.hostname, r)), typeof t.port == "string" && (e.port = oe(t.port, e.protocol, r)), typeof t.pathname == "string") {
528
- if (e.pathname = t.pathname, n && !J(e.pathname, r)) {
529
- let o = n.pathname.lastIndexOf("/");
530
- o >= 0 && (e.pathname = b(n.pathname.substring(0, o + 1), r) + e.pathname);
531
- }
532
- e.pathname = ae(e.pathname, e.protocol, r);
533
- }
534
- return typeof t.search == "string" && (e.search = re(t.search, r)), typeof t.hash == "string" && (e.hash = te(t.hash, r)), e;
535
- }
536
- function C(e) {
537
- return e.replace(/([+*?:{}()\\])/g, "\\$1");
538
- }
539
- function Oe(e) {
540
- return e.replace(/([.+*?^${}()[\]|/\\])/g, "\\$1");
541
- }
542
- function ke(e, t) {
543
- t.delimiter ?? (t.delimiter = "/#?"), t.prefixes ?? (t.prefixes = "./"), t.sensitive ?? (t.sensitive = false), t.strict ?? (t.strict = false), t.end ?? (t.end = true), t.start ?? (t.start = true), t.endsWith = "";
544
- let r = ".*", n = `[^${Oe(t.delimiter)}]+?`, o = /[$_\u200C\u200D\p{ID_Continue}]/u, c = "";
545
- for (let l = 0; l < e.length; ++l) {
546
- let s = e[l];
547
- if (s.type === 3) {
548
- if (s.modifier === 3) {
549
- c += C(s.value);
550
- continue;
551
- }
552
- c += `{${C(s.value)}}${k(s.modifier)}`;
553
- continue;
554
- }
555
- let i = s.hasCustomName(), a = !!s.suffix.length || !!s.prefix.length && (s.prefix.length !== 1 || !t.prefixes.includes(s.prefix)), f = l > 0 ? e[l - 1] : null, d = l < e.length - 1 ? e[l + 1] : null;
556
- if (!a && i && s.type === 1 && s.modifier === 3 && d && !d.prefix.length && !d.suffix.length) if (d.type === 3) {
557
- let T = d.value.length > 0 ? d.value[0] : "";
558
- a = o.test(T);
559
- } else a = !d.hasCustomName();
560
- if (!a && !s.prefix.length && f && f.type === 3) {
561
- let T = f.value[f.value.length - 1];
562
- a = t.prefixes.includes(T);
563
- }
564
- a && (c += "{"), c += C(s.prefix), i && (c += `:${s.name}`), s.type === 2 ? c += `(${s.value})` : s.type === 1 ? i || (c += `(${n})`) : s.type === 0 && (!i && (!f || f.type === 3 || f.modifier !== 3 || a || s.prefix !== "") ? c += "*" : c += `(${r})`), s.type === 1 && i && s.suffix.length && o.test(s.suffix[0]) && (c += "\\"), c += C(s.suffix), a && (c += "}"), s.modifier !== 3 && (c += k(s.modifier));
565
- }
566
- return c;
567
- }
568
- var me = (_b = class {
569
- constructor(t = {}, r, n) {
570
- __privateAdd(this, _i2);
571
- __privateAdd(this, _n2, {});
572
- __privateAdd(this, _t2, {});
573
- __privateAdd(this, _e2, {});
574
- __privateAdd(this, _s2, {});
575
- __privateAdd(this, _l2, false);
576
- try {
577
- let o;
578
- if (typeof r == "string" ? o = r : n = r, typeof t == "string") {
579
- let i = new H(t);
580
- if (i.parse(), t = i.result, o === void 0 && typeof t.protocol != "string") throw new TypeError("A base URL must be provided for a relative constructor string.");
581
- t.baseURL = o;
582
- } else {
583
- if (!t || typeof t != "object") throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");
584
- if (o) throw new TypeError("parameter 1 is not of type 'string'.");
585
- }
586
- typeof n > "u" && (n = { ignoreCase: false });
587
- let c = { ignoreCase: n.ignoreCase === true }, l = { pathname: E, protocol: E, username: E, password: E, hostname: E, port: E, search: E, hash: E };
588
- __privateSet(this, _i2, w(l, t, true)), _(__privateGet(this, _i2).protocol) === __privateGet(this, _i2).port && (__privateGet(this, _i2).port = "");
589
- let s;
590
- for (s of G) {
591
- if (!(s in __privateGet(this, _i2))) continue;
592
- let i = {}, a = __privateGet(this, _i2)[s];
593
- switch (__privateGet(this, _t2)[s] = [], s) {
594
- case "protocol":
595
- Object.assign(i, x), i.encodePart = y;
596
- break;
597
- case "username":
598
- Object.assign(i, x), i.encodePart = le;
599
- break;
600
- case "password":
601
- Object.assign(i, x), i.encodePart = fe;
602
- break;
603
- case "hostname":
604
- Object.assign(i, B), W(a) ? i.encodePart = j : i.encodePart = z;
605
- break;
606
- case "port":
607
- Object.assign(i, x), i.encodePart = K;
608
- break;
609
- case "pathname":
610
- N(__privateGet(this, _n2).protocol) ? (Object.assign(i, q, c), i.encodePart = he) : (Object.assign(i, x, c), i.encodePart = ue);
611
- break;
612
- case "search":
613
- Object.assign(i, x, c), i.encodePart = de;
614
- break;
615
- case "hash":
616
- Object.assign(i, x, c), i.encodePart = pe;
617
- break;
618
- }
619
- try {
620
- __privateGet(this, _s2)[s] = D(a, i), __privateGet(this, _n2)[s] = F(__privateGet(this, _s2)[s], __privateGet(this, _t2)[s], i), __privateGet(this, _e2)[s] = ke(__privateGet(this, _s2)[s], i), __privateSet(this, _l2, __privateGet(this, _l2) || __privateGet(this, _s2)[s].some((f) => f.type === 2));
621
- } catch {
622
- throw new TypeError(`invalid ${s} pattern '${__privateGet(this, _i2)[s]}'.`);
623
- }
624
- }
625
- } catch (o) {
626
- throw new TypeError(`Failed to construct 'URLPattern': ${o.message}`);
627
- }
628
- }
629
- test(t = {}, r) {
630
- let n = { pathname: "", protocol: "", username: "", password: "", hostname: "", port: "", search: "", hash: "" };
631
- if (typeof t != "string" && r) throw new TypeError("parameter 1 is not of type 'string'.");
632
- if (typeof t > "u") return false;
633
- try {
634
- typeof t == "object" ? n = w(n, t, false) : n = w(n, ge(t, r), false);
635
- } catch {
636
- return false;
637
- }
638
- let o;
639
- for (o of G) if (!__privateGet(this, _n2)[o].exec(n[o])) return false;
640
- return true;
641
- }
642
- exec(t = {}, r) {
643
- let n = { pathname: "", protocol: "", username: "", password: "", hostname: "", port: "", search: "", hash: "" };
644
- if (typeof t != "string" && r) throw new TypeError("parameter 1 is not of type 'string'.");
645
- if (typeof t > "u") return;
646
- try {
647
- typeof t == "object" ? n = w(n, t, false) : n = w(n, ge(t, r), false);
648
- } catch {
649
- return null;
650
- }
651
- let o = {};
652
- r ? o.inputs = [t, r] : o.inputs = [t];
653
- let c;
654
- for (c of G) {
655
- let l = __privateGet(this, _n2)[c].exec(n[c]);
656
- if (!l) return null;
657
- let s = {};
658
- for (let [i, a] of __privateGet(this, _t2)[c].entries()) if (typeof a == "string" || typeof a == "number") {
659
- let f = l[i + 1];
660
- s[a] = f;
661
- }
662
- o[c] = { input: n[c] ?? "", groups: s };
663
- }
664
- return o;
665
- }
666
- static compareComponent(t, r, n) {
667
- let o = (i, a) => {
668
- for (let f of ["type", "modifier", "prefix", "value", "suffix"]) {
669
- if (i[f] < a[f]) return -1;
670
- if (i[f] === a[f]) continue;
671
- return 1;
672
- }
673
- return 0;
674
- }, c = new R(3, "", "", "", "", 3), l = new R(0, "", "", "", "", 3), s = (i, a) => {
675
- let f = 0;
676
- for (; f < Math.min(i.length, a.length); ++f) {
677
- let d = o(i[f], a[f]);
678
- if (d) return d;
679
- }
680
- return i.length === a.length ? 0 : o(i[f] ?? c, a[f] ?? c);
681
- };
682
- return !__privateGet(r, _e2)[t] && !__privateGet(n, _e2)[t] ? 0 : __privateGet(r, _e2)[t] && !__privateGet(n, _e2)[t] ? s(__privateGet(r, _s2)[t], [l]) : !__privateGet(r, _e2)[t] && __privateGet(n, _e2)[t] ? s([l], __privateGet(n, _s2)[t]) : s(__privateGet(r, _s2)[t], __privateGet(n, _s2)[t]);
683
- }
684
- get protocol() {
685
- return __privateGet(this, _e2).protocol;
686
- }
687
- get username() {
688
- return __privateGet(this, _e2).username;
689
- }
690
- get password() {
691
- return __privateGet(this, _e2).password;
692
- }
693
- get hostname() {
694
- return __privateGet(this, _e2).hostname;
695
- }
696
- get port() {
697
- return __privateGet(this, _e2).port;
698
- }
699
- get pathname() {
700
- return __privateGet(this, _e2).pathname;
701
- }
702
- get search() {
703
- return __privateGet(this, _e2).search;
704
- }
705
- get hash() {
706
- return __privateGet(this, _e2).hash;
707
- }
708
- get hasRegExpGroups() {
709
- return __privateGet(this, _l2);
710
- }
711
- }, _i2 = new WeakMap(), _n2 = new WeakMap(), _t2 = new WeakMap(), _e2 = new WeakMap(), _s2 = new WeakMap(), _l2 = new WeakMap(), _b);
712
- if (!globalThis.URLPattern) {
713
- globalThis.URLPattern = me;
714
- }
715
- export {
716
- me as URLPattern
717
- };