@stream-mdx/react 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +385 -4
  2. package/README.md +141 -16
  3. package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
  4. package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
  5. package/dist/components/bottom-stick-scroll-area.cjs +268 -0
  6. package/dist/components/bottom-stick-scroll-area.d.cts +36 -0
  7. package/dist/components/bottom-stick-scroll-area.d.ts +36 -0
  8. package/dist/components/bottom-stick-scroll-area.mjs +249 -0
  9. package/dist/components/diff-renderer.cjs +86 -0
  10. package/dist/components/diff-renderer.d.cts +11 -0
  11. package/dist/components/diff-renderer.d.ts +11 -0
  12. package/dist/components/diff-renderer.mjs +66 -0
  13. package/dist/components/index.cjs +2879 -1295
  14. package/dist/components/index.d.cts +9 -2
  15. package/dist/components/index.d.ts +9 -2
  16. package/dist/components/index.mjs +2842 -1277
  17. package/dist/components/katex-math.cjs +220 -0
  18. package/dist/components/katex-math.d.cts +10 -0
  19. package/dist/components/katex-math.d.ts +10 -0
  20. package/dist/components/katex-math.mjs +188 -0
  21. package/dist/contexts/math-tracker.cjs +240 -521
  22. package/dist/contexts/math-tracker.mjs +235 -513
  23. package/dist/index-Cmne1yUK.d.cts +723 -0
  24. package/dist/index-D7dyyu3q.d.ts +723 -0
  25. package/dist/index.cjs +13180 -5640
  26. package/dist/index.d.cts +72 -40
  27. package/dist/index.d.ts +72 -40
  28. package/dist/index.mjs +12587 -5038
  29. package/dist/math/display-wrapper.cjs +7 -15
  30. package/dist/math/display-wrapper.d.cts +2 -2
  31. package/dist/math/display-wrapper.d.ts +2 -2
  32. package/dist/math/display-wrapper.mjs +2 -6
  33. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  34. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  35. package/dist/renderer/hooks.cjs +35 -20
  36. package/dist/renderer/hooks.d.cts +22 -1
  37. package/dist/renderer/hooks.d.ts +22 -1
  38. package/dist/renderer/hooks.mjs +27 -12
  39. package/dist/renderer/patch-batching.cjs +7 -8
  40. package/dist/renderer/patch-batching.d.cts +1 -1
  41. package/dist/renderer/patch-batching.d.ts +1 -1
  42. package/dist/renderer/patch-batching.mjs +2 -1
  43. package/dist/renderer/patch-coalescing.cjs +5 -8
  44. package/dist/renderer/patch-commit-scheduler.cjs +160 -326
  45. package/dist/renderer/patch-commit-scheduler.d.cts +28 -4
  46. package/dist/renderer/patch-commit-scheduler.d.ts +28 -4
  47. package/dist/renderer/patch-commit-scheduler.mjs +157 -318
  48. package/dist/renderer/store.cjs +3847 -1099
  49. package/dist/renderer/store.d.cts +111 -3
  50. package/dist/renderer/store.d.ts +111 -3
  51. package/dist/renderer/store.mjs +3847 -1085
  52. package/dist/renderer/virtualized-code.cjs +415 -71
  53. package/dist/renderer/virtualized-code.d.cts +24 -23
  54. package/dist/renderer/virtualized-code.d.ts +24 -23
  55. package/dist/renderer/virtualized-code.mjs +409 -62
  56. package/dist/renderer.cjs +10939 -3974
  57. package/dist/renderer.d.cts +100 -29
  58. package/dist/renderer.d.ts +100 -29
  59. package/dist/renderer.mjs +10711 -3697
  60. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  61. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  62. package/dist/server.cjs +10286 -3365
  63. package/dist/server.d.cts +17 -247
  64. package/dist/server.d.ts +17 -247
  65. package/dist/server.mjs +10565 -3619
  66. package/dist/{streaming-markdown-DOc2uLiP.d.ts → streaming-markdown-yELbJxyH.d.ts} +51 -55
  67. package/dist/{streaming-markdown-D-JcByd9.d.cts → streaming-markdown-zVwFuaJG.d.cts} +51 -55
  68. package/dist/streaming-markdown.cjs +11828 -4879
  69. package/dist/streaming-markdown.d.cts +9 -2
  70. package/dist/streaming-markdown.d.ts +9 -2
  71. package/dist/streaming-markdown.mjs +11820 -4821
  72. package/dist/trusted-mdx/index.cjs +833 -0
  73. package/dist/trusted-mdx/index.d.cts +11 -0
  74. package/dist/trusted-mdx/index.d.ts +11 -0
  75. package/dist/trusted-mdx/index.mjs +807 -0
  76. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  77. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  78. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  79. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  80. package/dist/trusted-mdx/server.cjs +752 -0
  81. package/dist/trusted-mdx/server.d.cts +24 -0
  82. package/dist/trusted-mdx/server.d.ts +24 -0
  83. package/dist/trusted-mdx/server.mjs +724 -0
  84. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  85. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  86. package/dist/utils/inline-html.cjs +246 -147
  87. package/dist/utils/inline-html.d.cts +39 -6
  88. package/dist/utils/inline-html.d.ts +39 -6
  89. package/dist/utils/inline-html.mjs +237 -134
  90. package/package.json +52 -18
  91. package/shadcn/README.md +28 -0
  92. package/shadcn/bottom-stick-scroll-area.tsx +358 -0
  93. package/dist/index-D2MYusAM.d.cts +0 -248
  94. package/dist/index-D2MYusAM.d.ts +0 -248
  95. package/dist/mdx-client.cjs +0 -408
  96. package/dist/mdx-client.d.cts +0 -113
  97. package/dist/mdx-client.d.ts +0 -113
  98. package/dist/mdx-client.mjs +0 -369
  99. package/dist/mdx-coordinator.cjs +0 -563
  100. package/dist/mdx-coordinator.d.cts +0 -21
  101. package/dist/mdx-coordinator.d.ts +0 -21
  102. package/dist/mdx-coordinator.mjs +0 -529
  103. package/dist/renderer/node-views.cjs +0 -1642
  104. package/dist/renderer/node-views.d.cts +0 -12
  105. package/dist/renderer/node-views.d.ts +0 -12
  106. package/dist/renderer/node-views.mjs +0 -1616
@@ -6,17 +6,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
8
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
13
12
  for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  return to;
18
15
  };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
20
17
 
21
18
  // src/contexts/math-tracker.ts
22
19
  var math_tracker_exports = {};
