@m6d/cortex 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  BACKEND_ERROR_STATUS,
3
- CortexError,
4
- DATASET_REQUEST_MAX_BYTES,
5
3
  backendErrorSchema,
6
- boundDatasetResult,
7
- checkDatasetQuery,
8
- contentVersion,
9
- datasetCatalogOf,
10
- datasetDefinitionSchema,
11
- datasetIdentifierSchema,
12
- datasetRequestSchema,
13
- envelopeOf,
14
4
  errorEnvelope,
15
5
  isRecord,
6
+ readJsonPointer,
7
+ CortexError2,
16
8
  malformedBody,
9
+ envelopeOf,
17
10
  protocolBodyLimit,
18
- readJsonPointer
19
- } from "./index-969vtyhy.js";
11
+ contentVersion,
12
+ datasetIdentifierSchema,
13
+ datasetDefinitionSchema,
14
+ DATASET_REQUEST_MAX_BYTES,
15
+ datasetRequestSchema,
16
+ datasetCatalogOf,
17
+ checkDatasetQuery,
18
+ boundDatasetResult
19
+ } from "./index-j0kpmpfv.js";
20
20
 
21
21
  // src/server/server.ts
22
22
  import { createHash, timingSafeEqual } from "node:crypto";
@@ -34,7 +34,7 @@ import { z as z3 } from "zod";
34
34
  * @repository [object Object]
35
35
  * @license MIT
36
36
  */
