-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelixir-data-viewer.js
More file actions
5450 lines (5446 loc) · 312 KB
/
Copy pathelixir-data-viewer.js
File metadata and controls
5450 lines (5446 loc) · 312 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".edv-container{position:relative;background:#1a1b26;color:#c0caf5;font-family:Cascadia Code,Fira Code,Consolas,Courier New,monospace;font-size:14px;line-height:20px;height:100%;overflow:hidden;display:flex;flex-direction:column;tab-size:2;-moz-tab-size:2}.edv-inner{flex:1;min-height:0;overflow:auto}.edv-scroll{min-width:fit-content;padding:8px 0}.edv-line{display:flex;min-height:20px}.edv-line:hover{background:#292e42;outline:1px dashed #3b4261}.edv-gutter{display:flex;align-items:center;flex-shrink:0;padding-right:8px;padding-left:4px;user-select:none;-webkit-user-select:none;gap:2px}.edv-line-number{color:#3b4261;text-align:right;min-width:2.5em;padding-right:4px;font-variant-numeric:tabular-nums}.edv-line:hover .edv-line-number{color:#737aa2}.edv-fold-indicator{width:16px;height:20px;display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:transparent;flex-shrink:0}.edv-fold-indicator.edv-foldable{cursor:pointer;color:#565f89;opacity:0;transition:opacity .15s ease}.edv-line:hover .edv-fold-indicator.edv-foldable,.edv-fold-indicator.edv-foldable[data-folded=true]{opacity:1}.edv-code{flex:1;white-space:pre;padding-left:8px;min-height:20px;border-left:1px solid #292e42}.edv-word-wrap .edv-scroll{min-width:unset}.edv-word-wrap .edv-code{white-space:pre-wrap;word-break:break-all;overflow-wrap:anywhere}.edv-word-wrap .edv-line{align-items:flex-start}.edv-string-truncated{display:inline-block;background:#292e42;color:#9ece6a;padding:0 5px;margin:0 2px;border-radius:3px;font-size:11px;cursor:pointer;border:1px solid #3b4261;line-height:16px;vertical-align:middle;white-space:nowrap}.edv-string-truncated:hover{background:#33394e;color:#9ece6a;border-color:#9ece6a}.edv-string-truncated--expanded{color:#565f89}.edv-string-truncated--expanded:hover{color:#9ece6a}.edv-fold-ellipsis{display:inline-block;background:#292e42;color:#7aa2f7;padding:0 5px;margin:0 2px;border-radius:3px;font-size:11px;cursor:pointer;border:1px solid #3b4261;line-height:16px;vertical-align:middle;white-space:nowrap}.edv-fold-ellipsis:hover{background:#33394e;color:#7aa2f7;border-color:#7aa2f7}.tok-atom{color:#2ac3de}.tok-namespace{color:#7dcfff}.tok-bool{color:#ff9e64}.tok-null{color:#2ac3de}.tok-number{color:#ff9e64}.tok-character{color:#9ece6a}.tok-variableName{color:#c0caf5}.tok-function,.tok-definition{color:#7aa2f7}.tok-special{color:#f7768e}.tok-string{color:#9ece6a}.tok-escape,.tok-keyword{color:#bb9af7}.tok-operator{color:#89ddff}.tok-comment{color:#565f89;font-style:italic}.tok-inspect-literal{color:#bb9af7}.tok-underscore{color:#565f89;font-style:italic}.tok-punctuation{color:#a9b1d6}.tok-separator,.tok-angleBracket{color:#89ddff}.tok-attributeName{color:#7dcfff}.tok-docString{color:#e0af68}.edv-inner::-webkit-scrollbar{width:10px;height:10px}.edv-inner::-webkit-scrollbar-track{background:#1a1b26}.edv-inner::-webkit-scrollbar-thumb{background:#3b4261;border-radius:5px}.edv-inner::-webkit-scrollbar-thumb:hover{background:#565f89}.edv-inner::-webkit-scrollbar-corner{background:#1a1b26}.edv-toolbar{position:absolute;top:4px;right:14px;z-index:10;display:flex;gap:2px;background:#1a1b26;border:1px solid #3b4261;border-radius:4px;padding:2px;opacity:0;transition:opacity .2s ease;pointer-events:none}.edv-container:hover .edv-toolbar{opacity:1;pointer-events:auto}.edv-toolbar-btn{background:transparent;border:1px solid transparent;color:#a9b1d6;width:26px;height:24px;border-radius:3px;cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;font-family:inherit;padding:0;line-height:1}.edv-toolbar-btn:hover{background:#292e42;border-color:#565f89;color:#c0caf5}.edv-toolbar-btn.edv-toolbar-btn--active{background:#292e42;border-color:#7aa2f7;color:#7aa2f7}.edv-fold-level-group{display:flex;align-items:center;margin:0 1px}.edv-fold-level-display{color:#a9b1d6;font-size:11px;min-width:24px;text-align:center;user-select:none;-webkit-user-select:none;line-height:24px;font-family:inherit}.edv-search-bar{flex-shrink:0;z-index:20;display:none;align-items:center;gap:6px;padding:4px 8px;background:#1a1b26;border-bottom:1px solid #3b4261;font-size:13px}.edv-search-bar--visible{display:flex}.edv-search-input-wrapper{display:flex;align-items:center;background:#1a1b26;border:1px solid #3b4261;border-radius:3px;overflow:hidden}.edv-search-input-wrapper:focus-within{border-color:#7aa2f7}.edv-search-input{background:transparent;border:none;outline:none;color:#c0caf5;font-family:inherit;font-size:13px;padding:3px 6px;width:180px}.edv-search-input::placeholder{color:#565f89}.edv-search-case-btn{background:transparent;border:1px solid transparent;color:#565f89;cursor:pointer;font-size:12px;font-family:inherit;padding:2px 6px;border-radius:2px;margin-right:2px;line-height:1}.edv-search-case-btn:hover{color:#c0caf5;background:#292e42;border-color:#565f89}.edv-search-case-btn--active{color:#7aa2f7;background:#292e42;border-color:#7aa2f7}.edv-search-case-btn--active:hover{border-color:#c0caf5}.edv-search-info{color:#c0caf5;font-size:12px;min-width:70px;text-align:center;white-space:nowrap}.edv-search-info--no-results{color:#f7768e}.edv-search-nav-btn{background:transparent;border:1px solid transparent;color:#a9b1d6;cursor:pointer;width:24px;height:24px;border-radius:3px;font-size:14px;display:flex;align-items:center;justify-content:center;font-family:inherit;padding:0;line-height:1}.edv-search-nav-btn:hover{background:#292e42;border-color:#565f89}.edv-search-match{background:#e0af6859;border-radius:2px;color:inherit}.edv-search-current{background:#e0af68;border-radius:2px;color:#1a1b26;outline:2px solid #e0af68;outline-offset:0px;box-shadow:0 0 8px #e0af6899}.edv-search-current *{color:#1a1b26!important}.edv-line--has-match .edv-line-number{color:#e0af68}.edv-line--current-match{background:#e0af681a}.edv-line--current-match .edv-line-number{color:#e0af68!important;font-weight:700}.edv-search-match-truncated{background:#e0af6840;border-radius:2px}.edv-code [data-from]{cursor:pointer}.edv-inspect-token{background:#7aa2f733;border-radius:2px;outline:1px solid rgba(122,162,247,.4)}.edv-line.edv-inspect-line{background:#7aa2f70f}.edv-inspect-bracket{background:#7aa2f733;border-radius:2px;outline:1px solid rgba(122,162,247,.35)}@keyframes edv-inspect-flash{0%{background-color:#7aa2f773}to{background-color:#7aa2f733}}.edv-inspect-copied{animation:edv-inspect-flash .4s ease-out}.edv-copied-toast{position:fixed;background:#292e42;color:#7aa2f7;border:1px solid #7aa2f7;border-radius:4px;padding:2px 8px;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;pointer-events:none;z-index:100;animation:edv-toast-fade 1.2s ease-out forwards}@keyframes edv-toast-fade{0%{opacity:1;transform:translateY(0)}70%{opacity:1}to{opacity:0;transform:translateY(-10px)}}.edv-filter-bar{flex-shrink:0;z-index:20;display:none;align-items:center;gap:6px;padding:4px 8px;background:#1a1b26;border-bottom:1px solid #3b4261;font-size:13px;flex-wrap:wrap}.edv-filter-bar--visible{display:flex}.edv-filter-input-wrapper{position:relative;display:flex;align-items:center;background:#1a1b26;border:1px solid #3b4261;border-radius:3px;overflow:visible}.edv-filter-input-wrapper:focus-within{border-color:#7aa2f7}.edv-filter-input{background:transparent;border:none;outline:none;color:#c0caf5;font-family:inherit;font-size:13px;padding:3px 6px;width:140px}.edv-filter-input::placeholder{color:#565f89}.edv-filter-tags{display:flex;gap:4px;flex-wrap:wrap;align-items:center}.edv-filter-tag{display:inline-flex;align-items:center;gap:2px;background:#292e42;border:1px solid #3b4261;border-radius:3px;padding:1px 4px 1px 6px;font-size:12px;color:#7aa2f7;white-space:nowrap;line-height:18px}.edv-filter-tag-label{color:#7aa2f7}.edv-filter-tag-remove{background:transparent;border:none;color:#565f89;cursor:pointer;font-size:10px;padding:0 2px;line-height:1;display:flex;align-items:center;justify-content:center;border-radius:2px}.edv-filter-tag-remove:hover{color:#f7768e;background:#f7768e26}.edv-filter-info{color:#c0caf5;font-size:12px;white-space:nowrap;margin-left:auto}.edv-filter-dropdown{display:none;position:absolute;top:100%;left:-1px;right:-1px;background:#1a1b26;border:1px solid #3b4261;border-top:none;border-radius:0 0 3px 3px;max-height:160px;overflow-y:auto;z-index:30}.edv-filter-dropdown--visible{display:block}.edv-filter-dropdown-item{padding:4px 8px;cursor:pointer;font-size:13px;color:#c0caf5;white-space:nowrap}.edv-filter-dropdown-item:hover,.edv-filter-dropdown-item--active{background:#292e42;color:#7aa2f7}.edv-filter-dropdown::-webkit-scrollbar{width:6px}.edv-filter-dropdown::-webkit-scrollbar-track{background:#1a1b26}.edv-filter-dropdown::-webkit-scrollbar-thumb{background:#3b4261;border-radius:3px}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
var Xt = Object.defineProperty;
var ct = (r, O, e) => O in r ? Xt(r, O, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[O] = e;
var d = (r, O, e) => ct(r, typeof O != "symbol" ? O + "" : O, e);
let ut = 0;
class MO {
constructor(O, e) {
this.from = O, this.to = e;
}
}
class T {
/**
Create a new node prop type.
*/
constructor(O = {}) {
this.id = ut++, this.perNode = !!O.perNode, this.deserialize = O.deserialize || (() => {
throw new Error("This node type doesn't define a deserialize function");
}), this.combine = O.combine || null;
}
/**
This is meant to be used with
[`NodeSet.extend`](#common.NodeSet.extend) or
[`LRParser.configure`](#lr.ParserConfig.props) to compute
prop values for each node type in the set. Takes a [match
object](#common.NodeType^match) or function that returns undefined
if the node type doesn't get this prop, and the prop's value if
it does.
*/
add(O) {
if (this.perNode)
throw new RangeError("Can't add per-node props to node types");
return typeof O != "function" && (O = F.match(O)), (e) => {
let t = O(e);
return t === void 0 ? null : [this, t];
};
}
}
T.closedBy = new T({ deserialize: (r) => r.split(" ") });
T.openedBy = new T({ deserialize: (r) => r.split(" ") });
T.group = new T({ deserialize: (r) => r.split(" ") });
T.isolate = new T({ deserialize: (r) => {
if (r && r != "rtl" && r != "ltr" && r != "auto")
throw new RangeError("Invalid value for isolate: " + r);
return r || "auto";
} });
T.contextHash = new T({ perNode: !0 });
T.lookAhead = new T({ perNode: !0 });
T.mounted = new T({ perNode: !0 });
class yO {
constructor(O, e, t, i = !1) {
this.tree = O, this.overlay = e, this.parser = t, this.bracketed = i;
}
/**
@internal
*/
static get(O) {
return O && O.props && O.props[T.mounted.id];
}
}
const ft = /* @__PURE__ */ Object.create(null);
class F {
/**
@internal
*/
constructor(O, e, t, i = 0) {
this.name = O, this.props = e, this.id = t, this.flags = i;
}
/**
Define a node type.
*/
static define(O) {
let e = O.props && O.props.length ? /* @__PURE__ */ Object.create(null) : ft, t = (O.top ? 1 : 0) | (O.skipped ? 2 : 0) | (O.error ? 4 : 0) | (O.name == null ? 8 : 0), i = new F(O.name || "", e, O.id, t);
if (O.props) {
for (let n of O.props)
if (Array.isArray(n) || (n = n(i)), n) {
if (n[0].perNode)
throw new RangeError("Can't store a per-node prop on a node type");
e[n[0].id] = n[1];
}
}
return i;
}
/**
Retrieves a node prop for this type. Will return `undefined` if
the prop isn't present on this node.
*/
prop(O) {
return this.props[O.id];
}
/**
True when this is the top node of a grammar.
*/
get isTop() {
return (this.flags & 1) > 0;
}
/**
True when this node is produced by a skip rule.
*/
get isSkipped() {
return (this.flags & 2) > 0;
}
/**
Indicates whether this is an error node.
*/
get isError() {
return (this.flags & 4) > 0;
}
/**
When true, this node type doesn't correspond to a user-declared
named node, for example because it is used to cache repetition.
*/
get isAnonymous() {
return (this.flags & 8) > 0;
}
/**
Returns true when this node's name or one of its
[groups](#common.NodeProp^group) matches the given string.
*/
is(O) {
if (typeof O == "string") {
if (this.name == O)
return !0;
let e = this.prop(T.group);
return e ? e.indexOf(O) > -1 : !1;
}
return this.id == O;
}
/**
Create a function from node types to arbitrary values by
specifying an object whose property names are node or
[group](#common.NodeProp^group) names. Often useful with
[`NodeProp.add`](#common.NodeProp.add). You can put multiple
names, separated by spaces, in a single property name to map
multiple node names to a single value.
*/
static match(O) {
let e = /* @__PURE__ */ Object.create(null);
for (let t in O)
for (let i of t.split(" "))
e[i] = O[t];
return (t) => {
for (let i = t.prop(T.group), n = -1; n < (i ? i.length : 0); n++) {
let a = e[n < 0 ? t.name : i[n]];
if (a)
return a;
}
};
}
}
F.none = new F(
"",
/* @__PURE__ */ Object.create(null),
0,
8
/* NodeFlag.Anonymous */
);
class oe {
/**
Create a set with the given types. The `id` property of each
type should correspond to its position within the array.
*/
constructor(O) {
this.types = O;
for (let e = 0; e < O.length; e++)
if (O[e].id != e)
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
}
/**
Create a copy of this set with some node properties added. The
arguments to this method can be created with
[`NodeProp.add`](#common.NodeProp.add).
*/
extend(...O) {
let e = [];
for (let t of this.types) {
let i = null;
for (let n of O) {
let a = n(t);
if (a) {
i || (i = Object.assign({}, t.props));
let s = a[1], l = a[0];
l.combine && l.id in i && (s = l.combine(i[l.id], s)), i[l.id] = s;
}
}
e.push(i ? new F(t.name, i, t.id, t.flags) : t);
}
return new oe(e);
}
}
const wO = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap();
var U;
(function(r) {
r[r.ExcludeBuffers = 1] = "ExcludeBuffers", r[r.IncludeAnonymous = 2] = "IncludeAnonymous", r[r.IgnoreMounts = 4] = "IgnoreMounts", r[r.IgnoreOverlays = 8] = "IgnoreOverlays", r[r.EnterBracketed = 16] = "EnterBracketed";
})(U || (U = {}));
class Z {
/**
Construct a new tree. See also [`Tree.build`](#common.Tree^build).
*/
constructor(O, e, t, i, n) {
if (this.type = O, this.children = e, this.positions = t, this.length = i, this.props = null, n && n.length) {
this.props = /* @__PURE__ */ Object.create(null);
for (let [a, s] of n)
this.props[typeof a == "number" ? a : a.id] = s;
}
}
/**
@internal
*/
toString() {
let O = yO.get(this);
if (O && !O.overlay)
return O.tree.toString();
let e = "";
for (let t of this.children) {
let i = t.toString();
i && (e && (e += ","), e += i);
}
return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (e.length ? "(" + e + ")" : "") : e;
}
/**
Get a [tree cursor](#common.TreeCursor) positioned at the top of
the tree. Mode can be used to [control](#common.IterMode) which
nodes the cursor visits.
*/
cursor(O = 0) {
return new ee(this.topNode, O);
}
/**
Get a [tree cursor](#common.TreeCursor) pointing into this tree
at the given position and side (see
[`moveTo`](#common.TreeCursor.moveTo).
*/
cursorAt(O, e = 0, t = 0) {
let i = wO.get(this) || this.topNode, n = new ee(i);
return n.moveTo(O, e), wO.set(this, n._tree), n;
}
/**
Get a [syntax node](#common.SyntaxNode) object for the top of the
tree.
*/
get topNode() {
return new I(this, 0, 0, null);
}
/**
Get the [syntax node](#common.SyntaxNode) at the given position.
If `side` is -1, this will move into nodes that end at the
position. If 1, it'll move into nodes that start at the
position. With 0, it'll only enter nodes that cover the position
from both sides.
Note that this will not enter
[overlays](#common.MountedTree.overlay), and you often want
[`resolveInner`](#common.Tree.resolveInner) instead.
*/
resolve(O, e = 0) {
let t = PO(wO.get(this) || this.topNode, O, e, !1);
return wO.set(this, t), t;
}
/**
Like [`resolve`](#common.Tree.resolve), but will enter
[overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
pointing into the innermost overlaid tree at the given position
(with parent links going through all parent structure, including
the host trees).
*/
resolveInner(O, e = 0) {
let t = PO($e.get(this) || this.topNode, O, e, !0);
return $e.set(this, t), t;
}
/**
In some situations, it can be useful to iterate through all
nodes around a position, including those in overlays that don't
directly cover the position. This method gives you an iterator
that will produce all nodes, from small to big, around the given
position.
*/
resolveStack(O, e = 0) {
return Qt(this, O, e);
}
/**
Iterate over the tree and its children, calling `enter` for any
node that touches the `from`/`to` region (if given) before
running over such a node's children, and `leave` (if given) when
leaving the node. When `enter` returns `false`, that node will
not have its children iterated over (or `leave` called).
*/
iterate(O) {
let { enter: e, leave: t, from: i = 0, to: n = this.length } = O, a = O.mode || 0, s = (a & U.IncludeAnonymous) > 0;
for (let l = this.cursor(a | U.IncludeAnonymous); ; ) {
let o = !1;
if (l.from <= n && l.to >= i && (!s && l.type.isAnonymous || e(l) !== !1)) {
if (l.firstChild())
continue;
o = !0;
}
for (; o && t && (s || !l.type.isAnonymous) && t(l), !l.nextSibling(); ) {
if (!l.parent())
return;
o = !0;
}
}
}
/**
Get the value of the given [node prop](#common.NodeProp) for this
node. Works with both per-node and per-type props.
*/
prop(O) {
return O.perNode ? this.props ? this.props[O.id] : void 0 : this.type.prop(O);
}
/**
Returns the node's [per-node props](#common.NodeProp.perNode) in a
format that can be passed to the [`Tree`](#common.Tree)
constructor.
*/
get propValues() {
let O = [];
if (this.props)
for (let e in this.props)
O.push([+e, this.props[e]]);
return O;
}
/**
Balance the direct children of this tree, producing a copy of
which may have children grouped into subtrees with type
[`NodeType.none`](#common.NodeType^none).
*/
balance(O = {}) {
return this.children.length <= 8 ? this : ce(F.none, this.children, this.positions, 0, this.children.length, 0, this.length, (e, t, i) => new Z(this.type, e, t, i, this.propValues), O.makeTree || ((e, t, i) => new Z(F.none, e, t, i)));
}
/**
Build a tree from a postfix-ordered buffer of node information,
or a cursor over such a buffer.
*/
static build(O) {
return gt(O);
}
}
Z.empty = new Z(F.none, [], [], 0);
class he {
constructor(O, e) {
this.buffer = O, this.index = e;
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
get pos() {
return this.index;
}
next() {
this.index -= 4;
}
fork() {
return new he(this.buffer, this.index);
}
}
class oO {
/**
Create a tree buffer.
*/
constructor(O, e, t) {
this.buffer = O, this.length = e, this.set = t;
}
/**
@internal
*/
get type() {
return F.none;
}
/**
@internal
*/
toString() {
let O = [];
for (let e = 0; e < this.buffer.length; )
O.push(this.childString(e)), e = this.buffer[e + 3];
return O.join(",");
}
/**
@internal
*/
childString(O) {
let e = this.buffer[O], t = this.buffer[O + 3], i = this.set.types[e], n = i.name;
if (/\W/.test(n) && !i.isError && (n = JSON.stringify(n)), O += 4, t == O)
return n;
let a = [];
for (; O < t; )
a.push(this.childString(O)), O = this.buffer[O + 3];
return n + "(" + a.join(",") + ")";
}
/**
@internal
*/
findChild(O, e, t, i, n) {
let { buffer: a } = this, s = -1;
for (let l = O; l != e && !(Le(n, i, a[l + 1], a[l + 2]) && (s = l, t > 0)); l = a[l + 3])
;
return s;
}
/**
@internal
*/
slice(O, e, t) {
let i = this.buffer, n = new Uint16Array(e - O), a = 0;
for (let s = O, l = 0; s < e; ) {
n[l++] = i[s++], n[l++] = i[s++] - t;
let o = n[l++] = i[s++] - t;
n[l++] = i[s++] - O, a = Math.max(a, o);
}
return new oO(n, a, this.set);
}
}
function Le(r, O, e, t) {
switch (r) {
case -2:
return e < O;
case -1:
return t >= O && e < O;
case 0:
return e < O && t > O;
case 1:
return e <= O && t > O;
case 2:
return t > O;
case 4:
return !0;
}
}
function PO(r, O, e, t) {
for (var i; r.from == r.to || (e < 1 ? r.from >= O : r.from > O) || (e > -1 ? r.to <= O : r.to < O); ) {
let a = !t && r instanceof I && r.index < 0 ? null : r.parent;
if (!a)
return r;
r = a;
}
let n = t ? 0 : U.IgnoreOverlays;
if (t)
for (let a = r, s = a.parent; s; a = s, s = a.parent)
a instanceof I && a.index < 0 && ((i = s.enter(O, e, n)) === null || i === void 0 ? void 0 : i.from) != a.from && (r = s);
for (; ; ) {
let a = r.enter(O, e, n);
if (!a)
return r;
r = a;
}
}
class Ie {
cursor(O = 0) {
return new ee(this, O);
}
getChild(O, e = null, t = null) {
let i = xe(this, O, e, t);
return i.length ? i[0] : null;
}
getChildren(O, e = null, t = null) {
return xe(this, O, e, t);
}
resolve(O, e = 0) {
return PO(this, O, e, !1);
}
resolveInner(O, e = 0) {
return PO(this, O, e, !0);
}
matchContext(O) {
return Oe(this.parent, O);
}
enterUnfinishedNodesBefore(O) {
let e = this.childBefore(O), t = this;
for (; e; ) {
let i = e.lastChild;
if (!i || i.to != e.to)
break;
i.type.isError && i.from == i.to ? (t = e, e = i.prevSibling) : e = i;
}
return t;
}
get node() {
return this;
}
get next() {
return this.parent;
}
}
class I extends Ie {
constructor(O, e, t, i) {
super(), this._tree = O, this.from = e, this.index = t, this._parent = i;
}
get type() {
return this._tree.type;
}
get name() {
return this._tree.type.name;
}
get to() {
return this.from + this._tree.length;
}
nextChild(O, e, t, i, n = 0) {
for (let a = this; ; ) {
for (let { children: s, positions: l } = a._tree, o = e > 0 ? s.length : -1; O != o; O += e) {
let u = s[O], X = l[O] + a.from, c;
if (!(!(n & U.EnterBracketed && u instanceof Z && (c = yO.get(u)) && !c.overlay && c.bracketed && t >= X && t <= X + u.length) && !Le(i, t, X, X + u.length))) {
if (u instanceof oO) {
if (n & U.ExcludeBuffers)
continue;
let p = u.findChild(0, u.buffer.length, e, t - X, i);
if (p > -1)
return new aO(new pt(a, u, O, X), null, p);
} else if (n & U.IncludeAnonymous || !u.type.isAnonymous || Xe(u)) {
let p;
if (!(n & U.IgnoreMounts) && (p = yO.get(u)) && !p.overlay)
return new I(p.tree, X, O, a);
let Q = new I(u, X, O, a);
return n & U.IncludeAnonymous || !Q.type.isAnonymous ? Q : Q.nextChild(e < 0 ? u.children.length - 1 : 0, e, t, i, n);
}
}
}
if (n & U.IncludeAnonymous || !a.type.isAnonymous || (a.index >= 0 ? O = a.index + e : O = e < 0 ? -1 : a._parent._tree.children.length, a = a._parent, !a))
return null;
}
}
get firstChild() {
return this.nextChild(
0,
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.nextChild(
this._tree.children.length - 1,
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(O) {
return this.nextChild(
0,
1,
O,
2
/* Side.After */
);
}
childBefore(O) {
return this.nextChild(
this._tree.children.length - 1,
-1,
O,
-2
/* Side.Before */
);
}
prop(O) {
return this._tree.prop(O);
}
enter(O, e, t = 0) {
let i;
if (!(t & U.IgnoreOverlays) && (i = yO.get(this._tree)) && i.overlay) {
let n = O - this.from, a = t & U.EnterBracketed && i.bracketed;
for (let { from: s, to: l } of i.overlay)
if ((e > 0 || a ? s <= n : s < n) && (e < 0 || a ? l >= n : l > n))
return new I(i.tree, i.overlay[0].from + this.from, -1, this);
}
return this.nextChild(0, 1, O, e, t);
}
nextSignificantParent() {
let O = this;
for (; O.type.isAnonymous && O._parent; )
O = O._parent;
return O;
}
get parent() {
return this._parent ? this._parent.nextSignificantParent() : null;
}
get nextSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index + 1,
1,
0,
4
/* Side.DontCare */
) : null;
}
get prevSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index - 1,
-1,
0,
4
/* Side.DontCare */
) : null;
}
get tree() {
return this._tree;
}
toTree() {
return this._tree;
}
/**
@internal
*/
toString() {
return this._tree.toString();
}
}
function xe(r, O, e, t) {
let i = r.cursor(), n = [];
if (!i.firstChild())
return n;
if (e != null) {
for (let a = !1; !a; )
if (a = i.type.is(e), !i.nextSibling())
return n;
}
for (; ; ) {
if (t != null && i.type.is(t))
return n;
if (i.type.is(O) && n.push(i.node), !i.nextSibling())
return t == null ? n : [];
}
}
function Oe(r, O, e = O.length - 1) {
for (let t = r; e >= 0; t = t.parent) {
if (!t)
return !1;
if (!t.type.isAnonymous) {
if (O[e] && O[e] != t.name)
return !1;
e--;
}
}
return !0;
}
class pt {
constructor(O, e, t, i) {
this.parent = O, this.buffer = e, this.index = t, this.start = i;
}
}
class aO extends Ie {
get name() {
return this.type.name;
}
get from() {
return this.context.start + this.context.buffer.buffer[this.index + 1];
}
get to() {
return this.context.start + this.context.buffer.buffer[this.index + 2];
}
constructor(O, e, t) {
super(), this.context = O, this._parent = e, this.index = t, this.type = O.buffer.set.types[O.buffer.buffer[t]];
}
child(O, e, t) {
let { buffer: i } = this.context, n = i.findChild(this.index + 4, i.buffer[this.index + 3], O, e - this.context.start, t);
return n < 0 ? null : new aO(this.context, this, n);
}
get firstChild() {
return this.child(
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.child(
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(O) {
return this.child(
1,
O,
2
/* Side.After */
);
}
childBefore(O) {
return this.child(
-1,
O,
-2
/* Side.Before */
);
}
prop(O) {
return this.type.prop(O);
}
enter(O, e, t = 0) {
if (t & U.ExcludeBuffers)
return null;
let { buffer: i } = this.context, n = i.findChild(this.index + 4, i.buffer[this.index + 3], e > 0 ? 1 : -1, O - this.context.start, e);
return n < 0 ? null : new aO(this.context, this, n);
}
get parent() {
return this._parent || this.context.parent.nextSignificantParent();
}
externalSibling(O) {
return this._parent ? null : this.context.parent.nextChild(
this.context.index + O,
O,
0,
4
/* Side.DontCare */
);
}
get nextSibling() {
let { buffer: O } = this.context, e = O.buffer[this.index + 3];
return e < (this._parent ? O.buffer[this._parent.index + 3] : O.buffer.length) ? new aO(this.context, this._parent, e) : this.externalSibling(1);
}
get prevSibling() {
let { buffer: O } = this.context, e = this._parent ? this._parent.index + 4 : 0;
return this.index == e ? this.externalSibling(-1) : new aO(this.context, this._parent, O.findChild(
e,
this.index,
-1,
0,
4
/* Side.DontCare */
));
}
get tree() {
return null;
}
toTree() {
let O = [], e = [], { buffer: t } = this.context, i = this.index + 4, n = t.buffer[this.index + 3];
if (n > i) {
let a = t.buffer[this.index + 1];
O.push(t.slice(i, n, a)), e.push(0);
}
return new Z(this.type, O, e, this.to - this.from);
}
/**
@internal
*/
toString() {
return this.context.buffer.childString(this.index);
}
}
function Fe(r) {
if (!r.length)
return null;
let O = 0, e = r[0];
for (let n = 1; n < r.length; n++) {
let a = r[n];
(a.from > e.from || a.to < e.to) && (e = a, O = n);
}
let t = e instanceof I && e.index < 0 ? null : e.parent, i = r.slice();
return t ? i[O] = t : i.splice(O, 1), new dt(i, e);
}
class dt {
constructor(O, e) {
this.heads = O, this.node = e;
}
get next() {
return Fe(this.heads);
}
}
function Qt(r, O, e) {
let t = r.resolveInner(O, e), i = null;
for (let n = t instanceof I ? t : t.context.parent; n; n = n.parent)
if (n.index < 0) {
let a = n.parent;
(i || (i = [t])).push(a.resolve(O, e)), n = a;
} else {
let a = yO.get(n.tree);
if (a && a.overlay && a.overlay[0].from <= O && a.overlay[a.overlay.length - 1].to >= O) {
let s = new I(a.tree, a.overlay[0].from + n.from, -1, n);
(i || (i = [t])).push(PO(s, O, e, !1));
}
}
return i ? Fe(i) : t;
}
class ee {
/**
Shorthand for `.type.name`.
*/
get name() {
return this.type.name;
}
/**
@internal
*/
constructor(O, e = 0) {
if (this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, this.mode = e & ~U.EnterBracketed, O instanceof I)
this.yieldNode(O);
else {
this._tree = O.context.parent, this.buffer = O.context;
for (let t = O._parent; t; t = t._parent)
this.stack.unshift(t.index);
this.bufferNode = O, this.yieldBuf(O.index);
}
}
yieldNode(O) {
return O ? (this._tree = O, this.type = O.type, this.from = O.from, this.to = O.to, !0) : !1;
}
yieldBuf(O, e) {
this.index = O;
let { start: t, buffer: i } = this.buffer;
return this.type = e || i.set.types[i.buffer[O]], this.from = t + i.buffer[O + 1], this.to = t + i.buffer[O + 2], !0;
}
/**
@internal
*/
yield(O) {
return O ? O instanceof I ? (this.buffer = null, this.yieldNode(O)) : (this.buffer = O.context, this.yieldBuf(O.index, O.type)) : !1;
}
/**
@internal
*/
toString() {
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
}
/**
@internal
*/
enterChild(O, e, t) {
if (!this.buffer)
return this.yield(this._tree.nextChild(O < 0 ? this._tree._tree.children.length - 1 : 0, O, e, t, this.mode));
let { buffer: i } = this.buffer, n = i.findChild(this.index + 4, i.buffer[this.index + 3], O, e - this.buffer.start, t);
return n < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(n));
}
/**
Move the cursor to this node's first child. When this returns
false, the node has no child, and the cursor has not been moved.
*/
firstChild() {
return this.enterChild(
1,
0,
4
/* Side.DontCare */
);
}
/**
Move the cursor to this node's last child.
*/
lastChild() {
return this.enterChild(
-1,
0,
4
/* Side.DontCare */
);
}
/**
Move the cursor to the first child that ends after `pos`.
*/
childAfter(O) {
return this.enterChild(
1,
O,
2
/* Side.After */
);
}
/**
Move to the last child that starts before `pos`.
*/
childBefore(O) {
return this.enterChild(
-1,
O,
-2
/* Side.Before */
);
}
/**
Move the cursor to the child around `pos`. If side is -1 the
child may end at that position, when 1 it may start there. This
will also enter [overlaid](#common.MountedTree.overlay)
[mounted](#common.NodeProp^mounted) trees unless `overlays` is
set to false.
*/
enter(O, e, t = this.mode) {
return this.buffer ? t & U.ExcludeBuffers ? !1 : this.enterChild(1, O, e) : this.yield(this._tree.enter(O, e, t));
}
/**
Move to the node's parent node, if this isn't the top node.
*/
parent() {
if (!this.buffer)
return this.yieldNode(this.mode & U.IncludeAnonymous ? this._tree._parent : this._tree.parent);
if (this.stack.length)
return this.yieldBuf(this.stack.pop());
let O = this.mode & U.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
return this.buffer = null, this.yieldNode(O);
}
/**
@internal
*/
sibling(O) {
if (!this.buffer)
return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + O, O, 0, 4, this.mode)) : !1;
let { buffer: e } = this.buffer, t = this.stack.length - 1;
if (O < 0) {
let i = t < 0 ? 0 : this.stack[t] + 4;
if (this.index != i)
return this.yieldBuf(e.findChild(
i,
this.index,
-1,
0,
4
/* Side.DontCare */
));
} else {
let i = e.buffer[this.index + 3];
if (i < (t < 0 ? e.buffer.length : e.buffer[this.stack[t] + 3]))
return this.yieldBuf(i);
}
return t < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + O, O, 0, 4, this.mode)) : !1;
}
/**
Move to this node's next sibling, if any.
*/
nextSibling() {
return this.sibling(1);
}
/**
Move to this node's previous sibling, if any.
*/
prevSibling() {
return this.sibling(-1);
}
atLastNode(O) {
let e, t, { buffer: i } = this;
if (i) {
if (O > 0) {
if (this.index < i.buffer.buffer.length)
return !1;
} else
for (let n = 0; n < this.index; n++)
if (i.buffer.buffer[n + 3] < this.index)
return !1;
({ index: e, parent: t } = i);
} else
({ index: e, _parent: t } = this._tree);
for (; t; { index: e, _parent: t } = t)
if (e > -1)
for (let n = e + O, a = O < 0 ? -1 : t._tree.children.length; n != a; n += O) {
let s = t._tree.children[n];
if (this.mode & U.IncludeAnonymous || s instanceof oO || !s.type.isAnonymous || Xe(s))
return !1;
}
return !0;
}
move(O, e) {
if (e && this.enterChild(
O,
0,
4
/* Side.DontCare */
))
return !0;
for (; ; ) {
if (this.sibling(O))
return !0;
if (this.atLastNode(O) || !this.parent())
return !1;
}
}
/**
Move to the next node in a
[pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
traversal, going from a node to its first child or, if the
current node is empty or `enter` is false, its next sibling or
the next sibling of the first parent node that has one.
*/
next(O = !0) {
return this.move(1, O);
}
/**
Move to the next node in a last-to-first pre-order traversal. A
node is followed by its last child or, if it has none, its
previous sibling or the previous sibling of the first parent
node that has one.
*/
prev(O = !0) {
return this.move(-1, O);
}
/**
Move the cursor to the innermost node that covers `pos`. If
`side` is -1, it will enter nodes that end at `pos`. If it is 1,
it will enter nodes that start at `pos`.
*/