@@ -27,19 +24,15 @@ __export(math_tracker_exports, {
27
24
  module.exports = __toCommonJS(math_tracker_exports);
28
25
 
29
26
  // ../../node_modules/@lezer/common/dist/index.js
30
- var DefaultBufferLength = 1024;
31
27
  var nextPropID = 0;
32
28
  var NodeProp = class {
33
29
  /**
34
30
  Create a new node prop type.
35
31
  */
36
32
  constructor(config = {}) {
37
- this.id = nextPropID++;
38
- this.perNode = !!config.perNode;
39
- this.deserialize = config.deserialize || (() => {
33
+ this.id = nextPropID++, this.perNode = !!config.perNode, this.deserialize = config.deserialize || (() => {
40
34
  throw new Error("This node type doesn't define a deserialize function");
41
- });
42
- this.combine = config.combine || null;
35
+ }), this.combine = config.combine || null;
43
36
  }
44
37
  /**
45
38
  This is meant to be used with
@@ -53,9 +46,7 @@ var NodeProp = class {
53
46
  add(match) {
54
47
  if (this.perNode)
55
48
  throw new RangeError("Can't add per-node props to node types");
56
- if (typeof match != "function")
57
- match = NodeType.match(match);
58
- return (type) => {
49
+ return typeof match != "function" && (match = NodeType.match(match)), (type) => {
59
50
  let result = match(type);
60
51
  return result === void 0 ? null : [this, result];
61
52
  };
@@ -69,14 +60,12 @@ NodeProp.isolate = new NodeProp({ deserialize: (value) => {
69
60
  throw new RangeError("Invalid value for isolate: " + value);
70
61
  return value || "auto";
71
62
  } });
72
- NodeProp.contextHash = new NodeProp({ perNode: true });
73
- NodeProp.lookAhead = new NodeProp({ perNode: true });
74
- NodeProp.mounted = new NodeProp({ perNode: true });
63
+ NodeProp.contextHash = new NodeProp({ perNode: !0 });
64
+ NodeProp.lookAhead = new NodeProp({ perNode: !0 });
65
+ NodeProp.mounted = new NodeProp({ perNode: !0 });
75
66
  var MountedTree = class {
76
67
  constructor(tree, overlay, parser) {
77
- this.tree = tree;
78
- this.overlay = overlay;
79
- this.parser = parser;
68
+ this.tree = tree, this.overlay = overlay, this.parser = parser;
80
69
  }
81
70
  /**
82
71
  @internal
@@ -84,35 +73,26 @@ var MountedTree = class {
84
73
  static get(tree) {
85
74
  return tree && tree.props && tree.props[NodeProp.mounted.id];
86
75
  }
87
- };
88
- var noProps = /* @__PURE__ */ Object.create(null);
89
- var NodeType = class _NodeType {
76
+ }, noProps = /* @__PURE__ */ Object.create(null), NodeType = class _NodeType {
90
77
  /**
91
78
  @internal
92
79
  */
93
80
  constructor(name, props, id2, flags = 0) {
94
- this.name = name;
95
- this.props = props;
96
- this.id = id2;
97
- this.flags = flags;
81
+ this.name = name, this.props = props, this.id = id2, this.flags = flags;
98
82
  }
99
83
  /**
100
84
  Define a node type.
101
85
  */
102
86
  static define(spec) {
103
- let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
104
- let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
105
- let type = new _NodeType(spec.name || "", props, spec.id, flags);
106
- if (spec.props)
107
- for (let src of spec.props) {
108
- if (!Array.isArray(src))
109
- src = src(type);
110
- if (src) {
87
+ let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps, flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0), type = new _NodeType(spec.name || "", props, spec.id, flags);
88
+ if (spec.props) {
89
+ for (let src of spec.props)
90
+ if (Array.isArray(src) || (src = src(type)), src) {
111
91
  if (src[0].perNode)
112
92
  throw new RangeError("Can't store a per-node prop on a node type");
113
93
  props[src[0].id] = src[1];
114
94
  }
115
- }
95
+ }
116
96
  return type;
117
97
  }
118
98
  /**
@@ -154,9 +134,9 @@ var NodeType = class _NodeType {
154
134
  is(name) {
155
135
  if (typeof name == "string") {
156
136
  if (this.name == name)
157
- return true;
137
+ return !0;
158
138
  let group = this.prop(NodeProp.group);
159
- return group ? group.indexOf(name) > -1 : false;
139
+ return group ? group.indexOf(name) > -1 : !1;
160
140
  }
161
141
  return this.id == name;
162
142
  }
@@ -189,26 +169,16 @@ NodeType.none = new NodeType(
189
169
  8
190
170
  /* NodeFlag.Anonymous */
191
171
  );
192
- var CachedNode = /* @__PURE__ */ new WeakMap();
193
- var CachedInnerNode = /* @__PURE__ */ new WeakMap();
194
- var IterMode;
172
+ var CachedNode = /* @__PURE__ */ new WeakMap(), CachedInnerNode = /* @__PURE__ */ new WeakMap(), IterMode;
195
173
  (function(IterMode2) {
196
- IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
197
- IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
198
- IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
199
- IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
174
+ IterMode2[IterMode2.ExcludeBuffers = 1] = "ExcludeBuffers", IterMode2[IterMode2.IncludeAnonymous = 2] = "IncludeAnonymous", IterMode2[IterMode2.IgnoreMounts = 4] = "IgnoreMounts", IterMode2[IterMode2.IgnoreOverlays = 8] = "IgnoreOverlays";
200
175
  })(IterMode || (IterMode = {}));
201
176
  var Tree = class _Tree {
202
177
  /**
203
178
  Construct a new tree. See also [`Tree.build`](#common.Tree^build).
204
179
  */
205
180
  constructor(type, children, positions, length, props) {
206
- this.type = type;
207
- this.children = children;
208
- this.positions = positions;
209
- this.length = length;
210
- this.props = null;
211
- if (props && props.length) {
181
+ if (this.type = type, this.children = children, this.positions = positions, this.length = length, this.props = null, props && props.length) {
212
182
  this.props = /* @__PURE__ */ Object.create(null);
213
183
  for (let [prop, value] of props)
214
184
  this.props[typeof prop == "number" ? prop : prop.id] = value;
@@ -224,13 +194,9 @@ var Tree = class _Tree {
224
194
  let children = "";
225
195
  for (let ch of this.children) {
226
196
  let str = ch.toString();
227
- if (str) {
228
- if (children)
229
- children += ",";
230
- children += str;
231
- }
197
+ str && (children && (children += ","), children += str);
232
198
  }
233
- return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
199
+ return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "") : children;
234
200
  }
235
201
  /**
236
202
  Get a [tree cursor](#common.TreeCursor) positioned at the top of
@@ -246,11 +212,8 @@ var Tree = class _Tree {
246
212
  [`moveTo`](#common.TreeCursor.moveTo).
247
213
  */
248
214
  cursorAt(pos, side = 0, mode = 0) {
249
- let scope = CachedNode.get(this) || this.topNode;
250
- let cursor = new TreeCursor(scope);
251
- cursor.moveTo(pos, side);
252
- CachedNode.set(this, cursor._tree);
253
- return cursor;
215
+ let scope = CachedNode.get(this) || this.topNode, cursor = new TreeCursor(scope);
216
+ return cursor.moveTo(pos, side), CachedNode.set(this, cursor._tree), cursor;
254
217
  }
255
218
  /**
256
219
  Get a [syntax node](#common.SyntaxNode) object for the top of the
@@ -271,9 +234,8 @@ var Tree = class _Tree {
271
234
  [`resolveInner`](#common.Tree.resolveInner) instead.
272
235
  */
273
236
  resolve(pos, side = 0) {
274
- let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
275
- CachedNode.set(this, node);
276
- return node;
237
+ let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, !1);
238
+ return CachedNode.set(this, node), node;
277
239
  }
278
240
  /**
279
241
  Like [`resolve`](#common.Tree.resolve), but will enter
@@ -283,9 +245,8 @@ var Tree = class _Tree {
283
245
  the host trees).
284
246
  */
285
247
  resolveInner(pos, side = 0) {
286
- let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
287
- CachedInnerNode.set(this, node);
288
- return node;
248
+ let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, !0);
249
+ return CachedInnerNode.set(this, node), node;
289
250
  }
290
251
  /**
291
252
  In some situations, it can be useful to iterate through all
@@ -305,23 +266,18 @@ var Tree = class _Tree {
305
266
  not have its children iterated over (or `leave` called).
306
267
  */
307
268
  iterate(spec) {
308
- let { enter, leave, from = 0, to = this.length } = spec;
309
- let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
269
+ let { enter, leave, from = 0, to = this.length } = spec, mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
310
270
  for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
311
- let entered = false;
312
- if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
271
+ let entered = !1;
272
+ if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== !1)) {
313
273
  if (c.firstChild())
314
274
  continue;
315
- entered = true;
275
+ entered = !0;
316
276
  }
317
- for (; ; ) {
318
- if (entered && leave && (anon || !c.type.isAnonymous))
319
- leave(c);
320
- if (c.nextSibling())
321
- break;
277
+ for (; entered && leave && (anon || !c.type.isAnonymous) && leave(c), !c.nextSibling(); ) {
322
278
  if (!c.parent())
323
279
  return;
324
- entered = true;
280
+ entered = !0;
325
281
  }
326
282
  }
327
283
  }
@@ -330,7 +286,7 @@ var Tree = class _Tree {
330
286
  node. Works with both per-node and per-type props.
331
287
  */
332
288
  prop(prop) {
333
- return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
289
+ return prop.perNode ? this.props ? this.props[prop.id] : void 0 : this.type.prop(prop);
334
290
  }
335
291
  /**
336
292
  Returns the node's [per-node props](#common.NodeProp.perNode) in a
@@ -363,8 +319,7 @@ var Tree = class _Tree {
363
319
  Tree.empty = new Tree(NodeType.none, [], [], 0);
364
320
  var FlatBufferCursor = class _FlatBufferCursor {
365
321
  constructor(buffer, index) {
366
- this.buffer = buffer;
367
- this.index = index;
322
+ this.buffer = buffer, this.index = index;
368
323
  }
369
324
  get id() {
370
325
  return this.buffer[this.index - 4];
@@ -387,15 +342,12 @@ var FlatBufferCursor = class _FlatBufferCursor {
387
342
  fork() {
388
343
  return new _FlatBufferCursor(this.buffer, this.index);
389
344
  }
390
- };
391
- var TreeBuffer = class _TreeBuffer {
345
+ }, TreeBuffer = class _TreeBuffer {
392
346
  /**
393
347
  Create a tree buffer.
394
348
  */
395
349
  constructor(buffer, length, set) {
396
- this.buffer = buffer;
397
- this.length = length;
398
- this.set = set;
350
+ this.buffer = buffer, this.length = length, this.set = set;
399
351
  }
400
352
  /**
401
353
  @internal
@@ -408,28 +360,20 @@ var TreeBuffer = class _TreeBuffer {
408
360
  */
409
361
  toString() {
410
362
  let result = [];
411
- for (let index = 0; index < this.buffer.length; ) {
412
- result.push(this.childString(index));
413
- index = this.buffer[index + 3];
414
- }
363
+ for (let index = 0; index < this.buffer.length; )
364
+ result.push(this.childString(index)), index = this.buffer[index + 3];
415
365
  return result.join(",");
416
366
  }
417
367
  /**
418
368
  @internal
419
369
  */
420
370
  childString(index) {
421
- let id2 = this.buffer[index], endIndex = this.buffer[index + 3];
422
- let type = this.set.types[id2], result = type.name;
423
- if (/\W/.test(result) && !type.isError)
424
- result = JSON.stringify(result);
425
- index += 4;
426
- if (endIndex == index)
371
+ let id2 = this.buffer[index], endIndex = this.buffer[index + 3], type = this.set.types[id2], result = type.name;
372
+ if (/\W/.test(result) && !type.isError && (result = JSON.stringify(result)), index += 4, endIndex == index)
427
373
  return result;
428
374
  let children = [];
429
- while (index < endIndex) {
430
- children.push(this.childString(index));
431
- index = this.buffer[index + 3];
432
- }
375
+ for (; index < endIndex; )
376
+ children.push(this.childString(index)), index = this.buffer[index + 3];
433
377
  return result + "(" + children.join(",") + ")";
434
378
  }
435
379
  /**
@@ -437,27 +381,19 @@ var TreeBuffer = class _TreeBuffer {
437
381
  */
438
382
  findChild(startIndex, endIndex, dir, pos, side) {
439
383
  let { buffer } = this, pick = -1;
440
- for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
441
- if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
442
- pick = i;
443
- if (dir > 0)
444
- break;
445
- }
446
- }
384
+ for (let i = startIndex; i != endIndex && !(checkSide(side, pos, buffer[i + 1], buffer[i + 2]) && (pick = i, dir > 0)); i = buffer[i + 3])
385
+ ;
447
386
  return pick;
448
387
  }
449
388
  /**
450
389
  @internal
451
390
  */
452
391
  slice(startI, endI, from) {
453
- let b = this.buffer;
454
- let copy = new Uint16Array(endI - startI), len = 0;
392
+ let b = this.buffer, copy = new Uint16Array(endI - startI), len = 0;
455
393
  for (let i = startI, j = 0; i < endI; ) {
456
- copy[j++] = b[i++];
457
- copy[j++] = b[i++] - from;
394
+ copy[j++] = b[i++], copy[j++] = b[i++] - from;
458
395
  let to = copy[j++] = b[i++] - from;
459
- copy[j++] = b[i++] - startI;
460
- len = Math.max(len, to);
396
+ copy[j++] = b[i++] - startI, len = Math.max(len, to);
461
397
  }
462
398
  return new _TreeBuffer(copy, len, this.set);
463
399
  }
@@ -475,12 +411,11 @@ function checkSide(side, pos, from, to) {
475
411
  case 2:
476
412
  return to > pos;
477
413
  case 4:
478
- return true;
414
+ return !0;
479
415
  }
480
416
  }
