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