react-dsl-editor 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,19 @@
1
1
  import { Fragment, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
2
2
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
3
- var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (o, g) => () => (g || o((g = { exports: {} }).exports, g), g.exports), __copyProps = (o, g, _, v) => {
4
- if (g && typeof g == "object" || typeof g == "function") for (var y = __getOwnPropNames(g), b = 0, x = y.length, S; b < x; b++) S = y[b], !__hasOwnProp.call(o, S) && S !== _ && __defProp(o, S, {
5
- get: ((o) => g[o]).bind(null, S),
6
- enumerable: !(v = __getOwnPropDesc(g, S)) || v.enumerable
3
+ var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (o, h) => () => (h || o((h = { exports: {} }).exports, h), h.exports), __copyProps = (o, h, g, _) => {
4
+ if (h && typeof h == "object" || typeof h == "function") for (var v = __getOwnPropNames(h), y = 0, b = v.length, x; y < b; y++) x = v[y], !__hasOwnProp.call(o, x) && x !== g && __defProp(o, x, {
5
+ get: ((o) => h[o]).bind(null, x),
6
+ enumerable: !(_ = __getOwnPropDesc(h, x)) || _.enumerable
7
7
  });
8
8
  return o;
9
- }, __toESM = (o, g, _) => (_ = o == null ? {} : __create(__getProtoOf(o)), __copyProps(g || !o || !o.__esModule ? __defProp(_, "default", {
9
+ }, __toESM = (o, h, g) => (g = o == null ? {} : __create(__getProtoOf(o)), __copyProps(h || !o || !o.__esModule ? __defProp(g, "default", {
10
10
  value: o,
11
11
  enumerable: !0
12
- }) : _, o));
12
+ }) : g, o));
13
13
  const textStyle = {
14
+ background: "transparent",
15
+ border: "none",
16
+ resize: "none",
14
17
  position: "absolute",
15
18
  inset: 0,
16
19
  overflow: "auto",
@@ -18,78 +21,78 @@ const textStyle = {
18
21
  fontSize: "1em",
19
22
  lineHeight: "1.3em",
20
23
  fontFamily: "monospace"
21
- }, ReadOnlyTextarea = forwardRef(function({ wrap: o, children: g, style: _ = {} }, v) {
24
+ }, ReadOnlyTextarea = forwardRef(function({ wrap: o, children: h, style: g = {} }, _) {
22
25
  return /* @__PURE__ */ jsx("pre", {
23
- ref: v,
26
+ ref: _,
24
27
  style: {
25
28
  ...textStyle,
26
29
  pointerEvents: "none",
27
30
  margin: 0,
28
31
  overflow: "auto",
29
32
  whiteSpace: o ? "pre-wrap" : "pre",
30
- ..._
33
+ ...g
31
34
  },
32
- children: g
35
+ children: h
33
36
  });
34
37
  });
35
- function e$3(o, g, _) {
36
- let v = (_) => o(_, ...g);
37
- return _ === void 0 ? v : Object.assign(v, {
38
- lazy: _,
39
- lazyArgs: g
38
+ function e$3(o, h, g) {
39
+ let _ = (g) => o(g, ...h);
40
+ return g === void 0 ? _ : Object.assign(_, {
41
+ lazy: g,
42
+ lazyArgs: h
40
43
  });
41
44
  }
42
- function t$6(o, g, _) {
43
- let v = o.length - g.length;
44
- if (v === 0) return o(...g);
45
- if (v === 1) return e$3(o, g, _);
45
+ function t$6(o, h, g) {
46
+ let _ = o.length - h.length;
47
+ if (_ === 0) return o(...h);
48
+ if (_ === 1) return e$3(o, h, g);
46
49
  throw Error("Wrong number of arguments");
47
50
  }
48
51
  var t$4 = {
49
52
  done: !1,
50
53
  hasNext: !1
51
54
  };
52
- function t$1(o, ...g) {
53
- let _ = o, v = g.map((o) => "lazy" in o ? r$7(o) : void 0), y = 0;
54
- for (; y < g.length;) {
55
- if (v[y] === void 0 || !i$2(_)) {
56
- let o = g[y];
57
- _ = o(_), y += 1;
55
+ function t$1(o, ...h) {
56
+ let g = o, _ = h.map((o) => "lazy" in o ? r$7(o) : void 0), v = 0;
57
+ for (; v < h.length;) {
58
+ if (_[v] === void 0 || !i$2(g)) {
59
+ let o = h[v];
60
+ g = o(g), v += 1;
58
61
  continue;
59
62
  }
60
63
  let o = [];
61
- for (let _ = y; _ < g.length; _++) {
62
- let g = v[_];
63
- if (g === void 0 || (o.push(g), g.isSingle)) break;
64
+ for (let g = v; g < h.length; g++) {
65
+ let h = _[g];
66
+ if (h === void 0 || (o.push(h), h.isSingle)) break;
64
67
  }
65
- let b = [];
66
- for (let g of _) if (n$8(g, b, o)) break;
67
- let { isSingle: x } = o.at(-1);
68
- _ = x ? b[0] : b, y += o.length;
68
+ let y = [];
69
+ for (let h of g) if (n$8(h, y, o)) break;
70
+ let { isSingle: b } = o.at(-1);
71
+ g = b ? y[0] : y, v += o.length;
69
72
  }
70
- return _;
73
+ return g;
71
74
  }
72
- function n$8(o, g, _) {
73
- if (_.length === 0) return g.push(o), !1;
74
- let v = o, y = t$4, b = !1;
75
- for (let [o, x] of _.entries()) {
76
- let { index: S, items: C } = x;
77
- if (C.push(v), y = x(v, S, C), x.index += 1, y.hasNext) {
78
- if (y.hasMany ?? !1) {
79
- for (let v of y.next) if (n$8(v, g, _.slice(o + 1))) return !0;
80
- return b;
75
+ function n$8(o, h, g) {
76
+ if (g.length === 0) return h.push(o), !1;
77
+ let _ = o, v = t$4, y = !1;
78
+ for (let [o, b] of g.entries()) {
79
+ let { index: x, items: S } = b;
80
+ if (S.push(_), v = b(_, x, S), b.index += 1, v.hasNext) {
81
+ if (v.hasMany ?? !1) {
82
+ for (let _ of v.next) if (n$8(_, h, g.slice(o + 1))) return !0;
83
+ return y;
81
84
  }
82
- v = y.next;
85
+ _ = v.next;
83
86
  }
84
- if (!y.hasNext) break;
85
- y.done && (b = !0);
87
+ if (!v.hasNext) break;
88
+ v.done && (y = !0);
86
89
  }
87
- return y.hasNext && g.push(v), b;
90
+ return v.hasNext && h.push(_), y;
88
91
  }
89
92
  function r$7(o) {
90
- let { lazy: g, lazyArgs: _ } = o, v = g(..._);
91
- return Object.assign(v, {
92
- isSingle: g.single ?? !1,
93
+ let { lazy: h, lazyArgs: g } = o, _ = h(...g);
94
+ return Object.assign(_, {
95
+ isSingle: h.single ?? !1,
93
96
  index: 0,
94
97
  items: []
95
98
  });
@@ -97,85 +100,85 @@ function r$7(o) {
97
100
  function i$2(o) {
98
101
  return typeof o == "string" || typeof o == "object" && !!o && Symbol.iterator in o;
99
102
  }
100
- function t$5(o, g) {
101
- let _ = g.length - o.length;
102
- if (_ === 1) {
103
- let [_, ...v] = g;
104
- return t$1(_, {
103
+ function t$5(o, h) {
104
+ let g = h.length - o.length;
105
+ if (g === 1) {
106
+ let [g, ..._] = h;
107
+ return t$1(g, {
105
108
  lazy: o,
106
- lazyArgs: v
109
+ lazyArgs: _
107
110
  });
108
111
  }
109
- if (_ === 0) {
110
- let _ = {
112
+ if (g === 0) {
113
+ let g = {
111
114
  lazy: o,
112
- lazyArgs: g
115
+ lazyArgs: h
113
116
  };
114
- return Object.assign((o) => t$1(o, _), _);
117
+ return Object.assign((o) => t$1(o, g), g);
115
118
  }
116
119
  throw Error("Wrong number of arguments");
117
120
  }
118
121
  function t$7(...o) {
119
122
  return t$6(n$7, o);
120
123
  }
121
- var n$7 = (o, g) => o.length >= g, e$1 = {
122
- asc: (o, g) => o > g,
123
- desc: (o, g) => o < g
124
+ var n$7 = (o, h) => o.length >= h, e$1 = {
125
+ asc: (o, h) => o > h,
126
+ desc: (o, h) => o < h
124
127
  };
125
- function t$8(o, g) {
126
- let [_, ...v] = g;
127
- if (!i$1(_)) {
128
- let g = r$6(...v);
129
- return o(_, g);
128
+ function t$8(o, h) {
129
+ let [g, ..._] = h;
130
+ if (!i$1(g)) {
131
+ let h = r$6(..._);
132
+ return o(g, h);
130
133
  }
131
- let y = r$6(_, ...v);
132
- return (g) => o(g, y);
133
- }
134
- function r$6(o, g, ..._) {
135
- let v = typeof o == "function" ? o : o[0], y = typeof o == "function" ? "asc" : o[1], { [y]: b } = e$1, x = g === void 0 ? void 0 : r$6(g, ..._);
136
- return (o, g) => {
137
- let _ = v(o), y = v(g);
138
- return b(_, y) ? 1 : b(y, _) ? -1 : x?.(o, g) ?? 0;
134
+ let v = r$6(g, ..._);
135
+ return (h) => o(h, v);
136
+ }
137
+ function r$6(o, h, ...g) {
138
+ let _ = typeof o == "function" ? o : o[0], v = typeof o == "function" ? "asc" : o[1], { [v]: y } = e$1, b = h === void 0 ? void 0 : r$6(h, ...g);
139
+ return (o, h) => {
140
+ let g = _(o), v = _(h);
141
+ return y(g, v) ? 1 : y(v, g) ? -1 : b?.(o, h) ?? 0;
139
142
  };
140
143
  }
141
144
  function i$1(o) {
142
145
  if (a(o)) return !0;
143
146
  if (typeof o != "object" || !Array.isArray(o)) return !1;
144
- let [g, _, ...v] = o;
145
- return a(g) && typeof _ == "string" && _ in e$1 && v.length === 0;
147
+ let [h, g, ..._] = o;
148
+ return a(h) && typeof g == "string" && g in e$1 && _.length === 0;
146
149
  }
147
150
  var a = (o) => typeof o == "function" && o.length === 1;
148
151
  function n$2(...o) {
149
152
  return t$6(r$5, o, i);
150
153
  }
151
- var r$5 = (o, g) => o.filter(g), i = (o) => (g, _, v) => o(g, _, v) ? {
154
+ var r$5 = (o, h) => o.filter(h), i = (o) => (h, g, _) => o(h, g, _) ? {
152
155
  done: !1,
153
156
  hasNext: !0,
154
- next: g
157
+ next: h
155
158
  } : t$4;
156
159
  function n$3(...o) {
157
160
  return t$8(r$4, o);
158
161
  }
159
- function r$4(o, g) {
162
+ function r$4(o, h) {
160
163
  if (!t$7(o, 2)) return o[0];
161
- let [_] = o, [, ...v] = o;
162
- for (let o of v) g(o, _) < 0 && (_ = o);
163
- return _;
164
+ let [g] = o, [, ..._] = o;
165
+ for (let o of _) h(o, g) < 0 && (g = o);
166
+ return g;
164
167
  }
165
168
  function t(...o) {
166
169
  return t$6(n$6, o, r$3);
167
170
  }
168
- var n$6 = (o, g) => o.flatMap(g), r$3 = (o) => (g, _, v) => {
169
- let y = o(g, _, v);
170
- return Array.isArray(y) ? {
171
+ var n$6 = (o, h) => o.flatMap(h), r$3 = (o) => (h, g, _) => {
172
+ let v = o(h, g, _);
173
+ return Array.isArray(v) ? {
171
174
  done: !1,
172
175
  hasNext: !0,
173
176
  hasMany: !0,
174
- next: y
177
+ next: v
175
178
  } : {
176
179
  done: !1,
177
180
  hasNext: !0,
178
- next: y
181
+ next: v
179
182
  };
180
183
  };
181
184
  function e(o) {
@@ -184,111 +187,73 @@ function e(o) {
184
187
  function t$2(...o) {
185
188
  return t$6(n$5, o, r$2);
186
189
  }
187
- var n$5 = (o, g) => o.map(g), r$2 = (o) => (g, _, v) => ({
190
+ var n$5 = (o, h) => o.map(h), r$2 = (o) => (h, g, _) => ({
188
191
  done: !1,
189
192
  hasNext: !0,
190
- next: o(g, _, v)
193
+ next: o(h, g, _)
191
194
  });
192
195
  function t$3(...o) {
193
196
  return t$6(n$4, o);
194
197
  }
195
- function n$4(o, g) {
196
- let _ = [];
197
- for (let v = o; v < g; v++) _.push(v);
198
- return _;
198
+ function n$4(o, h) {
199
+ let g = [];
200
+ for (let _ = o; _ < h; _++) g.push(_);
201
+ return g;
199
202
  }
200
203
  function n$1(...o) {
201
204
  return t$5(r$1, o);
202
205
  }
203
206
  function r$1() {
204
207
  let o = /* @__PURE__ */ new Set();
205
- return (g) => o.has(g) ? t$4 : (o.add(g), {
208
+ return (h) => o.has(h) ? t$4 : (o.add(h), {
206
209
  done: !1,
207
210
  hasNext: !0,
208
- next: g
211
+ next: h
209
212
  });
210
213
  }
211
214
  function n(...o) {
212
215
  return t$5(r, o);
213
216
  }
214
217
  function r(o) {
215
- let g = o, _ = /* @__PURE__ */ new Set();
216
- return (o, v, y) => {
217
- let b = g(o, v, y);
218
- return _.has(b) ? t$4 : (_.add(b), {
218
+ let h = o, g = /* @__PURE__ */ new Set();
219
+ return (o, _, v) => {
220
+ let y = h(o, _, v);
221
+ return g.has(y) ? t$4 : (g.add(y), {
219
222
  done: !1,
220
223
  hasNext: !0,
221
224
  next: o
222
225
  });
223
226
  };
224
227
  }
225
- function disjointIntervals(o) {
226
- if (o.length === 0) return [];
227
- let g = [...o].sort((o, g) => o.start - g.start), _ = [g[0]];
228
- for (let o = 1; o < g.length; o++) {
229
- let v = g[o], y = _[_.length - 1];
230
- v.start >= y.end ? _.push(v) : v.end > y.end && (_[_.length - 1] = {
231
- ...y,
232
- end: v.end
233
- });
234
- }
235
- return _;
236
- }
237
- function decorateIntervals(g, _, v) {
238
- let y = [], b = 0;
239
- return g.forEach((g, x) => {
240
- g.start > b && y.push(/* @__PURE__ */ jsx(Fragment, { children: _.substring(b, g.start) }, `text-${x}`)), y.push(v(_.substring(g.start, g.end), g, x)), b = g.end;
241
- }), b < _.length && y.push(/* @__PURE__ */ jsx(Fragment, { children: _.substring(b) }, "text-end")), y;
242
- }
243
- var squiggly = {
244
- textDecorationLine: "underline",
245
- textDecorationStyle: "wavy",
246
- textDecorationColor: "red"
247
- };
248
- function SyntaxHighlighter({ cstRoot: o, ref: g, wrap: _, syntaxColors: v }) {
228
+ function SyntaxHighlighter({ cstRoot: o, ref: h, wrap: g, syntaxColors: _ }) {
249
229
  return /* @__PURE__ */ jsx(ReadOnlyTextarea, {
250
- ref: g,
251
- wrap: _,
230
+ ref: h,
231
+ wrap: g,
252
232
  children: /* @__PURE__ */ jsx(StyledNode, {
253
233
  node: o,
254
- styleFor: v
234
+ styleFor: _
255
235
  })
256
236
  });
257
237
  }
258
- function ErrorHighlighter({ ref: o, wrap: g, errors: _, children: v }) {
259
- let y = `${v} `, b = disjointIntervals(_);
260
- return b.length === 0 ? /* @__PURE__ */ jsx(Fragment$1, {}) : /* @__PURE__ */ jsx(ReadOnlyTextarea, {
261
- ref: o,
262
- wrap: g,
263
- "data-id": "ErrorHighlighter",
264
- style: { color: "transparent" },
265
- children: decorateIntervals(b, y, (o, g, _) => /* @__PURE__ */ jsx("span", {
266
- style: squiggly,
267
- title: g.message,
268
- children: o
269
- }, `error-${_}`))
270
- });
271
- }
272
238
  function StyledNode(o) {
273
- let g = o.styleFor(o.node);
239
+ let h = o.styleFor(o.node);
274
240
  return e(o.node.children ?? []) && e(o.node.text) ? null : /* @__PURE__ */ jsx("span", {
275
- style: g,
241
+ style: h,
276
242
  "data-node": o.node.grammar.type,
277
- "data-node-error": o.node.recoverableError,
278
- "data-node-meta": o.node.grammar.meta ? JSON.stringify(o.node.grammar.meta, function(o, g) {
279
- return g instanceof RegExp ? g.toString() : g;
243
+ "data-node-meta": o.node.grammar.meta ? JSON.stringify(o.node.grammar.meta, function(o, h) {
244
+ return h instanceof RegExp ? h.toString() : h;
280
245
  }) : void 0,
281
- children: e(o.node.children ?? []) ? o.node.text : o.node.children.map((g, _) => /* @__PURE__ */ jsx(StyledNode, {
282
- node: g,
246
+ children: e(o.node.children ?? []) ? o.node.text : o.node.children.map((h, g) => /* @__PURE__ */ jsx(StyledNode, {
247
+ node: h,
283
248
  styleFor: o.styleFor
284
- }, _))
249
+ }, g))
285
250
  });
286
251
  }
287
- function cstPathAt(o, g) {
288
- return _cstPathAt(o, g, []);
252
+ function cstPathAt(o, h) {
253
+ return _cstPathAt(o, h, []);
289
254
  }
290
- function _cstPathAt(o, g, _ = []) {
291
- return o.offset <= g && g <= o.end ? (_.push(o), o.children?.forEach((o) => _cstPathAt(o, g, _)), _) : [];
255
+ function _cstPathAt(o, h, g = []) {
256
+ return o.offset <= h && h <= o.end ? (g.push(o), o.children?.forEach((o) => _cstPathAt(o, h, g)), g) : [];
292
257
  }
293
258
  var ParsingError = class extends Error {
294
259
  constructor(o) {
@@ -314,45 +279,45 @@ function asException(o) {
314
279
  return new ParsingError(`[${o.grammar.type}]: Expected ${o.expected.map((o) => JSON.stringify(o)).join(" | ")}, but got '${o.got}' (${pathToString([...o.path, o.grammar])})`);
315
280
  }
316
281
  function pickFromErrorLabels(o) {
317
- return t$1(o, n$2((o) => o.errorLabel !== void 0), n$3((o) => -o.errorLabel.got.length));
282
+ return t$1(o, n$2((o) => o.errorLabel !== void 0), n$3((o) => o.errorLabel.got.length));
318
283
  }
319
284
  function alternative(...o) {
320
- let g = {
285
+ let h = {
321
286
  type: "alternative",
322
287
  children: o,
323
- parse(_, v) {
324
- let y = {
325
- ...v,
326
- path: [...v.path, g]
327
- }, b = [], x = [];
328
- for (let v of o) {
329
- let o = v.parse(_, y);
288
+ parse(g, _) {
289
+ let v = {
290
+ ..._,
291
+ path: [..._.path, h]
292
+ }, y = [], b = [];
293
+ for (let _ of o) {
294
+ let o = _.parse(g, v);
330
295
  if (isParserError(o)) {
331
- b.push(o);
296
+ y.push(o);
332
297
  continue;
333
298
  }
334
299
  if (o.errorLabel) {
335
- x.push(o);
300
+ b.push(o);
336
301
  continue;
337
302
  }
338
303
  return success({
339
- grammar: g,
304
+ grammar: h,
340
305
  children: [o],
341
306
  text: o.text,
342
307
  errorLabel: o.errorLabel
343
308
  });
344
309
  }
345
- if (e(x)) return error({
310
+ if (e(b)) return error({
346
311
  offset: 0,
347
- path: y.path,
348
- grammar: g,
349
- got: _,
350
- expected: b.flatMap((o) => o.expected)
312
+ path: v.path,
313
+ grammar: h,
314
+ got: g,
315
+ expected: y.flatMap((o) => o.expected)
351
316
  });
352
317
  {
353
- let o = pickFromErrorLabels(x);
318
+ let o = pickFromErrorLabels(b);
354
319
  return success({
355
- grammar: g,
320
+ grammar: h,
356
321
  children: [o],
357
322
  text: o.text,
358
323
  errorLabel: o.errorLabel
@@ -363,32 +328,32 @@ function alternative(...o) {
363
328
  return o.flatMap((o) => o.suggestions());
364
329
  }
365
330
  };
366
- return g;
331
+ return h;
367
332
  }
368
- function named(o, g) {
369
- let _ = {
333
+ function named(o, h) {
334
+ let g = {
370
335
  meta: { name: o },
371
336
  type: "named",
372
337
  suggestions() {
373
- return g.suggestions();
338
+ return h.suggestions();
374
339
  },
375
- children: [g],
376
- parse(o, v) {
377
- let y = g.parse(o, v);
378
- return isParserError(y) ? y : success({
379
- text: y.text,
380
- grammar: _,
381
- children: [y]
340
+ children: [h],
341
+ parse(o, _) {
342
+ let v = h.parse(o, _);
343
+ return isParserError(v) ? v : success({
344
+ text: v.text,
345
+ grammar: g,
346
+ children: [v]
382
347
  });
383
348
  }
384
349
  };
385
- return _;
350
+ return g;
386
351
  }
387
352
  function nodeName(o) {
388
353
  return o.grammar.meta?.name;
389
354
  }
390
- var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
391
- g.exports = {
355
+ var require_types = /* @__PURE__ */ __commonJSMin(((o, h) => {
356
+ h.exports = {
392
357
  ROOT: 0,
393
358
  GROUP: 1,
394
359
  POSITION: 2,
@@ -399,136 +364,136 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
399
364
  CHAR: 7
400
365
  };
401
366
  })), require_sets = /* @__PURE__ */ __commonJSMin(((o) => {
402
- var g = require_types(), _ = () => [{
403
- type: g.RANGE,
367
+ var h = require_types(), g = () => [{
368
+ type: h.RANGE,
404
369
  from: 48,
405
370
  to: 57
406
- }], v = () => [
371
+ }], _ = () => [
407
372
  {
408
- type: g.CHAR,
373
+ type: h.CHAR,
409
374
  value: 95
410
375
  },
411
376
  {
412
- type: g.RANGE,
377
+ type: h.RANGE,
413
378
  from: 97,
414
379
  to: 122
415
380
  },
416
381
  {
417
- type: g.RANGE,
382
+ type: h.RANGE,
418
383
  from: 65,
419
384
  to: 90
420
385
  }
421
- ].concat(_()), y = () => [
386
+ ].concat(g()), v = () => [
422
387
  {
423
- type: g.CHAR,
388
+ type: h.CHAR,
424
389
  value: 9
425
390
  },
426
391
  {
427
- type: g.CHAR,
392
+ type: h.CHAR,
428
393
  value: 10
429
394
  },
430
395
  {
431
- type: g.CHAR,
396
+ type: h.CHAR,
432
397
  value: 11
433
398
  },
434
399
  {
435
- type: g.CHAR,
400
+ type: h.CHAR,
436
401
  value: 12
437
402
  },
438
403
  {
439
- type: g.CHAR,
404
+ type: h.CHAR,
440
405
  value: 13
441
406
  },
442
407
  {
443
- type: g.CHAR,
408
+ type: h.CHAR,
444
409
  value: 32
445
410
  },
446
411
  {
447
- type: g.CHAR,
412
+ type: h.CHAR,
448
413
  value: 160
449
414
  },
450
415
  {
451
- type: g.CHAR,
416
+ type: h.CHAR,
452
417
  value: 5760
453
418
  },
454
419
  {
455
- type: g.RANGE,
420
+ type: h.RANGE,
456
421
  from: 8192,
457
422
  to: 8202
458
423
  },
459
424
  {
460
- type: g.CHAR,
425
+ type: h.CHAR,
461
426
  value: 8232
462
427
  },
463
428
  {
464
- type: g.CHAR,
429
+ type: h.CHAR,
465
430
  value: 8233
466
431
  },
467
432
  {
468
- type: g.CHAR,
433
+ type: h.CHAR,
469
434
  value: 8239
470
435
  },
471
436
  {
472
- type: g.CHAR,
437
+ type: h.CHAR,
473
438
  value: 8287
474
439
  },
475
440
  {
476
- type: g.CHAR,
441
+ type: h.CHAR,
477
442
  value: 12288
478
443
  },
479
444
  {
480
- type: g.CHAR,
445
+ type: h.CHAR,
481
446
  value: 65279
482
447
  }
483
- ], b = () => [
448
+ ], y = () => [
484
449
  {
485
- type: g.CHAR,
450
+ type: h.CHAR,
486
451
  value: 10
487
452
  },
488
453
  {
489
- type: g.CHAR,
454
+ type: h.CHAR,
490
455
  value: 13
491
456
  },
492
457
  {
493
- type: g.CHAR,
458
+ type: h.CHAR,
494
459
  value: 8232
495
460
  },
496
461
  {
497
- type: g.CHAR,
462
+ type: h.CHAR,
498
463
  value: 8233
499
464
  }
500
465
  ];
501
466
  o.words = () => ({
502
- type: g.SET,
503
- set: v(),
467
+ type: h.SET,
468
+ set: _(),
504
469
  not: !1
505
470
  }), o.notWords = () => ({
506
- type: g.SET,
507
- set: v(),
471
+ type: h.SET,
472
+ set: _(),
508
473
  not: !0
509
474
  }), o.ints = () => ({
510
- type: g.SET,
511
- set: _(),
475
+ type: h.SET,
476
+ set: g(),
512
477
  not: !1
513
478
  }), o.notInts = () => ({
514
- type: g.SET,
515
- set: _(),
479
+ type: h.SET,
480
+ set: g(),
516
481
  not: !0
517
482
  }), o.whitespace = () => ({
518
- type: g.SET,
519
- set: y(),
483
+ type: h.SET,
484
+ set: v(),
520
485
  not: !1
521
486
  }), o.notWhitespace = () => ({
522
- type: g.SET,
523
- set: y(),
487
+ type: h.SET,
488
+ set: v(),
524
489
  not: !0
525
490
  }), o.anyChar = () => ({
526
- type: g.SET,
527
- set: b(),
491
+ type: h.SET,
492
+ set: y(),
528
493
  not: !0
529
494
  });
530
495
  })), require_util = /* @__PURE__ */ __commonJSMin(((o) => {
531
- var g = require_types(), _ = require_sets(), v = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?", y = {
496
+ var h = require_types(), g = require_sets(), _ = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?", v = {
532
497
  0: 0,
533
498
  t: 9,
534
499
  n: 10,
@@ -537,174 +502,174 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
537
502
  r: 13
538
503
  };
539
504
  o.strToChars = function(o) {
540
- return o = o.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g, function(o, g, _, b, x, S, C, w) {
541
- if (_) return o;
542
- var T = g ? 8 : b ? parseInt(b, 16) : x ? parseInt(x, 16) : S ? parseInt(S, 8) : C ? v.indexOf(C) : y[w], E = String.fromCharCode(T);
543
- return /[[\]{}^$.|?*+()]/.test(E) && (E = "\\" + E), E;
505
+ return o = o.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g, function(o, h, g, y, b, x, S, C) {
506
+ if (g) return o;
507
+ var w = h ? 8 : y ? parseInt(y, 16) : b ? parseInt(b, 16) : x ? parseInt(x, 8) : S ? _.indexOf(S) : v[C], T = String.fromCharCode(w);
508
+ return /[[\]{}^$.|?*+()]/.test(T) && (T = "\\" + T), T;
544
509
  }), o;
545
- }, o.tokenizeClass = (v, y) => {
546
- for (var b = [], x = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g, S, C; (S = x.exec(v)) != null;) if (S[1]) b.push(_.words());
547
- else if (S[2]) b.push(_.ints());
548
- else if (S[3]) b.push(_.whitespace());
549
- else if (S[4]) b.push(_.notWords());
550
- else if (S[5]) b.push(_.notInts());
551
- else if (S[6]) b.push(_.notWhitespace());
552
- else if (S[7]) b.push({
553
- type: g.RANGE,
554
- from: (S[8] || S[9]).charCodeAt(0),
555
- to: S[10].charCodeAt(0)
510
+ }, o.tokenizeClass = (_, v) => {
511
+ for (var y = [], b = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g, x, S; (x = b.exec(_)) != null;) if (x[1]) y.push(g.words());
512
+ else if (x[2]) y.push(g.ints());
513
+ else if (x[3]) y.push(g.whitespace());
514
+ else if (x[4]) y.push(g.notWords());
515
+ else if (x[5]) y.push(g.notInts());
516
+ else if (x[6]) y.push(g.notWhitespace());
517
+ else if (x[7]) y.push({
518
+ type: h.RANGE,
519
+ from: (x[8] || x[9]).charCodeAt(0),
520
+ to: x[10].charCodeAt(0)
556
521
  });
557
- else if (C = S[12]) b.push({
558
- type: g.CHAR,
559
- value: C.charCodeAt(0)
522
+ else if (S = x[12]) y.push({
523
+ type: h.CHAR,
524
+ value: S.charCodeAt(0)
560
525
  });
561
- else return [b, x.lastIndex];
562
- o.error(y, "Unterminated character class");
563
- }, o.error = (o, g) => {
564
- throw SyntaxError("Invalid regular expression: /" + o + "/: " + g);
526
+ else return [y, b.lastIndex];
527
+ o.error(v, "Unterminated character class");
528
+ }, o.error = (o, h) => {
529
+ throw SyntaxError("Invalid regular expression: /" + o + "/: " + h);
565
530
  };
566
531
  })), require_positions = /* @__PURE__ */ __commonJSMin(((o) => {
567
- var g = require_types();
532
+ var h = require_types();
568
533
  o.wordBoundary = () => ({
569
- type: g.POSITION,
534
+ type: h.POSITION,
570
535
  value: "b"
571
536
  }), o.nonWordBoundary = () => ({
572
- type: g.POSITION,
537
+ type: h.POSITION,
573
538
  value: "B"
574
539
  }), o.begin = () => ({
575
- type: g.POSITION,
540
+ type: h.POSITION,
576
541
  value: "^"
577
542
  }), o.end = () => ({
578
- type: g.POSITION,
543
+ type: h.POSITION,
579
544
  value: "$"
580
545
  });
581
- })), require_lib$1 = /* @__PURE__ */ __commonJSMin(((o, g) => {
582
- var _ = require_util(), v = require_types(), y = require_sets(), b = require_positions();
583
- g.exports = (o) => {
584
- var g = 0, x, S, C = {
585
- type: v.ROOT,
546
+ })), require_lib$1 = /* @__PURE__ */ __commonJSMin(((o, h) => {
547
+ var g = require_util(), _ = require_types(), v = require_sets(), y = require_positions();
548
+ h.exports = (o) => {
549
+ var h = 0, b, x, S = {
550
+ type: _.ROOT,
586
551
  stack: []
587
- }, w = C, T = C.stack, E = [], D = (g) => {
588
- _.error(o, `Nothing to repeat at column ${g - 1}`);
589
- }, O = _.strToChars(o);
590
- for (x = O.length; g < x;) switch (S = O[g++], S) {
552
+ }, C = S, w = S.stack, T = [], E = (h) => {
553
+ g.error(o, `Nothing to repeat at column ${h - 1}`);
554
+ }, D = g.strToChars(o);
555
+ for (b = D.length; h < b;) switch (x = D[h++], x) {
591
556
  case "\\":
592
- switch (S = O[g++], S) {
557
+ switch (x = D[h++], x) {
593
558
  case "b":
594
- T.push(b.wordBoundary());
559
+ w.push(y.wordBoundary());
595
560
  break;
596
561
  case "B":
597
- T.push(b.nonWordBoundary());
562
+ w.push(y.nonWordBoundary());
598
563
  break;
599
564
  case "w":
600
- T.push(y.words());
565
+ w.push(v.words());
601
566
  break;
602
567
  case "W":
603
- T.push(y.notWords());
568
+ w.push(v.notWords());
604
569
  break;
605
570
  case "d":
606
- T.push(y.ints());
571
+ w.push(v.ints());
607
572
  break;
608
573
  case "D":
609
- T.push(y.notInts());
574
+ w.push(v.notInts());
610
575
  break;
611
576
  case "s":
612
- T.push(y.whitespace());
577
+ w.push(v.whitespace());
613
578
  break;
614
579
  case "S":
615
- T.push(y.notWhitespace());
580
+ w.push(v.notWhitespace());
616
581
  break;
617
- default: /\d/.test(S) ? T.push({
618
- type: v.REFERENCE,
619
- value: parseInt(S, 10)
620
- }) : T.push({
621
- type: v.CHAR,
622
- value: S.charCodeAt(0)
582
+ default: /\d/.test(x) ? w.push({
583
+ type: _.REFERENCE,
584
+ value: parseInt(x, 10)
585
+ }) : w.push({
586
+ type: _.CHAR,
587
+ value: x.charCodeAt(0)
623
588
  });
624
589
  }
625
590
  break;
626
591
  case "^":
627
- T.push(b.begin());
592
+ w.push(y.begin());
628
593
  break;
629
594
  case "$":
630
- T.push(b.end());
595
+ w.push(y.end());
631
596
  break;
632
597
  case "[":
633
- var k;
634
- O[g] === "^" ? (k = !0, g++) : k = !1;
635
- var A = _.tokenizeClass(O.slice(g), o);
636
- g += A[1], T.push({
637
- type: v.SET,
638
- set: A[0],
639
- not: k
598
+ var O;
599
+ D[h] === "^" ? (O = !0, h++) : O = !1;
600
+ var k = g.tokenizeClass(D.slice(h), o);
601
+ h += k[1], w.push({
602
+ type: _.SET,
603
+ set: k[0],
604
+ not: O
640
605
  });
641
606
  break;
642
607
  case ".":
643
- T.push(y.anyChar());
608
+ w.push(v.anyChar());
644
609
  break;
645
610
  case "(":
646
- var j = {
647
- type: v.GROUP,
611
+ var A = {
612
+ type: _.GROUP,
648
613
  stack: [],
649
614
  remember: !0
650
615
  };
651
- S = O[g], S === "?" && (S = O[g + 1], g += 2, S === "=" ? j.followedBy = !0 : S === "!" ? j.notFollowedBy = !0 : S !== ":" && _.error(o, `Invalid group, character '${S}' after '?' at column ${g - 1}`), j.remember = !1), T.push(j), E.push(w), w = j, T = j.stack;
616
+ x = D[h], x === "?" && (x = D[h + 1], h += 2, x === "=" ? A.followedBy = !0 : x === "!" ? A.notFollowedBy = !0 : x !== ":" && g.error(o, `Invalid group, character '${x}' after '?' at column ${h - 1}`), A.remember = !1), w.push(A), T.push(C), C = A, w = A.stack;
652
617
  break;
653
618
  case ")":
654
- E.length === 0 && _.error(o, `Unmatched ) at column ${g - 1}`), w = E.pop(), T = w.options ? w.options[w.options.length - 1] : w.stack;
619
+ T.length === 0 && g.error(o, `Unmatched ) at column ${h - 1}`), C = T.pop(), w = C.options ? C.options[C.options.length - 1] : C.stack;
655
620
  break;
656
621
  case "|":
657
- w.options || (w.options = [w.stack], delete w.stack);
658
- var M = [];
659
- w.options.push(M), T = M;
622
+ C.options || (C.options = [C.stack], delete C.stack);
623
+ var j = [];
624
+ C.options.push(j), w = j;
660
625
  break;
661
626
  case "{":
662
- var N = /^(\d+)(,(\d+)?)?\}/.exec(O.slice(g)), P, F;
663
- N === null ? T.push({
664
- type: v.CHAR,
627
+ var M = /^(\d+)(,(\d+)?)?\}/.exec(D.slice(h)), N, P;
628
+ M === null ? w.push({
629
+ type: _.CHAR,
665
630
  value: 123
666
- }) : (T.length === 0 && D(g), P = parseInt(N[1], 10), F = N[2] ? N[3] ? parseInt(N[3], 10) : Infinity : P, g += N[0].length, T.push({
667
- type: v.REPETITION,
668
- min: P,
669
- max: F,
670
- value: T.pop()
631
+ }) : (w.length === 0 && E(h), N = parseInt(M[1], 10), P = M[2] ? M[3] ? parseInt(M[3], 10) : Infinity : N, h += M[0].length, w.push({
632
+ type: _.REPETITION,
633
+ min: N,
634
+ max: P,
635
+ value: w.pop()
671
636
  }));
672
637
  break;
673
638
  case "?":
674
- T.length === 0 && D(g), T.push({
675
- type: v.REPETITION,
639
+ w.length === 0 && E(h), w.push({
640
+ type: _.REPETITION,
676
641
  min: 0,
677
642
  max: 1,
678
- value: T.pop()
643
+ value: w.pop()
679
644
  });
680
645
  break;
681
646
  case "+":
682
- T.length === 0 && D(g), T.push({
683
- type: v.REPETITION,
647
+ w.length === 0 && E(h), w.push({
648
+ type: _.REPETITION,
684
649
  min: 1,
685
650
  max: Infinity,
686
- value: T.pop()
651
+ value: w.pop()
687
652
  });
688
653
  break;
689
654
  case "*":
690
- T.length === 0 && D(g), T.push({
691
- type: v.REPETITION,
655
+ w.length === 0 && E(h), w.push({
656
+ type: _.REPETITION,
692
657
  min: 0,
693
658
  max: Infinity,
694
- value: T.pop()
659
+ value: w.pop()
695
660
  });
696
661
  break;
697
- default: T.push({
698
- type: v.CHAR,
699
- value: S.charCodeAt(0)
662
+ default: w.push({
663
+ type: _.CHAR,
664
+ value: x.charCodeAt(0)
700
665
  });
701
666
  }
702
- return E.length !== 0 && _.error(o, "Unterminated group"), C;
703
- }, g.exports.types = v;
704
- })), require_lib = /* @__PURE__ */ __commonJSMin(((o, g) => {
705
- var _ = class o {
706
- constructor(o, g) {
707
- this.low = o, this.high = g, this.length = 1 + g - o;
667
+ return T.length !== 0 && g.error(o, "Unterminated group"), S;
668
+ }, h.exports.types = _;
669
+ })), require_lib = /* @__PURE__ */ __commonJSMin(((o, h) => {
670
+ var g = class o {
671
+ constructor(o, h) {
672
+ this.low = o, this.high = h, this.length = 1 + h - o;
708
673
  }
709
674
  overlaps(o) {
710
675
  return !(this.high < o.low || this.low > o.high);
@@ -712,52 +677,52 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
712
677
  touches(o) {
713
678
  return !(this.high + 1 < o.low || this.low - 1 > o.high);
714
679
  }
715
- add(g) {
716
- return new o(Math.min(this.low, g.low), Math.max(this.high, g.high));
680
+ add(h) {
681
+ return new o(Math.min(this.low, h.low), Math.max(this.high, h.high));
717
682
  }
718
- subtract(g) {
719
- return g.low <= this.low && g.high >= this.high ? [] : g.low > this.low && g.high < this.high ? [new o(this.low, g.low - 1), new o(g.high + 1, this.high)] : g.low <= this.low ? [new o(g.high + 1, this.high)] : [new o(this.low, g.low - 1)];
683
+ subtract(h) {
684
+ return h.low <= this.low && h.high >= this.high ? [] : h.low > this.low && h.high < this.high ? [new o(this.low, h.low - 1), new o(h.high + 1, this.high)] : h.low <= this.low ? [new o(h.high + 1, this.high)] : [new o(this.low, h.low - 1)];
720
685
  }
721
686
  toString() {
722
687
  return this.low == this.high ? this.low.toString() : this.low + "-" + this.high;
723
688
  }
724
689
  };
725
- g.exports = class o {
726
- constructor(o, g) {
727
- this.ranges = [], this.length = 0, o != null && this.add(o, g);
690
+ h.exports = class o {
691
+ constructor(o, h) {
692
+ this.ranges = [], this.length = 0, o != null && this.add(o, h);
728
693
  }
729
694
  _update_length() {
730
- this.length = this.ranges.reduce((o, g) => o + g.length, 0);
695
+ this.length = this.ranges.reduce((o, h) => o + h.length, 0);
731
696
  }
732
- add(g, v) {
733
- var y = (o) => {
734
- for (var g = 0; g < this.ranges.length && !o.touches(this.ranges[g]);) g++;
735
- for (var _ = this.ranges.slice(0, g); g < this.ranges.length && o.touches(this.ranges[g]);) o = o.add(this.ranges[g]), g++;
736
- _.push(o), this.ranges = _.concat(this.ranges.slice(g)), this._update_length();
697
+ add(h, _) {
698
+ var v = (o) => {
699
+ for (var h = 0; h < this.ranges.length && !o.touches(this.ranges[h]);) h++;
700
+ for (var g = this.ranges.slice(0, h); h < this.ranges.length && o.touches(this.ranges[h]);) o = o.add(this.ranges[h]), h++;
701
+ g.push(o), this.ranges = g.concat(this.ranges.slice(h)), this._update_length();
737
702
  };
738
- return g instanceof o ? g.ranges.forEach(y) : (v ??= g, y(new _(g, v))), this;
703
+ return h instanceof o ? h.ranges.forEach(v) : (_ ??= h, v(new g(h, _))), this;
739
704
  }
740
- subtract(g, v) {
741
- var y = (o) => {
742
- for (var g = 0; g < this.ranges.length && !o.overlaps(this.ranges[g]);) g++;
743
- for (var _ = this.ranges.slice(0, g); g < this.ranges.length && o.overlaps(this.ranges[g]);) _ = _.concat(this.ranges[g].subtract(o)), g++;
744
- this.ranges = _.concat(this.ranges.slice(g)), this._update_length();
705
+ subtract(h, _) {
706
+ var v = (o) => {
707
+ for (var h = 0; h < this.ranges.length && !o.overlaps(this.ranges[h]);) h++;
708
+ for (var g = this.ranges.slice(0, h); h < this.ranges.length && o.overlaps(this.ranges[h]);) g = g.concat(this.ranges[h].subtract(o)), h++;
709
+ this.ranges = g.concat(this.ranges.slice(h)), this._update_length();
745
710
  };
746
- return g instanceof o ? g.ranges.forEach(y) : (v ??= g, y(new _(g, v))), this;
711
+ return h instanceof o ? h.ranges.forEach(v) : (_ ??= h, v(new g(h, _))), this;
747
712
  }
748
- intersect(g, v) {
749
- var y = [], b = (o) => {
750
- for (var g = 0; g < this.ranges.length && !o.overlaps(this.ranges[g]);) g++;
751
- for (; g < this.ranges.length && o.overlaps(this.ranges[g]);) {
752
- var v = Math.max(this.ranges[g].low, o.low), b = Math.min(this.ranges[g].high, o.high);
753
- y.push(new _(v, b)), g++;
713
+ intersect(h, _) {
714
+ var v = [], y = (o) => {
715
+ for (var h = 0; h < this.ranges.length && !o.overlaps(this.ranges[h]);) h++;
716
+ for (; h < this.ranges.length && o.overlaps(this.ranges[h]);) {
717
+ var _ = Math.max(this.ranges[h].low, o.low), y = Math.min(this.ranges[h].high, o.high);
718
+ v.push(new g(_, y)), h++;
754
719
  }
755
720
  };
756
- return g instanceof o ? g.ranges.forEach(b) : (v ??= g, b(new _(g, v))), this.ranges = y, this._update_length(), this;
721
+ return h instanceof o ? h.ranges.forEach(y) : (_ ??= h, y(new g(h, _))), this.ranges = v, this._update_length(), this;
757
722
  }
758
723
  index(o) {
759
- for (var g = 0; g < this.ranges.length && this.ranges[g].length <= o;) o -= this.ranges[g].length, g++;
760
- return this.ranges[g].low + o;
724
+ for (var h = 0; h < this.ranges.length && this.ranges[h].length <= o;) o -= this.ranges[h].length, h++;
725
+ return this.ranges[h].low + o;
761
726
  }
762
727
  toString() {
763
728
  return "[ " + this.ranges.join(", ") + " ]";
@@ -766,8 +731,8 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
766
731
  return new o(this);
767
732
  }
768
733
  numbers() {
769
- return this.ranges.reduce((o, g) => {
770
- for (var _ = g.low; _ <= g.high;) o.push(_), _++;
734
+ return this.ranges.reduce((o, h) => {
735
+ for (var g = h.low; g <= h.high;) o.push(g), g++;
771
736
  return o;
772
737
  }, []);
773
738
  }
@@ -779,40 +744,40 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
779
744
  }));
780
745
  }
781
746
  };
782
- })), import_randexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((o, g) => {
783
- var _ = require_lib$1(), v = require_lib(), y = _.types;
784
- g.exports = class o {
785
- constructor(o, g) {
747
+ })), import_randexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((o, h) => {
748
+ var g = require_lib$1(), _ = require_lib(), v = g.types;
749
+ h.exports = class o {
750
+ constructor(o, h) {
786
751
  if (this._setDefaults(o), o instanceof RegExp) this.ignoreCase = o.ignoreCase, this.multiline = o.multiline, o = o.source;
787
- else if (typeof o == "string") this.ignoreCase = g && g.indexOf("i") !== -1, this.multiline = g && g.indexOf("m") !== -1;
752
+ else if (typeof o == "string") this.ignoreCase = h && h.indexOf("i") !== -1, this.multiline = h && h.indexOf("m") !== -1;
788
753
  else throw Error("Expected a regexp or string");
789
- this.tokens = _(o);
754
+ this.tokens = g(o);
790
755
  }
791
- _setDefaults(g) {
792
- this.max = g.max == null ? o.prototype.max == null ? 100 : o.prototype.max : g.max, this.defaultRange = g.defaultRange ? g.defaultRange : this.defaultRange.clone(), g.randInt && (this.randInt = g.randInt);
756
+ _setDefaults(h) {
757
+ this.max = h.max == null ? o.prototype.max == null ? 100 : o.prototype.max : h.max, this.defaultRange = h.defaultRange ? h.defaultRange : this.defaultRange.clone(), h.randInt && (this.randInt = h.randInt);
793
758
  }
794
759
  gen() {
795
760
  return this._gen(this.tokens, []);
796
761
  }
797
- _gen(o, g) {
798
- var _, v, b, x, S;
762
+ _gen(o, h) {
763
+ var g, _, y, b, x;
799
764
  switch (o.type) {
800
- case y.ROOT:
801
- case y.GROUP:
765
+ case v.ROOT:
766
+ case v.GROUP:
802
767
  if (o.followedBy || o.notFollowedBy) return "";
803
- for (o.remember && o.groupNumber === void 0 && (o.groupNumber = g.push(null) - 1), _ = o.options ? this._randSelect(o.options) : o.stack, v = "", x = 0, S = _.length; x < S; x++) v += this._gen(_[x], g);
804
- return o.remember && (g[o.groupNumber] = v), v;
805
- case y.POSITION: return "";
806
- case y.SET:
807
- var C = this._expand(o);
808
- return C.length ? String.fromCharCode(this._randSelect(C)) : "";
809
- case y.REPETITION:
810
- for (b = this.randInt(o.min, o.max === Infinity ? o.min + this.max : o.max), v = "", x = 0; x < b; x++) v += this._gen(o.value, g);
811
- return v;
812
- case y.REFERENCE: return g[o.value - 1] || "";
813
- case y.CHAR:
814
- var w = this.ignoreCase && this._randBool() ? this._toOtherCase(o.value) : o.value;
815
- return String.fromCharCode(w);
768
+ for (o.remember && o.groupNumber === void 0 && (o.groupNumber = h.push(null) - 1), g = o.options ? this._randSelect(o.options) : o.stack, _ = "", b = 0, x = g.length; b < x; b++) _ += this._gen(g[b], h);
769
+ return o.remember && (h[o.groupNumber] = _), _;
770
+ case v.POSITION: return "";
771
+ case v.SET:
772
+ var S = this._expand(o);
773
+ return S.length ? String.fromCharCode(this._randSelect(S)) : "";
774
+ case v.REPETITION:
775
+ for (y = this.randInt(o.min, o.max === Infinity ? o.min + this.max : o.max), _ = "", b = 0; b < y; b++) _ += this._gen(o.value, h);
776
+ return _;
777
+ case v.REFERENCE: return h[o.value - 1] || "";
778
+ case v.CHAR:
779
+ var C = this.ignoreCase && this._randBool() ? this._toOtherCase(o.value) : o.value;
780
+ return String.fromCharCode(C);
816
781
  }
817
782
  }
818
783
  _toOtherCase(o) {
@@ -822,35 +787,35 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
822
787
  return !this.randInt(0, 1);
823
788
  }
824
789
  _randSelect(o) {
825
- return o instanceof v ? o.index(this.randInt(0, o.length - 1)) : o[this.randInt(0, o.length - 1)];
790
+ return o instanceof _ ? o.index(this.randInt(0, o.length - 1)) : o[this.randInt(0, o.length - 1)];
826
791
  }
827
792
  _expand(o) {
828
- if (o.type === _.types.CHAR) return new v(o.value);
829
- if (o.type === _.types.RANGE) return new v(o.from, o.to);
793
+ if (o.type === g.types.CHAR) return new _(o.value);
794
+ if (o.type === g.types.RANGE) return new _(o.from, o.to);
830
795
  {
831
- let g = new v();
832
- for (let _ = 0; _ < o.set.length; _++) {
833
- let v = this._expand(o.set[_]);
834
- if (g.add(v), this.ignoreCase) for (let o = 0; o < v.length; o++) {
835
- let _ = v.index(o), y = this._toOtherCase(_);
836
- _ !== y && g.add(y);
796
+ let h = new _();
797
+ for (let g = 0; g < o.set.length; g++) {
798
+ let _ = this._expand(o.set[g]);
799
+ if (h.add(_), this.ignoreCase) for (let o = 0; o < _.length; o++) {
800
+ let g = _.index(o), v = this._toOtherCase(g);
801
+ g !== v && h.add(v);
837
802
  }
838
803
  }
839
- return o.not ? this.defaultRange.clone().subtract(g) : this.defaultRange.clone().intersect(g);
804
+ return o.not ? this.defaultRange.clone().subtract(h) : this.defaultRange.clone().intersect(h);
840
805
  }
841
806
  }
842
- randInt(o, g) {
843
- return o + Math.floor(Math.random() * (1 + g - o));
807
+ randInt(o, h) {
808
+ return o + Math.floor(Math.random() * (1 + h - o));
844
809
  }
845
810
  get defaultRange() {
846
- return this._range = this._range || new v(32, 126);
811
+ return this._range = this._range || new _(32, 126);
847
812
  }
848
813
  set defaultRange(o) {
849
814
  this._range = o;
850
815
  }
851
- static randexp(g, _) {
852
- var v;
853
- return typeof g == "string" && (g = new RegExp(g, _)), g._randexp === void 0 ? (v = new o(g, _), g._randexp = v) : (v = g._randexp, v._setDefaults(g)), v.gen();
816
+ static randexp(h, g) {
817
+ var _;
818
+ return typeof h == "string" && (h = new RegExp(h, g)), h._randexp === void 0 ? (_ = new o(h, g), h._randexp = _) : (_ = h._randexp, _._setDefaults(h)), _.gen();
854
819
  }
855
820
  static sugar() {
856
821
  RegExp.prototype.gen = function() {
@@ -859,87 +824,87 @@ var require_types = /* @__PURE__ */ __commonJSMin(((o, g) => {
859
824
  }
860
825
  };
861
826
  })))());
862
- function indexOf(o, g, _ = 0) {
863
- let v = o.indexOf(g, _);
864
- return v >= 0 ? v : o.length;
827
+ function indexOf(o, h, g = 0) {
828
+ let _ = o.indexOf(h, g);
829
+ return _ >= 0 ? _ : o.length;
865
830
  }
866
831
  function pattern(o) {
867
- let g = new import_randexp.default(o);
868
- g.randInt = (o) => o;
869
- function _() {
870
- return t$1(t$3(0, 10), t$2(() => g.gen()), n$1());
832
+ let h = new import_randexp.default(o);
833
+ h.randInt = (o) => o;
834
+ function g() {
835
+ return t$1(t$3(0, 10), t$2(() => h.gen()), n$1());
871
836
  }
872
- let v = {
837
+ let _ = {
873
838
  type: "pattern",
874
839
  children: [],
875
840
  meta: { regex: o },
876
- suggestions: _,
877
- parse(g, _) {
878
- let y = new RegExp(o, "yu");
879
- y.lastIndex = 0;
880
- let b = y.exec(g);
881
- return b ? success({
882
- text: b[0],
883
- grammar: v,
841
+ suggestions: g,
842
+ parse(h, g) {
843
+ let v = new RegExp(o, "yu");
844
+ v.lastIndex = 0;
845
+ let y = v.exec(h);
846
+ return y ? success({
847
+ text: y[0],
848
+ grammar: _,
884
849
  children: []
885
850
  }) : error({
886
- path: _.path,
887
- got: g.substring(0, indexOf(g, "\n")),
888
- expected: v.suggestions(),
851
+ path: g.path,
852
+ got: h.substring(0, indexOf(h, "\n")),
853
+ expected: [o.toString()],
889
854
  offset: 0,
890
- grammar: v
855
+ grammar: _
891
856
  });
892
857
  }
893
858
  };
894
- return v;
859
+ return _;
895
860
  }
896
- function getCommonPrefix(o, g) {
897
- let _ = 0, v = Math.min(o.length, g.length);
898
- for (; _ < v && o[_] === g[_];) _++;
899
- return o.substring(0, _);
861
+ function getCommonPrefix(o, h) {
862
+ let g = 0, _ = Math.min(o.length, h.length);
863
+ for (; g < _ && o[g] === h[g];) g++;
864
+ return o.substring(0, g);
900
865
  }
901
866
  function isTotalFailureErrorLabel(o) {
902
867
  return o.errorLabel ? getCommonPrefix(o.text, o.errorLabel.got).length >= o.text.length / 2 : !1;
903
868
  }
904
- function repeat(o, g = 1, _ = 1e3) {
905
- let v = {
869
+ function repeat(o, h = 1, g = 1e3) {
870
+ let _ = {
906
871
  type: "repeat",
907
872
  children: [o],
908
873
  suggestions: () => o.suggestions(),
909
- parse(y, b) {
910
- let x = {
911
- ...b,
912
- path: [...b.path, v]
913
- }, S = 0, C = [], w = 0;
914
- for (; w < _ && S < y.length; w++) {
915
- let _ = y.substring(S), b = o.parse(_, x);
916
- if (isParserError(b) || isTotalFailureErrorLabel(b)) return w >= g ? success({
917
- grammar: v,
918
- children: C,
919
- text: y.substring(0, S)
874
+ parse(v, y) {
875
+ let b = {
876
+ ...y,
877
+ path: [...y.path, _]
878
+ }, x = 0, S = [], C = 0;
879
+ for (; C < g && x < v.length; C++) {
880
+ let g = v.substring(x), y = o.parse(g, b);
881
+ if (isParserError(y) || isTotalFailureErrorLabel(y)) return C >= h ? success({
882
+ grammar: _,
883
+ children: S,
884
+ text: v.substring(0, x)
920
885
  }) : {
921
- ...isParserError(b) ? b : b.errorLabel,
922
- offset: S
886
+ ...isParserError(y) ? y : y.errorLabel,
887
+ offset: x
923
888
  };
924
- if (b.errorLabel && w > g) break;
925
- S += b.text.length, C.push(b);
889
+ if (y.errorLabel && C > h) break;
890
+ x += y.text.length, S.push(y);
926
891
  }
927
- let T = w < g ? error({
892
+ let w = C < h ? error({
928
893
  expected: o.suggestions(),
929
- got: y,
930
- grammar: v,
931
- offset: S,
932
- path: x.path
933
- }) : pickFromErrorLabels(C)?.errorLabel;
894
+ got: v,
895
+ grammar: _,
896
+ offset: x,
897
+ path: b.path
898
+ }) : pickFromErrorLabels(S)?.errorLabel;
934
899
  return success({
935
- grammar: v,
936
- children: C,
937
- text: y.substring(0, S),
938
- errorLabel: T
900
+ grammar: _,
901
+ children: S,
902
+ text: v.substring(0, x),
903
+ errorLabel: w
939
904
  });
940
905
  }
941
906
  };
942
- return v;
907
+ return _;
943
908
  }
944
909
  const rational = pattern(/\d+(:?.\d+)?/);
945
910
  function optional(o) {
@@ -958,192 +923,195 @@ function regexEscape(o) {
958
923
  }
959
924
  const newline = pattern(/\n+|$/);
960
925
  newline.type = "newline";
961
- function findIndex(o, g, _) {
962
- for (let v = g; v < o.length; v++) if (_(o[v])) return v;
926
+ function deepPredicate(o, h) {
927
+ return h(o) || o.children.some(h);
928
+ }
929
+ function findIndex(o, h, g) {
930
+ for (let _ = h; _ < o.length; _++) if (deepPredicate(o[_], g)) return _;
963
931
  return -1;
964
932
  }
965
933
  function sequence(...o) {
966
- let g = {
934
+ let h = {
967
935
  children: o,
968
936
  type: "sequence",
969
937
  suggestions() {
970
- let g = [];
971
- for (let _ of o) {
972
- let o = _.suggestions();
973
- if (g.push(...o.filter((o) => o !== "")), !o.includes("")) break;
938
+ let h = [];
939
+ for (let g of o) {
940
+ let o = g.suggestions();
941
+ if (h.push(...o.filter((o) => o !== "")), !o.includes("")) break;
974
942
  }
975
- return g;
943
+ return h;
976
944
  },
977
- parse(_, v) {
978
- let y = {
979
- ...v,
980
- path: [...v.path, g]
981
- }, b = 0, x = [];
982
- for (let g = 0; g < o.length; g++) {
983
- let v = o[g], S = _.substring(b), C = v.parse(S, y);
984
- if (isParserError(C)) {
985
- let v = error({
986
- ...C,
987
- offset: C.offset + b
988
- }), y = findIndex(o, g, (o) => o.type === newline.type);
989
- if (y >= 0) {
990
- let o = indexOf(_, "\n", b), S = _.substring(b, y === g ? o + 1 : o);
991
- x.push({
992
- text: S,
993
- grammar: C.grammar,
945
+ parse(g, _) {
946
+ let v = {
947
+ ..._,
948
+ path: [..._.path, h]
949
+ }, y = 0, b = [];
950
+ for (let h = 0; h < o.length; h++) {
951
+ let _ = o[h], x = g.substring(y), S = _.parse(x, v);
952
+ if (isParserError(S)) {
953
+ let _ = error({
954
+ ...S,
955
+ offset: S.offset + y
956
+ }), v = findIndex(o, h, (o) => o.type === newline.type);
957
+ if (v >= 0) {
958
+ let o = indexOf(g, "\n", y), x = g.substring(y, v === h ? o + 1 : o);
959
+ b.push({
960
+ text: x,
961
+ grammar: S.grammar,
994
962
  children: [],
995
- errorLabel: v
996
- }), b += S.length, g = y - 1;
963
+ errorLabel: _
964
+ }), y += x.length, h = v - 1;
997
965
  continue;
998
966
  }
999
- return v;
967
+ return _;
1000
968
  }
1001
- b += C.text.length, x.push(C);
969
+ y += S.text.length, b.push(S);
1002
970
  }
1003
971
  return success({
1004
- grammar: g,
1005
- text: _.substring(0, b),
1006
- children: x,
1007
- errorLabel: pickFromErrorLabels(x)?.errorLabel
972
+ grammar: h,
973
+ text: g.substring(0, y),
974
+ children: b,
975
+ errorLabel: pickFromErrorLabels(b)?.errorLabel
1008
976
  });
1009
977
  }
1010
978
  };
1011
- return g;
979
+ return h;
1012
980
  }
1013
- function withOffset(o, g = 0) {
1014
- let _ = g;
981
+ function withOffset(o, h = 0) {
982
+ let g = h;
1015
983
  return {
1016
984
  text: o.text,
1017
- offset: g,
1018
- end: g + o.text.length,
1019
- children: o.children?.map((o, g, v) => {
1020
- let { text: y } = v[g - 1] ?? { text: "" };
1021
- return _ += y.length, withOffset(o, _);
985
+ offset: h,
986
+ end: h + o.text.length,
987
+ children: o.children?.map((o, h, _) => {
988
+ let { text: v } = _[h - 1] ?? { text: "" };
989
+ return g += v.length, withOffset(o, g);
1022
990
  }),
1023
991
  grammar: o.grammar,
1024
992
  recoverableError: !!o.errorLabel
1025
993
  };
1026
994
  }
1027
995
  function _flatCST(o) {
1028
- return o.children && !e(o.children) ? o.children.flatMap((o) => flatCST(o)) : [o];
996
+ return o.children && !e(o.children) ? t$1(o.children, t((o) => flatCST(o))) : [o];
1029
997
  }
1030
998
  function flatCST(o) {
1031
999
  return _flatCST(o).filter((o) => o.text !== "");
1032
1000
  }
1033
1001
  function topError(o) {
1034
- return isParserSuccess(o) ? [] : [{
1035
- message: o.expected.join(" or ") + ` expected (${pathToString(o.path)})`,
1002
+ return !o || isParserSuccess(o) ? [] : [{
1003
+ message: o.expected.map((o) => JSON.stringify(o)).join(" or ") + ` expected, but got ${JSON.stringify(o.got)} (${pathToString(o.path)})`,
1036
1004
  expected: o.expected,
1037
1005
  start: o.offset,
1038
- end: o.offset + Math.max(...o.expected.map((o) => o.length)),
1006
+ end: o.offset + Math.max(1, o.got.length),
1039
1007
  depth: 1
1040
1008
  }];
1041
1009
  }
1042
1010
  var DSLParser = class {
1043
1011
  grammar;
1044
1012
  constructor(o) {
1045
- this.grammar = sequence(o, newline, repeat(newline));
1013
+ this.grammar = sequence(o, repeat(newline, 0));
1046
1014
  }
1047
1015
  _parseStrict(o) {
1048
- let g = [], _ = this.grammar.parse(o, {
1016
+ let h = [], g = this.grammar.parse(o, {
1049
1017
  path: [],
1050
- handleTerminalError(o, _, v) {
1051
- let y = [..._.path, v];
1052
- return g.length < y.length && (g = y), error({
1053
- grammar: v,
1018
+ handleTerminalError(o, g, _) {
1019
+ let v = [...g.path, _];
1020
+ return h.length < v.length && (h = v), error({
1021
+ grammar: _,
1054
1022
  offset: 0,
1055
- expected: v.suggestions(),
1023
+ expected: _.suggestions(),
1056
1024
  got: o,
1057
- path: y
1025
+ path: v
1058
1026
  });
1059
1027
  }
1060
1028
  });
1061
1029
  return {
1062
- deepestErrorPath: g,
1063
- parserResult: _
1030
+ deepestErrorPath: h,
1031
+ parserResult: g
1064
1032
  };
1065
1033
  }
1066
1034
  parseStrict(o) {
1067
- let { parserResult: g } = this._parseStrict(o);
1068
- if (!isParserError(g)) return g;
1035
+ let { parserResult: h } = this._parseStrict(o);
1036
+ if (!isParserError(h)) return h;
1069
1037
  }
1070
1038
  parse(o) {
1071
- let { parserResult: g } = this._parseStrict(o);
1072
- if (isParserError(g)) throw asException(g);
1073
- let _ = withOffset(g), v = flatCST(_);
1039
+ let { parserResult: h } = this._parseStrict(o);
1040
+ if (isParserError(h)) throw asException(h);
1041
+ let g = withOffset(h), _ = flatCST(g);
1074
1042
  return {
1075
- cst: _,
1076
- terminals: v,
1077
- result: g,
1078
- strictResult: isParserSuccess(g) ? g : void 0,
1079
- errors: [...topError(g)]
1043
+ cst: g,
1044
+ terminals: _,
1045
+ result: h,
1046
+ strictResult: isParserSuccess(h) ? h : void 0,
1047
+ errors: [...topError(h), ...topError(h.errorLabel)]
1080
1048
  };
1081
1049
  }
1082
1050
  };
1083
- function visit(o, g, _ = (o) => o.text) {
1051
+ function visit(o, h, g = (o) => o.text) {
1084
1052
  return visitPredicate(o, (o) => {
1085
- let _ = nodeName(o);
1086
- return _ !== void 0 && g.includes(_);
1087
- }, _);
1053
+ let g = nodeName(o);
1054
+ return g !== void 0 && h.includes(g);
1055
+ }, g);
1088
1056
  }
1089
- function visitPredicate(o, g, _ = (o) => o.text) {
1090
- return isParserError(o) ? [] : (g(o) ? [_(o)] : []).concat(...o.children?.flatMap((o) => visitPredicate(o, g, _)) ?? []);
1057
+ function visitPredicate(o, h, g = (o) => o.text) {
1058
+ return isParserError(o) ? [] : (h(o) ? [g(o)] : []).concat(...o.children?.flatMap((o) => visitPredicate(o, h, g)) ?? []);
1091
1059
  }
1092
- function getSuggestions(o, g, _ = () => void 0) {
1093
- let v = cstPathAt(o, g), y = t$1(v, t((o) => {
1060
+ function getSuggestions(o, h, g = () => void 0) {
1061
+ let _ = cstPathAt(o, h), v = t$1(_, t((o) => {
1094
1062
  if (nodeName(o) !== void 0) {
1095
- let g = _(o);
1096
- if (g) return g.map((g) => ({
1063
+ let h = g(o);
1064
+ if (h) return h.map((h) => ({
1097
1065
  node: o,
1098
- suggestion: g
1066
+ suggestion: h
1099
1067
  }));
1100
1068
  }
1101
- return o.grammar.suggestions().map((g) => ({
1069
+ return o.grammar.suggestions().map((h) => ({
1102
1070
  node: o,
1103
- suggestion: g
1071
+ suggestion: h
1104
1072
  }));
1105
1073
  }));
1106
- return t$1(y, t((o) => {
1107
- let _ = o.node.text.substring(0, g - o.node.offset);
1108
- return o.suggestion.startsWith(_) && o.suggestion.trim().length > 0 ? [{
1074
+ return t$1(v, t((o) => {
1075
+ let g = o.node.text.substring(0, h - o.node.offset);
1076
+ return o.suggestion.startsWith(g) && o.suggestion.trim().length > 0 ? [{
1109
1077
  suggestion: o.suggestion,
1110
- prefix: _
1078
+ prefix: g
1111
1079
  }] : [];
1112
1080
  }), n((o) => o.suggestion));
1113
1081
  }
1114
- const CursorPosition = forwardRef(function(o, g) {
1115
- let _ = useRef(null), v = useRef(null);
1116
- return useImperativeHandle(g, () => ({ getCursorPosition() {
1117
- if (!_.current || !v.current) return {
1082
+ const CursorPosition = forwardRef(function(o, h) {
1083
+ let g = useRef(null), _ = useRef(null);
1084
+ return useImperativeHandle(h, () => ({ getCursorPosition() {
1085
+ if (!g.current || !_.current) return {
1118
1086
  top: 0,
1119
1087
  left: 0
1120
1088
  };
1121
- let { offsetTop: o, offsetLeft: g } = _.current, { scrollTop: y, scrollLeft: b } = v.current, x = window.getComputedStyle(v.current), S = parseInt(x.lineHeight);
1089
+ let { offsetTop: o, offsetLeft: h } = g.current, { scrollTop: v, scrollLeft: y } = _.current, b = window.getComputedStyle(_.current), x = parseInt(b.lineHeight);
1122
1090
  return {
1123
- top: o - y + S,
1124
- left: g - b
1091
+ top: o - v + x,
1092
+ left: h - y
1125
1093
  };
1126
1094
  } }), []), /* @__PURE__ */ jsxs(ReadOnlyTextarea, {
1127
- ref: v,
1095
+ ref: _,
1128
1096
  wrap: o.wrap,
1129
1097
  style: { visibility: "hidden" },
1130
1098
  children: [o.text, /* @__PURE__ */ jsx("span", {
1131
- ref: _,
1099
+ ref: g,
1132
1100
  children: "\xA0"
1133
1101
  })]
1134
1102
  });
1135
1103
  });
1136
1104
  function shortcutName(o) {
1137
- let g = "";
1138
- o.ctrlKey && (g = "Ctrl");
1139
- let { key: _ } = o;
1140
- return _ === " " && (_ = "Space"), `${g}${_}`;
1105
+ let h = "";
1106
+ o.ctrlKey && (h = "Ctrl");
1107
+ let { key: g } = o;
1108
+ return g === " " && (g = "Space"), `${h}${g}`;
1141
1109
  }
1142
1110
  function useSyncScroll(...o) {
1143
- return useCallback((g) => {
1144
- let _ = g.currentTarget;
1111
+ return useCallback((h) => {
1112
+ let g = h.currentTarget;
1145
1113
  o.forEach((o) => {
1146
- o.current && _ && (o.current.scrollTop = _.scrollTop, o.current.scrollLeft = _.scrollLeft);
1114
+ o.current && g && (o.current.scrollTop = g.scrollTop, o.current.scrollLeft = g.scrollLeft);
1147
1115
  });
1148
1116
  }, [o]);
1149
1117
  }
@@ -1177,27 +1145,111 @@ var themes = {
1177
1145
  "#99CCFF"
1178
1146
  ]
1179
1147
  };
1180
- function cyrb53(o, g = 0) {
1181
- let _ = 3735928559 ^ g, v = 1103547991 ^ g;
1182
- for (let g = 0, y; g < o.length; g++) y = o.charCodeAt(g), _ = Math.imul(_ ^ y, 2654435761), v = Math.imul(v ^ y, 1597334677);
1183
- return _ = Math.imul(_ ^ _ >>> 16, 2246822507), _ ^= Math.imul(v ^ v >>> 13, 3266489909), v = Math.imul(v ^ v >>> 16, 2246822507), v ^= Math.imul(_ ^ _ >>> 13, 3266489909), 4294967296 * (2097151 & v) + (_ >>> 0);
1148
+ function cyrb53(o, h = 0) {
1149
+ let g = 3735928559 ^ h, _ = 1103547991 ^ h;
1150
+ for (let h = 0, v; h < o.length; h++) v = o.charCodeAt(h), g = Math.imul(g ^ v, 2654435761), _ = Math.imul(_ ^ v, 1597334677);
1151
+ return g = Math.imul(g ^ g >>> 16, 2246822507), g ^= Math.imul(_ ^ _ >>> 13, 3266489909), _ = Math.imul(_ ^ _ >>> 16, 2246822507), _ ^= Math.imul(g ^ g >>> 13, 3266489909), 4294967296 * (2097151 & _) + (g >>> 0);
1184
1152
  }
1185
- function getColorAssigment(o, g) {
1186
- let _ = cyrb53(String(o)) % g.length;
1187
- return g[_];
1153
+ function getColorAssigment(o, h) {
1154
+ let g = cyrb53(String(o)) % h.length;
1155
+ return h[g];
1188
1156
  }
1189
- function defaultStyleFor(o, g) {
1190
- let { name: _, regex: v } = o.grammar.meta ?? {}, y = _ ?? v;
1191
- if (y) return { color: getColorAssigment(y, g) };
1157
+ function defaultStyleFor(o, h) {
1158
+ let { name: g, regex: _ } = o.grammar.meta ?? {}, v = g ?? _;
1159
+ if (v) return { color: getColorAssigment(v, h) };
1192
1160
  }
1193
1161
  function defaultSyntaxColors(o) {
1194
- return (g) => defaultStyleFor(g, themes[o]);
1162
+ return (h) => defaultStyleFor(h, themes[o]);
1163
+ }
1164
+ function disjointIntervals(o) {
1165
+ if (o.length === 0) return [];
1166
+ let h = [...o].sort((o, h) => o.start - h.start), g = [h[0]];
1167
+ for (let o = 1; o < h.length; o++) {
1168
+ let _ = h[o], v = g[g.length - 1];
1169
+ _.start >= v.end ? g.push(_) : _.end > v.end && (g[g.length - 1] = {
1170
+ ...v,
1171
+ end: _.end
1172
+ });
1173
+ }
1174
+ return g;
1175
+ }
1176
+ function decorateIntervals(h, g, _) {
1177
+ let v = [], y = 0;
1178
+ return h.forEach((h, b) => {
1179
+ h.start > y && v.push(/* @__PURE__ */ jsx(Fragment, { children: g.substring(y, h.start) }, `text-${b}`)), v.push(_(g.substring(h.start, h.end), h, b)), y = h.end;
1180
+ }), y < g.length && v.push(/* @__PURE__ */ jsx(Fragment, { children: g.substring(y) }, "text-end")), v;
1181
+ }
1182
+ var squiggly = {
1183
+ textDecorationLine: "underline",
1184
+ textDecorationStyle: "wavy",
1185
+ textDecorationColor: "red"
1186
+ };
1187
+ const ErrorHighlighter = forwardRef(function(o, h) {
1188
+ let g = `${o.children} `, v = disjointIntervals(o.errors), [y, b] = useState();
1189
+ useEffect(() => {
1190
+ let o = (o) => {
1191
+ if (!h || !("current" in h) || !h.current) return;
1192
+ let g = elementBoundingPosition(h.current.querySelectorAll("span[title]"), o);
1193
+ b(g ? {
1194
+ ...g,
1195
+ message: g.element.title
1196
+ } : void 0);
1197
+ };
1198
+ return document.addEventListener("mousemove", o), () => document.removeEventListener("mousemove", o);
1199
+ }, [h]);
1200
+ let { style: T,...E } = o.tooltipProps;
1201
+ return v.length === 0 ? /* @__PURE__ */ jsx(Fragment$1, {}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ReadOnlyTextarea, {
1202
+ ref: h,
1203
+ wrap: o.wrap,
1204
+ style: { color: "transparent" },
1205
+ children: decorateIntervals(v, g, (o, h, g) => /* @__PURE__ */ jsx("span", {
1206
+ style: squiggly,
1207
+ title: h.message,
1208
+ children: o
1209
+ }, `error-${g}`))
1210
+ }), y && /* @__PURE__ */ jsx(Tooltip, {
1211
+ ...E,
1212
+ style: {
1213
+ left: y.x,
1214
+ top: y.y,
1215
+ ...T
1216
+ },
1217
+ onClick: () => b(void 0),
1218
+ children: y.message
1219
+ })] });
1220
+ });
1221
+ function Tooltip(o) {
1222
+ let { style: h, children: g,..._ } = o;
1223
+ return /* @__PURE__ */ jsx("div", {
1224
+ ..._,
1225
+ style: {
1226
+ position: "fixed",
1227
+ margin: 4,
1228
+ padding: "4px 8px",
1229
+ borderRadius: "4px",
1230
+ fontSize: "12px",
1231
+ zIndex: 1e3,
1232
+ whiteSpace: "nowrap",
1233
+ ...h
1234
+ },
1235
+ children: g
1236
+ });
1237
+ }
1238
+ function elementBoundingPosition(o, h) {
1239
+ for (let g = 0; g < o.length; g++) {
1240
+ let _ = o[g], v = _.getBoundingClientRect();
1241
+ if (h.clientX >= v.left && h.clientX <= v.right && h.clientY >= v.top && h.clientY <= v.bottom) return {
1242
+ x: v.left,
1243
+ y: v.bottom,
1244
+ element: _
1245
+ };
1246
+ }
1195
1247
  }
1196
- function SuggestionsMenu({ suggestions: o, onSelect: g, style: _, selectedIndex: v, onHover: y }) {
1248
+ function SuggestionsMenu({ suggestions: o, onSelect: h, style: g, selectedIndex: _, onHover: v }) {
1197
1249
  return /* @__PURE__ */ jsx("div", {
1198
1250
  style: {
1199
1251
  position: "absolute",
1200
- ..._,
1252
+ ...g,
1201
1253
  background: "#252526",
1202
1254
  border: "1px solid #454545",
1203
1255
  boxShadow: "0 2px 8px rgba(0,0,0,0.3)",
@@ -1207,51 +1259,51 @@ function SuggestionsMenu({ suggestions: o, onSelect: g, style: _, selectedIndex:
1207
1259
  minWidth: 200,
1208
1260
  zIndex: 100
1209
1261
  },
1210
- children: o.map((o, _) => /* @__PURE__ */ jsx("div", {
1211
- onClick: () => g(o),
1212
- onMouseOver: () => y(_),
1262
+ children: o.map((o, g) => /* @__PURE__ */ jsx("div", {
1263
+ onClick: () => h(o),
1264
+ onMouseOver: () => v(g),
1213
1265
  style: {
1214
1266
  cursor: "pointer",
1215
1267
  padding: "4px 8px",
1216
- backgroundColor: v === _ ? "#094771" : "transparent"
1268
+ backgroundColor: _ === g ? "#094771" : "transparent"
1217
1269
  },
1218
1270
  children: o.suggestion
1219
- }, _))
1271
+ }, g))
1220
1272
  });
1221
1273
  }
1222
- function DslEditor({ code: o, onChange: g, onParsed: y, grammar: C, wrap: E = !1, suggestions: D, className: O = DslEditor.name, syntaxColors: k = defaultSyntaxColors("light"),...A }) {
1223
- let [j, M] = useState([]), [N, P] = useState(), [I, L] = useState({
1274
+ function DslEditor({ code: o, onChange: h, onParsed: v, grammar: S, wrap: T = !1, tooltipProps: E = { style: { backgroundColor: "darkGray" } }, suggestions: D, className: O = DslEditor.name, syntaxColors: k = defaultSyntaxColors("light"),...A }) {
1275
+ let [j, M] = useState([]), [N, F] = useState(), [I, L] = useState({
1224
1276
  top: 0,
1225
1277
  left: 0,
1226
1278
  visible: !1
1227
1279
  }), [R, z] = useState(0), [B, V] = useState(""), H = useRef(null), U = useRef(null), W = useRef(null), G = useRef(null), K = useCallback((o) => {
1228
- let g = H.current?.selectionStart ?? 0, _ = getSuggestions(o, g, D);
1229
- return M(_), _;
1280
+ let h = H.current?.selectionStart ?? 0, g = getSuggestions(o, h, D);
1281
+ return M(g), g;
1230
1282
  }, [D]), q = useCallback(() => {
1231
1283
  N && V(H.current?.value?.substring(0, H.current?.selectionStart ?? 0) ?? "");
1232
1284
  }, [N]);
1233
1285
  useEffect(() => {
1234
- let g = new DSLParser(C).parse(o);
1235
- P(g), y?.(g), K(g.cst), V(o.substring(0, H.current?.selectionStart ?? 0));
1286
+ let h = new DSLParser(S).parse(o);
1287
+ F(h), v?.(h), K(h.cst), V(o.substring(0, H.current?.selectionStart ?? 0));
1236
1288
  }, [
1237
1289
  o,
1238
- y,
1239
- C,
1290
+ v,
1291
+ S,
1240
1292
  K
1241
1293
  ]);
1242
1294
  let J = useCallback(() => U.current?.getCursorPosition?.() ?? {
1243
1295
  top: 0,
1244
1296
  left: 0
1245
- }, []), Y = useCallback((_) => {
1297
+ }, []), Y = useCallback((g) => {
1246
1298
  if (!H.current) return;
1247
- let { selectionStart: v, selectionEnd: y } = H.current, { prefix: b } = _, x = o.substring(0, v - b.length) + _.suggestion + o.substring(y);
1248
- g(x), setTimeout(() => {
1249
- H.current && (H.current.focus(), H.current.selectionStart = H.current.selectionEnd = v - b.length + _.suggestion.length);
1299
+ let { selectionStart: _, selectionEnd: v } = H.current, { prefix: y } = g, b = o.substring(0, _ - y.length) + g.suggestion + o.substring(v);
1300
+ h(b), setTimeout(() => {
1301
+ H.current && (H.current.focus(), H.current.selectionStart = H.current.selectionEnd = _ - y.length + g.suggestion.length);
1250
1302
  }, 0), L((o) => ({
1251
1303
  ...o,
1252
1304
  visible: !1
1253
1305
  }));
1254
- }, [o, g]), X = useMemo(() => ({
1306
+ }, [o, h]), X = useMemo(() => ({
1255
1307
  ArrowDown() {
1256
1308
  z((o) => (o + 1) % j.length);
1257
1309
  },
@@ -1275,29 +1327,29 @@ function DslEditor({ code: o, onChange: g, onParsed: y, grammar: C, wrap: E = !1
1275
1327
  if (!N?.cst) return;
1276
1328
  let o = K(N?.cst);
1277
1329
  if (e(o)) return;
1278
- let { top: g, left: _ } = J();
1330
+ let { top: h, left: g } = J();
1279
1331
  z(0), L({
1280
1332
  visible: !0,
1281
- top: g,
1282
- left: _
1333
+ top: h,
1334
+ left: g
1283
1335
  });
1284
1336
  } }), [
1285
1337
  J,
1286
1338
  N?.cst,
1287
1339
  K
1288
1340
  ]), Q = useCallback((o) => {
1289
- let g = (I.visible ? X : Z)[shortcutName(o)];
1290
- g && (o.preventDefault(), g());
1341
+ let h = (I.visible ? X : Z)[shortcutName(o)];
1342
+ h && (o.preventDefault(), h());
1291
1343
  }, [
1292
1344
  I.visible,
1293
1345
  X,
1294
1346
  Z
1295
1347
  ]), $ = useCallback((o) => {
1296
- g(o.target.value), L((o) => ({
1348
+ h(o.target.value), L((o) => ({
1297
1349
  ...o,
1298
1350
  visible: !1
1299
1351
  })), V(o.target.value.substring(0, o.target.selectionStart));
1300
- }, [g]);
1352
+ }, [h]);
1301
1353
  return /* @__PURE__ */ jsx("div", {
1302
1354
  style: {
1303
1355
  display: "grid",
@@ -1317,14 +1369,8 @@ function DslEditor({ code: o, onChange: g, onParsed: y, grammar: C, wrap: E = !1
1317
1369
  /* @__PURE__ */ jsx("textarea", {
1318
1370
  ref: H,
1319
1371
  spellCheck: !1,
1320
- wrap: E ? "soft" : "off",
1321
- style: {
1322
- ...textStyle,
1323
- color: "transparent",
1324
- background: "transparent",
1325
- border: "none",
1326
- resize: "none"
1327
- },
1372
+ wrap: T ? "soft" : "off",
1373
+ style: textStyle,
1328
1374
  value: o,
1329
1375
  onSelect: q,
1330
1376
  onChange: $,
@@ -1335,19 +1381,20 @@ function DslEditor({ code: o, onChange: g, onParsed: y, grammar: C, wrap: E = !1
1335
1381
  N && /* @__PURE__ */ jsx(SyntaxHighlighter, {
1336
1382
  cstRoot: N.cst,
1337
1383
  ref: W,
1338
- wrap: E,
1384
+ wrap: T,
1339
1385
  syntaxColors: k
1340
1386
  }),
1341
1387
  !e(N?.errors ?? []) && /* @__PURE__ */ jsx(ErrorHighlighter, {
1342
1388
  ref: G,
1343
1389
  errors: N?.errors ?? [],
1344
- wrap: E,
1390
+ tooltipProps: E,
1391
+ wrap: T,
1345
1392
  children: o
1346
1393
  }),
1347
1394
  /* @__PURE__ */ jsx(CursorPosition, {
1348
1395
  ref: U,
1349
1396
  text: B,
1350
- wrap: E
1397
+ wrap: T
1351
1398
  }),
1352
1399
  I.visible && j.length > 0 && /* @__PURE__ */ jsx(SuggestionsMenu, {
1353
1400
  suggestions: j,