481
417
  function resolveNode(node, pos, side, overlays) {
482
- var _a;
483
- while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
418
+ for (var _a; node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos); ) {
484
419
  let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
485
420
  if (!parent)
486
421
  return node;
@@ -488,10 +423,8 @@ function resolveNode(node, pos, side, overlays) {
488
423
  }
489
424
  let mode = overlays ? 0 : IterMode.IgnoreOverlays;
490
425
  if (overlays)
491
- for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
492
- if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
493
- node = parent;
494
- }
426
+ for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent)
427
+ scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from && (node = parent);
495
428
  for (; ; ) {
496
429
  let inner = node.enter(pos, side, mode);
497
430
  if (!inner)
@@ -511,26 +444,21 @@ var BaseNode = class {
511
444
  return getChildren(this, type, before, after);
512
445
  }
513
446
  resolve(pos, side = 0) {
514
- return resolveNode(this, pos, side, false);
447
+ return resolveNode(this, pos, side, !1);
515
448
  }
516
449
  resolveInner(pos, side = 0) {
517
- return resolveNode(this, pos, side, true);
450
+ return resolveNode(this, pos, side, !0);
518
451
  }
519
452
  matchContext(context) {
520
453
  return matchNodeContext(this.parent, context);
521
454
  }
522
455
  enterUnfinishedNodesBefore(pos) {
523
456
  let scan = this.childBefore(pos), node = this;
524
- while (scan) {
457
+ for (; scan; ) {
525
458
  let last = scan.lastChild;
526
459
  if (!last || last.to != scan.to)
527
460
  break;
528
- if (last.type.isError && last.from == last.to) {
529
- node = scan;
530
- scan = last.prevSibling;
531
- } else {
532
- scan = last;
533
- }
461
+ last.type.isError && last.from == last.to ? (node = scan, scan = last.prevSibling) : scan = last;
534
462
  }
535
463
  return node;
536
464
  }
@@ -540,14 +468,9 @@ var BaseNode = class {
540
468
  get next() {
541
469
  return this.parent;
542
470
  }
543
- };
544
- var TreeNode = class _TreeNode extends BaseNode {
471
+ }, TreeNode = class _TreeNode extends BaseNode {
545
472
  constructor(_tree, from, index, _parent) {
546
- super();
547
- this._tree = _tree;
548
- this.from = from;
549
- this.index = index;
550
- this._parent = _parent;
473
+ super(), this._tree = _tree, this.from = from, this.index = index, this._parent = _parent;
551
474
  }
552
475
  get type() {
553
476
  return this._tree.type;
@@ -562,30 +485,23 @@ var TreeNode = class _TreeNode extends BaseNode {
562
485
  for (let parent = this; ; ) {
563
486
  for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
564
487
  let next = children[i], start = positions[i] + parent.from;
565
- if (!checkSide(side, pos, start, start + next.length))
566
- continue;
567
- if (next instanceof TreeBuffer) {
568
- if (mode & IterMode.ExcludeBuffers)
569
- continue;
570
- let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
571
- if (index > -1)
572
- return new BufferNode(new BufferContext(parent, next, i, start), null, index);
573
- } else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
574
- let mounted;
575
- if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
576
- return new _TreeNode(mounted.tree, start, i, parent);
577
- let inner = new _TreeNode(next, start, i, parent);
578
- return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
488
+ if (checkSide(side, pos, start, start + next.length)) {
489
+ if (next instanceof TreeBuffer) {
490
+ if (mode & IterMode.ExcludeBuffers)
491
+ continue;
492
+ let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
493
+ if (index > -1)
494
+ return new BufferNode(new BufferContext(parent, next, i, start), null, index);
495
+ } else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
496
+ let mounted;
497
+ if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
498
+ return new _TreeNode(mounted.tree, start, i, parent);
499
+ let inner = new _TreeNode(next, start, i, parent);
500
+ return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
501
+ }
579
502
  }
580
503
  }
581
- if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
582
- return null;
583
- if (parent.index >= 0)
584
- i = parent.index + dir;
585
- else
586
- i = dir < 0 ? -1 : parent._parent._tree.children.length;
587
- parent = parent._parent;
588
- if (!parent)
504
+ if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous || (parent.index >= 0 ? i = parent.index + dir : i = dir < 0 ? -1 : parent._parent._tree.children.length, parent = parent._parent, !parent))
589
505
  return null;
590
506
  }
591
507
  }
@@ -632,16 +548,15 @@ var TreeNode = class _TreeNode extends BaseNode {
632
548
  let mounted;
633
549
  if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
634
550
  let rPos = pos - this.from;
635
- for (let { from, to } of mounted.overlay) {
551
+ for (let { from, to } of mounted.overlay)
636
552
  if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
637
553
  return new _TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
638
- }
639
554
  }
640
555
  return this.nextChild(0, 1, pos, side, mode);
641
556
  }
