pinets 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +158 -0
- package/dist/pinets.dev.cjs +10125 -0
- package/dist/pinets.dev.cjs.map +1 -0
- package/dist/pinets.dev.es.js +2338 -0
- package/dist/pinets.dev.es.js.map +1 -0
- package/dist/pinets.min.browser.js +33 -0
- package/dist/pinets.min.cjs +32 -0
- package/dist/pinets.min.es.js +19 -0
- package/dist/types/Context.class.d.ts +48 -0
- package/dist/types/PineTS.class.d.ts +33 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/marketData/Binance/BinanceProvider.class.d.ts +4 -0
- package/dist/types/marketData/IProvider.d.ts +3 -0
- package/dist/types/marketData/Provider.class.d.ts +4 -0
- package/dist/types/namespaces/Core.d.ts +20 -0
- package/dist/types/namespaces/Input.d.ts +24 -0
- package/dist/types/namespaces/PineMath.d.ts +26 -0
- package/dist/types/namespaces/PineRequest.d.ts +7 -0
- package/dist/types/namespaces/Syminfo.d.ts +0 -0
- package/dist/types/namespaces/TechnicalAnalysis.d.ts +26 -0
- package/dist/types/transpiler/ScopeManager.class.d.ts +31 -0
- package/dist/types/transpiler/index.d.ts +1 -0
- package/dist/types/types/PineTypes.d.ts +48 -0
- package/package.json +48 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2025 Alaa-eddine KADDOURI
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Zt=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],at=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Jt="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",nt="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",ke={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},_e="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",$t={5:_e,"5module":_e+" export import",6:_e+" const class extends export import super"},ei=/^in(stanceof)?$/,ti=new RegExp("["+nt+"]"),ii=new RegExp("["+nt+Jt+"]");function Pe(e,t){for(var i=65536,r=0;r<t.length;r+=2){if(i+=t[r],i>e)return!1;if(i+=t[r+1],i>=e)return!0}return!1}function K(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&ti.test(String.fromCharCode(e)):t===!1?!1:Pe(e,at)}function te(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&ii.test(String.fromCharCode(e)):t===!1?!1:Pe(e,at)||Pe(e,Zt)}var C=function(t,i){i===void 0&&(i={}),this.label=t,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function M(e,t){return new C(e,{beforeExpr:!0,binop:t})}var R={beforeExpr:!0},L={startsExpr:!0},Me={};function w(e,t){return t===void 0&&(t={}),t.keyword=e,Me[e]=new C(e,t)}var o={num:new C("num",L),regexp:new C("regexp",L),string:new C("string",L),name:new C("name",L),privateId:new C("privateId",L),eof:new C("eof"),bracketL:new C("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new C("]"),braceL:new C("{",{beforeExpr:!0,startsExpr:!0}),braceR:new C("}"),parenL:new C("(",{beforeExpr:!0,startsExpr:!0}),parenR:new C(")"),comma:new C(",",R),semi:new C(";",R),colon:new C(":",R),dot:new C("."),question:new C("?",R),questionDot:new C("?."),arrow:new C("=>",R),template:new C("template"),invalidTemplate:new C("invalidTemplate"),ellipsis:new C("...",R),backQuote:new C("`",L),dollarBraceL:new C("${",{beforeExpr:!0,startsExpr:!0}),eq:new C("=",{beforeExpr:!0,isAssign:!0}),assign:new C("_=",{beforeExpr:!0,isAssign:!0}),incDec:new C("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new C("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:M("||",1),logicalAND:M("&&",2),bitwiseOR:M("|",3),bitwiseXOR:M("^",4),bitwiseAND:M("&",5),equality:M("==/!=/===/!==",6),relational:M("</>/<=/>=",7),bitShift:M("<</>>/>>>",8),plusMin:new C("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:M("%",10),star:M("*",10),slash:M("/",10),starstar:new C("**",{beforeExpr:!0}),coalesce:M("??",1),_break:w("break"),_case:w("case",R),_catch:w("catch"),_continue:w("continue"),_debugger:w("debugger"),_default:w("default",R),_do:w("do",{isLoop:!0,beforeExpr:!0}),_else:w("else",R),_finally:w("finally"),_for:w("for",{isLoop:!0}),_function:w("function",L),_if:w("if"),_return:w("return",R),_switch:w("switch"),_throw:w("throw",R),_try:w("try"),_var:w("var"),_const:w("const"),_while:w("while",{isLoop:!0}),_with:w("with"),_new:w("new",{beforeExpr:!0,startsExpr:!0}),_this:w("this",L),_super:w("super",L),_class:w("class",L),_extends:w("extends",R),_export:w("export"),_import:w("import",L),_null:w("null",L),_true:w("true",L),_false:w("false",L),_in:w("in",{beforeExpr:!0,binop:7}),_instanceof:w("instanceof",{beforeExpr:!0,binop:7}),_typeof:w("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:w("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:w("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},O=/\r\n?|\n|\u2028|\u2029/,ri=new RegExp(O.source,"g");function re(e){return e===10||e===13||e===8232||e===8233}function ot(e,t,i){i===void 0&&(i=e.length);for(var r=t;r<i;r++){var s=e.charCodeAt(r);if(re(s))return r<i-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ut=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,B=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,pt=Object.prototype,si=pt.hasOwnProperty,ai=pt.toString,se=Object.hasOwn||function(e,t){return si.call(e,t)},He=Array.isArray||function(e){return ai.call(e)==="[object Array]"},Ke=Object.create(null);function Z(e){return Ke[e]||(Ke[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Q(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ni=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,pe=function(t,i){this.line=t,this.column=i};pe.prototype.offset=function(t){return new pe(this.line,this.column+t)};var ve=function(t,i,r){this.start=i,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ht(e,t){for(var i=1,r=0;;){var s=ot(e,r,t);if(s<0)return new pe(i,t-r);++i,r=s}}var Ne={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Qe=!1;function oi(e){var t={};for(var i in Ne)t[i]=e&&se(e,i)?e[i]:Ne[i];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Qe&&typeof console=="object"&&console.warn&&(Qe=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
19
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),He(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return He(t.onComment)&&(t.onComment=ui(t,t.onComment)),t}function ui(e,t){return function(i,r,s,a,n,u){var p={type:i?"Block":"Line",value:r,start:s,end:a};e.locations&&(p.loc=new ve(this,n,u)),e.ranges&&(p.range=[s,a]),t.push(p)}}var he=1,ae=2,Re=4,ct=8,lt=16,ft=32,Be=64,mt=128,ce=256,De=he|ae|ce;function Oe(e,t){return ae|(e?Re:0)|(t?ct:0)}var xe=0,Fe=1,X=2,dt=3,xt=4,yt=5,A=function(t,i,r){this.options=t=oi(t),this.sourceFile=t.sourceFile,this.keywords=Z($t[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=ke[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=Z(s);var a=(s?s+" ":"")+ke.strict;this.reservedWordsStrict=Z(a),this.reservedWordsStrictBind=Z(a+" "+ke.strictBind),this.input=String(i),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
|
|
20
|
+
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(O).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=o.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(he),this.regexpState=null,this.privateNameStack=[]},z={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};A.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};z.inFunction.get=function(){return(this.currentVarScope().flags&ae)>0};z.inGenerator.get=function(){return(this.currentVarScope().flags&ct)>0&&!this.currentVarScope().inClassFieldInit};z.inAsync.get=function(){return(this.currentVarScope().flags&Re)>0&&!this.currentVarScope().inClassFieldInit};z.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e];if(t.inClassFieldInit||t.flags&ce)return!1;if(t.flags&ae)return(t.flags&Re)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};z.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags,i=e.inClassFieldInit;return(t&Be)>0||i||this.options.allowSuperOutsideMethod};z.allowDirectSuper.get=function(){return(this.currentThisScope().flags&mt)>0};z.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};z.allowNewDotTarget.get=function(){var e=this.currentThisScope(),t=e.flags,i=e.inClassFieldInit;return(t&(ae|ce))>0||i};z.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ce)>0};A.extend=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};A.parse=function(t,i){return new this(i,t).parse()};A.parseExpressionAt=function(t,i,r){var s=new this(r,t,i);return s.nextToken(),s.parseExpression()};A.tokenizer=function(t,i){return new this(i,t)};Object.defineProperties(A.prototype,z);var T=A.prototype,pi=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;T.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){B.lastIndex=e,e+=B.exec(this.input)[0].length;var t=pi.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){B.lastIndex=e+t[0].length;var i=B.exec(this.input),r=i.index+i[0].length,s=this.input.charAt(r);return s===";"||s==="}"||O.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,B.lastIndex=e,e+=B.exec(this.input)[0].length,this.input[e]===";"&&e++}};T.eat=function(e){return this.type===e?(this.next(),!0):!1};T.isContextual=function(e){return this.type===o.name&&this.value===e&&!this.containsEsc};T.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};T.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};T.canInsertSemicolon=function(){return this.type===o.eof||this.type===o.braceR||O.test(this.input.slice(this.lastTokEnd,this.start))};T.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};T.semicolon=function(){!this.eat(o.semi)&&!this.insertSemicolon()&&this.unexpected()};T.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};T.expect=function(e){this.eat(e)||this.unexpected()};T.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var we=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};T.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var i=t?e.parenthesizedAssign:e.parenthesizedBind;i>-1&&this.raiseRecoverable(i,t?"Assigning to rvalue":"Parenthesized pattern")}};T.checkExpressionErrors=function(e,t){if(!e)return!1;var i=e.shorthandAssign,r=e.doubleProto;if(!t)return i>=0||r>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};T.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};T.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var d=A.prototype;d.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==o.eof;){var i=this.parseStatement(null,!0,t);e.body.push(i)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var je={kind:"loop"},hi={kind:"switch"};d.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;B.lastIndex=this.pos;var t=B.exec(this.input),i=this.pos+t[0].length,r=this.input.charCodeAt(i);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(K(r,!0)){for(var s=i+1;te(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(i,s);if(!ei.test(a))return!0}return!1};d.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;B.lastIndex=this.pos;var e=B.exec(this.input),t=this.pos+e[0].length,i;return!O.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(te(i=this.input.charCodeAt(t+8))||i>55295&&i<56320))};d.parseStatement=function(e,t,i){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=o._var,a="let"),r){case o._break:case o._continue:return this.parseBreakContinueStatement(s,r.keyword);case o._debugger:return this.parseDebuggerStatement(s);case o._do:return this.parseDoStatement(s);case o._for:return this.parseForStatement(s);case o._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case o._class:return e&&this.unexpected(),this.parseClass(s,!0);case o._if:return this.parseIfStatement(s);case o._return:return this.parseReturnStatement(s);case o._switch:return this.parseSwitchStatement(s);case o._throw:return this.parseThrowStatement(s);case o._try:return this.parseTryStatement(s);case o._const:case o._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case o._while:return this.parseWhileStatement(s);case o._with:return this.parseWithStatement(s);case o.braceL:return this.parseBlock(!0,s);case o.semi:return this.parseEmptyStatement(s);case o._export:case o._import:if(this.options.ecmaVersion>10&&r===o._import){B.lastIndex=this.pos;var n=B.exec(this.input),u=this.pos+n[0].length,p=this.input.charCodeAt(u);if(p===40||p===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===o._import?this.parseImport(s):this.parseExport(s,i);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var h=this.value,c=this.parseExpression();return r===o.name&&c.type==="Identifier"&&this.eat(o.colon)?this.parseLabeledStatement(s,h,c,e):this.parseExpressionStatement(s,c)}};d.parseBreakContinueStatement=function(e,t){var i=t==="break";this.next(),this.eat(o.semi)||this.insertSemicolon()?e.label=null:this.type!==o.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(i||s.kind==="loop")||e.label&&i))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,i?"BreakStatement":"ContinueStatement")};d.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};d.parseDoStatement=function(e){return this.next(),this.labels.push(je),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(o._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(o.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};d.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(je),this.enterScope(0),this.expect(o.parenL),this.type===o.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var i=this.isLet();if(this.type===o._var||this.type===o._const||i){var r=this.startNode(),s=i?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),(this.type===o._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&r.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===o._in?t>-1&&this.unexpected(t):e.await=t>-1),this.parseForIn(e,r)):(t>-1&&this.unexpected(t),this.parseFor(e,r))}var a=this.isContextual("let"),n=!1,u=this.containsEsc,p=new we,h=this.start,c=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===o._in||(n=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===o._in&&this.unexpected(t),e.await=!0):n&&this.options.ecmaVersion>=8&&(c.start===h&&!u&&c.type==="Identifier"&&c.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&n&&this.raise(c.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(c,!1,p),this.checkLValPattern(c),this.parseForIn(e,c)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,c))};d.parseFunctionStatement=function(e,t,i){return this.next(),this.parseFunction(e,oe|(i?0:Ve),!1,t)};d.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(o._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};d.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(o.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};d.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(o.braceL),this.labels.push(hi),this.enterScope(0);for(var t,i=!1;this.type!==o.braceR;)if(this.type===o._case||this.type===o._default){var r=this.type===o._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,t.test=null),this.expect(o.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};d.parseThrowStatement=function(e){return this.next(),O.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var ci=[];d.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?ft:0),this.checkLValPattern(e,t?xt:X),this.expect(o.parenR),e};d.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===o._catch){var t=this.startNode();this.next(),this.eat(o.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(o._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};d.parseVarStatement=function(e,t,i){return this.next(),this.parseVar(e,!1,t,i),this.semicolon(),this.finishNode(e,"VariableDeclaration")};d.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(je),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};d.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};d.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};d.parseLabeledStatement=function(e,t,i,r){for(var s=0,a=this.labels;s<a.length;s+=1){var n=a[s];n.name===t&&this.raise(i.start,"Label '"+t+"' is already declared")}for(var u=this.type.isLoop?"loop":this.type===o._switch?"switch":null,p=this.labels.length-1;p>=0;p--){var h=this.labels[p];if(h.statementStart===e.start)h.statementStart=this.start,h.kind=u;else break}return this.labels.push({name:t,kind:u,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=i,this.finishNode(e,"LabeledStatement")};d.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};d.parseBlock=function(e,t,i){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(o.braceL),e&&this.enterScope(0);this.type!==o.braceR;){var r=this.parseStatement(null);t.body.push(r)}return i&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};d.parseFor=function(e,t){return e.init=t,this.expect(o.semi),e.test=this.type===o.semi?null:this.parseExpression(),this.expect(o.semi),e.update=this.type===o.parenR?null:this.parseExpression(),this.expect(o.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};d.parseForIn=function(e,t){var i=this.type===o._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(o.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,i?"ForInStatement":"ForOfStatement")};d.parseVar=function(e,t,i,r){for(e.declarations=[],e.kind=i;;){var s=this.startNode();if(this.parseVarId(s,i),this.eat(o.eq)?s.init=this.parseMaybeAssign(t):!r&&i==="const"&&!(this.type===o._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&s.id.type!=="Identifier"&&!(t&&(this.type===o._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(o.comma))break}return e};d.parseVarId=function(e,t){e.id=this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Fe:X,!1)};var oe=1,Ve=2,bt=4;d.parseFunction=function(e,t,i,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===o.star&&t&Ve&&this.unexpected(),e.generator=this.eat(o.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&oe&&(e.id=t&bt&&this.type!==o.name?null:this.parseIdent(),e.id&&!(t&Ve)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Fe:X:dt));var a=this.yieldPos,n=this.awaitPos,u=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Oe(e.async,e.generator)),t&oe||(e.id=this.type===o.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,i,!1,s),this.yieldPos=a,this.awaitPos=n,this.awaitIdentPos=u,this.finishNode(e,t&oe?"FunctionDeclaration":"FunctionExpression")};d.parseFunctionParams=function(e){this.expect(o.parenL),e.params=this.parseBindingList(o.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};d.parseClass=function(e,t){this.next();var i=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(o.braceL);this.type!==o.braceR;){var n=this.parseClassElement(e.superClass!==null);n&&(s.body.push(n),n.type==="MethodDefinition"&&n.kind==="constructor"?(a&&this.raiseRecoverable(n.start,"Duplicate constructor in the same class"),a=!0):n.key&&n.key.type==="PrivateIdentifier"&&li(r,n)&&this.raiseRecoverable(n.key.start,"Identifier '#"+n.key.name+"' has already been declared"))}return this.strict=i,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};d.parseClassElement=function(e){if(this.eat(o.semi))return null;var t=this.options.ecmaVersion,i=this.startNode(),r="",s=!1,a=!1,n="method",u=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(o.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===o.star?u=!0:r="static"}if(i.static=u,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===o.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(o.star)&&(s=!0),!r&&!a&&!s){var p=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?n=p:r=p)}if(r?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=r,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),t<13||this.type===o.parenL||n!=="method"||s||a){var h=!i.static&&ye(i,"constructor"),c=h&&e;h&&n!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=h?"constructor":n,this.parseClassMethod(i,s,a,c)}else this.parseClassField(i);return i};d.isClassElementNameStart=function(){return this.type===o.name||this.type===o.privateId||this.type===o.num||this.type===o.string||this.type===o.bracketL||this.type.keyword};d.parseClassElementName=function(e){this.type===o.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};d.parseClassMethod=function(e,t,i,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),i&&this.raise(s.start,"Constructor can't be an async method")):e.static&&ye(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,i,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};d.parseClassField=function(e){if(ye(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&ye(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(o.eq)){var t=this.currentThisScope(),i=t.inClassFieldInit;t.inClassFieldInit=!0,e.value=this.parseMaybeAssign(),t.inClassFieldInit=i}else e.value=null;return this.semicolon(),this.finishNode(e,"PropertyDefinition")};d.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ce|Be);this.type!==o.braceR;){var i=this.parseStatement(null);e.body.push(i)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};d.parseClassId=function(e,t){this.type===o.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,X,!1)):(t===!0&&this.unexpected(),e.id=null)};d.parseClassSuper=function(e){e.superClass=this.eat(o._extends)?this.parseExprSubscripts(null,!1):null};d.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};d.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,i=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var n=i[a];se(t,n.name)||(s?s.used.push(n):this.raiseRecoverable(n.start,"Private field '#"+n.name+"' must be declared in an enclosing class"))}};function li(e,t){var i=t.key.name,r=e[i],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[i]="true",!1):r?!0:(e[i]=s,!1)}function ye(e,t){var i=e.computed,r=e.key;return!i&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}d.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==o.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};d.parseExport=function(e,t){if(this.next(),this.eat(o.star))return this.parseExportAllDeclaration(e,t);if(this.eat(o._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null;else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==o.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var i=0,r=e.specifiers;i<r.length;i+=1){var s=r[i];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};d.parseExportDeclaration=function(e){return this.parseStatement(null)};d.parseExportDefaultDeclaration=function(){var e;if(this.type===o._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,oe|bt,!1,e)}else if(this.type===o._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};d.checkExport=function(e,t,i){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),se(e,t)&&this.raiseRecoverable(i,"Duplicate export '"+t+"'"),e[t]=!0)};d.checkPatternExport=function(e,t){var i=t.type;if(i==="Identifier")this.checkExport(e,t,t.start);else if(i==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(e,a)}else if(i==="ArrayPattern")for(var n=0,u=t.elements;n<u.length;n+=1){var p=u[n];p&&this.checkPatternExport(e,p)}else i==="Property"?this.checkPatternExport(e,t.value):i==="AssignmentPattern"?this.checkPatternExport(e,t.left):i==="RestElement"&&this.checkPatternExport(e,t.argument)};d.checkVariableExport=function(e,t){if(e)for(var i=0,r=t;i<r.length;i+=1){var s=r[i];this.checkPatternExport(e,s.id)}};d.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};d.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};d.parseExportSpecifiers=function(e){var t=[],i=!0;for(this.expect(o.braceL);!this.eat(o.braceR);){if(i)i=!1;else if(this.expect(o.comma),this.afterTrailingComma(o.braceR))break;t.push(this.parseExportSpecifier(e))}return t};d.parseImport=function(e){return this.next(),this.type===o.string?(e.specifiers=ci,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===o.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};d.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,X),this.finishNode(e,"ImportSpecifier")};d.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,X),this.finishNode(e,"ImportDefaultSpecifier")};d.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,X),this.finishNode(e,"ImportNamespaceSpecifier")};d.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===o.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(o.comma)))return e;if(this.type===o.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(o.braceL);!this.eat(o.braceR);){if(t)t=!1;else if(this.expect(o.comma),this.afterTrailingComma(o.braceR))break;e.push(this.parseImportSpecifier())}return e};d.parseWithClause=function(){var e=[];if(!this.eat(o._with))return e;this.expect(o.braceL);for(var t={},i=!0;!this.eat(o.braceR);){if(i)i=!1;else if(this.expect(o.comma),this.afterTrailingComma(o.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;se(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};d.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===o.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(o.colon),this.type!==o.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};d.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===o.string){var e=this.parseLiteral(this.value);return ni.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};d.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};d.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var F=A.prototype;F.toAssignable=function(e,t,i){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,i);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return e};F.toAssignableList=function(e,t){for(var i=e.length,r=0;r<i;r++){var s=e[r];s&&this.toAssignable(s,t)}if(i){var a=e[i-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};F.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};F.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==o.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};F.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case o.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(o.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case o.braceL:return this.parseObj(!0)}return this.parseIdent()};F.parseBindingList=function(e,t,i,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(o.comma),t&&this.type===o.comma)s.push(null);else{if(i&&this.afterTrailingComma(e))break;if(this.type===o.ellipsis){var n=this.parseRestBinding();this.parseBindingListItem(n),s.push(n),this.type===o.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};F.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};F.parseBindingListItem=function(e){return e};F.parseMaybeDefault=function(e,t,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(o.eq))return i;var r=this.startNodeAt(e,t);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};F.checkLValSimple=function(e,t,i){t===void 0&&(t=xe);var r=t!==xe;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===X&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),i&&(se(i,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),i[e.name]=!0),t!==yt&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,i);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};F.checkLValPattern=function(e,t,i){switch(t===void 0&&(t=xe),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,i)}break;case"ArrayPattern":for(var n=0,u=e.elements;n<u.length;n+=1){var p=u[n];p&&this.checkLValInnerPattern(p,t,i)}break;default:this.checkLValSimple(e,t,i)}};F.checkLValInnerPattern=function(e,t,i){switch(t===void 0&&(t=xe),e.type){case"Property":this.checkLValInnerPattern(e.value,t,i);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,i);break;case"RestElement":this.checkLValPattern(e.argument,t,i);break;default:this.checkLValPattern(e,t,i)}};var j=function(t,i,r,s,a){this.token=t,this.isExpr=!!i,this.preserveSpace=!!r,this.override=s,this.generator=!!a},k={b_stat:new j("{",!1),b_expr:new j("{",!0),b_tmpl:new j("${",!1),p_stat:new j("(",!1),p_expr:new j("(",!0),q_tmpl:new j("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new j("function",!1),f_expr:new j("function",!0),f_expr_gen:new j("function",!0,!1,null,!0),f_gen:new j("function",!1,!1,null,!0)},ne=A.prototype;ne.initialContext=function(){return[k.b_stat]};ne.curContext=function(){return this.context[this.context.length-1]};ne.braceIsBlock=function(e){var t=this.curContext();return t===k.f_expr||t===k.f_stat?!0:e===o.colon&&(t===k.b_stat||t===k.b_expr)?!t.isExpr:e===o._return||e===o.name&&this.exprAllowed?O.test(this.input.slice(this.lastTokEnd,this.start)):e===o._else||e===o.semi||e===o.eof||e===o.parenR||e===o.arrow?!0:e===o.braceL?t===k.b_stat:e===o._var||e===o._const||e===o.name?!1:!this.exprAllowed};ne.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};ne.updateContext=function(e){var t,i=this.type;i.keyword&&e===o.dot?this.exprAllowed=!1:(t=i.updateContext)?t.call(this,e):this.exprAllowed=i.beforeExpr};ne.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};o.parenR.updateContext=o.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===k.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};o.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?k.b_stat:k.b_expr),this.exprAllowed=!0};o.dollarBraceL.updateContext=function(){this.context.push(k.b_tmpl),this.exprAllowed=!0};o.parenL.updateContext=function(e){var t=e===o._if||e===o._for||e===o._with||e===o._while;this.context.push(t?k.p_stat:k.p_expr),this.exprAllowed=!0};o.incDec.updateContext=function(){};o._function.updateContext=o._class.updateContext=function(e){e.beforeExpr&&e!==o._else&&!(e===o.semi&&this.curContext()!==k.p_stat)&&!(e===o._return&&O.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===o.colon||e===o.braceL)&&this.curContext()===k.b_stat)?this.context.push(k.f_expr):this.context.push(k.f_stat),this.exprAllowed=!1};o.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};o.backQuote.updateContext=function(){this.curContext()===k.q_tmpl?this.context.pop():this.context.push(k.q_tmpl),this.exprAllowed=!1};o.star.updateContext=function(e){if(e===o._function){var t=this.context.length-1;this.context[t]===k.f_expr?this.context[t]=k.f_expr_gen:this.context[t]=k.f_gen}this.exprAllowed=!0};o.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==o.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var b=A.prototype;b.checkPropClash=function(e,t,i){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(t.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var n=t[s];if(n){var u;a==="init"?u=this.strict&&n.init||n.get||n.set:u=n.init||n[a],u&&this.raiseRecoverable(r.start,"Redefinition of property")}else n=t[s]={init:!1,get:!1,set:!1};n[a]=!0}};b.parseExpression=function(e,t){var i=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===o.comma){var a=this.startNodeAt(i,r);for(a.expressions=[s];this.eat(o.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};b.parseMaybeAssign=function(e,t,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,n=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,n=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new we,r=!0);var u=this.start,p=this.startLoc;(this.type===o.parenL||this.type===o.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var h=this.parseMaybeConditional(e,t);if(i&&(h=i.call(this,h,u,p)),this.type.isAssign){var c=this.startNodeAt(u,p);return c.operator=this.value,this.type===o.eq&&(h=this.toAssignable(h,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=h.start&&(t.shorthandAssign=-1),this.type===o.eq?this.checkLValPattern(h):this.checkLValSimple(h),c.left=h,this.next(),c.right=this.parseMaybeAssign(e),n>-1&&(t.doubleProto=n),this.finishNode(c,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),h};b.parseMaybeConditional=function(e,t){var i=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(o.question)){var a=this.startNodeAt(i,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(o.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};b.parseExprOps=function(e,t){var i=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===i&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,i,r,-1,e)};b.parseExprOp=function(e,t,i,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==o._in)&&a>r){var n=this.type===o.logicalOR||this.type===o.logicalAND,u=this.type===o.coalesce;u&&(a=o.logicalAND.binop);var p=this.value;this.next();var h=this.start,c=this.startLoc,y=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),h,c,a,s),l=this.buildBinary(t,i,e,y,p,n||u);return(n&&this.type===o.coalesce||u&&(this.type===o.logicalOR||this.type===o.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(l,t,i,r,s)}return e};b.buildBinary=function(e,t,i,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var n=this.startNodeAt(e,t);return n.left=i,n.operator=s,n.right=r,this.finishNode(n,a?"LogicalExpression":"BinaryExpression")};b.parseMaybeUnary=function(e,t,i,r){var s=this.start,a=this.startLoc,n;if(this.isContextual("await")&&this.canAwait)n=this.parseAwait(r),t=!0;else if(this.type.prefix){var u=this.startNode(),p=this.type===o.incDec;u.operator=this.value,u.prefix=!0,this.next(),u.argument=this.parseMaybeUnary(null,!0,p,r),this.checkExpressionErrors(e,!0),p?this.checkLValSimple(u.argument):this.strict&&u.operator==="delete"&>(u.argument)?this.raiseRecoverable(u.start,"Deleting local variable in strict mode"):u.operator==="delete"&&Te(u.argument)?this.raiseRecoverable(u.start,"Private fields can not be deleted"):t=!0,n=this.finishNode(u,p?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===o.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),n=this.parsePrivateIdent(),this.type!==o._in&&this.unexpected();else{if(n=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var h=this.startNodeAt(s,a);h.operator=this.value,h.prefix=!1,h.argument=n,this.checkLValSimple(n),this.next(),n=this.finishNode(h,"UpdateExpression")}}if(!i&&this.eat(o.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,n,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return n};function gt(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&>(e.expression)}function Te(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Te(e.expression)||e.type==="ParenthesizedExpression"&&Te(e.expression)}b.parseExprSubscripts=function(e,t){var i=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,i,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};b.parseSubscripts=function(e,t,i,r,s){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,n=!1;;){var u=this.parseSubscript(e,t,i,r,a,n,s);if(u.optional&&(n=!0),u===e||u.type==="ArrowFunctionExpression"){if(n){var p=this.startNodeAt(t,i);p.expression=u,u=this.finishNode(p,"ChainExpression")}return u}e=u}};b.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(o.arrow)};b.parseSubscriptAsyncArrow=function(e,t,i,r){return this.parseArrowExpression(this.startNodeAt(e,t),i,!0,r)};b.parseSubscript=function(e,t,i,r,s,a,n){var u=this.options.ecmaVersion>=11,p=u&&this.eat(o.questionDot);r&&p&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var h=this.eat(o.bracketL);if(h||p&&this.type!==o.parenL&&this.type!==o.backQuote||this.eat(o.dot)){var c=this.startNodeAt(t,i);c.object=e,h?(c.property=this.parseExpression(),this.expect(o.bracketR)):this.type===o.privateId&&e.type!=="Super"?c.property=this.parsePrivateIdent():c.property=this.parseIdent(this.options.allowReserved!=="never"),c.computed=!!h,u&&(c.optional=p),e=this.finishNode(c,"MemberExpression")}else if(!r&&this.eat(o.parenL)){var y=new we,l=this.yieldPos,g=this.awaitPos,E=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var x=this.parseExprList(o.parenR,this.options.ecmaVersion>=8,!1,y);if(s&&!p&&this.shouldParseAsyncArrow())return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=l,this.awaitPos=g,this.awaitIdentPos=E,this.parseSubscriptAsyncArrow(t,i,x,n);this.checkExpressionErrors(y,!0),this.yieldPos=l||this.yieldPos,this.awaitPos=g||this.awaitPos,this.awaitIdentPos=E||this.awaitIdentPos;var I=this.startNodeAt(t,i);I.callee=e,I.arguments=x,u&&(I.optional=p),e=this.finishNode(I,"CallExpression")}else if(this.type===o.backQuote){(p||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var P=this.startNodeAt(t,i);P.tag=e,P.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(P,"TaggedTemplateExpression")}return e};b.parseExprAtom=function(e,t,i){this.type===o.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case o._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===o.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==o.dot&&this.type!==o.bracketL&&this.type!==o.parenL&&this.unexpected(),this.finishNode(r,"Super");case o._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case o.name:var a=this.start,n=this.startLoc,u=this.containsEsc,p=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!u&&p.name==="async"&&!this.canInsertSemicolon()&&this.eat(o._function))return this.overrideContext(k.f_expr),this.parseFunction(this.startNodeAt(a,n),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(o.arrow))return this.parseArrowExpression(this.startNodeAt(a,n),[p],!1,t);if(this.options.ecmaVersion>=8&&p.name==="async"&&this.type===o.name&&!u&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return p=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(o.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,n),[p],!0,t)}return p;case o.regexp:var h=this.value;return r=this.parseLiteral(h.value),r.regex={pattern:h.pattern,flags:h.flags},r;case o.num:case o.string:return this.parseLiteral(this.value);case o._null:case o._true:case o._false:return r=this.startNode(),r.value=this.type===o._null?null:this.type===o._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case o.parenL:var c=this.start,y=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(y)&&(e.parenthesizedAssign=c),e.parenthesizedBind<0&&(e.parenthesizedBind=c)),y;case o.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(o.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case o.braceL:return this.overrideContext(k.b_expr),this.parseObj(!1,e);case o._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case o._class:return this.parseClass(this.startNode(),!1);case o._new:return this.parseNew();case o.backQuote:return this.parseTemplate();case o._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};b.parseExprAtomDefault=function(){this.unexpected()};b.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===o.parenL&&!e)return this.parseDynamicImport(t);if(this.type===o.dot){var i=this.startNodeAt(t.start,t.loc&&t.loc.start);return i.name="import",t.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};b.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(o.parenR)?e.options=null:(this.expect(o.comma),this.afterTrailingComma(o.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(o.parenR)||(this.expect(o.comma),this.afterTrailingComma(o.parenR)||this.unexpected())));else if(!this.eat(o.parenR)){var t=this.start;this.eat(o.comma)&&this.eat(o.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};b.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};b.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};b.parseParenExpression=function(){this.expect(o.parenL);var e=this.parseExpression();return this.expect(o.parenR),e};b.shouldParseArrow=function(e){return!this.canInsertSemicolon()};b.parseParenAndDistinguishExpression=function(e,t){var i=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var n=this.start,u=this.startLoc,p=[],h=!0,c=!1,y=new we,l=this.yieldPos,g=this.awaitPos,E;for(this.yieldPos=0,this.awaitPos=0;this.type!==o.parenR;)if(h?h=!1:this.expect(o.comma),a&&this.afterTrailingComma(o.parenR,!0)){c=!0;break}else if(this.type===o.ellipsis){E=this.start,p.push(this.parseParenItem(this.parseRestBinding())),this.type===o.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else p.push(this.parseMaybeAssign(!1,y,this.parseParenItem));var x=this.lastTokEnd,I=this.lastTokEndLoc;if(this.expect(o.parenR),e&&this.shouldParseArrow(p)&&this.eat(o.arrow))return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=l,this.awaitPos=g,this.parseParenArrowList(i,r,p,t);(!p.length||c)&&this.unexpected(this.lastTokStart),E&&this.unexpected(E),this.checkExpressionErrors(y,!0),this.yieldPos=l||this.yieldPos,this.awaitPos=g||this.awaitPos,p.length>1?(s=this.startNodeAt(n,u),s.expressions=p,this.finishNodeAt(s,"SequenceExpression",x,I)):s=p[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var P=this.startNodeAt(i,r);return P.expression=s,this.finishNode(P,"ParenthesizedExpression")}else return s};b.parseParenItem=function(e){return e};b.parseParenArrowList=function(e,t,i,r){return this.parseArrowExpression(this.startNodeAt(e,t),i,!1,r)};var fi=[];b.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===o.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var i=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(o.parenL)?e.arguments=this.parseExprList(o.parenR,this.options.ecmaVersion>=8,!1):e.arguments=fi,this.finishNode(e,"NewExpression")};b.parseTemplateElement=function(e){var t=e.isTagged,i=this.startNode();return this.type===o.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
21
|
+
`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
22
|
+
`),cooked:this.value},this.next(),i.tail=this.type===o.backQuote,this.finishNode(i,"TemplateElement")};b.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(i.quasis=[r];!r.tail;)this.type===o.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(o.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(o.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(i,"TemplateLiteral")};b.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===o.name||this.type===o.num||this.type===o.string||this.type===o.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===o.star)&&!O.test(this.input.slice(this.lastTokEnd,this.start))};b.parseObj=function(e,t){var i=this.startNode(),r=!0,s={};for(i.properties=[],this.next();!this.eat(o.braceR);){if(r)r=!1;else if(this.expect(o.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(o.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),i.properties.push(a)}return this.finishNode(i,e?"ObjectPattern":"ObjectExpression")};b.parseProperty=function(e,t){var i=this.startNode(),r,s,a,n;if(this.options.ecmaVersion>=9&&this.eat(o.ellipsis))return e?(i.argument=this.parseIdent(!1),this.type===o.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,t),this.type===o.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(e||t)&&(a=this.start,n=this.startLoc),e||(r=this.eat(o.star)));var u=this.containsEsc;return this.parsePropertyName(i),!e&&!u&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(o.star),this.parsePropertyName(i)):s=!1,this.parsePropertyValue(i,e,r,s,a,n,t,u),this.finishNode(i,"Property")};b.parseGetterSetter=function(e){e.kind=e.key.name,this.parsePropertyName(e),e.value=this.parseMethod(!1);var t=e.kind==="get"?0:1;if(e.value.params.length!==t){var i=e.value.start;e.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};b.parsePropertyValue=function(e,t,i,r,s,a,n,u){(i||r)&&this.type===o.colon&&this.unexpected(),this.eat(o.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,n),e.kind="init"):this.options.ecmaVersion>=6&&this.type===o.parenL?(t&&this.unexpected(),e.kind="init",e.method=!0,e.value=this.parseMethod(i,r)):!t&&!u&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==o.comma&&this.type!==o.braceR&&this.type!==o.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),e.kind="init",t?e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key)):this.type===o.eq&&n?(n.shorthandAssign<0&&(n.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.shorthand=!0):this.unexpected()};b.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(o.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(o.bracketR),e.key;e.computed=!1}return e.key=this.type===o.num||this.type===o.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};b.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};b.parseMethod=function(e,t,i){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,n=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Oe(t,r.generator)|Be|(i?mt:0)),this.expect(o.parenL),r.params=this.parseBindingList(o.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=n,this.finishNode(r,"FunctionExpression")};b.parseArrowExpression=function(e,t,i,r){var s=this.yieldPos,a=this.awaitPos,n=this.awaitIdentPos;return this.enterScope(Oe(i,!1)|lt),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=n,this.finishNode(e,"ArrowFunctionExpression")};b.parseFunctionBody=function(e,t,i,r){var s=t&&this.type!==o.braceL,a=this.strict,n=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var u=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||u)&&(n=this.strictDirective(this.end),n&&u&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var p=this.labels;this.labels=[],n&&(this.strict=!0),this.checkParams(e,!a&&!n&&!t&&!i&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,yt),e.body=this.parseBlock(!1,void 0,n&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=p}this.exitScope()};b.isSimpleParamList=function(e){for(var t=0,i=e;t<i.length;t+=1){var r=i[t];if(r.type!=="Identifier")return!1}return!0};b.checkParams=function(e,t){for(var i=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Fe,t?null:i)}};b.parseExprList=function(e,t,i,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(o.comma),t&&this.afterTrailingComma(e))break;var n=void 0;i&&this.type===o.comma?n=null:this.type===o.ellipsis?(n=this.parseSpread(r),r&&this.type===o.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):n=this.parseMaybeAssign(!1,r),s.push(n)}return s};b.checkUnreserved=function(e){var t=e.start,i=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,i).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};b.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};b.parseIdentNode=function(){var e=this.startNode();return this.type===o.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=o.name):this.unexpected(),e};b.parsePrivateIdent=function(){var e=this.startNode();return this.type===o.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};b.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===o.semi||this.canInsertSemicolon()||this.type!==o.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(o.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};b.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var be=A.prototype;be.raise=function(e,t){var i=ht(this.input,e);t+=" ("+i.line+":"+i.column+")";var r=new SyntaxError(t);throw r.pos=e,r.loc=i,r.raisedAt=this.pos,r};be.raiseRecoverable=be.raise;be.curPosition=function(){if(this.options.locations)return new pe(this.curLine,this.pos-this.lineStart)};var J=A.prototype,mi=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};J.enterScope=function(e){this.scopeStack.push(new mi(e))};J.exitScope=function(){this.scopeStack.pop()};J.treatFunctionsAsVarInScope=function(e){return e.flags&ae||!this.inModule&&e.flags&he};J.declareName=function(e,t,i){var r=!1;if(t===X){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&he&&delete this.undefinedExports[e]}else if(t===xt){var a=this.currentScope();a.lexical.push(e)}else if(t===dt){var n=this.currentScope();this.treatFunctionsAsVar?r=n.lexical.indexOf(e)>-1:r=n.lexical.indexOf(e)>-1||n.var.indexOf(e)>-1,n.functions.push(e)}else for(var u=this.scopeStack.length-1;u>=0;--u){var p=this.scopeStack[u];if(p.lexical.indexOf(e)>-1&&!(p.flags&ft&&p.lexical[0]===e)||!this.treatFunctionsAsVarInScope(p)&&p.functions.indexOf(e)>-1){r=!0;break}if(p.var.push(e),this.inModule&&p.flags&he&&delete this.undefinedExports[e],p.flags&De)break}r&&this.raiseRecoverable(i,"Identifier '"+e+"' has already been declared")};J.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};J.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};J.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&De)return t}};J.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&De&&!(t.flags<))return t}};var Ee=function(t,i,r){this.type="",this.start=i,this.end=0,t.options.locations&&(this.loc=new ve(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[i,0])},le=A.prototype;le.startNode=function(){return new Ee(this,this.start,this.startLoc)};le.startNodeAt=function(e,t){return new Ee(this,e,t)};function vt(e,t,i,r){return e.type=t,e.end=i,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=i),e}le.finishNode=function(e,t){return vt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};le.finishNodeAt=function(e,t,i,r){return vt.call(this,e,t,i,r)};le.copyNode=function(e){var t=new Ee(this,e.start,this.startLoc);for(var i in e)t[i]=e[i];return t};var di="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",wt="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",Et=wt+" Extended_Pictographic",Ct=Et,St=Ct+" EBase EComp EMod EPres ExtPict",kt=St,xi=kt,yi={9:wt,10:Et,11:Ct,12:St,13:kt,14:xi},bi="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",gi={9:"",10:"",11:"",12:"",13:"",14:bi},Ye="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",_t="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",At=_t+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",It=At+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Pt=It+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Nt=Pt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",vi=Nt+" "+di,wi={9:_t,10:At,11:It,12:Pt,13:Nt,14:vi},Vt={};function Ei(e){var t=Vt[e]={binary:Z(yi[e]+" "+Ye),binaryOfStrings:Z(gi[e]),nonBinary:{General_Category:Z(Ye),Script:Z(wi[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Ae=0,Xe=[9,10,11,12,13,14];Ae<Xe.length;Ae+=1){var Ci=Xe[Ae];Ei(Ci)}var m=A.prototype,ge=function(t,i){this.parent=t,this.base=i||this};ge.prototype.separatedFrom=function(t){for(var i=this;i;i=i.parent)for(var r=t;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};ge.prototype.sibling=function(){return new ge(this.parent,this.base)};var H=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Vt[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};H.prototype.reset=function(t,i,r){var s=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=i+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};H.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};H.prototype.at=function(t,i){i===void 0&&(i=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(i||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var n=r.charCodeAt(t+1);return n>=56320&&n<=57343?(a<<10)+n-56613888:a};H.prototype.nextIndex=function(t,i){i===void 0&&(i=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),n;return!(i||this.switchU)||a<=55295||a>=57344||t+1>=s||(n=r.charCodeAt(t+1))<56320||n>57343?t+1:t+2};H.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};H.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};H.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};H.prototype.eat=function(t,i){return i===void 0&&(i=!1),this.current(i)===t?(this.advance(i),!0):!1};H.prototype.eatChars=function(t,i){i===void 0&&(i=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var n=a[s],u=this.at(r,i);if(u===-1||u!==n)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};m.validateRegExpFlags=function(e){for(var t=e.validFlags,i=e.flags,r=!1,s=!1,a=0;a<i.length;a++){var n=i.charAt(a);t.indexOf(n)===-1&&this.raise(e.start,"Invalid regular expression flag"),i.indexOf(n,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),n==="u"&&(r=!0),n==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Si(e){for(var t in e)return!0;return!1}m.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Si(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};m.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,i=e.backReferenceNames;t<i.length;t+=1){var r=i[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};m.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ge(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};m.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};m.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};m.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!i,!0}return e.pos=t,!1};m.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};m.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};m.regexp_eatBracedQuantifier=function(e,t){var i=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=i}return!1};m.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};m.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};m.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(e),r=e.eat(45);if(i||r){for(var s=0;s<i.length;s++){var a=i.charAt(s);i.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var n=this.regexp_eatModifiers(e);!i&&!n&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var u=0;u<n.length;u++){var p=n.charAt(u);(n.indexOf(p,u+1)>-1||i.indexOf(p)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};m.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};m.regexp_eatModifiers=function(e){for(var t="",i=0;(i=e.current())!==-1&&ki(i);)t+=Q(i),e.advance();return t};function ki(e){return e===105||e===109||e===115}m.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};m.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};m.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Tt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Tt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}m.regexp_eatPatternCharacters=function(e){for(var t=e.pos,i=0;(i=e.current())!==-1&&!Tt(i);)e.advance();return e.pos!==t};m.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};m.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,i=e.groupNames[e.lastStringValue];if(i)if(t)for(var r=0,s=i;r<s.length;r+=1){var a=s[r];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(i||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};m.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};m.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Q(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Q(e.lastIntValue);return!0}return!1};m.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,r=e.current(i);return e.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(r=e.lastIntValue),_i(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function _i(e){return K(e,!0)||e===36||e===95}m.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,r=e.current(i);return e.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(r=e.lastIntValue),Ai(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ai(e){return te(e,!0)||e===36||e===95||e===8204||e===8205}m.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};m.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var i=e.lastIntValue;if(e.switchU)return i>e.maxBackReference&&(e.maxBackReference=i),!0;if(i<=e.numCapturingParens)return!0;e.pos=t}return!1};m.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};m.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};m.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};m.regexp_eatZero=function(e){return e.current()===48&&!Ce(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};m.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};m.regexp_eatControlLetter=function(e){var t=e.current();return Lt(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Lt(e){return e>=65&&e<=90||e>=97&&e<=122}m.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var i=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(n>=56320&&n<=57343)return e.lastIntValue=(s-55296)*1024+(n-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Ii(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=i}return!1};function Ii(e){return e>=0&&e<=1114111}m.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};m.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Mt=0,Y=1,D=2;m.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Pi(t))return e.lastIntValue=-1,e.advance(),Y;var i=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((i=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return i&&r===D&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Mt};function Pi(e){return e===100||e===68||e===115||e===83||e===119||e===87}m.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var i=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,i,r),Y}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Mt};m.regexp_validateUnicodePropertyNameAndValue=function(e,t,i){se(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(i)||e.raise("Invalid property value")};m.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Y;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return D;e.raise("Invalid property name")};m.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Rt(t=e.current());)e.lastStringValue+=Q(t),e.advance();return e.lastStringValue!==""};function Rt(e){return Lt(e)||e===95}m.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Ni(t=e.current());)e.lastStringValue+=Q(t),e.advance();return e.lastStringValue!==""};function Ni(e){return Rt(e)||Ce(e)}m.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};m.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),i=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&i===D&&e.raise("Negated character class may contain strings"),!0}return!1};m.regexp_classContents=function(e){return e.current()===93?Y:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Y)};m.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var i=e.lastIntValue;e.switchU&&(t===-1||i===-1)&&e.raise("Invalid character class"),t!==-1&&i!==-1&&t>i&&e.raise("Range out of order in character class")}}};m.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var i=e.current();(i===99||Ot(i))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};m.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};m.regexp_classSetExpression=function(e){var t=Y,i;if(!this.regexp_eatClassSetRange(e))if(i=this.regexp_eatClassSetOperand(e)){i===D&&(t=D);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(i=this.regexp_eatClassSetOperand(e))){i!==D&&(t=Y);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(i=this.regexp_eatClassSetOperand(e),!i)return t;i===D&&(t=D)}};m.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return i!==-1&&r!==-1&&i>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};m.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Y:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};m.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var i=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return i&&r===D&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};m.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var i=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return i}else e.raise("Invalid escape");e.pos=t}return null};m.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===D&&(t=D);return t};m.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Y:D};m.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var i=e.current();return i<0||i===e.lookahead()&&Vi(i)||Ti(i)?!1:(e.advance(),e.lastIntValue=i,!0)};function Vi(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Ti(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}m.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Li(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Li(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}m.regexp_eatClassControlLetter=function(e){var t=e.current();return Ce(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};m.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};m.regexp_eatDecimalDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;Ce(i=e.current());)e.lastIntValue=10*e.lastIntValue+(i-48),e.advance();return e.pos!==t};function Ce(e){return e>=48&&e<=57}m.regexp_eatHexDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;Bt(i=e.current());)e.lastIntValue=16*e.lastIntValue+Dt(i),e.advance();return e.pos!==t};function Bt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Dt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}m.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var i=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+i*8+e.lastIntValue:e.lastIntValue=t*8+i}else e.lastIntValue=t;return!0}return!1};m.regexp_eatOctalDigit=function(e){var t=e.current();return Ot(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ot(e){return e>=48&&e<=55}m.regexp_eatFixedHexDigits=function(e,t){var i=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Bt(s))return e.pos=i,!1;e.lastIntValue=16*e.lastIntValue+Dt(s),e.advance()}return!0};var qe=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new ve(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},v=A.prototype;v.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new qe(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};v.getToken=function(){return this.next(),new qe(this)};typeof Symbol<"u"&&(v[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===o.eof,value:t}}}});v.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(o.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};v.readToken=function(e){return K(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};v.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};v.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var r=void 0,s=t;(r=ot(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,i),t,this.pos,e,this.curPosition())};v.skipLineComment=function(e){for(var t=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!re(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,i,this.curPosition())};v.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&ut.test(String.fromCharCode(e)))++this.pos;else break e}}};v.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=e,this.value=t,this.updateContext(i)};v.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(o.ellipsis)):(++this.pos,this.finishToken(o.dot))};v.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(o.assign,2):this.finishOp(o.slash,1)};v.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),i=1,r=e===42?o.star:o.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++i,r=o.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(o.assign,i+1):this.finishOp(r,i)};v.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(o.assign,3)}return this.finishOp(e===124?o.logicalOR:o.logicalAND,2)}return t===61?this.finishOp(o.assign,2):this.finishOp(e===124?o.bitwiseOR:o.bitwiseAND,1)};v.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(o.assign,2):this.finishOp(o.bitwiseXOR,1)};v.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||O.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(o.incDec,2):t===61?this.finishOp(o.assign,2):this.finishOp(o.plusMin,1)};v.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),i=1;return t===e?(i=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(o.assign,i+1):this.finishOp(o.bitShift,i)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(i=2),this.finishOp(o.relational,i))};v.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(o.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(o.arrow)):this.finishOp(e===61?o.eq:o.prefix,1)};v.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(o.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(o.assign,3)}return this.finishOp(o.coalesce,2)}}return this.finishOp(o.question,1)};v.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),K(t,!0)||t===92))return this.finishToken(o.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Q(t)+"'")};v.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(o.parenL);case 41:return++this.pos,this.finishToken(o.parenR);case 59:return++this.pos,this.finishToken(o.semi);case 44:return++this.pos,this.finishToken(o.comma);case 91:return++this.pos,this.finishToken(o.bracketL);case 93:return++this.pos,this.finishToken(o.bracketR);case 123:return++this.pos,this.finishToken(o.braceL);case 125:return++this.pos,this.finishToken(o.braceR);case 58:return++this.pos,this.finishToken(o.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(o.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(o.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Q(e)+"'")};v.finishOp=function(e,t){var i=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,i)};v.readRegexp=function(){for(var e,t,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(O.test(r)&&this.raise(i,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(i,this.pos);++this.pos;var a=this.pos,n=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new H(this));u.reset(i,s,n),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var p=null;try{p=new RegExp(s,n)}catch{}return this.finishToken(o.regexp,{pattern:s,flags:n,value:p})};v.readInt=function(e,t,i){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,n=0,u=0,p=0,h=t??1/0;p<h;++p,++this.pos){var c=this.input.charCodeAt(this.pos),y=void 0;if(r&&c===95){s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),u===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),p===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),u=c;continue}if(c>=97?y=c-97+10:c>=65?y=c-65+10:c>=48&&c<=57?y=c-48:y=1/0,y>=e)break;u=c,n=n*e+y}return r&&u===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:n};function Mi(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ft(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}v.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var i=this.readInt(e);return i==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=Ft(this.input.slice(t,this.pos)),++this.pos):K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(o.num,i)};v.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var i=this.pos-t>=2&&this.input.charCodeAt(t)===48;i&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!e&&this.options.ecmaVersion>=11&&r===110){var s=Ft(this.input.slice(t,this.pos));return++this.pos,K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(o.num,s)}i&&/[89]/.test(this.input.slice(t,this.pos))&&(i=!1),r===46&&!i&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!i&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=Mi(this.input.slice(t,this.pos),i);return this.finishToken(o.num,a)};v.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else t=this.readHexChar(4);return t};v.readString=function(e){for(var t="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(i,this.pos),t+=this.readEscapedChar(!1),i=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(re(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(i,this.pos++),this.finishToken(o.string,t)};var jt={};v.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===jt)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};v.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw jt;this.raise(e,t)};v.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===o.template||this.type===o.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(o.dollarBraceL)):(++this.pos,this.finishToken(o.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(o.template,e));if(i===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(re(i)){switch(e+=this.input.slice(t,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
23
|
+
`;break;default:e+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};v.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(o.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
24
|
+
`&&++this.pos;case`
|
|
25
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};v.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
26
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Q(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return re(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};v.readHexChar=function(e){var t=this.pos,i=this.readInt(16,e);return i===null&&this.invalidStringToken(t,"Bad character escape sequence"),i};v.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(te(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(i,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var n=this.readCodePoint();(t?K:te)(n,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Q(n),i=this.pos}else break;t=!1}return e+this.input.slice(i,this.pos)};v.readWord=function(){var e=this.readWord1(),t=o.name;return this.keywords.test(e)&&(t=Me[e]),this.finishToken(t,e)};var Ri="8.14.0";A.acorn={Parser:A,version:Ri,defaultOptions:Ne,Position:pe,SourceLocation:ve,getLineInfo:ht,Node:Ee,TokenType:C,tokTypes:o,keywordTypes:Me,TokContext:j,tokContexts:k,isIdentifierChar:te,isIdentifierStart:K,Token:qe,isNewLine:re,lineBreak:O,lineBreakG:ri,nonASCIIwhitespace:ut};function Bi(e,t){return A.parse(e,t)}function qt(e,t,i,r,s){i||(i=f),function a(n,u,p){var h=p||n.type;i[h](n,u,a),t[h]&&t[h](n,u)}(e,r,s)}function V(e,t,i,r,s){var a=i?Di(i,r||void 0):r;(function n(u,p,h){a[h||u.type](u,p,n)})(e,t,s)}function Di(e,t){var i=Object.create(t||f);for(var r in e)i[r]=e[r];return i}function Ue(e,t,i){i(e,t)}function $(e,t,i){}var f={};f.Program=f.BlockStatement=f.StaticBlock=function(e,t,i){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];i(a,t,"Statement")}};f.Statement=Ue;f.EmptyStatement=$;f.ExpressionStatement=f.ParenthesizedExpression=f.ChainExpression=function(e,t,i){return i(e.expression,t,"Expression")};f.IfStatement=function(e,t,i){i(e.test,t,"Expression"),i(e.consequent,t,"Statement"),e.alternate&&i(e.alternate,t,"Statement")};f.LabeledStatement=function(e,t,i){return i(e.body,t,"Statement")};f.BreakStatement=f.ContinueStatement=$;f.WithStatement=function(e,t,i){i(e.object,t,"Expression"),i(e.body,t,"Statement")};f.SwitchStatement=function(e,t,i){i(e.discriminant,t,"Expression");for(var r=0,s=e.cases;r<s.length;r+=1){var a=s[r];i(a,t)}};f.SwitchCase=function(e,t,i){e.test&&i(e.test,t,"Expression");for(var r=0,s=e.consequent;r<s.length;r+=1){var a=s[r];i(a,t,"Statement")}};f.ReturnStatement=f.YieldExpression=f.AwaitExpression=function(e,t,i){e.argument&&i(e.argument,t,"Expression")};f.ThrowStatement=f.SpreadElement=function(e,t,i){return i(e.argument,t,"Expression")};f.TryStatement=function(e,t,i){i(e.block,t,"Statement"),e.handler&&i(e.handler,t),e.finalizer&&i(e.finalizer,t,"Statement")};f.CatchClause=function(e,t,i){e.param&&i(e.param,t,"Pattern"),i(e.body,t,"Statement")};f.WhileStatement=f.DoWhileStatement=function(e,t,i){i(e.test,t,"Expression"),i(e.body,t,"Statement")};f.ForStatement=function(e,t,i){e.init&&i(e.init,t,"ForInit"),e.test&&i(e.test,t,"Expression"),e.update&&i(e.update,t,"Expression"),i(e.body,t,"Statement")};f.ForInStatement=f.ForOfStatement=function(e,t,i){i(e.left,t,"ForInit"),i(e.right,t,"Expression"),i(e.body,t,"Statement")};f.ForInit=function(e,t,i){e.type==="VariableDeclaration"?i(e,t):i(e,t,"Expression")};f.DebuggerStatement=$;f.FunctionDeclaration=function(e,t,i){return i(e,t,"Function")};f.VariableDeclaration=function(e,t,i){for(var r=0,s=e.declarations;r<s.length;r+=1){var a=s[r];i(a,t)}};f.VariableDeclarator=function(e,t,i){i(e.id,t,"Pattern"),e.init&&i(e.init,t,"Expression")};f.Function=function(e,t,i){e.id&&i(e.id,t,"Pattern");for(var r=0,s=e.params;r<s.length;r+=1){var a=s[r];i(a,t,"Pattern")}i(e.body,t,e.expression?"Expression":"Statement")};f.Pattern=function(e,t,i){e.type==="Identifier"?i(e,t,"VariablePattern"):e.type==="MemberExpression"?i(e,t,"MemberPattern"):i(e,t)};f.VariablePattern=$;f.MemberPattern=Ue;f.RestElement=function(e,t,i){return i(e.argument,t,"Pattern")};f.ArrayPattern=function(e,t,i){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&i(a,t,"Pattern")}};f.ObjectPattern=function(e,t,i){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];a.type==="Property"?(a.computed&&i(a.key,t,"Expression"),i(a.value,t,"Pattern")):a.type==="RestElement"&&i(a.argument,t,"Pattern")}};f.Expression=Ue;f.ThisExpression=f.Super=f.MetaProperty=$;f.ArrayExpression=function(e,t,i){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&i(a,t,"Expression")}};f.ObjectExpression=function(e,t,i){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];i(a,t)}};f.FunctionExpression=f.ArrowFunctionExpression=f.FunctionDeclaration;f.SequenceExpression=function(e,t,i){for(var r=0,s=e.expressions;r<s.length;r+=1){var a=s[r];i(a,t,"Expression")}};f.TemplateLiteral=function(e,t,i){for(var r=0,s=e.quasis;r<s.length;r+=1){var a=s[r];i(a,t)}for(var n=0,u=e.expressions;n<u.length;n+=1){var p=u[n];i(p,t,"Expression")}};f.TemplateElement=$;f.UnaryExpression=f.UpdateExpression=function(e,t,i){i(e.argument,t,"Expression")};f.BinaryExpression=f.LogicalExpression=function(e,t,i){i(e.left,t,"Expression"),i(e.right,t,"Expression")};f.AssignmentExpression=f.AssignmentPattern=function(e,t,i){i(e.left,t,"Pattern"),i(e.right,t,"Expression")};f.ConditionalExpression=function(e,t,i){i(e.test,t,"Expression"),i(e.consequent,t,"Expression"),i(e.alternate,t,"Expression")};f.NewExpression=f.CallExpression=function(e,t,i){if(i(e.callee,t,"Expression"),e.arguments)for(var r=0,s=e.arguments;r<s.length;r+=1){var a=s[r];i(a,t,"Expression")}};f.MemberExpression=function(e,t,i){i(e.object,t,"Expression"),e.computed&&i(e.property,t,"Expression")};f.ExportNamedDeclaration=f.ExportDefaultDeclaration=function(e,t,i){e.declaration&&i(e.declaration,t,e.type==="ExportNamedDeclaration"||e.declaration.id?"Statement":"Expression"),e.source&&i(e.source,t,"Expression")};f.ExportAllDeclaration=function(e,t,i){e.exported&&i(e.exported,t),i(e.source,t,"Expression")};f.ImportDeclaration=function(e,t,i){for(var r=0,s=e.specifiers;r<s.length;r+=1){var a=s[r];i(a,t)}i(e.source,t,"Expression")};f.ImportExpression=function(e,t,i){i(e.source,t,"Expression")};f.ImportSpecifier=f.ImportDefaultSpecifier=f.ImportNamespaceSpecifier=f.Identifier=f.PrivateIdentifier=f.Literal=$;f.TaggedTemplateExpression=function(e,t,i){i(e.tag,t,"Expression"),i(e.quasi,t,"Expression")};f.ClassDeclaration=f.ClassExpression=function(e,t,i){return i(e,t,"Class")};f.Class=function(e,t,i){e.id&&i(e.id,t,"Pattern"),e.superClass&&i(e.superClass,t,"Expression"),i(e.body,t)};f.ClassBody=function(e,t,i){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];i(a,t)}};f.MethodDefinition=f.PropertyDefinition=f.Property=function(e,t,i){e.computed&&i(e.key,t,"Expression"),e.value&&i(e.value,t,"Expression")};const{stringify:Oi}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");const fe={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},q=17,Fi={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:q,ClassExpression:q,FunctionExpression:q,ObjectExpression:q,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function ee(e,t){const{generator:i}=e;if(e.write("("),t!=null&&t.length>0){i[t[0].type](t[0],e);const{length:r}=t;for(let s=1;s<r;s++){const a=t[s];e.write(", "),i[a.type](a,e)}}e.write(")")}function Ut(e,t,i,r){const s=e.expressionsPrecedence[t.type];if(s===q)return!0;const a=e.expressionsPrecedence[i.type];return s!==a?!r&&s===15&&a===14&&i.operator==="**"||s<a:s!==13&&s!==14?!1:t.operator==="**"&&i.operator==="**"?!r:s===13&&a===13&&(t.operator==="??"||i.operator==="??")?!0:r?fe[t.operator]<=fe[i.operator]:fe[t.operator]<fe[i.operator]}function me(e,t,i,r){const{generator:s}=e;Ut(e,t,i,r)?(e.write("("),s[t.type](t,e),e.write(")")):s[t.type](t,e)}function ji(e,t,i,r){const s=t.split(`
|
|
27
|
+
`),a=s.length-1;if(e.write(s[0].trim()),a>0){e.write(r);for(let n=1;n<a;n++)e.write(i+s[n].trim()+r);e.write(i+s[a].trim())}}function N(e,t,i,r){const{length:s}=t;for(let a=0;a<s;a++){const n=t[a];e.write(i),n.type[0]==="L"?e.write("// "+n.value.trim()+`
|
|
28
|
+
`,n):(e.write("/*"),ji(e,n.value,i,r),e.write("*/"+r))}}function qi(e){let t=e;for(;t!=null;){const{type:i}=t;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")t=t.object;else return!1}}function Ie(e,t){const{generator:i}=e,{declarations:r}=t;e.write(t.kind+" ");const{length:s}=r;if(s>0){i.VariableDeclarator(r[0],e);for(let a=1;a<s;a++)e.write(", "),i.VariableDeclarator(r[a],e)}}let Ze,Je,$e,et,tt,it;const Ui={Program(e,t){const i=t.indent.repeat(t.indentLevel),{lineEnd:r,writeComments:s}=t;s&&e.comments!=null&&N(t,e.comments,i,r);const a=e.body,{length:n}=a;for(let u=0;u<n;u++){const p=a[u];s&&p.comments!=null&&N(t,p.comments,i,r),t.write(i),this[p.type](p,t),t.write(r)}s&&e.trailingComments!=null&&N(t,e.trailingComments,i,r)},BlockStatement:it=function(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,a=i+t.indent;t.write("{");const n=e.body;if(n!=null&&n.length>0){t.write(r),s&&e.comments!=null&&N(t,e.comments,a,r);const{length:u}=n;for(let p=0;p<u;p++){const h=n[p];s&&h.comments!=null&&N(t,h.comments,a,r),t.write(a),this[h.type](h,t),t.write(r)}t.write(i)}else s&&e.comments!=null&&(t.write(r),N(t,e.comments,a,r),t.write(i));s&&e.trailingComments!=null&&N(t,e.trailingComments,a,r),t.write("}"),t.indentLevel--},ClassBody:it,StaticBlock(e,t){t.write("static "),this.BlockStatement(e,t)},EmptyStatement(e,t){t.write(";")},ExpressionStatement(e,t){const i=t.expressionsPrecedence[e.expression.type];i===q||i===3&&e.expression.left.type[0]==="O"?(t.write("("),this[e.expression.type](e.expression,t),t.write(")")):this[e.expression.type](e.expression,t),t.write(";")},IfStatement(e,t){t.write("if ("),this[e.test.type](e.test,t),t.write(") "),this[e.consequent.type](e.consequent,t),e.alternate!=null&&(t.write(" else "),this[e.alternate.type](e.alternate,t))},LabeledStatement(e,t){this[e.label.type](e.label,t),t.write(": "),this[e.body.type](e.body,t)},BreakStatement(e,t){t.write("break"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},ContinueStatement(e,t){t.write("continue"),e.label!=null&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},WithStatement(e,t){t.write("with ("),this[e.object.type](e.object,t),t.write(") "),this[e.body.type](e.body,t)},SwitchStatement(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t;t.indentLevel++;const a=i+t.indent,n=a+t.indent;t.write("switch ("),this[e.discriminant.type](e.discriminant,t),t.write(") {"+r);const{cases:u}=e,{length:p}=u;for(let h=0;h<p;h++){const c=u[h];s&&c.comments!=null&&N(t,c.comments,a,r),c.test?(t.write(a+"case "),this[c.test.type](c.test,t),t.write(":"+r)):t.write(a+"default:"+r);const{consequent:y}=c,{length:l}=y;for(let g=0;g<l;g++){const E=y[g];s&&E.comments!=null&&N(t,E.comments,n,r),t.write(n),this[E.type](E,t),t.write(r)}}t.indentLevel-=2,t.write(i+"}")},ReturnStatement(e,t){t.write("return"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t)),t.write(";")},ThrowStatement(e,t){t.write("throw "),this[e.argument.type](e.argument,t),t.write(";")},TryStatement(e,t){if(t.write("try "),this[e.block.type](e.block,t),e.handler){const{handler:i}=e;i.param==null?t.write(" catch "):(t.write(" catch ("),this[i.param.type](i.param,t),t.write(") ")),this[i.body.type](i.body,t)}e.finalizer&&(t.write(" finally "),this[e.finalizer.type](e.finalizer,t))},WhileStatement(e,t){t.write("while ("),this[e.test.type](e.test,t),t.write(") "),this[e.body.type](e.body,t)},DoWhileStatement(e,t){t.write("do "),this[e.body.type](e.body,t),t.write(" while ("),this[e.test.type](e.test,t),t.write(");")},ForStatement(e,t){if(t.write("for ("),e.init!=null){const{init:i}=e;i.type[0]==="V"?Ie(t,i):this[i.type](i,t)}t.write("; "),e.test&&this[e.test.type](e.test,t),t.write("; "),e.update&&this[e.update.type](e.update,t),t.write(") "),this[e.body.type](e.body,t)},ForInStatement:Ze=function(e,t){t.write(`for ${e.await?"await ":""}(`);const{left:i}=e;i.type[0]==="V"?Ie(t,i):this[i.type](i,t),t.write(e.type[3]==="I"?" in ":" of "),this[e.right.type](e.right,t),t.write(") "),this[e.body.type](e.body,t)},ForOfStatement:Ze,DebuggerStatement(e,t){t.write("debugger;",e)},FunctionDeclaration:Je=function(e,t){t.write((e.async?"async ":"")+(e.generator?"function* ":"function ")+(e.id?e.id.name:""),e),ee(t,e.params),t.write(" "),this[e.body.type](e.body,t)},FunctionExpression:Je,VariableDeclaration(e,t){Ie(t,e),t.write(";")},VariableDeclarator(e,t){this[e.id.type](e.id,t),e.init!=null&&(t.write(" = "),this[e.init.type](e.init,t))},ClassDeclaration(e,t){if(t.write("class "+(e.id?`${e.id.name} `:""),e),e.superClass){t.write("extends ");const{superClass:i}=e,{type:r}=i,s=t.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(s===q||s<t.expressionsPrecedence.ClassExpression)?(t.write("("),this[e.superClass.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ")}this.ClassBody(e.body,t)},ImportDeclaration(e,t){t.write("import ");const{specifiers:i,attributes:r}=e,{length:s}=i;let a=0;if(s>0){for(;a<s;){a>0&&t.write(", ");const n=i[a],u=n.type[6];if(u==="D")t.write(n.local.name,n),a++;else if(u==="N")t.write("* as "+n.local.name,n),a++;else break}if(a<s){for(t.write("{");;){const n=i[a],{name:u}=n.imported;if(t.write(u,n),u!==n.local.name&&t.write(" as "+n.local.name),++a<s)t.write(", ");else break}t.write("}")}t.write(" from ")}if(this.Literal(e.source,t),r&&r.length>0){t.write(" with { ");for(let n=0;n<r.length;n++)this.ImportAttribute(r[n],t),n<r.length-1&&t.write(", ");t.write(" }")}t.write(";")},ImportAttribute(e,t){this.Identifier(e.key,t),t.write(": "),this.Literal(e.value,t)},ImportExpression(e,t){t.write("import("),this[e.source.type](e.source,t),t.write(")")},ExportDefaultDeclaration(e,t){t.write("export default "),this[e.declaration.type](e.declaration,t),t.expressionsPrecedence[e.declaration.type]!=null&&e.declaration.type[0]!=="F"&&t.write(";")},ExportNamedDeclaration(e,t){if(t.write("export "),e.declaration)this[e.declaration.type](e.declaration,t);else{t.write("{");const{specifiers:i}=e,{length:r}=i;if(r>0)for(let s=0;;){const a=i[s],{name:n}=a.local;if(t.write(n,a),n!==a.exported.name&&t.write(" as "+a.exported.name),++s<r)t.write(", ");else break}if(t.write("}"),e.source&&(t.write(" from "),this.Literal(e.source,t)),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let s=0;s<e.attributes.length;s++)this.ImportAttribute(e.attributes[s],t),s<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")}},ExportAllDeclaration(e,t){if(e.exported!=null?t.write("export * as "+e.exported.name+" from "):t.write("export * from "),this.Literal(e.source,t),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let i=0;i<e.attributes.length;i++)this.ImportAttribute(e.attributes[i],t),i<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")},MethodDefinition(e,t){e.static&&t.write("static ");const i=e.kind[0];(i==="g"||i==="s")&&t.write(e.kind+" "),e.value.async&&t.write("async "),e.value.generator&&t.write("*"),e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),ee(t,e.value.params),t.write(" "),this[e.value.body.type](e.value.body,t)},ClassExpression(e,t){this.ClassDeclaration(e,t)},ArrowFunctionExpression(e,t){t.write(e.async?"async ":"",e);const{params:i}=e;i!=null&&(i.length===1&&i[0].type[0]==="I"?t.write(i[0].name,i[0]):ee(t,e.params)),t.write(" => "),e.body.type[0]==="O"?(t.write("("),this.ObjectExpression(e.body,t),t.write(")")):this[e.body.type](e.body,t)},ThisExpression(e,t){t.write("this",e)},Super(e,t){t.write("super",e)},RestElement:$e=function(e,t){t.write("..."),this[e.argument.type](e.argument,t)},SpreadElement:$e,YieldExpression(e,t){t.write(e.delegate?"yield*":"yield"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t))},AwaitExpression(e,t){t.write("await ",e),me(t,e.argument,e)},TemplateLiteral(e,t){const{quasis:i,expressions:r}=e;t.write("`");const{length:s}=r;for(let n=0;n<s;n++){const u=r[n],p=i[n];t.write(p.value.raw,p),t.write("${"),this[u.type](u,t),t.write("}")}const a=i[i.length-1];t.write(a.value.raw,a),t.write("`")},TemplateElement(e,t){t.write(e.value.raw,e)},TaggedTemplateExpression(e,t){me(t,e.tag,e),this[e.quasi.type](e.quasi,t)},ArrayExpression:tt=function(e,t){if(t.write("["),e.elements.length>0){const{elements:i}=e,{length:r}=i;for(let s=0;;){const a=i[s];if(a!=null&&this[a.type](a,t),++s<r)t.write(", ");else{a==null&&t.write(", ");break}}}t.write("]")},ArrayPattern:tt,ObjectExpression(e,t){const i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:s}=t,a=i+t.indent;if(t.write("{"),e.properties.length>0){t.write(r),s&&e.comments!=null&&N(t,e.comments,a,r);const n=","+r,{properties:u}=e,{length:p}=u;for(let h=0;;){const c=u[h];if(s&&c.comments!=null&&N(t,c.comments,a,r),t.write(a),this[c.type](c,t),++h<p)t.write(n);else break}t.write(r),s&&e.trailingComments!=null&&N(t,e.trailingComments,a,r),t.write(i+"}")}else s?e.comments!=null?(t.write(r),N(t,e.comments,a,r),e.trailingComments!=null&&N(t,e.trailingComments,a,r),t.write(i+"}")):e.trailingComments!=null?(t.write(r),N(t,e.trailingComments,a,r),t.write(i+"}")):t.write("}"):t.write("}");t.indentLevel--},Property(e,t){e.method||e.kind[0]!=="i"?this.MethodDefinition(e,t):(e.shorthand||(e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),t.write(": ")),this[e.value.type](e.value,t))},PropertyDefinition(e,t){if(e.static&&t.write("static "),e.computed&&t.write("["),this[e.key.type](e.key,t),e.computed&&t.write("]"),e.value==null){e.key.type[0]!=="F"&&t.write(";");return}t.write(" = "),this[e.value.type](e.value,t),t.write(";")},ObjectPattern(e,t){if(t.write("{"),e.properties.length>0){const{properties:i}=e,{length:r}=i;for(let s=0;this[i[s].type](i[s],t),++s<r;)t.write(", ")}t.write("}")},SequenceExpression(e,t){ee(t,e.expressions)},UnaryExpression(e,t){if(e.prefix){const{operator:i,argument:r,argument:{type:s}}=e;t.write(i);const a=Ut(t,r,e);!a&&(i.length>1||s[0]==="U"&&(s[1]==="n"||s[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&t.write(" "),a?(t.write(i.length>1?" (":"("),this[s](r,t),t.write(")")):this[s](r,t)}else this[e.argument.type](e.argument,t),t.write(e.operator)},UpdateExpression(e,t){e.prefix?(t.write(e.operator),this[e.argument.type](e.argument,t)):(this[e.argument.type](e.argument,t),t.write(e.operator))},AssignmentExpression(e,t){this[e.left.type](e.left,t),t.write(" "+e.operator+" "),this[e.right.type](e.right,t)},AssignmentPattern(e,t){this[e.left.type](e.left,t),t.write(" = "),this[e.right.type](e.right,t)},BinaryExpression:et=function(e,t){const i=e.operator==="in";i&&t.write("("),me(t,e.left,e,!1),t.write(" "+e.operator+" "),me(t,e.right,e,!0),i&&t.write(")")},LogicalExpression:et,ConditionalExpression(e,t){const{test:i}=e,r=t.expressionsPrecedence[i.type];r===q||r<=t.expressionsPrecedence.ConditionalExpression?(t.write("("),this[i.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ? "),this[e.consequent.type](e.consequent,t),t.write(" : "),this[e.alternate.type](e.alternate,t)},NewExpression(e,t){t.write("new ");const i=t.expressionsPrecedence[e.callee.type];i===q||i<t.expressionsPrecedence.CallExpression||qi(e.callee)?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),ee(t,e.arguments)},CallExpression(e,t){const i=t.expressionsPrecedence[e.callee.type];i===q||i<t.expressionsPrecedence.CallExpression?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),e.optional&&t.write("?."),ee(t,e.arguments)},ChainExpression(e,t){this[e.expression.type](e.expression,t)},MemberExpression(e,t){const i=t.expressionsPrecedence[e.object.type];i===q||i<t.expressionsPrecedence.MemberExpression?(t.write("("),this[e.object.type](e.object,t),t.write(")")):this[e.object.type](e.object,t),e.computed?(e.optional&&t.write("?."),t.write("["),this[e.property.type](e.property,t),t.write("]")):(e.optional?t.write("?."):t.write("."),this[e.property.type](e.property,t))},MetaProperty(e,t){t.write(e.meta.name+"."+e.property.name,e)},Identifier(e,t){t.write(e.name,e)},PrivateIdentifier(e,t){t.write(`#${e.name}`,e)},Literal(e,t){e.raw!=null?t.write(e.raw,e):e.regex!=null?this.RegExpLiteral(e,t):e.bigint!=null?t.write(e.bigint+"n",e):t.write(Oi(e.value),e)},RegExpLiteral(e,t){const{regex:i}=e;t.write(`/${i.pattern}/${i.flags}`,e)}},Wi={};class Gi{constructor(t){const i=t??Wi;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Ui,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:Fi,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
29
|
+
`,this.indentLevel=i.startingIndentLevel!=null?i.startingIndentLevel:0,this.writeComments=i.comments?i.comments:!1,i.sourceMap!=null&&(this.write=i.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=i.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
30
|
+
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(t){this.output+=t}writeToStream(t){this.output.write(t)}writeAndMap(t,i){this.output+=t,this.map(t,i)}writeToStreamAndMap(t,i){this.output.write(t),this.map(t,i)}map(t,i){if(i!=null){const{type:a}=i;if(a[0]==="L"&&a[2]==="n"){this.column=0,this.line++;return}if(i.loc!=null){const{mapping:n}=this;n.original=i.loc.start,n.name=i.name,this.sourceMap.addMapping(n)}if(a[0]==="T"&&a[8]==="E"||a[0]==="L"&&a[1]==="i"&&typeof i.value=="string"){const{length:n}=t;let{column:u,line:p}=this;for(let h=0;h<n;h++)t[h]===`
|
|
31
|
+
`?(u=0,p++):u++;this.column=u,this.line=p;return}}const{length:r}=t,{lineEnd:s}=this;r>0&&(this.lineEndSize>0&&(s.length===1?t[r-1]===s:t.endsWith(s))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function zi(e,t){const i=new Gi(t);return i.generator[e.type](e,i),i.output}class Hi{scopes=[];scopeTypes=[];scopeCounts=new Map;contextBoundVars=new Set;arrayPatternElements=new Set;rootParams=new Set;varKinds=new Map;loopVars=new Set;loopVarNames=new Map;paramIdCounter=0;tempVarCounter=0;get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}constructor(){this.pushScope("glb")}pushScope(t){this.scopes.push(new Map),this.scopeTypes.push(t),this.scopeCounts.set(t,(this.scopeCounts.get(t)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addContextBoundVar(t,i=!1){this.contextBoundVars.add(t),i&&this.rootParams.add(t)}addArrayPatternElement(t){this.arrayPatternElements.add(t)}isContextBound(t){return this.contextBoundVars.has(t)}isArrayPatternElement(t){return this.arrayPatternElements.has(t)}isRootParam(t){return this.rootParams.has(t)}addLoopVariable(t,i){this.loopVars.add(t),this.loopVarNames.set(t,i)}getLoopVariableName(t){return this.loopVarNames.get(t)}isLoopVariable(t){return this.loopVars.has(t)}addVariable(t,i){if(this.isContextBound(t))return t;const r=this.scopes[this.scopes.length-1],s=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(s)||1,n=`${s}${a}_${t}`;return r.set(t,n),this.varKinds.set(n,i),n}getVariable(t){if(this.loopVars.has(t)){const i=this.loopVarNames.get(t);if(i)return[i,"let"]}if(this.isContextBound(t))return[t,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(t)){const s=r.get(t),a=this.varKinds.get(s)||"let";return[s,a]}}return[t,"let"]}generateTempVar(){return`temp_${++this.tempVarCounter}`}}//!!!Warning!!! this code is not clean, it was initially written as a PoC then used as transpiler for PineTS
|
|
32
|
+
const _="$",Le={type:"Identifier",name:"undefined"};function ie(e,t){if(e.computed&&e.property.type==="Identifier"){if(t.isLoopVariable(e.property.name))return;if(!t.isContextBound(e.property.name)){const[i,r]=t.getVariable(e.property.name);e.property={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:r},computed:!1},property:{type:"Identifier",name:i},computed:!1},e.property={type:"MemberExpression",object:e.property,property:{type:"Literal",value:0},computed:!0}}}if(e.computed&&e.object.type==="Identifier"){if(t.isLoopVariable(e.object.name))return;if(!t.isContextBound(e.object.name)){const[i,r]=t.getVariable(e.object.name);e.object={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:r},computed:!1},property:{type:"Identifier",name:i},computed:!1}}if(e.property.type==="MemberExpression"){const i=e.property;i._indexTransformed||(ie(i,t),i._indexTransformed=!0)}}}function U(e,t,i){if(e.object&&e.object.type==="Identifier"&&e.object.name==="Math")return;const r=i.getCurrentScopeType()=="if",s=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";!r&&!s&&!a&&e.object&&e.object.type==="Identifier"&&i.isContextBound(e.object.name)&&!i.isRootParam(e.object.name)||e._indexTransformed||(ie(e,i),e._indexTransformed=!0)}function We(e,t){e.declarations.forEach(i=>{const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===_||i.init.object.name==="context2"),s=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===_||i.init.object.object.name==="context2"),a=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&t.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(l=>{l.key.name&&t.addContextBoundVar(l.key.name)}),i.init.object.name=_;return}if(s){i.id.name&&t.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(l=>{l.key.name&&t.addContextBoundVar(l.key.name)}),i.init.object.object.name=_;return}a&&i.init.params.forEach(l=>{l.type==="Identifier"&&t.addContextBoundVar(l.name)});const n=t.addVariable(i.id.name,e.kind),u=e.kind;i.init&&!a&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&t.isContextBound(i.init.callee.object.name)?W(i.init,t):V(i.init,{parent:i.init},{Identifier(l,g){l.parent=g.parent,G(l,t);const E=l.parent&&l.parent.type==="BinaryExpression",x=l.parent&&l.parent.type==="ConditionalExpression";l.type==="Identifier"&&(E||x)&&Object.assign(l,{type:"MemberExpression",object:{type:"Identifier",name:l.name},property:{type:"Literal",value:0},computed:!0})},CallExpression(l,g,E){l.callee.type==="Identifier"&&(l.callee.parent=l),l.arguments.forEach(x=>{x.type==="Identifier"&&(x.parent=l)}),W(l,t),l.arguments.forEach(x=>E(x,{parent:l}))},BinaryExpression(l,g,E){l.left.type==="Identifier"&&(l.left.parent=l),l.right.type==="Identifier"&&(l.right.parent=l),E(l.left,{parent:l}),E(l.right,{parent:l})},MemberExpression(l,g,E){l.object.type==="Identifier"&&(l.object.parent=l),l.property.type==="Identifier"&&(l.property.parent=l),ie(l,t),l.object&&E(l.object,{parent:l})}}));const p={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:u},computed:!1},property:{type:"Identifier",name:n},computed:!1},h=t.isArrayPatternElement(i.id.name),c=!h&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(ie(i.init.property,t),i.init.property._indexTransformed=!0));const y={type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:p,right:i.init?a||h?i.init:{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:"init"},computed:!1},arguments:c?[p,i.init.object,i.init.property]:[p,i.init]}:{type:"Identifier",name:"undefined"}}};h&&(y.expression.right.object.property.name+="?.[0]"),a&&(t.pushScope("fn"),V(i.init.body,t,{BlockStatement(l,g,E){l.body.forEach(x=>E(x,g))},IfStatement(l,g,E){g.pushScope("if"),E(l.consequent,g),l.alternate&&(g.pushScope("els"),E(l.alternate,g),g.popScope()),g.popScope()},VariableDeclaration(l,g){We(l,g)},Identifier(l,g){G(l,g)},AssignmentExpression(l,g){Ge(l,g)}}),t.popScope()),Object.assign(e,y)})}function G(e,t){if(e.name!==_){if(e.name==="Math"||e.name==="NaN"||e.name==="undefined"||e.name==="Infinity"||e.name==="null"||e.name.startsWith("'")&&e.name.endsWith("'")||e.name.startsWith('"')&&e.name.endsWith('"')||e.name.startsWith("`")&&e.name.endsWith("`")||t.isLoopVariable(e.name)||t.isContextBound(e.name)&&!t.isRootParam(e.name))return;const i=e.parent&&e.parent.type==="MemberExpression"&&e.parent.object===e&&t.isContextBound(e.name),r=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee&&e.parent.callee.type==="MemberExpression"&&e.parent.callee.property.name==="param";e.parent&&e.parent.type==="AssignmentExpression"&&e.parent.left;const s=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee&&e.parent.callee.type==="MemberExpression"&&t.isContextBound(e.parent.callee.object.name),a=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed,n=e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.property===e&&e.parent.parent&&e.parent.parent.type==="CallExpression"&&e.parent.parent.callee&&e.parent.parent.callee.type==="MemberExpression"&&t.isContextBound(e.parent.parent.callee.object.name),u=e.parent&&e.parent.type==="CallExpression"&&e.parent.callee===e;if(i||r||s||n||u){if(u)return;const[y,l]=t.getVariable(e.name);Object.assign(e,{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:l},computed:!1},property:{type:"Identifier",name:y},computed:!1});return}const[p,h]=t.getVariable(e.name),c={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:h},computed:!1},property:{type:"Identifier",name:p},computed:!1};!(e.parent&&e.parent.type==="MemberExpression"&&e.parent.computed&&e.parent.object===e)&&!a?Object.assign(e,{type:"MemberExpression",object:c,property:{type:"Literal",value:0},computed:!0}):Object.assign(e,c)}}function Ge(e,t){if(e.left.type==="Identifier"){const[i,r]=t.getVariable(e.left.name),s={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:r},computed:!1},property:{type:"Identifier",name:i},computed:!1};e.left={type:"MemberExpression",object:s,property:{type:"Literal",value:0},computed:!0}}V(e.right,{parent:e.right,inNamespaceCall:!1},{Identifier(i,r,s){i.parent=r.parent,G(i,t);const a=i.parent&&i.parent.type==="BinaryExpression";(i.parent&&i.parent.type==="ConditionalExpression"||a)&&(i.type==="MemberExpression"?ie(i,t):i.type==="Identifier"&&Se(i))},MemberExpression(i,r,s){ie(i,t),i.object&&s(i.object,{parent:i,inNamespaceCall:r.inNamespaceCall})},CallExpression(i,r,s){const a=i.callee&&i.callee.type==="MemberExpression"&&i.callee.object&&i.callee.object.type==="Identifier"&&t.isContextBound(i.callee.object.name);W(i,t),i.arguments.forEach(n=>s(n,{parent:i,inNamespaceCall:a||r.inNamespaceCall}))}})}function Ki(e,t,i=!1){e.params.forEach(r=>{r.type==="Identifier"&&t.addContextBoundVar(r.name,i)})}function Wt(e,t){const i=t.getCurrentScopeType();if(e.argument){if(e.argument.type==="ArrayExpression")e.argument.elements=e.argument.elements.map(r=>{if(r.type==="Identifier"){if(t.isContextBound(r.name)&&!t.isRootParam(r.name))return{type:"MemberExpression",object:r,property:{type:"Literal",value:0},computed:!0};const[s,a]=t.getVariable(r.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:a},computed:!1},property:{type:"Identifier",name:s},computed:!1},property:{type:"Literal",value:0},computed:!0}}else if(r.type==="MemberExpression")return r.computed&&r.object.type==="Identifier"&&t.isContextBound(r.object.name)&&!t.isRootParam(r.object.name)||U(r,"",t),r;return r}),e.argument={type:"ArrayExpression",elements:[e.argument]};else if(e.argument.type==="BinaryExpression")V(e.argument,t,{Identifier(r,s){G(r,s),r.type==="Identifier"&&Se(r)},MemberExpression(r){U(r,"",t)}});else if(e.argument.type==="ObjectExpression")e.argument.properties=e.argument.properties.map(r=>{if(r.shorthand){const[s,a]=t.getVariable(r.value.name);return{type:"Property",key:{type:"Identifier",name:r.key.name},value:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:a},computed:!1},property:{type:"Identifier",name:s},computed:!1},kind:"init",method:!1,shorthand:!1,computed:!1}}return r});else if(e.argument.type==="Identifier"){const[r,s]=t.getVariable(e.argument.name);e.argument={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:s},computed:!1},property:{type:"Identifier",name:r},computed:!1},e.argument={type:"MemberExpression",object:e.argument,property:{type:"Literal",value:0},computed:!0}}i==="fn"&&(e.argument={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:"precision"}},arguments:[e.argument]})}}function ue(e,t){if(e.type==="Identifier"){if(t.isLoopVariable(e.name))return e;if(t.isRootParam(e.name)){const[s,a]=t.getVariable(e.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:a},computed:!1},property:{type:"Identifier",name:s},computed:!1}}if(t.isContextBound(e.name))return e;const[i,r]=t.getVariable(e.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:r},computed:!1},property:{type:"Identifier",name:i},computed:!1}}return e}function rt(e,t,i=""){return e.type==="BinaryExpression"?Gt(e,t,i):e.type==="MemberExpression"?{type:"MemberExpression",object:e.object.type==="Identifier"?ue(e.object,t):e.object,property:e.property,computed:e.computed}:e.type==="Identifier"?t.isLoopVariable(e.name)||e.parent&&e.parent.type==="MemberExpression"&&e.parent.property===e?e:{type:"MemberExpression",object:ue(e,t),property:{type:"Literal",value:0},computed:!0}:e}function Gt(e,t,i){const r=rt(e.left,t,i),s=rt(e.right,t,i),a={type:"BinaryExpression",operator:e.operator,left:r,right:s,start:e.start,end:e.end};return V(a,t,{CallExpression(n,u){n._transformed||W(n,u)},MemberExpression(n){U(n,"",t)}}),{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"param"},computed:!1},arguments:[a,Le,t.nextParamIdArg],_transformed:!0,_isParamCall:!0}}function st(e,t,i){if(e.type==="BinaryExpression")return Gt(e,i,t);if(e.type==="MemberExpression"&&e.computed&&e.property){const r=e.object.type==="Identifier"&&i.isContextBound(e.object.name)&&!i.isRootParam(e.object.name)?e.object:ue(e.object,i),s=e.property.type==="Identifier"&&!i.isContextBound(e.property.name)&&!i.isLoopVariable(e.property.name)?ue(e.property,i):e.property;return{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:t},property:{type:"Identifier",name:"param"},computed:!1},arguments:[r,s,i.nextParamIdArg],_transformed:!0,_isParamCall:!0}}return e.type==="ObjectExpression"&&(e.properties=e.properties.map(r=>{if(r.value.name){const[s,a]=i.getVariable(r.value.name);return{type:"Property",key:{type:"Identifier",name:r.key.name},value:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:_},property:{type:"Identifier",name:a},computed:!1},property:{type:"Identifier",name:s},computed:!1},kind:"init",method:!1,shorthand:!1,computed:!1}}return r})),e.type==="Identifier"&&i.isContextBound(e.name)&&!i.isRootParam(e.name)?{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:t},property:{type:"Identifier",name:"param"},computed:!1},arguments:[e,Le,i.nextParamIdArg],_transformed:!0,_isParamCall:!0}:(e?.type==="CallExpression"&&W(e,i),{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:t},property:{type:"Identifier",name:"param"},computed:!1},arguments:[e.type==="Identifier"?ue(e,i):e,Le,i.nextParamIdArg],_transformed:!0,_isParamCall:!0})}function W(e,t){if(!e._transformed){if(e.callee&&e.callee.type==="MemberExpression"&&e.callee.object&&e.callee.object.type==="Identifier"&&(t.isContextBound(e.callee.object.name)||e.callee.object.name==="math"||e.callee.object.name==="ta")){const i=e.callee.object.name;e.arguments=e.arguments.map(r=>r._isParamCall?r:st(r,i,t)),e._transformed=!0}else e.callee&&e.callee.type==="Identifier"&&(e.arguments=e.arguments.map(i=>i._isParamCall?i:st(i,_,t)),e._transformed=!0);e.arguments.forEach(i=>{V(i,t,{CallExpression(r,s){r._transformed||W(r,s)},MemberExpression(r){U(r,"",t)}})})}}function Qi(e,t){e.params.forEach(i=>{i.type==="Identifier"&&t.addContextBoundVar(i.name,!1)}),e.body&&e.body.type==="BlockStatement"&&(t.pushScope("fn"),V(e.body,t,{BlockStatement(i,r,s){i.body.forEach(a=>s(a,r))},ReturnStatement(i,r){Wt(i,r)},VariableDeclaration(i,r){We(i,r)},Identifier(i,r){G(i,r)},CallExpression(i,r){W(i,r),i.arguments.forEach(s=>{s.type==="BinaryExpression"&&V(s,r,{CallExpression(a,n){W(a,n)},MemberExpression(a){U(a,"",r)}})})},MemberExpression(i){U(i,"",t)},AssignmentExpression(i,r){Ge(i,r)},ForStatement(i,r,s){zt(i,r,s)},IfStatement(i,r,s){Ht(i,r,s)},BinaryExpression(i,r,s){V(i,r,{CallExpression(a,n){W(a,n)},MemberExpression(a){U(a,"",r)}})}}),t.popScope())}function Se(e,t){Object.assign(e,{type:"MemberExpression",object:{type:"Identifier",name:e.name,start:e.start,end:e.end},property:{type:"Literal",value:0},computed:!0,_indexTransformed:!0})}function zt(e,t,i){if(e.init&&e.init.type==="VariableDeclaration"){const r=e.init.declarations[0],s=r.id.name;t.addLoopVariable(s,s),e.init={type:"VariableDeclaration",kind:e.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:r.init}]},r.init&&V(r.init,t,{Identifier(a,n){t.isLoopVariable(a.name)||(t.pushScope("for"),G(a,n),t.popScope())},MemberExpression(a){t.pushScope("for"),U(a,"",t),t.popScope()}})}e.test&&V(e.test,t,{Identifier(r,s){!t.isLoopVariable(r.name)&&!r.computed&&(t.pushScope("for"),G(r,s),r.type==="Identifier"&&(r.computed=!0,Se(r)),t.popScope())},MemberExpression(r){t.pushScope("for"),U(r,"",t),t.popScope()}}),e.update&&V(e.update,t,{Identifier(r,s){t.isLoopVariable(r.name)||(t.pushScope("for"),G(r,s),t.popScope())}}),t.pushScope("for"),i(e.body,t),t.popScope()}function Yi(e,t){V(e,t,{MemberExpression(i){U(i,"",t)},CallExpression(i,r){W(i,r)},Identifier(i,r){G(i,r);const s=t.getCurrentScopeType()==="if";t.isContextBound(i.name)&&!t.isRootParam(i.name)&&s&&Se(i)}})}function Ht(e,t,i){e.test&&(t.pushScope("if"),Yi(e.test,t),t.popScope()),t.pushScope("if"),i(e.consequent,t),t.popScope(),e.alternate&&(t.pushScope("els"),i(e.alternate,t),t.popScope())}function Xi(e){V(e,null,{VariableDeclaration(t,i,r){t.declarations&&t.declarations.length>0&&t.declarations.forEach(s=>{if(s.init&&s.init.type==="ArrowFunctionExpression"&&s.init.start!==0){const a={type:"FunctionDeclaration",id:s.id,params:s.init.params,body:s.init.body.type==="BlockStatement"?s.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:s.init.body}]},async:s.init.async,generator:!1};Object.assign(t,a)}}),t.body&&t.body.body&&t.body.body.forEach(s=>r(s,i))}})}function Zi(e,t){qt(e,{VariableDeclaration(i){i.declarations.forEach(r=>{const s=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===_||r.init.object.name==="context2"),a=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===_||r.init.object.object.name==="context2");(s||a)&&(r.id.name&&t.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(n=>{n.key.name&&t.addContextBoundVar(n.key.name)}))})}})}function Ji(e){let t=typeof e=="function"?e.toString():e;const i=Bi(t.trim(),{ecmaVersion:"latest",sourceType:"module"});Xi(i);const r=new Hi;let s;Zi(i,r),qt(i,{FunctionDeclaration(n){Qi(n,r)},ArrowFunctionExpression(n){const u=n.start===0;u&&n.params&&n.params.length>0&&(s=n.params[0].name,n.params[0].name=_),Ki(n,r,u)},VariableDeclaration(n){n.declarations.forEach(u=>{if(u.id.type==="ArrayPattern"){const p=r.generateTempVar(),h={type:"VariableDeclaration",kind:n.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:p},init:u.init}]};u.id.elements?.forEach(y=>{y.type==="Identifier"&&r.addArrayPatternElement(y.name)});const c=u.id.elements.map((y,l)=>({type:"VariableDeclaration",kind:n.kind,declarations:[{type:"VariableDeclarator",id:y,init:{type:"MemberExpression",object:{type:"Identifier",name:p},property:{type:"Literal",value:l},computed:!0}}]}));Object.assign(n,{type:"BlockStatement",body:[h,...c]})}})},ForStatement(n){}}),V(i,r,{BlockStatement(n,u,p){n.body.forEach(h=>p(h,u))},ReturnStatement(n,u){Wt(n,u)},VariableDeclaration(n,u){We(n,u)},Identifier(n,u){G(n,u)},CallExpression(n,u){W(n,u)},MemberExpression(n){U(n,s,r)},AssignmentExpression(n,u){Ge(n,u)},FunctionDeclaration(n,u){},ForStatement(n,u,p){zt(n,u,p)},IfStatement(n,u,p){Ht(n,u,p)}});const a=zi(i);return new Function("",`return ${a}`)(this)}class $i{constructor(t,i,r,s,a,n){this.source=t,this.tickerId=i,this.timeframe=r,this.limit=s,this.sDate=a,this.eDate=n,this._readyPromise=new Promise(u=>{this.loadMarketData(t,i,r,s,a,n).then(p=>{const h=p.reverse();this._periods=h.length,this.data=h;const c=h.map(S=>S.open),y=h.map(S=>S.close),l=h.map(S=>S.high),g=h.map(S=>S.low),E=h.map(S=>S.volume),x=h.map(S=>(S.high+S.low+S.close)/3),I=h.map(S=>(S.high+S.low)/2),P=h.map(S=>(S.high+S.low+S.open+S.close)/4),Yt=h.map(S=>S.openTime),Xt=h.map(S=>S.closeTime);this.open=c,this.close=y,this.high=l,this.low=g,this.volume=E,this.hl2=I,this.hlc3=x,this.ohlc4=P,this.openTime=Yt,this.closeTime=Xt,this._ready=!0,u(!0)})})}data=[];open=[];high=[];low=[];close=[];volume=[];hl2=[];hlc3=[];ohlc4=[];openTime=[];closeTime=[];_periods=void 0;get periods(){return this._periods}_readyPromise=null;_ready=!1;async loadMarketData(t,i,r,s,a,n){return Array.isArray(t)?t:t.getMarketData(i,r,s,a,n)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}async run(t,i){await this.ready(),i||(i=this._periods);const r=new Qt(this.data);r.timeframe=this.timeframe;let s=Ji.bind(this)(t);const a=["const","var","let","params"];for(let n=this._periods-i,u=i-1;n<this._periods;n++,u--){r.idx=n,r.data.close=this.close.slice(u),r.data.open=this.open.slice(u),r.data.high=this.high.slice(u),r.data.low=this.low.slice(u),r.data.volume=this.volume.slice(u),r.data.hl2=this.hl2.slice(u),r.data.hlc3=this.hlc3.slice(u),r.data.ohlc4=this.ohlc4.slice(u),r.data.openTime=this.openTime.slice(u),r.data.closeTime=this.closeTime.slice(u);const p=await s(r);if(typeof p=="object"){typeof r.result!="object"&&(r.result={});for(let h in p){r.result[h]===void 0&&(r.result[h]=[]);const c=Array.isArray(p[h])?p[h][0]:p[h];r.result[h].push(c)}}else Array.isArray(r.result)||(r.result=[]),r.result.push(p);for(let h of a)for(let c in r[h])if(Array.isArray(r[h][c])){const y=r[h][c][0];r[h][c].unshift(y)}}return r}}class er{constructor(t){this.context=t}color={white:"white",lime:"lime",green:"green",red:"red",maroon:"maroon",black:"black",gray:"gray",blue:"blue"};extractPlotOptions(t){const i={};for(let r in t)Array.isArray(t[r])?i[r]=t[r][0]:i[r]=t[r];return i}indicator(t,i,r){}plotchar(t,i,r){this.context.plots[i]||(this.context.plots[i]={data:[],options:this.extractPlotOptions(r),title:i}),this.context.plots[i].data.push({time:this.context.marketData[this.context.marketData.length-this.context.idx-1].openTime,value:t[0],options:this.extractPlotOptions(r)})}plot(t,i,r){this.context.plots[i]||(this.context.plots[i]={data:[],options:this.extractPlotOptions(r),title:i}),this.context.plots[i].data.push({time:this.context.marketData[this.context.marketData.length-this.context.idx-1].openTime,value:t[0],options:this.extractPlotOptions(r)})}na(t){return Array.isArray(t)?isNaN(t[0]):isNaN(t)}nz(t,i=0){return Array.isArray(t)?isNaN(t[0])?i:t[0]:isNaN(t)?i:t}}class tr{constructor(t){this.context=t}param(t,i=0){return Array.isArray(t)?[t[i]]:[t]}any(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}int(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}float(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}bool(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}string(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}timeframe(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}time(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}price(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}session(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}source(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}symbol(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}text_area(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}enum(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}color(t,{title:i,group:r}={}){return Array.isArray(t)?t[0]:t}}class ir{constructor(t){this.context=t}_cache={};param(t,i=0){return Array.isArray(t)?t[i]:t}abs(t){return Math.abs(t)}pow(t,i){return Math.pow(t,i)}sqrt(t){return Math.sqrt(t)}log(t){return Math.log(t)}ln(t){return Math.log(t)}exp(t){return Math.exp(t)}floor(t){return Math.floor(t)}ceil(t){return Math.ceil(t)}round(t){return Math.round(t)}random(){return Math.random()}max(...t){return Math.max(...t)}min(...t){return Math.min(...t)}sin(t){return Math.sin(t)}cos(t){return Math.cos(t)}tan(t){return Math.tan(t)}asin(t){return Math.asin(t)}acos(t){return Math.acos(t)}atan(t){return Math.atan(t)}avg(...t){return t.reduce((i,r)=>{const s=Array.isArray(i)?i[0]:i,a=Array.isArray(r)?r[0]:r;return s+a},0)/t.length}}class rr{constructor(t){this.context=t}_cache={};param(t,i,r){return this.context.params[r]||(this.context.params[r]=[]),Array.isArray(t)?(i?this.context.params[r]=t.slice(i):this.context.params[r]=t.slice(0),[t[i],r]):(this.context.params[r][0]=t,[t,r])}async security(t,i,r){throw new Error("Not implemented")}}class sr{constructor(t){this.context=t}get tr(){return this.context.math.max(this.context.data.high[0]-this.context.data.low[0],this.context.math.abs(this.context.data.high[0]-this.context.data.close[1]),this.context.math.abs(this.context.data.low[0]-this.context.data.close[1]))}param(t,i,r){return this.context.params[r]||(this.context.params[r]=[]),Array.isArray(t)?i?(this.context.params[r]=t.slice(i),this.context.params[r]):(this.context.params[r]=t.slice(0),this.context.params[r]):(this.context.params[r][0]=t,this.context.params[r])}ema(t,i){const r=Array.isArray(i)?i[0]:i,s=ar(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}sma(t,i){const r=Array.isArray(i)?i[0]:i,s=ze(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}vwma(t,i){const r=Array.isArray(i)?i[0]:i,s=this.context.data.volume,a=ur(t.slice(0).reverse(),s.slice(0).reverse(),r),n=this.context.idx;return this.context.precision(a[n])}wma(t,i){const r=Array.isArray(i)?i[0]:i,s=de(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}hma(t,i){const r=Array.isArray(i)?i[0]:i,s=pr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}rma(t,i){const r=Array.isArray(i)?i[0]:i,s=or(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}change(t,i=1){const r=Array.isArray(i)?i[0]:i,s=hr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}rsi(t,i){const r=Array.isArray(i)?i[0]:i,s=nr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}atr(t){const i=Array.isArray(t)?t[0]:t,r=this.context.data.high.slice().reverse(),s=this.context.data.low.slice().reverse(),a=this.context.data.close.slice().reverse(),n=Kt(r,s,a,i),u=this.context.idx;return this.context.precision(n[u])}mom(t,i){const r=Array.isArray(i)?i[0]:i,s=cr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}roc(t,i){const r=Array.isArray(i)?i[0]:i,s=lr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}dev(t,i){const r=Array.isArray(i)?i[0]:i,s=fr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}variance(t,i){const r=Array.isArray(i)?i[0]:i,s=mr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}highest(t,i){const r=Array.isArray(i)?i[0]:i,s=dr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}lowest(t,i){const r=Array.isArray(i)?i[0]:i,s=xr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}median(t,i){const r=Array.isArray(i)?i[0]:i,s=yr(t.slice(0).reverse(),r),a=this.context.idx;return this.context.precision(s[a])}stdev(t,i,r=!0){const s=Array.isArray(i)?i[0]:i,a=Array.isArray(r)?r[0]:r,n=br(t.slice(0).reverse(),s,a),u=this.context.idx;return this.context.precision(n[u])}linreg(t,i,r){const s=Array.isArray(i)?i[0]:i,a=Array.isArray(r)?r[0]:r,n=gr(t.slice(0).reverse(),s,a),u=this.context.idx;return this.context.precision(n[u])}supertrend(t,i){const r=Array.isArray(t)?t[0]:t,s=Array.isArray(i)?i[0]:i,a=this.context.data.high.slice().reverse(),n=this.context.data.low.slice().reverse(),u=this.context.data.close.slice().reverse(),[p,h]=vr(a,n,u,r,s),c=this.context.idx;return[[this.context.precision(p[c]),h[c]]]}}function Kt(e,t,i,r){const s=new Array(e.length);s[0]=e[0]-t[0];for(let u=1;u<e.length;u++){const p=e[u]-t[u],h=Math.abs(e[u]-i[u-1]),c=Math.abs(t[u]-i[u-1]);s[u]=Math.max(p,h,c)}const a=new Array(e.length).fill(NaN);let n=0;for(let u=0;u<r;u++)n+=s[u];a[r-1]=n/r;for(let u=r;u<s.length;u++)a[u]=(a[u-1]*(r-1)+s[u])/r;return a}function ar(e,t){const i=new Array(e.length).fill(NaN),r=2/(t+1);let s=0;for(let a=0;a<t;a++)s+=e[a]||0;i[t-1]=s/t;for(let a=t;a<e.length;a++)i[a]=e[a]*r+i[a-1]*(1-r);return i}function nr(e,t){const i=new Array(e.length).fill(NaN),r=new Array(e.length).fill(0),s=new Array(e.length).fill(0);for(let u=1;u<e.length;u++){const p=e[u]-e[u-1];r[u]=p>0?p:0,s[u]=p<0?-p:0}let a=0,n=0;for(let u=1;u<=t;u++)a+=r[u],n+=s[u];a/=t,n/=t,i[t]=n===0?100:100-100/(1+a/n);for(let u=t+1;u<e.length;u++)a=(a*(t-1)+r[u])/t,n=(n*(t-1)+s[u])/t,i[u]=n===0?100:100-100/(1+a/n);return i}function or(e,t){const i=new Array(e.length).fill(NaN),r=1/t;let s=0;for(let a=0;a<t;a++)s+=e[a]||0;i[t-1]=s/t;for(let a=t;a<e.length;a++){const n=e[a]||0;i[a]=n*r+i[a-1]*(1-r)}return i}function ze(e,t){const i=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){let s=0;for(let a=0;a<t;a++)s+=e[r-a]||0;i[r]=s/t}return i}function ur(e,t,i){const r=new Array(e.length).fill(NaN);for(let s=i-1;s<e.length;s++){let a=0,n=0;for(let u=0;u<i;u++)a+=t[s-u],n+=e[s-u]*t[s-u];r[s]=n/a}return r}function pr(e,t){const i=Math.floor(t/2),r=de(e,i),s=de(e,t),a=r.map((u,p)=>2*u-s[p]),n=Math.floor(Math.sqrt(t));return de(a,n)}function de(e,t){const i=new Array(e.length);for(let r=t-1;r<e.length;r++){let s=0,a=0;for(let n=0;n<t;n++)s+=e[r-n]*(t-n),a+=t-n;i[r]=s/a}for(let r=0;r<t-1;r++)i[r]=NaN;return i}function hr(e,t=1){const i=new Array(e.length).fill(NaN);for(let r=t;r<e.length;r++)i[r]=e[r]-e[r-t];return i}function cr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t;r<e.length;r++)i[r]=e[r]-e[r-t];return i}function lr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t;r<e.length;r++)i[r]=(e[r]-e[r-t])/e[r-t]*100;return i}function fr(e,t){const i=new Array(e.length).fill(NaN),r=ze(e,t);for(let s=t-1;s<e.length;s++){let a=0;for(let n=0;n<t;n++)a+=Math.abs(e[s-n]-r[s]);i[s]=a/t}return i}function mr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){let s=0,a=0;for(let u=0;u<t;u++)s+=e[r-u],a+=e[r-u]*e[r-u];const n=s/t;i[r]=a/t-n*n}return i}function dr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){let s=-1/0;for(let a=0;a<t;a++){const n=e[r-a];isNaN(n)?s=s===-1/0?NaN:s:s=Math.max(s,n)}i[r]=s}return i}function xr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){let s=1/0;for(let a=0;a<t;a++){const n=e[r-a];isNaN(n)?s=s===1/0?NaN:s:s=Math.min(s,n)}i[r]=s}return i}function yr(e,t){const i=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){const s=e.slice(r-t+1,r+1).slice().sort((n,u)=>n-u),a=Math.floor(t/2);i[r]=t%2===0?(s[a-1]+s[a])/2:s[a]}return i}function br(e,t,i=!0){const r=new Array(e.length).fill(NaN),s=ze(e,t);for(let a=t-1;a<e.length;a++){let n=0;for(let p=0;p<t;p++)n+=Math.pow(e[a-p]-s[a],2);const u=i?t:t-1;r[a]=Math.sqrt(n/u)}return r}function gr(e,t,i){const r=e.length,s=new Array(r).fill(NaN);for(let a=t-1;a<r;a++){let n=0,u=0,p=0,h=0;const c=t;for(let E=0;E<t;E++){const x=E,I=e[a-t+1+E];n+=x,u+=I,p+=x*I,h+=x*x}const y=c*h-n*n;if(y===0){s[a]=NaN;continue}const l=(c*p-n*u)/y,g=(u-l*n)/c+l*(t-1-i);s[a]=g}return s}function vr(e,t,i,r,s){const a=e.length,n=new Array(a).fill(NaN),u=new Array(a).fill(0),p=Kt(e,t,i,s),h=new Array(a).fill(NaN),c=new Array(a).fill(NaN);for(let x=0;x<a;x++){const I=(e[x]+t[x])/2,P=p[x];isNaN(P)||(h[x]=I+r*P,c[x]=I-r*P)}let y=h[s],l=c[s],g=i[s]<=y?y:l,E=i[s]<=y?-1:1;n[s]=g,u[s]=E;for(let x=s+1;x<a;x++){let I=h[x];I<y||i[x-1]>y?h[x]=I:h[x]=y;let P=c[x];P>l||i[x-1]<l?c[x]=P:c[x]=l,g===y?i[x]>h[x]?(u[x]=1,n[x]=c[x]):(u[x]=-1,n[x]=h[x]):i[x]<c[x]?(u[x]=-1,n[x]=h[x]):(u[x]=1,n[x]=c[x]),y=h[x],l=c[x],g=n[x]}return[n,u]}class Qt{constructor(t){this.marketData=t,this.math=new ir(this),this.ta=new sr(this),this.input=new tr(this),this.request=new rr(this);const i=new er(this);this.core={plotchar:i.plotchar.bind(i),na:i.na.bind(i),color:i.color,plot:i.plot.bind(i),nz:i.nz.bind(i)}}data={open:[],high:[],low:[],close:[],volume:[],hl2:[],hlc3:[],ohlc4:[]};math;ta;input;request;core;idx=0;params={};const={};var={};let={};result=void 0;plots={};timeframe="";init(t,i,r=0){return t?!Array.isArray(i)||Array.isArray(i[0])?t[0]=Array.isArray(i?.[0])?i[0]:this.precision(i):t[0]=this.precision(i[i.length-this.idx-1+r]):Array.isArray(i)?t=[this.precision(i[i.length-this.idx-1+r])]:t=[this.precision(i)],t}precision(t,i=10){return typeof t!="number"||isNaN(t)?t:Number(t.toFixed(i))}param(t,i,r){return typeof t=="string"||!Array.isArray(t)&&typeof t=="object"?t:(this.params[r]||(this.params[r]=[]),Array.isArray(t)?i?(this.params[r]=t.slice(i),this.params[r]):(this.params[r]=t.slice(0),this.params[r]):(this.params[r][0]=t,this.params[r]))}}const wr="https://api.binance.com/api/v3",Er={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class Cr{async getMarketData(t,i,r,s,a){try{const n=Er[i.toUpperCase()];if(!n)return console.error(`Unsupported timeframe: ${i}`),[];let u=`${wr}/klines?symbol=${t}&interval=${n}`;r&&(u+=`&limit=${r}`),s&&(u+=`&startTime=${s}`),a&&(u+=`&endTime=${a}`);const p=await fetch(u);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return(await p.json()).map(h=>({openTime:parseInt(h[0])/1e3,open:parseFloat(h[1]),high:parseFloat(h[2]),low:parseFloat(h[3]),close:parseFloat(h[4]),volume:parseFloat(h[5]),closeTime:parseInt(h[6])/1e3,quoteAssetVolume:parseFloat(h[7]),numberOfTrades:parseInt(h[8]),takerBuyBaseAssetVolume:parseFloat(h[9]),takerBuyQuoteAssetVolume:parseFloat(h[10]),ignore:h[11]}))}catch(n){return console.error("Error in binance.klines:",n),[]}}}const Sr={Binance:new Cr};exports.Context=Qt;exports.PineTS=$i;exports.Provider=Sr;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2025 Alaa-eddine KADDOURI
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import*as z from"acorn";import*as x from"acorn-walk";import*as K from"astring";var U=Object.defineProperty,H=(r,e,t)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,E=(r,e,t)=>H(r,typeof e!="symbol"?e+"":e,t);class Q{constructor(){E(this,"scopes",[]),E(this,"scopeTypes",[]),E(this,"scopeCounts",new Map),E(this,"contextBoundVars",new Set),E(this,"arrayPatternElements",new Set),E(this,"rootParams",new Set),E(this,"varKinds",new Map),E(this,"loopVars",new Set),E(this,"loopVarNames",new Map),E(this,"paramIdCounter",0),E(this,"tempVarCounter",0),this.pushScope("glb")}get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}pushScope(e){this.scopes.push(new Map),this.scopeTypes.push(e),this.scopeCounts.set(e,(this.scopeCounts.get(e)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addContextBoundVar(e,t=!1){this.contextBoundVars.add(e),t&&this.rootParams.add(e)}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,t){this.loopVars.add(e),this.loopVarNames.set(e,t)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addVariable(e,t){if(this.isContextBound(e))return e;const n=this.scopes[this.scopes.length-1],i=this.scopeTypes[this.scopeTypes.length-1],o=this.scopeCounts.get(i)||1,a=`${i}${o}_${e}`;return n.set(e,a),this.varKinds.set(a,t),a}getVariable(e){if(this.loopVars.has(e)){const t=this.loopVarNames.get(e);if(t)return[t,"let"]}if(this.isContextBound(e))return[e,"let"];for(let t=this.scopes.length-1;t>=0;t--){const n=this.scopes[t];if(n.has(e)){const i=n.get(e),o=this.varKinds.get(i)||"let";return[i,o]}}return[e,"let"]}generateTempVar(){return`temp_${++this.tempVarCounter}`}}//!!!Warning!!! this code is not clean, it was initially written as a PoC then used as transpiler for PineTS
|
|
19
|
+
const f="$",P={type:"Identifier",name:"undefined"};function C(r,e){if(r.computed&&r.property.type==="Identifier"){if(e.isLoopVariable(r.property.name))return;if(!e.isContextBound(r.property.name)){const[t,n]=e.getVariable(r.property.name);r.property={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:n},computed:!1},property:{type:"Identifier",name:t},computed:!1},r.property={type:"MemberExpression",object:r.property,property:{type:"Literal",value:0},computed:!0}}}if(r.computed&&r.object.type==="Identifier"){if(e.isLoopVariable(r.object.name))return;if(!e.isContextBound(r.object.name)){const[t,n]=e.getVariable(r.object.name);r.object={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:n},computed:!1},property:{type:"Identifier",name:t},computed:!1}}if(r.property.type==="MemberExpression"){const t=r.property;t._indexTransformed||(C(t,e),t._indexTransformed=!0)}}}function j(r,e,t){if(r.object&&r.object.type==="Identifier"&&r.object.name==="Math")return;const n=t.getCurrentScopeType()=="if",i=t.getCurrentScopeType()=="els",o=t.getCurrentScopeType()=="for";!n&&!i&&!o&&r.object&&r.object.type==="Identifier"&&t.isContextBound(r.object.name)&&!t.isRootParam(r.object.name)||r._indexTransformed||(C(r,t),r._indexTransformed=!0)}function B(r,e){r.declarations.forEach(t=>{const n=t.init&&t.init.type==="MemberExpression"&&t.init.object&&(t.init.object.name==="context"||t.init.object.name===f||t.init.object.name==="context2"),i=t.init&&t.init.type==="MemberExpression"&&t.init.object?.object&&(t.init.object.object.name==="context"||t.init.object.object.name===f||t.init.object.object.name==="context2"),o=t.init&&t.init.type==="ArrowFunctionExpression";if(n){t.id.name&&e.addContextBoundVar(t.id.name),t.id.properties&&t.id.properties.forEach(p=>{p.key.name&&e.addContextBoundVar(p.key.name)}),t.init.object.name=f;return}if(i){t.id.name&&e.addContextBoundVar(t.id.name),t.id.properties&&t.id.properties.forEach(p=>{p.key.name&&e.addContextBoundVar(p.key.name)}),t.init.object.object.name=f;return}o&&t.init.params.forEach(p=>{p.type==="Identifier"&&e.addContextBoundVar(p.name)});const a=e.addVariable(t.id.name,r.kind),s=r.kind;t.init&&!o&&(t.init.type==="CallExpression"&&t.init.callee.type==="MemberExpression"&&t.init.callee.object&&t.init.callee.object.type==="Identifier"&&e.isContextBound(t.init.callee.object.name)?M(t.init,e):x.recursive(t.init,{parent:t.init},{Identifier(p,u){p.parent=u.parent,v(p,e);const b=p.parent&&p.parent.type==="BinaryExpression",l=p.parent&&p.parent.type==="ConditionalExpression";p.type==="Identifier"&&(b||l)&&Object.assign(p,{type:"MemberExpression",object:{type:"Identifier",name:p.name},property:{type:"Literal",value:0},computed:!0})},CallExpression(p,u,b){p.callee.type==="Identifier"&&(p.callee.parent=p),p.arguments.forEach(l=>{l.type==="Identifier"&&(l.parent=p)}),M(p,e),p.arguments.forEach(l=>b(l,{parent:p}))},BinaryExpression(p,u,b){p.left.type==="Identifier"&&(p.left.parent=p),p.right.type==="Identifier"&&(p.right.parent=p),b(p.left,{parent:p}),b(p.right,{parent:p})},MemberExpression(p,u,b){p.object.type==="Identifier"&&(p.object.parent=p),p.property.type==="Identifier"&&(p.property.parent=p),C(p,e),p.object&&b(p.object,{parent:p})}}));const m={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:s},computed:!1},property:{type:"Identifier",name:a},computed:!1},c=e.isArrayPatternElement(t.id.name),y=!c&&t.init&&t.init.type==="MemberExpression"&&t.init.computed&&t.init.property&&(t.init.property.type==="Literal"||t.init.property.type==="MemberExpression");t.init?.property?.type==="MemberExpression"&&(t.init.property._indexTransformed||(C(t.init.property,e),t.init.property._indexTransformed=!0));const h={type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:m,right:t.init?o||c?t.init:{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:"init"},computed:!1},arguments:y?[m,t.init.object,t.init.property]:[m,t.init]}:{type:"Identifier",name:"undefined"}}};c&&(h.expression.right.object.property.name+="?.[0]"),o&&(e.pushScope("fn"),x.recursive(t.init.body,e,{BlockStatement(p,u,b){p.body.forEach(l=>b(l,u))},IfStatement(p,u,b){u.pushScope("if"),b(p.consequent,u),p.alternate&&(u.pushScope("els"),b(p.alternate,u),u.popScope()),u.popScope()},VariableDeclaration(p,u){B(p,u)},Identifier(p,u){v(p,u)},AssignmentExpression(p,u){T(p,u)}}),e.popScope()),Object.assign(r,h)})}function v(r,e){if(r.name!==f){if(r.name==="Math"||r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name.startsWith("'")&&r.name.endsWith("'")||r.name.startsWith('"')&&r.name.endsWith('"')||r.name.startsWith("`")&&r.name.endsWith("`")||e.isLoopVariable(r.name)||e.isContextBound(r.name)&&!e.isRootParam(r.name))return;const t=r.parent&&r.parent.type==="MemberExpression"&&r.parent.object===r&&e.isContextBound(r.name),n=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.type==="MemberExpression"&&r.parent.callee.property.name==="param";r.parent&&r.parent.type==="AssignmentExpression"&&r.parent.left;const i=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.type==="MemberExpression"&&e.isContextBound(r.parent.callee.object.name),o=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed,a=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.property===r&&r.parent.parent&&r.parent.parent.type==="CallExpression"&&r.parent.parent.callee&&r.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(r.parent.parent.callee.object.name),s=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee===r;if(t||n||i||a||s){if(s)return;const[h,p]=e.getVariable(r.name);Object.assign(r,{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:p},computed:!1},property:{type:"Identifier",name:h},computed:!1});return}const[m,c]=e.getVariable(r.name),y={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:c},computed:!1},property:{type:"Identifier",name:m},computed:!1};!(r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r)&&!o?Object.assign(r,{type:"MemberExpression",object:y,property:{type:"Literal",value:0},computed:!0}):Object.assign(r,y)}}function T(r,e){if(r.left.type==="Identifier"){const[t,n]=e.getVariable(r.left.name),i={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:n},computed:!1},property:{type:"Identifier",name:t},computed:!1};r.left={type:"MemberExpression",object:i,property:{type:"Literal",value:0},computed:!0}}x.recursive(r.right,{parent:r.right,inNamespaceCall:!1},{Identifier(t,n,i){t.parent=n.parent,v(t,e);const o=t.parent&&t.parent.type==="BinaryExpression";(t.parent&&t.parent.type==="ConditionalExpression"||o)&&(t.type==="MemberExpression"?C(t,e):t.type==="Identifier"&&S(t))},MemberExpression(t,n,i){C(t,e),t.object&&i(t.object,{parent:t,inNamespaceCall:n.inNamespaceCall})},CallExpression(t,n,i){const o=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&e.isContextBound(t.callee.object.name);M(t,e),t.arguments.forEach(a=>i(a,{parent:t,inNamespaceCall:o||n.inNamespaceCall}))}})}function X(r,e,t=!1){r.params.forEach(n=>{n.type==="Identifier"&&e.addContextBoundVar(n.name,t)})}function D(r,e){const t=e.getCurrentScopeType();if(r.argument){if(r.argument.type==="ArrayExpression")r.argument.elements=r.argument.elements.map(n=>{if(n.type==="Identifier"){if(e.isContextBound(n.name)&&!e.isRootParam(n.name))return{type:"MemberExpression",object:n,property:{type:"Literal",value:0},computed:!0};const[i,o]=e.getVariable(n.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:o},computed:!1},property:{type:"Identifier",name:i},computed:!1},property:{type:"Literal",value:0},computed:!0}}else if(n.type==="MemberExpression")return n.computed&&n.object.type==="Identifier"&&e.isContextBound(n.object.name)&&!e.isRootParam(n.object.name)||j(n,"",e),n;return n}),r.argument={type:"ArrayExpression",elements:[r.argument]};else if(r.argument.type==="BinaryExpression")x.recursive(r.argument,e,{Identifier(n,i){v(n,i),n.type==="Identifier"&&S(n)},MemberExpression(n){j(n,"",e)}});else if(r.argument.type==="ObjectExpression")r.argument.properties=r.argument.properties.map(n=>{if(n.shorthand){const[i,o]=e.getVariable(n.value.name);return{type:"Property",key:{type:"Identifier",name:n.key.name},value:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:o},computed:!1},property:{type:"Identifier",name:i},computed:!1},kind:"init",method:!1,shorthand:!1,computed:!1}}return n});else if(r.argument.type==="Identifier"){const[n,i]=e.getVariable(r.argument.name);r.argument={type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:i},computed:!1},property:{type:"Identifier",name:n},computed:!1},r.argument={type:"MemberExpression",object:r.argument,property:{type:"Literal",value:0},computed:!0}}t==="fn"&&(r.argument={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:"precision"}},arguments:[r.argument]})}}function N(r,e){if(r.type==="Identifier"){if(e.isLoopVariable(r.name))return r;if(e.isRootParam(r.name)){const[i,o]=e.getVariable(r.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:o},computed:!1},property:{type:"Identifier",name:i},computed:!1}}if(e.isContextBound(r.name))return r;const[t,n]=e.getVariable(r.name);return{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:n},computed:!1},property:{type:"Identifier",name:t},computed:!1}}return r}function _(r,e,t=""){return r.type==="BinaryExpression"?L(r,e,t):r.type==="MemberExpression"?{type:"MemberExpression",object:r.object.type==="Identifier"?N(r.object,e):r.object,property:r.property,computed:r.computed}:r.type==="Identifier"?e.isLoopVariable(r.name)||r.parent&&r.parent.type==="MemberExpression"&&r.parent.property===r?r:{type:"MemberExpression",object:N(r,e),property:{type:"Literal",value:0},computed:!0}:r}function L(r,e,t){const n=_(r.left,e,t),i=_(r.right,e,t),o={type:"BinaryExpression",operator:r.operator,left:n,right:i,start:r.start,end:r.end};return x.recursive(o,e,{CallExpression(a,s){a._transformed||M(a,s)},MemberExpression(a){j(a,"",e)}}),{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:t},property:{type:"Identifier",name:"param"},computed:!1},arguments:[o,P,e.nextParamIdArg],_transformed:!0,_isParamCall:!0}}function $(r,e,t){if(r.type==="BinaryExpression")return L(r,t,e);if(r.type==="MemberExpression"&&r.computed&&r.property){const n=r.object.type==="Identifier"&&t.isContextBound(r.object.name)&&!t.isRootParam(r.object.name)?r.object:N(r.object,t),i=r.property.type==="Identifier"&&!t.isContextBound(r.property.name)&&!t.isLoopVariable(r.property.name)?N(r.property,t):r.property;return{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:e},property:{type:"Identifier",name:"param"},computed:!1},arguments:[n,i,t.nextParamIdArg],_transformed:!0,_isParamCall:!0}}return r.type==="ObjectExpression"&&(r.properties=r.properties.map(n=>{if(n.value.name){const[i,o]=t.getVariable(n.value.name);return{type:"Property",key:{type:"Identifier",name:n.key.name},value:{type:"MemberExpression",object:{type:"MemberExpression",object:{type:"Identifier",name:f},property:{type:"Identifier",name:o},computed:!1},property:{type:"Identifier",name:i},computed:!1},kind:"init",method:!1,shorthand:!1,computed:!1}}return n})),r.type==="Identifier"&&t.isContextBound(r.name)&&!t.isRootParam(r.name)?{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:e},property:{type:"Identifier",name:"param"},computed:!1},arguments:[r,P,t.nextParamIdArg],_transformed:!0,_isParamCall:!0}:(r?.type==="CallExpression"&&M(r,t),{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:e},property:{type:"Identifier",name:"param"},computed:!1},arguments:[r.type==="Identifier"?N(r,t):r,P,t.nextParamIdArg],_transformed:!0,_isParamCall:!0})}function M(r,e){if(!r._transformed){if(r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&(e.isContextBound(r.callee.object.name)||r.callee.object.name==="math"||r.callee.object.name==="ta")){const t=r.callee.object.name;r.arguments=r.arguments.map(n=>n._isParamCall?n:$(n,t,e)),r._transformed=!0}else r.callee&&r.callee.type==="Identifier"&&(r.arguments=r.arguments.map(t=>t._isParamCall?t:$(t,f,e)),r._transformed=!0);r.arguments.forEach(t=>{x.recursive(t,e,{CallExpression(n,i){n._transformed||M(n,i)},MemberExpression(n){j(n,"",e)}})})}}function Y(r,e){r.params.forEach(t=>{t.type==="Identifier"&&e.addContextBoundVar(t.name,!1)}),r.body&&r.body.type==="BlockStatement"&&(e.pushScope("fn"),x.recursive(r.body,e,{BlockStatement(t,n,i){t.body.forEach(o=>i(o,n))},ReturnStatement(t,n){D(t,n)},VariableDeclaration(t,n){B(t,n)},Identifier(t,n){v(t,n)},CallExpression(t,n){M(t,n),t.arguments.forEach(i=>{i.type==="BinaryExpression"&&x.recursive(i,n,{CallExpression(o,a){M(o,a)},MemberExpression(o){j(o,"",n)}})})},MemberExpression(t){j(t,"",e)},AssignmentExpression(t,n){T(t,n)},ForStatement(t,n,i){O(t,n,i)},IfStatement(t,n,i){F(t,n,i)},BinaryExpression(t,n,i){x.recursive(t,n,{CallExpression(o,a){M(o,a)},MemberExpression(o){j(o,"",n)}})}}),e.popScope())}function S(r,e){Object.assign(r,{type:"MemberExpression",object:{type:"Identifier",name:r.name,start:r.start,end:r.end},property:{type:"Literal",value:0},computed:!0,_indexTransformed:!0})}function O(r,e,t){if(r.init&&r.init.type==="VariableDeclaration"){const n=r.init.declarations[0],i=n.id.name;e.addLoopVariable(i,i),r.init={type:"VariableDeclaration",kind:r.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:i},init:n.init}]},n.init&&x.recursive(n.init,e,{Identifier(o,a){e.isLoopVariable(o.name)||(e.pushScope("for"),v(o,a),e.popScope())},MemberExpression(o){e.pushScope("for"),j(o,"",e),e.popScope()}})}r.test&&x.recursive(r.test,e,{Identifier(n,i){!e.isLoopVariable(n.name)&&!n.computed&&(e.pushScope("for"),v(n,i),n.type==="Identifier"&&(n.computed=!0,S(n)),e.popScope())},MemberExpression(n){e.pushScope("for"),j(n,"",e),e.popScope()}}),r.update&&x.recursive(r.update,e,{Identifier(n,i){e.isLoopVariable(n.name)||(e.pushScope("for"),v(n,i),e.popScope())}}),e.pushScope("for"),t(r.body,e),e.popScope()}function G(r,e){x.recursive(r,e,{MemberExpression(t){j(t,"",e)},CallExpression(t,n){M(t,n)},Identifier(t,n){v(t,n);const i=e.getCurrentScopeType()==="if";e.isContextBound(t.name)&&!e.isRootParam(t.name)&&i&&S(t)}})}function F(r,e,t){r.test&&(e.pushScope("if"),G(r.test,e),e.popScope()),e.pushScope("if"),t(r.consequent,e),e.popScope(),r.alternate&&(e.pushScope("els"),t(r.alternate,e),e.popScope())}function J(r){x.recursive(r,null,{VariableDeclaration(e,t,n){e.declarations&&e.declarations.length>0&&e.declarations.forEach(i=>{if(i.init&&i.init.type==="ArrowFunctionExpression"&&i.init.start!==0){const o={type:"FunctionDeclaration",id:i.id,params:i.init.params,body:i.init.body.type==="BlockStatement"?i.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:i.init.body}]},async:i.init.async,generator:!1};Object.assign(e,o)}}),e.body&&e.body.body&&e.body.body.forEach(i=>n(i,t))}})}function Z(r,e){x.simple(r,{VariableDeclaration(t){t.declarations.forEach(n=>{const i=n.init&&n.init.type==="MemberExpression"&&n.init.object&&(n.init.object.name==="context"||n.init.object.name===f||n.init.object.name==="context2"),o=n.init&&n.init.type==="MemberExpression"&&n.init.object?.object&&(n.init.object.object.name==="context"||n.init.object.object.name===f||n.init.object.object.name==="context2");(i||o)&&(n.id.name&&e.addContextBoundVar(n.id.name),n.id.properties&&n.id.properties.forEach(a=>{a.key.name&&e.addContextBoundVar(a.key.name)}))})}})}function ee(r){let e=typeof r=="function"?r.toString():r;const t=z.parse(e.trim(),{ecmaVersion:"latest",sourceType:"module"});J(t);const n=new Q;let i;Z(t,n),x.simple(t,{FunctionDeclaration(a){Y(a,n)},ArrowFunctionExpression(a){const s=a.start===0;s&&a.params&&a.params.length>0&&(i=a.params[0].name,a.params[0].name=f),X(a,n,s)},VariableDeclaration(a){a.declarations.forEach(s=>{if(s.id.type==="ArrayPattern"){const m=n.generateTempVar(),c={type:"VariableDeclaration",kind:a.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:m},init:s.init}]};s.id.elements?.forEach(h=>{h.type==="Identifier"&&n.addArrayPatternElement(h.name)});const y=s.id.elements.map((h,p)=>({type:"VariableDeclaration",kind:a.kind,declarations:[{type:"VariableDeclarator",id:h,init:{type:"MemberExpression",object:{type:"Identifier",name:m},property:{type:"Literal",value:p},computed:!0}}]}));Object.assign(a,{type:"BlockStatement",body:[c,...y]})}})},ForStatement(a){}}),x.recursive(t,n,{BlockStatement(a,s,m){a.body.forEach(c=>m(c,s))},ReturnStatement(a,s){D(a,s)},VariableDeclaration(a,s){B(a,s)},Identifier(a,s){v(a,s)},CallExpression(a,s){M(a,s)},MemberExpression(a){j(a,i,n)},AssignmentExpression(a,s){T(a,s)},FunctionDeclaration(a,s){},ForStatement(a,s,m){O(a,s,m)},IfStatement(a,s,m){F(a,s,m)}});const o=K.generate(t);return new Function("",`return ${o}`)(this)}var te=Object.defineProperty,re=(r,e,t)=>e in r?te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,g=(r,e,t)=>re(r,typeof e!="symbol"?e+"":e,t);class Oe{constructor(e,t,n,i,o,a){this.source=e,this.tickerId=t,this.timeframe=n,this.limit=i,this.sDate=o,this.eDate=a,g(this,"data",[]),g(this,"open",[]),g(this,"high",[]),g(this,"low",[]),g(this,"close",[]),g(this,"volume",[]),g(this,"hl2",[]),g(this,"hlc3",[]),g(this,"ohlc4",[]),g(this,"openTime",[]),g(this,"closeTime",[]),g(this,"_periods"),g(this,"_readyPromise",null),g(this,"_ready",!1),this._readyPromise=new Promise(s=>{this.loadMarketData(e,t,n,i,o,a).then(m=>{const c=m.reverse();this._periods=c.length,this.data=c;const y=c.map(d=>d.open),h=c.map(d=>d.close),p=c.map(d=>d.high),u=c.map(d=>d.low),b=c.map(d=>d.volume),l=c.map(d=>(d.high+d.low+d.close)/3),I=c.map(d=>(d.high+d.low)/2),w=c.map(d=>(d.high+d.low+d.open+d.close)/4),q=c.map(d=>d.openTime),W=c.map(d=>d.closeTime);this.open=y,this.close=h,this.high=p,this.low=u,this.volume=b,this.hl2=I,this.hlc3=l,this.ohlc4=w,this.openTime=q,this.closeTime=W,this._ready=!0,s(!0)})})}get periods(){return this._periods}async loadMarketData(e,t,n,i,o,a){return Array.isArray(e)?e:e.getMarketData(t,n,i,o,a)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}async run(e,t){await this.ready(),t||(t=this._periods);const n=new _e(this.data);n.timeframe=this.timeframe;let i=ee.bind(this)(e);const o=["const","var","let","params"];for(let a=this._periods-t,s=t-1;a<this._periods;a++,s--){n.idx=a,n.data.close=this.close.slice(s),n.data.open=this.open.slice(s),n.data.high=this.high.slice(s),n.data.low=this.low.slice(s),n.data.volume=this.volume.slice(s),n.data.hl2=this.hl2.slice(s),n.data.hlc3=this.hlc3.slice(s),n.data.ohlc4=this.ohlc4.slice(s),n.data.openTime=this.openTime.slice(s),n.data.closeTime=this.closeTime.slice(s);const m=await i(n);if(typeof m=="object"){typeof n.result!="object"&&(n.result={});for(let c in m){n.result[c]===void 0&&(n.result[c]=[]);const y=Array.isArray(m[c])?m[c][0]:m[c];n.result[c].push(y)}}else Array.isArray(n.result)||(n.result=[]),n.result.push(m);for(let c of o)for(let y in n[c])if(Array.isArray(n[c][y])){const h=n[c][y][0];n[c][y].unshift(h)}}return n}}var ne=Object.defineProperty,ie=(r,e,t)=>e in r?ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oe=(r,e,t)=>ie(r,typeof e!="symbol"?e+"":e,t);class ae{constructor(e){this.context=e,oe(this,"color",{white:"white",lime:"lime",green:"green",red:"red",maroon:"maroon",black:"black",gray:"gray",blue:"blue"})}extractPlotOptions(e){const t={};for(let n in e)Array.isArray(e[n])?t[n]=e[n][0]:t[n]=e[n];return t}indicator(e,t,n){}plotchar(e,t,n){this.context.plots[t]||(this.context.plots[t]={data:[],options:this.extractPlotOptions(n),title:t}),this.context.plots[t].data.push({time:this.context.marketData[this.context.marketData.length-this.context.idx-1].openTime,value:e[0],options:this.extractPlotOptions(n)})}plot(e,t,n){this.context.plots[t]||(this.context.plots[t]={data:[],options:this.extractPlotOptions(n),title:t}),this.context.plots[t].data.push({time:this.context.marketData[this.context.marketData.length-this.context.idx-1].openTime,value:e[0],options:this.extractPlotOptions(n)})}na(e){return Array.isArray(e)?isNaN(e[0]):isNaN(e)}nz(e,t=0){return Array.isArray(e)?isNaN(e[0])?t:e[0]:isNaN(e)?t:e}}class se{constructor(e){this.context=e}param(e,t=0){return Array.isArray(e)?[e[t]]:[e]}any(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}int(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}float(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}bool(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}string(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}timeframe(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}time(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}price(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}session(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}source(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}symbol(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}text_area(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}enum(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}color(e,{title:t,group:n}={}){return Array.isArray(e)?e[0]:e}}var pe=Object.defineProperty,ce=(r,e,t)=>e in r?pe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,le=(r,e,t)=>ce(r,typeof e!="symbol"?e+"":e,t);class me{constructor(e){this.context=e,le(this,"_cache",{})}param(e,t=0){return Array.isArray(e)?e[t]:e}abs(e){return Math.abs(e)}pow(e,t){return Math.pow(e,t)}sqrt(e){return Math.sqrt(e)}log(e){return Math.log(e)}ln(e){return Math.log(e)}exp(e){return Math.exp(e)}floor(e){return Math.floor(e)}ceil(e){return Math.ceil(e)}round(e){return Math.round(e)}random(){return Math.random()}max(...e){return Math.max(...e)}min(...e){return Math.min(...e)}sin(e){return Math.sin(e)}cos(e){return Math.cos(e)}tan(e){return Math.tan(e)}asin(e){return Math.asin(e)}acos(e){return Math.acos(e)}atan(e){return Math.atan(e)}avg(...e){return e.reduce((t,n)=>{const i=Array.isArray(t)?t[0]:t,o=Array.isArray(n)?n[0]:n;return i+o},0)/e.length}}var ye=Object.defineProperty,ue=(r,e,t)=>e in r?ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,he=(r,e,t)=>ue(r,typeof e!="symbol"?e+"":e,t);class de{constructor(e){this.context=e,he(this,"_cache",{})}param(e,t,n){return this.context.params[n]||(this.context.params[n]=[]),Array.isArray(e)?(t?this.context.params[n]=e.slice(t):this.context.params[n]=e.slice(0),[e[t],n]):(this.context.params[n][0]=e,[e,n])}async security(e,t,n){throw new Error("Not implemented")}}class fe{constructor(e){this.context=e}get tr(){return this.context.math.max(this.context.data.high[0]-this.context.data.low[0],this.context.math.abs(this.context.data.high[0]-this.context.data.close[1]),this.context.math.abs(this.context.data.low[0]-this.context.data.close[1]))}param(e,t,n){return this.context.params[n]||(this.context.params[n]=[]),Array.isArray(e)?t?(this.context.params[n]=e.slice(t),this.context.params[n]):(this.context.params[n]=e.slice(0),this.context.params[n]):(this.context.params[n][0]=e,this.context.params[n])}ema(e,t){const n=Array.isArray(t)?t[0]:t,i=be(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}sma(e,t){const n=Array.isArray(t)?t[0]:t,i=k(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}vwma(e,t){const n=Array.isArray(t)?t[0]:t,i=this.context.data.volume,o=Ae(e.slice(0).reverse(),i.slice(0).reverse(),n),a=this.context.idx;return this.context.precision(o[a])}wma(e,t){const n=Array.isArray(t)?t[0]:t,i=V(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}hma(e,t){const n=Array.isArray(t)?t[0]:t,i=Ee(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}rma(e,t){const n=Array.isArray(t)?t[0]:t,i=ge(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}change(e,t=1){const n=Array.isArray(t)?t[0]:t,i=je(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}rsi(e,t){const n=Array.isArray(t)?t[0]:t,i=xe(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}atr(e){const t=Array.isArray(e)?e[0]:e,n=this.context.data.high.slice().reverse(),i=this.context.data.low.slice().reverse(),o=this.context.data.close.slice().reverse(),a=R(n,i,o,t),s=this.context.idx;return this.context.precision(a[s])}mom(e,t){const n=Array.isArray(t)?t[0]:t,i=Me(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}roc(e,t){const n=Array.isArray(t)?t[0]:t,i=Ie(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}dev(e,t){const n=Array.isArray(t)?t[0]:t,i=ve(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}variance(e,t){const n=Array.isArray(t)?t[0]:t,i=we(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}highest(e,t){const n=Array.isArray(t)?t[0]:t,i=Ce(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}lowest(e,t){const n=Array.isArray(t)?t[0]:t,i=Ne(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}median(e,t){const n=Array.isArray(t)?t[0]:t,i=Ve(e.slice(0).reverse(),n),o=this.context.idx;return this.context.precision(i[o])}stdev(e,t,n=!0){const i=Array.isArray(t)?t[0]:t,o=Array.isArray(n)?n[0]:n,a=Se(e.slice(0).reverse(),i,o),s=this.context.idx;return this.context.precision(a[s])}linreg(e,t,n){const i=Array.isArray(t)?t[0]:t,o=Array.isArray(n)?n[0]:n,a=Pe(e.slice(0).reverse(),i,o),s=this.context.idx;return this.context.precision(a[s])}supertrend(e,t){const n=Array.isArray(e)?e[0]:e,i=Array.isArray(t)?t[0]:t,o=this.context.data.high.slice().reverse(),a=this.context.data.low.slice().reverse(),s=this.context.data.close.slice().reverse(),[m,c]=Be(o,a,s,n,i),y=this.context.idx;return[[this.context.precision(m[y]),c[y]]]}}function R(r,e,t,n){const i=new Array(r.length);i[0]=r[0]-e[0];for(let s=1;s<r.length;s++){const m=r[s]-e[s],c=Math.abs(r[s]-t[s-1]),y=Math.abs(e[s]-t[s-1]);i[s]=Math.max(m,c,y)}const o=new Array(r.length).fill(NaN);let a=0;for(let s=0;s<n;s++)a+=i[s];o[n-1]=a/n;for(let s=n;s<i.length;s++)o[s]=(o[s-1]*(n-1)+i[s])/n;return o}function be(r,e){const t=new Array(r.length).fill(NaN),n=2/(e+1);let i=0;for(let o=0;o<e;o++)i+=r[o]||0;t[e-1]=i/e;for(let o=e;o<r.length;o++)t[o]=r[o]*n+t[o-1]*(1-n);return t}function xe(r,e){const t=new Array(r.length).fill(NaN),n=new Array(r.length).fill(0),i=new Array(r.length).fill(0);for(let s=1;s<r.length;s++){const m=r[s]-r[s-1];n[s]=m>0?m:0,i[s]=m<0?-m:0}let o=0,a=0;for(let s=1;s<=e;s++)o+=n[s],a+=i[s];o/=e,a/=e,t[e]=a===0?100:100-100/(1+o/a);for(let s=e+1;s<r.length;s++)o=(o*(e-1)+n[s])/e,a=(a*(e-1)+i[s])/e,t[s]=a===0?100:100-100/(1+o/a);return t}function ge(r,e){const t=new Array(r.length).fill(NaN),n=1/e;let i=0;for(let o=0;o<e;o++)i+=r[o]||0;t[e-1]=i/e;for(let o=e;o<r.length;o++){const a=r[o]||0;t[o]=a*n+t[o-1]*(1-n)}return t}function k(r,e){const t=new Array(r.length).fill(NaN);for(let n=e-1;n<r.length;n++){let i=0;for(let o=0;o<e;o++)i+=r[n-o]||0;t[n]=i/e}return t}function Ae(r,e,t){const n=new Array(r.length).fill(NaN);for(let i=t-1;i<r.length;i++){let o=0,a=0;for(let s=0;s<t;s++)o+=e[i-s],a+=r[i-s]*e[i-s];n[i]=a/o}return n}function Ee(r,e){const t=Math.floor(e/2),n=V(r,t),i=V(r,e),o=n.map((s,m)=>2*s-i[m]),a=Math.floor(Math.sqrt(e));return V(o,a)}function V(r,e){const t=new Array(r.length);for(let n=e-1;n<r.length;n++){let i=0,o=0;for(let a=0;a<e;a++)i+=r[n-a]*(e-a),o+=e-a;t[n]=i/o}for(let n=0;n<e-1;n++)t[n]=NaN;return t}function je(r,e=1){const t=new Array(r.length).fill(NaN);for(let n=e;n<r.length;n++)t[n]=r[n]-r[n-e];return t}function Me(r,e){const t=new Array(r.length).fill(NaN);for(let n=e;n<r.length;n++)t[n]=r[n]-r[n-e];return t}function Ie(r,e){const t=new Array(r.length).fill(NaN);for(let n=e;n<r.length;n++)t[n]=(r[n]-r[n-e])/r[n-e]*100;return t}function ve(r,e){const t=new Array(r.length).fill(NaN),n=k(r,e);for(let i=e-1;i<r.length;i++){let o=0;for(let a=0;a<e;a++)o+=Math.abs(r[i-a]-n[i]);t[i]=o/e}return t}function we(r,e){const t=new Array(r.length).fill(NaN);for(let n=e-1;n<r.length;n++){let i=0,o=0;for(let s=0;s<e;s++)i+=r[n-s],o+=r[n-s]*r[n-s];const a=i/e;t[n]=o/e-a*a}return t}function Ce(r,e){const t=new Array(r.length).fill(NaN);for(let n=e-1;n<r.length;n++){let i=-1/0;for(let o=0;o<e;o++){const a=r[n-o];isNaN(a)?i=i===-1/0?NaN:i:i=Math.max(i,a)}t[n]=i}return t}function Ne(r,e){const t=new Array(r.length).fill(NaN);for(let n=e-1;n<r.length;n++){let i=1/0;for(let o=0;o<e;o++){const a=r[n-o];isNaN(a)?i=i===1/0?NaN:i:i=Math.min(i,a)}t[n]=i}return t}function Ve(r,e){const t=new Array(r.length).fill(NaN);for(let n=e-1;n<r.length;n++){const i=r.slice(n-e+1,n+1).slice().sort((a,s)=>a-s),o=Math.floor(e/2);t[n]=e%2===0?(i[o-1]+i[o])/2:i[o]}return t}function Se(r,e,t=!0){const n=new Array(r.length).fill(NaN),i=k(r,e);for(let o=e-1;o<r.length;o++){let a=0;for(let m=0;m<e;m++)a+=Math.pow(r[o-m]-i[o],2);const s=t?e:e-1;n[o]=Math.sqrt(a/s)}return n}function Pe(r,e,t){const n=r.length,i=new Array(n).fill(NaN);for(let o=e-1;o<n;o++){let a=0,s=0,m=0,c=0;const y=e;for(let b=0;b<e;b++){const l=b,I=r[o-e+1+b];a+=l,s+=I,m+=l*I,c+=l*l}const h=y*c-a*a;if(h===0){i[o]=NaN;continue}const p=(y*m-a*s)/h,u=(s-p*a)/y+p*(e-1-t);i[o]=u}return i}function Be(r,e,t,n,i){const o=r.length,a=new Array(o).fill(NaN),s=new Array(o).fill(0),m=R(r,e,t,i),c=new Array(o).fill(NaN),y=new Array(o).fill(NaN);for(let l=0;l<o;l++){const I=(r[l]+e[l])/2,w=m[l];isNaN(w)||(c[l]=I+n*w,y[l]=I-n*w)}let h=c[i],p=y[i],u=t[i]<=h?h:p,b=t[i]<=h?-1:1;a[i]=u,s[i]=b;for(let l=i+1;l<o;l++){let I=c[l];I<h||t[l-1]>h?c[l]=I:c[l]=h;let w=y[l];w>p||t[l-1]<p?y[l]=w:y[l]=p,u===h?t[l]>c[l]?(s[l]=1,a[l]=y[l]):(s[l]=-1,a[l]=c[l]):t[l]<y[l]?(s[l]=-1,a[l]=c[l]):(s[l]=1,a[l]=y[l]),h=c[l],p=y[l],u=a[l]}return[a,s]}var Te=Object.defineProperty,ke=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,A=(r,e,t)=>ke(r,typeof e!="symbol"?e+"":e,t);class _e{constructor(e){this.marketData=e,A(this,"data",{open:[],high:[],low:[],close:[],volume:[],hl2:[],hlc3:[],ohlc4:[]}),A(this,"math"),A(this,"ta"),A(this,"input"),A(this,"request"),A(this,"core"),A(this,"idx",0),A(this,"params",{}),A(this,"const",{}),A(this,"var",{}),A(this,"let",{}),A(this,"result"),A(this,"plots",{}),A(this,"timeframe",""),this.math=new me(this),this.ta=new fe(this),this.input=new se(this),this.request=new de(this);const t=new ae(this);this.core={plotchar:t.plotchar.bind(t),na:t.na.bind(t),color:t.color,plot:t.plot.bind(t),nz:t.nz.bind(t)}}init(e,t,n=0){return e?!Array.isArray(t)||Array.isArray(t[0])?e[0]=Array.isArray(t?.[0])?t[0]:this.precision(t):e[0]=this.precision(t[t.length-this.idx-1+n]):Array.isArray(t)?e=[this.precision(t[t.length-this.idx-1+n])]:e=[this.precision(t)],e}precision(e,t=10){return typeof e!="number"||isNaN(e)?e:Number(e.toFixed(t))}param(e,t,n){return typeof e=="string"||!Array.isArray(e)&&typeof e=="object"?e:(this.params[n]||(this.params[n]=[]),Array.isArray(e)?t?(this.params[n]=e.slice(t),this.params[n]):(this.params[n]=e.slice(0),this.params[n]):(this.params[n][0]=e,this.params[n]))}}const $e="https://api.binance.com/api/v3",De={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class Le{async getMarketData(e,t,n,i,o){try{const a=De[t.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${t}`),[];let s=`${$e}/klines?symbol=${e}&interval=${a}`;n&&(s+=`&limit=${n}`),i&&(s+=`&startTime=${i}`),o&&(s+=`&endTime=${o}`);const m=await fetch(s);if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);return(await m.json()).map(c=>({openTime:parseInt(c[0])/1e3,open:parseFloat(c[1]),high:parseFloat(c[2]),low:parseFloat(c[3]),close:parseFloat(c[4]),volume:parseFloat(c[5]),closeTime:parseInt(c[6])/1e3,quoteAssetVolume:parseFloat(c[7]),numberOfTrades:parseInt(c[8]),takerBuyBaseAssetVolume:parseFloat(c[9]),takerBuyQuoteAssetVolume:parseFloat(c[10]),ignore:c[11]}))}catch(a){return console.error("Error in binance.klines:",a),[]}}}const Fe={Binance:new Le};export{_e as Context,Oe as PineTS,Fe as Provider};
|