37
- var RE2Flags = class RE2Flags2 {
37
+ var RE2Flags = class RE2Flags {
38
38
  static FOLD_CASE = 1;
39
39
  static LITERAL = 2;
40
40
  static CLASS_NL = 4;
@@ -45,8 +45,8 @@ var RE2Flags = class RE2Flags2 {
45
45
  static UNICODE_GROUPS = 128;
46
46
  static WAS_DOLLAR = 256;
47
47
  static LOOKBEHIND = 512;
48
- static MATCH_NL = RE2Flags2.CLASS_NL | RE2Flags2.DOT_NL;
49
- static PERL = RE2Flags2.CLASS_NL | RE2Flags2.ONE_LINE | RE2Flags2.PERL_X | RE2Flags2.UNICODE_GROUPS;
48
+ static MATCH_NL = RE2Flags.CLASS_NL | RE2Flags.DOT_NL;
49
+ static PERL = RE2Flags.CLASS_NL | RE2Flags.ONE_LINE | RE2Flags.PERL_X | RE2Flags.UNICODE_GROUPS;
50
50
  static POSIX = 0;
51
51
  static UNANCHORED = 0;
52
52
  static ANCHOR_START = 1;
@@ -515,11 +515,11 @@ var UnicodeTables = class {
515
515
  Inherited: () => new UnicodeRangeTable(decodeRanges("5cgBgBlgHAB", false))
516
516
  });
517
517
  };
518
- var Unicode = class Unicode2 {
518
+ var Unicode = class Unicode {
519
519
  static MAX_RUNE = 1114111;
520
520
  static RUNE_ERROR = 65533;
521
521
  static isUnsearchable(r) {
522
- return r === Unicode2.RUNE_ERROR || r >= Unicode2.MIN_HIGH_SURROGATE && r <= Unicode2.MAX_LOW_SURROGATE;
522
+ return r === Unicode.RUNE_ERROR || r >= Unicode.MIN_HIGH_SURROGATE && r <= Unicode.MAX_LOW_SURROGATE;
523
523
  }
524
524
  static MAX_ASCII = 127;
525
525
  static MAX_LATIN1 = 255;
@@ -550,7 +550,7 @@ var Unicode = class Unicode2 {
550
550
  return false;
551
551
  }
552
552
  static is(ranges, r) {
553
- if (r <= Unicode2.MAX_LATIN1) {
553
+ if (r <= Unicode.MAX_LATIN1) {
554
554
  for (let i = 0;i < ranges.length; i++) {
555
555
  if (r > ranges.getHi(i))
556
556
  continue;
@@ -562,24 +562,24 @@ var Unicode = class Unicode2 {
562
562
  }
563
563
  return false;
564
564
  }
565
- return ranges.length > 0 && r >= ranges.getLo(0) && Unicode2.is32(ranges, r);
565
+ return ranges.length > 0 && r >= ranges.getLo(0) && Unicode.is32(ranges, r);
566
566
  }
567
567
  static isUpper(r) {
568
- if (r <= Unicode2.MAX_LATIN1) {
568
+ if (r <= Unicode.MAX_LATIN1) {
569
569
  const s = String.fromCodePoint(r);
570
570
  return s.toUpperCase() === s && s.toLowerCase() !== s;
571
571
  }
572
- return Unicode2.is(UnicodeTables.Upper, r);
572
+ return Unicode.is(UnicodeTables.Upper, r);
573
573
  }
574
574
  static isPrint(r) {
575
- if (r <= Unicode2.MAX_LATIN1)
576
- return r >= 32 && r < Unicode2.MAX_ASCII || r >= 161 && r !== 173;
577
- return Unicode2.is(UnicodeTables.Print, r);
575
+ if (r <= Unicode.MAX_LATIN1)
576
+ return r >= 32 && r < Unicode.MAX_ASCII || r >= 161 && r !== 173;
577
+ return Unicode.is(UnicodeTables.Print, r);
578
578
  }
579
579
  static simpleFold(r) {
580
580
  if (UnicodeTables.CASE_ORBIT.has(r))
581
581
  return UnicodeTables.CASE_ORBIT.get(r);
582
- if (r <= Unicode2.MAX_ASCII) {
582
+ if (r <= Unicode.MAX_ASCII) {
583
583
  const l = Codepoint.toLowerCase(r);
584
584
  return l !== r ? l : Codepoint.toUpperCase(r);
585
585
  }
@@ -590,14 +590,14 @@ var Unicode = class Unicode2 {
590
590
  return true;
591
591
  if (r1 < 0 || r2 < 0)
592
592
  return false;
593
- if (r1 <= Unicode2.MAX_ASCII && r2 <= Unicode2.MAX_ASCII) {
593
+ if (r1 <= Unicode.MAX_ASCII && r2 <= Unicode.MAX_ASCII) {
594
594
  if (65 <= r1 && r1 <= 90)
595
595
  r1 |= 32;
596
596
  if (65 <= r2 && r2 <= 90)
597
597
  r2 |= 32;
598
598
  return r1 === r2;
599
599
  }
600
- for (let r = Unicode2.simpleFold(r1);r !== r1; r = Unicode2.simpleFold(r))
600
+ for (let r = Unicode.simpleFold(r1);r !== r1; r = Unicode.simpleFold(r))
601
601
  if (r === r2)
602
602
  return true;
603
603
  return false;
@@ -609,7 +609,7 @@ for (let i = 0;i < FAST_PATH_TABLE_SIZE; i++)
609
609
  WORD_RUNE_TABLE[i] = 97 <= i && i <= 122 || 65 <= i && i <= 90 || 48 <= i && i <= 57 || i === 95 ? 1 : 0;
610
610
  var cachedNativeEncoder = null;
611
611
  var cachedNativeDecoder = null;
612
- var Utils = class Utils2 {
612
+ var Utils = class Utils {
613
613
  static METACHARACTERS = "\\.+*?()|[]{}^$";
614
614
  static EMPTY_BEGIN_LINE = 1;
615
615
  static EMPTY_END_LINE = 2;
@@ -639,7 +639,7 @@ var Utils = class Utils2 {
639
639
  static escapeRune(rune) {
640
640
  let out = "";
641
641
  if (Unicode.isPrint(rune)) {
642
- if (Utils2.METACHARACTERS.indexOf(String.fromCodePoint(rune)) >= 0)
642
+ if (Utils.METACHARACTERS.indexOf(String.fromCodePoint(rune)) >= 0)
643
643
  out += "\\";
644
644
  out += String.fromCodePoint(rune);
645
645
  } else
@@ -700,22 +700,22 @@ var Utils = class Utils2 {
700
700
  static emptyOpContext(r1, r2) {
701
701
  let op = 0;
702
702
  if (r1 < 0)
703
- op |= Utils2.EMPTY_BEGIN_TEXT | Utils2.EMPTY_BEGIN_LINE;
703
+ op |= Utils.EMPTY_BEGIN_TEXT | Utils.EMPTY_BEGIN_LINE;
704
704
  if (r1 === 10)
705
- op |= Utils2.EMPTY_BEGIN_LINE;
705
+ op |= Utils.EMPTY_BEGIN_LINE;
706
706
  if (r2 < 0)
707
- op |= Utils2.EMPTY_END_TEXT | Utils2.EMPTY_END_LINE;
707
+ op |= Utils.EMPTY_END_TEXT | Utils.EMPTY_END_LINE;
708
708
  if (r2 === 10)
709
- op |= Utils2.EMPTY_END_LINE;
710
- if (Utils2.isWordRune(r1) !== Utils2.isWordRune(r2))
711
- op |= Utils2.EMPTY_WORD_BOUNDARY;
709
+ op |= Utils.EMPTY_END_LINE;
710
+ if (Utils.isWordRune(r1) !== Utils.isWordRune(r2))
711
+ op |= Utils.EMPTY_WORD_BOUNDARY;
712
712
  else
713
- op |= Utils2.EMPTY_NO_WORD_BOUNDARY;
713
+ op |= Utils.EMPTY_NO_WORD_BOUNDARY;
714
714
  return op;
715
715
  }
716
716
  static quoteMeta(str) {
717
717
  return str.split("").map((s) => {
718
- if (Utils2.METACHARACTERS.indexOf(s) >= 0)
718
+ if (Utils.METACHARACTERS.indexOf(s) >= 0)
719
719
  return `\\${s}`;
720
720
  return s;
721
721
  }).join("");
@@ -801,7 +801,7 @@ var createEnum = (values = [], initNum = 0) => {
801
801
  }
802
802
  return Object.freeze(enumObject);
803
803
  };
804
- var MatcherInputBase = class MatcherInputBase2 {
804
+ var MatcherInputBase = class MatcherInputBase {
805
805
  static Encoding = createEnum(["UTF_16", "UTF_8"]);
806
806
  getEncoding() {
807
807
  throw Error("not implemented");
@@ -816,10 +816,10 @@ var MatcherInputBase = class MatcherInputBase2 {
816
816
  throw Error("not implemented");
817
817
  }
818
818
  isUTF8Encoding() {
819
- return this.getEncoding() === MatcherInputBase2.Encoding.UTF_8;
819
+ return this.getEncoding() === MatcherInputBase.Encoding.UTF_8;
820
820
  }
821
821
  isUTF16Encoding() {
822
- return this.getEncoding() === MatcherInputBase2.Encoding.UTF_16;
822
+ return this.getEncoding() === MatcherInputBase.Encoding.UTF_16;
823
823
  }
824
824
  };
825
825
  var Utf8MatcherInput = class extends MatcherInputBase {
@@ -891,7 +891,7 @@ var MachineInputBase = class {
891
891
  return 0;
892
892
  }
893
893
  };
894
- var MachineUTF8Input = class MachineUTF8Input2 extends MachineInputBase {
894
+ var MachineUTF8Input = class MachineUTF8Input extends MachineInputBase {
895
895
  static RUNE_ERROR_STEP = Unicode.RUNE_ERROR << 3 | 1;
896
896
  constructor(bytes, start = 0, end = bytes.length) {
897
897
  super();
@@ -938,22 +938,22 @@ var MachineUTF8Input = class MachineUTF8Input2 extends MachineInputBase {
938
938
  else if (c === 244)
939
939
  hi = 143;
940
940
  } else
941
- return MachineUTF8Input2.RUNE_ERROR_STEP;
941
+ return MachineUTF8Input.RUNE_ERROR_STEP;
942
942
  if (pos + size > this.end)
943
- return MachineUTF8Input2.RUNE_ERROR_STEP;
943
+ return MachineUTF8Input.RUNE_ERROR_STEP;
944
944
  const c1 = this.bytes[pos + 1] & 255;
945
945
  if (c1 < lo || c1 > hi)
946
- return MachineUTF8Input2.RUNE_ERROR_STEP;
946
+ return MachineUTF8Input.RUNE_ERROR_STEP;
947
947
  rune = rune << 6 | c1 & 63;
948
948
  if (size > 2) {
949
949
  const c2 = this.bytes[pos + 2] & 255;
950
950
  if ((c2 & 192) !== 128)
951
- return MachineUTF8Input2.RUNE_ERROR_STEP;
951
+ return MachineUTF8Input.RUNE_ERROR_STEP;
952
952
  rune = rune << 6 | c2 & 63;
953
953
  if (size > 3) {
954
954
  const c3 = this.bytes[pos + 3] & 255;
955
955
  if ((c3 & 192) !== 128)
956
- return MachineUTF8Input2.RUNE_ERROR_STEP;
956
+ return MachineUTF8Input.RUNE_ERROR_STEP;
957
957
  rune = rune << 6 | c3 & 63;
958
958
  }
959
959
  }
@@ -1119,7 +1119,7 @@ var RE2JSInternalException = class extends RE2JSException {
1119
1119
  this.name = "RE2JSInternalException";
1120
1120
  }
1121
1121
  };
1122
- var Matcher = class Matcher2 {
1122
+ var Matcher = class Matcher {
1123
1123
  static MAX_REPLACER_ARGS = 65535;
1124
1124
  static quoteReplacement(str, javaMode = false) {
1125
1125
  if (javaMode) {
@@ -1469,7 +1469,7 @@ var Matcher = class Matcher2 {
1469
1469
  const hasNamedGroups = Object.keys(this.namedGroups).length > 0;
1470
1470
  let originalInput = null;
1471
1471
  if (isFunc) {
1472
- if (this.groupCount() >= Matcher2.MAX_REPLACER_ARGS)
1472
+ if (this.groupCount() >= Matcher.MAX_REPLACER_ARGS)
1473
1473
  throw new RE2JSGroupException("Too many capture groups to safely invoke replacer function");
1474
1474
  originalInput = this.matcherInput.isUTF8Encoding() ? this.matcherInput.asBytes() : this.matcherInput.asCharSequence();
1475
1475
  }
@@ -1514,7 +1514,7 @@ var Matcher = class Matcher2 {
1514
1514
  return args;
1515
1515
  }
1516
1516
  };
1517
- var Inst = class Inst2 {
1517
+ var Inst = class Inst {
1518
1518
  static ALT = 1;
1519
1519
  static ALT_MATCH = 2;
1520
1520
  static CAPTURE = 3;
@@ -1529,7 +1529,7 @@ var Inst = class Inst2 {
1529
1529
  static LB_WRITE = 12;
1530
1530
  static LB_CHECK = 13;
1531
1531
  static isRuneOp(op) {
1532
- return Inst2.RUNE <= op && op <= Inst2.RUNE_ANY_NOT_NL;
1532
+ return Inst.RUNE <= op && op <= Inst.RUNE_ANY_NOT_NL;
1533
1533
  }
1534
1534
  static escapeRunes(runes) {
1535
1535
  let out = '"';
@@ -1607,46 +1607,46 @@ var Inst = class Inst2 {
1607
1607
  }
1608
1608
  toString() {
1609
1609
  switch (this.op) {
1610
- case Inst2.ALT:
1610
+ case Inst.ALT:
1611
1611
  return `alt -> ${this.out}, ${this.arg}`;
1612
- case Inst2.ALT_MATCH:
1612
+ case Inst.ALT_MATCH:
1613
1613
  return `altmatch -> ${this.out}, ${this.arg}`;
1614
- case Inst2.CAPTURE:
1614
+ case Inst.CAPTURE:
1615
1615
  return `cap ${this.arg} -> ${this.out}`;
1616
- case Inst2.EMPTY_WIDTH:
1616
+ case Inst.EMPTY_WIDTH:
1617
1617
  return `empty ${this.arg} -> ${this.out}`;
1618
- case Inst2.MATCH:
1618
+ case Inst.MATCH:
1619
1619
  return `match${this.arg !== 0 ? ` ${this.arg}` : ""}`;
1620
- case Inst2.FAIL:
1620
+ case Inst.FAIL:
1621
1621
  return "fail";
1622
- case Inst2.NOP:
1622
+ case Inst.NOP:
1623
1623
  return `nop -> ${this.out}`;
1624
- case Inst2.LB_WRITE:
1624
+ case Inst.LB_WRITE:
1625
1625
  return `lbwrite ${this.arg} -> ${this.out}`;
1626
- case Inst2.LB_CHECK:
1626
+ case Inst.LB_CHECK:
1627
1627
  return `lbcheck ${this.arg} -> ${this.out}`;
1628
- case Inst2.RUNE:
1628
+ case Inst.RUNE:
1629
1629
  if (this.runes === null)
1630
1630
  return "rune <null>";
1631
1631
  return [
1632
1632
  "rune ",
1633
- Inst2.escapeRunes(this.runes),
1633
+ Inst.escapeRunes(this.runes),
1634
1634
  (this.arg & RE2Flags.FOLD_CASE) !== 0 ? "/i" : "",
1635
1635
  " -> ",
1636
1636
  this.out
1637
1637
  ].join("");
1638
- case Inst2.RUNE1:
1639
- return `rune1 ${Inst2.escapeRunes(this.runes)} -> ${this.out}`;
1640
- case Inst2.RUNE_ANY:
1638
+ case Inst.RUNE1:
1639
+ return `rune1 ${Inst.escapeRunes(this.runes)} -> ${this.out}`;
1640
+ case Inst.RUNE_ANY:
1641
1641
  return `any -> ${this.out}`;
1642
- case Inst2.RUNE_ANY_NOT_NL:
1642
+ case Inst.RUNE_ANY_NOT_NL:
1643
1643
  return `anynotnl -> ${this.out}`;
1644
1644
  default:
1645
1645
  throw new Error("unhandled case in Inst.toString");
1646
1646
  }
1647
1647
  }
1648
1648
  };
1649
- var Queue = class Queue2 {
1649
+ var Queue = class Queue {
1650
1650
  constructor(numInst) {
1651
1651
  this.sparse = new Int32Array(numInst);
1652
1652
  this.densePcs = new Int32Array(numInst);
@@ -1658,7 +1658,7 @@ var Queue = class Queue2 {
1658
1658
  static INITIAL_THREADS = 32;
1659
1659
  init(ncap) {
1660
1660
  this.ncap = ncap;
1661
- const needed = Math.min(this.densePcs.length, Queue2.INITIAL_THREADS) * ncap;
1661
+ const needed = Math.min(this.densePcs.length, Queue.INITIAL_THREADS) * ncap;
1662
1662
  if (!this.denseCaps || this.denseCaps.length < needed)
1663
1663
  this.denseCaps = new Int32Array(needed);
1664
1664
  }
@@ -1708,9 +1708,9 @@ var LookbehindState = class {
1708
1708
  this.size = 0;
1709
1709
  }
1710
1710
  };
1711
- var Machine = class Machine2 {
1711
+ var Machine = class Machine {
1712
1712
  static fromRE2(re2) {
1713
- const m = new Machine2;
1713
+ const m = new Machine;
1714
1714
  m.prog = re2.prog;
1715
1715
  m.re2 = re2;
1716
1716
  m.q0 = new Queue(m.prog.numInst());
@@ -2103,7 +2103,7 @@ var DFAState = class {
2103
2103
  this.nextAnchored = null;
2104
2104
  }
2105
2105
  };
2106
- var DFA = class DFA2 {
2106
+ var DFA = class DFA {
2107
2107
  static FLAG_EMPTY_MASK = 255;
2108
2108
  static FLAG_MATCH = 256;
2109
2109
  static FLAG_LAST_WORD = 512;
@@ -2225,11 +2225,11 @@ var DFA = class DFA2 {
2225
2225
  let bucket = this.stateCache.get(hash);
2226
2226
  if (bucket)
2227
2227
  for (let i = 0;i < bucket.length; i++) {
2228
- const state2 = bucket[i];
2229
- if (state2.flag === flag && arraysEqual(state2.nfaStates, pcs) && arraysEqual(state2.matchIDs, ids))
2230
- return state2;
2228
+ const state = bucket[i];
2229
+ if (state.flag === flag && arraysEqual(state.nfaStates, pcs) && arraysEqual(state.matchIDs, ids))
2230
+ return state;
2231
2231
  }
2232
- const cost = DFA2.STATE_OVERHEAD + 4 * pcs.length + 8 * ids.length;
2232
+ const cost = DFA.STATE_OVERHEAD + 4 * pcs.length + 8 * ids.length;
2233
2233
  if (this.memBudget < cost)
2234
2234
  return null;
2235
2235
  this.memBudget -= cost;
@@ -2243,16 +2243,16 @@ var DFA = class DFA2 {
2243
2243
  return state;
2244
2244
  }
2245
2245
  makeState(pcs, flag, ids) {
2246
- const closure = this.closure(pcs, flag & DFA2.FLAG_EMPTY_MASK);
2246
+ const closure = this.closure(pcs, flag & DFA.FLAG_EMPTY_MASK);
2247
2247
  let stateFlag = flag;
2248
2248
  if (closure.needflags === 0)
2249
- stateFlag &= DFA2.FLAG_MATCH;
2250
- stateFlag |= closure.needflags << DFA2.FLAG_NEED_SHIFT;
2249
+ stateFlag &= DFA.FLAG_MATCH;
2250
+ stateFlag |= closure.needflags << DFA.FLAG_NEED_SHIFT;
2251
2251
  return this.getState(closure.pcs, stateFlag, ids);
2252
2252
  }
2253
2253
  allocTable(state, anchor) {
2254
2254
  const size = this.numClasses + 1;
2255
- const cost = DFA2.TABLE_OVERHEAD + 8 * size;
2255
+ const cost = DFA.TABLE_OVERHEAD + 8 * size;
2256
2256
  if (this.memBudget < cost)
2257
2257
  return null;
2258
2258
  this.memBudget -= cost;
@@ -2284,8 +2284,8 @@ var DFA = class DFA2 {
2284
2284
  if (table === null)
2285
2285
  return null;
2286
2286
  }
2287
- const needflag = state.flag >>> DFA2.FLAG_NEED_SHIFT;
2288
- const oldbeforeflag = state.flag & DFA2.FLAG_EMPTY_MASK;
2287
+ const needflag = state.flag >>> DFA.FLAG_NEED_SHIFT;
2288
+ const oldbeforeflag = state.flag & DFA.FLAG_EMPTY_MASK;
2289
2289
  let beforeflag = oldbeforeflag;
2290
2290
  let afterflag = 0;
2291
2291
  if (rune === 10) {
@@ -2294,7 +2294,7 @@ var DFA = class DFA2 {
2294
2294
  }
2295
2295
  if (rune === END_TEXT)
2296
2296
  beforeflag |= Utils.EMPTY_END_LINE | Utils.EMPTY_END_TEXT;
2297
- const islastword = (state.flag & DFA2.FLAG_LAST_WORD) !== 0;
2297
+ const islastword = (state.flag & DFA.FLAG_LAST_WORD) !== 0;
2298
2298
  const isword = rune !== END_TEXT && Utils.isWordRune(rune);
2299
2299
  beforeflag |= isword === islastword ? Utils.EMPTY_NO_WORD_BOUNDARY : Utils.EMPTY_WORD_BOUNDARY;
2300
2300
  let pcs = state.nfaStates;
@@ -2320,9 +2320,9 @@ var DFA = class DFA2 {
2320
2320
  nextPCs.push(this.prog.start);
2321
2321
  let flag = afterflag;
2322
2322
  if (ismatch)
2323
- flag |= DFA2.FLAG_MATCH;
2323
+ flag |= DFA.FLAG_MATCH;
2324
2324
  if (isword)
2325
- flag |= DFA2.FLAG_LAST_WORD;
2325
+ flag |= DFA.FLAG_LAST_WORD;
2326
2326
  const nextState = this.makeState(nextPCs, flag, ids);
2327
2327
  if (nextState === null)
2328
2328
  return null;
@@ -2339,7 +2339,7 @@ var DFA = class DFA2 {
2339
2339
  else {
2340
2340
  const r = input.step(pos);
2341
2341
  const nextIsWord = r >= 0 && Utils.isWordRune(r >> 3);
2342
- flags = (context & Utils.EMPTY_WORD_BOUNDARY) !== 0 !== nextIsWord ? DFA2.FLAG_LAST_WORD : 0;
2342
+ flags = (context & Utils.EMPTY_WORD_BOUNDARY) !== 0 !== nextIsWord ? DFA.FLAG_LAST_WORD : 0;
2343
2343
  }
2344
2344
  let state = this.startStates.get(flags);
2345
2345
  if (state === undefined) {
@@ -2358,7 +2358,7 @@ var DFA = class DFA2 {
2358
2358
  let next = this.step(state, cls, rune, anchor);
2359
2359
  if (next !== null)
2360
2360
  return next;
2361
- if (search.resetPos >= 0 && pos - search.resetPos < DFA2.PROGRESS_PER_STATE * this.stateCount)
2361
+ if (search.resetPos >= 0 && pos - search.resetPos < DFA.PROGRESS_PER_STATE * this.stateCount)
2362
2362
  return null;
2363
2363
  search.resetPos = pos;
2364
2364
  const restored = this.resetCache(state);
@@ -2621,12 +2621,12 @@ var BitState = class {
2621
2621
  }
2622
2622
  };
2623
2623
  var bitStatePool = [];
2624
- var Backtracker = class Backtracker2 {
2624
+ var Backtracker = class Backtracker {
2625
2625
  static shouldBacktrack(prog) {
2626
2626
  return prog.numInst() <= MAX_BACKTRACK_PROG;
2627
2627
  }
2628
2628
  static maxBitStateLen(prog) {
2629
- if (!Backtracker2.shouldBacktrack(prog))
2629
+ if (!Backtracker.shouldBacktrack(prog))
2630
2630
  return 0;
2631
2631
  return Math.floor(MAX_BACKTRACK_VECTOR / prog.numInst());
2632
2632
  }
@@ -2956,7 +2956,7 @@ var cleanupOnePass = (p, original) => {
2956
2956
  }
2957
2957
  }
2958
2958
  };
2959
- var OnePass = class OnePass2 {
2959
+ var OnePass = class OnePass {
2960
2960
  static compile(prog) {
2961
2961
  if (prog.start === 0)
2962
2962
  return null;
@@ -3057,7 +3057,7 @@ var OnePass = class OnePass2 {
3057
3057
  break;
3058
3058
  case Inst.ALT:
3059
3059
  case Inst.ALT_MATCH:
3060
- pc = OnePass2.next(inst, rune);
3060
+ pc = OnePass.next(inst, rune);
3061
3061
  continue;
3062
3062
  case Inst.FAIL:
3063
3063
  return null;
@@ -3096,7 +3096,7 @@ var OnePass = class OnePass2 {
3096
3096
  return ncap === 0 ? [] : Utils.toArray(matchcap);
3097
3097
  }
3098
3098
  };
3099
- var Regexp = class Regexp2 {
3099
+ var Regexp = class Regexp {
3100
3100
  static Op = createEnum([
3101
3101
  "NO_MATCH",
3102
3102
  "EMPTY_MATCH",
@@ -3123,7 +3123,7 @@ var Regexp = class Regexp2 {
3123
3123
  "VERTICAL_BAR"
3124
3124
  ]);
3125
3125
  static isPseudoOp(op) {
3126
- return op >= Regexp2.Op.LEFT_PAREN;
3126
+ return op >= Regexp.Op.LEFT_PAREN;
3127
3127
  }
3128
3128
  static emptySubs() {
3129
3129
  return [];
@@ -3134,7 +3134,7 @@ var Regexp = class Regexp2 {
3134
3134
  return "";
3135
3135
  }
3136
3136
  static fromRegexp(re) {
3137
- const regex = new Regexp2(re.op);
3137
+ const regex = new Regexp(re.op);
3138
3138
  regex.flags = re.flags;
3139
3139
  regex.subs = re.subs;
3140
3140
  regex.runes = re.runes;
@@ -3149,7 +3149,7 @@ var Regexp = class Regexp2 {
3149
3149
  constructor(op) {
3150
3150
  this.op = op;
3151
3151
  this.flags = 0;
3152
- this.subs = Regexp2.emptySubs();
3152
+ this.subs = Regexp.emptySubs();
3153
3153
  this.runes = /* @__PURE__ */ new Int32Array(0);
3154
3154
  this.min = 0;
3155
3155
  this.max = 0;
@@ -3160,7 +3160,7 @@ var Regexp = class Regexp2 {
3160
3160
  }
3161
3161
  reinit() {
3162
3162
  this.flags = 0;
3163
- this.subs = Regexp2.emptySubs();
3163
+ this.subs = Regexp.emptySubs();
3164
3164
  this.runes = /* @__PURE__ */ new Int32Array(0);
3165
3165
  this.cap = 0;
3166
3166
  this.min = 0;
@@ -3175,32 +3175,32 @@ var Regexp = class Regexp2 {
3175
3175
  appendTo() {
3176
3176
  let out = "";
3177
3177
  switch (this.op) {
3178
- case Regexp2.Op.NO_MATCH:
3178
+ case Regexp.Op.NO_MATCH:
3179
3179
  out += "[^\\x00-\\x{10FFFF}]";
3180
3180
  break;
3181
- case Regexp2.Op.EMPTY_MATCH:
3181
+ case Regexp.Op.EMPTY_MATCH:
3182
3182
  out += "(?:)";
3183
3183
  break;
3184
- case Regexp2.Op.STAR:
3185
- case Regexp2.Op.PLUS:
3186
- case Regexp2.Op.QUEST:
3187
- case Regexp2.Op.REPEAT: {
3184
+ case Regexp.Op.STAR:
3185
+ case Regexp.Op.PLUS:
3186
+ case Regexp.Op.QUEST:
3187
+ case Regexp.Op.REPEAT: {
3188
3188
  const sub = this.subs[0];
3189
- if (sub.op > Regexp2.Op.CAPTURE || sub.op === Regexp2.Op.LITERAL && sub.runes.length > 1)
3189
+ if (sub.op > Regexp.Op.CAPTURE || sub.op === Regexp.Op.LITERAL && sub.runes.length > 1)
3190
3190
  out += `(?:${sub.appendTo()})`;
3191
3191
  else
3192
3192
  out += sub.appendTo();
3193
3193
  switch (this.op) {
3194
- case Regexp2.Op.STAR:
3194
+ case Regexp.Op.STAR:
3195
3195
  out += "*";
3196
3196
  break;
3197
- case Regexp2.Op.PLUS:
3197
+ case Regexp.Op.PLUS:
3198
3198
  out += "+";
3199
3199
  break;
3200
- case Regexp2.Op.QUEST:
3200
+ case Regexp.Op.QUEST:
3201
3201
  out += "?";
3202
3202
  break;
3203
- case Regexp2.Op.REPEAT:
3203
+ case Regexp.Op.REPEAT:
3204
3204
  out += `{${this.min}`;
3205
3205
  if (this.min !== this.max) {
3206
3206
  out += ",";
@@ -3213,14 +3213,14 @@ var Regexp = class Regexp2 {
3213
3213
  out += "?";
3214
3214
  break;
3215
3215
  }
3216
- case Regexp2.Op.CONCAT:
3216
+ case Regexp.Op.CONCAT:
3217
3217
  for (let sub of this.subs)
3218
- if (sub.op === Regexp2.Op.ALTERNATE)
3218
+ if (sub.op === Regexp.Op.ALTERNATE)
3219
3219
  out += `(?:${sub.appendTo()})`;
3220
3220
  else
3221
3221
  out += sub.appendTo();
3222
3222
  break;
3223
- case Regexp2.Op.ALTERNATE: {
3223
+ case Regexp.Op.ALTERNATE: {
3224
3224
  let sep = "";
3225
3225
  for (let sub of this.subs) {
3226
3226
  out += sep;
@@ -3229,7 +3229,7 @@ var Regexp = class Regexp2 {
3229
3229
  }
3230
3230
  break;
3231
3231
  }
3232
- case Regexp2.Op.LITERAL:
3232
+ case Regexp.Op.LITERAL:
3233
3233
  if ((this.flags & RE2Flags.FOLD_CASE) !== 0)
3234
3234
  out += "(?i:";
3235
3235
  for (let rune of this.runes)
@@ -3237,49 +3237,49 @@ var Regexp = class Regexp2 {
3237
3237
  if ((this.flags & RE2Flags.FOLD_CASE) !== 0)
3238
3238
  out += ")";
3239
3239
  break;
3240
- case Regexp2.Op.ANY_CHAR_NOT_NL:
3240
+ case Regexp.Op.ANY_CHAR_NOT_NL:
3241
3241
  out += "(?-s:.)";
3242
3242
  break;
3243
- case Regexp2.Op.ANY_CHAR:
3243
+ case Regexp.Op.ANY_CHAR:
3244
3244
  out += "(?s:.)";
3245
3245
  break;
3246
- case Regexp2.Op.PLB:
3246
+ case Regexp.Op.PLB:
3247
3247
  out += `(?<=${this.subs[0].appendTo()})`;
3248
3248
  break;
3249
- case Regexp2.Op.NLB:
3249
+ case Regexp.Op.NLB:
3250
3250
  out += `(?<!${this.subs[0].appendTo()})`;
3251
3251
  break;
3252
- case Regexp2.Op.CAPTURE:
3252
+ case Regexp.Op.CAPTURE:
3253
3253
  if (this.name === null || this.name.length === 0)
3254
3254
  out += "(";
3255
3255
  else
3256
3256
  out += `(?P<${this.name}>`;
3257
- if (this.subs[0].op !== Regexp2.Op.EMPTY_MATCH)
3257
+ if (this.subs[0].op !== Regexp.Op.EMPTY_MATCH)
3258
3258
  out += this.subs[0].appendTo();
3259
3259
  out += ")";
3260
3260
  break;
3261
- case Regexp2.Op.BEGIN_TEXT:
3261
+ case Regexp.Op.BEGIN_TEXT:
3262
3262
  out += "\\A";
3263
3263
  break;
3264
- case Regexp2.Op.END_TEXT:
3264
+ case Regexp.Op.END_TEXT:
3265
3265
  if ((this.flags & RE2Flags.WAS_DOLLAR) !== 0)
3266
3266
  out += "(?-m:$)";
3267
3267
  else
3268
3268
  out += "\\z";
3269
3269
  break;
3270
- case Regexp2.Op.BEGIN_LINE:
3270
+ case Regexp.Op.BEGIN_LINE:
3271
3271
  out += "^";
3272
3272
  break;
3273
- case Regexp2.Op.END_LINE:
3273
+ case Regexp.Op.END_LINE:
3274
3274
  out += "$";
3275
3275
  break;
3276
- case Regexp2.Op.WORD_BOUNDARY:
3276
+ case Regexp.Op.WORD_BOUNDARY:
3277
3277
  out += "\\b";
3278
3278
  break;
3279
- case Regexp2.Op.NO_WORD_BOUNDARY:
3279
+ case Regexp.Op.NO_WORD_BOUNDARY:
3280
3280
  out += "\\B";
3281
3281
  break;
3282
- case Regexp2.Op.CHAR_CLASS:
3282
+ case Regexp.Op.CHAR_CLASS:
3283
3283
  if (this.runes.length % 2 !== 0) {
3284
3284
  out += "[invalid char class]";
3285
3285
  break;
@@ -3292,11 +3292,11 @@ var Regexp = class Regexp2 {
3292
3292
  for (let i = 1;i < this.runes.length - 1; i += 2) {
3293
3293
  const lo = this.runes[i] + 1;
3294
3294
  const hi = this.runes[i + 1] - 1;
3295
- out += Regexp2.quoteIfHyphen(lo);
3295
+ out += Regexp.quoteIfHyphen(lo);
3296
3296
  out += Utils.escapeRune(lo);
3297
3297
  if (lo !== hi) {
3298
3298
  out += "-";
3299
- out += Regexp2.quoteIfHyphen(hi);
3299
+ out += Regexp.quoteIfHyphen(hi);
3300
3300
  out += Utils.escapeRune(hi);
3301
3301
  }
3302
3302
  }
@@ -3304,11 +3304,11 @@ var Regexp = class Regexp2 {
3304
3304
  for (let i = 0;i < this.runes.length; i += 2) {
3305
3305
  const lo = this.runes[i];
3306
3306
  const hi = this.runes[i + 1];
3307
- out += Regexp2.quoteIfHyphen(lo);
3307
+ out += Regexp.quoteIfHyphen(lo);
3308
3308
  out += Utils.escapeRune(lo);
3309
3309
  if (lo !== hi) {
3310
3310
  out += "-";
3311
- out += Regexp2.quoteIfHyphen(hi);
3311
+ out += Regexp.quoteIfHyphen(hi);
3312
3312
  out += Utils.escapeRune(hi);
3313
3313
  }
3314
3314
  }
@@ -3321,7 +3321,7 @@ var Regexp = class Regexp2 {
3321
3321
  }
3322
3322
  maxCap() {
3323
3323
  let m = 0;
3324
- if (this.op === Regexp2.Op.CAPTURE)
3324
+ if (this.op === Regexp.Op.CAPTURE)
3325
3325
  m = this.cap;
3326
3326
  if (this.subs !== null)
3327
3327
  for (let sub of this.subs) {
@@ -3332,17 +3332,17 @@ var Regexp = class Regexp2 {
3332
3332
  return m;
3333
3333
  }
3334
3334
  equals(that) {
3335
- if (!(that !== null && that instanceof Regexp2))
3335
+ if (!(that !== null && that instanceof Regexp))
3336
3336
  return false;
3337
3337
  if (this.op !== that.op)
3338
3338
  return false;
3339
3339
  switch (this.op) {
3340
- case Regexp2.Op.END_TEXT:
3340
+ case Regexp.Op.END_TEXT:
3341
3341
  if ((this.flags & RE2Flags.WAS_DOLLAR) !== (that.flags & RE2Flags.WAS_DOLLAR))
3342
3342
  return false;
3343
3343
  break;
3344
- case Regexp2.Op.LITERAL:
3345
- case Regexp2.Op.CHAR_CLASS:
3344
+ case Regexp.Op.LITERAL:
3345
+ case Regexp.Op.CHAR_CLASS:
3346
3346
  if ((this.flags & RE2Flags.FOLD_CASE) !== (that.flags & RE2Flags.FOLD_CASE))
3347
3347
  return false;
3348
3348
  if (this.runes === null && that.runes === null)
@@ -3355,30 +3355,30 @@ var Regexp = class Regexp2 {
3355
3355
  if (this.runes[i] !== that.runes[i])
3356
3356
  return false;
3357
3357
  break;
3358
- case Regexp2.Op.ALTERNATE:
3359
- case Regexp2.Op.CONCAT:
3358
+ case Regexp.Op.ALTERNATE:
3359
+ case Regexp.Op.CONCAT:
3360
3360
  if (this.subs.length !== that.subs.length)
3361
3361
  return false;
3362
3362
  for (let i = 0;i < this.subs.length; ++i)
3363
3363
  if (!this.subs[i].equals(that.subs[i]))
3364
3364
  return false;
3365
3365
  break;
3366
- case Regexp2.Op.STAR:
3367
- case Regexp2.Op.PLUS:
3368
- case Regexp2.Op.QUEST:
3366
+ case Regexp.Op.STAR:
3367
+ case Regexp.Op.PLUS:
3368
+ case Regexp.Op.QUEST:
3369
3369
  if ((this.flags & RE2Flags.NON_GREEDY) !== (that.flags & RE2Flags.NON_GREEDY) || !this.subs[0].equals(that.subs[0]))
3370
3370
  return false;
3371
3371
  break;
3372
- case Regexp2.Op.REPEAT:
3372
+ case Regexp.Op.REPEAT:
3373
3373
  if ((this.flags & RE2Flags.NON_GREEDY) !== (that.flags & RE2Flags.NON_GREEDY) || this.min !== that.min || this.max !== that.max || !this.subs[0].equals(that.subs[0]))
3374
3374
  return false;
3375
3375
  break;
3376
- case Regexp2.Op.CAPTURE:
3376
+ case Regexp.Op.CAPTURE:
3377
3377
  if (this.cap !== that.cap || (this.name === null ? that.name !== null : this.name !== that.name) || !this.subs[0].equals(that.subs[0]))
3378
3378
  return false;
3379
3379
  break;
3380
- case Regexp2.Op.PLB:
3381
- case Regexp2.Op.NLB:
3380
+ case Regexp.Op.PLB:
3381
+ case Regexp.Op.NLB:
3382
3382
  if (this.lb !== that.lb || !this.subs[0].equals(that.subs[0]))
3383
3383
  return false;
3384
3384
  }
@@ -3530,7 +3530,7 @@ var AhoCorasick = class {
3530
3530
  return false;
3531
3531
  }
3532
3532
  };
3533
- var Prefilter = class Prefilter2 {
3533
+ var Prefilter = class Prefilter {
3534
3534
  static Type = {
3535
3535
  NONE: 0,
3536
3536
  EXACT: 1,
@@ -3544,7 +3544,7 @@ var Prefilter = class Prefilter2 {
3544
3544
  this.subs = [];
3545
3545
  this.str = "";
3546
3546
  this.bytes = null;
3547
- this.cost = type === Prefilter2.Type.EXACT ? 1 : 0;
3547
+ this.cost = type === Prefilter.Type.EXACT ? 1 : 0;
3548
3548
  this.allExact = false;
3549
3549
  this.ac16 = null;
3550
3550
  this.ac8 = null;
@@ -3568,16 +3568,16 @@ var Prefilter = class Prefilter2 {
3568
3568
  }
3569
3569
  eval(input, pos) {
3570
3570
  switch (this.type) {
3571
- case Prefilter2.Type.NONE:
3571
+ case Prefilter.Type.NONE:
3572
3572
  return true;
3573
- case Prefilter2.Type.EXACT:
3573
+ case Prefilter.Type.EXACT:
3574
3574
  return input.hasString(this, pos);
3575
- case Prefilter2.Type.AND:
3575
+ case Prefilter.Type.AND:
3576
3576
  for (let i = 0;i < this.subs.length; i++)
3577
3577
  if (!this.subs[i].eval(input, pos))
3578
3578
  return false;
3579
3579
  return true;
3580
- case Prefilter2.Type.OR:
3580
+ case Prefilter.Type.OR:
3581
3581
  if (this.allExact)
3582
3582
  return input.hasAnyString(this, pos);
3583
3583
  for (let i = 0;i < this.subs.length; i++)
@@ -3589,17 +3589,17 @@ var Prefilter = class Prefilter2 {
3589
3589
  }
3590
3590
  }
3591
3591
  };
3592
- var PrefilterTree = class PrefilterTree2 {
3592
+ var PrefilterTree = class PrefilterTree {
3593
3593
  static build(re) {
3594
3594
  if (!re)
3595
3595
  return new Prefilter(Prefilter.Type.NONE);
3596
- return RegexpWalker.walk(re, PrefilterTree2.WALKER);
3596
+ return RegexpWalker.walk(re, PrefilterTree.WALKER);
3597
3597
  }
3598
3598
  static WALKER = {
3599
- leaf: (re) => PrefilterTree2.leaf(re),
3600
- enter: (re) => PrefilterTree2.enter(re),
3601
- child: (re, state, result) => PrefilterTree2.child(re, state, result),
3602
- leave: (re, state) => PrefilterTree2.leave(re, state)
3599
+ leaf: (re) => PrefilterTree.leaf(re),
3600
+ enter: (re) => PrefilterTree.enter(re),
3601
+ child: (re, state, result) => PrefilterTree.child(re, state, result),
3602
+ leave: (re, state) => PrefilterTree.leave(re, state)
3603
3603
  };
3604
3604
  static leaf(re) {
3605
3605
  if (re.op !== Regexp.Op.LITERAL)
@@ -3683,19 +3683,19 @@ var PrefilterTree = class PrefilterTree2 {
3683
3683
  }
3684
3684
  if (pf.type === Prefilter.Type.AND) {
3685
3685
  const kept = [];
3686
- let cost2 = 0;
3686
+ let cost = 0;
3687
3687
  for (const sub of subs) {
3688
- if (cost2 + sub.cost > Prefilter.MAX_SCANS)
3688
+ if (cost + sub.cost > Prefilter.MAX_SCANS)
3689
3689
  continue;
3690
3690
  kept.push(sub);
3691
- cost2 += sub.cost;
3691
+ cost += sub.cost;
3692
3692
  }
3693
3693
  if (kept.length === 0)
3694
3694
  return new Prefilter(Prefilter.Type.NONE);
3695
3695
  if (kept.length === 1)
3696
3696
  return kept[0];
3697
3697
  pf.subs = kept;
3698
- pf.cost = cost2;
3698
+ pf.cost = cost;
3699
3699
  return pf;
3700
3700
  }
3701
3701
  if (subs.length === 0)
@@ -3870,9 +3870,9 @@ var Frag = class {
3870
3870
  this.nullable = nullable;
3871
3871
  }
3872
3872
  };
3873
- var Compiler = class Compiler2 {
3873
+ var Compiler = class Compiler {
3874
3874
  static compileRegexp(re) {
3875
- const c = new Compiler2;
3875
+ const c = new Compiler;
3876
3876
  const f = c.compile(re);
3877
3877
  c.prog.patch(f.out, c.newInst(Inst.MATCH).i);
3878
3878
  c.prog.start = f.i;
@@ -3880,7 +3880,7 @@ var Compiler = class Compiler2 {
3880
3880
  return c.prog;
3881
3881
  }
3882
3882
  static compileSet(regexps) {
3883
- const c = new Compiler2;
3883
+ const c = new Compiler;
3884
3884
  if (regexps.length === 0) {
3885
3885
  c.prog.start = c.newInst(Inst.FAIL).i;
3886
3886
  c.prog.markLookbehindInsts();
@@ -4131,17 +4131,17 @@ var Compiler = class Compiler2 {
4131
4131
  }
4132
4132
  }
4133
4133
  };
4134
- var Simplify = class Simplify2 {
4134
+ var Simplify = class Simplify {
4135
4135
  static simplify(re) {
4136
4136
  if (re === null)
4137
4137
  return null;
4138
- return RegexpWalker.walk(re, Simplify2.WALKER);
4138
+ return RegexpWalker.walk(re, Simplify.WALKER);
4139
4139
  }
4140
4140
  static WALKER = {
4141
- leaf: (re) => Simplify2.leaf(re),
4142
- enter: (re) => Simplify2.enter(re),
4143
- child: (re, state, result, i) => Simplify2.child(re, state, result, i),
4144
- leave: (re, state) => Simplify2.leave(re, state)
4141
+ leaf: (re) => Simplify.leaf(re),
4142
+ enter: (re) => Simplify.enter(re),
4143
+ child: (re, state, result, i) => Simplify.child(re, state, result, i),
4144
+ leave: (re, state) => Simplify.leave(re, state)
4145
4145
  };
4146
4146
  static leaf(re) {
4147
4147
  if (re.op === Regexp.Op.CHAR_CLASS) {
@@ -4248,9 +4248,9 @@ var Simplify = class Simplify2 {
4248
4248
  case Regexp.Op.STAR:
4249
4249
  case Regexp.Op.PLUS:
4250
4250
  case Regexp.Op.QUEST:
4251
- return Simplify2.simplify1(re.op, re.flags, state.sub, re);
4251
+ return Simplify.simplify1(re.op, re.flags, state.sub, re);
4252
4252
  case Regexp.Op.REPEAT:
4253
- return Simplify2.simplifyRepeat(re, state.sub);
4253
+ return Simplify.simplifyRepeat(re, state.sub);
4254
4254
  default:
4255
4255
  return re;
4256
4256
  }
@@ -4258,14 +4258,14 @@ var Simplify = class Simplify2 {
4258
4258
  static simplifyRepeat(re, sub) {
4259
4259
  if (re.max === -1) {
4260
4260
  if (re.min === 0)
4261
- return Simplify2.simplify1(Regexp.Op.STAR, re.flags, sub, null);
4261
+ return Simplify.simplify1(Regexp.Op.STAR, re.flags, sub, null);
4262
4262
  if (re.min === 1)
4263
- return Simplify2.simplify1(Regexp.Op.PLUS, re.flags, sub, null);
4263
+ return Simplify.simplify1(Regexp.Op.PLUS, re.flags, sub, null);
4264
4264
  const subs = [];
4265
4265
  for (let i = 0;i < re.min - 1; i++)
4266
4266
  subs.push(sub);
4267
- subs.push(Simplify2.simplify1(Regexp.Op.PLUS, re.flags, sub, null));
4268
- return Simplify2.concat(subs);
4267
+ subs.push(Simplify.simplify1(Regexp.Op.PLUS, re.flags, sub, null));
4268
+ return Simplify.concat(subs);
4269
4269
  }
4270
4270
  if (re.min === 1 && re.max === 1)
4271
4271
  return sub;
@@ -4276,15 +4276,15 @@ var Simplify = class Simplify2 {
4276
4276
  prefixSubs.push(sub);
4277
4277
  }
4278
4278
  if (re.max > re.min) {
4279
- let suffix = Simplify2.simplify1(Regexp.Op.QUEST, re.flags, sub, null);
4279
+ let suffix = Simplify.simplify1(Regexp.Op.QUEST, re.flags, sub, null);
4280
4280
  for (let i = re.min + 1;i < re.max; i++)
4281
- suffix = Simplify2.simplify1(Regexp.Op.QUEST, re.flags, Simplify2.concat([sub, suffix]), null);
4281
+ suffix = Simplify.simplify1(Regexp.Op.QUEST, re.flags, Simplify.concat([sub, suffix]), null);
4282
4282
  if (prefixSubs === null)
4283
4283
  return suffix;
4284
4284
  prefixSubs.push(suffix);
4285
4285
  }
4286
4286
  if (prefixSubs !== null)
4287
- return Simplify2.concat(prefixSubs);
4287
+ return Simplify.concat(prefixSubs);
4288
4288
  return new Regexp(Regexp.Op.NO_MATCH);
4289
4289
  }
4290
4290
  static concat(subs) {
@@ -4457,7 +4457,7 @@ var POSIX_GROUPS = /* @__PURE__ */ new Map([
4457
4457
  ["[:xdigit:]", new CharGroup(1, code17)],
4458
4458
  ["[:^xdigit:]", new CharGroup(-1, code17)]
4459
4459
  ]);
4460
- var CharClass = class CharClass2 {
4460
+ var CharClass = class CharClass {
4461
4461
  static charClassToString(r, len) {
4462
4462
  let result = "[";
4463
4463
  for (let i = 0;i < len; i += 2) {
@@ -4504,7 +4504,7 @@ var CharClass = class CharClass2 {
4504
4504
  cleanClass() {
4505
4505
  if (this.len < 4)
4506
4506
  return this;
4507
- CharClass2.sortRanges(this.r, this.len);
4507
+ CharClass.sortRanges(this.r, this.len);
4508
4508
  let w = 2;
4509
4509
  for (let i = 2;i < this.len; i += 2) {
4510
4510
  const lo = this.r[i];
@@ -4651,11 +4651,11 @@ var CharClass = class CharClass2 {
4651
4651
  appendGroup(g, foldCase) {
4652
4652
  let cls = g.cls;
4653
4653
  if (foldCase)
4654
- cls = new CharClass2().appendFoldedClass(cls).cleanClass().toArray();
4654
+ cls = new CharClass().appendFoldedClass(cls).cleanClass().toArray();
4655
4655
  return this.appendClassWithSign(cls, g.sign);
4656
4656
  }
4657
4657
  toString() {
4658
- return CharClass2.charClassToString(this.r, this.len);
4658
+ return CharClass.charClassToString(this.r, this.len);
4659
4659
  }
4660
4660
  };
4661
4661
  var StringIterator = class {
@@ -4699,7 +4699,7 @@ var StringIterator = class {
4699
4699
  return this.rest();
4700
4700
  }
4701
4701
  };
4702
- var Parser = class Parser2 {
4702
+ var Parser = class Parser {
4703
4703
  static ERR_INTERNAL_ERROR = "regexp/syntax: internal error";
4704
4704
  static ERR_INVALID_CHAR_RANGE = "invalid character class range";
4705
4705
  static ERR_INVALID_ESCAPE = "invalid escape sequence";
@@ -4743,14 +4743,14 @@ var Parser = class Parser2 {
4743
4743
  static unicodeTable(name) {
4744
4744
  if (name === "Any")
4745
4745
  return {
4746
- tab: Parser2.ANY_TABLE,
4747
- fold: Parser2.ANY_TABLE,
4746
+ tab: Parser.ANY_TABLE,
4747
+ fold: Parser.ANY_TABLE,
4748
4748
  sign: 1
4749
4749
  };
4750
4750
  if (name === "Ascii")
4751
4751
  return {
4752
- tab: Parser2.ASCII_TABLE,
4753
- fold: Parser2.ASCII_FOLD_TABLE,
4752
+ tab: Parser.ASCII_TABLE,
4753
+ fold: Parser.ASCII_FOLD_TABLE,
4754
4754
  sign: 1
4755
4755
  };
4756
4756
  if (name === "Assigned")
@@ -4807,14 +4807,14 @@ var Parser = class Parser2 {
4807
4807
  return re;
4808
4808
  }
4809
4809
  static parse(pattern, flags) {
4810
- return new Parser2(pattern, flags).parseInternal();
4810
+ return new Parser(pattern, flags).parseInternal();
4811
4811
  }
4812
4812
  static parseRepeat(t) {
4813
4813
  const start = t.pos();
4814
4814
  if (!t.more() || !t.lookingAt("{"))
4815
4815
  return -1;
4816
4816
  t.skip(1);
4817
- const min = Parser2.parseInt(t);
4817
+ const min = Parser.parseInt(t);
4818
4818
  if (min === -1)
4819
4819
  return -1;
4820
4820
  if (!t.more())
@@ -4828,14 +4828,14 @@ var Parser = class Parser2 {
4828
4828
  return -1;
4829
4829
  if (t.lookingAt("}"))
4830
4830
  max = -1;
4831
- else if ((max = Parser2.parseInt(t)) === -1)
4831
+ else if ((max = Parser.parseInt(t)) === -1)
4832
4832
  return -1;
4833
4833
  }
4834
4834
  if (!t.more() || !t.lookingAt("}"))
4835
4835
  return -1;
4836
4836
  t.skip(1);
4837
4837
  if (min < 0 || min > 1000 || max === -2 || max > 1000 || max >= 0 && min > max)
4838
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_REPEAT_SIZE, t.from(start));
4838
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_SIZE, t.from(start));
4839
4839
  return min << 16 | max & Unicode.MAX_BMP;
4840
4840
  }
4841
4841
  static isValidCaptureName(name) {
@@ -4884,7 +4884,7 @@ var Parser = class Parser2 {
4884
4884
  case Regexp.Op.ANY_CHAR:
4885
4885
  break;
4886
4886
  case Regexp.Op.ANY_CHAR_NOT_NL:
4887
- if (Parser2.matchRune(src, Codepoint.CODES.get(`
4887
+ if (Parser.matchRune(src, Codepoint.CODES.get(`
4888
4888
  `)))
4889
4889
  dst.op = Regexp.Op.ANY_CHAR;
4890
4890
  break;
@@ -4908,7 +4908,7 @@ var Parser = class Parser2 {
4908
4908
  const startPos = t.pos();
4909
4909
  t.skip(1);
4910
4910
  if (!t.more())
4911
- throw new RE2JSSyntaxException(Parser2.ERR_TRAILING_BACKSLASH);
4911
+ throw new RE2JSSyntaxException(Parser.ERR_TRAILING_BACKSLASH);
4912
4912
  let c = t.pop();
4913
4913
  bigswitch:
4914
4914
  switch (c) {
@@ -4982,13 +4982,13 @@ var Parser = class Parser2 {
4982
4982
  if (c <= Unicode.MAX_ASCII && !Utils.isalnum(c))
4983
4983
  return c;
4984
4984
  }
4985
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_ESCAPE, t.from(startPos));
4985
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_ESCAPE, t.from(startPos));
4986
4986
  }
4987
4987
  static parseClassChar(t, wholeClassPos) {
4988
4988
  if (!t.more())
4989
- throw new RE2JSSyntaxException(Parser2.ERR_MISSING_BRACKET, t.from(wholeClassPos));
4989
+ throw new RE2JSSyntaxException(Parser.ERR_MISSING_BRACKET, t.from(wholeClassPos));
4990
4990
  if (t.lookingAt("\\"))
4991
- return Parser2.parseEscape(t);
4991
+ return Parser.parseEscape(t);
4992
4992
  return t.pop();
4993
4993
  }
4994
4994
  static hasCapture(re) {
@@ -4998,7 +4998,7 @@ var Parser = class Parser2 {
4998
4998
  return true;
4999
4999
  if (re.subs) {
5000
5000
  for (let sub of re.subs)
5001
- if (Parser2.hasCapture(sub))
5001
+ if (Parser.hasCapture(sub))
5002
5002
  return true;
5003
5003
  }
5004
5004
  return false;
@@ -5037,8 +5037,8 @@ var Parser = class Parser2 {
5037
5037
  this.free = re;
5038
5038
  }
5039
5039
  checkLimits(re) {
5040
- if (this.numRunes > Parser2.MAX_RUNES)
5041
- throw new RE2JSSyntaxException(Parser2.ERR_LARGE);
5040
+ if (this.numRunes > Parser.MAX_RUNES)
5041
+ throw new RE2JSSyntaxException(Parser.ERR_LARGE);
5042
5042
  this.checkSize(re);
5043
5043
  this.checkHeight(re);
5044
5044
  }
@@ -5052,19 +5052,19 @@ var Parser = class Parser2 {
5052
5052
  n = re.min;
5053
5053
  if (n <= 0)
5054
5054
  n = 1;
5055
- if (n > Math.floor(Parser2.MAX_SIZE / this.repeats))
5056
- this.repeats = Parser2.MAX_SIZE;
5055
+ if (n > Math.floor(Parser.MAX_SIZE / this.repeats))
5056
+ this.repeats = Parser.MAX_SIZE;
5057
5057
  else
5058
5058
  this.repeats *= n;
5059
5059
  }
5060
- if (this.numRegexp < Math.floor(Parser2.MAX_SIZE / this.repeats))
5060
+ if (this.numRegexp < Math.floor(Parser.MAX_SIZE / this.repeats))
5061
5061
  return;
5062
5062
  this.size = /* @__PURE__ */ new Map;
5063
5063
  for (let reEx of this.stack)
5064
5064
  this.checkSize(reEx);
5065
5065
  }
5066
- if (this.calcSize(re, true) > Parser2.MAX_SIZE)
5067
- throw new RE2JSSyntaxException(Parser2.ERR_LARGE);
5066
+ if (this.calcSize(re, true) > Parser.MAX_SIZE)
5067
+ throw new RE2JSSyntaxException(Parser.ERR_LARGE);
5068
5068
  }
5069
5069
  calcSize(re, force = false) {
5070
5070
  if (!force && this.size !== null) {
@@ -5116,15 +5116,15 @@ var Parser = class Parser2 {
5116
5116
  return size;
5117
5117
  }
5118
5118
  checkHeight(re) {
5119
- if (this.numRegexp < Parser2.MAX_HEIGHT)
5119
+ if (this.numRegexp < Parser.MAX_HEIGHT)
5120
5120
  return;
5121
5121
  if (this.height === null) {
5122
5122
  this.height = /* @__PURE__ */ new Map;
5123
5123
  for (let reEx of this.stack)
5124
5124
  this.checkHeight(reEx);
5125
5125
  }
5126
- if (this.calcHeight(re, true) > Parser2.MAX_HEIGHT)
5127
- throw new RE2JSSyntaxException(Parser2.ERR_NESTING_DEPTH);
5126
+ if (this.calcHeight(re, true) > Parser.MAX_HEIGHT)
5127
+ throw new RE2JSSyntaxException(Parser.ERR_NESTING_DEPTH);
5128
5128
  }
5129
5129
  calcHeight(re, force = false) {
5130
5130
  if (!force && this.height !== null) {
@@ -5197,7 +5197,7 @@ var Parser = class Parser2 {
5197
5197
  const re = this.newRegexp(Regexp.Op.LITERAL);
5198
5198
  re.flags = flags;
5199
5199
  if ((flags & RE2Flags.FOLD_CASE) !== 0)
5200
- r = Parser2.minFoldRune(r);
5200
+ r = Parser.minFoldRune(r);
5201
5201
  re.runes = [r];
5202
5202
  return re;
5203
5203
  }
@@ -5217,14 +5217,14 @@ var Parser = class Parser2 {
5217
5217
  flags ^= RE2Flags.NON_GREEDY;
5218
5218
  }
5219
5219
  if (lastRepeatPos !== -1)
5220
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_REPEAT_OP, t.from(lastRepeatPos));
5220
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_OP, t.from(lastRepeatPos));
5221
5221
  }
5222
5222
  const n = this.stack.length;
5223
5223
  if (n === 0)
5224
- throw new RE2JSSyntaxException(Parser2.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos));
5224
+ throw new RE2JSSyntaxException(Parser.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos));
5225
5225
  const sub = this.stack[n - 1];
5226
5226
  if (Regexp.isPseudoOp(sub.op))
5227
- throw new RE2JSSyntaxException(Parser2.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos));
5227
+ throw new RE2JSSyntaxException(Parser.ERR_MISSING_REPEAT_ARGUMENT, t.from(beforePos));
5228
5228
  const re = this.newRegexp(op);
5229
5229
  re.min = min;
5230
5230
  re.max = max;
@@ -5233,7 +5233,7 @@ var Parser = class Parser2 {
5233
5233
  this.stack[n - 1] = re;
5234
5234
  this.checkLimits(re);
5235
5235
  if (op === Regexp.Op.REPEAT && (min >= 2 || max >= 2) && !this.repeatIsValid(re, 1000))
5236
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_REPEAT_SIZE, t.from(beforePos));
5236
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_REPEAT_SIZE, t.from(beforePos));
5237
5237
  }
5238
5238
  repeatIsValid(re, n) {
5239
5239
  if (re.op === Regexp.Op.REPEAT) {
@@ -5369,8 +5369,8 @@ var Parser = class Parser2 {
5369
5369
  for (let i = 0;i <= lensub; i++) {
5370
5370
  let ifirst = null;
5371
5371
  if (i < lensub) {
5372
- ifirst = Parser2.leadingRegexp(array[s + i]);
5373
- if (first !== null && first.equals(ifirst) && (Parser2.isCharClass(first) || first.op === Regexp.Op.REPEAT && first.min === first.max && Parser2.isCharClass(first.subs[0])))
5372
+ ifirst = Parser.leadingRegexp(array[s + i]);
5373
+ if (first !== null && first.equals(ifirst) && (Parser.isCharClass(first) || first.op === Regexp.Op.REPEAT && first.min === first.max && Parser.isCharClass(first.subs[0])))
5374
5374
  continue;
5375
5375
  }
5376
5376
  if (i === start) {} else if (i === start + 1)
@@ -5395,7 +5395,7 @@ var Parser = class Parser2 {
5395
5395
  start = 0;
5396
5396
  lenout = 0;
5397
5397
  for (let i = 0;i <= lensub; i++) {
5398
- if (i < lensub && Parser2.isCharClass(array[s + i]))
5398
+ if (i < lensub && Parser.isCharClass(array[s + i]))
5399
5399
  continue;
5400
5400
  if (i === start) {} else if (i === start + 1)
5401
5401
  array[lenout++] = array[s + start];
@@ -5411,7 +5411,7 @@ var Parser = class Parser2 {
5411
5411
  array[s + start] = array[s + max];
5412
5412
  array[s + max] = tmp;
5413
5413
  for (let j = start + 1;j < i; j++) {
5414
- Parser2.mergeCharClass(array[s + start], array[s + j]);
5414
+ Parser.mergeCharClass(array[s + start], array[s + j]);
5415
5415
  this.reuse(array[s + j]);
5416
5416
  }
5417
5417
  this.cleanAlt(array[s + start]);
@@ -5490,7 +5490,7 @@ var Parser = class Parser2 {
5490
5490
  }
5491
5491
  parseInternal() {
5492
5492
  if ((this.flags & RE2Flags.LITERAL) !== 0)
5493
- return Parser2.literalRegexp(this.wholeRegexp, this.flags);
5493
+ return Parser.literalRegexp(this.wholeRegexp, this.flags);
5494
5494
  let lastRepeatPos = -1;
5495
5495
  let min = -1;
5496
5496
  let max = -1;
@@ -5571,7 +5571,7 @@ var Parser = class Parser2 {
5571
5571
  }
5572
5572
  case Codepoint.CODES.get("{"): {
5573
5573
  const before = t.pos();
5574
- const minMax = Parser2.parseRepeat(t);
5574
+ const minMax = Parser.parseRepeat(t);
5575
5575
  if (minMax < 0) {
5576
5576
  t.rewindTo(before);
5577
5577
  this.literal(t.pop());
@@ -5598,7 +5598,7 @@ var Parser = class Parser2 {
5598
5598
  this.op(Regexp.Op.NO_WORD_BOUNDARY);
5599
5599
  break bigswitch;
5600
5600
  case Codepoint.CODES.get("C"):
5601
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_ESCAPE, "\\C");
5601
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_ESCAPE, "\\C");
5602
5602
  case Codepoint.CODES.get("Q"): {
5603
5603
  let lit = t.rest();
5604
5604
  const i = lit.indexOf("\\E");
@@ -5627,9 +5627,9 @@ var Parser = class Parser2 {
5627
5627
  const re = this.newRegexp(Regexp.Op.CHAR_CLASS);
5628
5628
  re.flags = this.flags;
5629
5629
  if (t.lookingAt("\\p") || t.lookingAt("\\P")) {
5630
- const cc2 = new CharClass;
5631
- if (this.parseUnicodeClass(t, cc2)) {
5632
- re.runes = cc2.toArray();
5630
+ const cc = new CharClass;
5631
+ if (this.parseUnicodeClass(t, cc)) {
5632
+ re.runes = cc.toArray();
5633
5633
  this.push(re);
5634
5634
  break bigswitch;
5635
5635
  }
@@ -5642,7 +5642,7 @@ var Parser = class Parser2 {
5642
5642
  }
5643
5643
  t.rewindTo(savedPos);
5644
5644
  this.reuse(re);
5645
- this.literal(Parser2.parseEscape(t));
5645
+ this.literal(Parser.parseEscape(t));
5646
5646
  break;
5647
5647
  }
5648
5648
  default:
@@ -5655,7 +5655,7 @@ var Parser = class Parser2 {
5655
5655
  this.pop();
5656
5656
  this.alternate();
5657
5657
  if (this.stack.length !== 1)
5658
- throw new RE2JSSyntaxException(Parser2.ERR_MISSING_PAREN, this.wholeRegexp);
5658
+ throw new RE2JSSyntaxException(Parser.ERR_MISSING_PAREN, this.wholeRegexp);
5659
5659
  this.stack[0].namedGroups = this.namedGroups;
5660
5660
  return this.stack[0];
5661
5661
  }
@@ -5666,16 +5666,16 @@ var Parser = class Parser2 {
5666
5666
  const begin = s.charAt(2) === "P" ? 4 : 3;
5667
5667
  const end = s.indexOf(">");
5668
5668
  if (end < 0)
5669
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_NAMED_CAPTURE, s);
5669
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s);
5670
5670
  const name = s.substring(begin, end);
5671
5671
  t.skipString(name);
5672
5672
  t.skip(begin + 1);
5673
- if (!Parser2.isValidCaptureName(name))
5674
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_NAMED_CAPTURE, s.substring(0, end + 1));
5673
+ if (!Parser.isValidCaptureName(name))
5674
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s.substring(0, end + 1));
5675
5675
  const re = this.op(Regexp.Op.LEFT_PAREN);
5676
5676
  re.cap = ++this.numCap;
5677
5677
  if (this.namedGroups[name])
5678
- throw new RE2JSSyntaxException(Parser2.ERR_DUPLICATE_NAMED_CAPTURE, name);
5678
+ throw new RE2JSSyntaxException(Parser.ERR_DUPLICATE_NAMED_CAPTURE, name);
5679
5679
  this.namedGroups[name] = this.numCap;
5680
5680
  re.name = name;
5681
5681
  return;
@@ -5726,7 +5726,7 @@ var Parser = class Parser2 {
5726
5726
  break loop;
5727
5727
  }
5728
5728
  }
5729
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_PERL_OP, t.from(startPos));
5729
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_PERL_OP, t.from(startPos));
5730
5730
  }
5731
5731
  parsePosLookBehind() {
5732
5732
  const re = this.newRegexp(Regexp.Op.LEFT_PAREN);
@@ -5747,7 +5747,7 @@ var Parser = class Parser2 {
5747
5747
  }
5748
5748
  swapVerticalBar() {
5749
5749
  const n = this.stack.length;
5750
- if (n >= 3 && this.stack[n - 2].op === Regexp.Op.VERTICAL_BAR && Parser2.isCharClass(this.stack[n - 1]) && Parser2.isCharClass(this.stack[n - 3])) {
5750
+ if (n >= 3 && this.stack[n - 2].op === Regexp.Op.VERTICAL_BAR && Parser.isCharClass(this.stack[n - 1]) && Parser.isCharClass(this.stack[n - 3])) {
5751
5751
  let re1 = this.stack[n - 1];
5752
5752
  let re3 = this.stack[n - 3];
5753
5753
  if (re1.op > re3.op) {
@@ -5756,7 +5756,7 @@ var Parser = class Parser2 {
5756
5756
  re1 = tmp;
5757
5757
  this.stack[n - 3] = re3;
5758
5758
  }
5759
- Parser2.mergeCharClass(re3, re1);
5759
+ Parser.mergeCharClass(re3, re1);
5760
5760
  this.reuse(re1);
5761
5761
  this.pop();
5762
5762
  return true;
@@ -5780,15 +5780,15 @@ var Parser = class Parser2 {
5780
5780
  this.pop();
5781
5781
  this.alternate();
5782
5782
  if (this.stack.length < 2)
5783
- throw new RE2JSSyntaxException(Parser2.ERR_UNEXPECTED_PAREN, this.wholeRegexp);
5783
+ throw new RE2JSSyntaxException(Parser.ERR_UNEXPECTED_PAREN, this.wholeRegexp);
5784
5784
  const re1 = this.pop();
5785
5785
  const re2 = this.pop();
5786
5786
  if (re2.op !== Regexp.Op.LEFT_PAREN)
5787
- throw new RE2JSSyntaxException(Parser2.ERR_UNEXPECTED_PAREN, this.wholeRegexp);
5787
+ throw new RE2JSSyntaxException(Parser.ERR_UNEXPECTED_PAREN, this.wholeRegexp);
5788
5788
  this.flags = re2.flags;
5789
5789
  if (re2.lb !== 0) {
5790
- if (Parser2.hasCapture(re1))
5791
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CAPTURE_IN_LOOKBEHIND, this.wholeRegexp);
5790
+ if (Parser.hasCapture(re1))
5791
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CAPTURE_IN_LOOKBEHIND, this.wholeRegexp);
5792
5792
  if (re2.lb > 0)
5793
5793
  re2.op = Regexp.Op.PLB;
5794
5794
  else
@@ -5826,7 +5826,7 @@ var Parser = class Parser2 {
5826
5826
  t.skipString(name);
5827
5827
  const g = POSIX_GROUPS.has(name) ? POSIX_GROUPS.get(name) : null;
5828
5828
  if (g === null)
5829
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, name);
5829
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, name);
5830
5830
  cc.appendGroup(g, (this.flags & RE2Flags.FOLD_CASE) !== 0);
5831
5831
  return true;
5832
5832
  }
@@ -5841,7 +5841,7 @@ var Parser = class Parser2 {
5841
5841
  sign = -1;
5842
5842
  if (!t.more()) {
5843
5843
  t.rewindTo(startPos);
5844
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, t.rest());
5844
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest());
5845
5845
  }
5846
5846
  c = t.pop();
5847
5847
  let name;
@@ -5852,7 +5852,7 @@ var Parser = class Parser2 {
5852
5852
  const end = rest.indexOf("}");
5853
5853
  if (end < 0) {
5854
5854
  t.rewindTo(startPos);
5855
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, t.rest());
5855
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest());
5856
5856
  }
5857
5857
  name = rest.substring(0, end);
5858
5858
  t.skipString(name);
@@ -5862,9 +5862,9 @@ var Parser = class Parser2 {
5862
5862
  sign = 0 - sign;
5863
5863
  name = name.substring(1);
5864
5864
  }
5865
- const pair = Parser2.unicodeTable(name);
5865
+ const pair = Parser.unicodeTable(name);
5866
5866
  if (pair === null)
5867
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, t.from(startPos));
5867
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.from(startPos));
5868
5868
  if (pair.sign < 0)
5869
5869
  sign = 0 - sign;
5870
5870
  const tab = pair.tab;
@@ -5898,7 +5898,7 @@ var Parser = class Parser2 {
5898
5898
  const s = t.rest();
5899
5899
  if (s === "-" || !s.startsWith("-]")) {
5900
5900
  t.rewindTo(startPos);
5901
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, t.rest());
5901
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.rest());
5902
5902
  }
5903
5903
  }
5904
5904
  first = false;
@@ -5913,16 +5913,16 @@ var Parser = class Parser2 {
5913
5913
  if (this.parsePerlClassEscape(t, cc))
5914
5914
  continue;
5915
5915
  t.rewindTo(beforePos);
5916
- const lo = Parser2.parseClassChar(t, startPos);
5916
+ const lo = Parser.parseClassChar(t, startPos);
5917
5917
  let hi = lo;
5918
5918
  if (t.more() && t.lookingAt("-")) {
5919
5919
  t.skip(1);
5920
5920
  if (t.more() && t.lookingAt("]"))
5921
5921
  t.skip(-1);
5922
5922
  else {
5923
- hi = Parser2.parseClassChar(t, startPos);
5923
+ hi = Parser.parseClassChar(t, startPos);
5924
5924
  if (hi < lo)
5925
- throw new RE2JSSyntaxException(Parser2.ERR_INVALID_CHAR_RANGE, t.from(beforePos));
5925
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_CHAR_RANGE, t.from(beforePos));
5926
5926
  }
5927
5927
  }
5928
5928
  if ((this.flags & RE2Flags.FOLD_CASE) === 0)
@@ -5938,10 +5938,10 @@ var Parser = class Parser2 {
5938
5938
  this.push(re);
5939
5939
  }
5940
5940
  };
5941
- var RE2 = class RE22 {
5941
+ var RE2 = class RE2 {
5942
5942
  static initTest(expr) {
5943
- const re2 = RE22.compile(expr);
5944
- const res = new RE22(re2.expr, re2.prog, re2.numSubexp, re2.longest);
5943
+ const re2 = RE2.compile(expr);
5944
+ const res = new RE2(re2.expr, re2.prog, re2.numSubexp, re2.longest);
5945
5945
  res.cond = re2.cond;
5946
5946
  res.prefix = re2.prefix;
5947
5947
  res.prefixUTF8 = re2.prefixUTF8;
@@ -5951,10 +5951,10 @@ var RE2 = class RE22 {
5951
5951
  return res;
5952
5952
  }
5953
5953
  static compile(expr) {
5954
- return RE22.compileImpl(expr, RE2Flags.PERL, false);
5954
+ return RE2.compileImpl(expr, RE2Flags.PERL, false);
5955
5955
  }
5956
5956
  static compilePOSIX(expr) {
5957
- return RE22.compileImpl(expr, RE2Flags.POSIX, true);
5957
+ return RE2.compileImpl(expr, RE2Flags.POSIX, true);
5958
5958
  }
5959
5959
  static compileImpl(expr, mode, longest) {
5960
5960
  let re = Parser.parse(expr, mode);
@@ -5963,7 +5963,7 @@ var RE2 = class RE22 {
5963
5963
  re = Simplify.simplify(re);
5964
5964
  const prefilter = PrefilterTree.build(re);
5965
5965
  const prog = Compiler.compileRegexp(re);
5966
- const re2 = new RE22(expr, prog, maxCap, longest);
5966
+ const re2 = new RE2(expr, prog, maxCap, longest);
5967
5967
  re2.prefilter = prefilter.type === Prefilter.Type.NONE ? null : prefilter;
5968
5968
  const [prefixCompl, prefixStr] = prog.prefix();
5969
5969
  re2.prefixComplete = prefixCompl;
@@ -5975,7 +5975,7 @@ var RE2 = class RE22 {
5975
5975
  return re2;
5976
5976
  }
5977
5977
  static match(pattern, s) {
5978
- return RE22.compile(pattern).match(s);
5978
+ return RE2.compile(pattern).match(s);
5979
5979
  }
5980
5980
  constructor(expr, prog, numSubexp = 0, longest = 0) {
5981
5981
  this.expr = expr;
@@ -6292,11 +6292,11 @@ var RE2 = class RE22 {
6292
6292
  return result;
6293
6293
  }
6294
6294
  };
6295
- var RE2Set = class RE2Set2 {
6295
+ var RE2Set = class RE2Set {
6296
6296
  static UNANCHORED = RE2Flags.UNANCHORED;
6297
6297
  static ANCHOR_START = RE2Flags.ANCHOR_START;
6298
6298
  static ANCHOR_BOTH = RE2Flags.ANCHOR_BOTH;
6299
- constructor(anchor = RE2Set2.UNANCHORED, flags = 0, maxMem = 8388608) {
6299
+ constructor(anchor = RE2Set.UNANCHORED, flags = 0, maxMem = 8388608) {
6300
6300
  this.anchor = anchor;
6301
6301
  this.jsFlags = flags;
6302
6302
  this.maxMem = maxMem;
@@ -6346,9 +6346,9 @@ var RE2Set = class RE2Set2 {
6346
6346
  this.compile();
6347
6347
  const machineInput = Utils.isByteArray(input) ? MachineInput.fromUTF8(input) : MachineInput.fromUTF16(input);
6348
6348
  let internalAnchor = RE2Flags.UNANCHORED;
6349
- if (this.anchor === RE2Set2.ANCHOR_START)
6349
+ if (this.anchor === RE2Set.ANCHOR_START)
6350
6350
  internalAnchor = RE2Flags.ANCHOR_START;
6351
- else if (this.anchor === RE2Set2.ANCHOR_BOTH)
6351
+ else if (this.anchor === RE2Set.ANCHOR_BOTH)
6352
6352
  internalAnchor = RE2Flags.ANCHOR_BOTH;
6353
6353
  const dfaResult = this.dfa.matchSet(machineInput, 0, internalAnchor);
6354
6354
  if (dfaResult !== null)
@@ -6358,7 +6358,7 @@ var RE2Set = class RE2Set2 {
6358
6358
  return machine.matchSet(machineInput, 0, internalAnchor);
6359
6359
  }
6360
6360
  };
6361
- var TranslateRegExpString = class TranslateRegExpString2 {
6361
+ var TranslateRegExpString = class TranslateRegExpString {
6362
6362
  static isHexadecimal(ch) {
6363
6363
  return "0" <= ch && ch <= "9" || "A" <= ch && ch <= "F" || "a" <= ch && ch <= "f";
6364
6364
  }
@@ -6423,7 +6423,7 @@ var TranslateRegExpString = class TranslateRegExpString2 {
6423
6423
  closed = true;
6424
6424
  break;
6425
6425
  }
6426
- if (!TranslateRegExpString2.isHexadecimal(hexChar))
6426
+ if (!TranslateRegExpString.isHexadecimal(hexChar))
6427
6427
  break;
6428
6428
  hasHex = true;
6429
6429
  j++;
@@ -6437,7 +6437,7 @@ var TranslateRegExpString = class TranslateRegExpString2 {
6437
6437
  } else if (i + 5 < size) {
6438
6438
  let isHex4 = true;
6439
6439
  for (let j = 0;j < 4; j++)
6440
- if (!TranslateRegExpString2.isHexadecimal(data[i + 2 + j])) {
6440
+ if (!TranslateRegExpString.isHexadecimal(data[i + 2 + j])) {
6441
6441
  isHex4 = false;
6442
6442
  break;
6443
6443
  }
@@ -6465,14 +6465,14 @@ var TranslateRegExpString = class TranslateRegExpString2 {
6465
6465
  closed = true;
6466
6466
  break;
6467
6467
  }
6468
- if (!TranslateRegExpString2.isHexadecimal(hexChar))
6468
+ if (!TranslateRegExpString.isHexadecimal(hexChar))
6469
6469
  break;
6470
6470
  hasHex = true;
6471
6471
  j++;
6472
6472
  }
6473
6473
  if (closed && hasHex)
6474
6474
  isValidHex = true;
6475
- } else if (i + 3 < size && TranslateRegExpString2.isHexadecimal(data[i + 2]) && TranslateRegExpString2.isHexadecimal(data[i + 3]))
6475
+ } else if (i + 3 < size && TranslateRegExpString.isHexadecimal(data[i + 2]) && TranslateRegExpString.isHexadecimal(data[i + 3]))
6476
6476
  isValidHex = true;
6477
6477
  if (isValidHex) {
6478
6478
  result += "\\x";
@@ -6516,17 +6516,17 @@ var TranslateRegExpString = class TranslateRegExpString2 {
6516
6516
  i += 2;
6517
6517
  continue;
6518
6518
  default: {
6519
- let cp2 = data.codePointAt(i + 1);
6520
- if (cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122) {
6521
- let symSize2 = Utils.charCount(cp2);
6522
- result += data.substring(i + 1, i + 1 + symSize2);
6523
- i += symSize2 + 1;
6519
+ let cp = data.codePointAt(i + 1);
6520
+ if (cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122) {
6521
+ let symSize = Utils.charCount(cp);
6522
+ result += data.substring(i + 1, i + 1 + symSize);
6523
+ i += symSize + 1;
6524
6524
  changed = true;
6525
6525
  } else {
6526
6526
  result += "\\";
6527
- let symSize2 = Utils.charCount(cp2);
6528
- result += data.substring(i + 1, i + 1 + symSize2);
6529
- i += symSize2 + 1;
6527
+ let symSize = Utils.charCount(cp);
6528
+ result += data.substring(i + 1, i + 1 + symSize);
6529
+ i += symSize + 1;
6530
6530
  }
6531
6531
  continue;
6532
6532
  }
@@ -6560,7 +6560,7 @@ var TranslateRegExpString = class TranslateRegExpString2 {
6560
6560
  return finalResult;
6561
6561
  }
6562
6562
  };
6563
- var RE2JS = class RE2JS2 {
6563
+ var RE2JS = class RE2JS {
6564
6564
  static CASE_INSENSITIVE = PublicFlags.CASE_INSENSITIVE;
6565
6565
  static DOTALL = PublicFlags.DOTALL;
6566
6566
  static MULTILINE = PublicFlags.MULTILINE;
@@ -6578,32 +6578,32 @@ var RE2JS = class RE2JS2 {
6578
6578
  }
6579
6579
  static compile(regex, flags = 0) {
6580
6580
  let fregex = regex;
6581
- if ((flags & RE2JS2.CASE_INSENSITIVE) !== 0)
6581
+ if ((flags & RE2JS.CASE_INSENSITIVE) !== 0)
6582
6582
  fregex = `(?i)${fregex}`;
6583
- if ((flags & RE2JS2.DOTALL) !== 0)
6583
+ if ((flags & RE2JS.DOTALL) !== 0)
6584
6584
  fregex = `(?s)${fregex}`;
6585
- if ((flags & RE2JS2.MULTILINE) !== 0)
6585
+ if ((flags & RE2JS.MULTILINE) !== 0)
6586
6586
  fregex = `(?m)${fregex}`;
6587
- if ((flags & ~(RE2JS2.MULTILINE | RE2JS2.DOTALL | RE2JS2.CASE_INSENSITIVE | RE2JS2.DISABLE_UNICODE_GROUPS | RE2JS2.LONGEST_MATCH | RE2JS2.LOOKBEHINDS)) !== 0)
6587
+ if ((flags & ~(RE2JS.MULTILINE | RE2JS.DOTALL | RE2JS.CASE_INSENSITIVE | RE2JS.DISABLE_UNICODE_GROUPS | RE2JS.LONGEST_MATCH | RE2JS.LOOKBEHINDS)) !== 0)
6588
6588
  throw new RE2JSFlagsException("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH, LOOKBEHINDS");
6589
6589
  let re2Flags = RE2Flags.PERL;
6590
- if ((flags & RE2JS2.DISABLE_UNICODE_GROUPS) !== 0)
6590
+ if ((flags & RE2JS.DISABLE_UNICODE_GROUPS) !== 0)
6591
6591
  re2Flags &= ~RE2Flags.UNICODE_GROUPS;
6592
- if ((flags & RE2JS2.LOOKBEHINDS) !== 0)
6592
+ if ((flags & RE2JS.LOOKBEHINDS) !== 0)
6593
6593
  re2Flags |= RE2Flags.LOOKBEHIND;
6594
- const p = new RE2JS2(regex, flags);
6595
- p.re2Input = RE2.compileImpl(fregex, re2Flags, (flags & RE2JS2.LONGEST_MATCH) !== 0);
6594
+ const p = new RE2JS(regex, flags);
6595
+ p.re2Input = RE2.compileImpl(fregex, re2Flags, (flags & RE2JS.LONGEST_MATCH) !== 0);
6596
6596
  return p;
6597
6597
  }
6598
6598
  static matches(regex, input) {
6599
- return RE2JS2.compile(regex).testExact(input);
6599
+ return RE2JS.compile(regex).testExact(input);
6600
6600
  }
6601
6601
  static initTest(pattern, flags, re2) {
6602
6602
  if (pattern == null)
6603
6603
  throw new Error("pattern is null");
6604
6604
  if (re2 == null)
6605
6605
  throw new Error("re2 is null");
6606
- const p = new RE2JS2(pattern, flags);
6606
+ const p = new RE2JS(pattern, flags);
6607
6607
  p.re2Input = re2;
6608
6608
  return p;
6609
6609
  }
@@ -6973,6 +6973,7 @@ var DEFAULT_MEDIA_FORMS = [
6973
6973
  ];
6974
6974
  var ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024;
6975
6975
  var APPROVAL_TITLE_FIELD = "approvalTitle";
6976
+ var TIMEZONE_HEADER = "X-Cortex-Timezone";
6976
6977
  var TRIGGER_DROP_REASONS = ["busy", "approval_pending", "budget", "rate_limited"];
6977
6978
  var TRIGGER_REASONS = [
6978
6979
  ...TRIGGER_DROP_REASONS,
@@ -7494,10 +7495,13 @@ import { z as z4 } from "zod";
7494
7495
 
7495
7496
  // ../../internal/contracts/src/management/procedures.generated.ts
7496
7497
  var managementProcedureKinds = {
7498
+ "agents.addAlias": "mutation",
7497
7499
  "agents.create": "mutation",
7498
7500
  "agents.delete": "mutation",
7501
+ "agents.deleteAlias": "mutation",
7499
7502
  "agents.get": "query",
7500
7503
  "agents.list": "query",
7504
+ "agents.listAliases": "query",
7501
7505
  "agents.options": "query",
7502
7506
  "agents.publishPrompt": "mutation",
7503
7507
  "agents.rollbackPrompt": "mutation",
@@ -7586,12 +7590,9 @@ var managementProcedureKinds = {
7586
7590
  "secrets.set": "mutation",
7587
7591
  "servers.create": "mutation",
7588
7592
  "servers.delete": "mutation",
7589
- "servers.deleteAlias": "mutation",
7590
7593
  "servers.get": "query",
7591
7594
  "servers.list": "query",
7592
- "servers.listAliases": "query",
7593
7595
  "servers.options": "query",
7594
- "servers.setAlias": "mutation",
7595
7596
  "servers.sync": "mutation",
7596
7597
  "servers.update": "mutation",
7597
7598
  "services.create": "mutation",
@@ -7719,7 +7720,9 @@ async function callManagement(target, request) {
7719
7720
  method: method.toUpperCase(),
7720
7721
  headers: {
7721
7722
  Authorization: `Bearer ${target.key}`,
7722
- ...method === "post" ? { "Content-Type": "application/json" } : {}
7723
+ ...method === "post" ? { "Content-Type": "application/json" } : {},
7724
+ ...target.locale ? { "Accept-Language": target.locale } : {},
7725
+ ...target.timeZone ? { [TIMEZONE_HEADER]: target.timeZone } : {}
7723
7726
  },
7724
7727
  body: method === "post" && input !== undefined ? JSON.stringify(input) : undefined,
7725
7728
  signal
@@ -8136,7 +8139,7 @@ function propertyIssues(property, bindings) {
8136
8139
  }
8137
8140
  function bindingIssues(property, type, bindings) {
8138
8141
  const issues = new Array;
8139
- const scalar = SCALAR_TYPES.some((scalar2) => scalar2 === type);
8142
+ const scalar = SCALAR_TYPES.some((scalar) => scalar === type);
8140
8143
  const fields = { "x-source": "a top-level scalar field", "x-target": "a top-level field" };
8141
8144
  for (const binding of ["x-source", "x-target"]) {
8142
8145
  if (property[binding] === undefined)
@@ -8511,7 +8514,7 @@ var AGENT_LIMITS = { nameLength: 120 };
8511
8514
  var manifestAgentSchema = z5.strictObject({
8512
8515
  slug: agentSlugSchema,
8513
8516
  name: z5.string().trim().min(1).max(AGENT_LIMITS.nameLength),
8514
- server: nameSchema,
8517
+ server: nameSchema.optional(),
8515
8518
  prompt: z5.string().trim().min(1),
8516
8519
  auth: agentAuthSchema,
8517
8520
  models: z5.strictObject({
@@ -8541,6 +8544,23 @@ var manifestAgentSchema = z5.strictObject({
8541
8544
  "suggestions",
8542
8545
  "greeting"
8543
8546
  ])
8547
+ }).superRefine((agent, context) => {
8548
+ if (agent.server !== undefined)
8549
+ return;
8550
+ if (agent.auth.kind === "server") {
8551
+ context.addIssue({
8552
+ code: "custom",
8553
+ path: ["auth"],
8554
+ message: "server auth needs a server"
8555
+ });
8556
+ }
8557
+ if (agent.models.chat === undefined) {
8558
+ context.addIssue({
8559
+ code: "custom",
8560
+ path: ["models", "chat"],
8561
+ message: "an agent with no server names its own chat model"
8562
+ });
8563
+ }
8544
8564
  });
8545
8565
  var MANIFEST_KINDS = [
8546
8566
  "agents",
@@ -8611,13 +8631,13 @@ function defineManifest(manifest) {
8611
8631
  return manifest;
8612
8632
  }
8613
8633
  export {
8614
- isFiringRunning,
8615
- defineServer,
8616
- defineManifest,
8617
- defineDatasetHost,
8618
- createTriggerClient,
8619
- createManagementClient,
8620
- TriggerClientError,
8634
+ CortexError2 as CortexError,
8621
8635
  ManagementClientError,
8622
- CortexError
8636
+ TriggerClientError,
8637
+ createManagementClient,
8638
+ createTriggerClient,
8639
+ defineDatasetHost,
8640
+ defineManifest,
8641
+ defineServer,
8642
+ isFiringRunning
8623
8643
  };