642
557
  nextSignificantParent() {
643
558
  let val = this;
644
- while (val.type.isAnonymous && val._parent)
559
+ for (; val.type.isAnonymous && val._parent; )
645
560
  val = val._parent;
646
561
  return val;
647
562
  }
@@ -683,42 +598,35 @@ function getChildren(node, type, before, after) {
683
598
  let cur = node.cursor(), result = [];
684
599
  if (!cur.firstChild())
685
600
  return result;
686
- if (before != null)
687
- for (let found = false; !found; ) {
688
- found = cur.type.is(before);
689
- if (!cur.nextSibling())
601
+ if (before != null) {
602
+ for (let found = !1; !found; )
603
+ if (found = cur.type.is(before), !cur.nextSibling())
690
604
  return result;
691
- }
605
+ }
692
606
  for (; ; ) {
693
607
  if (after != null && cur.type.is(after))
694
608
  return result;
695
- if (cur.type.is(type))
696
- result.push(cur.node);
697
- if (!cur.nextSibling())
609
+ if (cur.type.is(type) && result.push(cur.node), !cur.nextSibling())
698
610
  return after == null ? result : [];
699
611
  }
700
612
  }
701
613
  function matchNodeContext(node, context, i = context.length - 1) {
702
614
  for (let p = node; i >= 0; p = p.parent) {
703
615
  if (!p)
704
- return false;
616
+ return !1;
705
617
  if (!p.type.isAnonymous) {
706
618
  if (context[i] && context[i] != p.name)
707
- return false;
619
+ return !1;
708
620
  i--;
709
621
  }
710
622
  }
711
- return true;
623
+ return !0;
712
624
  }
