-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
9856 lines (9750 loc) · 327 KB
/
index.js
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
// node_modules/codemirror/src/util/browser.js
var userAgent = navigator.userAgent;
var platform = navigator.platform;
var gecko = /gecko\/\d/i.test(userAgent);
var ie_upto10 = /MSIE \d/.test(userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
var edge = /Edge\/(\d+)/.exec(userAgent);
var ie = ie_upto10 || ie_11up || edge;
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
var webkit = !edge && /WebKit\//.test(userAgent);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
var chrome = !edge && /Chrome\//.test(userAgent);
var presto = /Opera\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent);
var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
var android = /Android/.test(userAgent);
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
var mac = ios || /Mac/.test(platform);
var chromeOS = /\bCrOS\b/.test(userAgent);
var windows = /win/i.test(platform);
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
if (presto_version)
presto_version = Number(presto_version[1]);
if (presto_version && presto_version >= 15) {
presto = false;
webkit = true;
}
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
var captureRightClick = gecko || ie && ie_version >= 9;
// node_modules/codemirror/src/util/dom.js
function classTest(cls) {
return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*");
}
var rmClass = function(node, cls) {
let current = node.className;
let match = classTest(cls).exec(current);
if (match) {
let after = current.slice(match.index + match[0].length);
node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
}
};
function removeChildren(e) {
for (let count = e.childNodes.length; count > 0; --count)
e.removeChild(e.firstChild);
return e;
}
function removeChildrenAndAdd(parent, e) {
return removeChildren(parent).appendChild(e);
}
function elt(tag, content, className, style) {
let e = document.createElement(tag);
if (className)
e.className = className;
if (style)
e.style.cssText = style;
if (typeof content == "string")
e.appendChild(document.createTextNode(content));
else if (content)
for (let i = 0; i < content.length; ++i)
e.appendChild(content[i]);
return e;
}
function eltP(tag, content, className, style) {
let e = elt(tag, content, className, style);
e.setAttribute("role", "presentation");
return e;
}
var range;
if (document.createRange)
range = function(node, start, end, endNode) {
let r = document.createRange();
r.setEnd(endNode || node, end);
r.setStart(node, start);
return r;
};
else
range = function(node, start, end) {
let r = document.body.createTextRange();
try {
r.moveToElementText(node.parentNode);
} catch (e) {
return r;
}
r.collapse(true);
r.moveEnd("character", end);
r.moveStart("character", start);
return r;
};
function contains(parent, child) {
if (child.nodeType == 3)
child = child.parentNode;
if (parent.contains)
return parent.contains(child);
do {
if (child.nodeType == 11)
child = child.host;
if (child == parent)
return true;
} while (child = child.parentNode);
}
function activeElt() {
let activeElement;
try {
activeElement = document.activeElement;
} catch (e) {
activeElement = document.body || null;
}
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
activeElement = activeElement.shadowRoot.activeElement;
return activeElement;
}
function addClass(node, cls) {
let current = node.className;
if (!classTest(cls).test(current))
node.className += (current ? " " : "") + cls;
}
function joinClasses(a, b) {
let as = a.split(" ");
for (let i = 0; i < as.length; i++)
if (as[i] && !classTest(as[i]).test(b))
b += " " + as[i];
return b;
}
var selectInput = function(node) {
node.select();
};
if (ios)
selectInput = function(node) {
node.selectionStart = 0;
node.selectionEnd = node.value.length;
};
else if (ie)
selectInput = function(node) {
try {
node.select();
} catch (_e) {
}
};
// node_modules/codemirror/src/util/misc.js
function bind(f) {
let args = Array.prototype.slice.call(arguments, 1);
return function() {
return f.apply(null, args);
};
}
function copyObj(obj, target, overwrite) {
if (!target)
target = {};
for (let prop in obj)
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
target[prop] = obj[prop];
return target;
}
function countColumn(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1)
end = string.length;
}
for (let i = startIndex || 0, n = startValue || 0; ; ) {
let nextTab = string.indexOf(" ", i);
if (nextTab < 0 || nextTab >= end)
return n + (end - i);
n += nextTab - i;
n += tabSize - n % tabSize;
i = nextTab + 1;
}
}
var Delayed = class {
constructor() {
this.id = null;
this.f = null;
this.time = 0;
this.handler = bind(this.onTimeout, this);
}
onTimeout(self2) {
self2.id = 0;
if (self2.time <= +new Date()) {
self2.f();
} else {
setTimeout(self2.handler, self2.time - +new Date());
}
}
set(ms, f) {
this.f = f;
const time = +new Date() + ms;
if (!this.id || time < this.time) {
clearTimeout(this.id);
this.id = setTimeout(this.handler, ms);
this.time = time;
}
}
};
function indexOf(array, elt2) {
for (let i = 0; i < array.length; ++i)
if (array[i] == elt2)
return i;
return -1;
}
var scrollerGap = 50;
var Pass = {toString: function() {
return "CodeMirror.Pass";
}};
var sel_dontScroll = {scroll: false};
var sel_mouse = {origin: "*mouse"};
var sel_move = {origin: "+move"};
function findColumn(string, goal, tabSize) {
for (let pos = 0, col = 0; ; ) {
let nextTab = string.indexOf(" ", pos);
if (nextTab == -1)
nextTab = string.length;
let skipped = nextTab - pos;
if (nextTab == string.length || col + skipped >= goal)
return pos + Math.min(skipped, goal - col);
col += nextTab - pos;
col += tabSize - col % tabSize;
pos = nextTab + 1;
if (col >= goal)
return pos;
}
}
var spaceStrs = [""];
function spaceStr(n) {
while (spaceStrs.length <= n)
spaceStrs.push(lst(spaceStrs) + " ");
return spaceStrs[n];
}
function lst(arr) {
return arr[arr.length - 1];
}
function map(array, f) {
let out = [];
for (let i = 0; i < array.length; i++)
out[i] = f(array[i], i);
return out;
}
function insertSorted(array, value, score) {
let pos = 0, priority = score(value);
while (pos < array.length && score(array[pos]) <= priority)
pos++;
array.splice(pos, 0, value);
}
function nothing() {
}
function createObj(base, props) {
let inst;
if (Object.create) {
inst = Object.create(base);
} else {
nothing.prototype = base;
inst = new nothing();
}
if (props)
copyObj(props, inst);
return inst;
}
var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
function isWordCharBasic(ch) {
return /\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
}
function isWordChar(ch, helper) {
if (!helper)
return isWordCharBasic(ch);
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch))
return true;
return helper.test(ch);
}
function isEmpty(obj) {
for (let n in obj)
if (obj.hasOwnProperty(n) && obj[n])
return false;
return true;
}
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
function isExtendingChar(ch) {
return ch.charCodeAt(0) >= 768 && extendingChars.test(ch);
}
function skipExtendingChars(str, pos, dir) {
while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos)))
pos += dir;
return pos;
}
function findFirst(pred, from, to) {
let dir = from > to ? -1 : 1;
for (; ; ) {
if (from == to)
return from;
let midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
if (mid == from)
return pred(mid) ? from : to;
if (pred(mid))
to = mid;
else
from = mid + dir;
}
}
// node_modules/codemirror/src/util/bidi.js
function iterateBidiSections(order, from, to, f) {
if (!order)
return f(from, to, "ltr", 0);
let found = false;
for (let i = 0; i < order.length; ++i) {
let part = order[i];
if (part.from < to && part.to > from || from == to && part.to == from) {
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
found = true;
}
}
if (!found)
f(from, to, "ltr");
}
var bidiOther = null;
function getBidiPartAt(order, ch, sticky) {
let found;
bidiOther = null;
for (let i = 0; i < order.length; ++i) {
let cur = order[i];
if (cur.from < ch && cur.to > ch)
return i;
if (cur.to == ch) {
if (cur.from != cur.to && sticky == "before")
found = i;
else
bidiOther = i;
}
if (cur.from == ch) {
if (cur.from != cur.to && sticky != "before")
found = i;
else
bidiOther = i;
}
}
return found != null ? found : bidiOther;
}
var bidiOrdering = function() {
let lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
let arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
function charType(code) {
if (code <= 247)
return lowTypes.charAt(code);
else if (1424 <= code && code <= 1524)
return "R";
else if (1536 <= code && code <= 1785)
return arabicTypes.charAt(code - 1536);
else if (1774 <= code && code <= 2220)
return "r";
else if (8192 <= code && code <= 8203)
return "w";
else if (code == 8204)
return "b";
else
return "L";
}
let bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
let isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
function BidiSpan(level, from, to) {
this.level = level;
this.from = from;
this.to = to;
}
return function(str, direction) {
let outerType = direction == "ltr" ? "L" : "R";
if (str.length == 0 || direction == "ltr" && !bidiRE.test(str))
return false;
let len = str.length, types = [];
for (let i = 0; i < len; ++i)
types.push(charType(str.charCodeAt(i)));
for (let i = 0, prev = outerType; i < len; ++i) {
let type = types[i];
if (type == "m")
types[i] = prev;
else
prev = type;
}
for (let i = 0, cur = outerType; i < len; ++i) {
let type = types[i];
if (type == "1" && cur == "r")
types[i] = "n";
else if (isStrong.test(type)) {
cur = type;
if (type == "r")
types[i] = "R";
}
}
for (let i = 1, prev = types[0]; i < len - 1; ++i) {
let type = types[i];
if (type == "+" && prev == "1" && types[i + 1] == "1")
types[i] = "1";
else if (type == "," && prev == types[i + 1] && (prev == "1" || prev == "n"))
types[i] = prev;
prev = type;
}
for (let i = 0; i < len; ++i) {
let type = types[i];
if (type == ",")
types[i] = "N";
else if (type == "%") {
let end;
for (end = i + 1; end < len && types[end] == "%"; ++end) {
}
let replace = i && types[i - 1] == "!" || end < len && types[end] == "1" ? "1" : "N";
for (let j = i; j < end; ++j)
types[j] = replace;
i = end - 1;
}
}
for (let i = 0, cur = outerType; i < len; ++i) {
let type = types[i];
if (cur == "L" && type == "1")
types[i] = "L";
else if (isStrong.test(type))
cur = type;
}
for (let i = 0; i < len; ++i) {
if (isNeutral.test(types[i])) {
let end;
for (end = i + 1; end < len && isNeutral.test(types[end]); ++end) {
}
let before = (i ? types[i - 1] : outerType) == "L";
let after = (end < len ? types[end] : outerType) == "L";
let replace = before == after ? before ? "L" : "R" : outerType;
for (let j = i; j < end; ++j)
types[j] = replace;
i = end - 1;
}
}
let order = [], m;
for (let i = 0; i < len; ) {
if (countsAsLeft.test(types[i])) {
let start = i;
for (++i; i < len && countsAsLeft.test(types[i]); ++i) {
}
order.push(new BidiSpan(0, start, i));
} else {
let pos = i, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
for (++i; i < len && types[i] != "L"; ++i) {
}
for (let j = pos; j < i; ) {
if (countsAsNum.test(types[j])) {
if (pos < j) {
order.splice(at, 0, new BidiSpan(1, pos, j));
at += isRTL;
}
let nstart = j;
for (++j; j < i && countsAsNum.test(types[j]); ++j) {
}
order.splice(at, 0, new BidiSpan(2, nstart, j));
at += isRTL;
pos = j;
} else
++j;
}
if (pos < i)
order.splice(at, 0, new BidiSpan(1, pos, i));
}
}
if (direction == "ltr") {
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
order[0].from = m[0].length;
order.unshift(new BidiSpan(0, 0, m[0].length));
}
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
lst(order).to -= m[0].length;
order.push(new BidiSpan(0, len - m[0].length, len));
}
}
return direction == "rtl" ? order.reverse() : order;
};
}();
function getOrder(line, direction) {
let order = line.order;
if (order == null)
order = line.order = bidiOrdering(line.text, direction);
return order;
}
// node_modules/codemirror/src/util/event.js
var noHandlers = [];
var on = function(emitter, type, f) {
if (emitter.addEventListener) {
emitter.addEventListener(type, f, false);
} else if (emitter.attachEvent) {
emitter.attachEvent("on" + type, f);
} else {
let map2 = emitter._handlers || (emitter._handlers = {});
map2[type] = (map2[type] || noHandlers).concat(f);
}
};
function getHandlers(emitter, type) {
return emitter._handlers && emitter._handlers[type] || noHandlers;
}
function off(emitter, type, f) {
if (emitter.removeEventListener) {
emitter.removeEventListener(type, f, false);
} else if (emitter.detachEvent) {
emitter.detachEvent("on" + type, f);
} else {
let map2 = emitter._handlers, arr = map2 && map2[type];
if (arr) {
let index = indexOf(arr, f);
if (index > -1)
map2[type] = arr.slice(0, index).concat(arr.slice(index + 1));
}
}
}
function signal(emitter, type) {
let handlers = getHandlers(emitter, type);
if (!handlers.length)
return;
let args = Array.prototype.slice.call(arguments, 2);
for (let i = 0; i < handlers.length; ++i)
handlers[i].apply(null, args);
}
function signalDOMEvent(cm, e, override) {
if (typeof e == "string")
e = {type: e, preventDefault: function() {
this.defaultPrevented = true;
}};
signal(cm, override || e.type, cm, e);
return e_defaultPrevented(e) || e.codemirrorIgnore;
}
function signalCursorActivity(cm) {
let arr = cm._handlers && cm._handlers.cursorActivity;
if (!arr)
return;
let set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
for (let i = 0; i < arr.length; ++i)
if (indexOf(set, arr[i]) == -1)
set.push(arr[i]);
}
function hasHandler(emitter, type) {
return getHandlers(emitter, type).length > 0;
}
function eventMixin(ctor) {
ctor.prototype.on = function(type, f) {
on(this, type, f);
};
ctor.prototype.off = function(type, f) {
off(this, type, f);
};
}
function e_preventDefault(e) {
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
}
function e_stopPropagation(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
}
function e_defaultPrevented(e) {
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
}
function e_stop(e) {
e_preventDefault(e);
e_stopPropagation(e);
}
function e_target(e) {
return e.target || e.srcElement;
}
function e_button(e) {
let b = e.which;
if (b == null) {
if (e.button & 1)
b = 1;
else if (e.button & 2)
b = 3;
else if (e.button & 4)
b = 2;
}
if (mac && e.ctrlKey && b == 1)
b = 3;
return b;
}
// node_modules/codemirror/src/util/feature_detection.js
var dragAndDrop = function() {
if (ie && ie_version < 9)
return false;
let div = elt("div");
return "draggable" in div || "dragDrop" in div;
}();
var zwspSupported;
function zeroWidthElement(measure) {
if (zwspSupported == null) {
let test = elt("span", "\u200B");
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
if (measure.firstChild.offsetHeight != 0)
zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
}
let node = zwspSupported ? elt("span", "\u200B") : elt("span", "\xA0", null, "display: inline-block; width: 1px; margin-right: -1px");
node.setAttribute("cm-text", "");
return node;
}
var badBidiRects;
function hasBadBidiRects(measure) {
if (badBidiRects != null)
return badBidiRects;
let txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062EA"));
let r0 = range(txt, 0, 1).getBoundingClientRect();
let r1 = range(txt, 1, 2).getBoundingClientRect();
removeChildren(measure);
if (!r0 || r0.left == r0.right)
return false;
return badBidiRects = r1.right - r0.right < 3;
}
var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? (string) => {
let pos = 0, result = [], l = string.length;
while (pos <= l) {
let nl = string.indexOf("\n", pos);
if (nl == -1)
nl = string.length;
let line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
let rt = line.indexOf("\r");
if (rt != -1) {
result.push(line.slice(0, rt));
pos += rt + 1;
} else {
result.push(line);
pos = nl + 1;
}
}
return result;
} : (string) => string.split(/\r\n?|\n/);
var hasSelection = window.getSelection ? (te) => {
try {
return te.selectionStart != te.selectionEnd;
} catch (e) {
return false;
}
} : (te) => {
let range2;
try {
range2 = te.ownerDocument.selection.createRange();
} catch (e) {
}
if (!range2 || range2.parentElement() != te)
return false;
return range2.compareEndPoints("StartToEnd", range2) != 0;
};
var hasCopyEvent = (() => {
let e = elt("div");
if ("oncopy" in e)
return true;
e.setAttribute("oncopy", "return;");
return typeof e.oncopy == "function";
})();
var badZoomedRects = null;
function hasBadZoomedRects(measure) {
if (badZoomedRects != null)
return badZoomedRects;
let node = removeChildrenAndAdd(measure, elt("span", "x"));
let normal = node.getBoundingClientRect();
let fromRange = range(node, 0, 1).getBoundingClientRect();
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
}
// node_modules/codemirror/src/modes.js
var modes = {};
var mimeModes = {};
function defineMode(name, mode) {
if (arguments.length > 2)
mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
}
function defineMIME(mime, spec) {
mimeModes[mime] = spec;
}
function resolveMode(spec) {
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
spec = mimeModes[spec];
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
let found = mimeModes[spec.name];
if (typeof found == "string")
found = {name: found};
spec = createObj(found, spec);
spec.name = found.name;
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
return resolveMode("application/xml");
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
return resolveMode("application/json");
}
if (typeof spec == "string")
return {name: spec};
else
return spec || {name: "null"};
}
function getMode(options, spec) {
spec = resolveMode(spec);
let mfactory = modes[spec.name];
if (!mfactory)
return getMode(options, "text/plain");
let modeObj = mfactory(options, spec);
if (modeExtensions.hasOwnProperty(spec.name)) {
let exts = modeExtensions[spec.name];
for (let prop in exts) {
if (!exts.hasOwnProperty(prop))
continue;
if (modeObj.hasOwnProperty(prop))
modeObj["_" + prop] = modeObj[prop];
modeObj[prop] = exts[prop];
}
}
modeObj.name = spec.name;
if (spec.helperType)
modeObj.helperType = spec.helperType;
if (spec.modeProps)
for (let prop in spec.modeProps)
modeObj[prop] = spec.modeProps[prop];
return modeObj;
}
var modeExtensions = {};
function extendMode(mode, properties) {
let exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : modeExtensions[mode] = {};
copyObj(properties, exts);
}
function copyState(mode, state) {
if (state === true)
return state;
if (mode.copyState)
return mode.copyState(state);
let nstate = {};
for (let n in state) {
let val = state[n];
if (val instanceof Array)
val = val.concat([]);
nstate[n] = val;
}
return nstate;
}
function innerMode(mode, state) {
let info;
while (mode.innerMode) {
info = mode.innerMode(state);
if (!info || info.mode == mode)
break;
state = info.state;
mode = info.mode;
}
return info || {mode, state};
}
function startState(mode, a1, a2) {
return mode.startState ? mode.startState(a1, a2) : true;
}
// node_modules/codemirror/src/util/StringStream.js
var StringStream = class {
constructor(string, tabSize, lineOracle) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
this.lineStart = 0;
this.lineOracle = lineOracle;
}
eol() {
return this.pos >= this.string.length;
}
sol() {
return this.pos == this.lineStart;
}
peek() {
return this.string.charAt(this.pos) || void 0;
}
next() {
if (this.pos < this.string.length)
return this.string.charAt(this.pos++);
}
eat(match) {
let ch = this.string.charAt(this.pos);
let ok;
if (typeof match == "string")
ok = ch == match;
else
ok = ch && (match.test ? match.test(ch) : match(ch));
if (ok) {
++this.pos;
return ch;
}
}
eatWhile(match) {
let start = this.pos;
while (this.eat(match)) {
}
return this.pos > start;
}
eatSpace() {
let start = this.pos;
while (/[\s\u00a0]/.test(this.string.charAt(this.pos)))
++this.pos;
return this.pos > start;
}
skipToEnd() {
this.pos = this.string.length;
}
skipTo(ch) {
let found = this.string.indexOf(ch, this.pos);
if (found > -1) {
this.pos = found;
return true;
}
}
backUp(n) {
this.pos -= n;
}
column() {
if (this.lastColumnPos < this.start) {
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
this.lastColumnPos = this.start;
}
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
}
indentation() {
return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
}
match(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
let cased = (str) => caseInsensitive ? str.toLowerCase() : str;
let substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false)
this.pos += pattern.length;
return true;
}
} else {
let match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0)
return null;
if (match && consume !== false)
this.pos += match[0].length;
return match;
}
}
current() {
return this.string.slice(this.start, this.pos);
}
hideFirstChars(n, inner) {
this.lineStart += n;
try {
return inner();
} finally {
this.lineStart -= n;
}
}
lookAhead(n) {
let oracle = this.lineOracle;
return oracle && oracle.lookAhead(n);
}
baseToken() {
let oracle = this.lineOracle;
return oracle && oracle.baseToken(this.pos);
}
};
var StringStream_default = StringStream;
// node_modules/codemirror/src/line/utils_line.js
function getLine(doc, n) {
n -= doc.first;
if (n < 0 || n >= doc.size)
throw new Error("There is no line " + (n + doc.first) + " in the document.");
let chunk = doc;
while (!chunk.lines) {
for (let i = 0; ; ++i) {
let child = chunk.children[i], sz = child.chunkSize();
if (n < sz) {
chunk = child;
break;
}
n -= sz;
}
}
return chunk.lines[n];
}
function getBetween(doc, start, end) {
let out = [], n = start.line;
doc.iter(start.line, end.line + 1, (line) => {
let text = line.text;
if (n == end.line)
text = text.slice(0, end.ch);
if (n == start.line)
text = text.slice(start.ch);
out.push(text);
++n;
});
return out;
}
function getLines(doc, from, to) {
let out = [];
doc.iter(from, to, (line) => {
out.push(line.text);
});
return out;
}
function updateLineHeight(line, height) {
let diff = height - line.height;
if (diff)
for (let n = line; n; n = n.parent)
n.height += diff;
}
function lineNo(line) {
if (line.parent == null)
return null;
let cur = line.parent, no = indexOf(cur.lines, line);
for (let chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
for (let i = 0; ; ++i) {
if (chunk.children[i] == cur)
break;
no += chunk.children[i].chunkSize();
}
}
return no + cur.first;
}
function lineAtHeight(chunk, h) {
let n = chunk.first;
outer:
do {
for (let i2 = 0; i2 < chunk.children.length; ++i2) {
let child = chunk.children[i2], ch = child.height;
if (h < ch) {
chunk = child;
continue outer;
}
h -= ch;
n += child.chunkSize();
}
return n;
} while (!chunk.lines);
let i = 0;
for (; i < chunk.lines.length; ++i) {
let line = chunk.lines[i], lh = line.height;
if (h < lh)
break;
h -= lh;
}
return n + i;
}
function isLine(doc, l) {
return l >= doc.first && l < doc.first + doc.size;
}
function lineNumberFor(options, i) {
return String(options.lineNumberFormatter(i + options.firstLineNumber));
}
// node_modules/codemirror/src/line/pos.js
function Pos(line, ch, sticky = null) {
if (!(this instanceof Pos))
return new Pos(line, ch, sticky);
this.line = line;
this.ch = ch;
this.sticky = sticky;
}
function cmp(a, b) {
return a.line - b.line || a.ch - b.ch;
}
function equalCursorPos(a, b) {
return a.sticky == b.sticky && cmp(a, b) == 0;
}
function copyPos(x) {
return Pos(x.line, x.ch);
}
function maxPos(a, b) {
return cmp(a, b) < 0 ? b : a;
}
function minPos(a, b) {
return cmp(a, b) < 0 ? a : b;
}
function clipLine(doc, n) {
return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));
}
function clipPos(doc, pos) {
if (pos.line < doc.first)
return Pos(doc.first, 0);
let last = doc.first + doc.size - 1;
if (pos.line > last)
return Pos(last, getLine(doc, last).text.length);
return clipToLen(pos, getLine(doc, pos.line).text.length);
}
function clipToLen(pos, linelen) {
let ch = pos.ch;
if (ch == null || ch > linelen)
return Pos(pos.line, linelen);
else if (ch < 0)
return Pos(pos.line, 0);
else
return pos;
}
function clipPosArray(doc, array) {
let out = [];
for (let i = 0; i < array.length; i++)
out[i] = clipPos(doc, array[i]);
return out;
}