@originator-profile/verify 0.5.1 → 0.6.0-beta.1

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