713
625
  var BufferContext = class {
714
626
  constructor(parent, buffer, index, start) {
715
- this.parent = parent;
716
- this.buffer = buffer;
717
- this.index = index;
718
- this.start = start;
627
+ this.parent = parent, this.buffer = buffer, this.index = index, this.start = start;
719
628
  }
720
- };
721
- var BufferNode = class _BufferNode extends BaseNode {
629
+ }, BufferNode = class _BufferNode extends BaseNode {
722
630
  get name() {
723
631
  return this.type.name;
724
632
  }
@@ -729,15 +637,10 @@ var BufferNode = class _BufferNode extends BaseNode {
729
637
  return this.context.start + this.context.buffer.buffer[this.index + 2];
730
638
  }
731
639
  constructor(context, _parent, index) {
732
- super();
733
- this.context = context;
734
- this._parent = _parent;
735
- this.index = index;
736
- this.type = context.buffer.set.types[context.buffer.buffer[index]];
640
+ super(), this.context = context, this._parent = _parent, this.index = index, this.type = context.buffer.set.types[context.buffer.buffer[index]];
737
641
  }
738
642
  child(dir, pos, side) {
739
- let { buffer } = this.context;
740
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
643
+ let { buffer } = this.context, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
741
644
  return index < 0 ? null : new _BufferNode(this.context, this, index);
742
645
  }
743
646
  get firstChild() {
@@ -778,8 +681,7 @@ var BufferNode = class _BufferNode extends BaseNode {
778
681
  enter(pos, side, mode = 0) {
779
682
  if (mode & IterMode.ExcludeBuffers)
780
683
  return null;
781
- let { buffer } = this.context;
782
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
684
+ let { buffer } = this.context, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
783
685
  return index < 0 ? null : new _BufferNode(this.context, this, index);
784
686
  }
785
687
  get parent() {
@@ -795,18 +697,12 @@ var BufferNode = class _BufferNode extends BaseNode {
795
697
  );
796
698
  }
797
699
  get nextSibling() {
798
- let { buffer } = this.context;
799
- let after = buffer.buffer[this.index + 3];
800
- if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
801
- return new _BufferNode(this.context, this._parent, after);
802
- return this.externalSibling(1);
700
+ let { buffer } = this.context, after = buffer.buffer[this.index + 3];
701
+ return after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length) ? new _BufferNode(this.context, this._parent, after) : this.externalSibling(1);
803
702
  }
804
703
  get prevSibling() {
805
- let { buffer } = this.context;
806
- let parentStart = this._parent ? this._parent.index + 4 : 0;
807
- if (this.index == parentStart)
808
- return this.externalSibling(-1);
809
- return new _BufferNode(this.context, this._parent, buffer.findChild(
704
+ let { buffer } = this.context, parentStart = this._parent ? this._parent.index + 4 : 0;
705
+ return this.index == parentStart ? this.externalSibling(-1) : new _BufferNode(this.context, this._parent, buffer.findChild(
810
706
  parentStart,
811
707
  this.index,
812
708
  -1,
@@ -819,13 +715,10 @@ var BufferNode = class _BufferNode extends BaseNode {
819
715
  return null;
820
716
  }
821
717
  toTree() {
822
- let children = [], positions = [];
823
- let { buffer } = this.context;
824
- let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
718
+ let children = [], positions = [], { buffer } = this.context, startI = this.index + 4, endI = buffer.buffer[this.index + 3];
825
719
  if (endI > startI) {
826
720
  let from = buffer.buffer[this.index + 1];
827
- children.push(buffer.slice(startI, endI, from));
828
- positions.push(0);
721
+ children.push(buffer.slice(startI, endI, from)), positions.push(0);
829
722
  }
830
723
  return new Tree(this.type, children, positions, this.to - this.from);
831
724
  }
@@ -842,23 +735,14 @@ function iterStack(heads) {
842
735
  let pick = 0, picked = heads[0];
843
736
  for (let i = 1; i < heads.length; i++) {
844
737
  let node = heads[i];
845
- if (node.from > picked.from || node.to < picked.to) {
846
- picked = node;
847
- pick = i;
848
- }
738
+ (node.from > picked.from || node.to < picked.to) && (picked = node, pick = i);
849
739
  }
850
- let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
851
- let newHeads = heads.slice();
852
- if (next)
853
- newHeads[pick] = next;
854
- else
855
- newHeads.splice(pick, 1);
856
- return new StackIterator(newHeads, picked);
740
+ let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent, newHeads = heads.slice();
741
+ return next ? newHeads[pick] = next : newHeads.splice(pick, 1), new StackIterator(newHeads, picked);
857
742
  }
858
743
  var StackIterator = class {
859
744
  constructor(heads, node) {
860
- this.heads = heads;
861
- this.node = node;
745
+ this.heads = heads, this.node = node;
862
746
  }
863
747
  get next() {
864
748
  return iterStack(this.heads);
@@ -866,19 +750,17 @@ var StackIterator = class {
866
750
  };
867
751
  function stackIterator(tree, pos, side) {
868
752
  let inner = tree.resolveInner(pos, side), layers = null;
869
- for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
753
+ for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent)
870
754
  if (scan.index < 0) {
871
755
  let parent = scan.parent;
872
- (layers || (layers = [inner])).push(parent.resolve(pos, side));
873
- scan = parent;
756
+ (layers || (layers = [inner])).push(parent.resolve(pos, side)), scan = parent;
874
757
  } else {
875
758
  let mount = MountedTree.get(scan.tree);
876
759
  if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
877
760
  let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
878
- (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
761
+ (layers || (layers = [inner])).push(resolveNode(root, pos, side, !1));
879
762
  }
880
763
  }
881
- }
882
764
  return layers ? iterStack(layers) : inner;
883
765
  }
884
766
  var TreeCursor = class {
@@ -892,51 +774,28 @@ var TreeCursor = class {
892
774
  @internal
893
775
  */
894
776
  constructor(node, mode = 0) {
895
- this.mode = mode;
896
- this.buffer = null;
897
- this.stack = [];
898
- this.index = 0;
899
- this.bufferNode = null;
900
- if (node instanceof TreeNode) {
777
+ if (this.mode = mode, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, node instanceof TreeNode)
901
778
  this.yieldNode(node);
902
- } else {
903
- this._tree = node.context.parent;
904
- this.buffer = node.context;
779
+ else {
780
+ this._tree = node.context.parent, this.buffer = node.context;
905
781
  for (let n = node._parent; n; n = n._parent)
906
782
  this.stack.unshift(n.index);
907
- this.bufferNode = node;
908
- this.yieldBuf(node.index);
783
+ this.bufferNode = node, this.yieldBuf(node.index);
909
784
  }
910
785
  }
911
786
  yieldNode(node) {
912
- if (!node)
913
- return false;
914
- this._tree = node;
915
- this.type = node.type;
916
- this.from = node.from;
917
- this.to = node.to;
918
- return true;
787
+ return node ? (this._tree = node, this.type = node.type, this.from = node.from, this.to = node.to, !0) : !1;
919
788
  }
920
789
  yieldBuf(index, type) {
921
790
  this.index = index;
922
791
  let { start, buffer } = this.buffer;
923
- this.type = type || buffer.set.types[buffer.buffer[index]];
924
- this.from = start + buffer.buffer[index + 1];
925
- this.to = start + buffer.buffer[index + 2];
926
- return true;
792
+ return this.type = type || buffer.set.types[buffer.buffer[index]], this.from = start + buffer.buffer[index + 1], this.to = start + buffer.buffer[index + 2], !0;
927
793
  }
928
794
  /**
929
795
  @internal
930
796
  */
931
797
  yield(node) {
932
- if (!node)
933
- return false;
934
- if (node instanceof TreeNode) {
935
- this.buffer = null;
936
- return this.yieldNode(node);
937
- }
938
- this.buffer = node.context;
939
- return this.yieldBuf(node.index, node.type);
798
+ return node ? node instanceof TreeNode ? (this.buffer = null, this.yieldNode(node)) : (this.buffer = node.context, this.yieldBuf(node.index, node.type)) : !1;
940
799
  }
941
800
  /**
942
801
  @internal
@@ -950,12 +809,8 @@ var TreeCursor = class {
950
809
  enterChild(dir, pos, side) {
951
810
  if (!this.buffer)
952
811
  return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
953
- let { buffer } = this.buffer;
954
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
955
- if (index < 0)
956
- return false;
957
- this.stack.push(this.index);
958
- return this.yieldBuf(index);
812
+ let { buffer } = this.buffer, index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
813
+ return index < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(index));
959
814
  }
960
815
  /**
961
816
  Move the cursor to this node's first child. When this returns
@@ -1010,9 +865,7 @@ var TreeCursor = class {
1010
865
  set to false.
1011
866
  */
1012
867
  enter(pos, side, mode = this.mode) {
1013
- if (!this.buffer)
1014
- return this.yield(this._tree.enter(pos, side, mode));
1015
- return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
868
+ return this.buffer ? mode & IterMode.ExcludeBuffers ? !1 : this.enterChild(1, pos, side) : this.yield(this._tree.enter(pos, side, mode));
1016
869
  }
1017
870
  /**
1018
871
  Move to the node's parent node, if this isn't the top node.
@@ -1023,15 +876,14 @@ var TreeCursor = class {
1023
876
  if (this.stack.length)
1024
877
  return this.yieldBuf(this.stack.pop());
1025
878
  let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
1026
- this.buffer = null;
1027
- return this.yieldNode(parent);
879
+ return this.buffer = null, this.yieldNode(parent);
1028
880
  }
1029
881
  /**
1030
882
  @internal
1031
883
  */
1032
884
  sibling(dir) {
1033
885
  if (!this.buffer)
1034
- return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
886
+ return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode)) : !1;
1035
887
  let { buffer } = this.buffer, d = this.stack.length - 1;
1036
888
  if (dir < 0) {
1037
889
  let parentStart = d < 0 ? 0 : this.stack[d] + 4;
@@ -1049,7 +901,7 @@ var TreeCursor = class {
1049
901
  if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
1050
902
  return this.yieldBuf(after);
1051
903
  }
1052
- return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
904
+ return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : !1;
1053
905
  }
1054
906
  /**
1055
907
  Move to this node's next sibling, if any.
@@ -1068,25 +920,22 @@ var TreeCursor = class {
1068
920
  if (buffer) {
1069
921
  if (dir > 0) {
1070
922
  if (this.index < buffer.buffer.buffer.length)
1071
- return false;
1072
- } else {
923
+ return !1;
924
+ } else
1073
925
  for (let i = 0; i < this.index; i++)
1074
926
  if (buffer.buffer.buffer[i + 3] < this.index)
1075
- return false;
1076
- }
927
+ return !1;
1077
928
  ({ index, parent } = buffer);
1078
- } else {
929
+ } else
1079
930
  ({ index, _parent: parent } = this._tree);
1080
- }
1081
- for (; parent; { index, _parent: parent } = parent) {
931
+ for (; parent; { index, _parent: parent } = parent)
1082
932
  if (index > -1)
1083
933
  for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
1084
934
  let child = parent._tree.children[i];
1085
935
  if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
1086
- return false;
936
+ return !1;
1087
937
  }
1088
- }
1089
- return true;
938
+ return !0;
1090
939
  }
1091
940
  move(dir, enter) {
1092
941
  if (enter && this.enterChild(
@@ -1095,12 +944,12 @@ var TreeCursor = class {
1095
944
  4
1096
945
  /* Side.DontCare */
1097
946
  ))
1098
- return true;
947
+ return !0;
1099
948
  for (; ; ) {
1100
949
  if (this.sibling(dir))
1101
- return true;
950
+ return !0;
1102
951
  if (this.atLastNode(dir) || !this.parent())
1103
- return false;
952
+ return !1;
1104
953
  }
1105
954
  }
1106
955
  /**
@@ -1110,7 +959,7 @@ var TreeCursor = class {
1110
959
  current node is empty or `enter` is false, its next sibling or
1111
960
  the next sibling of the first parent node that has one.
1112
961
  */
1113
- next(enter = true) {
962
+ next(enter = !0) {
1114
963
  return this.move(1, enter);
1115
964
  }
1116
965
  /**
@@ -1119,7 +968,7 @@ var TreeCursor = class {
1119
968
  previous sibling or the previous sibling of the first parent
1120
969
  node that has one.
1121
970
  */
1122
- prev(enter = true) {
971
+ prev(enter = !0) {
1123
972
  return this.move(-1, enter);
1124
973
  }
1125
974
  /**
@@ -1128,11 +977,10 @@ var TreeCursor = class {
1128
977
  it will enter nodes that start at `pos`.
1129
978
  */
1130
979
  moveTo(pos, side = 0) {
1131
- while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
1132
- if (!this.parent())
1133
- break;
1134
- while (this.enterChild(1, pos, side)) {
1135
- }
980
+ for (; (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) && this.parent(); )
981
+ ;
982
+ for (; this.enterChild(1, pos, side); )
983
+ ;
1136
984
  return this;
1137
985
  }
1138
986
  /**
@@ -1143,19 +991,17 @@ var TreeCursor = class {
1143
991
  if (!this.buffer)
1144
992
  return this._tree;
1145
993
  let cache = this.bufferNode, result = null, depth = 0;
1146
- if (cache && cache.context == this.buffer) {
994
+ if (cache && cache.context == this.buffer)
1147
995
  scan: for (let index = this.index, d = this.stack.length; d >= 0; ) {
1148
996
  for (let c = cache; c; c = c._parent)
1149
997
  if (c.index == index) {
1150
998
  if (index == this.index)
1151
999
  return c;
1152
- result = c;
1153
- depth = d + 1;
1000
+ result = c, depth = d + 1;
1154
1001
  break scan;
1155
1002
  }
1156
1003
  index = this.stack[--d];
1157
1004
  }
1158
- }
1159
1005
  for (let i = depth; i < this.stack.length; i++)
1160
1006
  result = new BufferNode(this.buffer, result, this.stack[i]);
1161
1007
  return this.bufferNode = new BufferNode(this.buffer, result, this.index);
@@ -1176,26 +1022,20 @@ var TreeCursor = class {
1176
1022
  */
1177
1023
  iterate(enter, leave) {
1178
1024
  for (let depth = 0; ; ) {
1179
- let mustLeave = false;
1180
- if (this.type.isAnonymous || enter(this) !== false) {
1025
+ let mustLeave = !1;
1026
+ if (this.type.isAnonymous || enter(this) !== !1) {
1181
1027
  if (this.firstChild()) {
1182
1028
  depth++;
1183
1029
  continue;
1184
1030
  }
1185
- if (!this.type.isAnonymous)
1186
- mustLeave = true;
1031
+ this.type.isAnonymous || (mustLeave = !0);
1187
1032
  }
1188
1033
  for (; ; ) {
1189
- if (mustLeave && leave)
1190
- leave(this);
1191
- mustLeave = this.type.isAnonymous;
1192
- if (!depth)
1034
+ if (mustLeave && leave && leave(this), mustLeave = this.type.isAnonymous, !depth)
1193
1035
  return;
1194
1036
  if (this.nextSibling())
1195
1037
  break;
1196
- this.parent();
1197
- depth--;
1198
- mustLeave = true;
1038
+ this.parent(), depth--, mustLeave = !0;
1199
1039
  }
1200
1040
  }
1201
1041
  }
@@ -1214,11 +1054,11 @@ var TreeCursor = class {
1214
1054
  let type = types[buffer.buffer[this.stack[d]]];
1215
1055
  if (!type.isAnonymous) {
1216
1056
  if (context[i] && context[i] != type.name)
1217
- return false;
1057
+ return !1;
1218
1058
  i--;
1219
1059
  }
1220
1060
  }
1221
- return true;
1061
+ return !0;
1222
1062
  }
1223
1063
  };
1224
1064
  function hasChild(tree) {
@@ -1226,19 +1066,13 @@ function hasChild(tree) {
1226
1066
  }
1227
1067
  function buildTree(data) {
1228
1068
  var _a;
1229
- let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
1230
- let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
1231
- let types = nodeSet.types;
1232
- let contextHash = 0, lookAhead = 0;
1069
+ let { buffer, nodeSet, maxBufferLength = 1024, reused = [], minRepeatType = nodeSet.types.length } = data, cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer, types = nodeSet.types, contextHash = 0, lookAhead = 0;
1233
1070
  function takeNode(parentStart, minPos, children2, positions2, inRepeat, depth) {
1234
- let { id: id2, start, end, size } = cursor;
1235
- let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1236
- if (size < 0) {
1237
- cursor.next();
1238
- if (size == -1) {
1071
+ let { id: id2, start, end, size } = cursor, lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1072
+ if (size < 0)
1073
+ if (cursor.next(), size == -1) {
1239
1074
  let node2 = reused[id2];
1240
- children2.push(node2);
1241
- positions2.push(start - parentStart);
1075
+ children2.push(node2), positions2.push(start - parentStart);
1242
1076
  return;
1243
1077
  } else if (size == -3) {
1244
1078
  contextHash = id2;
@@ -1246,81 +1080,45 @@ function buildTree(data) {
1246
1080
  } else if (size == -4) {
1247
1081
  lookAhead = id2;
1248
1082
  return;
1249
- } else {
1083
+ } else
1250
1084
  throw new RangeError(`Unrecognized record size: ${size}`);
1251
- }
1252
- }
1253
- let type = types[id2], node, buffer2;
1254
- let startPos = start - parentStart;
1085
+ let type = types[id2], node, buffer2, startPos = start - parentStart;
1255
1086
  if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
1256
- let data2 = new Uint16Array(buffer2.size - buffer2.skip);
1257
- let endPos = cursor.pos - buffer2.size, index = data2.length;
1258
- while (cursor.pos > endPos)
1087
+ let data2 = new Uint16Array(buffer2.size - buffer2.skip), endPos = cursor.pos - buffer2.size, index = data2.length;
1088
+ for (; cursor.pos > endPos; )
1259
1089
  index = copyToBuffer(buffer2.start, data2, index);
1260
- node = new TreeBuffer(data2, end - buffer2.start, nodeSet);
1261
- startPos = buffer2.start - parentStart;
1090
+ node = new TreeBuffer(data2, end - buffer2.start, nodeSet), startPos = buffer2.start - parentStart;
1262
1091
  } else {
1263
1092
  let endPos = cursor.pos - size;
1264
1093
  cursor.next();
1265
- let localChildren = [], localPositions = [];
1266
- let localInRepeat = id2 >= minRepeatType ? id2 : -1;
1267
- let lastGroup = 0, lastEnd = end;
1268
- while (cursor.pos > endPos) {
1269
- if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1270
- if (cursor.end <= lastEnd - maxBufferLength) {
1271
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1272
- lastGroup = localChildren.length;
1273
- lastEnd = cursor.end;
1274
- }
1275
- cursor.next();
1276
- } else if (depth > 2500) {
1277
- takeFlatNode(start, endPos, localChildren, localPositions);
1278
- } else {
1279
- takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1280
- }
1281
- }
1282
- if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
1283
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1284
- localChildren.reverse();
1285
- localPositions.reverse();
1286
- if (localInRepeat > -1 && lastGroup > 0) {
1094
+ let localChildren = [], localPositions = [], localInRepeat = id2 >= minRepeatType ? id2 : -1, lastGroup = 0, lastEnd = end;
1095
+ for (; cursor.pos > endPos; )
1096
+ localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0 ? (cursor.end <= lastEnd - maxBufferLength && (makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart), lastGroup = localChildren.length, lastEnd = cursor.end), cursor.next()) : depth > 2500 ? takeFlatNode(start, endPos, localChildren, localPositions) : takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1097
+ if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length && makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart), localChildren.reverse(), localPositions.reverse(), localInRepeat > -1 && lastGroup > 0) {
1287
1098
  let make = makeBalanced(type, contextAtStart);
1288
1099
  node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
1289
- } else {
1100
+ } else
1290
1101
  node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
1291
- }
1292
1102
  }
1293
- children2.push(node);
1294
- positions2.push(startPos);
1103
+ children2.push(node), positions2.push(startPos);
1295
1104
  }
1296
1105
  function takeFlatNode(parentStart, minPos, children2, positions2) {
1297
- let nodes = [];
1298
- let nodeCount = 0, stopAt = -1;
1299
- while (cursor.pos > minPos) {
1106
+ let nodes = [], nodeCount = 0, stopAt = -1;
1107
+ for (; cursor.pos > minPos; ) {
1300
1108
  let { id: id2, start, end, size } = cursor;
1301
- if (size > 4) {
1302
- cursor.next();
1303
- } else if (stopAt > -1 && start < stopAt) {
1304
- break;
1305
- } else {
1306
- if (stopAt < 0)
1307
- stopAt = end - maxBufferLength;
1308
- nodes.push(id2, start, end);
1309
- nodeCount++;
1109
+ if (size > 4)
1310
1110
  cursor.next();
1111
+ else {
1112
+ if (stopAt > -1 && start < stopAt)
1113
+ break;
1114
+ stopAt < 0 && (stopAt = end - maxBufferLength), nodes.push(id2, start, end), nodeCount++, cursor.next();
1311
1115
  }
1312
1116
  }
1313
1117
  if (nodeCount) {
1314
- let buffer2 = new Uint16Array(nodeCount * 4);
1315
- let start = nodes[nodes.length - 2];
1316
- for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
1317
- buffer2[j++] = nodes[i];
1318
- buffer2[j++] = nodes[i + 1] - start;
1319
- buffer2[j++] = nodes[i + 2] - start;
1320
- buffer2[j++] = j;
1321
- }
1322
- children2.push(new TreeBuffer(buffer2, nodes[2] - start, nodeSet));
1323
- positions2.push(start - parentStart);
1118
+ let buffer2 = new Uint16Array(nodeCount * 4), start = nodes[nodes.length - 2];
1119
+ for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3)
1120
+ buffer2[j++] = nodes[i], buffer2[j++] = nodes[i + 1] - start, buffer2[j++] = nodes[i + 2] - start, buffer2[j++] = j;
1121
+ children2.push(new TreeBuffer(buffer2, nodes[2] - start, nodeSet)), positions2.push(start - parentStart);
1324
1122
  }
1325
1123
  }
1326
1124
  function makeBalanced(type, contextHash2) {
@@ -1329,20 +1127,16 @@ function buildTree(data) {
1329
1127
  if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
1330
1128
  if (!lastI && last.type == type && last.length == length2)
1331
1129
  return last;
1332
- if (lookAheadProp = last.prop(NodeProp.lookAhead))
1333
- lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
1130
+ (lookAheadProp = last.prop(NodeProp.lookAhead)) && (lookAhead2 = positions2[lastI] + last.length + lookAheadProp);
1334
1131
  }
1335
1132
  return makeTree(type, children2, positions2, length2, lookAhead2, contextHash2);
1336
1133
  };
1337
1134
  }
1338
1135
  function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2, contextHash2) {
1339
1136
  let localChildren = [], localPositions = [];
1340
- while (children2.length > i) {
1341
- localChildren.push(children2.pop());
1342
- localPositions.push(positions2.pop() + base - from);
1343
- }
1344
- children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to, contextHash2));
1345
- positions2.push(from - base);
1137
+ for (; children2.length > i; )
1138
+ localChildren.push(children2.pop()), localPositions.push(positions2.pop() + base - from);
1139
+ children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to, contextHash2)), positions2.push(from - base);
1346
1140
  }
