forked from kakaroto/Beyond20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fvtt.js
7067 lines (6878 loc) · 308 KB
/
fvtt.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
(function(){
"use strict";
var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256";
var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";
var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;
var ρσ_object_counter = 0;
var ρσ_len;
function ρσ_bool(val) {
return !!val;
};
if (!ρσ_bool.__argnames__) Object.defineProperties(ρσ_bool, {
__argnames__ : {value: ["val"]}
});
function ρσ_print() {
var parts;
if (typeof console === "object") {
parts = [];
for (var i = 0; i < arguments.length; i++) {
parts.push(ρσ_str(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]));
}
console.log(parts.join(" "));
}
};
function ρσ_int(val, base) {
var ans;
if (typeof val === "number") {
ans = val | 0;
} else {
ans = parseInt(val, base || 10);
}
if (isNaN(ans)) {
throw new ValueError("Invalid literal for int with base " + (base || 10) + ": " + val);
}
return ans;
};
if (!ρσ_int.__argnames__) Object.defineProperties(ρσ_int, {
__argnames__ : {value: ["val", "base"]}
});
function ρσ_float(val) {
var ans;
if (typeof val === "number") {
ans = val;
} else {
ans = parseFloat(val);
}
if (isNaN(ans)) {
throw new ValueError("Could not convert string to float: " + arguments[0]);
}
return ans;
};
if (!ρσ_float.__argnames__) Object.defineProperties(ρσ_float, {
__argnames__ : {value: ["val"]}
});
function ρσ_arraylike_creator() {
var names;
names = "Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" ");
if (typeof HTMLCollection === "function") {
names = names.concat("HTMLCollection NodeList NamedNodeMap TouchList".split(" "));
}
return (function() {
var ρσ_anonfunc = function (x) {
if (Array.isArray(x) || typeof x === "string" || names.indexOf(Object.prototype.toString.call(x).slice(8, -1)) > -1) {
return true;
}
return false;
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["x"]}
});
return ρσ_anonfunc;
})();
};
function options_object(f) {
return function () {
if (typeof arguments[arguments.length - 1] === "object") {
arguments[ρσ_bound_index(arguments.length - 1, arguments)][ρσ_kwargs_symbol] = true;
}
return f.apply(this, arguments);
};
};
if (!options_object.__argnames__) Object.defineProperties(options_object, {
__argnames__ : {value: ["f"]}
});
function ρσ_id(x) {
return x.ρσ_object_id;
};
if (!ρσ_id.__argnames__) Object.defineProperties(ρσ_id, {
__argnames__ : {value: ["x"]}
});
function ρσ_dir(item) {
var arr;
arr = ρσ_list_decorate([]);
for (var i in item) {
arr.push(i);
}
return arr;
};
if (!ρσ_dir.__argnames__) Object.defineProperties(ρσ_dir, {
__argnames__ : {value: ["item"]}
});
function ρσ_ord(x) {
var ans, second;
ans = x.charCodeAt(0);
if (55296 <= ans && ans <= 56319) {
second = x.charCodeAt(1);
if (56320 <= second && second <= 57343) {
return (ans - 55296) * 1024 + second - 56320 + 65536;
}
throw new TypeError("string is missing the low surrogate char");
}
return ans;
};
if (!ρσ_ord.__argnames__) Object.defineProperties(ρσ_ord, {
__argnames__ : {value: ["x"]}
});
function ρσ_chr(code) {
if (code <= 65535) {
return String.fromCharCode(code);
}
code -= 65536;
return String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));
};
if (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, {
__argnames__ : {value: ["code"]}
});
function ρσ_callable(x) {
return typeof x === "function";
};
if (!ρσ_callable.__argnames__) Object.defineProperties(ρσ_callable, {
__argnames__ : {value: ["x"]}
});
function ρσ_bin(x) {
var ans;
if (typeof x !== "number" || x % 1 !== 0) {
throw new TypeError("integer required");
}
ans = x.toString(2);
if (ans[0] === "-") {
ans = "-" + "0b" + ans.slice(1);
} else {
ans = "0b" + ans;
}
return ans;
};
if (!ρσ_bin.__argnames__) Object.defineProperties(ρσ_bin, {
__argnames__ : {value: ["x"]}
});
function ρσ_hex(x) {
var ans;
if (typeof x !== "number" || x % 1 !== 0) {
throw new TypeError("integer required");
}
ans = x.toString(16);
if (ans[0] === "-") {
ans = "-" + "0x" + ans.slice(1);
} else {
ans = "0x" + ans;
}
return ans;
};
if (!ρσ_hex.__argnames__) Object.defineProperties(ρσ_hex, {
__argnames__ : {value: ["x"]}
});
function ρσ_enumerate(iterable) {
var ans, iterator;
ans = {"_i":-1};
ans[ρσ_iterator_symbol] = function () {
return this;
};
if (ρσ_arraylike(iterable)) {
ans["next"] = function () {
this._i += 1;
if (this._i < iterable.length) {
return {'done':false, 'value':[this._i, iterable[this._i]]};
}
return {'done':true};
};
return ans;
}
if (typeof iterable[ρσ_iterator_symbol] === "function") {
iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
ans["_iterator"] = iterator;
ans["next"] = function () {
var r;
r = this._iterator.next();
if (r.done) {
return {'done':true};
}
this._i += 1;
return {'done':false, 'value':[this._i, r.value]};
};
return ans;
}
return ρσ_enumerate(Object.keys(iterable));
};
if (!ρσ_enumerate.__argnames__) Object.defineProperties(ρσ_enumerate, {
__argnames__ : {value: ["iterable"]}
});
function ρσ_reversed(iterable) {
var ans;
if (ρσ_arraylike(iterable)) {
ans = {"_i": iterable.length};
ans["next"] = function () {
this._i -= 1;
if (this._i > -1) {
return {'done':false, 'value':iterable[this._i]};
}
return {'done':true};
};
ans[ρσ_iterator_symbol] = function () {
return this;
};
return ans;
}
throw new TypeError("reversed() can only be called on arrays or strings");
};
if (!ρσ_reversed.__argnames__) Object.defineProperties(ρσ_reversed, {
__argnames__ : {value: ["iterable"]}
});
function ρσ_iter(iterable) {
var ans;
if (typeof iterable[ρσ_iterator_symbol] === "function") {
return (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
}
if (ρσ_arraylike(iterable)) {
ans = {"_i":-1};
ans[ρσ_iterator_symbol] = function () {
return this;
};
ans["next"] = function () {
this._i += 1;
if (this._i < iterable.length) {
return {'done':false, 'value':iterable[this._i]};
}
return {'done':true};
};
return ans;
}
return ρσ_iter(Object.keys(iterable));
};
if (!ρσ_iter.__argnames__) Object.defineProperties(ρσ_iter, {
__argnames__ : {value: ["iterable"]}
});
function ρσ_range_next(step, length) {
var ρσ_unpack;
this._i += step;
this._idx += 1;
if (this._idx >= length) {
ρσ_unpack = [this.__i, -1];
this._i = ρσ_unpack[0];
this._idx = ρσ_unpack[1];
return {'done':true};
}
return {'done':false, 'value':this._i};
};
if (!ρσ_range_next.__argnames__) Object.defineProperties(ρσ_range_next, {
__argnames__ : {value: ["step", "length"]}
});
function ρσ_range(start, stop, step) {
var length, ans;
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
step = arguments[2] || 1;
length = Math.max(Math.ceil((stop - start) / step), 0);
ans = {start:start, step:step, stop:stop};
ans[ρσ_iterator_symbol] = function () {
var it;
it = {"_i": start - step, "_idx": -1};
it.next = ρσ_range_next.bind(it, step, length);
it[ρσ_iterator_symbol] = function () {
return this;
};
return it;
};
ans.count = (function() {
var ρσ_anonfunc = function (val) {
if (!this._cached) {
this._cached = list(this);
}
return this._cached.count(val);
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["val"]}
});
return ρσ_anonfunc;
})();
ans.index = (function() {
var ρσ_anonfunc = function (val) {
if (!this._cached) {
this._cached = list(this);
}
return this._cached.index(val);
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["val"]}
});
return ρσ_anonfunc;
})();
if (typeof Proxy === "function") {
ans = new Proxy(ans, (function(){
var ρσ_d = {};
ρσ_d["get"] = (function() {
var ρσ_anonfunc = function (obj, prop) {
var iprop;
if (typeof prop === "string") {
iprop = parseInt(prop);
if (!isNaN(iprop)) {
prop = iprop;
}
}
if (typeof prop === "number") {
if (!obj._cached) {
obj._cached = list(obj);
}
return (ρσ_expr_temp = obj._cached)[(typeof prop === "number" && prop < 0) ? ρσ_expr_temp.length + prop : prop];
}
return obj[(typeof prop === "number" && prop < 0) ? obj.length + prop : prop];
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["obj", "prop"]}
});
return ρσ_anonfunc;
})();
return ρσ_d;
}).call(this));
}
return ans;
};
if (!ρσ_range.__argnames__) Object.defineProperties(ρσ_range, {
__argnames__ : {value: ["start", "stop", "step"]}
});
function ρσ_getattr(obj, name, defval) {
var ret;
try {
ret = obj[(typeof name === "number" && name < 0) ? obj.length + name : name];
} catch (ρσ_Exception) {
ρσ_last_exception = ρσ_Exception;
if (ρσ_Exception instanceof TypeError) {
if (defval === undefined) {
throw new AttributeError("The attribute " + name + " is not present");
}
return defval;
} else {
throw ρσ_Exception;
}
}
if (ret === undefined && !(name in obj)) {
if (defval === undefined) {
throw new AttributeError("The attribute " + name + " is not present");
}
ret = defval;
}
return ret;
};
if (!ρσ_getattr.__argnames__) Object.defineProperties(ρσ_getattr, {
__argnames__ : {value: ["obj", "name", "defval"]}
});
function ρσ_setattr(obj, name, value) {
obj[(typeof name === "number" && name < 0) ? obj.length + name : name] = value;
};
if (!ρσ_setattr.__argnames__) Object.defineProperties(ρσ_setattr, {
__argnames__ : {value: ["obj", "name", "value"]}
});
function ρσ_hasattr(obj, name) {
return name in obj;
};
if (!ρσ_hasattr.__argnames__) Object.defineProperties(ρσ_hasattr, {
__argnames__ : {value: ["obj", "name"]}
});
ρσ_len = function () {
function len(obj) {
if (ρσ_arraylike(obj)) {
return obj.length;
}
if (typeof obj.__len__ === "function") {
return obj.__len__();
}
if (obj instanceof Set || obj instanceof Map) {
return obj.size;
}
return Object.keys(obj).length;
};
if (!len.__argnames__) Object.defineProperties(len, {
__argnames__ : {value: ["obj"]}
});
function len5(obj) {
if (ρσ_arraylike(obj)) {
return obj.length;
}
if (typeof obj.__len__ === "function") {
return obj.__len__();
}
return Object.keys(obj).length;
};
if (!len5.__argnames__) Object.defineProperties(len5, {
__argnames__ : {value: ["obj"]}
});
return (typeof Set === "function" && typeof Map === "function") ? len : len5;
}();
function ρσ_get_module(name) {
return ρσ_modules[(typeof name === "number" && name < 0) ? ρσ_modules.length + name : name];
};
if (!ρσ_get_module.__argnames__) Object.defineProperties(ρσ_get_module, {
__argnames__ : {value: ["name"]}
});
function ρσ_pow(x, y, z) {
var ans;
ans = Math.pow(x, y);
if (z !== undefined) {
ans %= z;
}
return ans;
};
if (!ρσ_pow.__argnames__) Object.defineProperties(ρσ_pow, {
__argnames__ : {value: ["x", "y", "z"]}
});
function ρσ_type(x) {
return x.constructor;
};
if (!ρσ_type.__argnames__) Object.defineProperties(ρσ_type, {
__argnames__ : {value: ["x"]}
});
function ρσ_divmod(x, y) {
var d;
if (y === 0) {
throw new ZeroDivisionError("integer division or modulo by zero");
}
d = Math.floor(x / y);
return [d, x - d * y];
};
if (!ρσ_divmod.__argnames__) Object.defineProperties(ρσ_divmod, {
__argnames__ : {value: ["x", "y"]}
});
function ρσ_max() {
var kwargs = arguments[arguments.length-1];
if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {};
var args = Array.prototype.slice.call(arguments, 0);
if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop();
var args, x;
if (args.length === 0) {
if (kwargs.defval !== undefined) {
return kwargs.defval;
}
throw new TypeError("expected at least one argument");
}
if (args.length === 1) {
args = args[0];
}
if (kwargs.key) {
args = (function() {
var ρσ_Iter = ρσ_Iterable(args), ρσ_Result = [], x;
for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
x = ρσ_Iter[ρσ_Index];
ρσ_Result.push(kwargs.key(x));
}
ρσ_Result = ρσ_list_constructor(ρσ_Result);
return ρσ_Result;
})();
}
if (!Array.isArray(args)) {
args = list(args);
}
if (args.length) {
return this.apply(null, args);
}
if (kwargs.defval !== undefined) {
return kwargs.defval;
}
throw new TypeError("expected at least one argument");
};
if (!ρσ_max.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_max, {
__handles_kwarg_interpolation__ : {value: true}
});
var abs = Math.abs, max = ρσ_max.bind(Math.max), min = ρσ_max.bind(Math.min), bool = ρσ_bool, type = ρσ_type;
var float = ρσ_float, int = ρσ_int, arraylike = ρσ_arraylike_creator(), ρσ_arraylike = arraylike;
var print = ρσ_print, id = ρσ_id, get_module = ρσ_get_module, pow = ρσ_pow, divmod = ρσ_divmod;
var dir = ρσ_dir, ord = ρσ_ord, chr = ρσ_chr, bin = ρσ_bin, hex = ρσ_hex, callable = ρσ_callable;
var enumerate = ρσ_enumerate, iter = ρσ_iter, reversed = ρσ_reversed, len = ρσ_len;
var range = ρσ_range, getattr = ρσ_getattr, setattr = ρσ_setattr, hasattr = ρσ_hasattr;function ρσ_equals(a, b) {
var ρσ_unpack, akeys, bkeys, key;
if (a === b) {
return true;
}
if (a && typeof a.__eq__ === "function") {
return a.__eq__(b);
}
if (b && typeof b.__eq__ === "function") {
return b.__eq__(a);
}
if (ρσ_arraylike(a) && ρσ_arraylike(b)) {
if ((a.length !== b.length && (typeof a.length !== "object" || ρσ_not_equals(a.length, b.length)))) {
return false;
}
for (var i=0; i < a.length; i++) {
if (!((a[(typeof i === "number" && i < 0) ? a.length + i : i] === b[(typeof i === "number" && i < 0) ? b.length + i : i] || typeof a[(typeof i === "number" && i < 0) ? a.length + i : i] === "object" && ρσ_equals(a[(typeof i === "number" && i < 0) ? a.length + i : i], b[(typeof i === "number" && i < 0) ? b.length + i : i])))) {
return false;
}
}
return true;
}
if (typeof a === "object" && typeof b === "object" && a !== null && b !== null && (a.constructor === Object && b.constructor === Object || Object.getPrototypeOf(a) === null && Object.getPrototypeOf(b) === null)) {
ρσ_unpack = [Object.keys(a), Object.keys(b)];
akeys = ρσ_unpack[0];
bkeys = ρσ_unpack[1];
if (akeys.length !== bkeys.length) {
return false;
}
for (var j=0; j < akeys.length; j++) {
key = akeys[(typeof j === "number" && j < 0) ? akeys.length + j : j];
if (!((a[(typeof key === "number" && key < 0) ? a.length + key : key] === b[(typeof key === "number" && key < 0) ? b.length + key : key] || typeof a[(typeof key === "number" && key < 0) ? a.length + key : key] === "object" && ρσ_equals(a[(typeof key === "number" && key < 0) ? a.length + key : key], b[(typeof key === "number" && key < 0) ? b.length + key : key])))) {
return false;
}
}
return true;
}
return false;
};
if (!ρσ_equals.__argnames__) Object.defineProperties(ρσ_equals, {
__argnames__ : {value: ["a", "b"]}
});
function ρσ_not_equals(a, b) {
if (a === b) {
return false;
}
if (a && typeof a.__ne__ === "function") {
return a.__ne__(b);
}
if (b && typeof b.__ne__ === "function") {
return b.__ne__(a);
}
return !ρσ_equals(a, b);
};
if (!ρσ_not_equals.__argnames__) Object.defineProperties(ρσ_not_equals, {
__argnames__ : {value: ["a", "b"]}
});
var equals = ρσ_equals;
function ρσ_list_extend(iterable) {
var start, iterator, result;
if (Array.isArray(iterable) || typeof iterable === "string") {
start = this.length;
this.length += iterable.length;
for (var i = 0; i < iterable.length; i++) {
(ρσ_expr_temp = this)[ρσ_bound_index(start + i, ρσ_expr_temp)] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
}
} else {
iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
result = iterator.next();
while (!result.done) {
this.push(result.value);
result = iterator.next();
}
}
};
if (!ρσ_list_extend.__argnames__) Object.defineProperties(ρσ_list_extend, {
__argnames__ : {value: ["iterable"]}
});
function ρσ_list_index(val, start, stop) {
var idx;
start = start || 0;
if (start < 0) {
start = this.length + start;
}
if (start < 0) {
throw new ValueError(val + " is not in list");
}
if (stop === undefined) {
idx = this.indexOf(val, start);
if (idx === -1) {
throw new ValueError(val + " is not in list");
}
return idx;
}
if (stop < 0) {
stop = this.length + stop;
}
for (var i = start; i < stop; i++) {
if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) {
return i;
}
}
throw new ValueError(val + " is not in list");
};
if (!ρσ_list_index.__argnames__) Object.defineProperties(ρσ_list_index, {
__argnames__ : {value: ["val", "start", "stop"]}
});
function ρσ_list_pop(index) {
var ans;
if (this.length === 0) {
throw new IndexError("list is empty");
}
if (index === undefined) {
index = -1;
}
ans = this.splice(index, 1);
if (!ans.length) {
throw new IndexError("pop index out of range");
}
return ans[0];
};
if (!ρσ_list_pop.__argnames__) Object.defineProperties(ρσ_list_pop, {
__argnames__ : {value: ["index"]}
});
function ρσ_list_remove(value) {
var idx;
idx = this.indexOf(value);
if (idx === -1) {
throw new ValueError(value + " not in list");
}
this.splice(idx, 1);
};
if (!ρσ_list_remove.__argnames__) Object.defineProperties(ρσ_list_remove, {
__argnames__ : {value: ["value"]}
});
function ρσ_list_to_string() {
return "[" + this.join(", ") + "]";
};
function ρσ_list_insert(index, val) {
if (index < 0) {
index += this.length;
}
index = min(this.length, max(index, 0));
if (index === 0) {
this.unshift(val);
return;
}
for (var i = this.length; i > index; i--) {
(ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = (ρσ_expr_temp = this)[ρσ_bound_index(i - 1, ρσ_expr_temp)];
}
(ρσ_expr_temp = this)[(typeof index === "number" && index < 0) ? ρσ_expr_temp.length + index : index] = val;
};
if (!ρσ_list_insert.__argnames__) Object.defineProperties(ρσ_list_insert, {
__argnames__ : {value: ["index", "val"]}
});
function ρσ_list_copy() {
return ρσ_list_constructor(this);
};
function ρσ_list_clear() {
this.length = 0;
};
function ρσ_list_as_array() {
return Array.prototype.slice.call(this);
};
function ρσ_list_count(value) {
return this.reduce((function() {
var ρσ_anonfunc = function (n, val) {
return n + (val === value);
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["n", "val"]}
});
return ρσ_anonfunc;
})(), 0);
};
if (!ρσ_list_count.__argnames__) Object.defineProperties(ρσ_list_count, {
__argnames__ : {value: ["value"]}
});
function ρσ_list_sort_key(value) {
var t;
t = typeof value;
if (t === "string" || t === "number") {
return value;
}
return value.toString();
};
if (!ρσ_list_sort_key.__argnames__) Object.defineProperties(ρσ_list_sort_key, {
__argnames__ : {value: ["value"]}
});
function ρσ_list_sort_cmp(a, b, ap, bp) {
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return ap - bp;
};
if (!ρσ_list_sort_cmp.__argnames__) Object.defineProperties(ρσ_list_sort_cmp, {
__argnames__ : {value: ["a", "b", "ap", "bp"]}
});
function ρσ_list_sort() {
var key = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_list_sort.__defaults__.key : arguments[0];
var reverse = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_list_sort.__defaults__.reverse : arguments[1];
var ρσ_kwargs_obj = arguments[arguments.length-1];
if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){
key = ρσ_kwargs_obj.key;
}
if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){
reverse = ρσ_kwargs_obj.reverse;
}
var mult, keymap, posmap, k;
key = key || ρσ_list_sort_key;
mult = (reverse) ? -1 : 1;
keymap = dict();
posmap = dict();
for (var i=0; i < this.length; i++) {
k = (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i];
keymap.set(k, key(k));
posmap.set(k, i);
}
this.sort((function() {
var ρσ_anonfunc = function (a, b) {
return mult * ρσ_list_sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b));
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["a", "b"]}
});
return ρσ_anonfunc;
})());
};
if (!ρσ_list_sort.__defaults__) Object.defineProperties(ρσ_list_sort, {
__defaults__ : {value: {key:null, reverse:false}},
__handles_kwarg_interpolation__ : {value: true},
__argnames__ : {value: ["key", "reverse"]}
});
function ρσ_list_concat() {
var ans;
ans = Array.prototype.concat.apply(this, arguments);
ρσ_list_decorate(ans);
return ans;
};
function ρσ_list_slice() {
var ans;
ans = Array.prototype.slice.apply(this, arguments);
ρσ_list_decorate(ans);
return ans;
};
function ρσ_list_iterator(value) {
var self;
self = this;
return (function(){
var ρσ_d = {};
ρσ_d["_i"] = -1;
ρσ_d["_list"] = self;
ρσ_d["next"] = function () {
this._i += 1;
if (this._i >= this._list.length) {
return (function(){
var ρσ_d = {};
ρσ_d["done"] = true;
return ρσ_d;
}).call(this);
}
return (function(){
var ρσ_d = {};
ρσ_d["done"] = false;
ρσ_d["value"] = (ρσ_expr_temp = this._list)[ρσ_bound_index(this._i, ρσ_expr_temp)];
return ρσ_d;
}).call(this);
};
return ρσ_d;
}).call(this);
};
if (!ρσ_list_iterator.__argnames__) Object.defineProperties(ρσ_list_iterator, {
__argnames__ : {value: ["value"]}
});
function ρσ_list_len() {
return this.length;
};
function ρσ_list_contains(val) {
for (var i = 0; i < this.length; i++) {
if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) {
return true;
}
}
return false;
};
if (!ρσ_list_contains.__argnames__) Object.defineProperties(ρσ_list_contains, {
__argnames__ : {value: ["val"]}
});
function ρσ_list_eq(other) {
if (!ρσ_arraylike(other)) {
return false;
}
if ((this.length !== other.length && (typeof this.length !== "object" || ρσ_not_equals(this.length, other.length)))) {
return false;
}
for (var i = 0; i < this.length; i++) {
if (!(((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === other[(typeof i === "number" && i < 0) ? other.length + i : i] || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], other[(typeof i === "number" && i < 0) ? other.length + i : i])))) {
return false;
}
}
return true;
};
if (!ρσ_list_eq.__argnames__) Object.defineProperties(ρσ_list_eq, {
__argnames__ : {value: ["other"]}
});
function ρσ_list_decorate(ans) {
ans.append = Array.prototype.push;
ans.toString = ρσ_list_to_string;
ans.inspect = ρσ_list_to_string;
ans.extend = ρσ_list_extend;
ans.index = ρσ_list_index;
ans.pypop = ρσ_list_pop;
ans.remove = ρσ_list_remove;
ans.insert = ρσ_list_insert;
ans.copy = ρσ_list_copy;
ans.clear = ρσ_list_clear;
ans.count = ρσ_list_count;
ans.concat = ρσ_list_concat;
ans.pysort = ρσ_list_sort;
ans.slice = ρσ_list_slice;
ans.as_array = ρσ_list_as_array;
ans.__len__ = ρσ_list_len;
ans.__contains__ = ρσ_list_contains;
ans.__eq__ = ρσ_list_eq;
ans.constructor = ρσ_list_constructor;
if (typeof ans[ρσ_iterator_symbol] !== "function") {
ans[ρσ_iterator_symbol] = ρσ_list_iterator;
}
return ans;
};
if (!ρσ_list_decorate.__argnames__) Object.defineProperties(ρσ_list_decorate, {
__argnames__ : {value: ["ans"]}
});
function ρσ_list_constructor(iterable) {
var ans, iterator, result;
if (iterable === undefined) {
ans = [];
} else if (ρσ_arraylike(iterable)) {
ans = new Array(iterable.length);
for (var i = 0; i < iterable.length; i++) {
ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
}
} else if (typeof iterable[ρσ_iterator_symbol] === "function") {
iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
ans = ρσ_list_decorate([]);
result = iterator.next();
while (!result.done) {
ans.push(result.value);
result = iterator.next();
}
} else if (typeof iterable === "number") {
ans = new Array(iterable);
} else {
ans = Object.keys(iterable);
}
return ρσ_list_decorate(ans);
};
if (!ρσ_list_constructor.__argnames__) Object.defineProperties(ρσ_list_constructor, {
__argnames__ : {value: ["iterable"]}
});
ρσ_list_constructor.__name__ = "list";
var list = ρσ_list_constructor, list_wrap = ρσ_list_decorate;
function sorted() {
var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0];
var key = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.key : arguments[1];
var reverse = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.reverse : arguments[2];
var ρσ_kwargs_obj = arguments[arguments.length-1];
if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){
key = ρσ_kwargs_obj.key;
}
if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){
reverse = ρσ_kwargs_obj.reverse;
}
var ans;
ans = ρσ_list_constructor(iterable);
ans.pysort(key, reverse);
return ans;
};
if (!sorted.__defaults__) Object.defineProperties(sorted, {
__defaults__ : {value: {key:null, reverse:false}},
__handles_kwarg_interpolation__ : {value: true},
__argnames__ : {value: ["iterable", "key", "reverse"]}
});
var ρσ_global_object_id = 0, ρσ_set_implementation;
function ρσ_set_keyfor(x) {
var t, ans;
t = typeof x;
if (t === "string" || t === "number" || t === "boolean") {
return "_" + t[0] + x;
}
if (x === null) {
return "__!@#$0";
}
ans = x.ρσ_hash_key_prop;
if (ans === undefined) {
ans = "_!@#$" + (++ρσ_global_object_id);
Object.defineProperty(x, "ρσ_hash_key_prop", (function(){
var ρσ_d = {};
ρσ_d["value"] = ans;
return ρσ_d;
}).call(this));
}
return ans;
};
if (!ρσ_set_keyfor.__argnames__) Object.defineProperties(ρσ_set_keyfor, {
__argnames__ : {value: ["x"]}
});
function ρσ_set_polyfill() {
this._store = {};
this.size = 0;
};
ρσ_set_polyfill.prototype.add = (function() {
var ρσ_anonfunc = function (x) {
var key;
key = ρσ_set_keyfor(x);
if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
this.size += 1;
(ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = x;
}
return this;
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["x"]}
});
return ρσ_anonfunc;
})();
ρσ_set_polyfill.prototype.clear = (function() {
var ρσ_anonfunc = function (x) {
this._store = {};
this.size = 0;
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["x"]}
});
return ρσ_anonfunc;
})();
ρσ_set_polyfill.prototype.delete = (function() {
var ρσ_anonfunc = function (x) {
var key;
key = ρσ_set_keyfor(x);
if (Object.prototype.hasOwnProperty.call(this._store, key)) {
this.size -= 1;
delete this._store[key];
return true;
}
return false;
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["x"]}
});
return ρσ_anonfunc;
})();
ρσ_set_polyfill.prototype.has = (function() {
var ρσ_anonfunc = function (x) {
return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x));
};
if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
__argnames__ : {value: ["x"]}
});
return ρσ_anonfunc;
})();