@foris/ai-agent 0.3.0 → 0.4.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.
- package/dist/ai-agent.es.js +3 -3
- package/dist/ai-agent.umd.js +620 -610
- package/dist/ai-prompt-code-editor/PromptCodeEditor.d.ts +20 -0
- package/dist/ai-prompt-code-editor/index.d.ts +1 -0
- package/dist/ai-prompt-code-editor/promptCodeEditor.mock.d.ts +5 -0
- package/dist/arc-CONcyq9a.js +85 -0
- package/dist/{architectureDiagram-VXUJARFQ-CuFlEJrK.js → architectureDiagram-VXUJARFQ-rKQ4Lyhz.js} +3 -3
- package/dist/{blockDiagram-VD42YOAC-Ceho4Zhj.js → blockDiagram-VD42YOAC-q8x-nl-I.js} +46 -46
- package/dist/{c4Diagram-YG6GDRKO-zPB3iQJ7.js → c4Diagram-YG6GDRKO-BCtZ1arM.js} +3 -3
- package/dist/channel-Bk9jsMES.js +5 -0
- package/dist/{chunk-4BX2VUAB-BZlHuf6l.js → chunk-4BX2VUAB-wPZhboqx.js} +1 -1
- package/dist/{chunk-55IACEB6-Dr8rgvy_.js → chunk-55IACEB6-BV8ciSb1.js} +1 -1
- package/dist/{chunk-B4BG7PRW-Ccllo2e-.js → chunk-B4BG7PRW-DsX0HPSj.js} +11 -11
- package/dist/{chunk-DI55MBZ5-DvAROTIr.js → chunk-DI55MBZ5-jq2QyBxN.js} +44 -44
- package/dist/{chunk-FMBD7UC4-CVr83prI.js → chunk-FMBD7UC4-YR7nwd5V.js} +1 -1
- package/dist/{chunk-QN33PNHL-nSyFq8_s.js → chunk-QN33PNHL-CEVf-TA_.js} +1 -1
- package/dist/{chunk-QZHKN3VN-Dg8JYP6e.js → chunk-QZHKN3VN-BjRs8z1O.js} +1 -1
- package/dist/{chunk-TZMSLE5B-Bmj6LGNW.js → chunk-TZMSLE5B-C1vaDaHJ.js} +1 -1
- package/dist/{classDiagram-2ON5EDUG-DAkxtl6o.js → classDiagram-2ON5EDUG-B4QDlpZ1.js} +6 -6
- package/dist/{classDiagram-v2-WZHVMYZB-DAkxtl6o.js → classDiagram-v2-WZHVMYZB-B4QDlpZ1.js} +6 -6
- package/dist/code-block-QI2IAROF-CqxV97B3.js +2812 -0
- package/dist/{cose-bilkent-S5V4N54A-DwRYWoaW.js → cose-bilkent-S5V4N54A-Ct46NMY7.js} +2 -2
- package/dist/{dagre-6UL2VRFP-imN1Fyg8.js → dagre-6UL2VRFP-DmQvQIeM.js} +3 -3
- package/dist/{diagram-PSM6KHXK-DAIDeBLn.js → diagram-PSM6KHXK-CkgrbT_2.js} +47 -47
- package/dist/{diagram-QEK2KX5R-DQFy-qK9.js → diagram-QEK2KX5R-CC4kNfLh.js} +13 -13
- package/dist/{diagram-S2PKOQOG-Hlk0Nx_Y.js → diagram-S2PKOQOG-Bn5_K1zg.js} +16 -16
- package/dist/{erDiagram-Q2GNP2WA-C8PZPSaf.js → erDiagram-Q2GNP2WA-DUUsccBq.js} +5 -5
- package/dist/{flowDiagram-NV44I4VS-CgTiIFnt.js → flowDiagram-NV44I4VS-BphIgEre.js} +6 -6
- package/dist/{ganttDiagram-JELNMOA3-DzYZEAE_.js → ganttDiagram-JELNMOA3-DB4uV-5E.js} +3 -3
- package/dist/{gitGraphDiagram-NY62KEGX-CPwI-Uag.js → gitGraphDiagram-NY62KEGX-CsGGzPy-.js} +16 -16
- package/dist/hooks/useCodeTransform.d.ts +14 -0
- package/dist/{index-C2DJ8qoy.js → index-4odIPslx.js} +18502 -11456
- package/dist/index.d.ts +2 -2
- package/dist/{infoDiagram-WHAUD3N6-CcN7ZNYI.js → infoDiagram-WHAUD3N6-DumQO9Nk.js} +2 -2
- package/dist/{journeyDiagram-XKPGCS4Q-BACao6jz.js → journeyDiagram-XKPGCS4Q-v431C5nB.js} +5 -5
- package/dist/{kanban-definition-3W4ZIXB7-Jb7Xwf92.js → kanban-definition-3W4ZIXB7-fvrRkH6c.js} +39 -39
- package/dist/{linear-CxGB80S5.js → linear-B5gvsjso.js} +1 -1
- package/dist/{mermaid-NA5CF7SZ-DekDSZe_.js → mermaid-NA5CF7SZ-DPw9pyDl.js} +1 -1
- package/dist/{mermaid.core-xMGW442o.js → mermaid.core-fgysRC67.js} +87 -87
- package/dist/{mindmap-definition-VGOIOE7T-UHZgRHb7.js → mindmap-definition-VGOIOE7T-DYVMZ5_0.js} +69 -69
- package/dist/{pieDiagram-ADFJNKIX-CHrTFTbw.js → pieDiagram-ADFJNKIX-ChUQ9M0l.js} +23 -23
- package/dist/{quadrantDiagram-AYHSOK5B-CDfhMB18.js → quadrantDiagram-AYHSOK5B-CCuKtq8U.js} +3 -3
- package/dist/{requirementDiagram-UZGBJVZJ-C0aeVQh6.js → requirementDiagram-UZGBJVZJ-CX2K4M3c.js} +4 -4
- package/dist/{sankeyDiagram-TZEHDZUN-kjxRgXd2.js → sankeyDiagram-TZEHDZUN-DDTggF6e.js} +2 -2
- package/dist/{sequenceDiagram-WL72ISMW-Bs0jyVuH.js → sequenceDiagram-WL72ISMW-hLodMsLa.js} +4 -4
- package/dist/services/fetch-api/FetchApi.d.ts +1 -0
- package/dist/{stateDiagram-FKZM4ZOC-CAWwlh9R.js → stateDiagram-FKZM4ZOC-BsygERhX.js} +12 -12
- package/dist/{stateDiagram-v2-4FDKWEC3-9TYlTzc3.js → stateDiagram-v2-4FDKWEC3-D_QAMIGV.js} +5 -5
- package/dist/style.css +1 -1
- package/dist/tailwind.css +93 -0
- package/dist/{timeline-definition-IT6M3QCI-DrPozOxH.js → timeline-definition-IT6M3QCI-DdL3lWtw.js} +47 -47
- package/dist/{xychartDiagram-PRI3JC2R-BkO8dJff.js → xychartDiagram-PRI3JC2R-vUb07G9z.js} +35 -35
- package/package.json +2 -1
- package/dist/ai-input-action/InputAction.d.ts +0 -8
- package/dist/ai-input-action/index.d.ts +0 -1
- package/dist/arc-DN1xn8kz.js +0 -85
- package/dist/channel-BC4mWQQF.js +0 -5
- package/dist/code-block-QI2IAROF-DN-BnDmt.js +0 -9263
|
@@ -0,0 +1,2812 @@
|
|
|
1
|
+
var Dr = Object.defineProperty;
|
|
2
|
+
var Tr = Object.getPrototypeOf;
|
|
3
|
+
var Br = Reflect.get;
|
|
4
|
+
var jr = (e, r, t) => r in e ? Dr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
5
|
+
var ye = (e, r, t) => (jr(e, typeof r != "symbol" ? r + "" : r, t), t), Ce = (e, r, t) => {
|
|
6
|
+
if (!r.has(e))
|
|
7
|
+
throw TypeError("Cannot " + t);
|
|
8
|
+
};
|
|
9
|
+
var $ = (e, r, t) => (Ce(e, r, "read from private field"), t ? t.call(e) : r.get(e)), V = (e, r, t) => {
|
|
10
|
+
if (r.has(e))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
r instanceof WeakSet ? r.add(e) : r.set(e, t);
|
|
13
|
+
}, M = (e, r, t, n) => (Ce(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
|
|
14
|
+
var be = (e, r, t) => (Ce(e, r, "access private method"), t), Ve = (e, r, t) => Br(Tr(e), t, r);
|
|
15
|
+
import { u as Re, j as v, C as Vr, D as zr, a as Wr, b as Hr } from "./index-4odIPslx.js";
|
|
16
|
+
import { memo as Xr, useMemo as pr, useContext as Zr, useState as Qr, useEffect as qr } from "react";
|
|
17
|
+
import "react-dom";
|
|
18
|
+
function ne(e) {
|
|
19
|
+
if ([...e].length !== 1)
|
|
20
|
+
throw new Error(`Expected "${e}" to be a single code point`);
|
|
21
|
+
return e.codePointAt(0);
|
|
22
|
+
}
|
|
23
|
+
function Jr(e, r, t) {
|
|
24
|
+
return e.has(r) || e.set(r, t), e.get(r);
|
|
25
|
+
}
|
|
26
|
+
const Ue = /* @__PURE__ */ new Set(["alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "word", "xdigit"]), x = String.raw;
|
|
27
|
+
function se(e, r) {
|
|
28
|
+
if (e == null)
|
|
29
|
+
throw new Error(r ?? "Value expected");
|
|
30
|
+
return e;
|
|
31
|
+
}
|
|
32
|
+
const fr = x`\[\^?`, dr = `c.? | C(?:-.?)?|${x`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${x`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${x`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${x`o\{[^\}]*\}?`}|${x`\d{1,3}`}`, Oe = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, le = new RegExp(x`
|
|
33
|
+
\\ (?:
|
|
34
|
+
${dr}
|
|
35
|
+
| [gk]<[^>]*>?
|
|
36
|
+
| [gk]'[^']*'?
|
|
37
|
+
| .
|
|
38
|
+
)
|
|
39
|
+
| \( (?:
|
|
40
|
+
\? (?:
|
|
41
|
+
[:=!>({]
|
|
42
|
+
| <[=!]
|
|
43
|
+
| <[^>]*>
|
|
44
|
+
| '[^']*'
|
|
45
|
+
| ~\|?
|
|
46
|
+
| #(?:[^)\\]|\\.?)*
|
|
47
|
+
| [^:)]*[:)]
|
|
48
|
+
)?
|
|
49
|
+
| \*[^\)]*\)?
|
|
50
|
+
)?
|
|
51
|
+
| (?:${Oe.source})+
|
|
52
|
+
| ${fr}
|
|
53
|
+
| .
|
|
54
|
+
`.replace(/\s+/g, ""), "gsu"), xe = new RegExp(x`
|
|
55
|
+
\\ (?:
|
|
56
|
+
${dr}
|
|
57
|
+
| .
|
|
58
|
+
)
|
|
59
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
60
|
+
| ${fr}
|
|
61
|
+
| &&
|
|
62
|
+
| .
|
|
63
|
+
`.replace(/\s+/g, ""), "gsu");
|
|
64
|
+
function Kr(e, r = {}) {
|
|
65
|
+
const t = { flags: "", ...r, rules: { captureGroup: !1, singleline: !1, ...r.rules } };
|
|
66
|
+
if (typeof e != "string")
|
|
67
|
+
throw new Error("String expected as pattern");
|
|
68
|
+
const n = wt(t.flags), s = [n.extended], o = { captureGroup: t.rules.captureGroup, getCurrentModX() {
|
|
69
|
+
return s.at(-1);
|
|
70
|
+
}, numOpenGroups: 0, popModX() {
|
|
71
|
+
s.pop();
|
|
72
|
+
}, pushModX(p) {
|
|
73
|
+
s.push(p);
|
|
74
|
+
}, replaceCurrentModX(p) {
|
|
75
|
+
s[s.length - 1] = p;
|
|
76
|
+
}, singleline: t.rules.singleline };
|
|
77
|
+
let a = [], i;
|
|
78
|
+
for (le.lastIndex = 0; i = le.exec(e); ) {
|
|
79
|
+
const p = Yr(o, e, i[0], le.lastIndex);
|
|
80
|
+
p.tokens ? a.push(...p.tokens) : p.token && a.push(p.token), p.lastIndex !== void 0 && (le.lastIndex = p.lastIndex);
|
|
81
|
+
}
|
|
82
|
+
const u = [];
|
|
83
|
+
let c = 0;
|
|
84
|
+
a.filter((p) => p.type === "GroupOpen").forEach((p) => {
|
|
85
|
+
p.kind === "capturing" ? p.number = ++c : p.raw === "(" && u.push(p);
|
|
86
|
+
}), c || u.forEach((p, f) => {
|
|
87
|
+
p.kind = "capturing", p.number = f + 1;
|
|
88
|
+
});
|
|
89
|
+
const l = c || u.length;
|
|
90
|
+
return { tokens: a.map((p) => p.type === "EscapedNumber" ? Ct(p, l) : p).flat(), flags: n };
|
|
91
|
+
}
|
|
92
|
+
function Yr(e, r, t, n) {
|
|
93
|
+
const [s, o] = t;
|
|
94
|
+
if (t === "[" || t === "[^") {
|
|
95
|
+
const a = et(r, t, n);
|
|
96
|
+
return { tokens: a.tokens, lastIndex: a.lastIndex };
|
|
97
|
+
}
|
|
98
|
+
if (s === "\\") {
|
|
99
|
+
if ("AbBGyYzZ".includes(o))
|
|
100
|
+
return { token: ze(t, t) };
|
|
101
|
+
if (/^\\g[<']/.test(t)) {
|
|
102
|
+
if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))
|
|
103
|
+
throw new Error(`Invalid group name "${t}"`);
|
|
104
|
+
return { token: lt(t) };
|
|
105
|
+
}
|
|
106
|
+
if (/^\\k[<']/.test(t)) {
|
|
107
|
+
if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))
|
|
108
|
+
throw new Error(`Invalid group name "${t}"`);
|
|
109
|
+
return { token: hr(t) };
|
|
110
|
+
}
|
|
111
|
+
if (o === "K")
|
|
112
|
+
return { token: mr("keep", t) };
|
|
113
|
+
if (o === "N" || o === "R")
|
|
114
|
+
return { token: H("newline", t, { negate: o === "N" }) };
|
|
115
|
+
if (o === "O")
|
|
116
|
+
return { token: H("any", t) };
|
|
117
|
+
if (o === "X")
|
|
118
|
+
return { token: H("text_segment", t) };
|
|
119
|
+
const a = gr(t, { inCharClass: !1 });
|
|
120
|
+
return Array.isArray(a) ? { tokens: a } : { token: a };
|
|
121
|
+
}
|
|
122
|
+
if (s === "(") {
|
|
123
|
+
if (o === "*")
|
|
124
|
+
return { token: gt(t) };
|
|
125
|
+
if (t === "(?{")
|
|
126
|
+
throw new Error(`Unsupported callout "${t}"`);
|
|
127
|
+
if (t.startsWith("(?#")) {
|
|
128
|
+
if (r[n] !== ")")
|
|
129
|
+
throw new Error('Unclosed comment group "(?#"');
|
|
130
|
+
return { lastIndex: n + 1 };
|
|
131
|
+
}
|
|
132
|
+
if (/^\(\?[-imx]+[:)]$/.test(t))
|
|
133
|
+
return { token: dt(t, e) };
|
|
134
|
+
if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:")
|
|
135
|
+
return { token: re("group", t) };
|
|
136
|
+
if (t === "(?>")
|
|
137
|
+
return { token: re("atomic", t) };
|
|
138
|
+
if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!")
|
|
139
|
+
return { token: re(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
|
|
140
|
+
if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'"))
|
|
141
|
+
return { token: re("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
|
|
142
|
+
if (t.startsWith("(?~")) {
|
|
143
|
+
if (t === "(?~|")
|
|
144
|
+
throw new Error(`Unsupported absence function kind "${t}"`);
|
|
145
|
+
return { token: re("absence_repeater", t) };
|
|
146
|
+
}
|
|
147
|
+
throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
|
|
148
|
+
}
|
|
149
|
+
if (t === ")") {
|
|
150
|
+
if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0)
|
|
151
|
+
throw new Error('Unmatched ")"');
|
|
152
|
+
return { token: it(t) };
|
|
153
|
+
}
|
|
154
|
+
if (e.getCurrentModX()) {
|
|
155
|
+
if (t === "#") {
|
|
156
|
+
const a = r.indexOf(`
|
|
157
|
+
`, n);
|
|
158
|
+
return { lastIndex: a === -1 ? r.length : a };
|
|
159
|
+
}
|
|
160
|
+
if (/^\s$/.test(t)) {
|
|
161
|
+
const a = /\s+/y;
|
|
162
|
+
return a.lastIndex = n, { lastIndex: a.exec(r) ? a.lastIndex : n };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (t === ".")
|
|
166
|
+
return { token: H("dot", t) };
|
|
167
|
+
if (t === "^" || t === "$") {
|
|
168
|
+
const a = e.singleline ? { "^": x`\A`, $: x`\Z` }[t] : t;
|
|
169
|
+
return { token: ze(a, t) };
|
|
170
|
+
}
|
|
171
|
+
return t === "|" ? { token: tt(t) } : Oe.test(t) ? { tokens: bt(t) } : { token: R(ne(t), t) };
|
|
172
|
+
}
|
|
173
|
+
function et(e, r, t) {
|
|
174
|
+
const n = [We(r[1] === "^", r)];
|
|
175
|
+
let s = 1, o;
|
|
176
|
+
for (xe.lastIndex = t; o = xe.exec(e); ) {
|
|
177
|
+
const a = o[0];
|
|
178
|
+
if (a[0] === "[" && a[1] !== ":")
|
|
179
|
+
s++, n.push(We(a[1] === "^", a));
|
|
180
|
+
else if (a === "]") {
|
|
181
|
+
if (n.at(-1).type === "CharacterClassOpen")
|
|
182
|
+
n.push(R(93, a));
|
|
183
|
+
else if (s--, n.push(nt(a)), !s)
|
|
184
|
+
break;
|
|
185
|
+
} else {
|
|
186
|
+
const i = rt(a);
|
|
187
|
+
Array.isArray(i) ? n.push(...i) : n.push(i);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { tokens: n, lastIndex: xe.lastIndex || e.length };
|
|
191
|
+
}
|
|
192
|
+
function rt(e) {
|
|
193
|
+
if (e[0] === "\\")
|
|
194
|
+
return gr(e, { inCharClass: !0 });
|
|
195
|
+
if (e[0] === "[") {
|
|
196
|
+
const r = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
|
|
197
|
+
if (!r || !Ue.has(r.groups.name))
|
|
198
|
+
throw new Error(`Invalid POSIX class "${e}"`);
|
|
199
|
+
return H("posix", e, { value: r.groups.name, negate: !!r.groups.negate });
|
|
200
|
+
}
|
|
201
|
+
return e === "-" ? st(e) : e === "&&" ? ot(e) : R(ne(e), e);
|
|
202
|
+
}
|
|
203
|
+
function gr(e, { inCharClass: r }) {
|
|
204
|
+
const t = e[1];
|
|
205
|
+
if (t === "c" || t === "C")
|
|
206
|
+
return ft(e);
|
|
207
|
+
if ("dDhHsSwW".includes(t))
|
|
208
|
+
return ht(e);
|
|
209
|
+
if (e.startsWith(x`\o{`))
|
|
210
|
+
throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
|
|
211
|
+
if (/^\\[pP]\{/.test(e)) {
|
|
212
|
+
if (e.length === 3)
|
|
213
|
+
throw new Error(`Incomplete or invalid Unicode property "${e}"`);
|
|
214
|
+
return mt(e);
|
|
215
|
+
}
|
|
216
|
+
if (new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}", "u").test(e))
|
|
217
|
+
try {
|
|
218
|
+
const n = e.split(/\\x/).slice(1).map((a) => parseInt(a, 16)), s = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }).decode(new Uint8Array(n)), o = new TextEncoder();
|
|
219
|
+
return [...s].map((a) => {
|
|
220
|
+
const i = [...o.encode(a)].map((u) => `\\x${u.toString(16)}`).join("");
|
|
221
|
+
return R(ne(a), i);
|
|
222
|
+
});
|
|
223
|
+
} catch {
|
|
224
|
+
throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
|
|
225
|
+
}
|
|
226
|
+
if (t === "u" || t === "x")
|
|
227
|
+
return R(yt(e), e);
|
|
228
|
+
if (He.has(t))
|
|
229
|
+
return R(He.get(t), e);
|
|
230
|
+
if (/\d/.test(t))
|
|
231
|
+
return at(r, e);
|
|
232
|
+
if (e === "\\")
|
|
233
|
+
throw new Error(x`Incomplete escape "\"`);
|
|
234
|
+
if (t === "M")
|
|
235
|
+
throw new Error(`Unsupported meta "${e}"`);
|
|
236
|
+
if ([...e].length === 2)
|
|
237
|
+
return R(e.codePointAt(1), e);
|
|
238
|
+
throw new Error(`Unexpected escape "${e}"`);
|
|
239
|
+
}
|
|
240
|
+
function tt(e) {
|
|
241
|
+
return { type: "Alternator", raw: e };
|
|
242
|
+
}
|
|
243
|
+
function ze(e, r) {
|
|
244
|
+
return { type: "Assertion", kind: e, raw: r };
|
|
245
|
+
}
|
|
246
|
+
function hr(e) {
|
|
247
|
+
return { type: "Backreference", raw: e };
|
|
248
|
+
}
|
|
249
|
+
function R(e, r) {
|
|
250
|
+
return { type: "Character", value: e, raw: r };
|
|
251
|
+
}
|
|
252
|
+
function nt(e) {
|
|
253
|
+
return { type: "CharacterClassClose", raw: e };
|
|
254
|
+
}
|
|
255
|
+
function st(e) {
|
|
256
|
+
return { type: "CharacterClassHyphen", raw: e };
|
|
257
|
+
}
|
|
258
|
+
function ot(e) {
|
|
259
|
+
return { type: "CharacterClassIntersector", raw: e };
|
|
260
|
+
}
|
|
261
|
+
function We(e, r) {
|
|
262
|
+
return { type: "CharacterClassOpen", negate: e, raw: r };
|
|
263
|
+
}
|
|
264
|
+
function H(e, r, t = {}) {
|
|
265
|
+
return { type: "CharacterSet", kind: e, ...t, raw: r };
|
|
266
|
+
}
|
|
267
|
+
function mr(e, r, t = {}) {
|
|
268
|
+
return e === "keep" ? { type: "Directive", kind: e, raw: r } : { type: "Directive", kind: e, flags: se(t.flags), raw: r };
|
|
269
|
+
}
|
|
270
|
+
function at(e, r) {
|
|
271
|
+
return { type: "EscapedNumber", inCharClass: e, raw: r };
|
|
272
|
+
}
|
|
273
|
+
function it(e) {
|
|
274
|
+
return { type: "GroupClose", raw: e };
|
|
275
|
+
}
|
|
276
|
+
function re(e, r, t = {}) {
|
|
277
|
+
return { type: "GroupOpen", kind: e, ...t, raw: r };
|
|
278
|
+
}
|
|
279
|
+
function ut(e, r, t, n) {
|
|
280
|
+
return { type: "NamedCallout", kind: e, tag: r, arguments: t, raw: n };
|
|
281
|
+
}
|
|
282
|
+
function ct(e, r, t, n) {
|
|
283
|
+
return { type: "Quantifier", kind: e, min: r, max: t, raw: n };
|
|
284
|
+
}
|
|
285
|
+
function lt(e) {
|
|
286
|
+
return { type: "Subroutine", raw: e };
|
|
287
|
+
}
|
|
288
|
+
const pt = /* @__PURE__ */ new Set(["COUNT", "CMP", "ERROR", "FAIL", "MAX", "MISMATCH", "SKIP", "TOTAL_COUNT"]), He = /* @__PURE__ */ new Map([["a", 7], ["b", 8], ["e", 27], ["f", 12], ["n", 10], ["r", 13], ["t", 9], ["v", 11]]);
|
|
289
|
+
function ft(e) {
|
|
290
|
+
const r = e[1] === "c" ? e[2] : e[3];
|
|
291
|
+
if (!r || !/[A-Za-z]/.test(r))
|
|
292
|
+
throw new Error(`Unsupported control character "${e}"`);
|
|
293
|
+
return R(ne(r.toUpperCase()) - 64, e);
|
|
294
|
+
}
|
|
295
|
+
function dt(e, r) {
|
|
296
|
+
let { on: t, off: n } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
|
|
297
|
+
n ?? (n = "");
|
|
298
|
+
const s = (r.getCurrentModX() || t.includes("x")) && !n.includes("x"), o = Ze(t), a = Ze(n), i = {};
|
|
299
|
+
if (o && (i.enable = o), a && (i.disable = a), e.endsWith(")"))
|
|
300
|
+
return r.replaceCurrentModX(s), mr("flags", e, { flags: i });
|
|
301
|
+
if (e.endsWith(":"))
|
|
302
|
+
return r.pushModX(s), r.numOpenGroups++, re("group", e, { ...(o || a) && { flags: i } });
|
|
303
|
+
throw new Error(`Unexpected flag modifier "${e}"`);
|
|
304
|
+
}
|
|
305
|
+
function gt(e) {
|
|
306
|
+
const r = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
|
|
307
|
+
if (!r)
|
|
308
|
+
throw new Error(`Incomplete or invalid named callout "${e}"`);
|
|
309
|
+
const { name: t, tag: n, args: s } = r.groups;
|
|
310
|
+
if (!t)
|
|
311
|
+
throw new Error(`Invalid named callout "${e}"`);
|
|
312
|
+
if (n === "")
|
|
313
|
+
throw new Error(`Named callout tag with empty value not allowed "${e}"`);
|
|
314
|
+
const o = s ? s.split(",").filter((l) => l !== "").map((l) => /^[+-]?\d+$/.test(l) ? +l : l) : [], [a, i, u] = o, c = pt.has(t) ? t.toLowerCase() : "custom";
|
|
315
|
+
switch (c) {
|
|
316
|
+
case "fail":
|
|
317
|
+
case "mismatch":
|
|
318
|
+
case "skip":
|
|
319
|
+
if (o.length > 0)
|
|
320
|
+
throw new Error(`Named callout arguments not allowed "${o}"`);
|
|
321
|
+
break;
|
|
322
|
+
case "error":
|
|
323
|
+
if (o.length > 1)
|
|
324
|
+
throw new Error(`Named callout allows only one argument "${o}"`);
|
|
325
|
+
if (typeof a == "string")
|
|
326
|
+
throw new Error(`Named callout argument must be a number "${a}"`);
|
|
327
|
+
break;
|
|
328
|
+
case "max":
|
|
329
|
+
if (!o.length || o.length > 2)
|
|
330
|
+
throw new Error(`Named callout must have one or two arguments "${o}"`);
|
|
331
|
+
if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a))
|
|
332
|
+
throw new Error(`Named callout argument one must be a tag or number "${a}"`);
|
|
333
|
+
if (o.length === 2 && (typeof i == "number" || !/^[<>X]$/.test(i)))
|
|
334
|
+
throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);
|
|
335
|
+
break;
|
|
336
|
+
case "count":
|
|
337
|
+
case "total_count":
|
|
338
|
+
if (o.length > 1)
|
|
339
|
+
throw new Error(`Named callout allows only one argument "${o}"`);
|
|
340
|
+
if (o.length === 1 && (typeof a == "number" || !/^[<>X]$/.test(a)))
|
|
341
|
+
throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);
|
|
342
|
+
break;
|
|
343
|
+
case "cmp":
|
|
344
|
+
if (o.length !== 3)
|
|
345
|
+
throw new Error(`Named callout must have three arguments "${o}"`);
|
|
346
|
+
if (typeof a == "string" && !/^[A-Za-z_]\w*$/.test(a))
|
|
347
|
+
throw new Error(`Named callout argument one must be a tag or number "${a}"`);
|
|
348
|
+
if (typeof i == "number" || !/^(?:[<>!=]=|[<>])$/.test(i))
|
|
349
|
+
throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);
|
|
350
|
+
if (typeof u == "string" && !/^[A-Za-z_]\w*$/.test(u))
|
|
351
|
+
throw new Error(`Named callout argument three must be a tag or number "${u}"`);
|
|
352
|
+
break;
|
|
353
|
+
case "custom":
|
|
354
|
+
throw new Error(`Undefined callout name "${t}"`);
|
|
355
|
+
default:
|
|
356
|
+
throw new Error(`Unexpected named callout kind "${c}"`);
|
|
357
|
+
}
|
|
358
|
+
return ut(c, n ?? null, (s == null ? void 0 : s.split(",")) ?? null, e);
|
|
359
|
+
}
|
|
360
|
+
function Xe(e) {
|
|
361
|
+
let r = null, t, n;
|
|
362
|
+
if (e[0] === "{") {
|
|
363
|
+
const { minStr: s, maxStr: o } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, a = 1e5;
|
|
364
|
+
if (+s > a || o && +o > a)
|
|
365
|
+
throw new Error("Quantifier value unsupported in Oniguruma");
|
|
366
|
+
if (t = +s, n = o === void 0 ? +s : o === "" ? 1 / 0 : +o, t > n && (r = "possessive", [t, n] = [n, t]), e.endsWith("?")) {
|
|
367
|
+
if (r === "possessive")
|
|
368
|
+
throw new Error('Unsupported possessive interval quantifier chain with "?"');
|
|
369
|
+
r = "lazy";
|
|
370
|
+
} else
|
|
371
|
+
r || (r = "greedy");
|
|
372
|
+
} else
|
|
373
|
+
t = e[0] === "+" ? 1 : 0, n = e[0] === "?" ? 1 : 1 / 0, r = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
|
|
374
|
+
return ct(r, t, n, e);
|
|
375
|
+
}
|
|
376
|
+
function ht(e) {
|
|
377
|
+
const r = e[1].toLowerCase();
|
|
378
|
+
return H({ d: "digit", h: "hex", s: "space", w: "word" }[r], e, { negate: e[1] !== r });
|
|
379
|
+
}
|
|
380
|
+
function mt(e) {
|
|
381
|
+
const { p: r, neg: t, value: n } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
|
|
382
|
+
return H("property", e, { value: n, negate: r === "P" && !t || r === "p" && !!t });
|
|
383
|
+
}
|
|
384
|
+
function Ze(e) {
|
|
385
|
+
const r = {};
|
|
386
|
+
return e.includes("i") && (r.ignoreCase = !0), e.includes("m") && (r.dotAll = !0), e.includes("x") && (r.extended = !0), Object.keys(r).length ? r : null;
|
|
387
|
+
}
|
|
388
|
+
function wt(e) {
|
|
389
|
+
const r = { ignoreCase: !1, dotAll: !1, extended: !1, digitIsAscii: !1, posixIsAscii: !1, spaceIsAscii: !1, wordIsAscii: !1, textSegmentMode: null };
|
|
390
|
+
for (let t = 0; t < e.length; t++) {
|
|
391
|
+
const n = e[t];
|
|
392
|
+
if (!"imxDPSWy".includes(n))
|
|
393
|
+
throw new Error(`Invalid flag "${n}"`);
|
|
394
|
+
if (n === "y") {
|
|
395
|
+
if (!/^y{[gw]}/.test(e.slice(t)))
|
|
396
|
+
throw new Error('Invalid or unspecified flag "y" mode');
|
|
397
|
+
r.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
r[{ i: "ignoreCase", m: "dotAll", x: "extended", D: "digitIsAscii", P: "posixIsAscii", S: "spaceIsAscii", W: "wordIsAscii" }[n]] = !0;
|
|
401
|
+
}
|
|
402
|
+
return r;
|
|
403
|
+
}
|
|
404
|
+
function yt(e) {
|
|
405
|
+
if (new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))", "u").test(e))
|
|
406
|
+
throw new Error(`Incomplete or invalid escape "${e}"`);
|
|
407
|
+
const r = e[2] === "{" ? new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)", "u").exec(e).groups.hex : e.slice(2);
|
|
408
|
+
return parseInt(r, 16);
|
|
409
|
+
}
|
|
410
|
+
function Ct(e, r) {
|
|
411
|
+
const { raw: t, inCharClass: n } = e, s = t.slice(1);
|
|
412
|
+
if (!n && (s !== "0" && s.length === 1 || s[0] !== "0" && +s <= r))
|
|
413
|
+
return [hr(t)];
|
|
414
|
+
const o = [], a = s.match(/^[0-7]+|\d/g);
|
|
415
|
+
for (let i = 0; i < a.length; i++) {
|
|
416
|
+
const u = a[i];
|
|
417
|
+
let c;
|
|
418
|
+
if (i === 0 && u !== "8" && u !== "9") {
|
|
419
|
+
if (c = parseInt(u, 8), c > 127)
|
|
420
|
+
throw new Error(x`Octal encoded byte above 177 unsupported "${t}"`);
|
|
421
|
+
} else
|
|
422
|
+
c = ne(u);
|
|
423
|
+
o.push(R(c, (i === 0 ? "\\" : "") + u));
|
|
424
|
+
}
|
|
425
|
+
return o;
|
|
426
|
+
}
|
|
427
|
+
function bt(e) {
|
|
428
|
+
const r = [], t = new RegExp(Oe, "gy");
|
|
429
|
+
let n;
|
|
430
|
+
for (; n = t.exec(e); ) {
|
|
431
|
+
const s = n[0];
|
|
432
|
+
if (s[0] === "{") {
|
|
433
|
+
const o = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);
|
|
434
|
+
if (o) {
|
|
435
|
+
const { min: a, max: i } = o.groups;
|
|
436
|
+
if (+a > +i && s.endsWith("?")) {
|
|
437
|
+
t.lastIndex--, r.push(Xe(s.slice(0, -1)));
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
r.push(Xe(s));
|
|
443
|
+
}
|
|
444
|
+
return r;
|
|
445
|
+
}
|
|
446
|
+
function wr(e, r) {
|
|
447
|
+
if (!Array.isArray(e.body))
|
|
448
|
+
throw new Error("Expected node with body array");
|
|
449
|
+
if (e.body.length !== 1)
|
|
450
|
+
return !1;
|
|
451
|
+
const t = e.body[0];
|
|
452
|
+
return !r || Object.keys(r).every((n) => r[n] === t[n]);
|
|
453
|
+
}
|
|
454
|
+
function xt(e) {
|
|
455
|
+
return kt.has(e.type);
|
|
456
|
+
}
|
|
457
|
+
const kt = /* @__PURE__ */ new Set(["AbsenceFunction", "Backreference", "CapturingGroup", "Character", "CharacterClass", "CharacterSet", "Group", "Quantifier", "Subroutine"]);
|
|
458
|
+
function yr(e, r = {}) {
|
|
459
|
+
const t = { flags: "", normalizeUnknownPropertyNames: !1, skipBackrefValidation: !1, skipLookbehindValidation: !1, skipPropertyNameValidation: !1, unicodePropertyMap: null, ...r, rules: { captureGroup: !1, singleline: !1, ...r.rules } }, n = Kr(e, { flags: t.flags, rules: { captureGroup: t.rules.captureGroup, singleline: t.rules.singleline } }), s = (f, g) => {
|
|
460
|
+
const d = n.tokens[o.nextIndex];
|
|
461
|
+
switch (o.parent = f, o.nextIndex++, d.type) {
|
|
462
|
+
case "Alternator":
|
|
463
|
+
return q();
|
|
464
|
+
case "Assertion":
|
|
465
|
+
return $t(d);
|
|
466
|
+
case "Backreference":
|
|
467
|
+
return Et(d, o);
|
|
468
|
+
case "Character":
|
|
469
|
+
return he(d.value, { useLastValid: !!g.isCheckingRangeEnd });
|
|
470
|
+
case "CharacterClassHyphen":
|
|
471
|
+
return At(d, o, g);
|
|
472
|
+
case "CharacterClassOpen":
|
|
473
|
+
return It(d, o, g);
|
|
474
|
+
case "CharacterSet":
|
|
475
|
+
return vt(d, o);
|
|
476
|
+
case "Directive":
|
|
477
|
+
return Ft(d.kind, { flags: d.flags });
|
|
478
|
+
case "GroupOpen":
|
|
479
|
+
return St(d, o, g);
|
|
480
|
+
case "NamedCallout":
|
|
481
|
+
return Pt(d.kind, d.tag, d.arguments);
|
|
482
|
+
case "Quantifier":
|
|
483
|
+
return _t(d, o);
|
|
484
|
+
case "Subroutine":
|
|
485
|
+
return Nt(d, o);
|
|
486
|
+
default:
|
|
487
|
+
throw new Error(`Unexpected token type "${d.type}"`);
|
|
488
|
+
}
|
|
489
|
+
}, o = { capturingGroups: [], hasNumberedRef: !1, namedGroupsByName: /* @__PURE__ */ new Map(), nextIndex: 0, normalizeUnknownPropertyNames: t.normalizeUnknownPropertyNames, parent: null, skipBackrefValidation: t.skipBackrefValidation, skipLookbehindValidation: t.skipLookbehindValidation, skipPropertyNameValidation: t.skipPropertyNameValidation, subroutines: [], tokens: n.tokens, unicodePropertyMap: t.unicodePropertyMap, walk: s }, a = Ut(Gt(n.flags));
|
|
490
|
+
let i = a.body[0];
|
|
491
|
+
for (; o.nextIndex < n.tokens.length; ) {
|
|
492
|
+
const f = s(i, {});
|
|
493
|
+
f.type === "Alternative" ? (a.body.push(f), i = f) : i.body.push(f);
|
|
494
|
+
}
|
|
495
|
+
const { capturingGroups: u, hasNumberedRef: c, namedGroupsByName: l, subroutines: p } = o;
|
|
496
|
+
if (c && l.size && !t.rules.captureGroup)
|
|
497
|
+
throw new Error("Numbered backref/subroutine not allowed when using named capture");
|
|
498
|
+
for (const { ref: f } of p)
|
|
499
|
+
if (typeof f == "number") {
|
|
500
|
+
if (f > u.length)
|
|
501
|
+
throw new Error("Subroutine uses a group number that's not defined");
|
|
502
|
+
f && (u[f - 1].isSubroutined = !0);
|
|
503
|
+
} else if (l.has(f)) {
|
|
504
|
+
if (l.get(f).length > 1)
|
|
505
|
+
throw new Error(x`Subroutine uses a duplicate group name "\g<${f}>"`);
|
|
506
|
+
l.get(f)[0].isSubroutined = !0;
|
|
507
|
+
} else
|
|
508
|
+
throw new Error(x`Subroutine uses a group name that's not defined "\g<${f}>"`);
|
|
509
|
+
return a;
|
|
510
|
+
}
|
|
511
|
+
function $t({ kind: e }) {
|
|
512
|
+
return Ne(se({ "^": "line_start", $: "line_end", "\\A": "string_start", "\\b": "word_boundary", "\\B": "word_boundary", "\\G": "search_start", "\\y": "text_segment_boundary", "\\Y": "text_segment_boundary", "\\z": "string_end", "\\Z": "string_end_newline" }[e], `Unexpected assertion kind "${e}"`), { negate: e === x`\B` || e === x`\Y` });
|
|
513
|
+
}
|
|
514
|
+
function Et({ raw: e }, r) {
|
|
515
|
+
const t = /^\\k[<']/.test(e), n = t ? e.slice(3, -1) : e.slice(1), s = (o, a = !1) => {
|
|
516
|
+
const i = r.capturingGroups.length;
|
|
517
|
+
let u = !1;
|
|
518
|
+
if (o > i)
|
|
519
|
+
if (r.skipBackrefValidation)
|
|
520
|
+
u = !0;
|
|
521
|
+
else
|
|
522
|
+
throw new Error(`Not enough capturing groups defined to the left "${e}"`);
|
|
523
|
+
return r.hasNumberedRef = !0, Me(a ? i + 1 - o : o, { orphan: u });
|
|
524
|
+
};
|
|
525
|
+
if (t) {
|
|
526
|
+
const o = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);
|
|
527
|
+
if (o)
|
|
528
|
+
return s(+o.groups.num, !!o.groups.sign);
|
|
529
|
+
if (/[-+]/.test(n))
|
|
530
|
+
throw new Error(`Invalid backref name "${e}"`);
|
|
531
|
+
if (!r.namedGroupsByName.has(n))
|
|
532
|
+
throw new Error(`Group name not defined to the left "${e}"`);
|
|
533
|
+
return Me(n);
|
|
534
|
+
}
|
|
535
|
+
return s(+n);
|
|
536
|
+
}
|
|
537
|
+
function At(e, r, t) {
|
|
538
|
+
const { tokens: n, walk: s } = r, o = r.parent, a = o.body.at(-1), i = n[r.nextIndex];
|
|
539
|
+
if (!t.isCheckingRangeEnd && a && a.type !== "CharacterClass" && a.type !== "CharacterClassRange" && i && i.type !== "CharacterClassOpen" && i.type !== "CharacterClassClose" && i.type !== "CharacterClassIntersector") {
|
|
540
|
+
const u = s(o, { ...t, isCheckingRangeEnd: !0 });
|
|
541
|
+
if (a.type === "Character" && u.type === "Character")
|
|
542
|
+
return o.body.pop(), Lt(a, u);
|
|
543
|
+
throw new Error("Invalid character class range");
|
|
544
|
+
}
|
|
545
|
+
return he(ne("-"));
|
|
546
|
+
}
|
|
547
|
+
function It({ negate: e }, r, t) {
|
|
548
|
+
const { tokens: n, walk: s } = r, o = n[r.nextIndex], a = [de()];
|
|
549
|
+
let i = Je(o);
|
|
550
|
+
for (; i.type !== "CharacterClassClose"; ) {
|
|
551
|
+
if (i.type === "CharacterClassIntersector")
|
|
552
|
+
a.push(de()), r.nextIndex++;
|
|
553
|
+
else {
|
|
554
|
+
const c = a.at(-1);
|
|
555
|
+
c.body.push(s(c, t));
|
|
556
|
+
}
|
|
557
|
+
i = Je(n[r.nextIndex], o);
|
|
558
|
+
}
|
|
559
|
+
const u = de({ negate: e });
|
|
560
|
+
return a.length === 1 ? u.body = a[0].body : (u.kind = "intersection", u.body = a.map((c) => c.body.length === 1 ? c.body[0] : c)), r.nextIndex++, u;
|
|
561
|
+
}
|
|
562
|
+
function vt({ kind: e, negate: r, value: t }, n) {
|
|
563
|
+
const { normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a } = n;
|
|
564
|
+
if (e === "property") {
|
|
565
|
+
const i = me(t);
|
|
566
|
+
if (Ue.has(i) && !(a != null && a.has(i)))
|
|
567
|
+
e = "posix", t = i;
|
|
568
|
+
else
|
|
569
|
+
return te(t, { negate: r, normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: a });
|
|
570
|
+
}
|
|
571
|
+
return e === "posix" ? Rt(t, { negate: r }) : Le(e, { negate: r });
|
|
572
|
+
}
|
|
573
|
+
function St(e, r, t) {
|
|
574
|
+
const { tokens: n, capturingGroups: s, namedGroupsByName: o, skipLookbehindValidation: a, walk: i } = r, u = Ot(e), c = u.type === "AbsenceFunction", l = qe(u), p = l && u.negate;
|
|
575
|
+
if (u.type === "CapturingGroup" && (s.push(u), u.name && Jr(o, u.name, []).push(u)), c && t.isInAbsenceFunction)
|
|
576
|
+
throw new Error("Nested absence function not supported by Oniguruma");
|
|
577
|
+
let f = Ke(n[r.nextIndex]);
|
|
578
|
+
for (; f.type !== "GroupClose"; ) {
|
|
579
|
+
if (f.type === "Alternator")
|
|
580
|
+
u.body.push(q()), r.nextIndex++;
|
|
581
|
+
else {
|
|
582
|
+
const g = u.body.at(-1), d = i(g, { ...t, isInAbsenceFunction: t.isInAbsenceFunction || c, isInLookbehind: t.isInLookbehind || l, isInNegLookbehind: t.isInNegLookbehind || p });
|
|
583
|
+
if (g.body.push(d), (l || t.isInLookbehind) && !a) {
|
|
584
|
+
const m = "Lookbehind includes a pattern not allowed by Oniguruma";
|
|
585
|
+
if (p || t.isInNegLookbehind) {
|
|
586
|
+
if (Qe(d) || d.type === "CapturingGroup")
|
|
587
|
+
throw new Error(m);
|
|
588
|
+
} else if (Qe(d) || qe(d) && d.negate)
|
|
589
|
+
throw new Error(m);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
f = Ke(n[r.nextIndex]);
|
|
593
|
+
}
|
|
594
|
+
return r.nextIndex++, u;
|
|
595
|
+
}
|
|
596
|
+
function _t({ kind: e, min: r, max: t }, n) {
|
|
597
|
+
const s = n.parent, o = s.body.at(-1);
|
|
598
|
+
if (!o || !xt(o))
|
|
599
|
+
throw new Error("Quantifier requires a repeatable token");
|
|
600
|
+
const a = br(e, r, t, o);
|
|
601
|
+
return s.body.pop(), a;
|
|
602
|
+
}
|
|
603
|
+
function Nt({ raw: e }, r) {
|
|
604
|
+
const { capturingGroups: t, subroutines: n } = r;
|
|
605
|
+
let s = e.slice(3, -1);
|
|
606
|
+
const o = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);
|
|
607
|
+
if (o) {
|
|
608
|
+
const i = +o.groups.num, u = t.length;
|
|
609
|
+
if (r.hasNumberedRef = !0, s = { "": i, "+": u + i, "-": u + 1 - i }[o.groups.sign], s < 1)
|
|
610
|
+
throw new Error("Invalid subroutine number");
|
|
611
|
+
} else
|
|
612
|
+
s === "0" && (s = 0);
|
|
613
|
+
const a = xr(s);
|
|
614
|
+
return n.push(a), a;
|
|
615
|
+
}
|
|
616
|
+
function Mt(e, r) {
|
|
617
|
+
return { type: "AbsenceFunction", kind: e, body: ce(r == null ? void 0 : r.body) };
|
|
618
|
+
}
|
|
619
|
+
function q(e) {
|
|
620
|
+
return { type: "Alternative", body: kr(e == null ? void 0 : e.body) };
|
|
621
|
+
}
|
|
622
|
+
function Ne(e, r) {
|
|
623
|
+
const t = { type: "Assertion", kind: e };
|
|
624
|
+
return (e === "word_boundary" || e === "text_segment_boundary") && (t.negate = !!(r != null && r.negate)), t;
|
|
625
|
+
}
|
|
626
|
+
function Me(e, r) {
|
|
627
|
+
const t = !!(r != null && r.orphan);
|
|
628
|
+
return { type: "Backreference", ref: e, ...t && { orphan: t } };
|
|
629
|
+
}
|
|
630
|
+
function Cr(e, r) {
|
|
631
|
+
const t = { name: void 0, isSubroutined: !1, ...r };
|
|
632
|
+
if (t.name !== void 0 && !Dt(t.name))
|
|
633
|
+
throw new Error(`Group name "${t.name}" invalid in Oniguruma`);
|
|
634
|
+
return { type: "CapturingGroup", number: e, ...t.name && { name: t.name }, ...t.isSubroutined && { isSubroutined: t.isSubroutined }, body: ce(r == null ? void 0 : r.body) };
|
|
635
|
+
}
|
|
636
|
+
function he(e, r) {
|
|
637
|
+
const t = { useLastValid: !1, ...r };
|
|
638
|
+
if (e > 1114111) {
|
|
639
|
+
const n = e.toString(16);
|
|
640
|
+
if (t.useLastValid)
|
|
641
|
+
e = 1114111;
|
|
642
|
+
else
|
|
643
|
+
throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${n}}"`) : new Error(`Invalid code point out of range in JS "\\x{${n}}"`);
|
|
644
|
+
}
|
|
645
|
+
return { type: "Character", value: e };
|
|
646
|
+
}
|
|
647
|
+
function de(e) {
|
|
648
|
+
const r = { kind: "union", negate: !1, ...e };
|
|
649
|
+
return { type: "CharacterClass", kind: r.kind, negate: r.negate, body: kr(e == null ? void 0 : e.body) };
|
|
650
|
+
}
|
|
651
|
+
function Lt(e, r) {
|
|
652
|
+
if (r.value < e.value)
|
|
653
|
+
throw new Error("Character class range out of order");
|
|
654
|
+
return { type: "CharacterClassRange", min: e, max: r };
|
|
655
|
+
}
|
|
656
|
+
function Le(e, r) {
|
|
657
|
+
const t = !!(r != null && r.negate), n = { type: "CharacterSet", kind: e };
|
|
658
|
+
return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (n.negate = t), (e === "text_segment" || e === "newline" && !t) && (n.variableLength = !0), n;
|
|
659
|
+
}
|
|
660
|
+
function Ft(e, r = {}) {
|
|
661
|
+
if (e === "keep")
|
|
662
|
+
return { type: "Directive", kind: e };
|
|
663
|
+
if (e === "flags")
|
|
664
|
+
return { type: "Directive", kind: e, flags: se(r.flags) };
|
|
665
|
+
throw new Error(`Unexpected directive kind "${e}"`);
|
|
666
|
+
}
|
|
667
|
+
function Gt(e) {
|
|
668
|
+
return { type: "Flags", ...e };
|
|
669
|
+
}
|
|
670
|
+
function L(e) {
|
|
671
|
+
const r = e == null ? void 0 : e.atomic, t = e == null ? void 0 : e.flags;
|
|
672
|
+
if (r && t)
|
|
673
|
+
throw new Error("Atomic group cannot have flags");
|
|
674
|
+
return { type: "Group", ...r && { atomic: r }, ...t && { flags: t }, body: ce(e == null ? void 0 : e.body) };
|
|
675
|
+
}
|
|
676
|
+
function W(e) {
|
|
677
|
+
const r = { behind: !1, negate: !1, ...e };
|
|
678
|
+
return { type: "LookaroundAssertion", kind: r.behind ? "lookbehind" : "lookahead", negate: r.negate, body: ce(e == null ? void 0 : e.body) };
|
|
679
|
+
}
|
|
680
|
+
function Pt(e, r, t) {
|
|
681
|
+
return { type: "NamedCallout", kind: e, tag: r, arguments: t };
|
|
682
|
+
}
|
|
683
|
+
function Rt(e, r) {
|
|
684
|
+
const t = !!(r != null && r.negate);
|
|
685
|
+
if (!Ue.has(e))
|
|
686
|
+
throw new Error(`Invalid POSIX class "${e}"`);
|
|
687
|
+
return { type: "CharacterSet", kind: "posix", value: e, negate: t };
|
|
688
|
+
}
|
|
689
|
+
function br(e, r, t, n) {
|
|
690
|
+
if (r > t)
|
|
691
|
+
throw new Error("Invalid reversed quantifier range");
|
|
692
|
+
return { type: "Quantifier", kind: e, min: r, max: t, body: n };
|
|
693
|
+
}
|
|
694
|
+
function Ut(e, r) {
|
|
695
|
+
return { type: "Regex", body: ce(r == null ? void 0 : r.body), flags: e };
|
|
696
|
+
}
|
|
697
|
+
function xr(e) {
|
|
698
|
+
return { type: "Subroutine", ref: e };
|
|
699
|
+
}
|
|
700
|
+
function te(e, r) {
|
|
701
|
+
var s;
|
|
702
|
+
const t = { negate: !1, normalizeUnknownPropertyNames: !1, skipPropertyNameValidation: !1, unicodePropertyMap: null, ...r };
|
|
703
|
+
let n = (s = t.unicodePropertyMap) == null ? void 0 : s.get(me(e));
|
|
704
|
+
if (!n) {
|
|
705
|
+
if (t.normalizeUnknownPropertyNames)
|
|
706
|
+
n = Tt(e);
|
|
707
|
+
else if (t.unicodePropertyMap && !t.skipPropertyNameValidation)
|
|
708
|
+
throw new Error(x`Invalid Unicode property "\p{${e}}"`);
|
|
709
|
+
}
|
|
710
|
+
return { type: "CharacterSet", kind: "property", value: n ?? e, negate: t.negate };
|
|
711
|
+
}
|
|
712
|
+
function Ot({ flags: e, kind: r, name: t, negate: n, number: s }) {
|
|
713
|
+
switch (r) {
|
|
714
|
+
case "absence_repeater":
|
|
715
|
+
return Mt("repeater");
|
|
716
|
+
case "atomic":
|
|
717
|
+
return L({ atomic: !0 });
|
|
718
|
+
case "capturing":
|
|
719
|
+
return Cr(s, { name: t });
|
|
720
|
+
case "group":
|
|
721
|
+
return L({ flags: e });
|
|
722
|
+
case "lookahead":
|
|
723
|
+
case "lookbehind":
|
|
724
|
+
return W({ behind: r === "lookbehind", negate: n });
|
|
725
|
+
default:
|
|
726
|
+
throw new Error(`Unexpected group kind "${r}"`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function ce(e) {
|
|
730
|
+
if (e === void 0)
|
|
731
|
+
e = [q()];
|
|
732
|
+
else if (!Array.isArray(e) || !e.length || !e.every((r) => r.type === "Alternative"))
|
|
733
|
+
throw new Error("Invalid body; expected array of one or more Alternative nodes");
|
|
734
|
+
return e;
|
|
735
|
+
}
|
|
736
|
+
function kr(e) {
|
|
737
|
+
if (e === void 0)
|
|
738
|
+
e = [];
|
|
739
|
+
else if (!Array.isArray(e) || !e.every((r) => !!r.type))
|
|
740
|
+
throw new Error("Invalid body; expected array of nodes");
|
|
741
|
+
return e;
|
|
742
|
+
}
|
|
743
|
+
function Qe(e) {
|
|
744
|
+
return e.type === "LookaroundAssertion" && e.kind === "lookahead";
|
|
745
|
+
}
|
|
746
|
+
function qe(e) {
|
|
747
|
+
return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
|
|
748
|
+
}
|
|
749
|
+
function Dt(e) {
|
|
750
|
+
return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
|
|
751
|
+
}
|
|
752
|
+
function Tt(e) {
|
|
753
|
+
return e.trim().replace(/[- _]+/g, "_").replace(/[A-Z][a-z]+(?=[A-Z])/g, "$&_").replace(/[A-Za-z]+/g, (r) => r[0].toUpperCase() + r.slice(1).toLowerCase());
|
|
754
|
+
}
|
|
755
|
+
function me(e) {
|
|
756
|
+
return e.replace(/[- _]+/g, "").toLowerCase();
|
|
757
|
+
}
|
|
758
|
+
function Je(e, r) {
|
|
759
|
+
return se(e, `${(r == null ? void 0 : r.type) === "Character" && r.value === 93 ? "Empty" : "Unclosed"} character class`);
|
|
760
|
+
}
|
|
761
|
+
function Ke(e) {
|
|
762
|
+
return se(e, "Unclosed group");
|
|
763
|
+
}
|
|
764
|
+
function ae(e, r, t = null) {
|
|
765
|
+
function n(o, a) {
|
|
766
|
+
for (let i = 0; i < o.length; i++) {
|
|
767
|
+
const u = s(o[i], a, i, o);
|
|
768
|
+
i = Math.max(-1, i + u);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function s(o, a = null, i = null, u = null) {
|
|
772
|
+
var E, A;
|
|
773
|
+
let c = 0, l = !1;
|
|
774
|
+
const p = { node: o, parent: a, key: i, container: u, root: e, remove() {
|
|
775
|
+
pe(u).splice(Math.max(0, K(i) + c), 1), c--, l = !0;
|
|
776
|
+
}, removeAllNextSiblings() {
|
|
777
|
+
return pe(u).splice(K(i) + 1);
|
|
778
|
+
}, removeAllPrevSiblings() {
|
|
779
|
+
const y = K(i) + c;
|
|
780
|
+
return c -= y, pe(u).splice(0, Math.max(0, y));
|
|
781
|
+
}, replaceWith(y, k = {}) {
|
|
782
|
+
const _ = !!k.traverse;
|
|
783
|
+
u ? u[Math.max(0, K(i) + c)] = y : se(a, "Can't replace root node")[i] = y, _ && s(y, a, i, u), l = !0;
|
|
784
|
+
}, replaceWithMultiple(y, k = {}) {
|
|
785
|
+
const _ = !!k.traverse;
|
|
786
|
+
if (pe(u).splice(Math.max(0, K(i) + c), 1, ...y), c += y.length - 1, _) {
|
|
787
|
+
let j = 0;
|
|
788
|
+
for (let N = 0; N < y.length; N++)
|
|
789
|
+
j += s(y[N], a, K(i) + N + j, u);
|
|
790
|
+
}
|
|
791
|
+
l = !0;
|
|
792
|
+
}, skip() {
|
|
793
|
+
l = !0;
|
|
794
|
+
} }, { type: f } = o, g = r["*"], d = r[f], m = typeof g == "function" ? g : g == null ? void 0 : g.enter, w = typeof d == "function" ? d : d == null ? void 0 : d.enter;
|
|
795
|
+
if (m == null || m(p, t), w == null || w(p, t), !l)
|
|
796
|
+
switch (f) {
|
|
797
|
+
case "AbsenceFunction":
|
|
798
|
+
case "CapturingGroup":
|
|
799
|
+
case "Group":
|
|
800
|
+
n(o.body, o);
|
|
801
|
+
break;
|
|
802
|
+
case "Alternative":
|
|
803
|
+
case "CharacterClass":
|
|
804
|
+
n(o.body, o);
|
|
805
|
+
break;
|
|
806
|
+
case "Assertion":
|
|
807
|
+
case "Backreference":
|
|
808
|
+
case "Character":
|
|
809
|
+
case "CharacterSet":
|
|
810
|
+
case "Directive":
|
|
811
|
+
case "Flags":
|
|
812
|
+
case "NamedCallout":
|
|
813
|
+
case "Subroutine":
|
|
814
|
+
break;
|
|
815
|
+
case "CharacterClassRange":
|
|
816
|
+
s(o.min, o, "min"), s(o.max, o, "max");
|
|
817
|
+
break;
|
|
818
|
+
case "LookaroundAssertion":
|
|
819
|
+
n(o.body, o);
|
|
820
|
+
break;
|
|
821
|
+
case "Quantifier":
|
|
822
|
+
s(o.body, o, "body");
|
|
823
|
+
break;
|
|
824
|
+
case "Regex":
|
|
825
|
+
n(o.body, o), s(o.flags, o, "flags");
|
|
826
|
+
break;
|
|
827
|
+
default:
|
|
828
|
+
throw new Error(`Unexpected node type "${f}"`);
|
|
829
|
+
}
|
|
830
|
+
return (E = d == null ? void 0 : d.exit) == null || E.call(d, p, t), (A = g == null ? void 0 : g.exit) == null || A.call(g, p, t), c;
|
|
831
|
+
}
|
|
832
|
+
return s(e), e;
|
|
833
|
+
}
|
|
834
|
+
function pe(e) {
|
|
835
|
+
if (!Array.isArray(e))
|
|
836
|
+
throw new Error("Container expected");
|
|
837
|
+
return e;
|
|
838
|
+
}
|
|
839
|
+
function K(e) {
|
|
840
|
+
if (typeof e != "number")
|
|
841
|
+
throw new Error("Numeric key expected");
|
|
842
|
+
return e;
|
|
843
|
+
}
|
|
844
|
+
const Bt = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
|
|
845
|
+
function jt(e, r) {
|
|
846
|
+
for (let t = 0; t < e.length; t++)
|
|
847
|
+
e[t] >= r && e[t]++;
|
|
848
|
+
}
|
|
849
|
+
function Vt(e, r, t, n) {
|
|
850
|
+
return e.slice(0, r) + n + e.slice(r + t.length);
|
|
851
|
+
}
|
|
852
|
+
const S = Object.freeze({
|
|
853
|
+
DEFAULT: "DEFAULT",
|
|
854
|
+
CHAR_CLASS: "CHAR_CLASS"
|
|
855
|
+
});
|
|
856
|
+
function De(e, r, t, n) {
|
|
857
|
+
const s = new RegExp(String.raw`${r}|(?<$skip>\[\^?|\\?.)`, "gsu"), o = [!1];
|
|
858
|
+
let a = 0, i = "";
|
|
859
|
+
for (const u of e.matchAll(s)) {
|
|
860
|
+
const { 0: c, groups: { $skip: l } } = u;
|
|
861
|
+
if (!l && (!n || n === S.DEFAULT == !a)) {
|
|
862
|
+
t instanceof Function ? i += t(u, {
|
|
863
|
+
context: a ? S.CHAR_CLASS : S.DEFAULT,
|
|
864
|
+
negated: o[o.length - 1]
|
|
865
|
+
}) : i += t;
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
c[0] === "[" ? (a++, o.push(c[1] === "^")) : c === "]" && a && (a--, o.pop()), i += c;
|
|
869
|
+
}
|
|
870
|
+
return i;
|
|
871
|
+
}
|
|
872
|
+
function $r(e, r, t, n) {
|
|
873
|
+
De(e, r, t, n);
|
|
874
|
+
}
|
|
875
|
+
function zt(e, r, t = 0, n) {
|
|
876
|
+
if (!new RegExp(r, "su").test(e))
|
|
877
|
+
return null;
|
|
878
|
+
const s = new RegExp(`${r}|(?<$skip>\\\\?.)`, "gsu");
|
|
879
|
+
s.lastIndex = t;
|
|
880
|
+
let o = 0, a;
|
|
881
|
+
for (; a = s.exec(e); ) {
|
|
882
|
+
const { 0: i, groups: { $skip: u } } = a;
|
|
883
|
+
if (!u && (!n || n === S.DEFAULT == !o))
|
|
884
|
+
return a;
|
|
885
|
+
i === "[" ? o++ : i === "]" && o && o--, s.lastIndex == a.index && s.lastIndex++;
|
|
886
|
+
}
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
function fe(e, r, t) {
|
|
890
|
+
return !!zt(e, r, 0, t);
|
|
891
|
+
}
|
|
892
|
+
function Wt(e, r) {
|
|
893
|
+
const t = /\\?./gsu;
|
|
894
|
+
t.lastIndex = r;
|
|
895
|
+
let n = e.length, s = 0, o = 1, a;
|
|
896
|
+
for (; a = t.exec(e); ) {
|
|
897
|
+
const [i] = a;
|
|
898
|
+
if (i === "[")
|
|
899
|
+
s++;
|
|
900
|
+
else if (s)
|
|
901
|
+
i === "]" && s--;
|
|
902
|
+
else if (i === "(")
|
|
903
|
+
o++;
|
|
904
|
+
else if (i === ")" && (o--, !o)) {
|
|
905
|
+
n = a.index;
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return e.slice(r, n);
|
|
910
|
+
}
|
|
911
|
+
const Ye = new RegExp(String.raw`(?<noncapturingStart>${Bt})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
|
|
912
|
+
function Ht(e, r) {
|
|
913
|
+
const t = (r == null ? void 0 : r.hiddenCaptures) ?? [];
|
|
914
|
+
let n = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
|
|
915
|
+
if (!/\(\?>/.test(e))
|
|
916
|
+
return {
|
|
917
|
+
pattern: e,
|
|
918
|
+
captureTransfers: n,
|
|
919
|
+
hiddenCaptures: t
|
|
920
|
+
};
|
|
921
|
+
const s = "(?>", o = "(?:(?=(", a = [0], i = [];
|
|
922
|
+
let u = 0, c = 0, l = NaN, p;
|
|
923
|
+
do {
|
|
924
|
+
p = !1;
|
|
925
|
+
let f = 0, g = 0, d = !1, m;
|
|
926
|
+
for (Ye.lastIndex = Number.isNaN(l) ? 0 : l + o.length; m = Ye.exec(e); ) {
|
|
927
|
+
const { 0: w, index: E, groups: { capturingStart: A, noncapturingStart: y } } = m;
|
|
928
|
+
if (w === "[")
|
|
929
|
+
f++;
|
|
930
|
+
else if (f)
|
|
931
|
+
w === "]" && f--;
|
|
932
|
+
else if (w === s && !d)
|
|
933
|
+
l = E, d = !0;
|
|
934
|
+
else if (d && y)
|
|
935
|
+
g++;
|
|
936
|
+
else if (A)
|
|
937
|
+
d ? g++ : (u++, a.push(u + c));
|
|
938
|
+
else if (w === ")" && d) {
|
|
939
|
+
if (!g) {
|
|
940
|
+
c++;
|
|
941
|
+
const k = u + c;
|
|
942
|
+
if (e = `${e.slice(0, l)}${o}${e.slice(l + s.length, E)}))<$$${k}>)${e.slice(E + 1)}`, p = !0, i.push(k), jt(t, k), n.size) {
|
|
943
|
+
const _ = /* @__PURE__ */ new Map();
|
|
944
|
+
n.forEach((j, N) => {
|
|
945
|
+
_.set(
|
|
946
|
+
N >= k ? N + 1 : N,
|
|
947
|
+
j.map((J) => J >= k ? J + 1 : J)
|
|
948
|
+
);
|
|
949
|
+
}), n = _;
|
|
950
|
+
}
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
g--;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
} while (p);
|
|
957
|
+
return t.push(...i), e = De(
|
|
958
|
+
e,
|
|
959
|
+
String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,
|
|
960
|
+
({ 0: f, groups: { backrefNum: g, wrappedBackrefNum: d } }) => {
|
|
961
|
+
if (g) {
|
|
962
|
+
const m = +g;
|
|
963
|
+
if (m > a.length - 1)
|
|
964
|
+
throw new Error(`Backref "${f}" greater than number of captures`);
|
|
965
|
+
return `\\${a[m]}`;
|
|
966
|
+
}
|
|
967
|
+
return `\\${d}`;
|
|
968
|
+
},
|
|
969
|
+
S.DEFAULT
|
|
970
|
+
), {
|
|
971
|
+
pattern: e,
|
|
972
|
+
captureTransfers: n,
|
|
973
|
+
hiddenCaptures: t
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
const Er = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`, ke = new RegExp(String.raw`
|
|
977
|
+
\\(?: \d+
|
|
978
|
+
| c[A-Za-z]
|
|
979
|
+
| [gk]<[^>]+>
|
|
980
|
+
| [pPu]\{[^\}]+\}
|
|
981
|
+
| u[A-Fa-f\d]{4}
|
|
982
|
+
| x[A-Fa-f\d]{2}
|
|
983
|
+
)
|
|
984
|
+
| \((?: \? (?: [:=!>]
|
|
985
|
+
| <(?:[=!]|[^>]+>)
|
|
986
|
+
| [A-Za-z\-]+:
|
|
987
|
+
| \(DEFINE\)
|
|
988
|
+
))?
|
|
989
|
+
| (?<qBase>${Er})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
990
|
+
| \\?.
|
|
991
|
+
`.replace(/\s+/g, ""), "gsu");
|
|
992
|
+
function Xt(e) {
|
|
993
|
+
if (!new RegExp(`${Er}\\+`).test(e))
|
|
994
|
+
return {
|
|
995
|
+
pattern: e
|
|
996
|
+
};
|
|
997
|
+
const r = [];
|
|
998
|
+
let t = null, n = null, s = "", o = 0, a;
|
|
999
|
+
for (ke.lastIndex = 0; a = ke.exec(e); ) {
|
|
1000
|
+
const { 0: i, index: u, groups: { qBase: c, qMod: l, invalidQ: p } } = a;
|
|
1001
|
+
if (i === "[")
|
|
1002
|
+
o || (n = u), o++;
|
|
1003
|
+
else if (i === "]")
|
|
1004
|
+
o ? o-- : n = null;
|
|
1005
|
+
else if (!o)
|
|
1006
|
+
if (l === "+" && s && !s.startsWith("(")) {
|
|
1007
|
+
if (p)
|
|
1008
|
+
throw new Error(`Invalid quantifier "${i}"`);
|
|
1009
|
+
let f = -1;
|
|
1010
|
+
if (/^\{\d+\}$/.test(c))
|
|
1011
|
+
e = Vt(e, u + c.length, l, "");
|
|
1012
|
+
else {
|
|
1013
|
+
if (s === ")" || s === "]") {
|
|
1014
|
+
const g = s === ")" ? t : n;
|
|
1015
|
+
if (g === null)
|
|
1016
|
+
throw new Error(`Invalid unmatched "${s}"`);
|
|
1017
|
+
e = `${e.slice(0, g)}(?>${e.slice(g, u)}${c})${e.slice(u + i.length)}`;
|
|
1018
|
+
} else
|
|
1019
|
+
e = `${e.slice(0, u - s.length)}(?>${s}${c})${e.slice(u + i.length)}`;
|
|
1020
|
+
f += 4;
|
|
1021
|
+
}
|
|
1022
|
+
ke.lastIndex += f;
|
|
1023
|
+
} else
|
|
1024
|
+
i[0] === "(" ? r.push(u) : i === ")" && (t = r.length ? r.pop() : null);
|
|
1025
|
+
s = i;
|
|
1026
|
+
}
|
|
1027
|
+
return {
|
|
1028
|
+
pattern: e
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
const I = String.raw, Zt = I`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`, Fe = I`\(\?R=(?<rDepth>[^\)]+)\)|${Zt}`, we = I`\(\?<(?![=!])(?<captureName>[^>]+)>`, Ar = I`${we}|(?<unnamed>\()(?!\?)`, z = new RegExp(I`${we}|${Fe}|\(\?|\\?.`, "gsu"), $e = "Cannot use multiple overlapping recursions";
|
|
1032
|
+
function Qt(e, r) {
|
|
1033
|
+
const { hiddenCaptures: t, mode: n } = {
|
|
1034
|
+
hiddenCaptures: [],
|
|
1035
|
+
mode: "plugin",
|
|
1036
|
+
...r
|
|
1037
|
+
};
|
|
1038
|
+
let s = (r == null ? void 0 : r.captureTransfers) ?? /* @__PURE__ */ new Map();
|
|
1039
|
+
if (!new RegExp(Fe, "su").test(e))
|
|
1040
|
+
return {
|
|
1041
|
+
pattern: e,
|
|
1042
|
+
captureTransfers: s,
|
|
1043
|
+
hiddenCaptures: t
|
|
1044
|
+
};
|
|
1045
|
+
if (n === "plugin" && fe(e, I`\(\?\(DEFINE\)`, S.DEFAULT))
|
|
1046
|
+
throw new Error("DEFINE groups cannot be used with recursion");
|
|
1047
|
+
const o = [], a = fe(e, I`\\[1-9]`, S.DEFAULT), i = /* @__PURE__ */ new Map(), u = [];
|
|
1048
|
+
let c = !1, l = 0, p = 0, f;
|
|
1049
|
+
for (z.lastIndex = 0; f = z.exec(e); ) {
|
|
1050
|
+
const { 0: g, groups: { captureName: d, rDepth: m, gRNameOrNum: w, gRDepth: E } } = f;
|
|
1051
|
+
if (g === "[")
|
|
1052
|
+
l++;
|
|
1053
|
+
else if (l)
|
|
1054
|
+
g === "]" && l--;
|
|
1055
|
+
else if (m) {
|
|
1056
|
+
if (er(m), c)
|
|
1057
|
+
throw new Error($e);
|
|
1058
|
+
if (a)
|
|
1059
|
+
throw new Error(
|
|
1060
|
+
// When used in `external` mode by transpilers other than Regex+, backrefs might have
|
|
1061
|
+
// gone through conversion from named to numbered, so avoid a misleading error
|
|
1062
|
+
`${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`
|
|
1063
|
+
);
|
|
1064
|
+
const A = e.slice(0, f.index), y = e.slice(z.lastIndex);
|
|
1065
|
+
if (fe(y, Fe, S.DEFAULT))
|
|
1066
|
+
throw new Error($e);
|
|
1067
|
+
const k = +m - 1;
|
|
1068
|
+
e = rr(
|
|
1069
|
+
A,
|
|
1070
|
+
y,
|
|
1071
|
+
k,
|
|
1072
|
+
!1,
|
|
1073
|
+
t,
|
|
1074
|
+
o,
|
|
1075
|
+
p
|
|
1076
|
+
), s = nr(
|
|
1077
|
+
s,
|
|
1078
|
+
A,
|
|
1079
|
+
k,
|
|
1080
|
+
o.length,
|
|
1081
|
+
0,
|
|
1082
|
+
p
|
|
1083
|
+
);
|
|
1084
|
+
break;
|
|
1085
|
+
} else if (w) {
|
|
1086
|
+
er(E);
|
|
1087
|
+
let A = !1;
|
|
1088
|
+
for (const oe of u)
|
|
1089
|
+
if (oe.name === w || oe.num === +w) {
|
|
1090
|
+
if (A = !0, oe.hasRecursedWithin)
|
|
1091
|
+
throw new Error($e);
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
if (!A)
|
|
1095
|
+
throw new Error(I`Recursive \g cannot be used outside the referenced group "${n === "external" ? w : I`\g<${w}&R=${E}>`}"`);
|
|
1096
|
+
const y = i.get(w), k = Wt(e, y);
|
|
1097
|
+
if (a && fe(k, I`${we}|\((?!\?)`, S.DEFAULT))
|
|
1098
|
+
throw new Error(
|
|
1099
|
+
// When used in `external` mode by transpilers other than Regex+, backrefs might have
|
|
1100
|
+
// gone through conversion from named to numbered, so avoid a misleading error
|
|
1101
|
+
`${n === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`
|
|
1102
|
+
);
|
|
1103
|
+
const _ = e.slice(y, f.index), j = k.slice(_.length + g.length), N = o.length, J = +E - 1, je = rr(
|
|
1104
|
+
_,
|
|
1105
|
+
j,
|
|
1106
|
+
J,
|
|
1107
|
+
!0,
|
|
1108
|
+
t,
|
|
1109
|
+
o,
|
|
1110
|
+
p
|
|
1111
|
+
);
|
|
1112
|
+
s = nr(
|
|
1113
|
+
s,
|
|
1114
|
+
_,
|
|
1115
|
+
J,
|
|
1116
|
+
o.length - N,
|
|
1117
|
+
N,
|
|
1118
|
+
p
|
|
1119
|
+
);
|
|
1120
|
+
const Ur = e.slice(0, y), Or = e.slice(y + k.length);
|
|
1121
|
+
e = `${Ur}${je}${Or}`, z.lastIndex += je.length - g.length - _.length - j.length, u.forEach((oe) => oe.hasRecursedWithin = !0), c = !0;
|
|
1122
|
+
} else if (d)
|
|
1123
|
+
p++, i.set(String(p), z.lastIndex), i.set(d, z.lastIndex), u.push({
|
|
1124
|
+
num: p,
|
|
1125
|
+
name: d
|
|
1126
|
+
});
|
|
1127
|
+
else if (g[0] === "(") {
|
|
1128
|
+
const A = g === "(";
|
|
1129
|
+
A && (p++, i.set(String(p), z.lastIndex)), u.push(A ? { num: p } : {});
|
|
1130
|
+
} else
|
|
1131
|
+
g === ")" && u.pop();
|
|
1132
|
+
}
|
|
1133
|
+
return t.push(...o), {
|
|
1134
|
+
pattern: e,
|
|
1135
|
+
captureTransfers: s,
|
|
1136
|
+
hiddenCaptures: t
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
function er(e) {
|
|
1140
|
+
const r = `Max depth must be integer between 2 and 100; used ${e}`;
|
|
1141
|
+
if (!/^[1-9]\d*$/.test(e))
|
|
1142
|
+
throw new Error(r);
|
|
1143
|
+
if (e = +e, e < 2 || e > 100)
|
|
1144
|
+
throw new Error(r);
|
|
1145
|
+
}
|
|
1146
|
+
function rr(e, r, t, n, s, o, a) {
|
|
1147
|
+
const i = /* @__PURE__ */ new Set();
|
|
1148
|
+
n && $r(e + r, we, ({ groups: { captureName: c } }) => {
|
|
1149
|
+
i.add(c);
|
|
1150
|
+
}, S.DEFAULT);
|
|
1151
|
+
const u = [
|
|
1152
|
+
t,
|
|
1153
|
+
n ? i : null,
|
|
1154
|
+
s,
|
|
1155
|
+
o,
|
|
1156
|
+
a
|
|
1157
|
+
];
|
|
1158
|
+
return `${e}${tr(`(?:${e}`, "forward", ...u)}(?:)${tr(`${r})`, "backward", ...u)}${r}`;
|
|
1159
|
+
}
|
|
1160
|
+
function tr(e, r, t, n, s, o, a) {
|
|
1161
|
+
const u = (l) => r === "forward" ? l + 2 : t - l + 2 - 1;
|
|
1162
|
+
let c = "";
|
|
1163
|
+
for (let l = 0; l < t; l++) {
|
|
1164
|
+
const p = u(l);
|
|
1165
|
+
c += De(
|
|
1166
|
+
e,
|
|
1167
|
+
I`${Ar}|\\k<(?<backref>[^>]+)>`,
|
|
1168
|
+
({ 0: f, groups: { captureName: g, unnamed: d, backref: m } }) => {
|
|
1169
|
+
if (m && n && !n.has(m))
|
|
1170
|
+
return f;
|
|
1171
|
+
const w = `_$${p}`;
|
|
1172
|
+
if (d || g) {
|
|
1173
|
+
const E = a + o.length + 1;
|
|
1174
|
+
return o.push(E), qt(s, E), d ? f : `(?<${g}${w}>`;
|
|
1175
|
+
}
|
|
1176
|
+
return I`\k<${m}${w}>`;
|
|
1177
|
+
},
|
|
1178
|
+
S.DEFAULT
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
return c;
|
|
1182
|
+
}
|
|
1183
|
+
function qt(e, r) {
|
|
1184
|
+
for (let t = 0; t < e.length; t++)
|
|
1185
|
+
e[t] >= r && e[t]++;
|
|
1186
|
+
}
|
|
1187
|
+
function nr(e, r, t, n, s, o) {
|
|
1188
|
+
if (e.size && n) {
|
|
1189
|
+
let a = 0;
|
|
1190
|
+
$r(r, Ar, () => a++, S.DEFAULT);
|
|
1191
|
+
const i = o - a + s, u = /* @__PURE__ */ new Map();
|
|
1192
|
+
return e.forEach((c, l) => {
|
|
1193
|
+
const p = (n - a * t) / t, f = a * t, g = l > i + a ? l + n : l, d = [];
|
|
1194
|
+
for (const m of c)
|
|
1195
|
+
if (m <= i)
|
|
1196
|
+
d.push(m);
|
|
1197
|
+
else if (m > i + a + p)
|
|
1198
|
+
d.push(m + n);
|
|
1199
|
+
else if (m <= i + a)
|
|
1200
|
+
for (let w = 0; w <= t; w++)
|
|
1201
|
+
d.push(m + a * w);
|
|
1202
|
+
else
|
|
1203
|
+
for (let w = 0; w <= t; w++)
|
|
1204
|
+
d.push(m + f + p * w);
|
|
1205
|
+
u.set(g, d);
|
|
1206
|
+
}), u;
|
|
1207
|
+
}
|
|
1208
|
+
return e;
|
|
1209
|
+
}
|
|
1210
|
+
var b = String.fromCodePoint, h = String.raw, U = {
|
|
1211
|
+
flagGroups: (() => {
|
|
1212
|
+
try {
|
|
1213
|
+
new RegExp("(?i:)");
|
|
1214
|
+
} catch {
|
|
1215
|
+
return !1;
|
|
1216
|
+
}
|
|
1217
|
+
return !0;
|
|
1218
|
+
})(),
|
|
1219
|
+
unicodeSets: (() => {
|
|
1220
|
+
try {
|
|
1221
|
+
new RegExp("[[]]", "v");
|
|
1222
|
+
} catch {
|
|
1223
|
+
return !1;
|
|
1224
|
+
}
|
|
1225
|
+
return !0;
|
|
1226
|
+
})()
|
|
1227
|
+
};
|
|
1228
|
+
U.bugFlagVLiteralHyphenIsRange = U.unicodeSets ? (() => {
|
|
1229
|
+
try {
|
|
1230
|
+
new RegExp(h`[\d\-a]`, "v");
|
|
1231
|
+
} catch {
|
|
1232
|
+
return !0;
|
|
1233
|
+
}
|
|
1234
|
+
return !1;
|
|
1235
|
+
})() : !1;
|
|
1236
|
+
U.bugNestedClassIgnoresNegation = U.unicodeSets && new RegExp("[[^a]]", "v").test("a");
|
|
1237
|
+
function ge(e, { enable: r, disable: t }) {
|
|
1238
|
+
return {
|
|
1239
|
+
dotAll: !(t != null && t.dotAll) && !!(r != null && r.dotAll || e.dotAll),
|
|
1240
|
+
ignoreCase: !(t != null && t.ignoreCase) && !!(r != null && r.ignoreCase || e.ignoreCase)
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function ie(e, r, t) {
|
|
1244
|
+
return e.has(r) || e.set(r, t), e.get(r);
|
|
1245
|
+
}
|
|
1246
|
+
function Ge(e, r) {
|
|
1247
|
+
return sr[e] >= sr[r];
|
|
1248
|
+
}
|
|
1249
|
+
function Jt(e, r) {
|
|
1250
|
+
if (e == null)
|
|
1251
|
+
throw new Error(r ?? "Value expected");
|
|
1252
|
+
return e;
|
|
1253
|
+
}
|
|
1254
|
+
var sr = {
|
|
1255
|
+
ES2025: 2025,
|
|
1256
|
+
ES2024: 2024,
|
|
1257
|
+
ES2018: 2018
|
|
1258
|
+
}, Kt = (
|
|
1259
|
+
/** @type {const} */
|
|
1260
|
+
{
|
|
1261
|
+
auto: "auto",
|
|
1262
|
+
ES2025: "ES2025",
|
|
1263
|
+
ES2024: "ES2024",
|
|
1264
|
+
ES2018: "ES2018"
|
|
1265
|
+
}
|
|
1266
|
+
);
|
|
1267
|
+
function Ir(e = {}) {
|
|
1268
|
+
if ({}.toString.call(e) !== "[object Object]")
|
|
1269
|
+
throw new Error("Unexpected options");
|
|
1270
|
+
if (e.target !== void 0 && !Kt[e.target])
|
|
1271
|
+
throw new Error(`Unexpected target "${e.target}"`);
|
|
1272
|
+
const r = {
|
|
1273
|
+
// Sets the level of emulation rigor/strictness.
|
|
1274
|
+
accuracy: "default",
|
|
1275
|
+
// Disables advanced emulation that relies on returning a `RegExp` subclass, resulting in
|
|
1276
|
+
// certain patterns not being emulatable.
|
|
1277
|
+
avoidSubclass: !1,
|
|
1278
|
+
// Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W`, `y{g}` in any order (all
|
|
1279
|
+
// optional). Oniguruma's `m` is equivalent to JavaScript's `s` (`dotAll`).
|
|
1280
|
+
flags: "",
|
|
1281
|
+
// Include JavaScript flag `g` (`global`) in the result.
|
|
1282
|
+
global: !1,
|
|
1283
|
+
// Include JavaScript flag `d` (`hasIndices`) in the result.
|
|
1284
|
+
hasIndices: !1,
|
|
1285
|
+
// Delay regex construction until first use if the transpiled pattern is at least this length.
|
|
1286
|
+
lazyCompileLength: 1 / 0,
|
|
1287
|
+
// JavaScript version used for generated regexes. Using `auto` detects the best value based on
|
|
1288
|
+
// your environment. Later targets allow faster processing, simpler generated source, and
|
|
1289
|
+
// support for additional features.
|
|
1290
|
+
target: "auto",
|
|
1291
|
+
// Disables minifications that simplify the pattern without changing the meaning.
|
|
1292
|
+
verbose: !1,
|
|
1293
|
+
...e,
|
|
1294
|
+
// Advanced options that override standard behavior, error checking, and flags when enabled.
|
|
1295
|
+
rules: {
|
|
1296
|
+
// Useful with TextMate grammars that merge backreferences across patterns.
|
|
1297
|
+
allowOrphanBackrefs: !1,
|
|
1298
|
+
// Use ASCII `\b` and `\B`, which increases search performance of generated regexes.
|
|
1299
|
+
asciiWordBoundaries: !1,
|
|
1300
|
+
// Allow unnamed captures and numbered calls (backreferences and subroutines) when using
|
|
1301
|
+
// named capture. This is Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`; on by default in
|
|
1302
|
+
// `vscode-oniguruma`.
|
|
1303
|
+
captureGroup: !1,
|
|
1304
|
+
// Change the recursion depth limit from Oniguruma's `20` to an integer `2`–`20`.
|
|
1305
|
+
recursionLimit: 20,
|
|
1306
|
+
// `^` as `\A`; `$` as`\Z`. Improves search performance of generated regexes without changing
|
|
1307
|
+
// the meaning if searching line by line. This is Oniguruma option `ONIG_OPTION_SINGLELINE`.
|
|
1308
|
+
singleline: !1,
|
|
1309
|
+
...e.rules
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
return r.target === "auto" && (r.target = U.flagGroups ? "ES2025" : U.unicodeSets ? "ES2024" : "ES2018"), r;
|
|
1313
|
+
}
|
|
1314
|
+
var Yt = "[ -\r ]", en = /* @__PURE__ */ new Set([
|
|
1315
|
+
b(304),
|
|
1316
|
+
// İ
|
|
1317
|
+
b(305)
|
|
1318
|
+
// ı
|
|
1319
|
+
]), F = h`[\p{L}\p{M}\p{N}\p{Pc}]`;
|
|
1320
|
+
function vr(e) {
|
|
1321
|
+
if (en.has(e))
|
|
1322
|
+
return [e];
|
|
1323
|
+
const r = /* @__PURE__ */ new Set(), t = e.toLowerCase(), n = t.toUpperCase(), s = nn.get(t), o = rn.get(t), a = tn.get(t);
|
|
1324
|
+
return [...n].length === 1 && r.add(n), a && r.add(a), s && r.add(s), r.add(t), o && r.add(o), [...r];
|
|
1325
|
+
}
|
|
1326
|
+
var Te = /* @__PURE__ */ new Map(
|
|
1327
|
+
`C Other
|
|
1328
|
+
Cc Control cntrl
|
|
1329
|
+
Cf Format
|
|
1330
|
+
Cn Unassigned
|
|
1331
|
+
Co Private_Use
|
|
1332
|
+
Cs Surrogate
|
|
1333
|
+
L Letter
|
|
1334
|
+
LC Cased_Letter
|
|
1335
|
+
Ll Lowercase_Letter
|
|
1336
|
+
Lm Modifier_Letter
|
|
1337
|
+
Lo Other_Letter
|
|
1338
|
+
Lt Titlecase_Letter
|
|
1339
|
+
Lu Uppercase_Letter
|
|
1340
|
+
M Mark Combining_Mark
|
|
1341
|
+
Mc Spacing_Mark
|
|
1342
|
+
Me Enclosing_Mark
|
|
1343
|
+
Mn Nonspacing_Mark
|
|
1344
|
+
N Number
|
|
1345
|
+
Nd Decimal_Number digit
|
|
1346
|
+
Nl Letter_Number
|
|
1347
|
+
No Other_Number
|
|
1348
|
+
P Punctuation punct
|
|
1349
|
+
Pc Connector_Punctuation
|
|
1350
|
+
Pd Dash_Punctuation
|
|
1351
|
+
Pe Close_Punctuation
|
|
1352
|
+
Pf Final_Punctuation
|
|
1353
|
+
Pi Initial_Punctuation
|
|
1354
|
+
Po Other_Punctuation
|
|
1355
|
+
Ps Open_Punctuation
|
|
1356
|
+
S Symbol
|
|
1357
|
+
Sc Currency_Symbol
|
|
1358
|
+
Sk Modifier_Symbol
|
|
1359
|
+
Sm Math_Symbol
|
|
1360
|
+
So Other_Symbol
|
|
1361
|
+
Z Separator
|
|
1362
|
+
Zl Line_Separator
|
|
1363
|
+
Zp Paragraph_Separator
|
|
1364
|
+
Zs Space_Separator
|
|
1365
|
+
ASCII
|
|
1366
|
+
ASCII_Hex_Digit AHex
|
|
1367
|
+
Alphabetic Alpha
|
|
1368
|
+
Any
|
|
1369
|
+
Assigned
|
|
1370
|
+
Bidi_Control Bidi_C
|
|
1371
|
+
Bidi_Mirrored Bidi_M
|
|
1372
|
+
Case_Ignorable CI
|
|
1373
|
+
Cased
|
|
1374
|
+
Changes_When_Casefolded CWCF
|
|
1375
|
+
Changes_When_Casemapped CWCM
|
|
1376
|
+
Changes_When_Lowercased CWL
|
|
1377
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
1378
|
+
Changes_When_Titlecased CWT
|
|
1379
|
+
Changes_When_Uppercased CWU
|
|
1380
|
+
Dash
|
|
1381
|
+
Default_Ignorable_Code_Point DI
|
|
1382
|
+
Deprecated Dep
|
|
1383
|
+
Diacritic Dia
|
|
1384
|
+
Emoji
|
|
1385
|
+
Emoji_Component EComp
|
|
1386
|
+
Emoji_Modifier EMod
|
|
1387
|
+
Emoji_Modifier_Base EBase
|
|
1388
|
+
Emoji_Presentation EPres
|
|
1389
|
+
Extended_Pictographic ExtPict
|
|
1390
|
+
Extender Ext
|
|
1391
|
+
Grapheme_Base Gr_Base
|
|
1392
|
+
Grapheme_Extend Gr_Ext
|
|
1393
|
+
Hex_Digit Hex
|
|
1394
|
+
IDS_Binary_Operator IDSB
|
|
1395
|
+
IDS_Trinary_Operator IDST
|
|
1396
|
+
ID_Continue IDC
|
|
1397
|
+
ID_Start IDS
|
|
1398
|
+
Ideographic Ideo
|
|
1399
|
+
Join_Control Join_C
|
|
1400
|
+
Logical_Order_Exception LOE
|
|
1401
|
+
Lowercase Lower
|
|
1402
|
+
Math
|
|
1403
|
+
Noncharacter_Code_Point NChar
|
|
1404
|
+
Pattern_Syntax Pat_Syn
|
|
1405
|
+
Pattern_White_Space Pat_WS
|
|
1406
|
+
Quotation_Mark QMark
|
|
1407
|
+
Radical
|
|
1408
|
+
Regional_Indicator RI
|
|
1409
|
+
Sentence_Terminal STerm
|
|
1410
|
+
Soft_Dotted SD
|
|
1411
|
+
Terminal_Punctuation Term
|
|
1412
|
+
Unified_Ideograph UIdeo
|
|
1413
|
+
Uppercase Upper
|
|
1414
|
+
Variation_Selector VS
|
|
1415
|
+
White_Space space
|
|
1416
|
+
XID_Continue XIDC
|
|
1417
|
+
XID_Start XIDS`.split(/\s/).map((e) => [me(e), e])
|
|
1418
|
+
), rn = /* @__PURE__ */ new Map([
|
|
1419
|
+
["s", b(383)],
|
|
1420
|
+
// s, ſ
|
|
1421
|
+
[b(383), "s"]
|
|
1422
|
+
// ſ, s
|
|
1423
|
+
]), tn = /* @__PURE__ */ new Map([
|
|
1424
|
+
[b(223), b(7838)],
|
|
1425
|
+
// ß, ẞ
|
|
1426
|
+
[b(107), b(8490)],
|
|
1427
|
+
// k, K (Kelvin)
|
|
1428
|
+
[b(229), b(8491)],
|
|
1429
|
+
// å, Å (Angstrom)
|
|
1430
|
+
[b(969), b(8486)]
|
|
1431
|
+
// ω, Ω (Ohm)
|
|
1432
|
+
]), nn = new Map([
|
|
1433
|
+
O(453),
|
|
1434
|
+
O(456),
|
|
1435
|
+
O(459),
|
|
1436
|
+
O(498),
|
|
1437
|
+
...Ee(8072, 8079),
|
|
1438
|
+
...Ee(8088, 8095),
|
|
1439
|
+
...Ee(8104, 8111),
|
|
1440
|
+
O(8124),
|
|
1441
|
+
O(8140),
|
|
1442
|
+
O(8188)
|
|
1443
|
+
]), sn = /* @__PURE__ */ new Map([
|
|
1444
|
+
["alnum", h`[\p{Alpha}\p{Nd}]`],
|
|
1445
|
+
["alpha", h`\p{Alpha}`],
|
|
1446
|
+
["ascii", h`\p{ASCII}`],
|
|
1447
|
+
["blank", h`[\p{Zs}\t]`],
|
|
1448
|
+
["cntrl", h`\p{Cc}`],
|
|
1449
|
+
["digit", h`\p{Nd}`],
|
|
1450
|
+
["graph", h`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
|
|
1451
|
+
["lower", h`\p{Lower}`],
|
|
1452
|
+
["print", h`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
|
|
1453
|
+
["punct", h`[\p{P}\p{S}]`],
|
|
1454
|
+
// Updated value from Onig 6.9.9; changed from Unicode `\p{punct}`
|
|
1455
|
+
["space", h`\p{space}`],
|
|
1456
|
+
["upper", h`\p{Upper}`],
|
|
1457
|
+
["word", h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
|
|
1458
|
+
["xdigit", h`\p{AHex}`]
|
|
1459
|
+
]);
|
|
1460
|
+
function on(e, r) {
|
|
1461
|
+
const t = [];
|
|
1462
|
+
for (let n = e; n <= r; n++)
|
|
1463
|
+
t.push(n);
|
|
1464
|
+
return t;
|
|
1465
|
+
}
|
|
1466
|
+
function O(e) {
|
|
1467
|
+
const r = b(e);
|
|
1468
|
+
return [r.toLowerCase(), r];
|
|
1469
|
+
}
|
|
1470
|
+
function Ee(e, r) {
|
|
1471
|
+
return on(e, r).map((t) => O(t));
|
|
1472
|
+
}
|
|
1473
|
+
var Sr = /* @__PURE__ */ new Set([
|
|
1474
|
+
"Lower",
|
|
1475
|
+
"Lowercase",
|
|
1476
|
+
"Upper",
|
|
1477
|
+
"Uppercase",
|
|
1478
|
+
"Ll",
|
|
1479
|
+
"Lowercase_Letter",
|
|
1480
|
+
"Lt",
|
|
1481
|
+
"Titlecase_Letter",
|
|
1482
|
+
"Lu",
|
|
1483
|
+
"Uppercase_Letter"
|
|
1484
|
+
// The `Changes_When_*` properties (and their aliases) could be included, but they're very rare.
|
|
1485
|
+
// Some other properties include a handful of chars with specific cases only, but these chars are
|
|
1486
|
+
// generally extreme edge cases and using such properties case insensitively generally produces
|
|
1487
|
+
// undesired behavior anyway
|
|
1488
|
+
]);
|
|
1489
|
+
function an(e, r) {
|
|
1490
|
+
const t = {
|
|
1491
|
+
// A couple edge cases exist where options `accuracy` and `bestEffortTarget` are used:
|
|
1492
|
+
// - `CharacterSet` kind `text_segment` (`\X`): An exact representation would require heavy
|
|
1493
|
+
// Unicode data; a best-effort approximation requires knowing the target.
|
|
1494
|
+
// - `CharacterSet` kind `posix` with values `graph` and `print`: Their complex Unicode
|
|
1495
|
+
// representations would be hard to change to ASCII versions after the fact in the generator
|
|
1496
|
+
// based on `target`/`accuracy`, so produce the appropriate structure here.
|
|
1497
|
+
accuracy: "default",
|
|
1498
|
+
asciiWordBoundaries: !1,
|
|
1499
|
+
avoidSubclass: !1,
|
|
1500
|
+
bestEffortTarget: "ES2025",
|
|
1501
|
+
...r
|
|
1502
|
+
};
|
|
1503
|
+
_r(e);
|
|
1504
|
+
const n = {
|
|
1505
|
+
accuracy: t.accuracy,
|
|
1506
|
+
asciiWordBoundaries: t.asciiWordBoundaries,
|
|
1507
|
+
avoidSubclass: t.avoidSubclass,
|
|
1508
|
+
flagDirectivesByAlt: /* @__PURE__ */ new Map(),
|
|
1509
|
+
jsGroupNameMap: /* @__PURE__ */ new Map(),
|
|
1510
|
+
minTargetEs2024: Ge(t.bestEffortTarget, "ES2024"),
|
|
1511
|
+
passedLookbehind: !1,
|
|
1512
|
+
strategy: null,
|
|
1513
|
+
// Subroutines can appear before the groups they ref, so collect reffed nodes for a second pass
|
|
1514
|
+
subroutineRefMap: /* @__PURE__ */ new Map(),
|
|
1515
|
+
supportedGNodes: /* @__PURE__ */ new Set(),
|
|
1516
|
+
digitIsAscii: e.flags.digitIsAscii,
|
|
1517
|
+
spaceIsAscii: e.flags.spaceIsAscii,
|
|
1518
|
+
wordIsAscii: e.flags.wordIsAscii
|
|
1519
|
+
};
|
|
1520
|
+
ae(e, un, n);
|
|
1521
|
+
const s = {
|
|
1522
|
+
dotAll: e.flags.dotAll,
|
|
1523
|
+
ignoreCase: e.flags.ignoreCase
|
|
1524
|
+
}, o = {
|
|
1525
|
+
currentFlags: s,
|
|
1526
|
+
prevFlags: null,
|
|
1527
|
+
globalFlags: s,
|
|
1528
|
+
groupOriginByCopy: /* @__PURE__ */ new Map(),
|
|
1529
|
+
groupsByName: /* @__PURE__ */ new Map(),
|
|
1530
|
+
multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
|
|
1531
|
+
openRefs: /* @__PURE__ */ new Map(),
|
|
1532
|
+
reffedNodesByReferencer: /* @__PURE__ */ new Map(),
|
|
1533
|
+
subroutineRefMap: n.subroutineRefMap
|
|
1534
|
+
};
|
|
1535
|
+
ae(e, cn, o);
|
|
1536
|
+
const a = {
|
|
1537
|
+
groupsByName: o.groupsByName,
|
|
1538
|
+
highestOrphanBackref: 0,
|
|
1539
|
+
numCapturesToLeft: 0,
|
|
1540
|
+
reffedNodesByReferencer: o.reffedNodesByReferencer
|
|
1541
|
+
};
|
|
1542
|
+
return ae(e, ln, a), e._originMap = o.groupOriginByCopy, e._strategy = n.strategy, e;
|
|
1543
|
+
}
|
|
1544
|
+
var un = {
|
|
1545
|
+
AbsenceFunction({ node: e, parent: r, replaceWith: t }) {
|
|
1546
|
+
const { body: n, kind: s } = e;
|
|
1547
|
+
if (s === "repeater") {
|
|
1548
|
+
const o = L();
|
|
1549
|
+
o.body[0].body.push(
|
|
1550
|
+
// Insert own alts as `body`
|
|
1551
|
+
W({ negate: !0, body: n }),
|
|
1552
|
+
te("Any")
|
|
1553
|
+
);
|
|
1554
|
+
const a = L();
|
|
1555
|
+
a.body[0].body.push(
|
|
1556
|
+
br("greedy", 0, 1 / 0, o)
|
|
1557
|
+
), t(C(a, r), { traverse: !0 });
|
|
1558
|
+
} else
|
|
1559
|
+
throw new Error('Unsupported absence function "(?~|"');
|
|
1560
|
+
},
|
|
1561
|
+
Alternative: {
|
|
1562
|
+
enter({ node: e, parent: r, key: t }, { flagDirectivesByAlt: n }) {
|
|
1563
|
+
const s = e.body.filter((o) => o.kind === "flags");
|
|
1564
|
+
for (let o = t + 1; o < r.body.length; o++) {
|
|
1565
|
+
const a = r.body[o];
|
|
1566
|
+
ie(n, a, []).push(...s);
|
|
1567
|
+
}
|
|
1568
|
+
},
|
|
1569
|
+
exit({ node: e }, { flagDirectivesByAlt: r }) {
|
|
1570
|
+
var t;
|
|
1571
|
+
if ((t = r.get(e)) != null && t.length) {
|
|
1572
|
+
const n = Mr(r.get(e));
|
|
1573
|
+
if (n) {
|
|
1574
|
+
const s = L({ flags: n });
|
|
1575
|
+
s.body[0].body = e.body, e.body = [C(s, e)];
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
Assertion({ node: e, parent: r, key: t, container: n, root: s, remove: o, replaceWith: a }, i) {
|
|
1581
|
+
const { kind: u, negate: c } = e, { asciiWordBoundaries: l, avoidSubclass: p, supportedGNodes: f, wordIsAscii: g } = i;
|
|
1582
|
+
if (u === "text_segment_boundary")
|
|
1583
|
+
throw new Error(`Unsupported text segment boundary "\\${c ? "Y" : "y"}"`);
|
|
1584
|
+
if (u === "line_end")
|
|
1585
|
+
a(C(W({ body: [
|
|
1586
|
+
q({ body: [Ne("string_end")] }),
|
|
1587
|
+
q({ body: [he(10)] })
|
|
1588
|
+
// `\n`
|
|
1589
|
+
] }), r));
|
|
1590
|
+
else if (u === "line_start")
|
|
1591
|
+
a(C(G(h`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: !0 }), r));
|
|
1592
|
+
else if (u === "search_start")
|
|
1593
|
+
if (f.has(e))
|
|
1594
|
+
s.flags.sticky = !0, o();
|
|
1595
|
+
else {
|
|
1596
|
+
const d = n[t - 1];
|
|
1597
|
+
if (d && mn(d))
|
|
1598
|
+
a(C(W({ negate: !0 }), r));
|
|
1599
|
+
else {
|
|
1600
|
+
if (p)
|
|
1601
|
+
throw new Error(h`Uses "\G" in a way that requires a subclass`);
|
|
1602
|
+
a(D(Ne("string_start"), r)), i.strategy = "clip_search";
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
else if (!(u === "string_end" || u === "string_start"))
|
|
1606
|
+
if (u === "string_end_newline")
|
|
1607
|
+
a(C(G(h`(?=\n?\z)`), r));
|
|
1608
|
+
else if (u === "word_boundary") {
|
|
1609
|
+
if (!g && !l) {
|
|
1610
|
+
const d = `(?:(?<=${F})(?!${F})|(?<!${F})(?=${F}))`, m = `(?:(?<=${F})(?=${F})|(?<!${F})(?!${F}))`;
|
|
1611
|
+
a(C(G(c ? m : d), r));
|
|
1612
|
+
}
|
|
1613
|
+
} else
|
|
1614
|
+
throw new Error(`Unexpected assertion kind "${u}"`);
|
|
1615
|
+
},
|
|
1616
|
+
Backreference({ node: e }, { jsGroupNameMap: r }) {
|
|
1617
|
+
let { ref: t } = e;
|
|
1618
|
+
typeof t == "string" && !Ie(t) && (t = Ae(t, r), e.ref = t);
|
|
1619
|
+
},
|
|
1620
|
+
CapturingGroup({ node: e }, { jsGroupNameMap: r, subroutineRefMap: t }) {
|
|
1621
|
+
let { name: n } = e;
|
|
1622
|
+
n && !Ie(n) && (n = Ae(n, r), e.name = n), t.set(e.number, e), n && t.set(n, e);
|
|
1623
|
+
},
|
|
1624
|
+
CharacterClassRange({ node: e, parent: r, replaceWith: t }) {
|
|
1625
|
+
if (r.kind === "intersection") {
|
|
1626
|
+
const n = de({ body: [e] });
|
|
1627
|
+
t(C(n, r), { traverse: !0 });
|
|
1628
|
+
}
|
|
1629
|
+
},
|
|
1630
|
+
CharacterSet({ node: e, parent: r, replaceWith: t }, { accuracy: n, minTargetEs2024: s, digitIsAscii: o, spaceIsAscii: a, wordIsAscii: i }) {
|
|
1631
|
+
const { kind: u, negate: c, value: l } = e;
|
|
1632
|
+
if (o && (u === "digit" || l === "digit")) {
|
|
1633
|
+
t(D(Le("digit", { negate: c }), r));
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
if (a && (u === "space" || l === "space")) {
|
|
1637
|
+
t(C(ve(G(Yt), c), r));
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
if (i && (u === "word" || l === "word")) {
|
|
1641
|
+
t(D(Le("word", { negate: c }), r));
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (u === "any")
|
|
1645
|
+
t(D(te("Any"), r));
|
|
1646
|
+
else if (u === "digit")
|
|
1647
|
+
t(D(te("Nd", { negate: c }), r));
|
|
1648
|
+
else if (u !== "dot")
|
|
1649
|
+
if (u === "text_segment") {
|
|
1650
|
+
if (n === "strict")
|
|
1651
|
+
throw new Error(h`Use of "\X" requires non-strict accuracy`);
|
|
1652
|
+
const p = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?", f = h`\p{RI}{2}|${p}(?:\u200D${p})*`;
|
|
1653
|
+
t(C(G(
|
|
1654
|
+
// Close approximation of an extended grapheme cluster; see <unicode.org/reports/tr29/>
|
|
1655
|
+
h`(?>\r\n|${s ? h`\p{RGI_Emoji}` : f}|\P{M}\p{M}*)`,
|
|
1656
|
+
// Allow JS property `RGI_Emoji` through
|
|
1657
|
+
{ skipPropertyNameValidation: !0 }
|
|
1658
|
+
), r));
|
|
1659
|
+
} else if (u === "hex")
|
|
1660
|
+
t(D(te("AHex", { negate: c }), r));
|
|
1661
|
+
else if (u === "newline")
|
|
1662
|
+
t(C(G(c ? `[^
|
|
1663
|
+
]` : `(?>\r
|
|
1664
|
+
?|[
|
|
1665
|
+
\v\f
\u2028\u2029])`), r));
|
|
1666
|
+
else if (u === "posix")
|
|
1667
|
+
if (!s && (l === "graph" || l === "print")) {
|
|
1668
|
+
if (n === "strict")
|
|
1669
|
+
throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);
|
|
1670
|
+
let p = {
|
|
1671
|
+
graph: "!-~",
|
|
1672
|
+
print: " -~"
|
|
1673
|
+
}[l];
|
|
1674
|
+
c && (p = `\0-${b(p.codePointAt(0) - 1)}${b(p.codePointAt(2) + 1)}-`), t(C(G(`[${p}]`), r));
|
|
1675
|
+
} else
|
|
1676
|
+
t(C(ve(G(sn.get(l)), c), r));
|
|
1677
|
+
else if (u === "property")
|
|
1678
|
+
Te.has(me(l)) || (e.key = "sc");
|
|
1679
|
+
else if (u === "space")
|
|
1680
|
+
t(D(te("space", { negate: c }), r));
|
|
1681
|
+
else if (u === "word")
|
|
1682
|
+
t(C(ve(G(F), c), r));
|
|
1683
|
+
else
|
|
1684
|
+
throw new Error(`Unexpected character set kind "${u}"`);
|
|
1685
|
+
},
|
|
1686
|
+
Directive({ node: e, parent: r, root: t, remove: n, replaceWith: s, removeAllPrevSiblings: o, removeAllNextSiblings: a }) {
|
|
1687
|
+
const { kind: i, flags: u } = e;
|
|
1688
|
+
if (i === "flags")
|
|
1689
|
+
if (!u.enable && !u.disable)
|
|
1690
|
+
n();
|
|
1691
|
+
else {
|
|
1692
|
+
const c = L({ flags: u });
|
|
1693
|
+
c.body[0].body = a(), s(C(c, r), { traverse: !0 });
|
|
1694
|
+
}
|
|
1695
|
+
else if (i === "keep") {
|
|
1696
|
+
const c = t.body[0], p = t.body.length === 1 && // Not emulatable if within a `CapturingGroup`
|
|
1697
|
+
wr(c, { type: "Group" }) && c.body[0].body.length === 1 ? c.body[0] : t;
|
|
1698
|
+
if (r.parent !== p || p.body.length > 1)
|
|
1699
|
+
throw new Error(h`Uses "\K" in a way that's unsupported`);
|
|
1700
|
+
const f = W({ behind: !0 });
|
|
1701
|
+
f.body[0].body = o(), s(C(f, r));
|
|
1702
|
+
} else
|
|
1703
|
+
throw new Error(`Unexpected directive kind "${i}"`);
|
|
1704
|
+
},
|
|
1705
|
+
Flags({ node: e, parent: r }) {
|
|
1706
|
+
if (e.posixIsAscii)
|
|
1707
|
+
throw new Error('Unsupported flag "P"');
|
|
1708
|
+
if (e.textSegmentMode === "word")
|
|
1709
|
+
throw new Error('Unsupported flag "y{w}"');
|
|
1710
|
+
[
|
|
1711
|
+
"digitIsAscii",
|
|
1712
|
+
// Flag D
|
|
1713
|
+
"extended",
|
|
1714
|
+
// Flag x
|
|
1715
|
+
"posixIsAscii",
|
|
1716
|
+
// Flag P
|
|
1717
|
+
"spaceIsAscii",
|
|
1718
|
+
// Flag S
|
|
1719
|
+
"wordIsAscii",
|
|
1720
|
+
// Flag W
|
|
1721
|
+
"textSegmentMode"
|
|
1722
|
+
// Flag y{g} or y{w}
|
|
1723
|
+
].forEach((t) => delete e[t]), Object.assign(e, {
|
|
1724
|
+
// JS flag g; no Onig equiv
|
|
1725
|
+
global: !1,
|
|
1726
|
+
// JS flag d; no Onig equiv
|
|
1727
|
+
hasIndices: !1,
|
|
1728
|
+
// JS flag m; no Onig equiv but its behavior is always on in Onig. Onig's only line break
|
|
1729
|
+
// char is line feed, unlike JS, so this flag isn't used since it would produce inaccurate
|
|
1730
|
+
// results (also allows `^` and `$` to be used in the generator for string start and end)
|
|
1731
|
+
multiline: !1,
|
|
1732
|
+
// JS flag y; no Onig equiv, but used for `\G` emulation
|
|
1733
|
+
sticky: e.sticky ?? !1
|
|
1734
|
+
// Note: Regex+ doesn't allow explicitly adding flags it handles implicitly, so leave out
|
|
1735
|
+
// properties `unicode` (JS flag u) and `unicodeSets` (JS flag v). Keep the existing values
|
|
1736
|
+
// for `ignoreCase` (flag i) and `dotAll` (JS flag s, but Onig flag m)
|
|
1737
|
+
}), r.options = {
|
|
1738
|
+
disable: {
|
|
1739
|
+
// Onig uses different rules for flag x than Regex+, so disable the implicit flag
|
|
1740
|
+
x: !0,
|
|
1741
|
+
// Onig has no flag to control "named capture only" mode but contextually applies its
|
|
1742
|
+
// behavior when named capturing is used, so disable Regex+'s implicit flag for it
|
|
1743
|
+
n: !0
|
|
1744
|
+
},
|
|
1745
|
+
force: {
|
|
1746
|
+
// Always add flag v because we're generating an AST that relies on it (it enables JS
|
|
1747
|
+
// support for Onig features nested classes, intersection, Unicode properties, etc.).
|
|
1748
|
+
// However, the generator might disable flag v based on its `target` option
|
|
1749
|
+
v: !0
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
},
|
|
1753
|
+
Group({ node: e }) {
|
|
1754
|
+
if (!e.flags)
|
|
1755
|
+
return;
|
|
1756
|
+
const { enable: r, disable: t } = e.flags;
|
|
1757
|
+
r != null && r.extended && delete r.extended, t != null && t.extended && delete t.extended, r != null && r.dotAll && (t != null && t.dotAll) && delete r.dotAll, r != null && r.ignoreCase && (t != null && t.ignoreCase) && delete r.ignoreCase, r && !Object.keys(r).length && delete e.flags.enable, t && !Object.keys(t).length && delete e.flags.disable, !e.flags.enable && !e.flags.disable && delete e.flags;
|
|
1758
|
+
},
|
|
1759
|
+
LookaroundAssertion({ node: e }, r) {
|
|
1760
|
+
const { kind: t } = e;
|
|
1761
|
+
t === "lookbehind" && (r.passedLookbehind = !0);
|
|
1762
|
+
},
|
|
1763
|
+
NamedCallout({ node: e, parent: r, replaceWith: t }) {
|
|
1764
|
+
const { kind: n } = e;
|
|
1765
|
+
if (n === "fail")
|
|
1766
|
+
t(C(W({ negate: !0 }), r));
|
|
1767
|
+
else
|
|
1768
|
+
throw new Error(`Unsupported named callout "(*${n.toUpperCase()}"`);
|
|
1769
|
+
},
|
|
1770
|
+
Quantifier({ node: e }) {
|
|
1771
|
+
if (e.body.type === "Quantifier") {
|
|
1772
|
+
const r = L();
|
|
1773
|
+
r.body[0].body.push(e.body), e.body = C(r, e);
|
|
1774
|
+
}
|
|
1775
|
+
},
|
|
1776
|
+
Regex: {
|
|
1777
|
+
enter({ node: e }, { supportedGNodes: r }) {
|
|
1778
|
+
const t = [];
|
|
1779
|
+
let n = !1, s = !1;
|
|
1780
|
+
for (const o of e.body)
|
|
1781
|
+
if (o.body.length === 1 && o.body[0].kind === "search_start")
|
|
1782
|
+
o.body.pop();
|
|
1783
|
+
else {
|
|
1784
|
+
const a = Fr(o.body);
|
|
1785
|
+
a ? (n = !0, Array.isArray(a) ? t.push(...a) : t.push(a)) : s = !0;
|
|
1786
|
+
}
|
|
1787
|
+
n && !s && t.forEach((o) => r.add(o));
|
|
1788
|
+
},
|
|
1789
|
+
exit(e, { accuracy: r, passedLookbehind: t, strategy: n }) {
|
|
1790
|
+
if (r === "strict" && t && n)
|
|
1791
|
+
throw new Error(h`Uses "\G" in a way that requires non-strict accuracy`);
|
|
1792
|
+
}
|
|
1793
|
+
},
|
|
1794
|
+
Subroutine({ node: e }, { jsGroupNameMap: r }) {
|
|
1795
|
+
let { ref: t } = e;
|
|
1796
|
+
typeof t == "string" && !Ie(t) && (t = Ae(t, r), e.ref = t);
|
|
1797
|
+
}
|
|
1798
|
+
}, cn = {
|
|
1799
|
+
Backreference({ node: e }, { multiplexCapturesToLeftByRef: r, reffedNodesByReferencer: t }) {
|
|
1800
|
+
const { orphan: n, ref: s } = e;
|
|
1801
|
+
n || t.set(e, [...r.get(s).map(({ node: o }) => o)]);
|
|
1802
|
+
},
|
|
1803
|
+
CapturingGroup: {
|
|
1804
|
+
enter({
|
|
1805
|
+
node: e,
|
|
1806
|
+
parent: r,
|
|
1807
|
+
replaceWith: t,
|
|
1808
|
+
skip: n
|
|
1809
|
+
}, {
|
|
1810
|
+
groupOriginByCopy: s,
|
|
1811
|
+
groupsByName: o,
|
|
1812
|
+
multiplexCapturesToLeftByRef: a,
|
|
1813
|
+
openRefs: i,
|
|
1814
|
+
reffedNodesByReferencer: u
|
|
1815
|
+
}) {
|
|
1816
|
+
const c = s.get(e);
|
|
1817
|
+
if (c && i.has(e.number)) {
|
|
1818
|
+
const p = D(or(e.number), r);
|
|
1819
|
+
u.set(p, i.get(e.number)), t(p);
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
i.set(e.number, e), a.set(e.number, []), e.name && ie(a, e.name, []);
|
|
1823
|
+
const l = a.get(e.name ?? e.number);
|
|
1824
|
+
for (let p = 0; p < l.length; p++) {
|
|
1825
|
+
const f = l[p];
|
|
1826
|
+
if (
|
|
1827
|
+
// This group is from subroutine expansion, and there's a multiplex value from either the
|
|
1828
|
+
// origin node or a prior subroutine expansion group with the same origin
|
|
1829
|
+
c === f.node || c && c === f.origin || // This group is not from subroutine expansion, and it comes after a subroutine expansion
|
|
1830
|
+
// group that refers to this group
|
|
1831
|
+
e === f.origin
|
|
1832
|
+
) {
|
|
1833
|
+
l.splice(p, 1);
|
|
1834
|
+
break;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
if (a.get(e.number).push({ node: e, origin: c }), e.name && a.get(e.name).push({ node: e, origin: c }), e.name) {
|
|
1838
|
+
const p = ie(o, e.name, /* @__PURE__ */ new Map());
|
|
1839
|
+
let f = !1;
|
|
1840
|
+
if (c)
|
|
1841
|
+
f = !0;
|
|
1842
|
+
else
|
|
1843
|
+
for (const g of p.values())
|
|
1844
|
+
if (!g.hasDuplicateNameToRemove) {
|
|
1845
|
+
f = !0;
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
o.get(e.name).set(e, { node: e, hasDuplicateNameToRemove: f });
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
exit({ node: e }, { openRefs: r }) {
|
|
1852
|
+
r.delete(e.number);
|
|
1853
|
+
}
|
|
1854
|
+
},
|
|
1855
|
+
Group: {
|
|
1856
|
+
enter({ node: e }, r) {
|
|
1857
|
+
r.prevFlags = r.currentFlags, e.flags && (r.currentFlags = ge(r.currentFlags, e.flags));
|
|
1858
|
+
},
|
|
1859
|
+
exit(e, r) {
|
|
1860
|
+
r.currentFlags = r.prevFlags;
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
Subroutine({ node: e, parent: r, replaceWith: t }, n) {
|
|
1864
|
+
const { isRecursive: s, ref: o } = e;
|
|
1865
|
+
if (s) {
|
|
1866
|
+
let l = r;
|
|
1867
|
+
for (; (l = l.parent) && !(l.type === "CapturingGroup" && (l.name === o || l.number === o)); )
|
|
1868
|
+
;
|
|
1869
|
+
n.reffedNodesByReferencer.set(e, l);
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
const a = n.subroutineRefMap.get(o), i = o === 0, u = i ? or(0) : (
|
|
1873
|
+
// The reffed group might itself contain subroutines, which are expanded during sub-traversal
|
|
1874
|
+
Nr(a, n.groupOriginByCopy, null)
|
|
1875
|
+
);
|
|
1876
|
+
let c = u;
|
|
1877
|
+
if (!i) {
|
|
1878
|
+
const l = Mr(dn(
|
|
1879
|
+
a,
|
|
1880
|
+
(f) => f.type === "Group" && !!f.flags
|
|
1881
|
+
)), p = l ? ge(n.globalFlags, l) : n.globalFlags;
|
|
1882
|
+
pn(p, n.currentFlags) || (c = L({
|
|
1883
|
+
flags: gn(p)
|
|
1884
|
+
}), c.body[0].body.push(u));
|
|
1885
|
+
}
|
|
1886
|
+
t(C(c, r), { traverse: !i });
|
|
1887
|
+
}
|
|
1888
|
+
}, ln = {
|
|
1889
|
+
Backreference({ node: e, parent: r, replaceWith: t }, n) {
|
|
1890
|
+
if (e.orphan) {
|
|
1891
|
+
n.highestOrphanBackref = Math.max(n.highestOrphanBackref, e.ref);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const o = n.reffedNodesByReferencer.get(e).filter((a) => fn(a, e));
|
|
1895
|
+
if (!o.length)
|
|
1896
|
+
t(C(W({ negate: !0 }), r));
|
|
1897
|
+
else if (o.length > 1) {
|
|
1898
|
+
const a = L({
|
|
1899
|
+
atomic: !0,
|
|
1900
|
+
body: o.reverse().map((i) => q({
|
|
1901
|
+
body: [Me(i.number)]
|
|
1902
|
+
}))
|
|
1903
|
+
});
|
|
1904
|
+
t(C(a, r));
|
|
1905
|
+
} else
|
|
1906
|
+
e.ref = o[0].number;
|
|
1907
|
+
},
|
|
1908
|
+
CapturingGroup({ node: e }, r) {
|
|
1909
|
+
e.number = ++r.numCapturesToLeft, e.name && r.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove && delete e.name;
|
|
1910
|
+
},
|
|
1911
|
+
Regex: {
|
|
1912
|
+
exit({ node: e }, r) {
|
|
1913
|
+
const t = Math.max(r.highestOrphanBackref - r.numCapturesToLeft, 0);
|
|
1914
|
+
for (let n = 0; n < t; n++) {
|
|
1915
|
+
const s = Cr();
|
|
1916
|
+
e.body.at(-1).body.push(s);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
},
|
|
1920
|
+
Subroutine({ node: e }, r) {
|
|
1921
|
+
!e.isRecursive || e.ref === 0 || (e.ref = r.reffedNodesByReferencer.get(e).number);
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
function _r(e) {
|
|
1925
|
+
ae(e, {
|
|
1926
|
+
"*"({ node: r, parent: t }) {
|
|
1927
|
+
r.parent = t;
|
|
1928
|
+
}
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
function pn(e, r) {
|
|
1932
|
+
return e.dotAll === r.dotAll && e.ignoreCase === r.ignoreCase;
|
|
1933
|
+
}
|
|
1934
|
+
function fn(e, r) {
|
|
1935
|
+
let t = r;
|
|
1936
|
+
do {
|
|
1937
|
+
if (t.type === "Regex")
|
|
1938
|
+
return !1;
|
|
1939
|
+
if (t.type === "Alternative")
|
|
1940
|
+
continue;
|
|
1941
|
+
if (t === e)
|
|
1942
|
+
return !1;
|
|
1943
|
+
const n = Lr(t.parent);
|
|
1944
|
+
for (const s of n) {
|
|
1945
|
+
if (s === t)
|
|
1946
|
+
break;
|
|
1947
|
+
if (s === e || Gr(s, e))
|
|
1948
|
+
return !0;
|
|
1949
|
+
}
|
|
1950
|
+
} while (t = t.parent);
|
|
1951
|
+
throw new Error("Unexpected path");
|
|
1952
|
+
}
|
|
1953
|
+
function Nr(e, r, t, n) {
|
|
1954
|
+
const s = Array.isArray(e) ? [] : {};
|
|
1955
|
+
for (const [o, a] of Object.entries(e))
|
|
1956
|
+
o === "parent" ? s.parent = Array.isArray(t) ? n : t : a && typeof a == "object" ? s[o] = Nr(a, r, s, t) : (o === "type" && a === "CapturingGroup" && r.set(s, r.get(e) ?? e), s[o] = a);
|
|
1957
|
+
return s;
|
|
1958
|
+
}
|
|
1959
|
+
function or(e) {
|
|
1960
|
+
const r = xr(e);
|
|
1961
|
+
return r.isRecursive = !0, r;
|
|
1962
|
+
}
|
|
1963
|
+
function dn(e, r) {
|
|
1964
|
+
const t = [];
|
|
1965
|
+
for (; e = e.parent; )
|
|
1966
|
+
(!r || r(e)) && t.push(e);
|
|
1967
|
+
return t;
|
|
1968
|
+
}
|
|
1969
|
+
function Ae(e, r) {
|
|
1970
|
+
if (r.has(e))
|
|
1971
|
+
return r.get(e);
|
|
1972
|
+
const t = `$${r.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug, "_")}`;
|
|
1973
|
+
return r.set(e, t), t;
|
|
1974
|
+
}
|
|
1975
|
+
function Mr(e) {
|
|
1976
|
+
const r = ["dotAll", "ignoreCase"], t = { enable: {}, disable: {} };
|
|
1977
|
+
return e.forEach(({ flags: n }) => {
|
|
1978
|
+
r.forEach((s) => {
|
|
1979
|
+
var o, a;
|
|
1980
|
+
(o = n.enable) != null && o[s] && (delete t.disable[s], t.enable[s] = !0), (a = n.disable) != null && a[s] && (t.disable[s] = !0);
|
|
1981
|
+
});
|
|
1982
|
+
}), Object.keys(t.enable).length || delete t.enable, Object.keys(t.disable).length || delete t.disable, t.enable || t.disable ? t : null;
|
|
1983
|
+
}
|
|
1984
|
+
function gn({ dotAll: e, ignoreCase: r }) {
|
|
1985
|
+
const t = {};
|
|
1986
|
+
return (e || r) && (t.enable = {}, e && (t.enable.dotAll = !0), r && (t.enable.ignoreCase = !0)), (!e || !r) && (t.disable = {}, !e && (t.disable.dotAll = !0), !r && (t.disable.ignoreCase = !0)), t;
|
|
1987
|
+
}
|
|
1988
|
+
function Lr(e) {
|
|
1989
|
+
if (!e)
|
|
1990
|
+
throw new Error("Node expected");
|
|
1991
|
+
const { body: r } = e;
|
|
1992
|
+
return Array.isArray(r) ? r : r ? [r] : null;
|
|
1993
|
+
}
|
|
1994
|
+
function Fr(e) {
|
|
1995
|
+
const r = e.find((t) => t.kind === "search_start" || wn(t, { negate: !1 }) || !hn(t));
|
|
1996
|
+
if (!r)
|
|
1997
|
+
return null;
|
|
1998
|
+
if (r.kind === "search_start")
|
|
1999
|
+
return r;
|
|
2000
|
+
if (r.type === "LookaroundAssertion")
|
|
2001
|
+
return r.body[0].body[0];
|
|
2002
|
+
if (r.type === "CapturingGroup" || r.type === "Group") {
|
|
2003
|
+
const t = [];
|
|
2004
|
+
for (const n of r.body) {
|
|
2005
|
+
const s = Fr(n.body);
|
|
2006
|
+
if (!s)
|
|
2007
|
+
return null;
|
|
2008
|
+
Array.isArray(s) ? t.push(...s) : t.push(s);
|
|
2009
|
+
}
|
|
2010
|
+
return t;
|
|
2011
|
+
}
|
|
2012
|
+
return null;
|
|
2013
|
+
}
|
|
2014
|
+
function Gr(e, r) {
|
|
2015
|
+
const t = Lr(e) ?? [];
|
|
2016
|
+
for (const n of t)
|
|
2017
|
+
if (n === r || Gr(n, r))
|
|
2018
|
+
return !0;
|
|
2019
|
+
return !1;
|
|
2020
|
+
}
|
|
2021
|
+
function hn({ type: e }) {
|
|
2022
|
+
return e === "Assertion" || e === "Directive" || e === "LookaroundAssertion";
|
|
2023
|
+
}
|
|
2024
|
+
function mn(e) {
|
|
2025
|
+
const r = [
|
|
2026
|
+
"Character",
|
|
2027
|
+
"CharacterClass",
|
|
2028
|
+
"CharacterSet"
|
|
2029
|
+
];
|
|
2030
|
+
return r.includes(e.type) || e.type === "Quantifier" && e.min && r.includes(e.body.type);
|
|
2031
|
+
}
|
|
2032
|
+
function wn(e, r) {
|
|
2033
|
+
const t = {
|
|
2034
|
+
negate: null,
|
|
2035
|
+
...r
|
|
2036
|
+
};
|
|
2037
|
+
return e.type === "LookaroundAssertion" && (t.negate === null || e.negate === t.negate) && e.body.length === 1 && wr(e.body[0], {
|
|
2038
|
+
type: "Assertion",
|
|
2039
|
+
kind: "search_start"
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
function Ie(e) {
|
|
2043
|
+
return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e);
|
|
2044
|
+
}
|
|
2045
|
+
function G(e, r) {
|
|
2046
|
+
const n = yr(e, {
|
|
2047
|
+
...r,
|
|
2048
|
+
// Providing a custom set of Unicode property names avoids converting some JS Unicode
|
|
2049
|
+
// properties (ex: `\p{Alpha}`) to Onig POSIX classes
|
|
2050
|
+
unicodePropertyMap: Te
|
|
2051
|
+
}).body;
|
|
2052
|
+
return n.length > 1 || n[0].body.length > 1 ? L({ body: n }) : n[0].body[0];
|
|
2053
|
+
}
|
|
2054
|
+
function ve(e, r) {
|
|
2055
|
+
return e.negate = r, e;
|
|
2056
|
+
}
|
|
2057
|
+
function D(e, r) {
|
|
2058
|
+
return e.parent = r, e;
|
|
2059
|
+
}
|
|
2060
|
+
function C(e, r) {
|
|
2061
|
+
return _r(e), e.parent = r, e;
|
|
2062
|
+
}
|
|
2063
|
+
function yn(e, r) {
|
|
2064
|
+
const t = Ir(r), n = Ge(t.target, "ES2024"), s = Ge(t.target, "ES2025"), o = t.rules.recursionLimit;
|
|
2065
|
+
if (!Number.isInteger(o) || o < 2 || o > 20)
|
|
2066
|
+
throw new Error("Invalid recursionLimit; use 2-20");
|
|
2067
|
+
let a = null, i = null;
|
|
2068
|
+
if (!s) {
|
|
2069
|
+
const g = [e.flags.ignoreCase];
|
|
2070
|
+
ae(e, Cn, {
|
|
2071
|
+
getCurrentModI: () => g.at(-1),
|
|
2072
|
+
popModI() {
|
|
2073
|
+
g.pop();
|
|
2074
|
+
},
|
|
2075
|
+
pushModI(d) {
|
|
2076
|
+
g.push(d);
|
|
2077
|
+
},
|
|
2078
|
+
setHasCasedChar() {
|
|
2079
|
+
g.at(-1) ? a = !0 : i = !0;
|
|
2080
|
+
}
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
const u = {
|
|
2084
|
+
dotAll: e.flags.dotAll,
|
|
2085
|
+
// - Turn global flag i on if a case insensitive node was used and no case sensitive nodes were
|
|
2086
|
+
// used (to avoid unnecessary node expansion).
|
|
2087
|
+
// - Turn global flag i off if a case sensitive node was used (since case sensitivity can't be
|
|
2088
|
+
// forced without the use of ES2025 flag groups)
|
|
2089
|
+
ignoreCase: !!((e.flags.ignoreCase || a) && !i)
|
|
2090
|
+
};
|
|
2091
|
+
let c = e;
|
|
2092
|
+
const l = {
|
|
2093
|
+
accuracy: t.accuracy,
|
|
2094
|
+
appliedGlobalFlags: u,
|
|
2095
|
+
captureMap: /* @__PURE__ */ new Map(),
|
|
2096
|
+
currentFlags: {
|
|
2097
|
+
dotAll: e.flags.dotAll,
|
|
2098
|
+
ignoreCase: e.flags.ignoreCase
|
|
2099
|
+
},
|
|
2100
|
+
inCharClass: !1,
|
|
2101
|
+
lastNode: c,
|
|
2102
|
+
originMap: e._originMap,
|
|
2103
|
+
recursionLimit: o,
|
|
2104
|
+
useAppliedIgnoreCase: !!(!s && a && i),
|
|
2105
|
+
useFlagMods: s,
|
|
2106
|
+
useFlagV: n,
|
|
2107
|
+
verbose: t.verbose
|
|
2108
|
+
};
|
|
2109
|
+
function p(g) {
|
|
2110
|
+
return l.lastNode = c, c = g, Jt(bn[g.type], `Unexpected node type "${g.type}"`)(g, l, p);
|
|
2111
|
+
}
|
|
2112
|
+
const f = {
|
|
2113
|
+
pattern: e.body.map(p).join("|"),
|
|
2114
|
+
// Could reset `lastNode` at this point via `lastNode = ast`, but it isn't needed by flags
|
|
2115
|
+
flags: p(e.flags),
|
|
2116
|
+
options: { ...e.options }
|
|
2117
|
+
};
|
|
2118
|
+
return n || (delete f.options.force.v, f.options.disable.v = !0, f.options.unicodeSetsPlugin = null), f._captureTransfers = /* @__PURE__ */ new Map(), f._hiddenCaptures = [], l.captureMap.forEach((g, d) => {
|
|
2119
|
+
g.hidden && f._hiddenCaptures.push(d), g.transferTo && ie(f._captureTransfers, g.transferTo, []).push(d);
|
|
2120
|
+
}), f;
|
|
2121
|
+
}
|
|
2122
|
+
var Cn = {
|
|
2123
|
+
"*": {
|
|
2124
|
+
enter({ node: e }, r) {
|
|
2125
|
+
if (ir(e)) {
|
|
2126
|
+
const t = r.getCurrentModI();
|
|
2127
|
+
r.pushModI(
|
|
2128
|
+
e.flags ? ge({ ignoreCase: t }, e.flags).ignoreCase : t
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
},
|
|
2132
|
+
exit({ node: e }, r) {
|
|
2133
|
+
ir(e) && r.popModI();
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
Backreference(e, r) {
|
|
2137
|
+
r.setHasCasedChar();
|
|
2138
|
+
},
|
|
2139
|
+
Character({ node: e }, r) {
|
|
2140
|
+
Be(b(e.value)) && r.setHasCasedChar();
|
|
2141
|
+
},
|
|
2142
|
+
CharacterClassRange({ node: e, skip: r }, t) {
|
|
2143
|
+
r(), Pr(e, { firstOnly: !0 }).length && t.setHasCasedChar();
|
|
2144
|
+
},
|
|
2145
|
+
CharacterSet({ node: e }, r) {
|
|
2146
|
+
e.kind === "property" && Sr.has(e.value) && r.setHasCasedChar();
|
|
2147
|
+
}
|
|
2148
|
+
}, bn = {
|
|
2149
|
+
/**
|
|
2150
|
+
@param {AlternativeNode} node
|
|
2151
|
+
*/
|
|
2152
|
+
Alternative({ body: e }, r, t) {
|
|
2153
|
+
return e.map(t).join("");
|
|
2154
|
+
},
|
|
2155
|
+
/**
|
|
2156
|
+
@param {AssertionNode} node
|
|
2157
|
+
*/
|
|
2158
|
+
Assertion({ kind: e, negate: r }) {
|
|
2159
|
+
if (e === "string_end")
|
|
2160
|
+
return "$";
|
|
2161
|
+
if (e === "string_start")
|
|
2162
|
+
return "^";
|
|
2163
|
+
if (e === "word_boundary")
|
|
2164
|
+
return r ? h`\B` : h`\b`;
|
|
2165
|
+
throw new Error(`Unexpected assertion kind "${e}"`);
|
|
2166
|
+
},
|
|
2167
|
+
/**
|
|
2168
|
+
@param {BackreferenceNode} node
|
|
2169
|
+
*/
|
|
2170
|
+
Backreference({ ref: e }, r) {
|
|
2171
|
+
if (typeof e != "number")
|
|
2172
|
+
throw new Error("Unexpected named backref in transformed AST");
|
|
2173
|
+
if (!r.useFlagMods && r.accuracy === "strict" && r.currentFlags.ignoreCase && !r.captureMap.get(e).ignoreCase)
|
|
2174
|
+
throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
|
|
2175
|
+
return "\\" + e;
|
|
2176
|
+
},
|
|
2177
|
+
/**
|
|
2178
|
+
@param {CapturingGroupNode} node
|
|
2179
|
+
*/
|
|
2180
|
+
CapturingGroup(e, r, t) {
|
|
2181
|
+
const { body: n, name: s, number: o } = e, a = { ignoreCase: r.currentFlags.ignoreCase }, i = r.originMap.get(e);
|
|
2182
|
+
return i && (a.hidden = !0, o > i.number && (a.transferTo = i.number)), r.captureMap.set(o, a), `(${s ? `?<${s}>` : ""}${n.map(t).join("|")})`;
|
|
2183
|
+
},
|
|
2184
|
+
/**
|
|
2185
|
+
@param {CharacterNode} node
|
|
2186
|
+
*/
|
|
2187
|
+
Character({ value: e }, r) {
|
|
2188
|
+
const t = b(e), n = Y(e, {
|
|
2189
|
+
escDigit: r.lastNode.type === "Backreference",
|
|
2190
|
+
inCharClass: r.inCharClass,
|
|
2191
|
+
useFlagV: r.useFlagV
|
|
2192
|
+
});
|
|
2193
|
+
if (n !== t)
|
|
2194
|
+
return n;
|
|
2195
|
+
if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase && Be(t)) {
|
|
2196
|
+
const s = vr(t);
|
|
2197
|
+
return r.inCharClass ? s.join("") : s.length > 1 ? `[${s.join("")}]` : s[0];
|
|
2198
|
+
}
|
|
2199
|
+
return t;
|
|
2200
|
+
},
|
|
2201
|
+
/**
|
|
2202
|
+
@param {CharacterClassNode} node
|
|
2203
|
+
*/
|
|
2204
|
+
CharacterClass(e, r, t) {
|
|
2205
|
+
const { kind: n, negate: s, parent: o } = e;
|
|
2206
|
+
let { body: a } = e;
|
|
2207
|
+
if (n === "intersection" && !r.useFlagV)
|
|
2208
|
+
throw new Error("Use of character class intersection requires min target ES2024");
|
|
2209
|
+
U.bugFlagVLiteralHyphenIsRange && r.useFlagV && a.some(ur) && (a = [he(45), ...a.filter((c) => !ur(c))]);
|
|
2210
|
+
const i = () => `[${s ? "^" : ""}${a.map(t).join(n === "intersection" ? "&&" : "")}]`;
|
|
2211
|
+
if (!r.inCharClass) {
|
|
2212
|
+
if (
|
|
2213
|
+
// Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
|
|
2214
|
+
(!r.useFlagV || U.bugNestedClassIgnoresNegation) && !s
|
|
2215
|
+
) {
|
|
2216
|
+
const l = a.filter(
|
|
2217
|
+
(p) => p.type === "CharacterClass" && p.kind === "union" && p.negate
|
|
2218
|
+
);
|
|
2219
|
+
if (l.length) {
|
|
2220
|
+
const p = L(), f = p.body[0];
|
|
2221
|
+
return p.parent = o, f.parent = p, a = a.filter((g) => !l.includes(g)), e.body = a, a.length ? (e.parent = f, f.body.push(e)) : p.body.pop(), l.forEach((g) => {
|
|
2222
|
+
const d = q({ body: [g] });
|
|
2223
|
+
g.parent = d, d.parent = p, p.body.push(d);
|
|
2224
|
+
}), t(p);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
r.inCharClass = !0;
|
|
2228
|
+
const c = i();
|
|
2229
|
+
return r.inCharClass = !1, c;
|
|
2230
|
+
}
|
|
2231
|
+
const u = a[0];
|
|
2232
|
+
if (
|
|
2233
|
+
// Already established that the parent is a char class via `inCharClass`; don't check again
|
|
2234
|
+
n === "union" && !s && u && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
|
|
2235
|
+
((!r.useFlagV || !r.verbose) && o.kind === "union" && !(U.bugFlagVLiteralHyphenIsRange && r.useFlagV) || !r.verbose && o.kind === "intersection" && // JS doesn't allow intersection with union or ranges
|
|
2236
|
+
a.length === 1 && u.type !== "CharacterClassRange")
|
|
2237
|
+
)
|
|
2238
|
+
return a.map(t).join("");
|
|
2239
|
+
if (!r.useFlagV && o.type === "CharacterClass")
|
|
2240
|
+
throw new Error("Uses nested character class in a way that requires min target ES2024");
|
|
2241
|
+
return i();
|
|
2242
|
+
},
|
|
2243
|
+
/**
|
|
2244
|
+
@param {CharacterClassRangeNode} node
|
|
2245
|
+
*/
|
|
2246
|
+
CharacterClassRange(e, r) {
|
|
2247
|
+
const t = e.min.value, n = e.max.value, s = {
|
|
2248
|
+
escDigit: !1,
|
|
2249
|
+
inCharClass: !0,
|
|
2250
|
+
useFlagV: r.useFlagV
|
|
2251
|
+
}, o = Y(t, s), a = Y(n, s), i = /* @__PURE__ */ new Set();
|
|
2252
|
+
if (r.useAppliedIgnoreCase && r.currentFlags.ignoreCase) {
|
|
2253
|
+
const u = Pr(e);
|
|
2254
|
+
An(u).forEach((l) => {
|
|
2255
|
+
i.add(
|
|
2256
|
+
Array.isArray(l) ? `${Y(l[0], s)}-${Y(l[1], s)}` : Y(l, s)
|
|
2257
|
+
);
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
return `${o}-${a}${[...i].join("")}`;
|
|
2261
|
+
},
|
|
2262
|
+
/**
|
|
2263
|
+
@param {CharacterSetNode} node
|
|
2264
|
+
*/
|
|
2265
|
+
CharacterSet({ kind: e, negate: r, value: t, key: n }, s) {
|
|
2266
|
+
if (e === "dot")
|
|
2267
|
+
return s.currentFlags.dotAll ? s.appliedGlobalFlags.dotAll || s.useFlagMods ? "." : "[^]" : (
|
|
2268
|
+
// Onig's only line break char is line feed, unlike JS
|
|
2269
|
+
h`[^\n]`
|
|
2270
|
+
);
|
|
2271
|
+
if (e === "digit")
|
|
2272
|
+
return r ? h`\D` : h`\d`;
|
|
2273
|
+
if (e === "property") {
|
|
2274
|
+
if (s.useAppliedIgnoreCase && s.currentFlags.ignoreCase && Sr.has(t))
|
|
2275
|
+
throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);
|
|
2276
|
+
return `${r ? h`\P` : h`\p`}{${n ? `${n}=` : ""}${t}}`;
|
|
2277
|
+
}
|
|
2278
|
+
if (e === "word")
|
|
2279
|
+
return r ? h`\W` : h`\w`;
|
|
2280
|
+
throw new Error(`Unexpected character set kind "${e}"`);
|
|
2281
|
+
},
|
|
2282
|
+
/**
|
|
2283
|
+
@param {FlagsNode} node
|
|
2284
|
+
*/
|
|
2285
|
+
Flags(e, r) {
|
|
2286
|
+
return (
|
|
2287
|
+
// The transformer should never turn on the properties for flags d, g, m since Onig doesn't
|
|
2288
|
+
// have equivs. Flag m is never used since Onig uses different line break chars than JS
|
|
2289
|
+
// (node.hasIndices ? 'd' : '') +
|
|
2290
|
+
// (node.global ? 'g' : '') +
|
|
2291
|
+
// (node.multiline ? 'm' : '') +
|
|
2292
|
+
(r.appliedGlobalFlags.ignoreCase ? "i" : "") + (e.dotAll ? "s" : "") + (e.sticky ? "y" : "")
|
|
2293
|
+
);
|
|
2294
|
+
},
|
|
2295
|
+
/**
|
|
2296
|
+
@param {GroupNode} node
|
|
2297
|
+
*/
|
|
2298
|
+
Group({ atomic: e, body: r, flags: t, parent: n }, s, o) {
|
|
2299
|
+
const a = s.currentFlags;
|
|
2300
|
+
t && (s.currentFlags = ge(a, t));
|
|
2301
|
+
const i = r.map(o).join("|"), u = !s.verbose && r.length === 1 && // Single alt
|
|
2302
|
+
n.type !== "Quantifier" && !e && (!s.useFlagMods || !t) ? i : `(?${In(e, t, s.useFlagMods)}${i})`;
|
|
2303
|
+
return s.currentFlags = a, u;
|
|
2304
|
+
},
|
|
2305
|
+
/**
|
|
2306
|
+
@param {LookaroundAssertionNode} node
|
|
2307
|
+
*/
|
|
2308
|
+
LookaroundAssertion({ body: e, kind: r, negate: t }, n, s) {
|
|
2309
|
+
return `(?${`${r === "lookahead" ? "" : "<"}${t ? "!" : "="}`}${e.map(s).join("|")})`;
|
|
2310
|
+
},
|
|
2311
|
+
/**
|
|
2312
|
+
@param {QuantifierNode} node
|
|
2313
|
+
*/
|
|
2314
|
+
Quantifier(e, r, t) {
|
|
2315
|
+
return t(e.body) + vn(e);
|
|
2316
|
+
},
|
|
2317
|
+
/**
|
|
2318
|
+
@param {SubroutineNode & {isRecursive: true}} node
|
|
2319
|
+
*/
|
|
2320
|
+
Subroutine({ isRecursive: e, ref: r }, t) {
|
|
2321
|
+
if (!e)
|
|
2322
|
+
throw new Error("Unexpected non-recursive subroutine in transformed AST");
|
|
2323
|
+
const n = t.recursionLimit;
|
|
2324
|
+
return r === 0 ? `(?R=${n})` : h`\g<${r}&R=${n}>`;
|
|
2325
|
+
}
|
|
2326
|
+
}, xn = /* @__PURE__ */ new Set([
|
|
2327
|
+
"$",
|
|
2328
|
+
"(",
|
|
2329
|
+
")",
|
|
2330
|
+
"*",
|
|
2331
|
+
"+",
|
|
2332
|
+
".",
|
|
2333
|
+
"?",
|
|
2334
|
+
"[",
|
|
2335
|
+
"\\",
|
|
2336
|
+
"]",
|
|
2337
|
+
"^",
|
|
2338
|
+
"{",
|
|
2339
|
+
"|",
|
|
2340
|
+
"}"
|
|
2341
|
+
]), kn = /* @__PURE__ */ new Set([
|
|
2342
|
+
"-",
|
|
2343
|
+
"\\",
|
|
2344
|
+
"]",
|
|
2345
|
+
"^",
|
|
2346
|
+
// Literal `[` doesn't require escaping with flag u, but this can help work around regex source
|
|
2347
|
+
// linters and regex syntax processors that expect unescaped `[` to create a nested class
|
|
2348
|
+
"["
|
|
2349
|
+
]), $n = /* @__PURE__ */ new Set([
|
|
2350
|
+
"(",
|
|
2351
|
+
")",
|
|
2352
|
+
"-",
|
|
2353
|
+
"/",
|
|
2354
|
+
"[",
|
|
2355
|
+
"\\",
|
|
2356
|
+
"]",
|
|
2357
|
+
"^",
|
|
2358
|
+
"{",
|
|
2359
|
+
"|",
|
|
2360
|
+
"}",
|
|
2361
|
+
// Double punctuators; also includes already-listed `-` and `^`
|
|
2362
|
+
"!",
|
|
2363
|
+
"#",
|
|
2364
|
+
"$",
|
|
2365
|
+
"%",
|
|
2366
|
+
"&",
|
|
2367
|
+
"*",
|
|
2368
|
+
"+",
|
|
2369
|
+
",",
|
|
2370
|
+
".",
|
|
2371
|
+
":",
|
|
2372
|
+
";",
|
|
2373
|
+
"<",
|
|
2374
|
+
"=",
|
|
2375
|
+
">",
|
|
2376
|
+
"?",
|
|
2377
|
+
"@",
|
|
2378
|
+
"`",
|
|
2379
|
+
"~"
|
|
2380
|
+
]), ar = /* @__PURE__ */ new Map([
|
|
2381
|
+
[9, h`\t`],
|
|
2382
|
+
// horizontal tab
|
|
2383
|
+
[10, h`\n`],
|
|
2384
|
+
// line feed
|
|
2385
|
+
[11, h`\v`],
|
|
2386
|
+
// vertical tab
|
|
2387
|
+
[12, h`\f`],
|
|
2388
|
+
// form feed
|
|
2389
|
+
[13, h`\r`],
|
|
2390
|
+
// carriage return
|
|
2391
|
+
[8232, h`\u2028`],
|
|
2392
|
+
// line separator
|
|
2393
|
+
[8233, h`\u2029`],
|
|
2394
|
+
// paragraph separator
|
|
2395
|
+
[65279, h`\uFEFF`]
|
|
2396
|
+
// ZWNBSP/BOM
|
|
2397
|
+
]), En = new RegExp("^\\p{Cased}$", "u");
|
|
2398
|
+
function Be(e) {
|
|
2399
|
+
return En.test(e);
|
|
2400
|
+
}
|
|
2401
|
+
function Pr(e, r) {
|
|
2402
|
+
const t = !!(r != null && r.firstOnly), n = e.min.value, s = e.max.value, o = [];
|
|
2403
|
+
if (n < 65 && (s === 65535 || s >= 131071) || n === 65536 && s >= 131071)
|
|
2404
|
+
return o;
|
|
2405
|
+
for (let a = n; a <= s; a++) {
|
|
2406
|
+
const i = b(a);
|
|
2407
|
+
if (!Be(i))
|
|
2408
|
+
continue;
|
|
2409
|
+
const u = vr(i).filter((c) => {
|
|
2410
|
+
const l = c.codePointAt(0);
|
|
2411
|
+
return l < n || l > s;
|
|
2412
|
+
});
|
|
2413
|
+
if (u.length && (o.push(...u), t))
|
|
2414
|
+
break;
|
|
2415
|
+
}
|
|
2416
|
+
return o;
|
|
2417
|
+
}
|
|
2418
|
+
function Y(e, { escDigit: r, inCharClass: t, useFlagV: n }) {
|
|
2419
|
+
if (ar.has(e))
|
|
2420
|
+
return ar.get(e);
|
|
2421
|
+
if (
|
|
2422
|
+
// Control chars, etc.; condition modeled on the Chrome developer console's display for strings
|
|
2423
|
+
e < 32 || e > 126 && e < 160 || // Unicode planes 4-16; unassigned, special purpose, and private use area
|
|
2424
|
+
e > 262143 || // Avoid corrupting a preceding backref by immediately following it with a literal digit
|
|
2425
|
+
r && Sn(e)
|
|
2426
|
+
)
|
|
2427
|
+
return e > 255 ? `\\u{${e.toString(16).toUpperCase()}}` : `\\x${e.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
2428
|
+
const s = t ? n ? $n : kn : xn, o = b(e);
|
|
2429
|
+
return (s.has(o) ? "\\" : "") + o;
|
|
2430
|
+
}
|
|
2431
|
+
function An(e) {
|
|
2432
|
+
const r = e.map((s) => s.codePointAt(0)).sort((s, o) => s - o), t = [];
|
|
2433
|
+
let n = null;
|
|
2434
|
+
for (let s = 0; s < r.length; s++)
|
|
2435
|
+
r[s + 1] === r[s] + 1 ? n ?? (n = r[s]) : n === null ? t.push(r[s]) : (t.push([n, r[s]]), n = null);
|
|
2436
|
+
return t;
|
|
2437
|
+
}
|
|
2438
|
+
function In(e, r, t) {
|
|
2439
|
+
if (e)
|
|
2440
|
+
return ">";
|
|
2441
|
+
let n = "";
|
|
2442
|
+
if (r && t) {
|
|
2443
|
+
const { enable: s, disable: o } = r;
|
|
2444
|
+
n = (s != null && s.ignoreCase ? "i" : "") + (s != null && s.dotAll ? "s" : "") + (o ? "-" : "") + (o != null && o.ignoreCase ? "i" : "") + (o != null && o.dotAll ? "s" : "");
|
|
2445
|
+
}
|
|
2446
|
+
return `${n}:`;
|
|
2447
|
+
}
|
|
2448
|
+
function vn({ kind: e, max: r, min: t }) {
|
|
2449
|
+
let n;
|
|
2450
|
+
return !t && r === 1 ? n = "?" : !t && r === 1 / 0 ? n = "*" : t === 1 && r === 1 / 0 ? n = "+" : t === r ? n = `{${t}}` : n = `{${t},${r === 1 / 0 ? "" : r}}`, n + {
|
|
2451
|
+
greedy: "",
|
|
2452
|
+
lazy: "?",
|
|
2453
|
+
possessive: "+"
|
|
2454
|
+
}[e];
|
|
2455
|
+
}
|
|
2456
|
+
function ir({ type: e }) {
|
|
2457
|
+
return e === "CapturingGroup" || e === "Group" || e === "LookaroundAssertion";
|
|
2458
|
+
}
|
|
2459
|
+
function Sn(e) {
|
|
2460
|
+
return e > 47 && e < 58;
|
|
2461
|
+
}
|
|
2462
|
+
function ur({ type: e, value: r }) {
|
|
2463
|
+
return e === "Character" && r === 45;
|
|
2464
|
+
}
|
|
2465
|
+
var T, P, X, B, Z, ue, Pe, Q, _n = (Q = class extends RegExp {
|
|
2466
|
+
/**
|
|
2467
|
+
@overload
|
|
2468
|
+
@param {string} pattern
|
|
2469
|
+
@param {string} [flags]
|
|
2470
|
+
@param {EmulatedRegExpOptions} [options]
|
|
2471
|
+
*/
|
|
2472
|
+
/**
|
|
2473
|
+
@overload
|
|
2474
|
+
@param {EmulatedRegExp} pattern
|
|
2475
|
+
@param {string} [flags]
|
|
2476
|
+
*/
|
|
2477
|
+
constructor(t, n, s) {
|
|
2478
|
+
var r = (...Kn) => (super(...Kn), /**
|
|
2479
|
+
Adds support for hidden and transfer captures.
|
|
2480
|
+
@param {string} str
|
|
2481
|
+
@returns
|
|
2482
|
+
*/
|
|
2483
|
+
V(this, ue), /**
|
|
2484
|
+
@type {Map<number, {
|
|
2485
|
+
hidden?: true;
|
|
2486
|
+
transferTo?: number;
|
|
2487
|
+
}>}
|
|
2488
|
+
*/
|
|
2489
|
+
V(this, T, /* @__PURE__ */ new Map()), /**
|
|
2490
|
+
@type {RegExp | EmulatedRegExp | null}
|
|
2491
|
+
*/
|
|
2492
|
+
V(this, P, null), /**
|
|
2493
|
+
@type {string}
|
|
2494
|
+
*/
|
|
2495
|
+
V(this, X, void 0), /**
|
|
2496
|
+
@type {Map<number, string>?}
|
|
2497
|
+
*/
|
|
2498
|
+
V(this, B, null), /**
|
|
2499
|
+
@type {string?}
|
|
2500
|
+
*/
|
|
2501
|
+
V(this, Z, null), /**
|
|
2502
|
+
Can be used to serialize the instance.
|
|
2503
|
+
@type {EmulatedRegExpOptions}
|
|
2504
|
+
*/
|
|
2505
|
+
ye(this, "rawOptions", {}), this);
|
|
2506
|
+
const o = !!(s != null && s.lazyCompile);
|
|
2507
|
+
if (t instanceof RegExp) {
|
|
2508
|
+
if (s)
|
|
2509
|
+
throw new Error("Cannot provide options when copying a regexp");
|
|
2510
|
+
const a = t;
|
|
2511
|
+
r(a, n), M(this, X, a.source), a instanceof Q && (M(this, T, $(a, T)), M(this, B, $(a, B)), M(this, Z, $(a, Z)), this.rawOptions = a.rawOptions);
|
|
2512
|
+
} else {
|
|
2513
|
+
const a = {
|
|
2514
|
+
hiddenCaptures: [],
|
|
2515
|
+
strategy: null,
|
|
2516
|
+
transfers: [],
|
|
2517
|
+
...s
|
|
2518
|
+
};
|
|
2519
|
+
r(o ? "" : t, n), M(this, X, t), M(this, T, Mn(a.hiddenCaptures, a.transfers)), M(this, Z, a.strategy), this.rawOptions = s ?? {};
|
|
2520
|
+
}
|
|
2521
|
+
o || M(this, P, this);
|
|
2522
|
+
}
|
|
2523
|
+
// Override the getter with one that works with lazy-compiled regexes
|
|
2524
|
+
get source() {
|
|
2525
|
+
return $(this, X) || "(?:)";
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
Called internally by all String/RegExp methods that use regexes.
|
|
2529
|
+
@override
|
|
2530
|
+
@param {string} str
|
|
2531
|
+
@returns {RegExpExecArray?}
|
|
2532
|
+
*/
|
|
2533
|
+
exec(t) {
|
|
2534
|
+
if (!$(this, P)) {
|
|
2535
|
+
const { lazyCompile: o, ...a } = this.rawOptions;
|
|
2536
|
+
M(this, P, new Q($(this, X), this.flags, a));
|
|
2537
|
+
}
|
|
2538
|
+
const n = this.global || this.sticky, s = this.lastIndex;
|
|
2539
|
+
if ($(this, Z) === "clip_search" && n && s) {
|
|
2540
|
+
this.lastIndex = 0;
|
|
2541
|
+
const o = be(this, ue, Pe).call(this, t.slice(s));
|
|
2542
|
+
return o && (Nn(o, s, t, this.hasIndices), this.lastIndex += s), o;
|
|
2543
|
+
}
|
|
2544
|
+
return be(this, ue, Pe).call(this, t);
|
|
2545
|
+
}
|
|
2546
|
+
}, T = new WeakMap(), P = new WeakMap(), X = new WeakMap(), B = new WeakMap(), Z = new WeakMap(), ue = new WeakSet(), Pe = function(t) {
|
|
2547
|
+
$(this, P).lastIndex = this.lastIndex;
|
|
2548
|
+
const n = Ve(Q.prototype, this, "exec").call($(this, P), t);
|
|
2549
|
+
if (this.lastIndex = $(this, P).lastIndex, !n || !$(this, T).size)
|
|
2550
|
+
return n;
|
|
2551
|
+
const s = [...n];
|
|
2552
|
+
n.length = 1;
|
|
2553
|
+
let o;
|
|
2554
|
+
this.hasIndices && (o = [...n.indices], n.indices.length = 1);
|
|
2555
|
+
const a = [0];
|
|
2556
|
+
for (let i = 1; i < s.length; i++) {
|
|
2557
|
+
const { hidden: u, transferTo: c } = $(this, T).get(i) ?? {};
|
|
2558
|
+
if (u ? a.push(null) : (a.push(n.length), n.push(s[i]), this.hasIndices && n.indices.push(o[i])), c && s[i] !== void 0) {
|
|
2559
|
+
const l = a[c];
|
|
2560
|
+
if (!l)
|
|
2561
|
+
throw new Error(`Invalid capture transfer to "${l}"`);
|
|
2562
|
+
if (n[l] = s[i], this.hasIndices && (n.indices[l] = o[i]), n.groups) {
|
|
2563
|
+
$(this, B) || M(this, B, Ln(this.source));
|
|
2564
|
+
const p = $(this, B).get(c);
|
|
2565
|
+
p && (n.groups[p] = s[i], this.hasIndices && (n.indices.groups[p] = o[i]));
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
return n;
|
|
2570
|
+
}, Q);
|
|
2571
|
+
function Nn(e, r, t, n) {
|
|
2572
|
+
if (e.index += r, e.input = t, n) {
|
|
2573
|
+
const s = e.indices;
|
|
2574
|
+
for (let a = 0; a < s.length; a++) {
|
|
2575
|
+
const i = s[a];
|
|
2576
|
+
i && (s[a] = [i[0] + r, i[1] + r]);
|
|
2577
|
+
}
|
|
2578
|
+
const o = s.groups;
|
|
2579
|
+
o && Object.keys(o).forEach((a) => {
|
|
2580
|
+
const i = o[a];
|
|
2581
|
+
i && (o[a] = [i[0] + r, i[1] + r]);
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
function Mn(e, r) {
|
|
2586
|
+
const t = /* @__PURE__ */ new Map();
|
|
2587
|
+
for (const n of e)
|
|
2588
|
+
t.set(n, {
|
|
2589
|
+
hidden: !0
|
|
2590
|
+
});
|
|
2591
|
+
for (const [n, s] of r)
|
|
2592
|
+
for (const o of s)
|
|
2593
|
+
ie(t, o, {}).transferTo = n;
|
|
2594
|
+
return t;
|
|
2595
|
+
}
|
|
2596
|
+
function Ln(e) {
|
|
2597
|
+
const r = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu, t = /* @__PURE__ */ new Map();
|
|
2598
|
+
let n = 0, s = 0, o;
|
|
2599
|
+
for (; o = r.exec(e); ) {
|
|
2600
|
+
const { 0: a, groups: { capture: i, name: u } } = o;
|
|
2601
|
+
a === "[" ? n++ : n ? a === "]" && n-- : i && (s++, u && t.set(s, u));
|
|
2602
|
+
}
|
|
2603
|
+
return t;
|
|
2604
|
+
}
|
|
2605
|
+
function Fn(e, r) {
|
|
2606
|
+
const t = Gn(e, r);
|
|
2607
|
+
return t.options ? new _n(t.pattern, t.flags, t.options) : new RegExp(t.pattern, t.flags);
|
|
2608
|
+
}
|
|
2609
|
+
function Gn(e, r) {
|
|
2610
|
+
const t = Ir(r), n = yr(e, {
|
|
2611
|
+
flags: t.flags,
|
|
2612
|
+
normalizeUnknownPropertyNames: !0,
|
|
2613
|
+
rules: {
|
|
2614
|
+
captureGroup: t.rules.captureGroup,
|
|
2615
|
+
singleline: t.rules.singleline
|
|
2616
|
+
},
|
|
2617
|
+
skipBackrefValidation: t.rules.allowOrphanBackrefs,
|
|
2618
|
+
unicodePropertyMap: Te
|
|
2619
|
+
}), s = an(n, {
|
|
2620
|
+
accuracy: t.accuracy,
|
|
2621
|
+
asciiWordBoundaries: t.rules.asciiWordBoundaries,
|
|
2622
|
+
avoidSubclass: t.avoidSubclass,
|
|
2623
|
+
bestEffortTarget: t.target
|
|
2624
|
+
}), o = yn(s, t), a = Qt(o.pattern, {
|
|
2625
|
+
captureTransfers: o._captureTransfers,
|
|
2626
|
+
hiddenCaptures: o._hiddenCaptures,
|
|
2627
|
+
mode: "external"
|
|
2628
|
+
}), i = Xt(a.pattern), u = Ht(i.pattern, {
|
|
2629
|
+
captureTransfers: a.captureTransfers,
|
|
2630
|
+
hiddenCaptures: a.hiddenCaptures
|
|
2631
|
+
}), c = {
|
|
2632
|
+
pattern: u.pattern,
|
|
2633
|
+
flags: `${t.hasIndices ? "d" : ""}${t.global ? "g" : ""}${o.flags}${o.options.disable.v ? "u" : "v"}`
|
|
2634
|
+
};
|
|
2635
|
+
if (t.avoidSubclass) {
|
|
2636
|
+
if (t.lazyCompileLength !== 1 / 0)
|
|
2637
|
+
throw new Error("Lazy compilation requires subclass");
|
|
2638
|
+
} else {
|
|
2639
|
+
const l = u.hiddenCaptures.sort((d, m) => d - m), p = Array.from(u.captureTransfers), f = s._strategy, g = c.pattern.length >= t.lazyCompileLength;
|
|
2640
|
+
(l.length || p.length || f || g) && (c.options = {
|
|
2641
|
+
...l.length && { hiddenCaptures: l },
|
|
2642
|
+
...p.length && { transfers: p },
|
|
2643
|
+
...f && { strategy: f },
|
|
2644
|
+
...g && { lazyCompile: g }
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
return c;
|
|
2648
|
+
}
|
|
2649
|
+
const cr = 4294967295;
|
|
2650
|
+
class Pn {
|
|
2651
|
+
constructor(r, t = {}) {
|
|
2652
|
+
ye(this, "regexps");
|
|
2653
|
+
this.patterns = r, this.options = t;
|
|
2654
|
+
const {
|
|
2655
|
+
forgiving: n = !1,
|
|
2656
|
+
cache: s,
|
|
2657
|
+
regexConstructor: o
|
|
2658
|
+
} = t;
|
|
2659
|
+
if (!o)
|
|
2660
|
+
throw new Error("Option `regexConstructor` is not provided");
|
|
2661
|
+
this.regexps = r.map((a) => {
|
|
2662
|
+
if (typeof a != "string")
|
|
2663
|
+
return a;
|
|
2664
|
+
const i = s == null ? void 0 : s.get(a);
|
|
2665
|
+
if (i) {
|
|
2666
|
+
if (i instanceof RegExp)
|
|
2667
|
+
return i;
|
|
2668
|
+
if (n)
|
|
2669
|
+
return null;
|
|
2670
|
+
throw i;
|
|
2671
|
+
}
|
|
2672
|
+
try {
|
|
2673
|
+
const u = o(a);
|
|
2674
|
+
return s == null || s.set(a, u), u;
|
|
2675
|
+
} catch (u) {
|
|
2676
|
+
if (s == null || s.set(a, u), n)
|
|
2677
|
+
return null;
|
|
2678
|
+
throw u;
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
findNextMatchSync(r, t, n) {
|
|
2683
|
+
const s = typeof r == "string" ? r : r.content, o = [];
|
|
2684
|
+
function a(i, u, c = 0) {
|
|
2685
|
+
return {
|
|
2686
|
+
index: i,
|
|
2687
|
+
captureIndices: u.indices.map((l) => l == null ? {
|
|
2688
|
+
start: cr,
|
|
2689
|
+
end: cr,
|
|
2690
|
+
length: 0
|
|
2691
|
+
} : {
|
|
2692
|
+
start: l[0] + c,
|
|
2693
|
+
end: l[1] + c,
|
|
2694
|
+
length: l[1] - l[0]
|
|
2695
|
+
})
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
for (let i = 0; i < this.regexps.length; i++) {
|
|
2699
|
+
const u = this.regexps[i];
|
|
2700
|
+
if (u)
|
|
2701
|
+
try {
|
|
2702
|
+
u.lastIndex = t;
|
|
2703
|
+
const c = u.exec(s);
|
|
2704
|
+
if (!c)
|
|
2705
|
+
continue;
|
|
2706
|
+
if (c.index === t)
|
|
2707
|
+
return a(i, c, 0);
|
|
2708
|
+
o.push([i, c, 0]);
|
|
2709
|
+
} catch (c) {
|
|
2710
|
+
if (this.options.forgiving)
|
|
2711
|
+
continue;
|
|
2712
|
+
throw c;
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
if (o.length) {
|
|
2716
|
+
const i = Math.min(...o.map((u) => u[1].index));
|
|
2717
|
+
for (const [u, c, l] of o)
|
|
2718
|
+
if (c.index === i)
|
|
2719
|
+
return a(u, c, l);
|
|
2720
|
+
}
|
|
2721
|
+
return null;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
function Rn(e, r) {
|
|
2725
|
+
return Fn(
|
|
2726
|
+
e,
|
|
2727
|
+
{
|
|
2728
|
+
global: !0,
|
|
2729
|
+
hasIndices: !0,
|
|
2730
|
+
// This has no benefit for the standard JS engine, but it avoids a perf penalty for
|
|
2731
|
+
// precompiled grammars when constructing extremely long patterns that aren't always used
|
|
2732
|
+
lazyCompileLength: 3e3,
|
|
2733
|
+
rules: {
|
|
2734
|
+
// Needed since TextMate grammars merge backrefs across patterns
|
|
2735
|
+
allowOrphanBackrefs: !0,
|
|
2736
|
+
// Improves search performance for generated regexes
|
|
2737
|
+
asciiWordBoundaries: !0,
|
|
2738
|
+
// Follow `vscode-oniguruma` which enables this Oniguruma option by default
|
|
2739
|
+
captureGroup: !0,
|
|
2740
|
+
// Oniguruma uses depth limit `20`; lowered here to keep regexes shorter and maybe
|
|
2741
|
+
// sometimes faster, but can be increased if issues reported due to low limit
|
|
2742
|
+
recursionLimit: 5,
|
|
2743
|
+
// Oniguruma option for `^`->`\A`, `$`->`\Z`; improves search performance without any
|
|
2744
|
+
// change in meaning since TM grammars search line by line
|
|
2745
|
+
singleline: !0
|
|
2746
|
+
},
|
|
2747
|
+
...r
|
|
2748
|
+
}
|
|
2749
|
+
);
|
|
2750
|
+
}
|
|
2751
|
+
function Un(e = {}) {
|
|
2752
|
+
const r = Object.assign(
|
|
2753
|
+
{
|
|
2754
|
+
target: "auto",
|
|
2755
|
+
cache: /* @__PURE__ */ new Map()
|
|
2756
|
+
},
|
|
2757
|
+
e
|
|
2758
|
+
);
|
|
2759
|
+
return r.regexConstructor || (r.regexConstructor = (t) => Rn(t, { target: r.target })), {
|
|
2760
|
+
createScanner(t) {
|
|
2761
|
+
return new Pn(t, r);
|
|
2762
|
+
},
|
|
2763
|
+
createString(t) {
|
|
2764
|
+
return {
|
|
2765
|
+
content: t
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
var On = Re("block", "before:content-[counter(line)]", "before:inline-block", "before:[counter-increment:line]", "before:w-4", "before:mr-4", "before:text-[13px]", "before:text-right", "before:text-muted-foreground/50", "before:font-mono", "before:select-none"), Dn = Xr(({ children: e, result: r, language: t, className: n, ...s }) => {
|
|
2771
|
+
let o = pr(() => ({ backgroundColor: r.bg, color: r.fg }), [r.bg, r.fg]);
|
|
2772
|
+
return v.jsx("pre", { className: Re(n, "p-4 text-sm dark:bg-(--shiki-dark-bg)!"), "data-language": t, "data-streamdown": "code-block-body", style: o, ...s, children: v.jsx("code", { className: "[counter-increment:line_0] [counter-reset:line]", children: r.tokens.map((a, i) => v.jsx("span", { className: On, children: a.map((u, c) => v.jsx("span", { className: "dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!", style: { color: u.color, backgroundColor: u.bgColor, ...u.htmlStyle }, ...u.htmlAttrs, children: u.content }, c)) }, i)) }) });
|
|
2773
|
+
}, (e, r) => e.result === r.result && e.language === r.language && e.className === r.className), Tn = ({ className: e, language: r, style: t, ...n }) => v.jsx("div", { className: Re("my-4 w-full overflow-hidden rounded-xl border border-border", e), "data-language": r, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...t }, ...n }), Bn = ({ language: e, children: r }) => v.jsxs("div", { className: "flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: [v.jsx("span", { className: "ml-1 font-mono lowercase", children: e }), v.jsx("div", { className: "flex items-center gap-2", children: r })] }), jn = Un({ forgiving: !0 }), Se = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), Vn = (e, r) => `${e}-${r[0]}-${r[1]}`, zn = (e, r, t) => {
|
|
2774
|
+
let n = e.slice(0, 100), s = e.length > 100 ? e.slice(-100) : "";
|
|
2775
|
+
return `${r}:${t[0]}:${t[1]}:${e.length}:${n}:${s}`;
|
|
2776
|
+
}, Rr = (e) => Object.hasOwn(Hr, e), Wn = (e, r) => {
|
|
2777
|
+
let t = Rr(e) ? e : "text", n = Vn(t, r);
|
|
2778
|
+
if (Se.has(n))
|
|
2779
|
+
return Se.get(n);
|
|
2780
|
+
let s = Wr({ themes: r, langs: [t], engine: jn });
|
|
2781
|
+
return Se.set(n, s), s;
|
|
2782
|
+
}, lr = (e, r, t, n) => {
|
|
2783
|
+
let s = Rr(r) ? r : "text", o = zn(e, s, t);
|
|
2784
|
+
return _e.has(o) ? _e.get(o) : (n && (ee.has(o) || ee.set(o, /* @__PURE__ */ new Set()), ee.get(o).add(n)), Wn(s, t).then((a) => {
|
|
2785
|
+
let i = a.codeToTokens(e, { lang: s, themes: { light: t[0], dark: t[1] } });
|
|
2786
|
+
_e.set(o, i);
|
|
2787
|
+
let u = ee.get(o);
|
|
2788
|
+
if (u) {
|
|
2789
|
+
for (let c of u)
|
|
2790
|
+
c(i);
|
|
2791
|
+
ee.delete(o);
|
|
2792
|
+
}
|
|
2793
|
+
}).catch((a) => {
|
|
2794
|
+
console.error("Failed to highlight code:", a), ee.delete(o);
|
|
2795
|
+
}), null);
|
|
2796
|
+
}, qn = ({ code: e, language: r, className: t, children: n, ...s }) => {
|
|
2797
|
+
let { shikiTheme: o } = Zr(Vr), a = pr(() => ({ bg: "transparent", fg: "inherit", tokens: e.split(`
|
|
2798
|
+
`).map((c) => [{ content: c, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [e]), [i, u] = Qr(a);
|
|
2799
|
+
return qr(() => {
|
|
2800
|
+
let c = lr(e, r, o);
|
|
2801
|
+
if (c) {
|
|
2802
|
+
u(c);
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
lr(e, r, o, (l) => {
|
|
2806
|
+
u(l);
|
|
2807
|
+
});
|
|
2808
|
+
}, [e, r, o]), v.jsx(zr.Provider, { value: { code: e }, children: v.jsxs(Tn, { language: r, children: [v.jsx(Bn, { language: r, children: n }), v.jsx(Dn, { className: t, language: r, result: i, ...s })] }) });
|
|
2809
|
+
};
|
|
2810
|
+
export {
|
|
2811
|
+
qn as CodeBlock
|
|
2812
|
+
};
|