1347
1141
  function makeTree(type, children2, positions2, length2, lookAhead2, contextHash2, props) {
1348
1142
  if (contextHash2) {
@@ -1356,71 +1150,45 @@ function buildTree(data) {
1356
1150
  return new Tree(type, children2, positions2, length2, props);
1357
1151
  }
1358
1152
  function findBufferSize(maxSize, inRepeat) {
1359
- let fork = cursor.fork();
1360
- let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
1361
- let result = { size: 0, start: 0, skip: 0 };
1153
+ let fork = cursor.fork(), size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength, result = { size: 0, start: 0, skip: 0 };
1362
1154
  scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
1363
1155
  let nodeSize2 = fork.size;
1364
1156
  if (fork.id == inRepeat && nodeSize2 >= 0) {
1365
- result.size = size;
1366
- result.start = start;
1367
- result.skip = skip;
1368
- skip += 4;
1369
- size += 4;
1370
- fork.next();
1157
+ result.size = size, result.start = start, result.skip = skip, skip += 4, size += 4, fork.next();
1371
1158
  continue;
1372
1159
  }
1373
1160
  let startPos = fork.pos - nodeSize2;
1374
1161
  if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
1375
1162
  break;
1376
- let localSkipped = fork.id >= minRepeatType ? 4 : 0;
1377
- let nodeStart = fork.start;
1378
- fork.next();
1379
- while (fork.pos > startPos) {
1380
- if (fork.size < 0) {
1163
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0, nodeStart = fork.start;
1164
+ for (fork.next(); fork.pos > startPos; ) {
1165
+ if (fork.size < 0)
1381
1166
  if (fork.size == -3 || fork.size == -4)
1382
1167
  localSkipped += 4;
1383
1168
  else
1384
1169
  break scan;
1385
- } else if (fork.id >= minRepeatType) {
1386
- localSkipped += 4;
1387
- }
1170
+ else fork.id >= minRepeatType && (localSkipped += 4);
1388
1171
  fork.next();
1389
1172
  }
1390
- start = nodeStart;
1391
- size += nodeSize2;
1392
- skip += localSkipped;
1173
+ start = nodeStart, size += nodeSize2, skip += localSkipped;
1393
1174
  }
1394
- if (inRepeat < 0 || size == maxSize) {
1395
- result.size = size;
1396
- result.start = start;
1397
- result.skip = skip;
1398
- }
1399
- return result.size > 4 ? result : void 0;
1175
+ return (inRepeat < 0 || size == maxSize) && (result.size = size, result.start = start, result.skip = skip), result.size > 4 ? result : void 0;
1400
1176
  }
1401
1177
  function copyToBuffer(bufferStart, buffer2, index) {
1402
1178
  let { id: id2, start, end, size } = cursor;
1403
- cursor.next();
1404
- if (size >= 0 && id2 < minRepeatType) {
1179
+ if (cursor.next(), size >= 0 && id2 < minRepeatType) {
1405
1180
  let startIndex = index;
1406
1181
  if (size > 4) {
1407
1182
  let endPos = cursor.pos - (size - 4);
1408
- while (cursor.pos > endPos)
1183
+ for (; cursor.pos > endPos; )
1409
1184
  index = copyToBuffer(bufferStart, buffer2, index);
1410
1185
  }
1411
- buffer2[--index] = startIndex;
1412
- buffer2[--index] = end - bufferStart;
1413
- buffer2[--index] = start - bufferStart;
1414
- buffer2[--index] = id2;
1415
- } else if (size == -3) {
1416
- contextHash = id2;
1417
- } else if (size == -4) {
1418
- lookAhead = id2;
1419
- }
1186
+ buffer2[--index] = startIndex, buffer2[--index] = end - bufferStart, buffer2[--index] = start - bufferStart, buffer2[--index] = id2;
1187
+ } else size == -3 ? contextHash = id2 : size == -4 && (lookAhead = id2);
1420
1188
  return index;
1421
1189
  }
1422
1190
  let children = [], positions = [];
1423
- while (cursor.pos > 0)
1191
+ for (; cursor.pos > 0; )
1424
1192
  takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
1425
1193
  let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
1426
1194
  return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
@@ -1450,13 +1218,11 @@ function balanceRange(balanceType, children, positions, from, to, start, length,
1450
1218
  let maxChild = Math.ceil(
1451
1219
  total * 1.5 / 8
1452
1220
  /* Balance.BranchFactor */
1453
- );
1454
- let localChildren = [], localPositions = [];
1221
+ ), localChildren = [], localPositions = [];
1455
1222
  function divide(children2, positions2, from2, to2, offset) {
1456
1223
  for (let i = from2; i < to2; ) {
1457
1224
  let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
1458
- i++;
1459
- for (; i < to2; i++) {
1225
+ for (i++; i < to2; i++) {
1460
1226
  let nextSize = nodeSize(balanceType, children2[i]);
1461
1227
  if (groupSize + nextSize >= maxChild)
1462
1228
  break;
@@ -1476,10 +1242,9 @@ function balanceRange(balanceType, children, positions, from, to, start, length,
1476
1242
  localPositions.push(groupStart + offset - start);
1477
1243
  }
1478
1244
  }
1479
- divide(children, positions, from, to, 0);
1480
- return (mkTop || mkTree)(localChildren, localPositions, length);
1245
+ return divide(children, positions, from, to, 0), (mkTop || mkTree)(localChildren, localPositions, length);
1481
1246
  }
1482
- var stoppedInner = new NodeProp({ perNode: true });
1247
+ var stoppedInner = new NodeProp({ perNode: !0 });
1483
1248
 
1484
1249
  // ../../node_modules/@lezer/lr/dist/index.js
1485
1250
  function decodeArray(input, Type = Uint16Array) {
@@ -1489,88 +1254,59 @@ function decodeArray(input, Type = Uint16Array) {
1489
1254
  for (let pos = 0, out = 0; pos < input.length; ) {
1490
1255
  let value = 0;
1491
1256
  for (; ; ) {
1492
- let next = input.charCodeAt(pos++), stop = false;
1257
+ let next = input.charCodeAt(pos++), stop = !1;
1493
1258
  if (next == 126) {
1494
1259
  value = 65535;
1495
1260
  break;
1496
1261
  }
1497
- if (next >= 92)
1498
- next--;
1499
- if (next >= 34)
1500
- next--;
1262
+ next >= 92 && next--, next >= 34 && next--;
1501
1263
  let digit = next - 32;
1502
- if (digit >= 46) {
1503
- digit -= 46;
1504
- stop = true;
1505
- }
1506
- value += digit;
1507
- if (stop)
1264
+ if (digit >= 46 && (digit -= 46, stop = !0), value += digit, stop)
1508
1265
  break;
1509
1266
  value *= 46;
1510
1267
  }
1511
- if (array)
1512
- array[out++] = value;
1513
- else
1514
- array = new Type(value);
1268
+ array ? array[out++] = value : array = new Type(value);
1515
1269
  }
1516
1270
  return array;
1517
1271
  }
1518
1272
  var CachedToken = class {
1519
1273
  constructor() {
1520
- this.start = -1;
1521
- this.value = -1;
1522
- this.end = -1;
1523
- this.extended = -1;
1524
- this.lookAhead = 0;
1525
- this.mask = 0;
1526
- this.context = 0;
1274
+ this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
1527
1275
  }
1528
- };
1529
- var nullToken = new CachedToken();
1276
+ }, nullToken = new CachedToken();
1530
1277
  var TokenGroup = class {
1531
1278
  constructor(data, id2) {
1532
- this.data = data;
1533
- this.id = id2;
1279
+ this.data = data, this.id = id2;
1534
1280
  }
1535
1281
  token(input, stack) {
1536
1282
  let { parser } = stack.p;
1537
1283
  readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
1538
1284
  }
1539
1285
  };
1540
- TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
1286
+ TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = !1;
1541
1287
  var LocalTokenGroup = class {
1542
1288
  constructor(data, precTable, elseToken) {
1543
- this.precTable = precTable;
1544
- this.elseToken = elseToken;
1545
- this.data = typeof data == "string" ? decodeArray(data) : data;
1289
+ this.precTable = precTable, this.elseToken = elseToken, this.data = typeof data == "string" ? decodeArray(data) : data;
1546
1290
  }
1547
1291
  token(input, stack) {
1548
1292
  let start = input.pos, skipped = 0;
1549
1293
  for (; ; ) {
1550
1294
  let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
1551
- readToken(this.data, input, stack, 0, this.data, this.precTable);
1552
- if (input.token.value > -1)
1295
+ if (readToken(this.data, input, stack, 0, this.data, this.precTable), input.token.value > -1)
1553
1296
  break;
1554
1297
  if (this.elseToken == null)
1555
1298
  return;
1556
- if (!atEof)
1557
- skipped++;
1558
- if (nextPos == null)
1299
+ if (atEof || skipped++, nextPos == null)
1559
1300
  break;
1560
1301
  input.reset(nextPos, input.token);
1561
1302
  }
1562
- if (skipped) {
1563
- input.reset(start, input.token);
1564
- input.acceptToken(this.elseToken, skipped);
1565
- }
1303
+ skipped && (input.reset(start, input.token), input.acceptToken(this.elseToken, skipped));
1566
1304
  }
1567
1305
  };
1568
- LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
1306
+ LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = !1;
1569
1307
  function readToken(data, input, stack, group, precTable, precOffset) {
1570
1308
  let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
1571
- scan: for (; ; ) {
1572
- if ((groupMask & data[state]) == 0)
1573
- break;
1309
+ scan: for (; (groupMask & data[state]) != 0; ) {
1574
1310
  let accEnd = data[state + 1];
1575
1311
  for (let i = state + 3; i < accEnd; i += 2)
1576
1312
  if ((data[i + 1] & groupMask) > 0) {
@@ -1586,16 +1322,13 @@ function readToken(data, input, stack, group, precTable, precOffset) {
1586
1322
  continue scan;
1587
1323
  }
1588
1324
  for (; low < high; ) {
1589
- let mid = low + high >> 1;
1590
- let index = accEnd + mid + (mid << 1);
1591
- let from = data[index], to = data[index + 1] || 65536;
1325
+ let mid = low + high >> 1, index = accEnd + mid + (mid << 1), from = data[index], to = data[index + 1] || 65536;
1592
1326
  if (next < from)
1593
1327
  high = mid;
1594
1328
  else if (next >= to)
1595
1329
  low = mid + 1;
1596
1330
  else {
1597
- state = data[index + 2];
1598
- input.advance();
1331
+ state = data[index + 2], input.advance();
1599
1332
  continue scan;
1600
1333
  }
1601
1334
  }
@@ -1612,19 +1345,13 @@ function overrides(token, prev, tableData, tableOffset) {
1612
1345
  let iPrev = findOffset(tableData, tableOffset, prev);
1613
1346
  return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
1614
1347
  }
1615
- var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
1616
- var id = (x) => x;
1617
- var ContextTracker = class {
1348
+ var verbose = typeof process < "u" && process.env && /\bparse\b/.test(process.env.LOG);
1349
+ var id = (x) => x, ContextTracker = class {
1618
1350
  /**
1619
1351
  Define a context tracker.
1620
1352
  */
1621
1353
  constructor(spec) {
1622
- this.start = spec.start;
1623
- this.shift = spec.shift || id;
1624
- this.reduce = spec.reduce || id;
1625
- this.reuse = spec.reuse || id;
1626
- this.hash = spec.hash || (() => 0);
1627
- this.strict = spec.strict !== false;
1354
+ this.start = spec.start, this.shift = spec.shift || id, this.reduce = spec.reduce || id, this.reuse = spec.reuse || id, this.hash = spec.hash || (() => 0), this.strict = spec.strict !== !1;
1628
1355
  }
1629
1356
  };
1630
1357
 
@@ -1642,74 +1369,68 @@ var MATH_TOKENS = {
1642
1369
  CLOSE_PAREN: 10,
1643
1370
  BACKSLASH: 11,
1644
1371
  NEWLINE: 12
1645
- };
1646
- var mathContextTracker = new ContextTracker({
1372
+ }, mathContextTracker = new ContextTracker({
1647
1373
  start: {
1648
- inMath: false,
1374
+ inMath: !1,
1649
1375
  mathType: null,
1650
1376
  depth: 0,
1651
1377
  startPos: -1,
1652
- isComplete: false,
1653
- hasError: false
1378
+ isComplete: !1,
1379
+ hasError: !1
1654
1380
  },
1655
1381
  shift(context, term, stack) {
1656
- const pos = stack.pos;
1382
+ let pos = stack.pos;
1657
1383
  switch (term) {
1658
1384
  case MATH_TOKENS.INLINE_MATH:
1659
- if (!context.inMath) {
1385
+ if (!context.inMath)
1660
1386
  return {
1661
1387
  ...context,
1662
- inMath: true,
1388
+ inMath: !0,
1663
1389
  mathType: "inline",
1664
1390
  startPos: pos,
1665
- isComplete: false,
1666
- hasError: false
1391
+ isComplete: !1,
1392
+ hasError: !1
1667
1393
  };
1668
- }
1669
- if (context.mathType === "inline") {
1394
+ if (context.mathType === "inline")
1670
1395
  return {
1671
1396
  ...context,
1672
- inMath: false,
1397
+ inMath: !1,
1673
1398
  mathType: null,
1674
- isComplete: true
1399
+ isComplete: !0
1675
1400
  };
1676
- }
1677
1401
  break;
1678
1402
  case MATH_TOKENS.DISPLAY_MATH:
1679
- if (!context.inMath) {
1403
+ if (!context.inMath)
1680
1404
  return {
1681
1405
  ...context,
1682
- inMath: true,
1406
+ inMath: !0,
1683
1407
  mathType: "display",
1684
1408
  startPos: pos,
1685
- isComplete: false,
1686
- hasError: false
1409
+ isComplete: !1,
1410
+ hasError: !1
1687
1411
  };
1688
- }
1689
- if (context.mathType === "display") {
1412
+ if (context.mathType === "display")
1690
1413
  return {
1691
1414
  ...context,
1692
- inMath: false,
1415
+ inMath: !1,
1693
1416
  mathType: null,
1694
- isComplete: true
1417
+ isComplete: !0
1695
1418
  };
1696
- }
1697
1419
  break;
1698
1420
  case MATH_TOKENS.OPEN_BRACE:
1699
1421
  case MATH_TOKENS.OPEN_BRACKET:
1700
1422
  case MATH_TOKENS.OPEN_PAREN:
1701
- if (context.inMath) {
1423
+ if (context.inMath)
1702
1424
  return {
1703
1425
  ...context,
1704
1426
  depth: context.depth + 1
1705
1427
  };
1706
- }
1707
1428
  break;
1708
1429
  case MATH_TOKENS.CLOSE_BRACE:
1709
1430
  case MATH_TOKENS.CLOSE_BRACKET:
1710
1431
  case MATH_TOKENS.CLOSE_PAREN:
1711
1432
  if (context.inMath) {
1712
- const newDepth = Math.max(0, context.depth - 1);
1433
+ let newDepth = Math.max(0, context.depth - 1);
1713
1434
  return {
1714
1435
  ...context,
1715
1436
  depth: newDepth,
@@ -1719,12 +1440,11 @@ var mathContextTracker = new ContextTracker({
1719
1440
  }
1720
1441
  break;
1721
1442
  case MATH_TOKENS.NEWLINE:
1722
- if (context.inMath && context.mathType === "inline") {
1443
+ if (context.inMath && context.mathType === "inline")
1723
1444
  return {
1724
1445
  ...context,
1725
- hasError: true
1446
+ hasError: !0
1726
1447
  };
1727
- }
1728
1448
  break;
1729
1449
  }
1730
1450
  return context;
@@ -1733,12 +1453,11 @@ var mathContextTracker = new ContextTracker({
1733
1453
  switch (term) {
1734
1454
  case MATH_TOKENS.INLINE_MATH:
1735
1455
  case MATH_TOKENS.DISPLAY_MATH:
1736
- if (context.inMath && context.depth > 0) {
1456
+ if (context.inMath && context.depth > 0)
1737
1457
  return {
1738
1458
  ...context,
1739
- hasError: true
1459
+ hasError: !0
1740
1460
  };
1741
- }
1742
1461
  break;
1743
1462
  }
1744
1463
  return context;
@@ -1782,7 +1501,7 @@ var MathContextUtils = {
1782
1501
  createErrorContext(baseContext) {
1783
1502
  return {
1784
1503
  ...baseContext,
1785
- hasError: true
1504
+ hasError: !0
1786
1505
  };
1787
1506
  },
1788
1507
  /**
@@ -1790,12 +1509,12 @@ var MathContextUtils = {
1790
1509
  */
1791
1510
  resetContext() {
1792
1511
  return {
1793
- inMath: false,
1512
+ inMath: !1,
1794
1513
  mathType: null,
1795
1514
  depth: 0,
1796
1515
  startPos: -1,
1797
- isComplete: false,
1798
- hasError: false
1516
+ isComplete: !1,
1517
+ hasError: !1
1799
1518
  };
1800
1519
  }
1801
1520
  };