pinets 0.9.4 → 0.9.6
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/README.md +3 -2
- package/dist/pinets.min.browser.es.js +18 -18
- package/dist/pinets.min.browser.es.js.map +1 -1
- package/dist/pinets.min.browser.js +18 -18
- package/dist/pinets.min.browser.js.map +1 -1
- package/dist/pinets.min.cjs +18 -18
- package/dist/pinets.min.cjs.map +1 -1
- package/dist/pinets.min.es.js +20 -20
- package/dist/pinets.min.es.js.map +1 -1
- package/dist/types/Context.class.d.ts +2 -0
- package/dist/types/PineTS.class.d.ts +17 -0
- package/dist/types/errors/PineRuntimeError.d.ts +27 -0
- package/dist/types/index.d.ts +10 -1
- package/dist/types/marketData/Alpaca/AlpacaProvider.class.d.ts +115 -0
- package/dist/types/marketData/BaseProvider.d.ts +92 -0
- package/dist/types/marketData/Binance/BinanceProvider.class.d.ts +15 -5
- package/dist/types/marketData/FMP/FMPProvider.class.d.ts +69 -0
- package/dist/types/marketData/IProvider.d.ts +26 -1
- package/dist/types/marketData/Mock/MockProvider.class.d.ts +12 -22
- package/dist/types/marketData/Provider.class.d.ts +4 -1
- package/dist/types/marketData/aggregation.d.ts +38 -0
- package/dist/types/marketData/types.d.ts +106 -0
- package/dist/types/namespaces/Log.d.ts +1 -0
- package/dist/types/transpiler/analysis/ScopeManager.d.ts +2 -0
- package/dist/types/transpiler/pineToJS/codegen.d.ts +1 -1
- package/dist/types/transpiler/transformers/StatementTransformer.d.ts +10 -0
- package/package.json +4 -4
package/dist/pinets.min.cjs
CHANGED
|
@@ -15,33 +15,33 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var vn=require("fs"),wn=require("path"),En=require("url");function sr(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if(i!=="default"){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var rt=sr(vn),gt=sr(wn),Sn=[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,78,5,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,199,7,137,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,55,9,266,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,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],ar=[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,7,25,39,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,5,57,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,24,43,261,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,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,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,208,30,2,2,2,1,2,6,3,4,10,1,225,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,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],Nn="\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-\u1ADD\u1AE0-\u1AEB\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",or="\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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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",Kt={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"},Ht="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",Cn={5:Ht,"5module":Ht+" export import",6:Ht+" const class extends export import super"},lr=/^in(stanceof)?$/,In=new RegExp("["+or+"]"),kn=new RegExp("["+or+Nn+"]");function ei(t,e){for(var i=65536,r=0;r<e.length;r+=2){if(i+=e[r],i>t)return!1;if(i+=e[r+1],i>=t)return!0}return!1}function Ae(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&In.test(String.fromCharCode(t)):e===!1?!1:ei(t,ar)}function ze(t,e){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&kn.test(String.fromCharCode(t)):e===!1?!1:ei(t,ar)||ei(t,Sn)}var j=function(e,i){i===void 0&&(i={}),this.label=e,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 xe(t,e){return new j(t,{beforeExpr:!0,binop:e})}var ge={beforeExpr:!0},oe={startsExpr:!0},pi={};function L(t,e){return e===void 0&&(e={}),e.keyword=t,pi[t]=new j(t,e)}var d={num:new j("num",oe),regexp:new j("regexp",oe),string:new j("string",oe),name:new j("name",oe),privateId:new j("privateId",oe),eof:new j("eof"),bracketL:new j("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new j("]"),braceL:new j("{",{beforeExpr:!0,startsExpr:!0}),braceR:new j("}"),parenL:new j("(",{beforeExpr:!0,startsExpr:!0}),parenR:new j(")"),comma:new j(",",ge),semi:new j(";",ge),colon:new j(":",ge),dot:new j("."),question:new j("?",ge),questionDot:new j("?."),arrow:new j("=>",ge),template:new j("template"),invalidTemplate:new j("invalidTemplate"),ellipsis:new j("...",ge),backQuote:new j("`",oe),dollarBraceL:new j("${",{beforeExpr:!0,startsExpr:!0}),eq:new j("=",{beforeExpr:!0,isAssign:!0}),assign:new j("_=",{beforeExpr:!0,isAssign:!0}),incDec:new j("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new j("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:xe("||",1),logicalAND:xe("&&",2),bitwiseOR:xe("|",3),bitwiseXOR:xe("^",4),bitwiseAND:xe("&",5),equality:xe("==/!=/===/!==",6),relational:xe("</>/<=/>=",7),bitShift:xe("<</>>/>>>",8),plusMin:new j("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:xe("%",10),star:xe("*",10),slash:xe("/",10),starstar:new j("**",{beforeExpr:!0}),coalesce:xe("??",1),_break:L("break"),_case:L("case",ge),_catch:L("catch"),_continue:L("continue"),_debugger:L("debugger"),_default:L("default",ge),_do:L("do",{isLoop:!0,beforeExpr:!0}),_else:L("else",ge),_finally:L("finally"),_for:L("for",{isLoop:!0}),_function:L("function",oe),_if:L("if"),_return:L("return",ge),_switch:L("switch"),_throw:L("throw",ge),_try:L("try"),_var:L("var"),_const:L("const"),_while:L("while",{isLoop:!0}),_with:L("with"),_new:L("new",{beforeExpr:!0,startsExpr:!0}),_this:L("this",oe),_super:L("super",oe),_class:L("class",oe),_extends:L("extends",ge),_export:L("export"),_import:L("import",oe),_null:L("null",oe),_true:L("true",oe),_false:L("false",oe),_in:L("in",{beforeExpr:!0,binop:7}),_instanceof:L("instanceof",{beforeExpr:!0,binop:7}),_typeof:L("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:L("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:L("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},le=/\r\n?|\n|\u2028|\u2029/,An=new RegExp(le.source,"g");function ht(t){return t===10||t===13||t===8232||t===8233}function cr(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(ht(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var hr=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,te=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ur=Object.prototype,Tn=ur.hasOwnProperty,Pn=ur.toString,ut=Object.hasOwn||(function(t,e){return Tn.call(t,e)}),Ii=Array.isArray||(function(t){return Pn.call(t)==="[object Array]"}),ki=Object.create(null);function qe(t){return ki[t]||(ki[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function Oe(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var Dn=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,vt=function(e,i){this.line=e,this.column=i};vt.prototype.offset=function(e){return new vt(this.line,this.column+e)};var jt=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function pr(t,e){for(var i=1,r=0;;){var n=cr(t,r,e);if(n<0)return new vt(i,e-r);++i,r=n}}var ti={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},Ai=!1;function Rn(t){var e={};for(var i in ti)e[i]=t&&ut(t,i)?t[i]:ti[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Ai&&typeof console=="object"&&console.warn&&(Ai=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
19
|
-
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!t||t.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),
|
|
20
|
-
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(le).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=d.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=e.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&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?Ze:Xe),this.regexpState=null,this.privateNameStack=[]},_e={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};K.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};_e.inFunction.get=function(){return(this.currentVarScope().flags&Ze)>0};_e.inGenerator.get=function(){return(this.currentVarScope().flags&fr)>0};_e.inAsync.get=function(){return(this.currentVarScope().flags&fi)>0};_e.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Je|wt))return!1;if(i&Ze)return(i&fi)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};_e.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Xe)};_e.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&Bt)>0||this.options.allowSuperOutsideMethod};_e.allowDirectSuper.get=function(){return(this.currentThisScope().flags&mr)>0};_e.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};_e.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Je|wt)||i&Ze&&!(i&di))return!0}return!1};_e.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&xr||!this.inModule&&e&Xe)};_e.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Je)>0};K.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};K.parse=function(e,i){return new this(i,e).parse()};K.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};K.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(K.prototype,_e);var ae=K.prototype,On=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ae.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){te.lastIndex=t,t+=te.exec(this.input)[0].length;var e=On.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){te.lastIndex=t+e[0].length;var i=te.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||le.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,te.lastIndex=t,t+=te.exec(this.input)[0].length,this.input[t]===";"&&t++}};ae.eat=function(t){return this.type===t?(this.next(),!0):!1};ae.isContextual=function(t){return this.type===d.name&&this.value===t&&!this.containsEsc};ae.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};ae.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};ae.canInsertSemicolon=function(){return this.type===d.eof||this.type===d.braceR||le.test(this.input.slice(this.lastTokEnd,this.start))};ae.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};ae.semicolon=function(){!this.eat(d.semi)&&!this.insertSemicolon()&&this.unexpected()};ae.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};ae.expect=function(t){this.eat(t)||this.unexpected()};ae.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Wt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ae.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var i=e?t.parenthesizedAssign:t.parenthesizedBind;i>-1&&this.raiseRecoverable(i,e?"Assigning to rvalue":"Parenthesized pattern")}};ae.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,r=t.doubleProto;if(!e)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")};ae.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")};ae.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var k=K.prototype;k.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==d.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var a=n[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var gi={kind:"loop"},Vn={kind:"switch"};k.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;te.lastIndex=this.pos;var e=te.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(Ae(r)){var n=i;do i+=r<=65535?1:2;while(ze(r=this.fullCharCodeAt(i)));if(r===92)return!0;var a=this.input.slice(n,i);if(!lr.test(a))return!0}return!1};k.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;te.lastIndex=this.pos;var t=te.exec(this.input),e=this.pos+t[0].length,i;return!le.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(ze(i=this.fullCharCodeAt(e+8))||i===92))};k.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;te.lastIndex=this.pos;var i=te.exec(this.input),r=this.pos+i[0].length;if(le.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,a;if(this.input.slice(r,n)!=="using"||n===this.input.length||ze(a=this.fullCharCodeAt(n))||a===92)return!1;te.lastIndex=n;var s=te.exec(this.input);if(r=n+s[0].length,s&&le.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!Ae(o)&&o!==92)return!1;var l=r;do r+=o<=65535?1:2;while(ze(o=this.fullCharCodeAt(r)));if(o===92)return!0;var c=this.input.slice(l,r);return!(lr.test(c)||e&&c==="of")};k.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};k.isUsing=function(t){return this.isUsingKeyword(!1,t)};k.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),a;switch(this.isLet(t)&&(r=d._var,a="let"),r){case d._break:case d._continue:return this.parseBreakContinueStatement(n,r.keyword);case d._debugger:return this.parseDebuggerStatement(n);case d._do:return this.parseDoStatement(n);case d._for:return this.parseForStatement(n);case d._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case d._class:return t&&this.unexpected(),this.parseClass(n,!0);case d._if:return this.parseIfStatement(n);case d._return:return this.parseReturnStatement(n);case d._switch:return this.parseSwitchStatement(n);case d._throw:return this.parseThrowStatement(n);case d._try:return this.parseTryStatement(n);case d._const:case d._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(n,a);case d._while:return this.parseWhileStatement(n);case d._with:return this.parseWithStatement(n);case d.braceL:return this.parseBlock(!0,n);case d.semi:return this.parseEmptyStatement(n);case d._export:case d._import:if(this.options.ecmaVersion>10&&r===d._import){te.lastIndex=this.pos;var s=te.exec(this.input),o=this.pos+s[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||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===d._import?this.parseImport(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,c),this.semicolon(),this.finishNode(n,"VariableDeclaration");var h=this.value,p=this.parseExpression();return r===d.name&&p.type==="Identifier"&&this.eat(d.colon)?this.parseLabeledStatement(n,h,p,t):this.parseExpressionStatement(n,p)}};k.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(d.semi)||this.insertSemicolon()?t.label=null:this.type!==d.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};k.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};k.parseDoStatement=function(t){return this.next(),this.labels.push(gi),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(d._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(d.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};k.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(gi),this.enterScope(0),this.expect(d.parenL),this.type===d.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===d._var||this.type===d._const||i){var r=this.startNode(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var a=this.isContextual("let"),s=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(t,l,e)}var c=this.containsEsc,h=new Wt,p=this.start,u=e>-1?this.parseExprSubscripts(h,"await"):this.parseExpression(!0,h);return this.type===d._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===d._in&&this.unexpected(e),t.await=!0):s&&this.options.ecmaVersion>=8&&(u.start===p&&!c&&u.type==="Identifier"&&u.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&s&&this.raise(u.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(u,!1,h),this.checkLValPattern(u),this.parseForIn(t,u)):(this.checkExpressionErrors(h,!0),e>-1&&this.unexpected(e),this.parseFor(t,u))};k.parseForAfterInit=function(t,e,i){return(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===d._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};k.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,_t|(i?0:ii),!1,e)};k.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(d._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};k.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(d.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};k.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(d.braceL),this.labels.push(Vn),this.enterScope(xr);for(var e,i=!1;this.type!==d.braceR;)if(this.type===d._case||this.type===d._default){var r=this.type===d._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),r?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(d.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};k.parseThrowStatement=function(t){return this.next(),le.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Ln=[];k.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?dr:0),this.checkLValPattern(t,e?yr:Le),this.expect(d.parenR),t};k.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===d._catch){var e=this.startNode();this.next(),this.eat(d.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(d._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};k.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};k.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(gi),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};k.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};k.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};k.parseLabeledStatement=function(t,e,i,r){for(var n=0,a=this.labels;n<a.length;n+=1){var s=a[n];s.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===d._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var c=this.labels[l];if(c.statementStart===t.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};k.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};k.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(d.braceL),t&&this.enterScope(0);this.type!==d.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};k.parseFor=function(t,e){return t.init=e,this.expect(d.semi),t.test=this.type===d.semi?null:this.parseExpression(),this.expect(d.semi),t.update=this.type===d.parenR?null:this.parseExpression(),this.expect(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};k.parseForIn=function(t,e){var i=this.type===d._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};k.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(d.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==d._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===d._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(d.comma))break}return t};k.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?xi:Le,!1)};var _t=1,ii=2,br=4;k.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===d.star&&e&ii&&this.unexpected(),t.generator=this.eat(d.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&_t&&(t.id=e&br&&this.type!==d.name?null:this.parseIdent(),t.id&&!(e&ii)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?xi:Le:gr));var a=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(mi(t.async,t.generator)),e&_t||(t.id=this.type===d.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(t,e&_t?"FunctionDeclaration":"FunctionExpression")};k.parseFunctionParams=function(t){this.expect(d.parenL),t.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};k.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),a=!1;for(n.body=[],this.expect(d.braceL);this.type!==d.braceR;){var s=this.parseClassElement(t.superClass!==null);s&&(n.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&jn(r,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};k.parseClassElement=function(t){if(this.eat(d.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,a=!1,s="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(d.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===d.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===d.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(e>=9||!a)&&this.eat(d.star)&&(n=!0),!r&&!a&&!n){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=l:r=l)}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),e<13||this.type===d.parenL||s!=="method"||n||a){var c=!i.static&&Dt(i,"constructor"),h=c&&t;c&&s!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":s,this.parseClassMethod(i,n,a,h)}else this.parseClassField(i);return i};k.isClassElementNameStart=function(){return this.type===d.name||this.type===d.privateId||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword};k.parseClassElementName=function(t){this.type===d.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};k.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&Dt(t,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var a=t.value=this.parseMethod(e,i,r);return t.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),t.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),t.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};k.parseClassField=function(t){return Dt(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&Dt(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(d.eq)?(this.enterScope(wt|Bt),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};k.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(Je|Bt);this.type!==d.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};k.parseClassId=function(t,e){this.type===d.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,Le,!1)):(e===!0&&this.unexpected(),t.id=null)};k.parseClassSuper=function(t){t.superClass=this.eat(d._extends)?this.parseExprSubscripts(null,!1):null};k.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};k.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var s=i[a];ut(e,s.name)||(n?n.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function jn(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function Dt(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}k.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==d.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};k.parseExport=function(t,e){if(this.next(),this.eat(d.star))return this.parseExportAllDeclaration(t,e);if(this.eat(d._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==d.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var i=0,r=t.specifiers;i<r.length;i+=1){var n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};k.parseExportDeclaration=function(t){return this.parseStatement(null)};k.parseExportDefaultDeclaration=function(){var t;if(this.type===d._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,_t|br,!1,t)}else if(this.type===d._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};k.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),ut(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};k.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var r=0,n=e.properties;r<n.length;r+=1){var a=n[r];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var s=0,o=e.elements;s<o.length;s+=1){var l=o[s];l&&this.checkPatternExport(t,l)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};k.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};k.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};k.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};k.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(d.braceL);!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;e.push(this.parseExportSpecifier(t))}return e};k.parseImport=function(t){return this.next(),this.type===d.string?(t.specifiers=Ln,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===d.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};k.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,Le),this.finishNode(t,"ImportSpecifier")};k.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,Le),this.finishNode(t,"ImportDefaultSpecifier")};k.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,Le),this.finishNode(t,"ImportNamespaceSpecifier")};k.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===d.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(d.comma)))return t;if(this.type===d.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(d.braceL);!this.eat(d.braceR);){if(e)e=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;t.push(this.parseImportSpecifier())}return t};k.parseWithClause=function(){var t=[];if(!this.eat(d._with))return t;this.expect(d.braceL);for(var e={},i=!0;!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;var r=this.parseImportAttribute(),n=r.key.type==="Identifier"?r.key.name:r.key.value;ut(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};k.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(d.colon),this.type!==d.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};k.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===d.string){var t=this.parseLiteral(this.value);return Dn.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};k.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};k.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var be=K.prototype;be.toAssignable=function(t,e,i){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.toAssignable(a,e),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,i);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return t};be.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,e)}if(i){var a=t[i-1];this.options.ecmaVersion===6&&e&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return t};be.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};be.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==d.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};be.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case d.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(d.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case d.braceL:return this.parseObj(!0)}return this.parseIdent()};be.parseBindingList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(d.comma),e&&this.type===d.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===d.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),n.push(s),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};be.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};be.parseBindingListItem=function(t){return t};be.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(d.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};be.checkLValSimple=function(t,e,i){e===void 0&&(e=Pt);var r=e!==Pt;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(r?"Binding ":"Assigning to ")+t.name+" in strict mode"),r&&(e===Le&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(ut(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==_r&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(r?"Binding":"Assigning to")+" rvalue")}};be.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=Pt),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var s=0,o=t.elements;s<o.length;s+=1){var l=o[s];l&&this.checkLValInnerPattern(l,e,i)}break;default:this.checkLValSimple(t,e,i)}};be.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=Pt),t.type){case"Property":this.checkLValInnerPattern(t.value,e,i);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,i);break;case"RestElement":this.checkLValPattern(t.argument,e,i);break;default:this.checkLValPattern(t,e,i)}};var Ee=function(e,i,r,n,a){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!a},U={b_stat:new Ee("{",!1),b_expr:new Ee("{",!0),b_tmpl:new Ee("${",!1),p_stat:new Ee("(",!1),p_expr:new Ee("(",!0),q_tmpl:new Ee("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Ee("function",!1),f_expr:new Ee("function",!0),f_expr_gen:new Ee("function",!0,!1,null,!0),f_gen:new Ee("function",!1,!1,null,!0)},pt=K.prototype;pt.initialContext=function(){return[U.b_stat]};pt.curContext=function(){return this.context[this.context.length-1]};pt.braceIsBlock=function(t){var e=this.curContext();return e===U.f_expr||e===U.f_stat?!0:t===d.colon&&(e===U.b_stat||e===U.b_expr)?!e.isExpr:t===d._return||t===d.name&&this.exprAllowed?le.test(this.input.slice(this.lastTokEnd,this.start)):t===d._else||t===d.semi||t===d.eof||t===d.parenR||t===d.arrow?!0:t===d.braceL?e===U.b_stat:t===d._var||t===d._const||t===d.name?!1:!this.exprAllowed};pt.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};pt.updateContext=function(t){var e,i=this.type;i.keyword&&t===d.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};pt.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};d.parenR.updateContext=d.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===U.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};d.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?U.b_stat:U.b_expr),this.exprAllowed=!0};d.dollarBraceL.updateContext=function(){this.context.push(U.b_tmpl),this.exprAllowed=!0};d.parenL.updateContext=function(t){var e=t===d._if||t===d._for||t===d._with||t===d._while;this.context.push(e?U.p_stat:U.p_expr),this.exprAllowed=!0};d.incDec.updateContext=function(){};d._function.updateContext=d._class.updateContext=function(t){t.beforeExpr&&t!==d._else&&!(t===d.semi&&this.curContext()!==U.p_stat)&&!(t===d._return&&le.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===d.colon||t===d.braceL)&&this.curContext()===U.b_stat)?this.context.push(U.f_expr):this.context.push(U.f_stat),this.exprAllowed=!1};d.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};d.backQuote.updateContext=function(){this.curContext()===U.q_tmpl?this.context.pop():this.context.push(U.q_tmpl),this.exprAllowed=!1};d.star.updateContext=function(t){if(t===d._function){var e=this.context.length-1;this.context[e]===U.f_expr?this.context[e]=U.f_expr_gen:this.context[e]=U.f_gen}this.exprAllowed=!0};d.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==d.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var T=K.prototype;T.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r=t.key,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&a==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var s=e[n];if(s){var o;a==="init"?o=this.strict&&s.init||s.get||s.set:o=s.init||s[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=e[n]={init:!1,get:!1,set:!1};s[a]=!0}};T.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===d.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(d.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n};T.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,a=-1,s=-1;e?(n=e.parenthesizedAssign,a=e.trailingComma,s=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Wt,r=!0);var o=this.start,l=this.startLoc;(this.type===d.parenL||this.type===d.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,l)),this.type.isAssign){var h=this.startNodeAt(o,l);return h.operator=this.value,this.type===d.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===d.eq?this.checkLValPattern(c):this.checkLValSimple(c),h.left=c,this.next(),h.right=this.parseMaybeAssign(t),s>-1&&(e.doubleProto=s),this.finishNode(h,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),a>-1&&(e.trailingComma=a),c};T.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(d.question)){var a=this.startNodeAt(i,r);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(d.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n};T.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};T.parseExprOp=function(t,e,i,r,n){var a=this.type.binop;if(a!=null&&(!n||this.type!==d._in)&&a>r){var s=this.type===d.logicalOR||this.type===d.logicalAND,o=this.type===d.coalesce;o&&(a=d.logicalAND.binop);var l=this.value;this.next();var c=this.start,h=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),c,h,a,n),u=this.buildBinary(e,i,t,p,l,s||o);return(s&&this.type===d.coalesce||o&&(this.type===d.logicalOR||this.type===d.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,e,i,r,n)}return t};T.buildBinary=function(t,e,i,r,n,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(t,e);return s.left=i,s.operator=n,s.right=r,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};T.parseMaybeUnary=function(t,e,i,r){var n=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===d.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&vr(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&ri(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,s=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===d.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==d._in&&this.unexpected();else{if(s=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(n,a);c.operator=this.value,c.prefix=!1,c.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(d.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return s};function vr(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&vr(t.expression)}function ri(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&ri(t.expression)||t.type==="ParenthesizedExpression"&&ri(t.expression)}T.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var a=this.parseSubscripts(n,i,r,!1,e);return t&&a.type==="MemberExpression"&&(t.parenthesizedAssign>=a.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=a.start&&(t.parenthesizedBind=-1),t.trailingComma>=a.start&&(t.trailingComma=-1)),a};T.parseSubscripts=function(t,e,i,r,n){for(var a=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,s=!1;;){var o=this.parseSubscript(t,e,i,r,a,s,n);if(o.optional&&(s=!0),o===t||o.type==="ArrowFunctionExpression"){if(s){var l=this.startNodeAt(e,i);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}t=o}};T.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(d.arrow)};T.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};T.parseSubscript=function(t,e,i,r,n,a,s){var o=this.options.ecmaVersion>=11,l=o&&this.eat(d.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(d.bracketL);if(c||l&&this.type!==d.parenL&&this.type!==d.backQuote||this.eat(d.dot)){var h=this.startNodeAt(e,i);h.object=t,c?(h.property=this.parseExpression(),this.expect(d.bracketR)):this.type===d.privateId&&t.type!=="Super"?h.property=this.parsePrivateIdent():h.property=this.parseIdent(this.options.allowReserved!=="never"),h.computed=!!c,o&&(h.optional=l),t=this.finishNode(h,"MemberExpression")}else if(!r&&this.eat(d.parenL)){var p=new Wt,u=this.yieldPos,f=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=u,this.awaitPos=f,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,i,y,s);this.checkExpressionErrors(p,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=f||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var _=this.startNodeAt(e,i);_.callee=t,_.arguments=y,o&&(_.optional=l),t=this.finishNode(_,"CallExpression")}else if(this.type===d.backQuote){(l||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var b=this.startNodeAt(e,i);b.tag=t,b.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(b,"TaggedTemplateExpression")}return t};T.parseExprAtom=function(t,e,i){this.type===d.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case d._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===d.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==d.dot&&this.type!==d.bracketL&&this.type!==d.parenL&&this.unexpected(),this.finishNode(r,"Super");case d._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case d.name:var a=this.start,s=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(d._function))return this.overrideContext(U.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(d.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[l],!1,e);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===d.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(d.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[l],!0,e)}return l;case d.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case d.num:case d.string:return this.parseLiteral(this.value);case d._null:case d._true:case d._false:return r=this.startNode(),r.value=this.type===d._null?null:this.type===d._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case d.parenL:var h=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),p;case d.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(d.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case d.braceL:return this.overrideContext(U.b_expr),this.parseObj(!1,t);case d._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case d._class:return this.parseClass(this.startNode(),!1);case d._new:return this.parseNew();case d.backQuote:return this.parseTemplate();case d._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};T.parseExprAtomDefault=function(){this.unexpected()};T.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===d.parenL&&!t)return this.parseDynamicImport(e);if(this.type===d.dot){var i=this.startNodeAt(e.start,e.loc&&e.loc.start);return i.name="import",e.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};T.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(d.parenR)?t.options=null:(this.expect(d.comma),this.afterTrailingComma(d.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(d.parenR)||(this.expect(d.comma),this.afterTrailingComma(d.parenR)||this.unexpected())));else if(!this.eat(d.parenR)){var e=this.start;this.eat(d.comma)&&this.eat(d.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};T.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};T.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};T.parseParenExpression=function(){this.expect(d.parenL);var t=this.parseExpression();return this.expect(d.parenR),t};T.shouldParseArrow=function(t){return!this.canInsertSemicolon()};T.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,o=this.startLoc,l=[],c=!0,h=!1,p=new Wt,u=this.yieldPos,f=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==d.parenR;)if(c?c=!1:this.expect(d.comma),a&&this.afterTrailingComma(d.parenR,!0)){h=!0;break}else if(this.type===d.ellipsis){m=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,_=this.lastTokEndLoc;if(this.expect(d.parenR),t&&this.shouldParseArrow(l)&&this.eat(d.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=u,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);(!l.length||h)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?(n=this.startNodeAt(s,o),n.expressions=l,this.finishNodeAt(n,"SequenceExpression",y,_)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var b=this.startNodeAt(i,r);return b.expression=n,this.finishNode(b,"ParenthesizedExpression")}else return n};T.parseParenItem=function(t){return t};T.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var Bn=[];T.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===d.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var i=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var r=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(d.parenL)?t.arguments=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1):t.arguments=Bn,this.finishNode(t,"NewExpression")};T.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===d.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
18
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Un=require("fs"),qn=require("path"),zn=require("url");function vr(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if(i!=="default"){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var st=vr(Un),vt=vr(qn),Kn=[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,78,5,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,199,7,137,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,55,9,266,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,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Sr=[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,7,25,39,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,5,57,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,24,43,261,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,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,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,208,30,2,2,2,1,2,6,3,4,10,1,225,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,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],Hn="\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-\u1ADD\u1AE0-\u1AEB\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",Er="\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-\u088F\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\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\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-\uA7DC\uA7F1-\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",ei={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"},ti="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",Gn={5:ti,"5module":ti+" export import",6:ti+" const class extends export import super"},Nr=/^in(stanceof)?$/,Yn=new RegExp("["+Er+"]"),Xn=new RegExp("["+Er+Hn+"]");function oi(t,e){for(var i=65536,r=0;r<e.length;r+=2){if(i+=e[r],i>t)return!1;if(i+=e[r+1],i>=t)return!0}return!1}function Te(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Yn.test(String.fromCharCode(t)):e===!1?!1:oi(t,Sr)}function He(t,e){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Xn.test(String.fromCharCode(t)):e===!1?!1:oi(t,Sr)||oi(t,Kn)}var B=function(e,i){i===void 0&&(i={}),this.label=e,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 ge(t,e){return new B(t,{beforeExpr:!0,binop:e})}var ye={beforeExpr:!0},oe={startsExpr:!0},bi={};function L(t,e){return e===void 0&&(e={}),e.keyword=t,bi[t]=new B(t,e)}var d={num:new B("num",oe),regexp:new B("regexp",oe),string:new B("string",oe),name:new B("name",oe),privateId:new B("privateId",oe),eof:new B("eof"),bracketL:new B("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new B("]"),braceL:new B("{",{beforeExpr:!0,startsExpr:!0}),braceR:new B("}"),parenL:new B("(",{beforeExpr:!0,startsExpr:!0}),parenR:new B(")"),comma:new B(",",ye),semi:new B(";",ye),colon:new B(":",ye),dot:new B("."),question:new B("?",ye),questionDot:new B("?."),arrow:new B("=>",ye),template:new B("template"),invalidTemplate:new B("invalidTemplate"),ellipsis:new B("...",ye),backQuote:new B("`",oe),dollarBraceL:new B("${",{beforeExpr:!0,startsExpr:!0}),eq:new B("=",{beforeExpr:!0,isAssign:!0}),assign:new B("_=",{beforeExpr:!0,isAssign:!0}),incDec:new B("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new B("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ge("||",1),logicalAND:ge("&&",2),bitwiseOR:ge("|",3),bitwiseXOR:ge("^",4),bitwiseAND:ge("&",5),equality:ge("==/!=/===/!==",6),relational:ge("</>/<=/>=",7),bitShift:ge("<</>>/>>>",8),plusMin:new B("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ge("%",10),star:ge("*",10),slash:ge("/",10),starstar:new B("**",{beforeExpr:!0}),coalesce:ge("??",1),_break:L("break"),_case:L("case",ye),_catch:L("catch"),_continue:L("continue"),_debugger:L("debugger"),_default:L("default",ye),_do:L("do",{isLoop:!0,beforeExpr:!0}),_else:L("else",ye),_finally:L("finally"),_for:L("for",{isLoop:!0}),_function:L("function",oe),_if:L("if"),_return:L("return",ye),_switch:L("switch"),_throw:L("throw",ye),_try:L("try"),_var:L("var"),_const:L("const"),_while:L("while",{isLoop:!0}),_with:L("with"),_new:L("new",{beforeExpr:!0,startsExpr:!0}),_this:L("this",oe),_super:L("super",oe),_class:L("class",oe),_extends:L("extends",ye),_export:L("export"),_import:L("import",oe),_null:L("null",oe),_true:L("true",oe),_false:L("false",oe),_in:L("in",{beforeExpr:!0,binop:7}),_instanceof:L("instanceof",{beforeExpr:!0,binop:7}),_typeof:L("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:L("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:L("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},ce=/\r\n?|\n|\u2028|\u2029/,Qn=new RegExp(ce.source,"g");function mt(t){return t===10||t===13||t===8232||t===8233}function Cr(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(mt(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var Ir=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,te=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,kr=Object.prototype,Zn=kr.hasOwnProperty,Jn=kr.toString,gt=Object.hasOwn||(function(t,e){return Zn.call(t,e)}),Li=Array.isArray||(function(t){return Jn.call(t)==="[object Array]"}),Bi=Object.create(null);function Ke(t){return Bi[t]||(Bi[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function Le(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var es=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Ct=function(e,i){this.line=e,this.column=i};Ct.prototype.offset=function(e){return new Ct(this.line,this.column+e)};var Kt=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function Ar(t,e){for(var i=1,r=0;;){var n=Cr(t,r,e);if(n<0)return new Ct(i,e-r);++i,r=n}}var li={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},ji=!1;function ts(t){var e={};for(var i in li)e[i]=t&>(t,i)?t[i]:li[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!ji&&typeof console=="object"&&console.warn&&(ji=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
19
|
+
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!t||t.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),Li(e.onToken)){var r=e.onToken;e.onToken=function(n){return r.push(n)}}if(Li(e.onComment)&&(e.onComment=is(e,e.onComment)),e.sourceType==="commonjs"&&e.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return e}function is(t,e){return function(i,r,n,a,s,o){var l={type:i?"Block":"Line",value:r,start:n,end:a};t.locations&&(l.loc=new Kt(this,s,o)),t.ranges&&(l.range=[n,a]),e.push(l)}}var Je=1,et=2,wi=4,Tr=8,vi=16,Pr=32,Ht=64,Dr=128,tt=256,It=512,Mr=1024,Gt=Je|et|tt;function Si(t,e){return et|(t?wi:0)|(e?Tr:0)}var jt=0,Ei=1,je=2,Rr=3,Or=4,Vr=5,G=function(e,i,r){this.options=e=ts(e),this.sourceFile=e.sourceFile,this.keywords=Ke(Gn[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var n="";e.allowReserved!==!0&&(n=ei[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(n+=" await")),this.reservedWords=Ke(n);var a=(n?n+" ":"")+ei.strict;this.reservedWordsStrict=Ke(a),this.reservedWordsStrictBind=Ke(a+" "+ei.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(ce).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=d.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=e.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&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?et:Je),this.regexpState=null,this.privateNameStack=[]},_e={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};G.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};_e.inFunction.get=function(){return(this.currentVarScope().flags&et)>0};_e.inGenerator.get=function(){return(this.currentVarScope().flags&Tr)>0};_e.inAsync.get=function(){return(this.currentVarScope().flags&wi)>0};_e.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(tt|It))return!1;if(i&et)return(i&wi)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};_e.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Je)};_e.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&Ht)>0||this.options.allowSuperOutsideMethod};_e.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Dr)>0};_e.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};_e.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(tt|It)||i&et&&!(i&vi))return!0}return!1};_e.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&Mr||!this.inModule&&e&Je)};_e.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&tt)>0};G.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};G.parse=function(e,i){return new this(i,e).parse()};G.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};G.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(G.prototype,_e);var ae=G.prototype,rs=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ae.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){te.lastIndex=t,t+=te.exec(this.input)[0].length;var e=rs.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){te.lastIndex=t+e[0].length;var i=te.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||ce.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,te.lastIndex=t,t+=te.exec(this.input)[0].length,this.input[t]===";"&&t++}};ae.eat=function(t){return this.type===t?(this.next(),!0):!1};ae.isContextual=function(t){return this.type===d.name&&this.value===t&&!this.containsEsc};ae.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};ae.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};ae.canInsertSemicolon=function(){return this.type===d.eof||this.type===d.braceR||ce.test(this.input.slice(this.lastTokEnd,this.start))};ae.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};ae.semicolon=function(){!this.eat(d.semi)&&!this.insertSemicolon()&&this.unexpected()};ae.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};ae.expect=function(t){this.eat(t)||this.unexpected()};ae.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Yt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ae.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var i=e?t.parenthesizedAssign:t.parenthesizedBind;i>-1&&this.raiseRecoverable(i,e?"Assigning to rvalue":"Parenthesized pattern")}};ae.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,r=t.doubleProto;if(!e)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")};ae.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")};ae.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var k=G.prototype;k.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==d.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var a=n[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var Ni={kind:"loop"},ns={kind:"switch"};k.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;te.lastIndex=this.pos;var e=te.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(Te(r)){var n=i;do i+=r<=65535?1:2;while(He(r=this.fullCharCodeAt(i)));if(r===92)return!0;var a=this.input.slice(n,i);if(!Nr.test(a))return!0}return!1};k.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;te.lastIndex=this.pos;var t=te.exec(this.input),e=this.pos+t[0].length,i;return!ce.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(He(i=this.fullCharCodeAt(e+8))||i===92))};k.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;te.lastIndex=this.pos;var i=te.exec(this.input),r=this.pos+i[0].length;if(ce.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,a;if(this.input.slice(r,n)!=="using"||n===this.input.length||He(a=this.fullCharCodeAt(n))||a===92)return!1;te.lastIndex=n;var s=te.exec(this.input);if(r=n+s[0].length,s&&ce.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!Te(o)&&o!==92)return!1;var l=r;do r+=o<=65535?1:2;while(He(o=this.fullCharCodeAt(r)));if(o===92)return!0;var c=this.input.slice(l,r);return!(Nr.test(c)||e&&c==="of")};k.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};k.isUsing=function(t){return this.isUsingKeyword(!1,t)};k.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),a;switch(this.isLet(t)&&(r=d._var,a="let"),r){case d._break:case d._continue:return this.parseBreakContinueStatement(n,r.keyword);case d._debugger:return this.parseDebuggerStatement(n);case d._do:return this.parseDoStatement(n);case d._for:return this.parseForStatement(n);case d._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case d._class:return t&&this.unexpected(),this.parseClass(n,!0);case d._if:return this.parseIfStatement(n);case d._return:return this.parseReturnStatement(n);case d._switch:return this.parseSwitchStatement(n);case d._throw:return this.parseThrowStatement(n);case d._try:return this.parseTryStatement(n);case d._const:case d._var:return a=a||this.value,t&&a!=="var"&&this.unexpected(),this.parseVarStatement(n,a);case d._while:return this.parseWhileStatement(n);case d._with:return this.parseWithStatement(n);case d.braceL:return this.parseBlock(!0,n);case d.semi:return this.parseEmptyStatement(n);case d._export:case d._import:if(this.options.ecmaVersion>10&&r===d._import){te.lastIndex=this.pos;var s=te.exec(this.input),o=this.pos+s[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||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===d._import?this.parseImport(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,c),this.semicolon(),this.finishNode(n,"VariableDeclaration");var h=this.value,p=this.parseExpression();return r===d.name&&p.type==="Identifier"&&this.eat(d.colon)?this.parseLabeledStatement(n,h,p,t):this.parseExpressionStatement(n,p)}};k.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(d.semi)||this.insertSemicolon()?t.label=null:this.type!==d.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};k.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};k.parseDoStatement=function(t){return this.next(),this.labels.push(Ni),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(d._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(d.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};k.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Ni),this.enterScope(0),this.expect(d.parenL),this.type===d.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===d._var||this.type===d._const||i){var r=this.startNode(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var a=this.isContextual("let"),s=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(t,l,e)}var c=this.containsEsc,h=new Yt,p=this.start,u=e>-1?this.parseExprSubscripts(h,"await"):this.parseExpression(!0,h);return this.type===d._in||(s=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===d._in&&this.unexpected(e),t.await=!0):s&&this.options.ecmaVersion>=8&&(u.start===p&&!c&&u.type==="Identifier"&&u.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),a&&s&&this.raise(u.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(u,!1,h),this.checkLValPattern(u),this.parseForIn(t,u)):(this.checkExpressionErrors(h,!0),e>-1&&this.unexpected(e),this.parseFor(t,u))};k.parseForAfterInit=function(t,e,i){return(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===d._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};k.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,Et|(i?0:ci),!1,e)};k.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(d._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};k.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(d.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};k.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(d.braceL),this.labels.push(ns),this.enterScope(Mr);for(var e,i=!1;this.type!==d.braceR;)if(this.type===d._case||this.type===d._default){var r=this.type===d._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),r?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(d.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};k.parseThrowStatement=function(t){return this.next(),ce.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var ss=[];k.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?Pr:0),this.checkLValPattern(t,e?Or:je),this.expect(d.parenR),t};k.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===d._catch){var e=this.startNode();this.next(),this.eat(d.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(d._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};k.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};k.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Ni),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};k.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};k.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};k.parseLabeledStatement=function(t,e,i,r){for(var n=0,a=this.labels;n<a.length;n+=1){var s=a[n];s.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===d._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var c=this.labels[l];if(c.statementStart===t.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};k.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};k.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(d.braceL),t&&this.enterScope(0);this.type!==d.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};k.parseFor=function(t,e){return t.init=e,this.expect(d.semi),t.test=this.type===d.semi?null:this.parseExpression(),this.expect(d.semi),t.update=this.type===d.parenR?null:this.parseExpression(),this.expect(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};k.parseForIn=function(t,e){var i=this.type===d._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(d.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};k.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(d.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===d._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==d._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===d._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(d.comma))break}return t};k.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Ei:je,!1)};var Et=1,ci=2,Lr=4;k.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===d.star&&e&ci&&this.unexpected(),t.generator=this.eat(d.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&Et&&(t.id=e&Lr&&this.type!==d.name?null:this.parseIdent(),t.id&&!(e&ci)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Ei:je:Rr));var a=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Si(t.async,t.generator)),e&Et||(t.id=this.type===d.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=a,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(t,e&Et?"FunctionDeclaration":"FunctionExpression")};k.parseFunctionParams=function(t){this.expect(d.parenL),t.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};k.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),a=!1;for(n.body=[],this.expect(d.braceL);this.type!==d.braceR;){var s=this.parseClassElement(t.superClass!==null);s&&(n.body.push(s),s.type==="MethodDefinition"&&s.kind==="constructor"?(a&&this.raiseRecoverable(s.start,"Duplicate constructor in the same class"),a=!0):s.key&&s.key.type==="PrivateIdentifier"&&as(r,s)&&this.raiseRecoverable(s.key.start,"Identifier '#"+s.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};k.parseClassElement=function(t){if(this.eat(d.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,a=!1,s="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(d.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===d.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===d.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(e>=9||!a)&&this.eat(d.star)&&(n=!0),!r&&!a&&!n){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?s=l:r=l)}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),e<13||this.type===d.parenL||s!=="method"||n||a){var c=!i.static&&Ft(i,"constructor"),h=c&&t;c&&s!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":s,this.parseClassMethod(i,n,a,h)}else this.parseClassField(i);return i};k.isClassElementNameStart=function(){return this.type===d.name||this.type===d.privateId||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword};k.parseClassElementName=function(t){this.type===d.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};k.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&Ft(t,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var a=t.value=this.parseMethod(e,i,r);return t.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),t.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),t.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};k.parseClassField=function(t){return Ft(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&Ft(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(d.eq)?(this.enterScope(It|Ht),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};k.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(tt|Ht);this.type!==d.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};k.parseClassId=function(t,e){this.type===d.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,je,!1)):(e===!0&&this.unexpected(),t.id=null)};k.parseClassSuper=function(t){t.superClass=this.eat(d._extends)?this.parseExprSubscripts(null,!1):null};k.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};k.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],a=0;a<i.length;++a){var s=i[a];gt(e,s.name)||(n?n.used.push(s):this.raiseRecoverable(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"))}};function as(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function Ft(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}k.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==d.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};k.parseExport=function(t,e){if(this.next(),this.eat(d.star))return this.parseExportAllDeclaration(t,e);if(this.eat(d._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==d.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var i=0,r=t.specifiers;i<r.length;i+=1){var n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};k.parseExportDeclaration=function(t){return this.parseStatement(null)};k.parseExportDefaultDeclaration=function(){var t;if(this.type===d._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,Et|Lr,!1,t)}else if(this.type===d._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};k.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),gt(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};k.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var r=0,n=e.properties;r<n.length;r+=1){var a=n[r];this.checkPatternExport(t,a)}else if(i==="ArrayPattern")for(var s=0,o=e.elements;s<o.length;s+=1){var l=o[s];l&&this.checkPatternExport(t,l)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};k.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};k.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};k.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};k.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(d.braceL);!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;e.push(this.parseExportSpecifier(t))}return e};k.parseImport=function(t){return this.next(),this.type===d.string?(t.specifiers=ss,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===d.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};k.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,je),this.finishNode(t,"ImportSpecifier")};k.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,je),this.finishNode(t,"ImportDefaultSpecifier")};k.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,je),this.finishNode(t,"ImportNamespaceSpecifier")};k.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===d.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(d.comma)))return t;if(this.type===d.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(d.braceL);!this.eat(d.braceR);){if(e)e=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;t.push(this.parseImportSpecifier())}return t};k.parseWithClause=function(){var t=[];if(!this.eat(d._with))return t;this.expect(d.braceL);for(var e={},i=!0;!this.eat(d.braceR);){if(i)i=!1;else if(this.expect(d.comma),this.afterTrailingComma(d.braceR))break;var r=this.parseImportAttribute(),n=r.key.type==="Identifier"?r.key.name:r.key.value;gt(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};k.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(d.colon),this.type!==d.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};k.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===d.string){var t=this.parseLiteral(this.value);return es.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};k.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};k.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var be=G.prototype;be.toAssignable=function(t,e,i){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.toAssignable(a,e),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,i);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return t};be.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,e)}if(i){var a=t[i-1];this.options.ecmaVersion===6&&e&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return t};be.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};be.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==d.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};be.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case d.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(d.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case d.braceL:return this.parseObj(!0)}return this.parseIdent()};be.parseBindingList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);)if(a?a=!1:this.expect(d.comma),e&&this.type===d.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===d.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),n.push(s),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};be.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};be.parseBindingListItem=function(t){return t};be.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(d.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};be.checkLValSimple=function(t,e,i){e===void 0&&(e=jt);var r=e!==jt;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(r?"Binding ":"Assigning to ")+t.name+" in strict mode"),r&&(e===je&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(gt(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==Vr&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(r?"Binding":"Assigning to")+" rvalue")}};be.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=jt),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,e,i)}break;case"ArrayPattern":for(var s=0,o=t.elements;s<o.length;s+=1){var l=o[s];l&&this.checkLValInnerPattern(l,e,i)}break;default:this.checkLValSimple(t,e,i)}};be.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=jt),t.type){case"Property":this.checkLValInnerPattern(t.value,e,i);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,i);break;case"RestElement":this.checkLValPattern(t.argument,e,i);break;default:this.checkLValPattern(t,e,i)}};var Se=function(e,i,r,n,a){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!a},U={b_stat:new Se("{",!1),b_expr:new Se("{",!0),b_tmpl:new Se("${",!1),p_stat:new Se("(",!1),p_expr:new Se("(",!0),q_tmpl:new Se("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Se("function",!1),f_expr:new Se("function",!0),f_expr_gen:new Se("function",!0,!1,null,!0),f_gen:new Se("function",!1,!1,null,!0)},yt=G.prototype;yt.initialContext=function(){return[U.b_stat]};yt.curContext=function(){return this.context[this.context.length-1]};yt.braceIsBlock=function(t){var e=this.curContext();return e===U.f_expr||e===U.f_stat?!0:t===d.colon&&(e===U.b_stat||e===U.b_expr)?!e.isExpr:t===d._return||t===d.name&&this.exprAllowed?ce.test(this.input.slice(this.lastTokEnd,this.start)):t===d._else||t===d.semi||t===d.eof||t===d.parenR||t===d.arrow?!0:t===d.braceL?e===U.b_stat:t===d._var||t===d._const||t===d.name?!1:!this.exprAllowed};yt.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};yt.updateContext=function(t){var e,i=this.type;i.keyword&&t===d.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};yt.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};d.parenR.updateContext=d.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===U.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};d.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?U.b_stat:U.b_expr),this.exprAllowed=!0};d.dollarBraceL.updateContext=function(){this.context.push(U.b_tmpl),this.exprAllowed=!0};d.parenL.updateContext=function(t){var e=t===d._if||t===d._for||t===d._with||t===d._while;this.context.push(e?U.p_stat:U.p_expr),this.exprAllowed=!0};d.incDec.updateContext=function(){};d._function.updateContext=d._class.updateContext=function(t){t.beforeExpr&&t!==d._else&&!(t===d.semi&&this.curContext()!==U.p_stat)&&!(t===d._return&&ce.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===d.colon||t===d.braceL)&&this.curContext()===U.b_stat)?this.context.push(U.f_expr):this.context.push(U.f_stat),this.exprAllowed=!1};d.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};d.backQuote.updateContext=function(){this.curContext()===U.q_tmpl?this.context.pop():this.context.push(U.q_tmpl),this.exprAllowed=!1};d.star.updateContext=function(t){if(t===d._function){var e=this.context.length-1;this.context[e]===U.f_expr?this.context[e]=U.f_expr_gen:this.context[e]=U.f_gen}this.exprAllowed=!0};d.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==d.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var P=G.prototype;P.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r=t.key,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var a=t.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&a==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var s=e[n];if(s){var o;a==="init"?o=this.strict&&s.init||s.get||s.set:o=s.init||s[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=e[n]={init:!1,get:!1,set:!1};s[a]=!0}};P.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===d.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(d.comma);)a.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n};P.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,a=-1,s=-1;e?(n=e.parenthesizedAssign,a=e.trailingComma,s=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Yt,r=!0);var o=this.start,l=this.startLoc;(this.type===d.parenL||this.type===d.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,l)),this.type.isAssign){var h=this.startNodeAt(o,l);return h.operator=this.value,this.type===d.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===d.eq?this.checkLValPattern(c):this.checkLValSimple(c),h.left=c,this.next(),h.right=this.parseMaybeAssign(t),s>-1&&(e.doubleProto=s),this.finishNode(h,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),a>-1&&(e.trailingComma=a),c};P.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(d.question)){var a=this.startNodeAt(i,r);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(d.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n};P.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};P.parseExprOp=function(t,e,i,r,n){var a=this.type.binop;if(a!=null&&(!n||this.type!==d._in)&&a>r){var s=this.type===d.logicalOR||this.type===d.logicalAND,o=this.type===d.coalesce;o&&(a=d.logicalAND.binop);var l=this.value;this.next();var c=this.start,h=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),c,h,a,n),u=this.buildBinary(e,i,t,p,l,s||o);return(s&&this.type===d.coalesce||o&&(this.type===d.logicalOR||this.type===d.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(u,e,i,r,n)}return t};P.buildBinary=function(t,e,i,r,n,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var s=this.startNodeAt(t,e);return s.left=i,s.operator=n,s.right=r,this.finishNode(s,a?"LogicalExpression":"BinaryExpression")};P.parseMaybeUnary=function(t,e,i,r){var n=this.start,a=this.startLoc,s;if(this.isContextual("await")&&this.canAwait)s=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===d.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&Br(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&hi(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,s=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===d.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==d._in&&this.unexpected();else{if(s=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(n,a);c.operator=this.value,c.prefix=!1,c.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(d.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,a,s,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return s};function Br(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&Br(t.expression)}function hi(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&hi(t.expression)||t.type==="ParenthesizedExpression"&&hi(t.expression)}P.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var a=this.parseSubscripts(n,i,r,!1,e);return t&&a.type==="MemberExpression"&&(t.parenthesizedAssign>=a.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=a.start&&(t.parenthesizedBind=-1),t.trailingComma>=a.start&&(t.trailingComma=-1)),a};P.parseSubscripts=function(t,e,i,r,n){for(var a=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,s=!1;;){var o=this.parseSubscript(t,e,i,r,a,s,n);if(o.optional&&(s=!0),o===t||o.type==="ArrowFunctionExpression"){if(s){var l=this.startNodeAt(e,i);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}t=o}};P.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(d.arrow)};P.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};P.parseSubscript=function(t,e,i,r,n,a,s){var o=this.options.ecmaVersion>=11,l=o&&this.eat(d.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(d.bracketL);if(c||l&&this.type!==d.parenL&&this.type!==d.backQuote||this.eat(d.dot)){var h=this.startNodeAt(e,i);h.object=t,c?(h.property=this.parseExpression(),this.expect(d.bracketR)):this.type===d.privateId&&t.type!=="Super"?h.property=this.parsePrivateIdent():h.property=this.parseIdent(this.options.allowReserved!=="never"),h.computed=!!c,o&&(h.optional=l),t=this.finishNode(h,"MemberExpression")}else if(!r&&this.eat(d.parenL)){var p=new Yt,u=this.yieldPos,f=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var x=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=u,this.awaitPos=f,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,i,x,s);this.checkExpressionErrors(p,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=f||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var _=this.startNodeAt(e,i);_.callee=t,_.arguments=x,o&&(_.optional=l),t=this.finishNode(_,"CallExpression")}else if(this.type===d.backQuote){(l||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var b=this.startNodeAt(e,i);b.tag=t,b.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(b,"TaggedTemplateExpression")}return t};P.parseExprAtom=function(t,e,i){this.type===d.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case d._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===d.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==d.dot&&this.type!==d.bracketL&&this.type!==d.parenL&&this.unexpected(),this.finishNode(r,"Super");case d._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case d.name:var a=this.start,s=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(d._function))return this.overrideContext(U.f_expr),this.parseFunction(this.startNodeAt(a,s),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(d.arrow))return this.parseArrowExpression(this.startNodeAt(a,s),[l],!1,e);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===d.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(d.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,s),[l],!0,e)}return l;case d.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case d.num:case d.string:return this.parseLiteral(this.value);case d._null:case d._true:case d._false:return r=this.startNode(),r.value=this.type===d._null?null:this.type===d._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case d.parenL:var h=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),p;case d.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(d.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case d.braceL:return this.overrideContext(U.b_expr),this.parseObj(!1,t);case d._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case d._class:return this.parseClass(this.startNode(),!1);case d._new:return this.parseNew();case d.backQuote:return this.parseTemplate();case d._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};P.parseExprAtomDefault=function(){this.unexpected()};P.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===d.parenL&&!t)return this.parseDynamicImport(e);if(this.type===d.dot){var i=this.startNodeAt(e.start,e.loc&&e.loc.start);return i.name="import",e.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};P.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(d.parenR)?t.options=null:(this.expect(d.comma),this.afterTrailingComma(d.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(d.parenR)||(this.expect(d.comma),this.afterTrailingComma(d.parenR)||this.unexpected())));else if(!this.eat(d.parenR)){var e=this.start;this.eat(d.comma)&&this.eat(d.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};P.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};P.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};P.parseParenExpression=function(){this.expect(d.parenL);var t=this.parseExpression();return this.expect(d.parenR),t};P.shouldParseArrow=function(t){return!this.canInsertSemicolon()};P.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,o=this.startLoc,l=[],c=!0,h=!1,p=new Yt,u=this.yieldPos,f=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==d.parenR;)if(c?c=!1:this.expect(d.comma),a&&this.afterTrailingComma(d.parenR,!0)){h=!0;break}else if(this.type===d.ellipsis){m=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var x=this.lastTokEnd,_=this.lastTokEndLoc;if(this.expect(d.parenR),t&&this.shouldParseArrow(l)&&this.eat(d.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=u,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);(!l.length||h)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=u||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?(n=this.startNodeAt(s,o),n.expressions=l,this.finishNodeAt(n,"SequenceExpression",x,_)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var b=this.startNodeAt(i,r);return b.expression=n,this.finishNode(b,"ParenthesizedExpression")}else return n};P.parseParenItem=function(t){return t};P.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var os=[];P.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===d.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var i=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var r=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(d.parenL)?t.arguments=this.parseExprList(d.parenR,this.options.ecmaVersion>=8,!1):t.arguments=os,this.finishNode(t,"NewExpression")};P.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===d.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
21
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===d.backQuote,this.finishNode(i,"TemplateElement")};T.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:e});for(i.quasis=[r];!r.tail;)this.type===d.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(d.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(d.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};T.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===d.name||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===d.star)&&!le.test(this.input.slice(this.lastTokEnd,this.start))};T.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(d.braceR);){if(r)r=!1;else if(this.expect(d.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(d.braceR))break;var a=this.parseProperty(t,e);t||this.checkPropClash(a,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};T.parseProperty=function(t,e){var i=this.startNode(),r,n,a,s;if(this.options.ecmaVersion>=9&&this.eat(d.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,e),this.type===d.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(t||e)&&(a=this.start,s=this.startLoc),t||(r=this.eat(d.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(d.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,a,s,e,o),this.finishNode(i,"Property")};T.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};T.parsePropertyValue=function(t,e,i,r,n,a,s,o){(i||r)&&this.type===d.colon&&this.unexpected(),this.eat(d.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),t.kind="init"):this.options.ecmaVersion>=6&&this.type===d.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==d.comma&&this.type!==d.braceR&&this.type!==d.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key)):this.type===d.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};T.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(d.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(d.bracketR),t.key;t.computed=!1}return t.key=this.type===d.num||this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};T.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};T.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(mi(e,r.generator)|Bt|(i?mr:0)),this.expect(d.parenL),r.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(r,"FunctionExpression")};T.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(mi(i,!1)|di),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,r),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(t,"ArrowFunctionExpression")};T.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==d.braceL,a=this.strict,s=!1;if(n)t.body=this.parseMaybeAssign(r),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!a||o)&&(s=this.strictDirective(this.end),s&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(t,!a&&!s&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,_r),t.body=this.parseBlock(!1,void 0,s&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()};T.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var r=i[e];if(r.type!=="Identifier")return!1}return!0};T.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,xi,e?null:i)}};T.parseExprList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(d.comma),e&&this.afterTrailingComma(t))break;var s=void 0;i&&this.type===d.comma?s=null:this.type===d.ellipsis?(s=this.parseSpread(r),r&&this.type===d.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):s=this.parseMaybeAssign(!1,r),n.push(s)}return n};T.checkUnreserved=function(t){var e=t.start,i=t.end,r=t.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Ft)&&r==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(e,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+r+"' is reserved"))}};T.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};T.parseIdentNode=function(){var t=this.startNode();return this.type===d.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=d.name):this.unexpected(),t};T.parsePrivateIdent=function(){var t=this.startNode();return this.type===d.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};T.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===d.semi||this.canInsertSemicolon()||this.type!==d.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(d.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};T.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var Rt=K.prototype;Rt.raise=function(t,e){var i=pr(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};Rt.raiseRecoverable=Rt.raise;Rt.curPosition=function(){if(this.options.locations)return new vt(this.curLine,this.pos-this.lineStart)};var Ke=K.prototype,Fn=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Ke.enterScope=function(t){this.scopeStack.push(new Fn(t))};Ke.exitScope=function(){this.scopeStack.pop()};Ke.treatFunctionsAsVarInScope=function(t){return t.flags&Ze||!this.inModule&&t.flags&Xe};Ke.declareName=function(t,e,i){var r=!1;if(e===Le){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&Xe&&delete this.undefinedExports[t]}else if(e===yr){var a=this.currentScope();a.lexical.push(t)}else if(e===gr){var s=this.currentScope();this.treatFunctionsAsVar?r=s.lexical.indexOf(t)>-1:r=s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(t)>-1&&!(l.flags&dr&&l.lexical[0]===t)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(t)>-1){r=!0;break}if(l.var.push(t),this.inModule&&l.flags&Xe&&delete this.undefinedExports[t],l.flags&Ft)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};Ke.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};Ke.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Ke.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(Ft|wt|Je))return e}};Ke.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(Ft|wt|Je)&&!(e.flags&di))return e}};var $t=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new jt(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},Et=K.prototype;Et.startNode=function(){return new $t(this,this.start,this.startLoc)};Et.startNodeAt=function(t,e){return new $t(this,t,e)};function wr(t,e,i,r){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=i),t}Et.finishNode=function(t,e){return wr.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};Et.finishNodeAt=function(t,e,i,r){return wr.call(this,t,e,i,r)};Et.copyNode=function(t){var e=new $t(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var Wn="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",Er="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",Sr=Er+" Extended_Pictographic",Nr=Sr,Cr=Nr+" EBase EComp EMod EPres ExtPict",Ir=Cr,$n=Ir,Un={9:Er,10:Sr,11:Nr,12:Cr,13:Ir,14:$n},qn="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",zn={9:"",10:"",11:"",12:"",13:"",14:qn},Ti="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",kr="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",Ar=kr+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Tr=Ar+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Pr=Tr+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Dr=Pr+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Kn=Dr+" "+Wn,Hn={9:kr,10:Ar,11:Tr,12:Pr,13:Dr,14:Kn},Rr={};function Gn(t){var e=Rr[t]={binary:qe(Un[t]+" "+Ti),binaryOfStrings:qe(zn[t]),nonBinary:{General_Category:qe(Ti),Script:qe(Hn[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Gt=0,Pi=[9,10,11,12,13,14];Gt<Pi.length;Gt+=1){var Yn=Pi[Gt];Gn(Yn)}var I=K.prototype,Mt=function(e,i){this.parent=e,this.base=i||this};Mt.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};Mt.prototype.sibling=function(){return new Mt(this.parent,this.base)};var Te=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Rr[e.options.ecmaVersion>=14?14:e.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};Te.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&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)};Te.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};Te.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var a=r.charCodeAt(e);if(!(i||this.switchU)||a<=55295||a>=57344||e+1>=n)return a;var s=r.charCodeAt(e+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a};Te.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var a=r.charCodeAt(e),s;return!(i||this.switchU)||a<=55295||a>=57344||e+1>=n||(s=r.charCodeAt(e+1))<56320||s>57343?e+1:e+2};Te.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};Te.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};Te.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};Te.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};Te.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,a=e;n<a.length;n+=1){var s=a[n],o=this.at(r,i);if(o===-1||o!==s)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};I.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,a=0;a<i.length;a++){var s=i.charAt(a);e.indexOf(s)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(s,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),s==="u"&&(r=!0),s==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function Qn(t){for(var e in t)return!0;return!1}I.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&Qn(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};I.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;e<i.length;e+=1){var r=i[e];t.groupNames[r]||t.raise("Invalid named capture referenced")}};I.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Mt(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};I.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};I.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};I.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!i,!0}return t.pos=e,!1};I.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};I.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};I.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};I.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};I.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};I.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(t),r=t.eat(45);if(i||r){for(var n=0;n<i.length;n++){var a=i.charAt(n);i.indexOf(a,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var s=this.regexp_eatModifiers(t);!i&&!s&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<s.length;o++){var l=s.charAt(o);(s.indexOf(l,o+1)>-1||i.indexOf(l)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};I.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};I.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&Xn(i);)e+=Oe(i),t.advance();return e};function Xn(t){return t===105||t===109||t===115}I.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};I.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};I.regexp_eatSyntaxCharacter=function(t){var e=t.current();return Mr(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Mr(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}I.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!Mr(i);)t.advance();return t.pos!==e};I.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};I.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,i=t.groupNames[t.lastStringValue];if(i)if(e)for(var r=0,n=i;r<n.length;r+=1){var a=n[r];a.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(i||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};I.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};I.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Oe(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Oe(t.lastIntValue);return!0}return!1};I.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Zn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Zn(t){return Ae(t,!0)||t===36||t===95}I.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Jn(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Jn(t){return ze(t,!0)||t===36||t===95||t===8204||t===8205}I.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};I.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var i=t.lastIntValue;if(t.switchU)return i>t.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1};I.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};I.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};I.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};I.regexp_eatZero=function(t){return t.current()===48&&!Ut(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};I.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};I.regexp_eatControlLetter=function(t){var e=t.current();return Or(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function Or(t){return t>=65&&t<=90||t>=97&&t<=122}I.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(s>=56320&&s<=57343)return t.lastIntValue=(n-55296)*1024+(s-56320)+65536,!0}t.pos=a,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&es(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function es(t){return t>=0&&t<=1114111}I.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};I.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var Vr=0,Ve=1,ye=2;I.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(ts(e))return t.lastIntValue=-1,t.advance(),Ve;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var r;if(t.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&r===ye&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return Vr};function ts(t){return t===100||t===68||t===115||t===83||t===119||t===87}I.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,r),Ve}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return Vr};I.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){ut(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};I.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Ve;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return ye;t.raise("Invalid property name")};I.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";Lr(e=t.current());)t.lastStringValue+=Oe(e),t.advance();return t.lastStringValue!==""};function Lr(t){return Or(t)||t===95}I.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";is(e=t.current());)t.lastStringValue+=Oe(e),t.advance();return t.lastStringValue!==""};function is(t){return Lr(t)||Ut(t)}I.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};I.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),i=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&i===ye&&t.raise("Negated character class may contain strings"),!0}return!1};I.regexp_classContents=function(t){return t.current()===93?Ve:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Ve)};I.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;t.switchU&&(e===-1||i===-1)&&t.raise("Invalid character class"),e!==-1&&i!==-1&&e>i&&t.raise("Range out of order in character class")}}};I.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var i=t.current();(i===99||Fr(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return r!==93?(t.lastIntValue=r,t.advance(),!0):!1};I.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};I.regexp_classSetExpression=function(t){var e=Ve,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===ye&&(e=ye);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==ye&&(e=Ve);continue}t.raise("Invalid character in character class")}if(r!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(r!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(i=this.regexp_eatClassSetOperand(t),!i)return e;i===ye&&(e=ye)}};I.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;return i!==-1&&r!==-1&&i>r&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};I.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Ve:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};I.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),r=this.regexp_classContents(t);if(t.eat(93))return i&&r===ye&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};I.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var i=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return i}else t.raise("Invalid escape");t.pos=e}return null};I.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===ye&&(e=ye);return e};I.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Ve:ye};I.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var i=t.current();return i<0||i===t.lookahead()&&rs(i)||ns(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function rs(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function ns(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}I.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return ss(e)?(t.lastIntValue=e,t.advance(),!0):!1};function ss(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}I.regexp_eatClassControlLetter=function(t){var e=t.current();return Ut(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};I.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};I.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Ut(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function Ut(t){return t>=48&&t<=57}I.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;jr(i=t.current());)t.lastIntValue=16*t.lastIntValue+Br(i),t.advance();return t.pos!==e};function jr(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Br(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}I.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var i=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+i*8+t.lastIntValue:t.lastIntValue=e*8+i}else t.lastIntValue=e;return!0}return!1};I.regexp_eatOctalDigit=function(t){var e=t.current();return Fr(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function Fr(t){return t>=48&&t<=55}I.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!jr(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+Br(n),t.advance()}return!0};var yi=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new jt(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},O=K.prototype;O.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new yi(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};O.getToken=function(){return this.next(),new yi(this)};typeof Symbol<"u"&&(O[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===d.eof,value:e}}}});O.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(d.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};O.readToken=function(t){return Ae(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};O.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};O.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};O.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=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,n=e;(r=cr(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};O.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!ht(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,i,this.curPosition())};O.skipSpace=function(){e:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){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(t>8&&t<14||t>=5760&&hr.test(String.fromCharCode(t)))++this.pos;else break e}}};O.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=t,this.value=e,this.updateContext(i)};O.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(d.ellipsis)):(++this.pos,this.finishToken(d.dot))};O.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(d.assign,2):this.finishOp(d.slash,1)};O.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?d.star:d.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=d.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(d.assign,i+1):this.finishOp(r,i)};O.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(d.assign,3)}return this.finishOp(t===124?d.logicalOR:d.logicalAND,2)}return e===61?this.finishOp(d.assign,2):this.finishOp(t===124?d.bitwiseOR:d.bitwiseAND,1)};O.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(d.assign,2):this.finishOp(d.bitwiseXOR,1)};O.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||le.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(d.incDec,2):e===61?this.finishOp(d.assign,2):this.finishOp(d.plusMin,1)};O.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),i=1;return e===t?(i=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(d.assign,i+1):this.finishOp(d.bitShift,i)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(i=2),this.finishOp(d.relational,i))};O.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(d.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(d.arrow)):this.finishOp(t===61?d.eq:d.prefix,1)};O.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(d.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(d.assign,3)}return this.finishOp(d.coalesce,2)}}return this.finishOp(d.question,1)};O.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Ae(e,!0)||e===92))return this.finishToken(d.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Oe(e)+"'")};O.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(d.parenL);case 41:return++this.pos,this.finishToken(d.parenR);case 59:return++this.pos,this.finishToken(d.semi);case 44:return++this.pos,this.finishToken(d.comma);case 91:return++this.pos,this.finishToken(d.bracketL);case 93:return++this.pos,this.finishToken(d.bracketR);case 123:return++this.pos,this.finishToken(d.braceL);case 125:return++this.pos,this.finishToken(d.braceR);case 58:return++this.pos,this.finishToken(d.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(d.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===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(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(d.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Oe(t)+"'")};O.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};O.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(le.test(r)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(r==="[")e=!0;else if(r==="]"&&e)e=!1;else if(r==="/"&&!e)break;t=r==="\\"}++this.pos}var n=this.input.slice(i,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Te(this));o.reset(i,n,s),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(n,s)}catch{}return this.finishToken(d.regexp,{pattern:n,flags:s,value:l})};O.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,o=0,l=0,c=e??1/0;l<c;++l,++this.pos){var h=this.input.charCodeAt(this.pos),p=void 0;if(r&&h===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),l===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=h;continue}if(h>=97?p=h-97+10:h>=65?p=h-65+10:h>=48&&h<=57?p=h-48:p=1/0,p>=t)break;o=h,s=s*t+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||e!=null&&this.pos-a!==e?null:s};function as(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function Wr(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}O.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var i=this.readInt(t);return i==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=Wr(this.input.slice(e,this.pos)),++this.pos):Ae(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,i)};O.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var i=this.pos-e>=2&&this.input.charCodeAt(e)===48;i&&this.strict&&this.raise(e,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&r===110){var n=Wr(this.input.slice(e,this.pos));return++this.pos,Ae(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,n)}i&&/[89]/.test(this.input.slice(e,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(e,"Invalid number")),Ae(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=as(this.input.slice(e,this.pos),i);return this.finishToken(d.num,a)};O.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else e=this.readHexChar(4);return e};O.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===t)break;r===92?(e+=this.input.slice(i,this.pos),e+=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)):(ht(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(d.string,e)};var $r={};O.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===$r)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};O.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw $r;this.raise(t,e)};O.readTmplToken=function(){for(var t="",e=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===d.template||this.type===d.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(d.dollarBraceL)):(++this.pos,this.finishToken(d.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(d.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(ht(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
22
|
+
`),cooked:this.value},this.next(),i.tail=this.type===d.backQuote,this.finishNode(i,"TemplateElement")};P.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:e});for(i.quasis=[r];!r.tail;)this.type===d.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(d.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(d.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};P.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===d.name||this.type===d.num||this.type===d.string||this.type===d.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===d.star)&&!ce.test(this.input.slice(this.lastTokEnd,this.start))};P.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(d.braceR);){if(r)r=!1;else if(this.expect(d.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(d.braceR))break;var a=this.parseProperty(t,e);t||this.checkPropClash(a,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};P.parseProperty=function(t,e){var i=this.startNode(),r,n,a,s;if(this.options.ecmaVersion>=9&&this.eat(d.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===d.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,e),this.type===d.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(t||e)&&(a=this.start,s=this.startLoc),t||(r=this.eat(d.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(d.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,a,s,e,o),this.finishNode(i,"Property")};P.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};P.parsePropertyValue=function(t,e,i,r,n,a,s,o){(i||r)&&this.type===d.colon&&this.unexpected(),this.eat(d.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),t.kind="init"):this.options.ecmaVersion>=6&&this.type===d.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==d.comma&&this.type!==d.braceR&&this.type!==d.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key)):this.type===d.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,a,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};P.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(d.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(d.bracketR),t.key;t.computed=!1}return t.key=this.type===d.num||this.type===d.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};P.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};P.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Si(e,r.generator)|Ht|(i?Dr:0)),this.expect(d.parenL),r.params=this.parseBindingList(d.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(r,"FunctionExpression")};P.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,a=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Si(i,!1)|vi),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,r),this.yieldPos=n,this.awaitPos=a,this.awaitIdentPos=s,this.finishNode(t,"ArrowFunctionExpression")};P.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==d.braceL,a=this.strict,s=!1;if(n)t.body=this.parseMaybeAssign(r),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!a||o)&&(s=this.strictDirective(this.end),s&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(t,!a&&!s&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,Vr),t.body=this.parseBlock(!1,void 0,s&&!a),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()};P.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var r=i[e];if(r.type!=="Identifier")return!1}return!0};P.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var a=n[r];this.checkLValInnerPattern(a,Ei,e?null:i)}};P.parseExprList=function(t,e,i,r){for(var n=[],a=!0;!this.eat(t);){if(a)a=!1;else if(this.expect(d.comma),e&&this.afterTrailingComma(t))break;var s=void 0;i&&this.type===d.comma?s=null:this.type===d.ellipsis?(s=this.parseSpread(r),r&&this.type===d.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):s=this.parseMaybeAssign(!1,r),n.push(s)}return n};P.checkUnreserved=function(t){var e=t.start,i=t.end,r=t.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Gt)&&r==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(e,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+r+"' is reserved"))}};P.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};P.parseIdentNode=function(){var t=this.startNode();return this.type===d.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=d.name):this.unexpected(),t};P.parsePrivateIdent=function(){var t=this.startNode();return this.type===d.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};P.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===d.semi||this.canInsertSemicolon()||this.type!==d.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(d.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};P.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var $t=G.prototype;$t.raise=function(t,e){var i=Ar(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};$t.raiseRecoverable=$t.raise;$t.curPosition=function(){if(this.options.locations)return new Ct(this.curLine,this.pos-this.lineStart)};var Ge=G.prototype,ls=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Ge.enterScope=function(t){this.scopeStack.push(new ls(t))};Ge.exitScope=function(){this.scopeStack.pop()};Ge.treatFunctionsAsVarInScope=function(t){return t.flags&et||!this.inModule&&t.flags&Je};Ge.declareName=function(t,e,i){var r=!1;if(e===je){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&Je&&delete this.undefinedExports[t]}else if(e===Or){var a=this.currentScope();a.lexical.push(t)}else if(e===Rr){var s=this.currentScope();this.treatFunctionsAsVar?r=s.lexical.indexOf(t)>-1:r=s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(t)>-1&&!(l.flags&Pr&&l.lexical[0]===t)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(t)>-1){r=!0;break}if(l.var.push(t),this.inModule&&l.flags&Je&&delete this.undefinedExports[t],l.flags&Gt)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};Ge.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};Ge.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};Ge.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(Gt|It|tt))return e}};Ge.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(Gt|It|tt)&&!(e.flags&vi))return e}};var Xt=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new Kt(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},kt=G.prototype;kt.startNode=function(){return new Xt(this,this.start,this.startLoc)};kt.startNodeAt=function(t,e){return new Xt(this,t,e)};function jr(t,e,i,r){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=i),t}kt.finishNode=function(t,e){return jr.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};kt.finishNodeAt=function(t,e,i,r){return jr.call(this,t,e,i,r)};kt.copyNode=function(t){var e=new Xt(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var cs="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",Fr="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",$r=Fr+" Extended_Pictographic",Wr=$r,Ur=Wr+" EBase EComp EMod EPres ExtPict",qr=Ur,hs=qr,us={9:Fr,10:$r,11:Wr,12:Ur,13:qr,14:hs},ps="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",fs={9:"",10:"",11:"",12:"",13:"",14:ps},Fi="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",zr="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",Kr=zr+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Hr=Kr+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Gr=Hr+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Yr=Gr+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",ds=Yr+" "+cs,ms={9:zr,10:Kr,11:Hr,12:Gr,13:Yr,14:ds},Xr={};function gs(t){var e=Xr[t]={binary:Ke(us[t]+" "+Fi),binaryOfStrings:Ke(fs[t]),nonBinary:{General_Category:Ke(Fi),Script:Ke(ms[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var ii=0,$i=[9,10,11,12,13,14];ii<$i.length;ii+=1){var ys=$i[ii];gs(ys)}var I=G.prototype,Wt=function(e,i){this.parent=e,this.base=i||this};Wt.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};Wt.prototype.sibling=function(){return new Wt(this.parent,this.base)};var De=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Xr[e.options.ecmaVersion>=14?14:e.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};De.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&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)};De.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};De.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var a=r.charCodeAt(e);if(!(i||this.switchU)||a<=55295||a>=57344||e+1>=n)return a;var s=r.charCodeAt(e+1);return s>=56320&&s<=57343?(a<<10)+s-56613888:a};De.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var a=r.charCodeAt(e),s;return!(i||this.switchU)||a<=55295||a>=57344||e+1>=n||(s=r.charCodeAt(e+1))<56320||s>57343?e+1:e+2};De.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};De.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};De.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};De.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};De.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,a=e;n<a.length;n+=1){var s=a[n],o=this.at(r,i);if(o===-1||o!==s)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};I.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,a=0;a<i.length;a++){var s=i.charAt(a);e.indexOf(s)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(s,a+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),s==="u"&&(r=!0),s==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function xs(t){for(var e in t)return!0;return!1}I.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&xs(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};I.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;e<i.length;e+=1){var r=i[e];t.groupNames[r]||t.raise("Invalid named capture referenced")}};I.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Wt(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};I.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};I.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};I.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!i,!0}return t.pos=e,!1};I.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};I.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};I.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};I.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};I.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};I.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(t),r=t.eat(45);if(i||r){for(var n=0;n<i.length;n++){var a=i.charAt(n);i.indexOf(a,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var s=this.regexp_eatModifiers(t);!i&&!s&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<s.length;o++){var l=s.charAt(o);(s.indexOf(l,o+1)>-1||i.indexOf(l)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};I.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};I.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&_s(i);)e+=Le(i),t.advance();return e};function _s(t){return t===105||t===109||t===115}I.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};I.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};I.regexp_eatSyntaxCharacter=function(t){var e=t.current();return Qr(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Qr(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}I.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!Qr(i);)t.advance();return t.pos!==e};I.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};I.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,i=t.groupNames[t.lastStringValue];if(i)if(e)for(var r=0,n=i;r<n.length;r+=1){var a=n[r];a.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(i||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};I.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};I.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Le(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Le(t.lastIntValue);return!0}return!1};I.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),bs(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function bs(t){return Te(t,!0)||t===36||t===95}I.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),ws(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function ws(t){return He(t,!0)||t===36||t===95||t===8204||t===8205}I.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};I.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var i=t.lastIntValue;if(t.switchU)return i>t.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1};I.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};I.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};I.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};I.regexp_eatZero=function(t){return t.current()===48&&!Qt(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};I.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};I.regexp_eatControlLetter=function(t){var e=t.current();return Zr(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function Zr(t){return t>=65&&t<=90||t>=97&&t<=122}I.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(s>=56320&&s<=57343)return t.lastIntValue=(n-55296)*1024+(s-56320)+65536,!0}t.pos=a,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&vs(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function vs(t){return t>=0&&t<=1114111}I.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};I.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var Jr=0,Be=1,xe=2;I.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(Ss(e))return t.lastIntValue=-1,t.advance(),Be;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var r;if(t.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&r===xe&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return Jr};function Ss(t){return t===100||t===68||t===115||t===83||t===119||t===87}I.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,r),Be}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return Jr};I.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){gt(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};I.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Be;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return xe;t.raise("Invalid property name")};I.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";en(e=t.current());)t.lastStringValue+=Le(e),t.advance();return t.lastStringValue!==""};function en(t){return Zr(t)||t===95}I.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";Es(e=t.current());)t.lastStringValue+=Le(e),t.advance();return t.lastStringValue!==""};function Es(t){return en(t)||Qt(t)}I.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};I.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),i=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&i===xe&&t.raise("Negated character class may contain strings"),!0}return!1};I.regexp_classContents=function(t){return t.current()===93?Be:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Be)};I.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;t.switchU&&(e===-1||i===-1)&&t.raise("Invalid character class"),e!==-1&&i!==-1&&e>i&&t.raise("Range out of order in character class")}}};I.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var i=t.current();(i===99||nn(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return r!==93?(t.lastIntValue=r,t.advance(),!0):!1};I.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};I.regexp_classSetExpression=function(t){var e=Be,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===xe&&(e=xe);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==xe&&(e=Be);continue}t.raise("Invalid character in character class")}if(r!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(r!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(i=this.regexp_eatClassSetOperand(t),!i)return e;i===xe&&(e=xe)}};I.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;return i!==-1&&r!==-1&&i>r&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};I.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Be:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};I.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),r=this.regexp_classContents(t);if(t.eat(93))return i&&r===xe&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};I.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var i=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return i}else t.raise("Invalid escape");t.pos=e}return null};I.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===xe&&(e=xe);return e};I.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Be:xe};I.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var i=t.current();return i<0||i===t.lookahead()&&Ns(i)||Cs(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function Ns(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function Cs(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}I.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return Is(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Is(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}I.regexp_eatClassControlLetter=function(t){var e=t.current();return Qt(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};I.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};I.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;Qt(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function Qt(t){return t>=48&&t<=57}I.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;tn(i=t.current());)t.lastIntValue=16*t.lastIntValue+rn(i),t.advance();return t.pos!==e};function tn(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function rn(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}I.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var i=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+i*8+t.lastIntValue:t.lastIntValue=e*8+i}else t.lastIntValue=e;return!0}return!1};I.regexp_eatOctalDigit=function(t){var e=t.current();return nn(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function nn(t){return t>=48&&t<=55}I.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!tn(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+rn(n),t.advance()}return!0};var Ci=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new Kt(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},O=G.prototype;O.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Ci(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};O.getToken=function(){return this.next(),new Ci(this)};typeof Symbol<"u"&&(O[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===d.eof,value:e}}}});O.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(d.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};O.readToken=function(t){return Te(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};O.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};O.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};O.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=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,n=e;(r=Cr(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};O.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!mt(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,i,this.curPosition())};O.skipSpace=function(){e:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){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(t>8&&t<14||t>=5760&&Ir.test(String.fromCharCode(t)))++this.pos;else break e}}};O.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=t,this.value=e,this.updateContext(i)};O.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(d.ellipsis)):(++this.pos,this.finishToken(d.dot))};O.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(d.assign,2):this.finishOp(d.slash,1)};O.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?d.star:d.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=d.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(d.assign,i+1):this.finishOp(r,i)};O.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(d.assign,3)}return this.finishOp(t===124?d.logicalOR:d.logicalAND,2)}return e===61?this.finishOp(d.assign,2):this.finishOp(t===124?d.bitwiseOR:d.bitwiseAND,1)};O.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(d.assign,2):this.finishOp(d.bitwiseXOR,1)};O.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||ce.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(d.incDec,2):e===61?this.finishOp(d.assign,2):this.finishOp(d.plusMin,1)};O.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),i=1;return e===t?(i=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(d.assign,i+1):this.finishOp(d.bitShift,i)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(i=2),this.finishOp(d.relational,i))};O.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(d.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(d.arrow)):this.finishOp(t===61?d.eq:d.prefix,1)};O.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(d.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(d.assign,3)}return this.finishOp(d.coalesce,2)}}return this.finishOp(d.question,1)};O.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Te(e,!0)||e===92))return this.finishToken(d.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Le(e)+"'")};O.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(d.parenL);case 41:return++this.pos,this.finishToken(d.parenR);case 59:return++this.pos,this.finishToken(d.semi);case 44:return++this.pos,this.finishToken(d.comma);case 91:return++this.pos,this.finishToken(d.bracketL);case 93:return++this.pos,this.finishToken(d.bracketR);case 123:return++this.pos,this.finishToken(d.braceL);case 125:return++this.pos,this.finishToken(d.braceR);case 58:return++this.pos,this.finishToken(d.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(d.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===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(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(d.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Le(t)+"'")};O.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};O.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(ce.test(r)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(r==="[")e=!0;else if(r==="]"&&e)e=!1;else if(r==="/"&&!e)break;t=r==="\\"}++this.pos}var n=this.input.slice(i,this.pos);++this.pos;var a=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new De(this));o.reset(i,n,s),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(n,s)}catch{}return this.finishToken(d.regexp,{pattern:n,flags:s,value:l})};O.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,a=this.pos,s=0,o=0,l=0,c=e??1/0;l<c;++l,++this.pos){var h=this.input.charCodeAt(this.pos),p=void 0;if(r&&h===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),l===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=h;continue}if(h>=97?p=h-97+10:h>=65?p=h-65+10:h>=48&&h<=57?p=h-48:p=1/0,p>=t)break;o=h,s=s*t+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||e!=null&&this.pos-a!==e?null:s};function ks(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function sn(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}O.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var i=this.readInt(t);return i==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=sn(this.input.slice(e,this.pos)),++this.pos):Te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,i)};O.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var i=this.pos-e>=2&&this.input.charCodeAt(e)===48;i&&this.strict&&this.raise(e,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&r===110){var n=sn(this.input.slice(e,this.pos));return++this.pos,Te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(d.num,n)}i&&/[89]/.test(this.input.slice(e,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(e,"Invalid number")),Te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=ks(this.input.slice(e,this.pos),i);return this.finishToken(d.num,a)};O.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else e=this.readHexChar(4);return e};O.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===t)break;r===92?(e+=this.input.slice(i,this.pos),e+=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)):(mt(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(d.string,e)};var an={};O.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===an)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};O.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw an;this.raise(t,e)};O.readTmplToken=function(){for(var t="",e=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===d.template||this.type===d.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(d.dollarBraceL)):(++this.pos,this.finishToken(d.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(d.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(mt(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
23
23
|
`;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};O.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(d.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
24
24
|
`&&++this.pos;case`
|
|
25
25
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};O.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
26
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return
|
|
27
|
-
`),a=n.length-1;if(t.write(n[0].trim()),a>0){t.write(r);for(let s=1;s<a;s++)t.write(i+n[s].trim()+r);t.write(i+n[a].trim())}}function
|
|
28
|
-
`,s):(t.write("/*"),hs(t,s.value,i,r),t.write("*/"+r))}}function us(t){let e=t;for(;e!=null;){const{type:i}=e;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")e=e.object;else return!1}}function Yt(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:n}=r;if(n>0){i.VariableDeclarator(r[0],t);for(let a=1;a<n;a++)t.write(", "),i.VariableDeclarator(r[a],t)}}let Di,Ri,Mi,Oi,Vi,Li;const _i={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:n}=e;n&&t.comments!=null&&re(e,t.comments,i,r);const a=t.body,{length:s}=a;for(let o=0;o<s;o++){const l=a[o];n&&l.comments!=null&&re(e,l.comments,i,r),e.write(i),this[l.type](l,e),e.write(r)}n&&t.trailingComments!=null&&re(e,t.trailingComments,i,r)},BlockStatement:Li=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;e.write("{");const s=t.body;if(s!=null&&s.length>0){e.write(r),n&&t.comments!=null&&re(e,t.comments,a,r);const{length:o}=s;for(let l=0;l<o;l++){const c=s[l];n&&c.comments!=null&&re(e,c.comments,a,r),e.write(a),this[c.type](c,e),e.write(r)}e.write(i)}else n&&t.comments!=null&&(e.write(r),re(e,t.comments,a,r),e.write(i));n&&t.trailingComments!=null&&re(e,t.trailingComments,a,r),e.write("}"),e.indentLevel--},ClassBody:Li,StaticBlock(t,e){e.write("static "),this.BlockStatement(t,e)},EmptyStatement(t,e){e.write(";")},ExpressionStatement(t,e){const i=e.expressionsPrecedence[t.expression.type];i===Se||i===3&&t.expression.left.type[0]==="O"?(e.write("("),this[t.expression.type](t.expression,e),e.write(")")):this[t.expression.type](t.expression,e),e.write(";")},IfStatement(t,e){e.write("if ("),this[t.test.type](t.test,e),e.write(") "),this[t.consequent.type](t.consequent,e),t.alternate!=null&&(e.write(" else "),this[t.alternate.type](t.alternate,e))},LabeledStatement(t,e){this[t.label.type](t.label,e),e.write(": "),this[t.body.type](t.body,e)},BreakStatement(t,e){e.write("break"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},ContinueStatement(t,e){e.write("continue"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},WithStatement(t,e){e.write("with ("),this[t.object.type](t.object,e),e.write(") "),this[t.body.type](t.body,e)},SwitchStatement(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e;e.indentLevel++;const a=i+e.indent,s=a+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:l}=o;for(let c=0;c<l;c++){const h=o[c];n&&h.comments!=null&&re(e,h.comments,a,r),h.test?(e.write(a+"case "),this[h.test.type](h.test,e),e.write(":"+r)):e.write(a+"default:"+r);const{consequent:p}=h,{length:u}=p;for(let f=0;f<u;f++){const m=p[f];n&&m.comments!=null&&re(e,m.comments,s,r),e.write(s),this[m.type](m,e),e.write(r)}}e.indentLevel-=2,e.write(i+"}")},ReturnStatement(t,e){e.write("return"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e)),e.write(";")},ThrowStatement(t,e){e.write("throw "),this[t.argument.type](t.argument,e),e.write(";")},TryStatement(t,e){if(e.write("try "),this[t.block.type](t.block,e),t.handler){const{handler:i}=t;i.param==null?e.write(" catch "):(e.write(" catch ("),this[i.param.type](i.param,e),e.write(") ")),this[i.body.type](i.body,e)}t.finalizer&&(e.write(" finally "),this[t.finalizer.type](t.finalizer,e))},WhileStatement(t,e){e.write("while ("),this[t.test.type](t.test,e),e.write(") "),this[t.body.type](t.body,e)},DoWhileStatement(t,e){e.write("do "),this[t.body.type](t.body,e),e.write(" while ("),this[t.test.type](t.test,e),e.write(");")},ForStatement(t,e){if(e.write("for ("),t.init!=null){const{init:i}=t;i.type[0]==="V"?Yt(e,i):this[i.type](i,e)}e.write("; "),t.test&&this[t.test.type](t.test,e),e.write("; "),t.update&&this[t.update.type](t.update,e),e.write(") "),this[t.body.type](t.body,e)},ForInStatement:Di=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?Yt(e,i):this[i.type](i,e),e.write(t.type[3]==="I"?" in ":" of "),this[t.right.type](t.right,e),e.write(") "),this[t.body.type](t.body,e)},ForOfStatement:Di,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:Ri=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),nt(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:Ri,VariableDeclaration(t,e){Yt(e,t),e.write(";")},VariableDeclarator(t,e){this[t.id.type](t.id,e),t.init!=null&&(e.write(" = "),this[t.init.type](t.init,e))},ClassDeclaration(t,e){if(e.write("class "+(t.id?`${t.id.name} `:""),t),t.superClass){e.write("extends ");const{superClass:i}=t,{type:r}=i,n=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(n===Se||n<e.expressionsPrecedence.ClassExpression)?(e.write("("),this[t.superClass.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ")}this.ClassBody(t.body,e)},ImportDeclaration(t,e){e.write("import ");const{specifiers:i,attributes:r}=t,{length:n}=i;let a=0;if(n>0){for(;a<n;){a>0&&e.write(", ");const s=i[a],o=s.type[6];if(o==="D")e.write(s.local.name,s),a++;else if(o==="N")e.write("* as "+s.local.name,s),a++;else break}if(a<n){for(e.write("{");;){const s=i[a],{name:o}=s.imported;if(e.write(o,s),o!==s.local.name&&e.write(" as "+s.local.name),++a<n)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let s=0;s<r.length;s++)this.ImportAttribute(r[s],e),s<r.length-1&&e.write(", ");e.write(" }")}e.write(";")},ImportAttribute(t,e){this.Identifier(t.key,e),e.write(": "),this.Literal(t.value,e)},ImportExpression(t,e){e.write("import("),this[t.source.type](t.source,e),e.write(")")},ExportDefaultDeclaration(t,e){e.write("export default "),this[t.declaration.type](t.declaration,e),e.expressionsPrecedence[t.declaration.type]!=null&&t.declaration.type[0]!=="F"&&e.write(";")},ExportNamedDeclaration(t,e){if(e.write("export "),t.declaration)this[t.declaration.type](t.declaration,e);else{e.write("{");const{specifiers:i}=t,{length:r}=i;if(r>0)for(let n=0;;){const a=i[n],{name:s}=a.local;if(e.write(s,a),s!==a.exported.name&&e.write(" as "+a.exported.name),++n<r)e.write(", ");else break}if(e.write("}"),t.source&&(e.write(" from "),this.Literal(t.source,e)),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let n=0;n<t.attributes.length;n++)this.ImportAttribute(t.attributes[n],e),n<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")}},ExportAllDeclaration(t,e){if(t.exported!=null?e.write("export * as "+t.exported.name+" from "):e.write("export * from "),this.Literal(t.source,e),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let i=0;i<t.attributes.length;i++)this.ImportAttribute(t.attributes[i],e),i<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")},MethodDefinition(t,e){t.static&&e.write("static ");const i=t.kind[0];(i==="g"||i==="s")&&e.write(t.kind+" "),t.value.async&&e.write("async "),t.value.generator&&e.write("*"),t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),nt(e,t.value.params),e.write(" "),this[t.value.body.type](t.value.body,e)},ClassExpression(t,e){this.ClassDeclaration(t,e)},ArrowFunctionExpression(t,e){e.write(t.async?"async ":"",t);const{params:i}=t;i!=null&&(i.length===1&&i[0].type[0]==="I"?e.write(i[0].name,i[0]):nt(e,t.params)),e.write(" => "),t.body.type[0]==="O"?(e.write("("),this.ObjectExpression(t.body,e),e.write(")")):this[t.body.type](t.body,e)},ThisExpression(t,e){e.write("this",t)},Super(t,e){e.write("super",t)},RestElement:Mi=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:Mi,YieldExpression(t,e){e.write(t.delegate?"yield*":"yield"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e))},AwaitExpression(t,e){e.write("await ",t),It(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:n}=r;for(let s=0;s<n;s++){const o=r[s],l=i[s];e.write(l.value.raw,l),e.write("${"),this[o.type](o,e),e.write("}")}const a=i[i.length-1];e.write(a.value.raw,a),e.write("`")},TemplateElement(t,e){e.write(t.value.raw,t)},TaggedTemplateExpression(t,e){It(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:Vi=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let n=0;;){const a=i[n];if(a!=null&&this[a.type](a,e),++n<r)e.write(", ");else{a==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:Vi,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),n&&t.comments!=null&&re(e,t.comments,a,r);const s=","+r,{properties:o}=t,{length:l}=o;for(let c=0;;){const h=o[c];if(n&&h.comments!=null&&re(e,h.comments,a,r),e.write(a),this[h.type](h,e),++c<l)e.write(s);else break}e.write(r),n&&t.trailingComments!=null&&re(e,t.trailingComments,a,r),e.write(i+"}")}else n?t.comments!=null?(e.write(r),re(e,t.comments,a,r),t.trailingComments!=null&&re(e,t.trailingComments,a,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),re(e,t.trailingComments,a,r),e.write(i+"}")):e.write("}"):e.write("}");e.indentLevel--},Property(t,e){t.method||t.kind[0]!=="i"?this.MethodDefinition(t,e):(t.shorthand||(t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),e.write(": ")),this[t.value.type](t.value,e))},PropertyDefinition(t,e){if(t.static&&e.write("static "),t.computed&&e.write("["),this[t.key.type](t.key,e),t.computed&&e.write("]"),t.value==null){t.key.type[0]!=="F"&&e.write(";");return}e.write(" = "),this[t.value.type](t.value,e),e.write(";")},ObjectPattern(t,e){if(e.write("{"),t.properties.length>0){const{properties:i}=t,{length:r}=i;for(let n=0;this[i[n].type](i[n],e),++n<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){nt(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:n}}=t;e.write(i);const a=qr(e,r,t);!a&&(i.length>1||n[0]==="U"&&(n[1]==="n"||n[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),a?(e.write(i.length>1?" (":"("),this[n](r,e),e.write(")")):this[n](r,e)}else this[t.argument.type](t.argument,e),e.write(t.operator)},UpdateExpression(t,e){t.prefix?(e.write(t.operator),this[t.argument.type](t.argument,e)):(this[t.argument.type](t.argument,e),e.write(t.operator))},AssignmentExpression(t,e){this[t.left.type](t.left,e),e.write(" "+t.operator+" "),this[t.right.type](t.right,e)},AssignmentPattern(t,e){this[t.left.type](t.left,e),e.write(" = "),this[t.right.type](t.right,e)},BinaryExpression:Oi=function(t,e){const i=t.operator==="in";i&&e.write("("),It(e,t.left,t,!1),e.write(" "+t.operator+" "),It(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:Oi,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===Se||r<=e.expressionsPrecedence.ConditionalExpression?(e.write("("),this[i.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ? "),this[t.consequent.type](t.consequent,e),e.write(" : "),this[t.alternate.type](t.alternate,e)},NewExpression(t,e){e.write("new ");const i=e.expressionsPrecedence[t.callee.type];i===Se||i<e.expressionsPrecedence.CallExpression||us(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),nt(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===Se||i<e.expressionsPrecedence.CallExpression?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),t.optional&&e.write("?."),nt(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===Se||i<e.expressionsPrecedence.MemberExpression?(e.write("("),this[t.object.type](t.object,e),e.write(")")):this[t.object.type](t.object,e),t.computed?(t.optional&&e.write("?."),e.write("["),this[t.property.type](t.property,e),e.write("]")):(t.optional?e.write("?."):e.write("."),this[t.property.type](t.property,e))},MetaProperty(t,e){e.write(t.meta.name+"."+t.property.name,t)},Identifier(t,e){e.write(t.name,t)},PrivateIdentifier(t,e){e.write(`#${t.name}`,t)},Literal(t,e){t.raw!=null?e.write(t.raw,t):t.regex!=null?this.RegExpLiteral(t,e):t.bigint!=null?e.write(t.bigint+"n",t):e.write(ls(t.value),t)},RegExpLiteral(t,e){const{regex:i}=t;e.write(`/${i.pattern}/${i.flags}`,t)}},ps={},fs=_i;class ds{constructor(e){const i=e??ps;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:_i,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:cs,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
26
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Le(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"),t){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=parseInt(r,8)),this.pos+=r.length-1,e=this.input.charCodeAt(this.pos),(r!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-r.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return mt(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};O.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};O.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(He(n,r))this.pos+=n<=65535?1:2;else if(n===92){this.containsEsc=!0,t+=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 s=this.readCodePoint();(e?Te:He)(s,r)||this.invalidStringToken(a,"Invalid Unicode escape"),t+=Le(s),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};O.readWord=function(){var t=this.readWord1(),e=d.name;return this.keywords.test(t)&&(e=bi[t]),this.finishToken(e,t)};var As="8.16.0";G.acorn={Parser:G,version:As,defaultOptions:li,Position:Ct,SourceLocation:Kt,getLineInfo:Ar,Node:Xt,TokenType:B,tokTypes:d,keywordTypes:bi,TokContext:Se,tokContexts:U,isIdentifierChar:He,isIdentifierStart:Te,Token:Ci,isNewLine:mt,lineBreak:ce,lineBreakG:Qn,nonASCIIwhitespace:Ir};function on(t,e){return G.parse(t,e)}const{stringify:Ts}=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 Dt={"||":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},Ee=17,Ps={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:Ee,ClassExpression:Ee,FunctionExpression:Ee,ObjectExpression:Ee,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function at(t,e){const{generator:i}=t;if(t.write("("),e!=null&&e.length>0){i[e[0].type](e[0],t);const{length:r}=e;for(let n=1;n<r;n++){const a=e[n];t.write(", "),i[a.type](a,t)}}t.write(")")}function ln(t,e,i,r){const n=t.expressionsPrecedence[e.type];if(n===Ee)return!0;const a=t.expressionsPrecedence[i.type];return n!==a?!r&&n===15&&a===14&&i.operator==="**"||n<a:n!==13&&n!==14?!1:e.operator==="**"&&i.operator==="**"?!r:n===13&&a===13&&(e.operator==="??"||i.operator==="??")?!0:r?Dt[e.operator]<=Dt[i.operator]:Dt[e.operator]<Dt[i.operator]}function Mt(t,e,i,r){const{generator:n}=t;ln(t,e,i,r)?(t.write("("),n[e.type](e,t),t.write(")")):n[e.type](e,t)}function Ds(t,e,i,r){const n=e.split(`
|
|
27
|
+
`),a=n.length-1;if(t.write(n[0].trim()),a>0){t.write(r);for(let s=1;s<a;s++)t.write(i+n[s].trim()+r);t.write(i+n[a].trim())}}function ne(t,e,i,r){const{length:n}=e;for(let a=0;a<n;a++){const s=e[a];t.write(i),s.type[0]==="L"?t.write("// "+s.value.trim()+`
|
|
28
|
+
`,s):(t.write("/*"),Ds(t,s.value,i,r),t.write("*/"+r))}}function Ms(t){let e=t;for(;e!=null;){const{type:i}=e;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")e=e.object;else return!1}}function ri(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:n}=r;if(n>0){i.VariableDeclarator(r[0],t);for(let a=1;a<n;a++)t.write(", "),i.VariableDeclarator(r[a],t)}}let Wi,Ui,qi,zi,Ki,Hi;const Ii={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:n}=e;n&&t.comments!=null&&ne(e,t.comments,i,r);const a=t.body,{length:s}=a;for(let o=0;o<s;o++){const l=a[o];n&&l.comments!=null&&ne(e,l.comments,i,r),e.write(i),this[l.type](l,e),e.write(r)}n&&t.trailingComments!=null&&ne(e,t.trailingComments,i,r)},BlockStatement:Hi=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;e.write("{");const s=t.body;if(s!=null&&s.length>0){e.write(r),n&&t.comments!=null&&ne(e,t.comments,a,r);const{length:o}=s;for(let l=0;l<o;l++){const c=s[l];n&&c.comments!=null&&ne(e,c.comments,a,r),e.write(a),this[c.type](c,e),e.write(r)}e.write(i)}else n&&t.comments!=null&&(e.write(r),ne(e,t.comments,a,r),e.write(i));n&&t.trailingComments!=null&&ne(e,t.trailingComments,a,r),e.write("}"),e.indentLevel--},ClassBody:Hi,StaticBlock(t,e){e.write("static "),this.BlockStatement(t,e)},EmptyStatement(t,e){e.write(";")},ExpressionStatement(t,e){const i=e.expressionsPrecedence[t.expression.type];i===Ee||i===3&&t.expression.left.type[0]==="O"?(e.write("("),this[t.expression.type](t.expression,e),e.write(")")):this[t.expression.type](t.expression,e),e.write(";")},IfStatement(t,e){e.write("if ("),this[t.test.type](t.test,e),e.write(") "),this[t.consequent.type](t.consequent,e),t.alternate!=null&&(e.write(" else "),this[t.alternate.type](t.alternate,e))},LabeledStatement(t,e){this[t.label.type](t.label,e),e.write(": "),this[t.body.type](t.body,e)},BreakStatement(t,e){e.write("break"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},ContinueStatement(t,e){e.write("continue"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},WithStatement(t,e){e.write("with ("),this[t.object.type](t.object,e),e.write(") "),this[t.body.type](t.body,e)},SwitchStatement(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e;e.indentLevel++;const a=i+e.indent,s=a+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:l}=o;for(let c=0;c<l;c++){const h=o[c];n&&h.comments!=null&&ne(e,h.comments,a,r),h.test?(e.write(a+"case "),this[h.test.type](h.test,e),e.write(":"+r)):e.write(a+"default:"+r);const{consequent:p}=h,{length:u}=p;for(let f=0;f<u;f++){const m=p[f];n&&m.comments!=null&&ne(e,m.comments,s,r),e.write(s),this[m.type](m,e),e.write(r)}}e.indentLevel-=2,e.write(i+"}")},ReturnStatement(t,e){e.write("return"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e)),e.write(";")},ThrowStatement(t,e){e.write("throw "),this[t.argument.type](t.argument,e),e.write(";")},TryStatement(t,e){if(e.write("try "),this[t.block.type](t.block,e),t.handler){const{handler:i}=t;i.param==null?e.write(" catch "):(e.write(" catch ("),this[i.param.type](i.param,e),e.write(") ")),this[i.body.type](i.body,e)}t.finalizer&&(e.write(" finally "),this[t.finalizer.type](t.finalizer,e))},WhileStatement(t,e){e.write("while ("),this[t.test.type](t.test,e),e.write(") "),this[t.body.type](t.body,e)},DoWhileStatement(t,e){e.write("do "),this[t.body.type](t.body,e),e.write(" while ("),this[t.test.type](t.test,e),e.write(");")},ForStatement(t,e){if(e.write("for ("),t.init!=null){const{init:i}=t;i.type[0]==="V"?ri(e,i):this[i.type](i,e)}e.write("; "),t.test&&this[t.test.type](t.test,e),e.write("; "),t.update&&this[t.update.type](t.update,e),e.write(") "),this[t.body.type](t.body,e)},ForInStatement:Wi=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?ri(e,i):this[i.type](i,e),e.write(t.type[3]==="I"?" in ":" of "),this[t.right.type](t.right,e),e.write(") "),this[t.body.type](t.body,e)},ForOfStatement:Wi,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:Ui=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),at(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:Ui,VariableDeclaration(t,e){ri(e,t),e.write(";")},VariableDeclarator(t,e){this[t.id.type](t.id,e),t.init!=null&&(e.write(" = "),this[t.init.type](t.init,e))},ClassDeclaration(t,e){if(e.write("class "+(t.id?`${t.id.name} `:""),t),t.superClass){e.write("extends ");const{superClass:i}=t,{type:r}=i,n=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(n===Ee||n<e.expressionsPrecedence.ClassExpression)?(e.write("("),this[t.superClass.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ")}this.ClassBody(t.body,e)},ImportDeclaration(t,e){e.write("import ");const{specifiers:i,attributes:r}=t,{length:n}=i;let a=0;if(n>0){for(;a<n;){a>0&&e.write(", ");const s=i[a],o=s.type[6];if(o==="D")e.write(s.local.name,s),a++;else if(o==="N")e.write("* as "+s.local.name,s),a++;else break}if(a<n){for(e.write("{");;){const s=i[a],{name:o}=s.imported;if(e.write(o,s),o!==s.local.name&&e.write(" as "+s.local.name),++a<n)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let s=0;s<r.length;s++)this.ImportAttribute(r[s],e),s<r.length-1&&e.write(", ");e.write(" }")}e.write(";")},ImportAttribute(t,e){this.Identifier(t.key,e),e.write(": "),this.Literal(t.value,e)},ImportExpression(t,e){e.write("import("),this[t.source.type](t.source,e),e.write(")")},ExportDefaultDeclaration(t,e){e.write("export default "),this[t.declaration.type](t.declaration,e),e.expressionsPrecedence[t.declaration.type]!=null&&t.declaration.type[0]!=="F"&&e.write(";")},ExportNamedDeclaration(t,e){if(e.write("export "),t.declaration)this[t.declaration.type](t.declaration,e);else{e.write("{");const{specifiers:i}=t,{length:r}=i;if(r>0)for(let n=0;;){const a=i[n],{name:s}=a.local;if(e.write(s,a),s!==a.exported.name&&e.write(" as "+a.exported.name),++n<r)e.write(", ");else break}if(e.write("}"),t.source&&(e.write(" from "),this.Literal(t.source,e)),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let n=0;n<t.attributes.length;n++)this.ImportAttribute(t.attributes[n],e),n<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")}},ExportAllDeclaration(t,e){if(t.exported!=null?e.write("export * as "+t.exported.name+" from "):e.write("export * from "),this.Literal(t.source,e),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let i=0;i<t.attributes.length;i++)this.ImportAttribute(t.attributes[i],e),i<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")},MethodDefinition(t,e){t.static&&e.write("static ");const i=t.kind[0];(i==="g"||i==="s")&&e.write(t.kind+" "),t.value.async&&e.write("async "),t.value.generator&&e.write("*"),t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),at(e,t.value.params),e.write(" "),this[t.value.body.type](t.value.body,e)},ClassExpression(t,e){this.ClassDeclaration(t,e)},ArrowFunctionExpression(t,e){e.write(t.async?"async ":"",t);const{params:i}=t;i!=null&&(i.length===1&&i[0].type[0]==="I"?e.write(i[0].name,i[0]):at(e,t.params)),e.write(" => "),t.body.type[0]==="O"?(e.write("("),this.ObjectExpression(t.body,e),e.write(")")):this[t.body.type](t.body,e)},ThisExpression(t,e){e.write("this",t)},Super(t,e){e.write("super",t)},RestElement:qi=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:qi,YieldExpression(t,e){e.write(t.delegate?"yield*":"yield"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e))},AwaitExpression(t,e){e.write("await ",t),Mt(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:n}=r;for(let s=0;s<n;s++){const o=r[s],l=i[s];e.write(l.value.raw,l),e.write("${"),this[o.type](o,e),e.write("}")}const a=i[i.length-1];e.write(a.value.raw,a),e.write("`")},TemplateElement(t,e){e.write(t.value.raw,t)},TaggedTemplateExpression(t,e){Mt(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:Ki=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let n=0;;){const a=i[n];if(a!=null&&this[a.type](a,e),++n<r)e.write(", ");else{a==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:Ki,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,a=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),n&&t.comments!=null&&ne(e,t.comments,a,r);const s=","+r,{properties:o}=t,{length:l}=o;for(let c=0;;){const h=o[c];if(n&&h.comments!=null&&ne(e,h.comments,a,r),e.write(a),this[h.type](h,e),++c<l)e.write(s);else break}e.write(r),n&&t.trailingComments!=null&&ne(e,t.trailingComments,a,r),e.write(i+"}")}else n?t.comments!=null?(e.write(r),ne(e,t.comments,a,r),t.trailingComments!=null&&ne(e,t.trailingComments,a,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),ne(e,t.trailingComments,a,r),e.write(i+"}")):e.write("}"):e.write("}");e.indentLevel--},Property(t,e){t.method||t.kind[0]!=="i"?this.MethodDefinition(t,e):(t.shorthand||(t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),e.write(": ")),this[t.value.type](t.value,e))},PropertyDefinition(t,e){if(t.static&&e.write("static "),t.computed&&e.write("["),this[t.key.type](t.key,e),t.computed&&e.write("]"),t.value==null){t.key.type[0]!=="F"&&e.write(";");return}e.write(" = "),this[t.value.type](t.value,e),e.write(";")},ObjectPattern(t,e){if(e.write("{"),t.properties.length>0){const{properties:i}=t,{length:r}=i;for(let n=0;this[i[n].type](i[n],e),++n<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){at(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:n}}=t;e.write(i);const a=ln(e,r,t);!a&&(i.length>1||n[0]==="U"&&(n[1]==="n"||n[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),a?(e.write(i.length>1?" (":"("),this[n](r,e),e.write(")")):this[n](r,e)}else this[t.argument.type](t.argument,e),e.write(t.operator)},UpdateExpression(t,e){t.prefix?(e.write(t.operator),this[t.argument.type](t.argument,e)):(this[t.argument.type](t.argument,e),e.write(t.operator))},AssignmentExpression(t,e){this[t.left.type](t.left,e),e.write(" "+t.operator+" "),this[t.right.type](t.right,e)},AssignmentPattern(t,e){this[t.left.type](t.left,e),e.write(" = "),this[t.right.type](t.right,e)},BinaryExpression:zi=function(t,e){const i=t.operator==="in";i&&e.write("("),Mt(e,t.left,t,!1),e.write(" "+t.operator+" "),Mt(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:zi,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===Ee||r<=e.expressionsPrecedence.ConditionalExpression?(e.write("("),this[i.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ? "),this[t.consequent.type](t.consequent,e),e.write(" : "),this[t.alternate.type](t.alternate,e)},NewExpression(t,e){e.write("new ");const i=e.expressionsPrecedence[t.callee.type];i===Ee||i<e.expressionsPrecedence.CallExpression||Ms(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),at(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===Ee||i<e.expressionsPrecedence.CallExpression?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),t.optional&&e.write("?."),at(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===Ee||i<e.expressionsPrecedence.MemberExpression?(e.write("("),this[t.object.type](t.object,e),e.write(")")):this[t.object.type](t.object,e),t.computed?(t.optional&&e.write("?."),e.write("["),this[t.property.type](t.property,e),e.write("]")):(t.optional?e.write("?."):e.write("."),this[t.property.type](t.property,e))},MetaProperty(t,e){e.write(t.meta.name+"."+t.property.name,t)},Identifier(t,e){e.write(t.name,t)},PrivateIdentifier(t,e){e.write(`#${t.name}`,t)},Literal(t,e){t.raw!=null?e.write(t.raw,t):t.regex!=null?this.RegExpLiteral(t,e):t.bigint!=null?e.write(t.bigint+"n",t):e.write(Ts(t.value),t)},RegExpLiteral(t,e){const{regex:i}=t;e.write(`/${i.pattern}/${i.flags}`,t)}},Rs={},Os=Ii;class Vs{constructor(e){const i=e??Rs;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Ii,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:Ps,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
29
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
30
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(e){this.output+=e}writeToStream(e){this.output.write(e)}writeAndMap(e,i){this.output+=e,this.map(e,i)}writeToStreamAndMap(e,i){this.output.write(e),this.map(e,i)}map(e,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:s}=this;s.original=i.loc.start,s.name=i.name,this.sourceMap.addMapping(s)}if(a[0]==="T"&&a[8]==="E"||a[0]==="L"&&a[1]==="i"&&typeof i.value=="string"){const{length:s}=e;let{column:o,line:l}=this;for(let c=0;c<s;c++)e[c]===`
|
|
31
|
-
`?(o=0,l++):o++;this.column=o,this.line=l;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function zr(t,e){const i=new ds(e);return i.generator[t.type](t,i),i.output}const ms=new Set(["Infinity","NaN","undefined","null","true","false"]),xs=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class gs{scopes=[];scopeTypes=[];scopeCounts=new Map;contextBoundVars=new Set;arrayPatternElements=new Set;rootParams=new Set;localSeriesVars=new Set;varKinds=new Map;loopVars=new Set;loopVarNames=new Map;paramIdCounter=0;cacheIdCounter=0;tempVarCounter=0;taCallIdCounter=0;userCallIdCounter=0;plotCallIdCounter=0;hoistingStack=[];suppressHoisting=!1;reservedNames=new Set;userFunctions=new Set;userMethods=new Set;get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}getNextUserCallId(){return{type:"Literal",value:`_fn${this.userCallIdCounter++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}constructor(){this.pushScope("glb")}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}addLocalSeriesVar(e){this.localSeriesVars.add(e)}removeLocalSeriesVar(e){this.localSeriesVars.delete(e)}isLocalSeriesVar(e){return this.localSeriesVars.has(e)}addContextBoundVar(e,i=!1){this.contextBoundVars.add(e),i&&this.rootParams.add(e)}removeContextBoundVar(e){this.contextBoundVars.has(e)&&(this.contextBoundVars.delete(e),this.rootParams.has(e)&&this.rootParams.delete(e))}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return ms.has(e)||xs.has(e)?!1:this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,i){this.loopVars.add(e),this.loopVarNames.set(e,i)}removeLoopVariable(e){this.loopVars.delete(e),this.loopVarNames.delete(e)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addReservedName(e){this.reservedNames.add(e)}addUserFunction(e){this.userFunctions.add(e)}isUserFunction(e){return this.userFunctions.has(e)}addUserMethod(e){this.userMethods.add(e)}isUserMethod(e){return this.userMethods.has(e)}addVariable(e,i){if(this.isContextBound(e))return e;const r=this.scopes[this.scopes.length-1],n=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(n)||1,s=`${n}${a}_${e}`;return r.set(e,s),this.varKinds.set(s,i),s}getVariable(e){if(this.loopVars.has(e)){const i=this.loopVarNames.get(e);if(i)return[i,"let"]}if(this.isContextBound(e))return[e,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(e)){const n=r.get(e),a=this.varKinds.get(n)||"let";return[n,a]}}return[e,"let"]}isVariableInFunctionScope(e){for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e)){for(let r=0;r<=i;r++)if(this.scopeTypes[r]==="fn")return!0;return!1}return!1}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(e){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(e)}addOuterHoistedStatement(e){if(this.hoistingStack.length>0&&!this.suppressHoisting){const i=Math.min(1,this.hoistingStack.length-1);this.hoistingStack[i].push(e)}}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}setSuppressHoisting(e){this.suppressHoisting=e}shouldSuppressHoisting(){return this.suppressHoisting}hasVariableInScope(e){if(this.reservedNames.has(e))return!0;for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e))return!0;return!!(this.contextBoundVars.has(e)||this.loopVars.has(e)||this.localSeriesVars.has(e))}generateParamId(){let e=`p${this.paramIdCounter++}`;for(;this.hasVariableInScope(e);)e=`p${this.paramIdCounter++}`;const i=this.scopes[this.scopes.length-1];return i&&i.set(e,e),e}}function Ue(t,e,i,r,n){i||(i=C),(function a(s,o,l){var c=l||s.type;Kr(i,c,s,o,a),e[c]&&e[c](s,o)})(t,r,n)}function ys(t,e,i,r,n){var a=[];i||(i=C),(function s(o,l,c){var h=c||o.type,p=o!==a[a.length-1];p&&a.push(o),Kr(i,h,o,l,s),e[h]&&e[h](o,l||a,a),p&&a.pop()})(t,r,n)}function Y(t,e,i,r,n){var a=i?_s(i,r||void 0):r;(function s(o,l,c){a[c||o.type](o,l,s)})(t,e,n)}function _s(t,e){var i=Object.create(e||C);for(var r in t)i[r]=t[r];return i}function bi(t,e,i){i(t,e)}function et(t,e,i){}function Kr(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var C={};C.Program=C.BlockStatement=C.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};C.Statement=bi;C.EmptyStatement=et;C.ExpressionStatement=C.ParenthesizedExpression=C.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};C.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};C.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};C.BreakStatement=C.ContinueStatement=et;C.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};C.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var a=n[r];i(a,e)}};C.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};C.ReturnStatement=C.YieldExpression=C.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};C.ThrowStatement=C.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};C.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};C.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};C.WhileStatement=C.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};C.ForStatement=function(t,e,i){t.init&&i(t.init,e,"ForInit"),t.test&&i(t.test,e,"Expression"),t.update&&i(t.update,e,"Expression"),i(t.body,e,"Statement")};C.ForInStatement=C.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};C.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};C.DebuggerStatement=et;C.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};C.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var a=n[r];i(a,e)}};C.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};C.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var a=n[r];i(a,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};C.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};C.VariablePattern=et;C.MemberPattern=bi;C.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};C.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Pattern")}};C.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];a.type==="Property"?(a.computed&&i(a.key,e,"Expression"),i(a.value,e,"Pattern")):a.type==="RestElement"&&i(a.argument,e,"Pattern")}};C.Expression=bi;C.ThisExpression=C.Super=C.MetaProperty=et;C.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Expression")}};C.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];i(a,e)}};C.FunctionExpression=C.ArrowFunctionExpression=C.FunctionDeclaration;C.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};C.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var a=n[r];i(a,e)}for(var s=0,o=t.expressions;s<o.length;s+=1){var l=o[s];i(l,e,"Expression")}};C.TemplateElement=et;C.UnaryExpression=C.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};C.BinaryExpression=C.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};C.AssignmentExpression=C.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};C.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};C.NewExpression=C.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};C.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};C.ExportNamedDeclaration=C.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};C.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};C.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};C.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var a=n[r];i(a,e)}if(i(t.source,e,"Expression"),t.attributes)for(var s=0,o=t.attributes;s<o.length;s+=1){var l=o[s];i(l,e)}};C.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};C.ImportSpecifier=C.ImportDefaultSpecifier=C.ImportNamespaceSpecifier=C.Identifier=C.PrivateIdentifier=C.Literal=et;C.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};C.ClassDeclaration=C.ClassExpression=function(t,e,i){return i(t,e,"Class")};C.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};C.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e)}};C.MethodDefinition=C.PropertyDefinition=C.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const z="$",E={createIdentifier(t){return{type:"Identifier",name:t}},createLiteral(t){return{type:"Literal",value:t}},createMemberExpression(t,e,i=!1){return{type:"MemberExpression",object:t,property:e,computed:i}},createContextIdentifier(){return this.createIdentifier("$")},createLocalContextIdentifier(){return this.createIdentifier("$$")},createContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createDynamicContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),e,!0)},createContextVariableAccess0(t,e){const i=this.createContextVariableReference(t,e);return this.createGetCall(i,0)},createDynamicContextVariableAccess0(t,e){const i=this.createDynamicContextVariableReference(t,e);return this.createGetCall(i,0)},createArrayAccess(t,e){const i=typeof e=="number"?this.createLiteral(e):e;return this.createMemberExpression(t,i,!0)},createCallExpression(t,e){return{type:"CallExpression",callee:t,arguments:e}},createAssignmentExpression(t,e,i="="){return{type:"AssignmentExpression",operator:i,left:t,right:e}},createExpressionStatement(t){return{type:"ExpressionStatement",expression:t}},createInitCall(t,e,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},createInitVarCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[t,e];return this.createCallExpression(i,r)},createGetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof e=="number"?this.createLiteral(e):e;return this.createCallExpression(i,[t,r])},createSetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[t,e])},createMathEqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[t,e])},createMathNeqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__neq"),!1);return this.createCallExpression(n,[t,e])},createWrapperFunction(t){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}},createVariableDeclaration(t,e){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(t),init:e}]}},createAwaitExpression(t){return{type:"AwaitExpression",argument:t}}},ft=["ta","math","request","array","input","color"],je=["hline","plot","fill","label","line","na","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],bs=["request.security","request.security_lower_tf"],vs=["line.new","line.copy","label.new","label.copy","polyline.new","box.new","box.copy","table.new","linefill.new"],Hr=["open","high","low","close","volume","hl2","hlc3","ohlc4","hlcc4","openTime","closeTime"],vi=[...ft,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","strategy","library","alertcondition","alert","error","max_bars_back","fixnan","na","nz","timestamp","str","box","line","label","table","chart","linefill","polyline","map","matrix","log","Type","bool","int","float","string","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font","extend","position","barmerge","adjustment","backadjustment","earnings","dividends","splits"],ws=["na","nz","plot","plotchar","color","hline","fill"];function Es(t){let e=null,i=z;if(t.type==="Program"&&t.body.length>0){const f=t.body[0];if(f.type==="ExpressionStatement"&&(f.expression.type==="ArrowFunctionExpression"||f.expression.type==="FunctionExpression")){const m=f.expression;m.body.type==="BlockStatement"&&(e=m.body.body,m.params.length>0&&m.params[0].type==="Identifier"&&(i=m.params[0].name))}}if(!e)return;const r=new Set,n=new Set,a=f=>{f.type==="Identifier"?r.add(f.name):f.type==="ObjectPattern"?f.properties.forEach(m=>a(m.value)):f.type==="ArrayPattern"&&f.elements.forEach(m=>{m&&a(m)})};Y(t,{},{VariableDeclarator(f,m,y){a(f.id),f.init&&y(f.init,m)},FunctionDeclaration(f,m,y){a(f.id),y(f.body,m)},Identifier(f,m,y){n.add(f.name)},MemberExpression(f,m,y){y(f.object,m),f.computed&&y(f.property,m)},Property(f,m,y){f.computed&&y(f.key,m),y(f.value,m)}}),e.forEach(f=>{f.type==="VariableDeclaration"?f.declarations.forEach(m=>a(m.id)):f.type==="FunctionDeclaration"&&a(f.id)});const s=Hr,o=vi,l=s.filter(f=>!r.has(f)),c=o.filter(f=>!r.has(f)),h=l.filter(f=>n.has(f)),p=c.filter(f=>n.has(f)),u=[];h.length>0&&u.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:h.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&u.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),u.length>0&&e.unshift(...u)}function Ss(t){let e=null,i=z;if(t.type==="Program"&&t.body.length>0){const o=t.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const l=o.expression;l.body.type==="BlockStatement"&&(e=l.body.body,l.params.length>0&&l.params[0].type==="Identifier"&&(i=l.params[0].name))}}if(!e)return;const r=new Set(Hr),n=new Set(vi),a=new Set(ws),s=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(l=>{if(l.init&&l.init.type==="MemberExpression"&&l.init.object.type==="Identifier"&&l.init.object.name===i&&l.init.property.type==="Identifier"){const c=l.init.property.name;let h=null;if(c==="data"?h=r:c==="pine"?h=n:c==="core"&&(h=a),h&&l.id.type==="ObjectPattern")l.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const u=p.key.name,f=p.value.name;h.has(u)&&u!==f&&(s.set(f,u),p.value.name=u,p.shorthand=!0)}});else if(l.id.type==="Identifier"&&ft.includes(c)){const p=c,u=l.id.name;p!==u&&(s.set(u,p),l.id.name=p)}}})}),s.size>0&&Y(t,{},{Identifier(o){s.has(o.name)&&(o.name=s.get(o.name))},MemberExpression(o,l,c){c(o.object,l),o.computed&&c(o.property,l)},Property(o,l,c){o.computed&&c(o.key,l),c(o.value,l)}})}function Ns(t){try{const e=Ur(t,{ecmaVersion:"latest",sourceType:"module"});if(e.type==="Program"&&e.body.length===1){const i=e.body[0];if(i.type==="ExpressionStatement"){const r=i.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return{isWrapped:!0,isAsync:r.async||!1,functionNode:r}}if(i.type==="FunctionDeclaration")return{isWrapped:!0,isAsync:i.async||!1,functionNode:i}}return{isWrapped:!1,isAsync:!1}}catch{return{isWrapped:!1,isAsync:!1}}}function Cs(t){return t.async=!0,zr(t)}function Is(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=Ns(t);return e&&r?i?t:Cs(r):`async (context) => {
|
|
31
|
+
`?(o=0,l++):o++;this.column=o,this.line=l;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function cn(t,e){const i=new Vs(e);return i.generator[t.type](t,i),i.output}const Ls=new Set(["Infinity","NaN","undefined","null","true","false"]),Bs=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class js{scopes=[];scopeTypes=[];scopeCounts=new Map;contextBoundVars=new Set;arrayPatternElements=new Set;rootParams=new Set;localSeriesVars=new Set;varKinds=new Map;loopVars=new Set;loopVarNames=new Map;paramIdCounter=0;cacheIdCounter=0;tempVarCounter=0;taCallIdCounter=0;userCallIdCounter=0;plotCallIdCounter=0;loopGuardCounter=0;hoistingStack=[];suppressHoisting=!1;reservedNames=new Set;userFunctions=new Set;userMethods=new Set;get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}getNextUserCallId(){return{type:"Literal",value:`_fn${this.userCallIdCounter++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}getNextLoopGuardName(){return`__lg${this.loopGuardCounter++}`}constructor(){this.pushScope("glb")}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}addLocalSeriesVar(e){this.localSeriesVars.add(e)}removeLocalSeriesVar(e){this.localSeriesVars.delete(e)}isLocalSeriesVar(e){return this.localSeriesVars.has(e)}addContextBoundVar(e,i=!1){this.contextBoundVars.add(e),i&&this.rootParams.add(e)}removeContextBoundVar(e){this.contextBoundVars.has(e)&&(this.contextBoundVars.delete(e),this.rootParams.has(e)&&this.rootParams.delete(e))}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return Ls.has(e)||Bs.has(e)?!1:this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,i){this.loopVars.add(e),this.loopVarNames.set(e,i)}removeLoopVariable(e){this.loopVars.delete(e),this.loopVarNames.delete(e)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addReservedName(e){this.reservedNames.add(e)}addUserFunction(e){this.userFunctions.add(e)}isUserFunction(e){return this.userFunctions.has(e)}addUserMethod(e){this.userMethods.add(e)}isUserMethod(e){return this.userMethods.has(e)}addVariable(e,i){if(this.isContextBound(e))return e;const r=this.scopes[this.scopes.length-1],n=this.scopeTypes[this.scopeTypes.length-1],a=this.scopeCounts.get(n)||1,s=`${n}${a}_${e}`;return r.set(e,s),this.varKinds.set(s,i),s}getVariable(e){if(this.loopVars.has(e)){const i=this.loopVarNames.get(e);if(i)return[i,"let"]}if(this.isContextBound(e))return[e,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(e)){const n=r.get(e),a=this.varKinds.get(n)||"let";return[n,a]}}return[e,"let"]}isVariableInFunctionScope(e){for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e)){for(let r=0;r<=i;r++)if(this.scopeTypes[r]==="fn")return!0;return!1}return!1}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(e){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(e)}addOuterHoistedStatement(e){if(this.hoistingStack.length>0&&!this.suppressHoisting){const i=Math.min(1,this.hoistingStack.length-1);this.hoistingStack[i].push(e)}}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}setSuppressHoisting(e){this.suppressHoisting=e}shouldSuppressHoisting(){return this.suppressHoisting}hasVariableInScope(e){if(this.reservedNames.has(e))return!0;for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e))return!0;return!!(this.contextBoundVars.has(e)||this.loopVars.has(e)||this.localSeriesVars.has(e))}generateParamId(){let e=`p${this.paramIdCounter++}`;for(;this.hasVariableInScope(e);)e=`p${this.paramIdCounter++}`;const i=this.scopes[this.scopes.length-1];return i&&i.set(e,e),e}}function ze(t,e,i,r,n){i||(i=N),(function a(s,o,l){var c=l||s.type;hn(i,c,s,o,a),e[c]&&e[c](s,o)})(t,r,n)}function Fs(t,e,i,r,n){var a=[];i||(i=N),(function s(o,l,c){var h=c||o.type,p=o!==a[a.length-1];p&&a.push(o),hn(i,h,o,l,s),e[h]&&e[h](o,l||a,a),p&&a.pop()})(t,r,n)}function H(t,e,i,r,n){var a=i?$s(i,r||void 0):r;(function s(o,l,c){a[c||o.type](o,l,s)})(t,e,n)}function $s(t,e){var i=Object.create(e||N);for(var r in t)i[r]=t[r];return i}function ki(t,e,i){i(t,e)}function it(t,e,i){}function hn(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var N={};N.Program=N.BlockStatement=N.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};N.Statement=ki;N.EmptyStatement=it;N.ExpressionStatement=N.ParenthesizedExpression=N.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};N.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};N.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};N.BreakStatement=N.ContinueStatement=it;N.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};N.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var a=n[r];i(a,e)}};N.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var a=n[r];i(a,e,"Statement")}};N.ReturnStatement=N.YieldExpression=N.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};N.ThrowStatement=N.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};N.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};N.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};N.WhileStatement=N.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};N.ForStatement=function(t,e,i){t.init&&i(t.init,e,"ForInit"),t.test&&i(t.test,e,"Expression"),t.update&&i(t.update,e,"Expression"),i(t.body,e,"Statement")};N.ForInStatement=N.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};N.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};N.DebuggerStatement=it;N.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};N.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var a=n[r];i(a,e)}};N.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};N.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var a=n[r];i(a,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};N.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};N.VariablePattern=it;N.MemberPattern=ki;N.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};N.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Pattern")}};N.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];a.type==="Property"?(a.computed&&i(a.key,e,"Expression"),i(a.value,e,"Pattern")):a.type==="RestElement"&&i(a.argument,e,"Pattern")}};N.Expression=ki;N.ThisExpression=N.Super=N.MetaProperty=it;N.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var a=n[r];a&&i(a,e,"Expression")}};N.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var a=n[r];i(a,e)}};N.FunctionExpression=N.ArrowFunctionExpression=N.FunctionDeclaration;N.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};N.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var a=n[r];i(a,e)}for(var s=0,o=t.expressions;s<o.length;s+=1){var l=o[s];i(l,e,"Expression")}};N.TemplateElement=it;N.UnaryExpression=N.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};N.BinaryExpression=N.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};N.AssignmentExpression=N.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};N.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};N.NewExpression=N.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var a=n[r];i(a,e,"Expression")}};N.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};N.ExportNamedDeclaration=N.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};N.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var a=n[r];i(a,e)}};N.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};N.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var a=n[r];i(a,e)}if(i(t.source,e,"Expression"),t.attributes)for(var s=0,o=t.attributes;s<o.length;s+=1){var l=o[s];i(l,e)}};N.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};N.ImportSpecifier=N.ImportDefaultSpecifier=N.ImportNamespaceSpecifier=N.Identifier=N.PrivateIdentifier=N.Literal=it;N.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};N.ClassDeclaration=N.ClassExpression=function(t,e,i){return i(t,e,"Class")};N.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};N.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var a=n[r];i(a,e)}};N.MethodDefinition=N.PropertyDefinition=N.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const z="$",S={createIdentifier(t){return{type:"Identifier",name:t}},createLiteral(t){return{type:"Literal",value:t}},createMemberExpression(t,e,i=!1){return{type:"MemberExpression",object:t,property:e,computed:i}},createContextIdentifier(){return this.createIdentifier("$")},createLocalContextIdentifier(){return this.createIdentifier("$$")},createContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createDynamicContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),e,!0)},createContextVariableAccess0(t,e){const i=this.createContextVariableReference(t,e);return this.createGetCall(i,0)},createDynamicContextVariableAccess0(t,e){const i=this.createDynamicContextVariableReference(t,e);return this.createGetCall(i,0)},createArrayAccess(t,e){const i=typeof e=="number"?this.createLiteral(e):e;return this.createMemberExpression(t,i,!0)},createCallExpression(t,e){return{type:"CallExpression",callee:t,arguments:e}},createAssignmentExpression(t,e,i="="){return{type:"AssignmentExpression",operator:i,left:t,right:e}},createExpressionStatement(t){return{type:"ExpressionStatement",expression:t}},createInitCall(t,e,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},createInitVarCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[t,e];return this.createCallExpression(i,r)},createGetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof e=="number"?this.createLiteral(e):e;return this.createCallExpression(i,[t,r])},createSetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[t,e])},createMathEqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[t,e])},createMathNeqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__neq"),!1);return this.createCallExpression(n,[t,e])},createWrapperFunction(t){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}},createVariableDeclaration(t,e){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(t),init:e}]}},createAwaitExpression(t){return{type:"AwaitExpression",argument:t}}},xt=["ta","math","request","array","input","color"],Fe=["hline","plot","fill","label","line","na","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],Ws=["request.security","request.security_lower_tf"],Us=["line.new","line.copy","label.new","label.copy","polyline.new","box.new","box.copy","table.new","linefill.new"],un=["open","high","low","close","volume","hl2","hlc3","ohlc4","hlcc4","openTime","closeTime"],Ai=[...xt,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","strategy","library","alertcondition","alert","error","max_bars_back","fixnan","na","nz","timestamp","str","box","line","label","table","chart","linefill","polyline","map","matrix","log","Type","bool","int","float","string","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font","extend","position","barmerge","adjustment","backadjustment","earnings","dividends","splits"],qs=["na","nz","plot","plotchar","color","hline","fill"];function zs(t){let e=null,i=z;if(t.type==="Program"&&t.body.length>0){const f=t.body[0];if(f.type==="ExpressionStatement"&&(f.expression.type==="ArrowFunctionExpression"||f.expression.type==="FunctionExpression")){const m=f.expression;m.body.type==="BlockStatement"&&(e=m.body.body,m.params.length>0&&m.params[0].type==="Identifier"&&(i=m.params[0].name))}}if(!e)return;const r=new Set,n=new Set,a=f=>{f.type==="Identifier"?r.add(f.name):f.type==="ObjectPattern"?f.properties.forEach(m=>a(m.value)):f.type==="ArrayPattern"&&f.elements.forEach(m=>{m&&a(m)})};H(t,{},{VariableDeclarator(f,m,x){a(f.id),f.init&&x(f.init,m)},FunctionDeclaration(f,m,x){a(f.id),x(f.body,m)},Identifier(f,m,x){n.add(f.name)},MemberExpression(f,m,x){x(f.object,m),f.computed&&x(f.property,m)},Property(f,m,x){f.computed&&x(f.key,m),x(f.value,m)}}),e.forEach(f=>{f.type==="VariableDeclaration"?f.declarations.forEach(m=>a(m.id)):f.type==="FunctionDeclaration"&&a(f.id)});const s=un,o=Ai,l=s.filter(f=>!r.has(f)),c=o.filter(f=>!r.has(f)),h=l.filter(f=>n.has(f)),p=c.filter(f=>n.has(f)),u=[];h.length>0&&u.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:h.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&u.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),u.length>0&&e.unshift(...u)}function Ks(t){let e=null,i=z;if(t.type==="Program"&&t.body.length>0){const o=t.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const l=o.expression;l.body.type==="BlockStatement"&&(e=l.body.body,l.params.length>0&&l.params[0].type==="Identifier"&&(i=l.params[0].name))}}if(!e)return;const r=new Set(un),n=new Set(Ai),a=new Set(qs),s=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(l=>{if(l.init&&l.init.type==="MemberExpression"&&l.init.object.type==="Identifier"&&l.init.object.name===i&&l.init.property.type==="Identifier"){const c=l.init.property.name;let h=null;if(c==="data"?h=r:c==="pine"?h=n:c==="core"&&(h=a),h&&l.id.type==="ObjectPattern")l.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const u=p.key.name,f=p.value.name;h.has(u)&&u!==f&&(s.set(f,u),p.value.name=u,p.shorthand=!0)}});else if(l.id.type==="Identifier"&&xt.includes(c)){const p=c,u=l.id.name;p!==u&&(s.set(u,p),l.id.name=p)}}})}),s.size>0&&H(t,{},{Identifier(o){s.has(o.name)&&(o.name=s.get(o.name))},MemberExpression(o,l,c){c(o.object,l),o.computed&&c(o.property,l)},Property(o,l,c){o.computed&&c(o.key,l),c(o.value,l)}})}function Hs(t){try{const e=on(t,{ecmaVersion:"latest",sourceType:"module"});if(e.type==="Program"&&e.body.length===1){const i=e.body[0];if(i.type==="ExpressionStatement"){const r=i.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return{isWrapped:!0,isAsync:r.async||!1,functionNode:r}}if(i.type==="FunctionDeclaration")return{isWrapped:!0,isAsync:i.async||!1,functionNode:i}}return{isWrapped:!1,isAsync:!1}}catch{return{isWrapped:!1,isAsync:!1}}}function Gs(t){return t.async=!0,cn(t)}function Ys(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=Hs(t);return e&&r?i?t:Gs(r):`async (context) => {
|
|
32
32
|
${t}
|
|
33
|
-
}`}function ks(t){Y(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const a={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,a)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function As(t,e){Ue(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===z||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===z||r.init.object.object.name==="context2");(n||a)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(s=>{s.key.name&&e.addContextBoundVar(s.key.name)}))})}})}function Ts(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function Ps(t,e){let i;return ys(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name))},ExpressionStatement(r){const n=r.expression;n&&n.type==="AssignmentExpression"&&n.operator==="="&&n.left?.type==="MemberExpression"&&n.left.property?.name==="__pineMethod__"&&n.left.object?.type==="Identifier"&&n.right?.value===!0&&e.addUserMethod(n.left.object.name)},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=z),Ts(r,e,n)},VariableDeclaration(r,n){const a=n.length>1?n[n.length-2]:null,s=a&&(a.type==="ForOfStatement"||a.type==="ForInStatement")&&a.left===r;r.declarations.forEach(o=>{if(o.id.type==="Identifier")e.addReservedName(o.id.name);else if(o.id.type==="ObjectPattern")o.id.properties.forEach(l=>{l.key&&l.key.type==="Identifier"&&e.addReservedName(l.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(u=>{u&&u.type==="Identifier"&&e.addReservedName(u.name)}),s)return;const l=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:l},init:o.init}]},h=c.declarations[0].init;h&&h.type==="CallExpression"&&(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&Ue(h.callee.body,{ReturnStatement(u){u.argument&&u.argument.type==="ArrayExpression"&&(u.argument={type:"ArrayExpression",elements:[u.argument]})}}),o.id.elements?.forEach(u=>{u.type==="Identifier"&&e.addArrayPatternElement(u.name)});const p=o.id.elements.map((u,f)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:u,init:{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Literal",value:f},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...p]})}})},ForStatement(r){}}),i}const ni={type:"Identifier",name:"undefined"};function Z(t,e){const[i,r]=e.getVariable(t);if((i.match(/^fn\d+_/)||e.isVariableInFunctionScope(t))&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return E.createLocalContextVariableReference(r,i)}return E.createContextVariableReference(r,i)}function Gr(t,e){const i=Z(t,e);return E.createGetCall(i,0)}function tt(t,e){if(t.computed&&t.property.type==="Identifier"){if(e.isLoopVariable(t.property.name)){if(t.object.type==="Identifier"&&!e.isLoopVariable(t.object.name)){if(e.isLocalSeriesVar(t.object.name)){const i=E.createIdentifier(t.object.name);i._skipTransformation=!0;const r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=Z(t.object.name,e),r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}e.isContextBound(t.property.name)||(t.property=Z(t.property.name,e),t.property=E.createGetCall(t.property,0))}if(t.computed&&t.object.type==="Identifier"){if(e.isLoopVariable(t.object.name))return;if(e.isLocalSeriesVar(t.object.name)){const i=E.createIdentifier(t.object.name);i._skipTransformation=!0;const r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=Z(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(tt(i,e),i._indexTransformed=!0)}}t.computed&&t.property.type!=="Identifier"&&t.property.type!=="MemberExpression"&&!t._indexTransformed&&(t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression")&&(t.property=ke(t.property,e))}function pe(t,e){const i=E.createGetCall(E.createIdentifier(t.name),0);t.start!==void 0&&(i.start=t.start),t.end!==void 0&&(i.end=t.end),i._indexTransformed=!0,Object.assign(t,i)}function Q(t,e){if(!t._skipTransformation&&t.name!==z){if(je.includes(t.name)&&e.isContextBound(t.name)){const u=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,f=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!u&&!f){const m={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},y=E.createGetCall(m,0);Object.assign(t,y),delete t.name;return}}if(t.name==="Math"||t.name==="NaN"||t.name==="undefined"||t.name==="Infinity"||t.name==="null"||t.name.startsWith("'")&&t.name.endsWith("'")||t.name.startsWith('"')&&t.name.endsWith('"')||t.name.startsWith("`")&&t.name.endsWith("`")||e.isLoopVariable(t.name))return;let i=!1;if(t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t)){const u=t.parent.callee;if(u.type==="MemberExpression"&&u.object&&u.object.name===z&&["get","set","init","param","call"].includes(u.property.name)){const f=t.parent.arguments.indexOf(t);u.property.name==="call"?f>=2&&(i=!0):f===0&&(i=!0)}else{const f=u.type==="MemberExpression"&&u.object&&u.object.type==="Identifier"&&ft.includes(u.object.name);u.type==="MemberExpression"&&!f?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.property.name==="param";t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left;const a=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,s=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.object===t,o=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.property===t&&t.parent.parent&&t.parent.parent.type==="CallExpression"&&t.parent.parent.callee&&t.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(t.parent.parent.callee.object.name);if(r||n||i||o||a){if(a||t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.object&&t.parent.callee.object.name===z&&t.parent.callee.property.name==="call"&&t.parent.arguments[0]===t||e.isLocalSeriesVar(t.name)||e.isContextBound(t.name)&&!e.isRootParam(t.name))return;const u=Z(t.name,e);Object.assign(t,u);return}const l=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(l){const u=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),f=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,m=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!u&&!f&&!m)return}if(e.isLocalSeriesVar(t.name)){if(!s){const u=E.createIdentifier(t.name),f=E.createGetCall(u,0);Object.assign(t,f)}return}const[c,h]=e.getVariable(t.name);let p;if(l)p=E.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;p=Z(t.name,e)}if(s)Object.assign(t,p);else{const u=E.createGetCall(p,0);Object.assign(t,u)}}}function se(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&ft.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const l=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,c=t.parent&&(t.parent.type==="VariableDeclarator"&&(t.parent.id.type==="ArrayPattern"||t.parent.id.type==="ObjectPattern")||t.parent.type==="AssignmentExpression"&&(t.parent.left.type==="ArrayPattern"||t.parent.left.type==="ObjectPattern")||t.parent.type==="Property");if(!l&&!c){const h={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(h.start=t.start),t.end!==void 0&&(h.end=t.end),Object.assign(t,h);return}}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";if(!r&&!n&&!a&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(tt(t,i),t._indexTransformed=!0);const s=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===z||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(s||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&je.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const l=E.createGetCall(t.object,t.property);t.start&&(l.start=t.start),t.end&&(l.end=t.end),Object.assign(t,l),delete t.object,delete t.property,delete t.computed}}function bt(t,e){if(t.type==="Identifier"){if(je.includes(t.name)&&e.isContextBound(t.name)){const a=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:a},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[a,s]=e.getVariable(t.name);return E.createContextVariableReference(s,a)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?Z(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:Z(t.name,e)}return t}function ke(t,e,i=""){switch(t.type){case"BinaryExpression":return si(t,e,i);case"LogicalExpression":return ai(t,e,i);case"MemberExpression":{const r=!t.computed&&t.object.type==="Identifier"&&je.includes(t.object.name)&&e.isContextBound(t.object.name),n=t.object.type==="Identifier"&&!r?bt(t.object,e):t.object;let a=n;if(!t.computed&&t.object.type==="Identifier"&&!r){const[s]=e.getVariable(t.object.name);s!==t.object.name&&!e.isLoopVariable(t.object.name)&&(a=E.createGetCall(n,0))}return{type:"MemberExpression",object:a,property:t.property,computed:t.computed}}case"Identifier":{if(e.isLoopVariable(t.name)||t.parent&&t.parent.type==="MemberExpression"&&t.parent.property===t)return t;const r=bt(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:E.createGetCall(r,0)}case"UnaryExpression":return oi(t,e,i);case"ConditionalExpression":{const r=ke(t.test,e,i),n=ke(t.consequent,e,i),a=ke(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:a,start:t.start,end:t.end}}}return t}function si(t,e,i){const r=ke(t.left,e,i),n=ke(t.right,e,i),a={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return Y(a,e,{CallExpression(s,o){s._transformed||J(s,o)},MemberExpression(s){se(s,"",e)}}),a}function ai(t,e,i){const r=ke(t.left,e,i),n=ke(t.right,e,i),a={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return Y(a,e,{CallExpression(s,o){s._transformed||J(s,o)}}),a}function ji(t,e,i){Y(t,{parent:t,inNamespaceCall:!1},{Identifier(s,o,l){if(s.name=="NaN")return;if(je.includes(s.name)&&e.isContextBound(s.name)){if(o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===s&&!o.parent.computed)return;const h={type:"MemberExpression",object:{type:"Identifier",name:s.name},property:{type:"Identifier",name:"__value"},computed:!1},p=E.createGetCall(h,0);Object.assign(s,p),delete s.name;return}s.parent=o.parent,Q(s,e);const c=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||c)&&(s.type==="MemberExpression"?tt(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===z&&s.parent.callee.property.name==="get"||pe(s)))},MemberExpression(s,o,l){se(s,"",e),s.object&&l(s.object,{parent:s,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(s,o,l){const c={...o,parent:s};s.test&&l(s.test,c),s.consequent&&l(s.consequent,c),s.alternate&&l(s.alternate,c)},BinaryExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},LogicalExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},UnaryExpression(s,o,l){const c={...o,parent:s};l(s.argument,c)},CallExpression(s,o,l){const c=s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&s.callee.object.type==="Identifier"&&e.isContextBound(s.callee.object.name);J(s,e),s.arguments.forEach(h=>l(h,{parent:s,inNamespaceCall:c||o.inNamespaceCall}))}});const r=E.createMemberExpression(E.createIdentifier(i),E.createIdentifier("param")),n=e.generateParamId(),a={type:"CallExpression",callee:r,arguments:[t,ni,{type:"Identifier",name:`'${n}'`}],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const s=n;e.addLocalSeriesVar(s);const o=E.createVariableDeclaration(s,a);return e.addHoistedStatement(o),E.createIdentifier(s)}return a}function oi(t,e,i){const r=ke(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return Y(n,e,{CallExpression(a,s){a._transformed||J(a,s)},MemberExpression(a){se(a,"",e)}}),n}function Ye(t,e,i){switch(t?.type){case"BinaryExpression":t=si(t,i,e);break;case"LogicalExpression":t=ai(t,i,e);break;case"ConditionalExpression":return ji(t,i,e);case"UnaryExpression":t=oi(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>{if(c.type==="Identifier"){if(i.isContextBound(c.name)&&!i.isRootParam(c.name))return c;if(i.isLocalSeriesVar(c.name)){const h=E.createIdentifier(c.name);return E.createGetCall(h,0)}return Gr(c.name,i)}return c});break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){t.object.type==="CallExpression"?J(t.object,i):t.object.type==="MemberExpression"?se(t.object,"",i):t.object.type==="BinaryExpression"?t.object=si(t.object,i,e):t.object.type==="LogicalExpression"?t.object=ai(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=ji(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=oi(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:bt(t.object,i);let h;t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?h=E.createGetCall(bt(t.property,i),0):t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression"?h=ke(t.property,i,e):h=t.property;const p=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),u=i.generateParamId(),f={type:"CallExpression",callee:p,arguments:[c,h,{type:"Identifier",name:`'${u}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const m=u;i.addLocalSeriesVar(m);const y=E.createVariableDeclaration(m,f);return i.addHoistedStatement(y),E.createIdentifier(m)}return f}if(n){if(t.object.type==="Identifier"&&ft.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.object.name,h={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:t.property.name},computed:!1},arguments:[],_transformed:!0};c==="ta"&&h.arguments.push(i.getNextTACallId());const p=i.generateTempVar();i.addLocalSeriesVar(p);const u=E.createVariableDeclaration(p,h);return i.addOuterHoistedStatement(u),Object.assign(t,E.createIdentifier(p)),t}if(t.object.type==="Identifier"){const c=t.object.name,[h,p]=i.getVariable(c);if(h!==c&&!i.isLoopVariable(c)){const u=Z(c,i),f=E.createGetCall(u,0);t.object=f}}else t.object.type==="MemberExpression"?Ye(t.object,e,i):t.object.type==="CallExpression"&&(t.object._transformed||J(t.object,i))}if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(c=>c.value.name?i.isContextBound(c.value.name)||i.isLocalSeriesVar(c.value.name)||i.isLoopVariable(c.value.name)?{type:"Property",key:{type:"Identifier",name:c.key.name},value:E.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:Z(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Ye(c.value,e,i)),c))),t.type==="Identifier"){if(je.includes(t.name)&&i.isContextBound(t.name)){const c=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),h=i.generateParamId(),p={type:"CallExpression",callee:c,arguments:[t,ni,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const u=h;i.addLocalSeriesVar(u);const f=E.createVariableDeclaration(u,p);return i.addHoistedStatement(f),E.createIdentifier(u)}return p}}t?.type==="CallExpression"&&J(t,i);const a=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),s=t.type==="Identifier"?bt(t,i):t,o=i.generateParamId(),l={type:"CallExpression",callee:a,arguments:[s,ni,{type:"Identifier",name:`'${o}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const h=E.createVariableDeclaration(c,l);return i.addHoistedStatement(h),E.createIdentifier(c)}return l}function yt(t){if(!t)return!1;if(Yr(t))return!0;if(t.type==="MemberExpression")return yt(t.object);if(t.type==="ChainExpression")return yt(t.expression);if(t.type==="CallExpression"){const e=t.callee;if(e?.type==="MemberExpression")return yt(e.object);if(e?.type==="ChainExpression")return yt(e.expression)}return!1}function Yr(t){return t?.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&t.callee.object?.name==="$"&&t.callee.property?.name==="get"}function li(t,e,i){t&&(t.type==="Identifier"?(t.parent=e,Q(t,i)):t.type==="MemberExpression"?li(t.object,t,i):t.type==="CallExpression"&&(t.callee&&t.callee.type==="MemberExpression"&&li(t.callee.object,t.callee,i),t._transformed||J(t,i)))}function J(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(ft.includes(t.callee.name)||je.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=E.createMemberExpression(t.callee,E.createIdentifier("any")));const r=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&(e.isContextBound(t.callee.object.name)||t.callee.object.name==="math"||t.callee.object.name==="ta");if(r){if(t.callee.object.name===z&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,a=[];if(t.arguments.forEach(h=>{if(h._isParamCall){a.push(h);return}a.push(Ye(h,n,e))}),t.arguments=a,["plot","hline","fill"].includes(n)){const h=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const h=e.getNextTACallId(),[p]=e.getVariable("$$");let u;p?u=E.createMemberExpression(E.createLocalContextIdentifier(),E.createIdentifier("id")):u=E.createLiteral("");const f={type:"BinaryExpression",operator:"+",left:u,right:h};t.arguments.push(f)}else t.arguments.push(e.getNextTACallId());const s=t.callee.property.name,o=`${n}.${s}`,l=bs.includes(o),c=t._insideAwait===!0;if(l&&!c){const h=Object.assign({},t),p=E.createAwaitExpression(h);Object.assign(t,p)}if(!e.shouldSuppressHoisting()){const h=e.generateTempVar();e.addLocalSeriesVar(h);const p=t._insideAwait===!0;let u=Object.assign({},t);p&&(u=E.createAwaitExpression(u));const f=E.createVariableDeclaration(h,u);e.addHoistedStatement(f);const m=E.createIdentifier(h);Object.assign(t,m),t._wasHoisted=!0,t._wasInsideAwait=p;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:Ye(n,z,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),a=E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("call")),s=[t.callee,n,...t.arguments];t.callee=a,t.arguments=s}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name,a=e.isUserFunction(n),s=t.callee.object,o=s.type==="Identifier"&&e.isLocalSeriesVar(s.name),l=s.type==="MemberExpression",c=e.isUserMethod(n);if(a&&c&&!e.isContextBound(n)&&!o&&!l){const h=t.callee.object;t.callee.property;const p=t.arguments.map(b=>b._isParamCall?b:Ye(b,z,e));let u=h;h.type==="Identifier"?u=Ye(h,z,e):h.type==="CallExpression"&&(J(h,e),u=Ye(h,z,e));const f=E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("call")),m=e.getNextUserCallId(),y=E.createIdentifier(n);y._skipTransformation=!0;const _=[y,m,u,...p];t.callee=f,t.arguments=_,t._transformed=!0;return}t.callee.object.type==="Identifier"?Q(t.callee.object,e):li(t.callee.object,t.callee,e)}if(t.arguments.forEach(n=>{Y(n,{parent:t},{Identifier(a,s,o){a.parent=s.parent,Q(a,e);const l=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||l)&&(a.type==="MemberExpression"?tt(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===z&&a.parent.callee.property.name==="get"||pe(a)))},BinaryExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},LogicalExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},UnaryExpression(a,s,o){const l={...s,parent:a};o(a.argument,l)},CallExpression(a,s,o){a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&(a.callee.object.parent=a.callee,o(a.callee.object,{parent:a.callee})),a._transformed||J(a,e)},MemberExpression(a,s,o){se(a,"",e),a.object&&o(a.object,{parent:a})}})}),t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.object,a=Yr(n),s=n?.type==="MemberExpression"&&yt(n);if(a||s){const o=Object.assign({},t.callee,{optional:!0});t.callee={type:"ChainExpression",expression:o},t.optional=!0}}}function ci(t,e){let i=null;if(t.left.type==="Identifier")i=Z(t.left.name,e);else if(t.left.type==="MemberExpression"&&t.left.computed){if(t.left.object.type==="Identifier"){const r=t.left.object.name,[n,a]=e.getVariable(r),s=n!==r,o=e.isContextBound(r);(s||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=Z(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed&&t.left.object.type==="Identifier"){const r=t.left.object.name,[n,a]=e.getVariable(r);if(n!==r&&!e.isLoopVariable(r)){const s=Z(r,e),o=E.createGetCall(s,0);t.left.object=o}}if(Y(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,a){if(je.includes(r.name)&&e.isContextBound(r.name)){const m={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},y=E.createGetCall(m,0);Object.assign(r,y),delete r.name;return}r.parent=n.parent,Q(r,e);const s=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",l=e.isContextBound(r.name)&&!e.isRootParam(r.name),c=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,h=r.parent&&r.parent._isParamCall,p=r.parent&&r.parent.type==="MemberExpression",u=r.name==="NaN",f=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===z&&r.parent.callee.property.name==="get";(l||o||s)&&(r.type==="MemberExpression"?tt(r,e):r.type==="Identifier"&&!p&&!c&&!h&&!u&&!f&&pe(r))},MemberExpression(r,n,a){se(r,"",e),r.type==="CallExpression"?r.arguments.forEach(s=>a(s,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&a(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,a){const s=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);J(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&a(r.callee,{parent:r,inNamespaceCall:s||n.inNamespaceCall}),r.arguments.forEach(o=>a(o,{parent:r,inNamespaceCall:s||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const a=t.operator.replace("=",""),s=E.createGetCall(i,0);r={type:"BinaryExpression",operator:a,left:s,right:t.right,start:t.start,end:t.end}}const n=E.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function Qr(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&je.includes(i.init.name)&&e.isContextBound(i.init.name)){const u=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:u},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===z||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===z||i.init.object.object.name==="context2"),a=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(u=>{u.key.name&&e.addContextBoundVar(u.key.name)}),i.init.object.name=z;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(u=>{u.key.name&&e.addContextBoundVar(u.key.name)}),i.init.object.object.name=z;return}e.addVariable(i.id.name,t.kind);const s=t.kind,o=e.isArrayPatternElement(i.id.name)&&i.init&&i.init.type==="MemberExpression"&&i.init.computed;i.init&&!a&&!o&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&e.isContextBound(i.init.callee.object.name)?J(i.init,e):Y(i.init,{parent:i.init},{Identifier(u,f){u.parent=f.parent,Q(u,e);const m=u.parent&&u.parent.type==="BinaryExpression",y=u.parent&&u.parent.type==="UnaryExpression",_=u.parent&&u.parent.type==="ConditionalExpression",b=u.parent&&u.parent.type==="CallExpression"&&u.parent.callee&&u.parent.callee.object&&u.parent.callee.object.name===z&&u.parent.callee.property.name==="get";u.type==="Identifier"&&(m||y||_)&&!b&&pe(u)},CallExpression(u,f,m){u.callee.type==="Identifier"&&(u.callee.parent=u),u.arguments.forEach(y=>{y.type==="Identifier"&&(y.parent=u)}),(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&m(u.callee,{parent:u}),J(u,e),u.type==="CallExpression"&&(u.callee.type==="MemberExpression"&&m(u.callee,{parent:u}),u.arguments.forEach(y=>m(y,{parent:u})))},BinaryExpression(u,f,m){u.left.type==="Identifier"&&(u.left.parent=u),u.right.type==="Identifier"&&(u.right.parent=u),m(u.left,{parent:u}),m(u.right,{parent:u})},MemberExpression(u,f,m){u.object&&u.object.type==="Identifier"&&(u.object.parent=u),u.property&&u.property.type==="Identifier"&&(u.property.parent=u),se(u,"",e),u.type==="CallExpression"?u.arguments.forEach(y=>m(y,{parent:u})):u.object&&m(u.object,{parent:u})},AwaitExpression(u,f,m){u.argument&&(u.argument._insideAwait=!0,m(u.argument,{parent:u}),u.argument.type==="Identifier"&&u.argument._wasInsideAwait&&Object.assign(u,u.argument))},ArrowFunctionExpression(u,f,m){if(u.body)if(u.body.type==="BlockStatement"){const y=[];u.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:u.body,insideIIFE:!0});const b=e.exitHoistingScope();y.push(...b),y.push(_)}),u.body.body=y}else m(u.body,{parent:u,insideIIFE:!0})},FunctionExpression(u,f,m){if(u.body&&u.body.type==="BlockStatement"){const y=[];u.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:u.body,insideIIFE:!0});const b=e.exitHoistingScope();y.push(...b),y.push(_)}),u.body.body=y}},SwitchStatement(u,f,m){u.discriminant&&(u.discriminant.parent=u,m(u.discriminant,{parent:u})),u.cases&&u.cases.forEach(y=>{y.parent=u,m(y,{parent:u})})},SwitchCase(u,f,m){if(u.test&&(u.test.parent=u,m(u.test,{parent:u})),u.consequent){const y=[];u.consequent.forEach(_=>{e.enterHoistingScope(),_.parent=u,m(_,{parent:u});const b=e.exitHoistingScope();y.push(...b),y.push(_)}),u.consequent=y}},AssignmentExpression(u,f,m){if(f.insideIIFE){if(u.left.type==="Identifier"){const[y]=e.getVariable(u.left.name);if(y===u.left.name&&!e.isContextBound(u.left.name)){m(u.right,{parent:u});return}}ci(u,e)}}}));const l=Z(i.id.name,e),c=!o&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(tt(i.init.property,e),i.init.property._indexTransformed=!0)),s==="var"){const u=e.getCurrentHoistingScope();if(u){for(const f of u)if(f.type==="VariableDeclaration")for(const m of f.declarations){if(!m.init||m.init.type!=="CallExpression")continue;const y=m.init.callee;if(y?.type!=="MemberExpression")continue;let _;const b=y.property?.name;if(y.object?.type==="Identifier"?_=y.object.name:y.object?.type==="MemberExpression"&&y.object.property?.name&&(_=y.object.property.name),_&&b){const w=`${_}.${b}`;vs.includes(w)&&(m.init={type:"ArrowFunctionExpression",params:[],body:m.init,expression:!0,async:!1})}}}}let h;i.init?a||o?h=i.init:s==="var"?h=E.createInitVarCall(l,i.init):h=E.createInitCall(l,c?i.init.object:i.init,c?i.init.property:void 0):h=E.createIdentifier("undefined");const p=E.createExpressionStatement(E.createAssignmentExpression(l,h));if(o){const u=i.init.object.name,f=Z(u,e),m=i.init.property.value,y={type:"MemberExpression",object:E.createGetCall(f,0),property:{type:"Literal",value:m},computed:!0};p.expression.right=E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("init")),[l,y])}a&&(e.pushScope("fn"),Y(i.init.body,e,{IfStatement(u,f,m){f.pushScope("if"),m(u.consequent,f),u.alternate&&(f.pushScope("els"),m(u.alternate,f),f.popScope()),f.popScope()},VariableDeclaration(u,f){Qr(u,f)},Identifier(u,f){Q(u,f)},AssignmentExpression(u,f){ci(u,f)},SwitchStatement(u,f,m){u.discriminant.parent=u,m(u.discriminant,f),u.cases.forEach(y=>{y.parent=u,m(y,f)})},SwitchCase(u,f,m){u.test&&(u.test.parent=u,m(u.test,f));const y=[];u.consequent.forEach(_=>{f.enterHoistingScope(),m(_,f);const b=f.exitHoistingScope();y.push(...b),y.push(_)}),u.consequent=y},BlockStatement(u,f,m){const y=[];u.body.forEach(_=>{f.enterHoistingScope(),m(_,f);const b=f.exitHoistingScope();y.push(...b),y.push(_)}),u.body=y}}),e.popScope()),Object.assign(t,p)})}function Ds(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const r=t.init.declarations[0],n=r.id.name;e.addLoopVariable(n,n),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:n},init:r.init}]},r.init&&Y(r.init,e,{Identifier(a,s){!e.isLoopVariable(a.name)&&!a.computed&&(e.pushScope("for"),Q(a,s),a.type==="Identifier"&&(e.isContextBound(a.name)&&a.parent&&a.parent.type==="MemberExpression"&&a.parent.object===a||(a.computed=!0,pe(a))),e.popScope())},MemberExpression(a,s,o){e.pushScope("for"),se(a,"",e),e.popScope(),a.type==="MemberExpression"&&a.object&&(a.object.type!=="Identifier"||!e.isContextBound(a.object.name))&&o(a.object,s)},CallExpression(a,s,o){a.callee.parent=a,o(a.callee,s);for(const l of a.arguments)o(l,s)}})}if(t.test&&Y(t.test,e,{Identifier(r,n){!e.isLoopVariable(r.name)&&!r.computed&&(e.pushScope("for"),Q(r,n),r.type==="Identifier"&&(e.isContextBound(r.name)&&r.parent&&r.parent.type==="MemberExpression"&&r.parent.object===r||(r.computed=!0,pe(r))),e.popScope())},MemberExpression(r,n,a){e.pushScope("for"),se(r,"",e),e.popScope(),r.type==="MemberExpression"&&r.object&&(r.object.type!=="Identifier"||!e.isContextBound(r.object.name))&&a(r.object,n)},CallExpression(r,n,a){r.callee.parent=r,a(r.callee,n);for(const s of r.arguments)a(s,n)}}),t.update&&Y(t.update,e,{Identifier(r,n){!e.isLoopVariable(r.name)&&!r.computed&&(e.pushScope("for"),Q(r,n),r.type==="Identifier"&&(e.isContextBound(r.name)&&r.parent&&r.parent.type==="MemberExpression"&&r.parent.object===r||(r.computed=!0,pe(r))),e.popScope())},MemberExpression(r,n,a){e.pushScope("for"),se(r,"",e),e.popScope(),r.type==="MemberExpression"&&r.object&&(r.object.type!=="Identifier"||!e.isContextBound(r.object.name))&&a(r.object,n)},CallExpression(r,n,a){r.callee.parent=r,a(r.callee,n);for(const s of r.arguments)a(s,n)}}),e.setSuppressHoisting(!1),e.pushScope("for"),i(t.body,e),e.popScope(),t.init&&t.init.type==="VariableDeclaration"){const r=t.init.declarations[0];e.removeLoopVariable(r.id.name)}}function Rs(t,e,i){e.setSuppressHoisting(!0),t.test&&Y(t.test,e,{Identifier(r,n){r.computed||(Q(r,n),r.type==="Identifier"&&(e.isContextBound(r.name)&&r.parent&&r.parent.type==="MemberExpression"&&r.parent.object===r||(r.computed=!0,pe(r))))},MemberExpression(r,n,a){se(r,"",e),r.type==="MemberExpression"&&r.object&&(r.object.type!=="Identifier"||!e.isContextBound(r.object.name))&&a(r.object,n)},CallExpression(r,n,a){if(r.callee.parent=r,a(r.callee,n),J(r,n),r.arguments)for(const s of r.arguments)a(s,n)}}),e.setSuppressHoisting(!1),e.pushScope("whl"),i(t.body,e),e.popScope()}function Ms(t,e){Y(t,e,{MemberExpression(i,r,n){i.object&&i.object.type==="Identifier"&&!e.isContextBound(i.object.name)&&!i.computed&&(i.object.parent=i,n(i.object,r)),se(i,"",e)},CallExpression(i,r){J(i,r)},Identifier(i,r){Q(i,r);const n=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&n&&pe(i)}})}function Os(t,e,i){t.test&&(e.pushScope("if"),Ms(t.test,e),e.popScope()),e.pushScope("if"),i(t.consequent,e),e.popScope(),t.alternate&&(e.pushScope("els"),i(t.alternate,e),e.popScope())}function Vs(t,e){const i=e.getCurrentScopeType();if(t.argument&&(t.argument.type==="ArrayExpression"?(t.argument.elements=t.argument.elements.map(r=>r.type==="Identifier"?e.isContextBound(r.name)&&!e.isRootParam(r.name)?E.createGetCall(r,0):Gr(r.name,e):r.type==="MemberExpression"?r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?E.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||se(r,"",e),r):r),t.argument={type:"ArrayExpression",elements:[t.argument]}):t.argument.type==="ObjectExpression"?t.argument.properties=t.argument.properties.map(r=>r.shorthand?e.isContextBound(r.value.name)?r:(e.getVariable(r.value.name),{type:"Property",key:E.createIdentifier(r.key.name),value:Z(r.value.name,e),kind:"init",method:!1,shorthand:!1,computed:!1}):(r.value&&r.value.type==="Identifier"&&(e.isContextBound(r.value.name)&&!e.isRootParam(r.value.name)||e.isContextBound(r.value.name)||(r.value=Z(r.value.name,e))),r)):t.argument.type==="Identifier"?(Q(t.argument,e),t.argument.type==="Identifier"&&pe(t.argument)):t.argument.type==="MemberExpression"&&t.argument.object.type==="Identifier"&&!e.isContextBound(t.argument.object.name)&&!e.isLoopVariable(t.argument.object.name)&&Q(t.argument.object,e),i==="fn")){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=E.createArrayAccess(t.argument,0):t.argument.type==="MemberExpression"?t.argument.object.type==="Identifier"&&e.isContextBound(t.argument.object.name)&&!e.isRootParam(t.argument.object.name)&&(t.argument._indexTransformed||(tt(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression")&&Y(t.argument,e,{Identifier(n,a){Q(n,a),n.type==="Identifier"&&!n._arrayAccessed&&(pe(n),n._arrayAccessed=!0)},MemberExpression(n){se(n,"",e)},CallExpression(n,a,s){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&s(n.callee,a),J(n,a),n.type==="CallExpression"&&n.arguments.forEach(o=>s(o,a))},BinaryExpression(n,a,s){s(n.left,a),s(n.right,a)},ArrowFunctionExpression(n,a,s){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}else s(n.body,a)},FunctionExpression(n,a,s){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}},SwitchStatement(n,a,s){n.discriminant.parent=n,s(n.discriminant,a),n.cases.forEach(o=>{o.parent=n,s(o,a)})},SwitchCase(n,a,s){n.test&&(n.test.parent=n,s(n.test,a));const o=[];n.consequent.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.consequent=o},BlockStatement(n,a,s){const o=[];n.body.forEach(l=>{a.enterHoistingScope(),s(l,a);const c=a.exitHoistingScope();o.push(...c),o.push(l)}),n.body=o}});const r=E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("precision")),[t.argument]);t.argument=r}}function Ls(t,e,i){const r=E.createVariableDeclaration("$$",E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("peekCtx")),[]));r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"&&(t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(n=>{n.type==="Identifier"&&e.addLocalSeriesVar(n.name)}),i(t.body,e),t.params.forEach(n=>{n.type==="Identifier"&&e.removeLocalSeriesVar(n.name)}),e.popScope())}function js(t){const e={...C,LineComment:()=>{}};function i(o){return o?o.type==="Identifier"?o.name:o.type==="CallExpression"&&o.callee?.type==="MemberExpression"&&o.callee.object?.name==="$"&&o.callee.property?.name==="get"&&o.arguments?.[0]?.type==="Identifier"?o.arguments[0].name:null:null}const r=new Map;Ue(t,{FunctionDeclaration(o){o.id?.name&&r.set(o.id.name,o)}},e);function n(o){let l=!1;const c={...e,FunctionDeclaration:()=>{},FunctionExpression:()=>{},ArrowFunctionExpression:()=>{}};return Ue(o,{AwaitExpression(){l=!0}},c),l}let a=!0,s=0;for(;a&&s<20;){a=!1,s++,Ue(t,{ArrowFunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,a=!0)},FunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,a=!0)}},e);const o=[];Ue(t,{CallExpression(c){!c._asyncWrapped&&(c.callee?.type==="ArrowFunctionExpression"||c.callee?.type==="FunctionExpression")&&c.callee.async===!0&&o.push(c)}},e);for(const c of o){const h={};for(const p of Object.keys(c))h[p]=c[p];h._asyncWrapped=!0;for(const p of Object.keys(c))delete c[p];c.type="AwaitExpression",c.argument=h,a=!0}const l=new Set;for(const[c,h]of r)n(h.body)&&(h.async||(h.async=!0,a=!0),l.add(c));if(l.size>0){const c=[];Ue(t,{CallExpression(h){if(!h._asyncWrapped&&h.callee?.type==="MemberExpression"&&h.callee.object?.name==="$"&&h.callee.property?.name==="call"&&h.arguments?.length>0){const p=i(h.arguments[0]);p&&l.has(p)&&c.push(h)}}},e);for(const h of c){const p={};for(const u of Object.keys(h))p[u]=h[u];p._asyncWrapped=!0;for(const u of Object.keys(h))delete h[u];h.type="AwaitExpression",h.argument=p,a=!0}}}}function Bs(t){const e={...C,LineComment:()=>{}};Ue(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=E.createMathEqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}else if(i.operator==="!="||i.operator==="!=="){const r=E.createMathNeqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}}},e)}function Fs(t,e,i,r={debug:!1,ln:!1},n=[]){const a=s=>{if(!r.debug||!s.loc||!n.length)return null;const o=s.loc.start.line-1;if(o>=0&&o<n.length){const l=n[o].trim();if(l)return{type:"LineComment",value:`${r.ln?` [Line ${s.loc.start.line}]`:""} ${l}`}}return null};Y(t,e,{Program(s,o,l){const c=[];s.body.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope(),u=a(h);u&&c.push(u),c.push(...p),c.push(h)}),s.body=c},BlockStatement(s,o,l){const c=[];s.body.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope(),u=a(h);u&&c.push(u),c.push(...p),c.push(h)}),s.body=c},ReturnStatement(s,o,l){s.argument&&s.argument.type!=="ArrayExpression"&&s.argument.type!=="ObjectExpression"&&s.argument.type!=="Identifier"&&s.argument.type!=="MemberExpression"&&o.getCurrentScopeType()!=="fn"&&l(s.argument,o),Vs(s,o)},VariableDeclaration(s,o){Qr(s,o)},Identifier(s,o){Q(s,o)},CallExpression(s,o,l){s.callee&&(s.callee.type==="ArrowFunctionExpression"||s.callee.type==="FunctionExpression")?l(s.callee,o):s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&(s.callee.object.parent=s.callee,l(s.callee.object,o)),J(s,o)},ArrowFunctionExpression(s,o,l){s.body&&l(s.body,o)},FunctionExpression(s,o,l){s.body&&l(s.body,o)},ForOfStatement(s,o,l){if(s.left&&s.left.type==="VariableDeclaration"){s.left._skipTransformation=!0;const c=s.left.declarations[0];c.id.type==="Identifier"?o.addLoopVariable(c.id.name,c.id.name):c.id.type==="ArrayPattern"&&c.id.elements.forEach(h=>{h.type==="Identifier"&&o.addLoopVariable(h.name,h.name)})}if(s.right&&s.right.type==="Identifier"){Q(s.right,o),s.right.type==="Identifier"&&pe(s.right);const c={...s.right};let h=E.createMemberExpression(c,E.createIdentifier("array"),!1);s.left&&s.left.type==="VariableDeclaration"&&s.left.declarations[0].id.type==="ArrayPattern"&&(h=E.createCallExpression(E.createMemberExpression(h,E.createIdentifier("entries"),!1),[])),Object.assign(s.right,h)}else s.right&&l(s.right,o);if(s.body&&l(s.body,o),s.left&&s.left.type==="VariableDeclaration"){const c=s.left.declarations[0];c.id.type==="Identifier"?o.removeLoopVariable(c.id.name):c.id.type==="ArrayPattern"&&c.id.elements.forEach(h=>{h.type==="Identifier"&&o.removeLoopVariable(h.name)})}},ForInStatement(s,o,l){s.left&&s.left.type==="VariableDeclaration"&&(s.left._skipTransformation=!0),s.right&&s.right.type==="Identifier"?(Q(s.right,o),s.right.type==="Identifier"&&pe(s.right)):s.right&&l(s.right,o),s.body&&l(s.body,o)},MemberExpression(s,o,l){s.object&&(s.object.type==="CallExpression"||s.object.type==="MemberExpression")&&(s.object.parent=s,l(s.object,o)),s.object&&s.object.type==="Identifier"&&!o.isContextBound(s.object.name)&&(s.object.parent=s,l(s.object,o)),se(s,i,o)},AssignmentExpression(s,o,l){if(ci(s,o),s.type==="CallExpression"&&s.arguments){const c=h=>{h&&(h.type==="CallExpression"&&h.callee&&(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&l(h.callee,o),h.type==="BinaryExpression"&&(c(h.left),c(h.right)))};s.arguments.forEach(h=>c(h))}},FunctionDeclaration(s,o,l){Ls(s,o,l)},ForStatement(s,o,l){Ds(s,o,l)},WhileStatement(s,o,l){Rs(s,o,l)},IfStatement(s,o,l){Os(s,o,l)},SwitchStatement(s,o,l){s.discriminant.parent=s,l(s.discriminant,o),s.cases.forEach(c=>{c.parent=s,l(c,o)})},SwitchCase(s,o,l){s.test&&(s.test.parent=s,l(s.test,o));const c=[];s.consequent.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope();c.push(...p),c.push(h)}),s.consequent=c},AwaitExpression(s,o,l){s.argument&&(s.argument._insideAwait=!0,l(s.argument,o),s.argument.type==="Identifier"&&s.argument._wasInsideAwait===!0&&(s.type="Identifier",s.name=s.argument.name,s.argument._wasHoisted&&(s._wasHoisted=s.argument._wasHoisted),delete s.argument))}})}const x={NUMBER:"NUMBER",STRING:"STRING",BOOLEAN:"BOOLEAN",IDENTIFIER:"IDENTIFIER",KEYWORD:"KEYWORD",OPERATOR:"OPERATOR",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",INDENT:"INDENT",DEDENT:"DEDENT",NEWLINE:"NEWLINE",COMMENT:"COMMENT",EOF:"EOF"},Ws=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends","enum"]),$s=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class Us{constructor(e,i,r,n,a=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=a}}class qs{source;pos;line;column;tokens;indentStack;atLineStart;parenDepth;bracketDepth;braceDepth;constructor(e){this.source=e,this.pos=0,this.line=1,this.column=1,this.tokens=[],this.indentStack=[0],this.atLineStart=!0,this.parenDepth=0,this.bracketDepth=0,this.braceDepth=0}tokenize(){for(;this.pos<this.source.length;){const e=this.peek();if(e==="\r"){this.advance();continue}if(e===`
|
|
33
|
+
}`}function Xs(t){H(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const a={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,a)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function Qs(t,e){ze(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===z||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===z||r.init.object.object.name==="context2");(n||a)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(s=>{s.key.name&&e.addContextBoundVar(s.key.name)}))})}})}function Zs(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function Js(t,e){let i;return Fs(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name))},ExpressionStatement(r){const n=r.expression;n&&n.type==="AssignmentExpression"&&n.operator==="="&&n.left?.type==="MemberExpression"&&n.left.property?.name==="__pineMethod__"&&n.left.object?.type==="Identifier"&&n.right?.value===!0&&e.addUserMethod(n.left.object.name)},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=z),Zs(r,e,n)},VariableDeclaration(r,n){const a=n.length>1?n[n.length-2]:null,s=a&&(a.type==="ForOfStatement"||a.type==="ForInStatement")&&a.left===r;r.declarations.forEach(o=>{if(o.id.type==="Identifier")e.addReservedName(o.id.name);else if(o.id.type==="ObjectPattern")o.id.properties.forEach(l=>{l.key&&l.key.type==="Identifier"&&e.addReservedName(l.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(u=>{u&&u.type==="Identifier"&&e.addReservedName(u.name)}),s)return;const l=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:l},init:o.init}]},h=c.declarations[0].init;h&&h.type==="CallExpression"&&(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&ze(h.callee.body,{ReturnStatement(u){u.argument&&u.argument.type==="ArrayExpression"&&(u.argument={type:"ArrayExpression",elements:[u.argument]})}}),o.id.elements?.forEach(u=>{u.type==="Identifier"&&e.addArrayPatternElement(u.name)});const p=o.id.elements.map((u,f)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:u,init:{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Literal",value:f},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...p]})}})},ForStatement(r){}}),i}const ui={type:"Identifier",name:"undefined"};function J(t,e){const[i,r]=e.getVariable(t);if((i.match(/^fn\d+_/)||e.isVariableInFunctionScope(t))&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return S.createLocalContextVariableReference(r,i)}return S.createContextVariableReference(r,i)}function pn(t,e){const i=J(t,e);return S.createGetCall(i,0)}function rt(t,e){if(t.computed&&t.property.type==="Identifier"){if(e.isLoopVariable(t.property.name)){if(t.object.type==="Identifier"&&!e.isLoopVariable(t.object.name)){if(e.isLocalSeriesVar(t.object.name)){const i=S.createIdentifier(t.object.name);i._skipTransformation=!0;const r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=J(t.object.name,e),r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}e.isContextBound(t.property.name)||(t.property=J(t.property.name,e),t.property=S.createGetCall(t.property,0))}if(t.computed&&t.object.type==="Identifier"){if(e.isLoopVariable(t.object.name))return;if(e.isLocalSeriesVar(t.object.name)){const i=S.createIdentifier(t.object.name);i._skipTransformation=!0;const r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=J(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(rt(i,e),i._indexTransformed=!0)}}t.computed&&t.property.type!=="Identifier"&&t.property.type!=="MemberExpression"&&!t._indexTransformed&&(t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression")&&(t.property=Ae(t.property,e))}function le(t,e){const i=S.createGetCall(S.createIdentifier(t.name),0);t.start!==void 0&&(i.start=t.start),t.end!==void 0&&(i.end=t.end),i._indexTransformed=!0,Object.assign(t,i)}function K(t,e){if(!t._skipTransformation&&t.name!==z){if(Fe.includes(t.name)&&e.isContextBound(t.name)){const u=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,f=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!u&&!f){const m={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},x=S.createGetCall(m,0);Object.assign(t,x),delete t.name;return}}if(t.name==="Math"||t.name==="NaN"||t.name==="undefined"||t.name==="Infinity"||t.name==="null"||t.name.startsWith("'")&&t.name.endsWith("'")||t.name.startsWith('"')&&t.name.endsWith('"')||t.name.startsWith("`")&&t.name.endsWith("`")||e.isLoopVariable(t.name))return;let i=!1;if(t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t)){const u=t.parent.callee;if(u.type==="MemberExpression"&&u.object&&u.object.name===z&&["get","set","init","param","call"].includes(u.property.name)){const f=t.parent.arguments.indexOf(t);u.property.name==="call"?f>=2&&(i=!0):f===0&&(i=!0)}else{const f=u.type==="MemberExpression"&&u.object&&u.object.type==="Identifier"&&xt.includes(u.object.name);u.type==="MemberExpression"&&!f?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.property.name==="param";t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left;const a=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,s=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.object===t,o=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.property===t&&t.parent.parent&&t.parent.parent.type==="CallExpression"&&t.parent.parent.callee&&t.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(t.parent.parent.callee.object.name);if(r||n||i||o||a){if(a||t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.object&&t.parent.callee.object.name===z&&t.parent.callee.property.name==="call"&&t.parent.arguments[0]===t||e.isLocalSeriesVar(t.name)||e.isContextBound(t.name)&&!e.isRootParam(t.name))return;const u=J(t.name,e);Object.assign(t,u);return}const l=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(l){const u=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),f=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,m=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!u&&!f&&!m)return}if(e.isLocalSeriesVar(t.name)){if(!s){const u=S.createIdentifier(t.name),f=S.createGetCall(u,0);Object.assign(t,f)}return}const[c,h]=e.getVariable(t.name);let p;if(l)p=S.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;p=J(t.name,e)}if(s)Object.assign(t,p);else{const u=S.createGetCall(p,0);Object.assign(t,u)}}}function ie(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&xt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const l=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,c=t.parent&&(t.parent.type==="VariableDeclarator"&&(t.parent.id.type==="ArrayPattern"||t.parent.id.type==="ObjectPattern")||t.parent.type==="AssignmentExpression"&&(t.parent.left.type==="ArrayPattern"||t.parent.left.type==="ObjectPattern")||t.parent.type==="Property");if(!l&&!c){const h={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(h.start=t.start),t.end!==void 0&&(h.end=t.end),Object.assign(t,h);return}}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",a=i.getCurrentScopeType()=="for";if(!r&&!n&&!a&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(rt(t,i),t._indexTransformed=!0);const s=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===z||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(s||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&Fe.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const l=S.createGetCall(t.object,t.property);t.start&&(l.start=t.start),t.end&&(l.end=t.end),Object.assign(t,l),delete t.object,delete t.property,delete t.computed}}function Nt(t,e){if(t.type==="Identifier"){if(Fe.includes(t.name)&&e.isContextBound(t.name)){const a=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:a},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[a,s]=e.getVariable(t.name);return S.createContextVariableReference(s,a)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?J(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:J(t.name,e)}return t}function Ae(t,e,i=""){switch(t.type){case"BinaryExpression":return pi(t,e,i);case"LogicalExpression":return fi(t,e,i);case"MemberExpression":{const r=!t.computed&&t.object.type==="Identifier"&&Fe.includes(t.object.name)&&e.isContextBound(t.object.name),n=t.object.type==="Identifier"&&!r?Nt(t.object,e):t.object;let a=n;if(!t.computed&&t.object.type==="Identifier"&&!r){const[s]=e.getVariable(t.object.name);s!==t.object.name&&!e.isLoopVariable(t.object.name)&&(a=S.createGetCall(n,0))}return{type:"MemberExpression",object:a,property:t.property,computed:t.computed}}case"Identifier":{if(e.isLoopVariable(t.name)||t.parent&&t.parent.type==="MemberExpression"&&t.parent.property===t)return t;const r=Nt(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:S.createGetCall(r,0)}case"UnaryExpression":return di(t,e,i);case"ConditionalExpression":{const r=Ae(t.test,e,i),n=Ae(t.consequent,e,i),a=Ae(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:a,start:t.start,end:t.end}}}return t}function pi(t,e,i){const r=Ae(t.left,e,i),n=Ae(t.right,e,i),a={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return H(a,e,{CallExpression(s,o){s._transformed||Q(s,o)},MemberExpression(s){ie(s,"",e)}}),a}function fi(t,e,i){const r=Ae(t.left,e,i),n=Ae(t.right,e,i),a={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return H(a,e,{CallExpression(s,o){s._transformed||Q(s,o)}}),a}function Gi(t,e,i){H(t,{parent:t,inNamespaceCall:!1},{Identifier(s,o,l){if(s.name=="NaN")return;if(Fe.includes(s.name)&&e.isContextBound(s.name)){if(o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===s&&!o.parent.computed)return;const h={type:"MemberExpression",object:{type:"Identifier",name:s.name},property:{type:"Identifier",name:"__value"},computed:!1},p=S.createGetCall(h,0);Object.assign(s,p),delete s.name;return}s.parent=o.parent,K(s,e);const c=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||c)&&(s.type==="MemberExpression"?rt(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===z&&s.parent.callee.property.name==="get"||le(s)))},MemberExpression(s,o,l){ie(s,"",e),s.object&&l(s.object,{parent:s,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(s,o,l){const c={...o,parent:s};s.test&&l(s.test,c),s.consequent&&l(s.consequent,c),s.alternate&&l(s.alternate,c)},BinaryExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},LogicalExpression(s,o,l){const c={...o,parent:s};l(s.left,c),l(s.right,c)},UnaryExpression(s,o,l){const c={...o,parent:s};l(s.argument,c)},CallExpression(s,o,l){const c=s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&s.callee.object.type==="Identifier"&&e.isContextBound(s.callee.object.name);Q(s,e),s.arguments.forEach(h=>l(h,{parent:s,inNamespaceCall:c||o.inNamespaceCall}))}});const r=S.createMemberExpression(S.createIdentifier(i),S.createIdentifier("param")),n=e.generateParamId(),a={type:"CallExpression",callee:r,arguments:[t,ui,{type:"Identifier",name:`'${n}'`}],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const s=n;e.addLocalSeriesVar(s);const o=S.createVariableDeclaration(s,a);return e.addHoistedStatement(o),S.createIdentifier(s)}return a}function di(t,e,i){const r=Ae(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return H(n,e,{CallExpression(a,s){a._transformed||Q(a,s)},MemberExpression(a){ie(a,"",e)}}),n}function Qe(t,e,i){switch(t?.type){case"BinaryExpression":t=pi(t,i,e);break;case"LogicalExpression":t=fi(t,i,e);break;case"ConditionalExpression":return Gi(t,i,e);case"UnaryExpression":t=di(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>{if(c.type==="Identifier"){if(i.isContextBound(c.name)&&!i.isRootParam(c.name))return c;if(i.isLocalSeriesVar(c.name)){const h=S.createIdentifier(c.name);return S.createGetCall(h,0)}return pn(c.name,i)}return c});break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){t.object.type==="CallExpression"?Q(t.object,i):t.object.type==="MemberExpression"?ie(t.object,"",i):t.object.type==="BinaryExpression"?t.object=pi(t.object,i,e):t.object.type==="LogicalExpression"?t.object=fi(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=Gi(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=di(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:Nt(t.object,i);let h;t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?h=S.createGetCall(Nt(t.property,i),0):t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression"?h=Ae(t.property,i,e):h=t.property;const p=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),u=i.generateParamId(),f={type:"CallExpression",callee:p,arguments:[c,h,{type:"Identifier",name:`'${u}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const m=u;i.addLocalSeriesVar(m);const x=S.createVariableDeclaration(m,f);return i.addHoistedStatement(x),S.createIdentifier(m)}return f}if(n){if(t.object.type==="Identifier"&&xt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.object.name,h={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:t.property.name},computed:!1},arguments:[],_transformed:!0};c==="ta"&&h.arguments.push(i.getNextTACallId());const p=i.generateTempVar();i.addLocalSeriesVar(p);const u=S.createVariableDeclaration(p,h);return i.addOuterHoistedStatement(u),Object.assign(t,S.createIdentifier(p)),t}if(t.object.type==="Identifier"){const c=t.object.name,[h,p]=i.getVariable(c);if(h!==c&&!i.isLoopVariable(c)){const u=J(c,i),f=S.createGetCall(u,0);t.object=f}}else t.object.type==="MemberExpression"?Qe(t.object,e,i):t.object.type==="CallExpression"&&(t.object._transformed||Q(t.object,i))}if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(c=>c.value.name?i.isContextBound(c.value.name)||i.isLocalSeriesVar(c.value.name)||i.isLoopVariable(c.value.name)?{type:"Property",key:{type:"Identifier",name:c.key.name},value:S.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:J(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Qe(c.value,e,i)),c))),t.type==="Identifier"){if(Fe.includes(t.name)&&i.isContextBound(t.name)){const c=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),h=i.generateParamId(),p={type:"CallExpression",callee:c,arguments:[t,ui,{type:"Identifier",name:`'${h}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const u=h;i.addLocalSeriesVar(u);const f=S.createVariableDeclaration(u,p);return i.addHoistedStatement(f),S.createIdentifier(u)}return p}}t?.type==="CallExpression"&&Q(t,i);const a=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),s=t.type==="Identifier"?Nt(t,i):t,o=i.generateParamId(),l={type:"CallExpression",callee:a,arguments:[s,ui,{type:"Identifier",name:`'${o}'`}],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const h=S.createVariableDeclaration(c,l);return i.addHoistedStatement(h),S.createIdentifier(c)}return l}function St(t){if(!t)return!1;if(fn(t))return!0;if(t.type==="MemberExpression")return St(t.object);if(t.type==="ChainExpression")return St(t.expression);if(t.type==="CallExpression"){const e=t.callee;if(e?.type==="MemberExpression")return St(e.object);if(e?.type==="ChainExpression")return St(e.expression)}return!1}function fn(t){return t?.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&t.callee.object?.name==="$"&&t.callee.property?.name==="get"}function mi(t,e,i){t&&(t.type==="Identifier"?(t.parent=e,K(t,i)):t.type==="MemberExpression"?mi(t.object,t,i):t.type==="CallExpression"&&(t.callee&&t.callee.type==="MemberExpression"&&mi(t.callee.object,t.callee,i),t._transformed||Q(t,i)))}function Q(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(xt.includes(t.callee.name)||Fe.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=S.createMemberExpression(t.callee,S.createIdentifier("any")));const r=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&(e.isContextBound(t.callee.object.name)||t.callee.object.name==="math"||t.callee.object.name==="ta");if(r){if(t.callee.object.name===z&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,a=[];if(t.arguments.forEach(h=>{if(h._isParamCall){a.push(h);return}a.push(Qe(h,n,e))}),t.arguments=a,["plot","hline","fill"].includes(n)){const h=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const h=e.getNextTACallId(),[p]=e.getVariable("$$");let u;p?u=S.createMemberExpression(S.createLocalContextIdentifier(),S.createIdentifier("id")):u=S.createLiteral("");const f={type:"BinaryExpression",operator:"+",left:u,right:h};t.arguments.push(f)}else t.arguments.push(e.getNextTACallId());const s=t.callee.property.name,o=`${n}.${s}`,l=Ws.includes(o),c=t._insideAwait===!0;if(l&&!c){const h=Object.assign({},t),p=S.createAwaitExpression(h);Object.assign(t,p)}if(!e.shouldSuppressHoisting()){const h=e.generateTempVar();e.addLocalSeriesVar(h);const p=t._insideAwait===!0;let u=Object.assign({},t);p&&(u=S.createAwaitExpression(u));const f=S.createVariableDeclaration(h,u);e.addHoistedStatement(f);const m=S.createIdentifier(h);Object.assign(t,m),t._wasHoisted=!0,t._wasInsideAwait=p;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:Qe(n,z,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),a=S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("call")),s=[t.callee,n,...t.arguments];t.callee=a,t.arguments=s}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name,a=e.isUserFunction(n),s=t.callee.object,o=s.type==="Identifier"&&e.isLocalSeriesVar(s.name),l=s.type==="MemberExpression",c=e.isUserMethod(n);if(a&&c&&!e.isContextBound(n)&&!o&&!l){const h=t.callee.object;t.callee.property;const p=t.arguments.map(b=>b._isParamCall?b:Qe(b,z,e));let u=h;h.type==="Identifier"?u=Qe(h,z,e):h.type==="CallExpression"&&(Q(h,e),u=Qe(h,z,e));const f=S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("call")),m=e.getNextUserCallId(),x=S.createIdentifier(n);x._skipTransformation=!0;const _=[x,m,u,...p];t.callee=f,t.arguments=_,t._transformed=!0;return}t.callee.object.type==="Identifier"?K(t.callee.object,e):mi(t.callee.object,t.callee,e)}if(t.arguments.forEach(n=>{H(n,{parent:t},{Identifier(a,s,o){a.parent=s.parent,K(a,e);const l=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||l)&&(a.type==="MemberExpression"?rt(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===z&&a.parent.callee.property.name==="get"||le(a)))},BinaryExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},LogicalExpression(a,s,o){const l={...s,parent:a};o(a.left,l),o(a.right,l)},UnaryExpression(a,s,o){const l={...s,parent:a};o(a.argument,l)},CallExpression(a,s,o){a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&(a.callee.object.parent=a.callee,o(a.callee.object,{parent:a.callee})),a._transformed||Q(a,e)},MemberExpression(a,s,o){ie(a,"",e),a.object&&o(a.object,{parent:a})}})}),t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.object,a=fn(n),s=n?.type==="MemberExpression"&&St(n);if(a||s){const o=Object.assign({},t.callee,{optional:!0});t.callee={type:"ChainExpression",expression:o},t.optional=!0}}}function Ti(t){const e={type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:{type:"Literal",value:0}}]},i={type:"IfStatement",test:{type:"BinaryExpression",operator:">",left:{type:"UpdateExpression",operator:"++",prefix:!0,argument:{type:"Identifier",name:t}},right:{type:"Identifier",name:"__maxLoops"}},consequent:{type:"ThrowStatement",argument:{type:"NewExpression",callee:{type:"Identifier",name:"Error"},arguments:[{type:"Literal",value:`Loop exceeded maximum iterations (${t})`}]}},alternate:null};return{counterDecl:e,guardCheck:i}}function gi(t,e){let i=null;if(t.left.type==="Identifier")i=J(t.left.name,e);else if(t.left.type==="MemberExpression"&&t.left.computed){if(t.left.object.type==="Identifier"){const r=t.left.object.name,[n,a]=e.getVariable(r),s=n!==r,o=e.isContextBound(r);(s||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=J(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed){let r=null,n=t.left;for(;n.type==="MemberExpression"&&!n.computed;){if(n.object.type==="Identifier"){r=n;break}n=n.object}if(r){const a=r.object.name,[s,o]=e.getVariable(a);if(s!==a&&!e.isLoopVariable(a)){const l=J(a,e),c=S.createGetCall(l,0);r.object=c}}}if(H(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,a){if(Fe.includes(r.name)&&e.isContextBound(r.name)){const m={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},x=S.createGetCall(m,0);Object.assign(r,x),delete r.name;return}r.parent=n.parent,K(r,e);const s=r.parent&&r.parent.type==="BinaryExpression",o=r.parent&&r.parent.type==="ConditionalExpression",l=e.isContextBound(r.name)&&!e.isRootParam(r.name),c=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,h=r.parent&&r.parent._isParamCall,p=r.parent&&r.parent.type==="MemberExpression",u=r.name==="NaN",f=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===z&&r.parent.callee.property.name==="get";(l||o||s)&&(r.type==="MemberExpression"?rt(r,e):r.type==="Identifier"&&!p&&!c&&!h&&!u&&!f&&le(r))},MemberExpression(r,n,a){ie(r,"",e),r.type==="CallExpression"?r.arguments.forEach(s=>a(s,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&a(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,a){const s=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);Q(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&a(r.callee,{parent:r,inNamespaceCall:s||n.inNamespaceCall}),r.arguments.forEach(o=>a(o,{parent:r,inNamespaceCall:s||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const a=t.operator.replace("=",""),s=S.createGetCall(i,0);r={type:"BinaryExpression",operator:a,left:s,right:t.right,start:t.start,end:t.end}}const n=S.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function dn(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&Fe.includes(i.init.name)&&e.isContextBound(i.init.name)){const u=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:u},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===z||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===z||i.init.object.object.name==="context2"),a=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(u=>{u.key.name&&e.addContextBoundVar(u.key.name)}),i.init.object.name=z;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(u=>{u.key.name&&e.addContextBoundVar(u.key.name)}),i.init.object.object.name=z;return}e.addVariable(i.id.name,t.kind);const s=t.kind,o=e.isArrayPatternElement(i.id.name)&&i.init&&i.init.type==="MemberExpression"&&i.init.computed;i.init&&!a&&!o&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&e.isContextBound(i.init.callee.object.name)?Q(i.init,e):H(i.init,{parent:i.init},{Identifier(u,f){u.parent=f.parent,K(u,e);const m=u.parent&&u.parent.type==="BinaryExpression",x=u.parent&&u.parent.type==="UnaryExpression",_=u.parent&&u.parent.type==="ConditionalExpression",b=u.parent&&u.parent.type==="CallExpression"&&u.parent.callee&&u.parent.callee.object&&u.parent.callee.object.name===z&&u.parent.callee.property.name==="get";u.type==="Identifier"&&(m||x||_)&&!b&&le(u)},CallExpression(u,f,m){u.callee.type==="Identifier"&&(u.callee.parent=u),u.arguments.forEach(x=>{x.type==="Identifier"&&(x.parent=u)}),(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&m(u.callee,{parent:u}),Q(u,e),u.type==="CallExpression"&&(u.callee.type==="MemberExpression"&&m(u.callee,{parent:u}),u.arguments.forEach(x=>m(x,{parent:u})))},BinaryExpression(u,f,m){u.left.type==="Identifier"&&(u.left.parent=u),u.right.type==="Identifier"&&(u.right.parent=u),m(u.left,{parent:u}),m(u.right,{parent:u})},MemberExpression(u,f,m){u.object&&u.object.type==="Identifier"&&(u.object.parent=u),u.property&&u.property.type==="Identifier"&&(u.property.parent=u),ie(u,"",e),u.type==="CallExpression"?u.arguments.forEach(x=>m(x,{parent:u})):u.object&&m(u.object,{parent:u})},AwaitExpression(u,f,m){u.argument&&(u.argument._insideAwait=!0,m(u.argument,{parent:u}),u.argument.type==="Identifier"&&u.argument._wasInsideAwait&&Object.assign(u,u.argument))},ArrowFunctionExpression(u,f,m){if(u.body)if(u.body.type==="BlockStatement"){const x=[];u.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:u.body,insideIIFE:!0});const b=e.exitHoistingScope();x.push(...b),x.push(_)}),u.body.body=x}else m(u.body,{parent:u,insideIIFE:!0})},FunctionExpression(u,f,m){if(u.body&&u.body.type==="BlockStatement"){const x=[];u.body.body.forEach(_=>{e.enterHoistingScope(),m(_,{parent:u.body,insideIIFE:!0});const b=e.exitHoistingScope();x.push(...b),x.push(_)}),u.body.body=x}},SwitchStatement(u,f,m){u.discriminant&&(u.discriminant.parent=u,m(u.discriminant,{parent:u})),u.cases&&u.cases.forEach(x=>{x.parent=u,m(x,{parent:u})})},SwitchCase(u,f,m){if(u.test&&(u.test.parent=u,m(u.test,{parent:u})),u.consequent){const x=[];u.consequent.forEach(_=>{e.enterHoistingScope(),_.parent=u,m(_,{parent:u});const b=e.exitHoistingScope();x.push(...b),x.push(_)}),u.consequent=x}},AssignmentExpression(u,f,m){if(f.insideIIFE){if(u.left.type==="Identifier"){const[x]=e.getVariable(u.left.name);if(x===u.left.name&&!e.isContextBound(u.left.name)){m(u.right,{parent:u});return}}gi(u,e)}}}));const l=J(i.id.name,e),c=!o&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(rt(i.init.property,e),i.init.property._indexTransformed=!0)),s==="var"){const u=e.getCurrentHoistingScope();if(u){for(const f of u)if(f.type==="VariableDeclaration")for(const m of f.declarations){if(!m.init||m.init.type!=="CallExpression")continue;const x=m.init.callee;if(x?.type!=="MemberExpression")continue;let _;const b=x.property?.name;if(x.object?.type==="Identifier"?_=x.object.name:x.object?.type==="MemberExpression"&&x.object.property?.name&&(_=x.object.property.name),_&&b){const v=`${_}.${b}`;Us.includes(v)&&(m.init={type:"ArrowFunctionExpression",params:[],body:m.init,expression:!0,async:!1})}}}}let h;i.init?a||o?h=i.init:s==="var"?h=S.createInitVarCall(l,i.init):h=S.createInitCall(l,c?i.init.object:i.init,c?i.init.property:void 0):h=S.createIdentifier("undefined");const p=S.createExpressionStatement(S.createAssignmentExpression(l,h));if(o){const u=i.init.object.name,f=J(u,e),m=i.init.property.value,x={type:"MemberExpression",object:S.createGetCall(f,0),property:{type:"Literal",value:m},computed:!0};p.expression.right=S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("init")),[l,x])}a&&(e.pushScope("fn"),H(i.init.body,e,{IfStatement(u,f,m){f.pushScope("if"),m(u.consequent,f),u.alternate&&(f.pushScope("els"),m(u.alternate,f),f.popScope()),f.popScope()},VariableDeclaration(u,f){dn(u,f)},Identifier(u,f){K(u,f)},AssignmentExpression(u,f){gi(u,f)},SwitchStatement(u,f,m){u.discriminant.parent=u,m(u.discriminant,f),u.cases.forEach(x=>{x.parent=u,m(x,f)})},SwitchCase(u,f,m){u.test&&(u.test.parent=u,m(u.test,f));const x=[];u.consequent.forEach(_=>{f.enterHoistingScope(),m(_,f);const b=f.exitHoistingScope();x.push(...b),x.push(_)}),u.consequent=x},BlockStatement(u,f,m){const x=[];u.body.forEach(_=>{f.enterHoistingScope(),m(_,f);const b=f.exitHoistingScope();x.push(...b),x.push(_)}),u.body=x}}),e.popScope()),Object.assign(t,p)})}function ea(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const a=t.init.declarations[0],s=a.id.name;e.addLoopVariable(s,s),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:a.init}]},a.init&&H(a.init,e,{Identifier(o,l){!e.isLoopVariable(o.name)&&!o.computed&&(e.pushScope("for"),K(o,l),o.type==="Identifier"&&(e.isContextBound(o.name)&&o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===o||(o.computed=!0,le(o))),e.popScope())},MemberExpression(o,l,c){e.pushScope("for"),ie(o,"",e),e.popScope(),o.type==="MemberExpression"&&o.object&&(o.object.type!=="Identifier"||!e.isContextBound(o.object.name))&&c(o.object,l)},CallExpression(o,l,c){o.callee.parent=o,c(o.callee,l);for(const h of o.arguments)c(h,l)}})}t.test&&H(t.test,e,{Identifier(a,s){!e.isLoopVariable(a.name)&&!a.computed&&(e.pushScope("for"),K(a,s),a.type==="Identifier"&&(e.isContextBound(a.name)&&a.parent&&a.parent.type==="MemberExpression"&&a.parent.object===a||(a.computed=!0,le(a))),e.popScope())},MemberExpression(a,s,o){e.pushScope("for"),ie(a,"",e),e.popScope(),a.type==="MemberExpression"&&a.object&&(a.object.type!=="Identifier"||!e.isContextBound(a.object.name))&&o(a.object,s)},CallExpression(a,s,o){a.callee.parent=a,o(a.callee,s);for(const l of a.arguments)o(l,s)}}),t.update&&H(t.update,e,{Identifier(a,s){!e.isLoopVariable(a.name)&&!a.computed&&(e.pushScope("for"),K(a,s),a.type==="Identifier"&&(e.isContextBound(a.name)&&a.parent&&a.parent.type==="MemberExpression"&&a.parent.object===a||(a.computed=!0,le(a))),e.popScope())},MemberExpression(a,s,o){e.pushScope("for"),ie(a,"",e),e.popScope(),a.type==="MemberExpression"&&a.object&&(a.object.type!=="Identifier"||!e.isContextBound(a.object.name))&&o(a.object,s)},CallExpression(a,s,o){a.callee.parent=a,o(a.callee,s);for(const l of a.arguments)o(l,s)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=Ti(r);if(e.addHoistedStatement(n.counterDecl),e.pushScope("for"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck),t.init&&t.init.type==="VariableDeclaration"){const a=t.init.declarations[0];e.removeLoopVariable(a.id.name)}}function ta(t,e,i){e.setSuppressHoisting(!0),t.test&&H(t.test,e,{Identifier(a,s){a.computed||(K(a,s),a.type==="Identifier"&&(e.isContextBound(a.name)&&a.parent&&a.parent.type==="MemberExpression"&&a.parent.object===a||(a.computed=!0,le(a))))},MemberExpression(a,s,o){ie(a,"",e),a.type==="MemberExpression"&&a.object&&(a.object.type!=="Identifier"||!e.isContextBound(a.object.name))&&o(a.object,s)},CallExpression(a,s,o){if(a.callee.parent=a,o(a.callee,s),Q(a,s),a.arguments)for(const l of a.arguments)o(l,s)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=Ti(r);e.addHoistedStatement(n.counterDecl),e.pushScope("whl"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck)}function ia(t,e){H(t,e,{MemberExpression(i,r,n){i.object&&i.object.type==="Identifier"&&!e.isContextBound(i.object.name)&&!i.computed&&(i.object.parent=i,n(i.object,r)),ie(i,"",e)},CallExpression(i,r){Q(i,r)},Identifier(i,r){K(i,r);const n=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&n&&le(i)}})}function ra(t,e,i){t.test&&(e.pushScope("if"),ia(t.test,e),e.popScope()),e.pushScope("if"),i(t.consequent,e),e.popScope(),t.alternate&&(e.pushScope("els"),i(t.alternate,e),e.popScope())}function na(t,e){const i=e.getCurrentScopeType();if(t.argument&&(t.argument.type==="ArrayExpression"?(t.argument.elements=t.argument.elements.map(r=>r.type==="Identifier"?e.isContextBound(r.name)&&!e.isRootParam(r.name)?S.createGetCall(r,0):pn(r.name,e):r.type==="MemberExpression"?r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?S.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||ie(r,"",e),r):((r.type==="BinaryExpression"||r.type==="LogicalExpression"||r.type==="ConditionalExpression"||r.type==="CallExpression"||r.type==="UnaryExpression")&&H(r,e,{Identifier(n,a){K(n,a),n.type==="Identifier"&&!n._arrayAccessed&&(le(n),n._arrayAccessed=!0)},MemberExpression(n){ie(n,"",e)},CallExpression(n,a,s){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&s(n.callee,a),Q(n,a),n.type==="CallExpression"&&n.arguments.forEach(o=>s(o,a))},BinaryExpression(n,a,s){s(n.left,a),s(n.right,a)}}),r)),t.argument={type:"ArrayExpression",elements:[t.argument]}):t.argument.type==="ObjectExpression"?t.argument.properties=t.argument.properties.map(r=>r.shorthand?e.isContextBound(r.value.name)?r:(e.getVariable(r.value.name),{type:"Property",key:S.createIdentifier(r.key.name),value:J(r.value.name,e),kind:"init",method:!1,shorthand:!1,computed:!1}):(r.value&&r.value.type==="Identifier"&&(e.isContextBound(r.value.name)&&!e.isRootParam(r.value.name)||e.isContextBound(r.value.name)||(r.value=J(r.value.name,e))),r)):t.argument.type==="Identifier"?(K(t.argument,e),t.argument.type==="Identifier"&&le(t.argument)):t.argument.type==="MemberExpression"&&t.argument.object.type==="Identifier"&&!e.isContextBound(t.argument.object.name)&&!e.isLoopVariable(t.argument.object.name)&&K(t.argument.object,e),i==="fn")){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=S.createArrayAccess(t.argument,0):t.argument.type==="MemberExpression"?t.argument.object.type==="Identifier"&&e.isContextBound(t.argument.object.name)&&!e.isRootParam(t.argument.object.name)&&(t.argument._indexTransformed||(rt(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression")&&H(t.argument,e,{Identifier(n,a){K(n,a),n.type==="Identifier"&&!n._arrayAccessed&&(le(n),n._arrayAccessed=!0)},MemberExpression(n){ie(n,"",e)},CallExpression(n,a,s){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&s(n.callee,a),Q(n,a),n.type==="CallExpression"&&n.arguments.forEach(o=>s(o,a))},BinaryExpression(n,a,s){s(n.left,a),s(n.right,a)},ArrowFunctionExpression(n,a,s){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}else s(n.body,a)},FunctionExpression(n,a,s){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}},SwitchStatement(n,a,s){n.discriminant.parent=n,s(n.discriminant,a),n.cases.forEach(o=>{o.parent=n,s(o,a)})},SwitchCase(n,a,s){n.test&&(n.test.parent=n,s(n.test,a));const o=[];n.consequent.forEach(l=>{e.enterHoistingScope(),s(l,a);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.consequent=o},BlockStatement(n,a,s){const o=[];n.body.forEach(l=>{a.enterHoistingScope(),s(l,a);const c=a.exitHoistingScope();o.push(...c),o.push(l)}),n.body=o}});const r=S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("precision")),[t.argument]);t.argument=r}}function sa(t,e,i){const r=S.createVariableDeclaration("$$",S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("peekCtx")),[]));r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"&&(t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(n=>{n.type==="Identifier"&&e.addLocalSeriesVar(n.name)}),i(t.body,e),t.params.forEach(n=>{n.type==="Identifier"&&e.removeLocalSeriesVar(n.name)}),e.popScope())}function aa(t){const e={...N,LineComment:()=>{}};function i(o){return o?o.type==="Identifier"?o.name:o.type==="CallExpression"&&o.callee?.type==="MemberExpression"&&o.callee.object?.name==="$"&&o.callee.property?.name==="get"&&o.arguments?.[0]?.type==="Identifier"?o.arguments[0].name:null:null}const r=new Map;ze(t,{FunctionDeclaration(o){o.id?.name&&r.set(o.id.name,o)}},e);function n(o){let l=!1;const c={...e,FunctionDeclaration:()=>{},FunctionExpression:()=>{},ArrowFunctionExpression:()=>{}};return ze(o,{AwaitExpression(){l=!0}},c),l}let a=!0,s=0;for(;a&&s<20;){a=!1,s++,ze(t,{ArrowFunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,a=!0)},FunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,a=!0)}},e);const o=[];ze(t,{CallExpression(c){!c._asyncWrapped&&(c.callee?.type==="ArrowFunctionExpression"||c.callee?.type==="FunctionExpression")&&c.callee.async===!0&&o.push(c)}},e);for(const c of o){const h={};for(const p of Object.keys(c))h[p]=c[p];h._asyncWrapped=!0;for(const p of Object.keys(c))delete c[p];c.type="AwaitExpression",c.argument=h,a=!0}const l=new Set;for(const[c,h]of r)n(h.body)&&(h.async||(h.async=!0,a=!0),l.add(c));if(l.size>0){const c=[];ze(t,{CallExpression(h){if(!h._asyncWrapped&&h.callee?.type==="MemberExpression"&&h.callee.object?.name==="$"&&h.callee.property?.name==="call"&&h.arguments?.length>0){const p=i(h.arguments[0]);p&&l.has(p)&&c.push(h)}}},e);for(const h of c){const p={};for(const u of Object.keys(h))p[u]=h[u];p._asyncWrapped=!0;for(const u of Object.keys(h))delete h[u];h.type="AwaitExpression",h.argument=p,a=!0}}}}function oa(t){const e={...N,LineComment:()=>{}};ze(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=S.createMathEqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}else if(i.operator==="!="||i.operator==="!=="){const r=S.createMathNeqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}}},e)}function la(t,e,i,r={debug:!1,ln:!1},n=[]){const a=s=>{if(!r.debug||!s.loc||!n.length)return null;const o=s.loc.start.line-1;if(o>=0&&o<n.length){const l=n[o].trim();if(l)return{type:"LineComment",value:`${r.ln?` [Line ${s.loc.start.line}]`:""} ${l}`}}return null};H(t,e,{Program(s,o,l){const c=[];s.body.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope(),u=a(h);u&&c.push(u),c.push(...p),c.push(h)}),s.body=c},BlockStatement(s,o,l){const c=[];s.body.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope(),u=a(h);u&&c.push(u),c.push(...p),c.push(h)}),s.body=c},ReturnStatement(s,o,l){s.argument&&s.argument.type!=="ArrayExpression"&&s.argument.type!=="ObjectExpression"&&s.argument.type!=="Identifier"&&s.argument.type!=="MemberExpression"&&o.getCurrentScopeType()!=="fn"&&l(s.argument,o),na(s,o)},VariableDeclaration(s,o){dn(s,o)},Identifier(s,o){K(s,o)},CallExpression(s,o,l){s.callee&&(s.callee.type==="ArrowFunctionExpression"||s.callee.type==="FunctionExpression")?l(s.callee,o):s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&(s.callee.object.parent=s.callee,l(s.callee.object,o)),Q(s,o)},ArrowFunctionExpression(s,o,l){s.body&&l(s.body,o)},FunctionExpression(s,o,l){s.body&&l(s.body,o)},ForOfStatement(s,o,l){if(s.left&&s.left.type==="VariableDeclaration"){s.left._skipTransformation=!0;const p=s.left.declarations[0];p.id.type==="Identifier"?o.addLoopVariable(p.id.name,p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(u=>{u.type==="Identifier"&&o.addLoopVariable(u.name,u.name)})}if(s.right&&s.right.type==="Identifier"){K(s.right,o),s.right.type==="Identifier"&&le(s.right);const p={...s.right};let u=S.createMemberExpression(p,S.createIdentifier("array"),!1);s.left&&s.left.type==="VariableDeclaration"&&s.left.declarations[0].id.type==="ArrayPattern"&&(u=S.createCallExpression(S.createMemberExpression(u,S.createIdentifier("entries"),!1),[])),Object.assign(s.right,u)}else s.right&&l(s.right,o);const c=o.getNextLoopGuardName(),h=Ti(c);if(o.addHoistedStatement(h.counterDecl),s.body&&l(s.body,o),s.body&&s.body.type==="BlockStatement"&&s.body.body.unshift(h.guardCheck),s.left&&s.left.type==="VariableDeclaration"){const p=s.left.declarations[0];p.id.type==="Identifier"?o.removeLoopVariable(p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(u=>{u.type==="Identifier"&&o.removeLoopVariable(u.name)})}},ForInStatement(s,o,l){s.left&&s.left.type==="VariableDeclaration"&&(s.left._skipTransformation=!0),s.right&&s.right.type==="Identifier"?(K(s.right,o),s.right.type==="Identifier"&&le(s.right)):s.right&&l(s.right,o),s.body&&l(s.body,o)},MemberExpression(s,o,l){s.object&&(s.object.type==="CallExpression"||s.object.type==="MemberExpression")&&(s.object.parent=s,l(s.object,o)),s.object&&s.object.type==="Identifier"&&!o.isContextBound(s.object.name)&&(s.object.parent=s,l(s.object,o)),ie(s,i,o)},AssignmentExpression(s,o,l){if(gi(s,o),s.type==="CallExpression"&&s.arguments){const c=h=>{h&&(h.type==="CallExpression"&&h.callee&&(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&l(h.callee,o),h.type==="BinaryExpression"&&(c(h.left),c(h.right)))};s.arguments.forEach(h=>c(h))}},FunctionDeclaration(s,o,l){sa(s,o,l)},ForStatement(s,o,l){ea(s,o,l)},WhileStatement(s,o,l){ta(s,o,l)},IfStatement(s,o,l){ra(s,o,l)},SwitchStatement(s,o,l){s.discriminant.parent=s,l(s.discriminant,o),s.cases.forEach(c=>{c.parent=s,l(c,o)})},SwitchCase(s,o,l){s.test&&(s.test.parent=s,l(s.test,o));const c=[];s.consequent.forEach(h=>{o.enterHoistingScope(),l(h,o);const p=o.exitHoistingScope();c.push(...p),c.push(h)}),s.consequent=c},AwaitExpression(s,o,l){s.argument&&(s.argument._insideAwait=!0,l(s.argument,o),s.argument.type==="Identifier"&&s.argument._wasInsideAwait===!0&&(s.type="Identifier",s.name=s.argument.name,s.argument._wasHoisted&&(s._wasHoisted=s.argument._wasHoisted),delete s.argument))}})}const g={NUMBER:"NUMBER",STRING:"STRING",BOOLEAN:"BOOLEAN",IDENTIFIER:"IDENTIFIER",KEYWORD:"KEYWORD",OPERATOR:"OPERATOR",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",INDENT:"INDENT",DEDENT:"DEDENT",NEWLINE:"NEWLINE",COMMENT:"COMMENT",EOF:"EOF"},ca=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends","enum"]),ha=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class ua{constructor(e,i,r,n,a=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=a}}class pa{source;pos;line;column;tokens;indentStack;atLineStart;parenDepth;bracketDepth;braceDepth;constructor(e){this.source=e,this.pos=0,this.line=1,this.column=1,this.tokens=[],this.indentStack=[0],this.atLineStart=!0,this.parenDepth=0,this.bracketDepth=0,this.braceDepth=0}tokenize(){for(;this.pos<this.source.length;){const e=this.peek();if(e==="\r"){this.advance();continue}if(e===`
|
|
34
34
|
`){this.handleNewline();continue}if(this.atLineStart&&e!==`
|
|
35
|
-
`){this.handleIndentation(),this.atLineStart=!1;continue}if(e===" "||e===" "){this.advance();continue}if(this.pos>=this.source.length)break;if(e==="/"&&this.peek(1)==="/"){this.readComment();continue}if(e==='"'||e==="'"){this.readString();continue}if(e==="#"){this.readColorLiteral();continue}if(this.isDigit(e)){this.readNumber();continue}if(this.isIdentifierStart(e)){this.readIdentifier();continue}if(!this.readOperatorOrPunctuation())throw new Error(`Unexpected character '${e}' at ${this.line}:${this.column}`)}for(;this.indentStack.length>1;)this.indentStack.pop(),this.addToken(
|
|
35
|
+
`){this.handleIndentation(),this.atLineStart=!1;continue}if(e===" "||e===" "){this.advance();continue}if(this.pos>=this.source.length)break;if(e==="/"&&this.peek(1)==="/"){this.readComment();continue}if(e==='"'||e==="'"){this.readString();continue}if(e==="#"){this.readColorLiteral();continue}if(this.isDigit(e)){this.readNumber();continue}if(this.isIdentifierStart(e)){this.readIdentifier();continue}if(!this.readOperatorOrPunctuation())throw new Error(`Unexpected character '${e}' at ${this.line}:${this.column}`)}for(;this.indentStack.length>1;)this.indentStack.pop(),this.addToken(g.DEDENT,"",this.getCurrentIndent());return this.addToken(g.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(g.NEWLINE,`
|
|
36
36
|
`),this.atLineStart=!0),this.advance(),this.line++,this.column=1}handleIndentation(){let e=0,i=0;for(this.pos;this.pos<this.source.length;){const n=this.peek();if(n===" ")i++,this.advance();else if(n===" ")e++,this.advance();else break}if(this.peek()===`
|
|
37
|
-
`||this.peek()==="\r"||this.peek()==="\0")return;e+=Math.floor(i/4);const r=this.indentStack[this.indentStack.length-1];if(e>r)this.indentStack.push(e),this.addToken(
|
|
38
|
-
`;)e+=this.advance();this.addToken(
|
|
39
|
-
`;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case e:r+=e;break;default:r+=n}}else r+=this.advance();if(this.peek()!==e)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(x.STRING,r)}readColorLiteral(){const e=this.column;let i="#";for(this.advance();this.pos<this.source.length&&i.length<9;){const r=this.peek();if(r>="0"&&r<="9"||r>="A"&&r<="F"||r>="a"&&r<="f")i+=this.advance();else break}if(i.length!==7&&i.length!==9)throw new Error(`Invalid color literal '${i}' at ${this.line}:${e}`);this.addToken(x.STRING,i)}readNumber(){this.column;let e="",i=!1;for(this.peek()==="."&&this.isDigit(this.peek(1))&&(i=!0,e+=this.advance());this.pos<this.source.length;){const r=this.peek();if(this.isDigit(r))e+=this.advance();else if(r==="."&&!i){const n=this.peek(1);if(this.isDigit(n)||!this.isIdentifierStart(n)){if(i=!0,e+=this.advance(),!this.isDigit(this.peek()))break}else break}else break}if(this.pos<this.source.length){const r=this.peek();if(r==="e"||r==="E"){const n=this.peek(1);if(this.isDigit(n))for(e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance();else if(n==="+"||n==="-"){const a=this.peek(2);if(this.isDigit(a))for(e+=this.advance(),e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance()}}}this.addToken(x.NUMBER,parseFloat(e))}readIdentifier(){this.column;let e="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)e+=this.advance();Ws.has(e)?this.addToken(x.KEYWORD,e):e==="true"||e==="false"?this.addToken(x.BOOLEAN,e==="true"):this.addToken(x.IDENTIFIER,e)}readOperatorOrPunctuation(){const e=this.peek(),i=this.peek(1),r=e+i;if($s.includes(r))return this.advance(),this.advance(),this.addToken(x.OPERATOR,r),!0;if("+-*/%<>=!?".includes(e))return this.advance(),this.addToken(x.OPERATOR,e),!0;switch(e){case"(":return this.parenDepth++,this.advance(),this.addToken(x.LPAREN,e),!0;case")":return this.parenDepth--,this.advance(),this.addToken(x.RPAREN,e),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(x.LBRACKET,e),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(x.RBRACKET,e),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(x.LBRACE,e),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(x.RBRACE,e),!0;case",":return this.advance(),this.addToken(x.COMMA,e),!0;case".":return this.isDigit(this.peek(1))?(this.readNumber(),!0):(this.advance(),this.addToken(x.DOT,e),!0);case":":return this.advance(),this.addToken(x.COLON,e),!0;case";":return this.advance(),this.addToken(x.SEMICOLON,e),!0}return!1}peek(e=0){const i=this.pos+e;return i<this.source.length?this.source[i]:"\0"}advance(){const e=this.source[this.pos++];return this.column++,e}skipWhitespaceInline(){if(!this.atLineStart)for(;this.pos<this.source.length&&(this.peek()===" "||this.peek()===" ");)this.advance()}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}getCurrentIndent(){return this.indentStack[this.indentStack.length-1]}addToken(e,i,r=null){const n=new Us(e,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(n)}}class ${constructor(e){this.type=e}}class zs extends ${constructor(e){super("Program"),this.body=e}}class ue extends ${constructor(e){super("ExpressionStatement"),this.expression=e}}var Me=(t=>(t.VAR="var",t.LET="let",t.CONST="const",t))(Me||{});class Pe extends ${constructor(e,i="let"){super("VariableDeclaration"),this.declarations=e,this.kind=i}}class De extends ${constructor(e,i,r=null){super("VariableDeclarator"),this.id=e,this.init=i,this.varType=r}}class Bi extends ${constructor(e,i,r,n=null){super("FunctionDeclaration"),this.id=e,this.params=i,this.body=r,this.returnType=n}}class Ks extends ${constructor(e,i){super("TypeDefinition"),this.name=e,this.fields=i}}class Hs extends ${constructor(e,i,r=null){super("IfStatement"),this.test=e,this.consequent=i,this.alternate=r}_line}class Fi extends ${constructor(e,i,r,n){super("ForStatement"),this.init=e,this.test=i,this.update=r,this.body=n}isForIn}class Gs extends ${constructor(e,i){super("WhileStatement"),this.test=e,this.body=i}}class Be extends ${constructor(e){super("BlockStatement"),this.body=e}}class Wi extends ${constructor(e){super("ReturnStatement"),this.argument=e}}class X extends ${constructor(e){super("Identifier"),this.name=e}varType;returnType;isMethod}class Ge extends ${constructor(e,i=null){super("Literal"),this.value=e,this.raw=i}}class Re extends ${constructor(e,i,r){super("BinaryExpression"),this.operator=e,this.left=i,this.right=r}}class $i extends ${constructor(e,i,r=!0){super("UnaryExpression"),this.operator=e,this.argument=i,this.prefix=r}}class xt extends ${constructor(e,i,r){super("AssignmentExpression"),this.operator=e,this.left=i,this.right=r}}class Ui extends ${constructor(e,i,r=!1){super("UpdateExpression"),this.operator=e,this.argument=i,this.prefix=r}}class Ys extends ${constructor(e,i){super("CallExpression"),this.callee=e,this.args=i,this.callee=e,this.arguments=i}arguments}class qi extends ${constructor(e,i,r=!1){super("MemberExpression"),this.object=e,this.property=i,this.computed=r}}class Fe extends ${constructor(e,i,r){super("ConditionalExpression"),this.test=e,this.consequent=i,this.alternate=r}needsIIFE;consequentStmts;alternateStmts}class Qs extends ${constructor(e){super("ArrayExpression"),this.elements=e}}class zi extends ${constructor(e){super("ObjectExpression"),this.properties=e}}class Ki extends ${constructor(e,i){super("Property"),this.key=e,this.value=i,this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}kind;method;shorthand;computed}class Hi extends ${constructor(e){super("ArrayPattern"),this.elements=e}}class Gi extends ${constructor(e,i){super("AssignmentPattern"),this.left=e,this.right=i}}class Xs extends ${constructor(e,i){super("SwitchExpression"),this.discriminant=e,this.cases=i}}class Zs extends ${constructor(e,i,r){super("SwitchCase"),this.test=e,this.consequent=i,this.statements=r,this.statements=r}}class Js{tokens;pos;functionNames=new Set;constructor(e){this.tokens=e,this.pos=0}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){return this.tokens[this.pos++]}match(e,i=null){const r=this.peek();return!(r.type!==e||i!==null&&r.value!==i)}expect(e,i=null){const r=this.peek();if(r.type!==e)throw new Error(`Expected ${e} but got ${r.type} at ${r.line}:${r.column}`);if(i!==null&&r.value!==i)throw new Error(`Expected '${i}' but got '${r.value}' at ${r.line}:${r.column}`);return this.advance()}matchEx(e,i=null,r=!1){if(!r)return this.match(e,i);let n=0,a=this.peek(n);if(a.type===x.NEWLINE&&(n++,a=this.peek(n),a.type===x.INDENT&&(n++,a=this.peek(n))),a.type!==e||i!==null&&a.value!==i)return!1;for(let s=0;s<n;s++)this.advance();return!0}peekOperatorEx(e){let i=0,r=this.peek(i),n=!1;if(r.type===x.NEWLINE&&(i++,r=this.peek(i),r.type===x.INDENT&&(n=!0,i++,r=this.peek(i))),r.type!==x.OPERATOR||!e.includes(r.value)||n&&(r.value==="+"||r.value==="-"))return null;for(let a=0;a<i;a++)this.advance();return r.value}skipNewlines(e=!1){for(;this.match(x.NEWLINE)||this.match(x.COMMENT);)this.advance();e&&this.match(x.INDENT)&&this.advance()}parse(){const e=[];for(;!this.match(x.EOF);){if(this.skipNewlines(),this.match(x.DEDENT)){this.advance();continue}if(this.match(x.EOF))break;const i=this.parseStatement();i&&e.push(i),this.skipNewlines()}return new zs(e)}parseStatement(e=!0){this.skipNewlines();const i=this.peek().line;if(this.match(x.COMMENT))return this.advance(),null;let r;if(this.match(x.KEYWORD,"enum"))r=this.parseEnumDefinition();else if(this.match(x.KEYWORD,"type"))r=this.parseTypeDefinition();else if(this.match(x.KEYWORD,"var")||this.match(x.KEYWORD,"varip"))r=this.parseVarDeclaration();else if(this.match(x.KEYWORD,"method"))r=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())r=this.parseFunctionDeclaration();else if(this.match(x.KEYWORD,"if"))r=this.parseIfStatement();else if(this.match(x.KEYWORD,"for"))r=this.parseForStatement();else if(this.match(x.KEYWORD,"while"))r=this.parseWhileStatement();else if(this.match(x.KEYWORD,"break")||this.match(x.KEYWORD,"continue")){const n=this.advance().value;r=new ue(new X(n))}else this.isTupleDestructuring()?r=this.parseTupleDestructuring():this.peek().type===x.IDENTIFIER&&this.isTypedVarDeclaration()&&(r=this.parseTypedVarDeclaration());if(!r){const n=this.parseExpression();if(this.match(x.OPERATOR)){const a=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(a)){this.advance(),this.skipNewlines(!0);const s=this.parseExpression();a==="="&&n.type==="Identifier"?r=new Pe([new De(n,s)],Me.LET):r=new ue(new xt(a===":="?"=":a,n,s))}else r=new ue(n)}else r=new ue(n)}if(r&&(r._line=i,e&&this.match(x.COMMA)&&this.peek().line===i)){const n=[r];for(;this.match(x.COMMA)&&this.peek().line===i;){this.advance(),this.skipNewlines(!0);const a=this.parseStatement(!1);a&&n.push(a)}return new Be(n)}return r}isFunctionDeclaration(){const e=this.pos;try{let i=0;if(this.peek(i).type===x.IDENTIFIER&&this.peek(i+1).type===x.IDENTIFIER&&i++,this.peek(i).type!==x.IDENTIFIER||(i++,this.peek(i).type!==x.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==x.EOF;)this.peek(i).type===x.LPAREN&&r++,this.peek(i).type===x.RPAREN&&r--,i++;for(;this.peek(i).type===x.NEWLINE;)i++;return this.peek(i).type===x.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=e}}parseTypeExpression(){let e=this.expect(x.IDENTIFIER).value;for(;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(x.OPERATOR,"<")){this.advance();const i=[];for(i.push(this.parseTypeExpression());this.match(x.COMMA);)this.advance(),this.skipNewlines(),i.push(this.parseTypeExpression());return this.expect(x.OPERATOR,">"),e+"<"+i.join(", ")+">"}return this.match(x.LBRACKET)&&this.peek(1).type===x.RBRACKET?(this.advance(),this.advance(),"array<"+e+">"):e}parseEnumDefinition(){this.expect(x.KEYWORD,"enum");const e=this.expect(x.IDENTIFIER).value;this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){if(this.match(x.COMMENT)){this.advance();continue}const a=this.expect(x.IDENTIFIER).value;i.push(a),this.skipNewlines()}this.match(x.DEDENT)&&this.advance();const r=i.map(a=>new Ki(new X(a),new Ge(`${e}.${a}`))),n=new zi(r);return new Pe([new De(new X(e),n)],Me.CONST)}parseTypeDefinition(){this.expect(x.KEYWORD,"type");const e=this.expect(x.IDENTIFIER).value;this.match(x.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const r=this.parseTypeExpression(),n=this.expect(x.IDENTIFIER).value;let a=null;this.match(x.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),a=this.parseExpression()),i.push({type:r,name:n,defaultValue:a}),this.skipNewlines()}return this.match(x.DEDENT)&&this.advance(),new Ks(e,i)}parseVarDeclaration(){const e=this.advance().value;let i=null,r=null;if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.LBRACKET&&this.peek(2).type===x.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(x.IDENTIFIER).value;else if(this.peek().type===x.IDENTIFIER&&(this.peek(1).type===x.DOT||this.peek(1).type===x.IDENTIFIER||this.peek(1).type===x.OPERATOR&&this.peek(1).value==="<")){for(i=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),i+="."+this.advance().value;if(this.match(x.LBRACKET)&&this.peek(1).type===x.RBRACKET)this.advance(),this.advance(),i+="[]",r=this.expect(x.IDENTIFIER).value;else if(this.match(x.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(x.OPERATOR,">");)if(this.match(x.IDENTIFIER))for(i+=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)i+=".",this.advance(),i+=this.advance().value;else if(this.match(x.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(x.OPERATOR,">")&&(i+=">",this.advance()),r=this.expect(x.IDENTIFIER).value}else r=this.expect(x.IDENTIFIER).value}else if(this.peek().type===x.IDENTIFIER)r=this.advance().value;else throw new Error(`Expected identifier after ${e} at ${this.peek().line}:${this.peek().column}`);this.functionNames.has(r)&&(r=r+"_var"),this.expect(x.OPERATOR,"="),this.skipNewlines(!0);const n=this.parseExpression(),a=new X(r);i&&(a.varType=i);const s=[new De(a,n,i)];for(;this.match(x.COMMA)&&this.peek(1).type===x.KEYWORD&&(this.peek(1).value==="var"||this.peek(1).value==="varip");){this.advance();const o=this.parseVarDeclaration();s.push(...o.declarations)}return new Pe(s,e)}isTypedVarDeclaration(){let e=0;if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.DOT&&this.peek(e+1).type===x.IDENTIFIER;)e+=2;if(this.peek(e).type===x.LBRACKET&&this.peek(e+1).type===x.RBRACKET)return e+=2,this.peek(e).type!==x.IDENTIFIER?!1:(e++,this.peek(e).type===x.OPERATOR&&this.peek(e).value==="=");if(this.peek(e).type===x.OPERATOR&&this.peek(e).value==="<"){e++;let i=1;for(;i>0&&this.peek(e).type!==x.EOF;)this.peek(e).type===x.OPERATOR&&this.peek(e).value==="<"?i++:this.peek(e).type===x.OPERATOR&&this.peek(e).value===">"&&i--,e++;return this.peek(e).type!==x.IDENTIFIER?!1:(e++,this.peek(e).type===x.OPERATOR&&this.peek(e).value==="=")}if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.IDENTIFIER;)e++;return this.peek(e).type===x.OPERATOR&&this.peek(e).value==="="}parseTypedVarDeclaration(){let e=this.advance().value;for(;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(x.LBRACKET)&&this.peek(1).type===x.RBRACKET)this.advance(),this.advance(),e+="[]";else if(this.match(x.OPERATOR,"<")){for(this.advance(),e+="<";!this.match(x.OPERATOR,">");)if(this.match(x.IDENTIFIER))for(e+=this.advance().value;this.match(x.DOT)&&this.peek(1).type===x.IDENTIFIER;)e+=".",this.advance(),e+=this.advance().value;else if(this.match(x.COMMA))e+=this.advance().value,this.skipNewlines();else break;this.match(x.OPERATOR,">")&&(e+=">",this.advance())}else for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER;)e+=" "+this.advance().value;let i=this.expect(x.IDENTIFIER).value;this.functionNames.has(i)&&(i=i+"_var"),this.expect(x.OPERATOR,"="),this.skipNewlines(!0);const r=this.parseExpression(),n=new X(i);return n.varType=e,new Pe([new De(n,r,e)],Me.LET)}parseFunctionDeclaration(){let e=null;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&(e=this.advance().value);const i=this.expect(x.IDENTIFIER).value;this.functionNames.add(i),this.expect(x.LPAREN);const r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){let s=null;for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type!==x.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.OPERATOR&&this.peek(1).value==="<"){const c=this.parseTypeExpression();s=s?s+" "+c:c}if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.LBRACKET&&this.peek(2).type===x.RBRACKET){const c=this.parseTypeExpression();s=s?s+" "+c:c}const o=this.expect(x.IDENTIFIER).value,l=new X(o);if(s&&(l.varType=s),this.match(x.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Gi(l,c))}else r.push(l);this.match(x.COMMA)&&this.advance()}this.expect(x.RPAREN),this.skipNewlines(),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new X(i);return e&&(a.returnType=e),new Bi(a,r,n,e)}parseMethodDeclaration(){this.expect(x.KEYWORD,"method");let e=null;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type===x.LPAREN&&(e=this.advance().value);const i=this.expect(x.IDENTIFIER).value;this.expect(x.LPAREN);const r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){let s=null;for(;this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.IDENTIFIER&&this.peek(2).type!==x.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.OPERATOR&&this.peek(1).value==="<"){const c=this.parseTypeExpression();s=s?s+" "+c:c}if(this.peek().type===x.IDENTIFIER&&this.peek(1).type===x.LBRACKET&&this.peek(2).type===x.RBRACKET){const c=this.parseTypeExpression();s=s?s+" "+c:c}const o=this.expect(x.IDENTIFIER).value,l=new X(o);if(s&&(l.varType=s),this.match(x.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new Gi(l,c))}else r.push(l);this.match(x.COMMA)&&this.advance()}this.expect(x.RPAREN),this.skipNewlines(),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new X(i);return e&&(a.returnType=e),a.isMethod=!0,new Bi(a,r,n,e)}parseFunctionBody(){const e=[];if(!this.match(x.INDENT)){const i=this.parseExpression();return new Be([new Wi(i)])}for(this.advance();!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?e.push(...i):i&&e.push(i)}return this.match(x.DEDENT)&&this.advance(),e.length>0&&this._addImplicitReturn(e),new Be(e)}_addImplicitReturn(e){const i=e[e.length-1];i.type==="ExpressionStatement"?e[e.length-1]=new Wi(i.expression):i.type==="IfStatement"&&this._addImplicitReturnToIf(i)}_addImplicitReturnToIf(e){e.consequent&&e.consequent.type==="BlockStatement"&&e.consequent.body.length>0&&this._addImplicitReturn(e.consequent.body),e.alternate&&(e.alternate.type==="IfStatement"?this._addImplicitReturnToIf(e.alternate):e.alternate.type==="BlockStatement"&&e.alternate.body.length>0&&this._addImplicitReturn(e.alternate.body))}parseStatementOrSequence(){this.pos;const e=this.peek().line;if(this.match(x.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=e),r}if(this.match(x.KEYWORD,"for"))return this.parseForStatement();if(this.match(x.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(x.KEYWORD,"break")||this.match(x.KEYWORD,"continue")){const r=this.advance().value;return new ue(new X(r))}if(this.match(x.KEYWORD,"var")||this.match(x.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===x.IDENTIFIER&&this.isTypedVarDeclaration()){const r=this.parseTypedVarDeclaration();if(this.match(x.COMMA)&&this.peek(1).type===x.IDENTIFIER){const n=[r];for(;this.match(x.COMMA);)if(this.advance(),this.skipNewlines(!0),this.peek().type===x.IDENTIFIER&&this.isTypedVarDeclaration())n.push(this.parseTypedVarDeclaration());else{const a=this.parseExpression();if(this.match(x.OPERATOR)){const s=this.peek().value;if(["=",":="].includes(s)){this.advance(),this.skipNewlines(!0);const o=this.parseExpression();s==="="&&a.type==="Identifier"?n.push(new Pe([new De(a,o)],Me.LET)):n.push(new ue(new xt(s===":="?"=":s,a,o)))}}break}return n}return r}const i=[];for(;;){const r=this.parseExpression();if(this.match(x.OPERATOR)){const n=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(n)){this.advance(),this.skipNewlines(!0);const a=this.parseExpression();if(n==="="&&r.type==="Identifier"?i.push(new Pe([new De(r,a)],Me.LET)):i.push(new ue(new xt(n===":="?"=":n,r,a))),this.match(x.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new ue(r));else return new ue(r);break}}else if(this.match(x.COMMA)){i.push(new ue(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new ue(r));else return new ue(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(x.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.skipNewlines(),this.match(x.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(x.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new Hs(e,i,r)}parseForStatement(){this.expect(x.KEYWORD,"for");let e=null,i=!1;if(this.match(x.LBRACKET)){this.advance();const r=[];for(;!this.match(x.RBRACKET);)this.skipNewlines(),r.push(new X(this.expect(x.IDENTIFIER).value)),this.match(x.COMMA)&&this.advance();this.expect(x.RBRACKET),e=new Hi(r),i=!0}else{const r=this.expect(x.IDENTIFIER).value;e=new X(r)}if(this.match(x.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const n=this.parseBlock(),a=new Pe([new De(e,r)],Me.CONST),s=new Fi(a,null,null,n);return s.isForIn=!0,s}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(x.OPERATOR,"=");const r=this.parseExpression();this.expect(x.KEYWORD,"to");const n=this.parseExpression();let a=null;this.match(x.KEYWORD,"by")&&(this.advance(),a=this.parseExpression()),this.skipNewlines();const s=this.parseBlock(),o=new Pe([new De(e,r)],Me.LET),l=new Re("<=",r,n),c=new Fe(l,new Re("<=",e,n),new Re(">=",e,n));let h;return a?h=new Fe(l,new xt("+=",e,a),new xt("-=",e,a)):h=new Fe(l,new Ui("++",e),new Ui("--",e)),new Fi(o,c,h,s)}}parseWhileStatement(){this.expect(x.KEYWORD,"while");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new Gs(e,i)}parseBlock(){if(!this.match(x.INDENT)){const r=this.parseStatement();return new Be(r?[r]:[])}const e=this.peek().indent;this.advance();const i=[];for(;!this.match(x.EOF);){if(this.skipNewlines(),this.match(x.DEDENT)){if(this.peek().indent<e)break;this.advance();continue}if(this.match(x.EOF))break;const r=this.parseStatement();r&&i.push(r)}return this.match(x.DEDENT)&&this.peek().indent<e&&this.advance(),new Be(i)}isTupleDestructuring(){if(!this.match(x.LBRACKET))return!1;let e=1;for(;;){for(;this.peek(e).type===x.NEWLINE;)e++;if(this.peek(e).type!==x.IDENTIFIER)return!1;for(e++;this.peek(e).type===x.NEWLINE;)e++;if(this.peek(e).type===x.RBRACKET){e++;break}else if(this.peek(e).type===x.COMMA){e++;continue}else return!1}for(;this.peek(e).type===x.NEWLINE;)e++;return this.peek(e).type===x.OPERATOR&&this.peek(e).value==="="}parseTupleDestructuring(){this.expect(x.LBRACKET);const e=[];for(;!this.match(x.RBRACKET);){this.skipNewlines();let r=this.expect(x.IDENTIFIER).value;this.functionNames.has(r)&&(r=r+"_var"),e.push(new X(r)),this.match(x.COMMA)&&this.advance()}this.expect(x.RBRACKET),this.skipNewlines(),this.expect(x.OPERATOR,"="),this.skipNewlines(!0);const i=this.parseExpression();return new Pe([new De(new Hi(e),i)],Me.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let e=this.parseLogicalOr();if(this.matchEx(x.OPERATOR,"?",!0)){this.advance(),this.skipNewlines(!0);const i=this.parseExpression();this.matchEx(x.COLON,null,!0)?this.advance():this.expect(x.COLON),this.skipNewlines(!0);const r=this.parseExpression();return new Fe(e,i,r)}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.matchEx(x.KEYWORD,"or",!0)||this.peekOperatorEx(["||"]);){this.advance(),this.skipNewlines(!0);const i=this.parseLogicalAnd();e=new Re("||",e,i)}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.matchEx(x.KEYWORD,"and",!0)||this.peekOperatorEx(["&&"]);){this.advance(),this.skipNewlines(!0);const i=this.parseEquality();e=new Re("&&",e,i)}return e}parseEquality(){let e=this.parseComparison();for(;this.peekOperatorEx(["==","!="]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseComparison();e=new Re(i,e,r)}return e}parseComparison(){let e=this.parseAdditive();for(;this.peekOperatorEx(["<",">","<=",">="]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseAdditive();e=new Re(i,e,r)}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.peekOperatorEx(["+","-"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseMultiplicative();e=new Re(i,e,r)}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.peekOperatorEx(["*","/","%"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseUnary();e=new Re(i,e,r)}return e}parseUnary(){if(this.match(x.OPERATOR)){const e=this.peek().value;if(["+","-","!"].includes(e))return this.advance(),this.skipNewlines(),new $i(e,this.parseUnary())}return this.match(x.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new $i("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(x.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,n=!0,a="";const s=new Set(["float","int","string","bool","color","line","label","box","linefill","table"]);for(;r>0&&!this.match(x.EOF);)if(this.match(x.OPERATOR,"<"))r++,this.advance();else if(this.match(x.OPERATOR,">"))r--,this.advance();else if(this.match(x.IDENTIFIER)||this.match(x.COMMA)||this.match(x.DOT))r===1&&this.match(x.IDENTIFIER)&&a===""&&(a=this.peek().value),this.advance();else{n=!1,this.pos=i;break}if(n&&e.type==="MemberExpression"&&e.property.name==="new"&&(e.object.name==="array"||e.object.name==="matrix")&&s.has(a)&&(e.property=new X("new_"+a)),n&&this.match(x.LPAREN)){e=this.parseCallExpression(e);continue}else{if(n)continue;break}}else if(this.match(x.LPAREN))e=this.parseCallExpression(e);else if(this.match(x.DOT)){this.advance(),this.skipNewlines();const i=this.peek();if(i.type!==x.IDENTIFIER&&i.type!==x.KEYWORD)throw new Error(`Expected property name but got ${i.type} at ${i.line}:${i.column}`);this.advance(),e=new qi(e,new X(i.value),!1)}else if(this.match(x.LBRACKET)){if(this.isTupleDestructuring())break;this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(x.RBRACKET),e=new qi(e,i,!0)}else break;return e}parseCallExpression(e){this.expect(x.LPAREN);const i=[],r=[];for(;!this.match(x.RPAREN)&&(this.skipNewlines(),!this.match(x.RPAREN));){if((this.peek().type===x.IDENTIFIER||this.peek().type===x.KEYWORD)&&this.peek(1).type===x.OPERATOR&&this.peek(1).value==="="){const n=this.advance().value;this.advance(),this.skipNewlines();const a=this.parseExpression();r.push(new Ki(new X(n),a))}else i.push(this.parseExpression());this.match(x.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(x.RPAREN),r.length>0&&i.push(new zi(r)),new Ys(e,i)}parsePrimary(){const e=this.peek();if(this.match(x.NUMBER)){const i=this.advance();return new Ge(i.value)}if(this.match(x.STRING)){const i=this.advance();return new Ge(i.value)}if(this.match(x.BOOLEAN)){const i=this.advance();return new Ge(i.value)}if(this.match(x.IDENTIFIER)){let i=this.advance().value;return this.functionNames.has(i)&&this.peek().type!==x.LPAREN&&(i=i+"_var"),new X(i)}if(this.match(x.LBRACKET))return this.parseArrayLiteral();if(this.match(x.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(x.RPAREN),i}if(this.match(x.KEYWORD,"if"))return this.parseIfExpression();if(this.match(x.KEYWORD,"switch"))return this.parseSwitchExpression();if(this.match(x.KEYWORD,"for"))return this.parseForExpression();if(this.match(x.KEYWORD,"while"))return this.parseWhileExpression();throw new Error(`Unexpected token ${e.type} '${e.value}' at ${e.line}:${e.column}`)}parseArrayLiteral(){this.expect(x.LBRACKET);const e=[];for(;!this.match(x.RBRACKET)&&(this.skipNewlines(),!this.match(x.RBRACKET));)e.push(this.parseExpression()),this.match(x.COMMA)&&this.advance(),this.skipNewlines();return this.expect(x.RBRACKET),new Qs(e)}parseIfExpression(){this.expect(x.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&i.push(s)}this.advance();let r=[];if(this.match(x.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(x.KEYWORD,"if")){const s=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new Fe(e,new Be(i),s);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=s,o}else return new Fe(e,this.getBlockValue(i),s)}else{for(this.expect(x.INDENT);!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&r.push(s)}this.advance()}if(this.needsIIFE(i,r)){const s=new Fe(e,new Be(i),new Be(r));return s.needsIIFE=!0,s.consequentStmts=i,s.alternateStmts=r,s}const n=this.getBlockValue(i),a=r.length>0?this.getBlockValue(r):new Ge(null);return new Fe(e,n,a)}needsIIFE(e,i){if(e.length>1||i.length>1)return!0;const r=n=>n.some(a=>a.type==="IfStatement"||a.type==="ForStatement"||a.type==="WhileStatement"||a.type==="BlockStatement");return r(e)||r(i)}parseSwitchExpression(){this.expect(x.KEYWORD,"switch");let e=null;!this.match(x.NEWLINE)&&!this.match(x.INDENT)&&(e=this.parseExpression()),this.skipNewlines(),this.expect(x.INDENT);const i=[];for(;!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){let r=null;this.match(x.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(x.OPERATOR,"=>"),this.skipNewlines();const n=[];if(this.match(x.INDENT)){for(this.advance();!this.match(x.DEDENT)&&!this.match(x.EOF)&&(this.skipNewlines(),!this.match(x.DEDENT));){const s=this.parseStatement();s&&n.push(s)}this.advance()}else n.push(new ue(this.parseExpression()));const a=this.getBlockValue(n);i.push(new Zs(r,a,n)),this.skipNewlines()}return this.advance(),new Xs(e,i)}parseForExpression(){const e=this.parseForStatement();return e.isExpression=!0,e}parseWhileExpression(){const e=this.parseWhileStatement();return e.isExpression=!0,e}getBlockValue(e){if(e.length===0)return new Ge(null);const i=e[e.length-1];return i.type==="ExpressionStatement"?i.expression:i.type==="VariableDeclaration"&&i.declarations.length>0?i.declarations[0].id:new Ge(null)}}const ea=new Set(vi);class ta{indent;indentStr;output;sourceCode;sourceLines;lastCommentedLine;includeSourceComments;paramRenameCounter;functionParams;constructor(e={}){this.indent=0,this.indentStr=e.indentStr||" ",this.output=[],this.sourceCode=e.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
|
|
37
|
+
`||this.peek()==="\r"||this.peek()==="\0")return;e+=Math.floor(i/4);const r=this.indentStack[this.indentStack.length-1];if(e>r)this.indentStack.push(e),this.addToken(g.INDENT,"",e);else if(e<r){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>e;)this.indentStack.pop(),this.addToken(g.DEDENT,"",this.indentStack[this.indentStack.length-1]);if(this.indentStack[this.indentStack.length-1]!==e)throw new Error(`Indentation error at ${this.line}:${this.column} - misaligned dedent`)}}readComment(){this.column;let e="";for(this.advance(),this.advance();this.pos<this.source.length&&this.peek()!==`
|
|
38
|
+
`;)e+=this.advance();this.addToken(g.COMMENT,e.trim())}readString(){const e=this.advance(),i=this.column-1;let r="";for(;this.pos<this.source.length&&this.peek()!==e;)if(this.peek()==="\\"){this.advance();const n=this.advance();switch(n){case"n":r+=`
|
|
39
|
+
`;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case e:r+=e;break;default:r+=n}}else r+=this.advance();if(this.peek()!==e)throw new Error(`Unterminated string at ${this.line}:${i}`);this.advance(),this.addToken(g.STRING,r)}readColorLiteral(){const e=this.column;let i="#";for(this.advance();this.pos<this.source.length&&i.length<9;){const r=this.peek();if(r>="0"&&r<="9"||r>="A"&&r<="F"||r>="a"&&r<="f")i+=this.advance();else break}if(i.length!==7&&i.length!==9)throw new Error(`Invalid color literal '${i}' at ${this.line}:${e}`);this.addToken(g.STRING,i)}readNumber(){this.column;let e="",i=!1;for(this.peek()==="."&&this.isDigit(this.peek(1))&&(i=!0,e+=this.advance());this.pos<this.source.length;){const r=this.peek();if(this.isDigit(r))e+=this.advance();else if(r==="."&&!i){const n=this.peek(1);if(this.isDigit(n)||!this.isIdentifierStart(n)){if(i=!0,e+=this.advance(),!this.isDigit(this.peek()))break}else break}else break}if(this.pos<this.source.length){const r=this.peek();if(r==="e"||r==="E"){const n=this.peek(1);if(this.isDigit(n))for(e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance();else if(n==="+"||n==="-"){const a=this.peek(2);if(this.isDigit(a))for(e+=this.advance(),e+=this.advance();this.pos<this.source.length&&this.isDigit(this.peek());)e+=this.advance()}}}this.addToken(g.NUMBER,parseFloat(e))}readIdentifier(){this.column;let e="";for(;this.pos<this.source.length&&this.isIdentifierChar(this.peek());)e+=this.advance();ca.has(e)?this.addToken(g.KEYWORD,e):e==="true"||e==="false"?this.addToken(g.BOOLEAN,e==="true"):this.addToken(g.IDENTIFIER,e)}readOperatorOrPunctuation(){const e=this.peek(),i=this.peek(1),r=e+i;if(ha.includes(r))return this.advance(),this.advance(),this.addToken(g.OPERATOR,r),!0;if("+-*/%<>=!?".includes(e))return this.advance(),this.addToken(g.OPERATOR,e),!0;switch(e){case"(":return this.parenDepth++,this.advance(),this.addToken(g.LPAREN,e),!0;case")":return this.parenDepth--,this.advance(),this.addToken(g.RPAREN,e),!0;case"[":return this.bracketDepth++,this.advance(),this.addToken(g.LBRACKET,e),!0;case"]":return this.bracketDepth--,this.advance(),this.addToken(g.RBRACKET,e),!0;case"{":return this.braceDepth++,this.advance(),this.addToken(g.LBRACE,e),!0;case"}":return this.braceDepth--,this.advance(),this.addToken(g.RBRACE,e),!0;case",":return this.advance(),this.addToken(g.COMMA,e),!0;case".":return this.isDigit(this.peek(1))?(this.readNumber(),!0):(this.advance(),this.addToken(g.DOT,e),!0);case":":return this.advance(),this.addToken(g.COLON,e),!0;case";":return this.advance(),this.addToken(g.SEMICOLON,e),!0}return!1}peek(e=0){const i=this.pos+e;return i<this.source.length?this.source[i]:"\0"}advance(){const e=this.source[this.pos++];return this.column++,e}skipWhitespaceInline(){if(!this.atLineStart)for(;this.pos<this.source.length&&(this.peek()===" "||this.peek()===" ");)this.advance()}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}getCurrentIndent(){return this.indentStack[this.indentStack.length-1]}addToken(e,i,r=null){const n=new ua(e,i,this.line,this.column,r!==null?r:this.getCurrentIndent());this.tokens.push(n)}}class W{constructor(e){this.type=e}}class fa extends W{constructor(e){super("Program"),this.body=e}}class pe extends W{constructor(e){super("ExpressionStatement"),this.expression=e}}var Ve=(t=>(t.VAR="var",t.LET="let",t.CONST="const",t))(Ve||{});class Me extends W{constructor(e,i="let"){super("VariableDeclaration"),this.declarations=e,this.kind=i}}class Re extends W{constructor(e,i,r=null){super("VariableDeclarator"),this.id=e,this.init=i,this.varType=r}}class Yi extends W{constructor(e,i,r,n=null){super("FunctionDeclaration"),this.id=e,this.params=i,this.body=r,this.returnType=n}}class da extends W{constructor(e,i){super("TypeDefinition"),this.name=e,this.fields=i}}class ma extends W{constructor(e,i,r=null){super("IfStatement"),this.test=e,this.consequent=i,this.alternate=r}_line}class Xi extends W{constructor(e,i,r,n){super("ForStatement"),this.init=e,this.test=i,this.update=r,this.body=n}isForIn}class ga extends W{constructor(e,i){super("WhileStatement"),this.test=e,this.body=i}}class $e extends W{constructor(e){super("BlockStatement"),this.body=e}}class Qi extends W{constructor(e){super("ReturnStatement"),this.argument=e}}class Z extends W{constructor(e){super("Identifier"),this.name=e}varType;returnType;isMethod}class Xe extends W{constructor(e,i=null){super("Literal"),this.value=e,this.raw=i}}class Oe extends W{constructor(e,i,r){super("BinaryExpression"),this.operator=e,this.left=i,this.right=r}}class Zi extends W{constructor(e,i,r=!0){super("UnaryExpression"),this.operator=e,this.argument=i,this.prefix=r}}class wt extends W{constructor(e,i,r){super("AssignmentExpression"),this.operator=e,this.left=i,this.right=r}}class Ji extends W{constructor(e,i,r=!1){super("UpdateExpression"),this.operator=e,this.argument=i,this.prefix=r}}class ya extends W{constructor(e,i){super("CallExpression"),this.callee=e,this.args=i,this.callee=e,this.arguments=i}arguments}class er extends W{constructor(e,i,r=!1){super("MemberExpression"),this.object=e,this.property=i,this.computed=r}}class We extends W{constructor(e,i,r){super("ConditionalExpression"),this.test=e,this.consequent=i,this.alternate=r}needsIIFE;consequentStmts;alternateStmts}class xa extends W{constructor(e){super("ArrayExpression"),this.elements=e}}class tr extends W{constructor(e){super("ObjectExpression"),this.properties=e}}class ir extends W{constructor(e,i){super("Property"),this.key=e,this.value=i,this.kind="init",this.method=!1,this.shorthand=!1,this.computed=!1}kind;method;shorthand;computed}class rr extends W{constructor(e){super("ArrayPattern"),this.elements=e}}class nr extends W{constructor(e,i){super("AssignmentPattern"),this.left=e,this.right=i}}class _a extends W{constructor(e,i){super("SwitchExpression"),this.discriminant=e,this.cases=i}}class ba extends W{constructor(e,i,r){super("SwitchCase"),this.test=e,this.consequent=i,this.statements=r,this.statements=r}}class wa{tokens;pos;functionNames=new Set;constructor(e){this.tokens=e,this.pos=0}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){return this.tokens[this.pos++]}match(e,i=null){const r=this.peek();return!(r.type!==e||i!==null&&r.value!==i)}expect(e,i=null){const r=this.peek();if(r.type!==e)throw new Error(`Expected ${e} but got ${r.type} at ${r.line}:${r.column}`);if(i!==null&&r.value!==i)throw new Error(`Expected '${i}' but got '${r.value}' at ${r.line}:${r.column}`);return this.advance()}matchEx(e,i=null,r=!1){if(!r)return this.match(e,i);let n=0,a=this.peek(n);if(a.type===g.NEWLINE&&(n++,a=this.peek(n),a.type===g.INDENT&&(n++,a=this.peek(n))),a.type!==e||i!==null&&a.value!==i)return!1;for(let s=0;s<n;s++)this.advance();return!0}peekOperatorEx(e){let i=0,r=this.peek(i),n=!1;if(r.type===g.NEWLINE&&(i++,r=this.peek(i),r.type===g.INDENT&&(n=!0,i++,r=this.peek(i))),r.type!==g.OPERATOR||!e.includes(r.value)||n&&(r.value==="+"||r.value==="-"))return null;for(let a=0;a<i;a++)this.advance();return r.value}skipNewlines(e=!1){for(;this.match(g.NEWLINE)||this.match(g.COMMENT);)this.advance();e&&this.match(g.INDENT)&&this.advance()}parse(){const e=[];for(;!this.match(g.EOF);){if(this.skipNewlines(),this.match(g.DEDENT)){this.advance();continue}if(this.match(g.EOF))break;const i=this.parseStatement();i&&e.push(i),this.skipNewlines()}return new fa(e)}parseStatement(e=!0){this.skipNewlines();const i=this.peek().line;if(this.match(g.COMMENT))return this.advance(),null;let r;if(this.match(g.KEYWORD,"enum"))r=this.parseEnumDefinition();else if(this.match(g.KEYWORD,"type"))r=this.parseTypeDefinition();else if(this.match(g.KEYWORD,"var")||this.match(g.KEYWORD,"varip"))r=this.parseVarDeclaration();else if(this.match(g.KEYWORD,"method"))r=this.parseMethodDeclaration();else if(this.isFunctionDeclaration())r=this.parseFunctionDeclaration();else if(this.match(g.KEYWORD,"if"))r=this.parseIfStatement();else if(this.match(g.KEYWORD,"for"))r=this.parseForStatement();else if(this.match(g.KEYWORD,"while"))r=this.parseWhileStatement();else if(this.match(g.KEYWORD,"break")||this.match(g.KEYWORD,"continue")){const n=this.advance().value;r=new pe(new Z(n))}else this.isTupleDestructuring()?r=this.parseTupleDestructuring():this.peek().type===g.IDENTIFIER&&this.isTypedVarDeclaration()&&(r=this.parseTypedVarDeclaration());if(!r){const n=this.parseExpression();if(this.match(g.OPERATOR)){const a=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(a)){this.advance(),this.skipNewlines(!0);const s=this.parseExpression();a==="="&&n.type==="Identifier"?r=new Me([new Re(n,s)],Ve.LET):r=new pe(new wt(a===":="?"=":a,n,s))}else r=new pe(n)}else r=new pe(n)}if(r&&(r._line=i,e&&this.match(g.COMMA)&&this.peek().line===i)){const n=[r];for(;this.match(g.COMMA)&&this.peek().line===i;){this.advance(),this.skipNewlines(!0);const a=this.parseStatement(!1);a&&n.push(a)}return new $e(n)}return r}isFunctionDeclaration(){const e=this.pos;try{let i=0;if(this.peek(i).type===g.IDENTIFIER&&this.peek(i+1).type===g.IDENTIFIER&&i++,this.peek(i).type!==g.IDENTIFIER||(i++,this.peek(i).type!==g.LPAREN))return!1;i++;let r=1;for(;r>0&&this.peek(i).type!==g.EOF;)this.peek(i).type===g.LPAREN&&r++,this.peek(i).type===g.RPAREN&&r--,i++;for(;this.peek(i).type===g.NEWLINE;)i++;return this.peek(i).type===g.OPERATOR&&this.peek(i).value==="=>"}finally{this.pos=e}}parseTypeExpression(){let e=this.expect(g.IDENTIFIER).value;for(;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(g.OPERATOR,"<")){this.advance();const i=[];for(i.push(this.parseTypeExpression());this.match(g.COMMA);)this.advance(),this.skipNewlines(),i.push(this.parseTypeExpression());return this.expect(g.OPERATOR,">"),e+"<"+i.join(", ")+">"}return this.match(g.LBRACKET)&&this.peek(1).type===g.RBRACKET?(this.advance(),this.advance(),"array<"+e+">"):e}parseEnumDefinition(){this.expect(g.KEYWORD,"enum");const e=this.expect(g.IDENTIFIER).value;this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){if(this.match(g.COMMENT)){this.advance();continue}const a=this.expect(g.IDENTIFIER).value;i.push(a),this.skipNewlines()}this.match(g.DEDENT)&&this.advance();const r=i.map(a=>new ir(new Z(a),new Xe(`${e}.${a}`))),n=new tr(r);return new Me([new Re(new Z(e),n)],Ve.CONST)}parseTypeDefinition(){this.expect(g.KEYWORD,"type");const e=this.expect(g.IDENTIFIER).value;this.match(g.OPERATOR,"=>")&&this.advance(),this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const r=this.parseTypeExpression(),n=this.expect(g.IDENTIFIER).value;let a=null;this.match(g.OPERATOR,"=")&&(this.advance(),this.skipNewlines(),a=this.parseExpression()),i.push({type:r,name:n,defaultValue:a}),this.skipNewlines()}return this.match(g.DEDENT)&&this.advance(),new da(e,i)}parseVarDeclaration(){const e=this.advance().value;let i=null,r=null;if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.LBRACKET&&this.peek(2).type===g.RBRACKET)i=this.advance().value,this.advance(),i+="[]",this.advance(),r=this.expect(g.IDENTIFIER).value;else if(this.peek().type===g.IDENTIFIER&&(this.peek(1).type===g.DOT||this.peek(1).type===g.IDENTIFIER||this.peek(1).type===g.OPERATOR&&this.peek(1).value==="<")){for(i=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),i+="."+this.advance().value;if(this.match(g.LBRACKET)&&this.peek(1).type===g.RBRACKET)this.advance(),this.advance(),i+="[]",r=this.expect(g.IDENTIFIER).value;else if(this.match(g.OPERATOR,"<")){for(this.advance(),i+="<";!this.match(g.OPERATOR,">");)if(this.match(g.IDENTIFIER))for(i+=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)i+=".",this.advance(),i+=this.advance().value;else if(this.match(g.COMMA))i+=this.advance().value,this.skipNewlines();else break;this.match(g.OPERATOR,">")&&(i+=">",this.advance()),r=this.expect(g.IDENTIFIER).value}else r=this.expect(g.IDENTIFIER).value}else if(this.peek().type===g.IDENTIFIER)r=this.advance().value;else throw new Error(`Expected identifier after ${e} at ${this.peek().line}:${this.peek().column}`);this.functionNames.has(r)&&(r=r+"_var"),this.expect(g.OPERATOR,"="),this.skipNewlines(!0);const n=this.parseExpression(),a=new Z(r);i&&(a.varType=i);const s=[new Re(a,n,i)];for(;this.match(g.COMMA)&&this.peek(1).type===g.KEYWORD&&(this.peek(1).value==="var"||this.peek(1).value==="varip");){this.advance();const o=this.parseVarDeclaration();s.push(...o.declarations)}return new Me(s,e)}isTypedVarDeclaration(){let e=0;if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.DOT&&this.peek(e+1).type===g.IDENTIFIER;)e+=2;if(this.peek(e).type===g.LBRACKET&&this.peek(e+1).type===g.RBRACKET)return e+=2,this.peek(e).type!==g.IDENTIFIER?!1:(e++,this.peek(e).type===g.OPERATOR&&this.peek(e).value==="=");if(this.peek(e).type===g.OPERATOR&&this.peek(e).value==="<"){e++;let i=1;for(;i>0&&this.peek(e).type!==g.EOF;)this.peek(e).type===g.OPERATOR&&this.peek(e).value==="<"?i++:this.peek(e).type===g.OPERATOR&&this.peek(e).value===">"&&i--,e++;return this.peek(e).type!==g.IDENTIFIER?!1:(e++,this.peek(e).type===g.OPERATOR&&this.peek(e).value==="=")}if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.IDENTIFIER;)e++;return this.peek(e).type===g.OPERATOR&&this.peek(e).value==="="}parseTypedVarDeclaration(){let e=this.advance().value;for(;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)this.advance(),e+="."+this.advance().value;if(this.match(g.LBRACKET)&&this.peek(1).type===g.RBRACKET)this.advance(),this.advance(),e+="[]";else if(this.match(g.OPERATOR,"<")){for(this.advance(),e+="<";!this.match(g.OPERATOR,">");)if(this.match(g.IDENTIFIER))for(e+=this.advance().value;this.match(g.DOT)&&this.peek(1).type===g.IDENTIFIER;)e+=".",this.advance(),e+=this.advance().value;else if(this.match(g.COMMA))e+=this.advance().value,this.skipNewlines();else break;this.match(g.OPERATOR,">")&&(e+=">",this.advance())}else for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER;)e+=" "+this.advance().value;let i=this.expect(g.IDENTIFIER).value;this.functionNames.has(i)&&(i=i+"_var"),this.expect(g.OPERATOR,"="),this.skipNewlines(!0);const r=this.parseExpression(),n=new Z(i);return n.varType=e,new Me([new Re(n,r,e)],Ve.LET)}parseFunctionDeclaration(){let e=null;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&(e=this.advance().value);const i=this.expect(g.IDENTIFIER).value;this.functionNames.add(i),this.expect(g.LPAREN);const r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){let s=null;for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type!==g.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.OPERATOR&&this.peek(1).value==="<"){const c=this.parseTypeExpression();s=s?s+" "+c:c}if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.LBRACKET&&this.peek(2).type===g.RBRACKET){const c=this.parseTypeExpression();s=s?s+" "+c:c}const o=this.expect(g.IDENTIFIER).value,l=new Z(o);if(s&&(l.varType=s),this.match(g.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new nr(l,c))}else r.push(l);this.match(g.COMMA)&&this.advance()}this.expect(g.RPAREN),this.skipNewlines(),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new Z(i);return e&&(a.returnType=e),new Yi(a,r,n,e)}parseMethodDeclaration(){this.expect(g.KEYWORD,"method");let e=null;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type===g.LPAREN&&(e=this.advance().value);const i=this.expect(g.IDENTIFIER).value;this.expect(g.LPAREN);const r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){let s=null;for(;this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.IDENTIFIER&&this.peek(2).type!==g.LPAREN;)s&&(s+=" "),s=(s||"")+this.advance().value;if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.OPERATOR&&this.peek(1).value==="<"){const c=this.parseTypeExpression();s=s?s+" "+c:c}if(this.peek().type===g.IDENTIFIER&&this.peek(1).type===g.LBRACKET&&this.peek(2).type===g.RBRACKET){const c=this.parseTypeExpression();s=s?s+" "+c:c}const o=this.expect(g.IDENTIFIER).value,l=new Z(o);if(s&&(l.varType=s),this.match(g.OPERATOR,"=")){this.advance(),this.skipNewlines();const c=this.parseExpression();r.push(new nr(l,c))}else r.push(l);this.match(g.COMMA)&&this.advance()}this.expect(g.RPAREN),this.skipNewlines(),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=this.parseFunctionBody(),a=new Z(i);return e&&(a.returnType=e),a.isMethod=!0,new Yi(a,r,n,e)}parseFunctionBody(){const e=[];if(!this.match(g.INDENT)){const i=this.parseExpression();return new $e([new Qi(i)])}for(this.advance();!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const i=this.parseStatementOrSequence();Array.isArray(i)?e.push(...i):i&&e.push(i)}return this.match(g.DEDENT)&&this.advance(),e.length>0&&this._addImplicitReturn(e),new $e(e)}_addImplicitReturn(e){const i=e[e.length-1];i.type==="ExpressionStatement"?e[e.length-1]=new Qi(i.expression):i.type==="IfStatement"&&this._addImplicitReturnToIf(i)}_addImplicitReturnToIf(e){e.consequent&&e.consequent.type==="BlockStatement"&&e.consequent.body.length>0&&this._addImplicitReturn(e.consequent.body),e.alternate&&(e.alternate.type==="IfStatement"?this._addImplicitReturnToIf(e.alternate):e.alternate.type==="BlockStatement"&&e.alternate.body.length>0&&this._addImplicitReturn(e.alternate.body))}parseStatementOrSequence(){this.pos;const e=this.peek().line;if(this.match(g.KEYWORD,"if")){const r=this.parseIfStatement();return r&&(r._line=e),r}if(this.match(g.KEYWORD,"for"))return this.parseForStatement();if(this.match(g.KEYWORD,"while"))return this.parseWhileStatement();if(this.match(g.KEYWORD,"break")||this.match(g.KEYWORD,"continue")){const r=this.advance().value;return new pe(new Z(r))}if(this.match(g.KEYWORD,"var")||this.match(g.KEYWORD,"varip"))return this.parseVarDeclaration();if(this.isTupleDestructuring())return this.parseTupleDestructuring();if(this.peek().type===g.IDENTIFIER&&this.isTypedVarDeclaration()){const r=this.parseTypedVarDeclaration();if(this.match(g.COMMA)&&this.peek(1).type===g.IDENTIFIER){const n=[r];for(;this.match(g.COMMA);)if(this.advance(),this.skipNewlines(!0),this.peek().type===g.IDENTIFIER&&this.isTypedVarDeclaration())n.push(this.parseTypedVarDeclaration());else{const a=this.parseExpression();if(this.match(g.OPERATOR)){const s=this.peek().value;if(["=",":="].includes(s)){this.advance(),this.skipNewlines(!0);const o=this.parseExpression();s==="="&&a.type==="Identifier"?n.push(new Me([new Re(a,o)],Ve.LET)):n.push(new pe(new wt(s===":="?"=":s,a,o)))}}break}return n}return r}const i=[];for(;;){const r=this.parseExpression();if(this.match(g.OPERATOR)){const n=this.peek().value;if(["=",":=","+=","-=","*=","/=","%="].includes(n)){this.advance(),this.skipNewlines(!0);const a=this.parseExpression();if(n==="="&&r.type==="Identifier"?i.push(new Me([new Re(r,a)],Ve.LET)):i.push(new pe(new wt(n===":="?"=":n,r,a))),this.match(g.COMMA)){this.advance(),this.skipNewlines();continue}break}else{if(i.length>0)i.push(new pe(r));else return new pe(r);break}}else if(this.match(g.COMMA)){i.push(new pe(r)),this.advance(),this.skipNewlines();continue}else{if(i.length>0)i.push(new pe(r));else return new pe(r);break}}return i.length>1?i:i.length===1?i[0]:null}parseIfStatement(){this.expect(g.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();let r=null;return this.skipNewlines(),this.match(g.KEYWORD,"else")&&(this.advance(),this.skipNewlines(),this.match(g.KEYWORD,"if")?r=this.parseIfStatement():r=this.parseBlock()),new ma(e,i,r)}parseForStatement(){this.expect(g.KEYWORD,"for");let e=null,i=!1;if(this.match(g.LBRACKET)){this.advance();const r=[];for(;!this.match(g.RBRACKET);)this.skipNewlines(),r.push(new Z(this.expect(g.IDENTIFIER).value)),this.match(g.COMMA)&&this.advance();this.expect(g.RBRACKET),e=new rr(r),i=!0}else{const r=this.expect(g.IDENTIFIER).value;e=new Z(r)}if(this.match(g.KEYWORD,"in")){this.advance();const r=this.parseExpression();this.skipNewlines();const n=this.parseBlock(),a=new Me([new Re(e,r)],Ve.CONST),s=new Xi(a,null,null,n);return s.isForIn=!0,s}else{if(i)throw new Error(`Range-based for loops don't support destructuring at ${this.peek().line}:${this.peek().column}`);this.expect(g.OPERATOR,"=");const r=this.parseExpression();this.expect(g.KEYWORD,"to");const n=this.parseExpression();let a=null;this.match(g.KEYWORD,"by")&&(this.advance(),a=this.parseExpression()),this.skipNewlines();const s=this.parseBlock(),o=new Me([new Re(e,r)],Ve.LET),l=new Oe("<=",r,n),c=new We(l,new Oe("<=",e,n),new Oe(">=",e,n));let h;return a?h=new We(l,new wt("+=",e,a),new wt("-=",e,a)):h=new We(l,new Ji("++",e),new Ji("--",e)),new Xi(o,c,h,s)}}parseWhileStatement(){this.expect(g.KEYWORD,"while");const e=this.parseExpression();this.skipNewlines();const i=this.parseBlock();return new ga(e,i)}parseBlock(){if(!this.match(g.INDENT)){const r=this.parseStatement();return new $e(r?[r]:[])}const e=this.peek().indent;this.advance();const i=[];for(;!this.match(g.EOF);){if(this.skipNewlines(),this.match(g.DEDENT)){if(this.peek().indent<e)break;this.advance();continue}if(this.match(g.EOF))break;const r=this.parseStatement();r&&i.push(r)}return this.match(g.DEDENT)&&this.peek().indent<e&&this.advance(),new $e(i)}isTupleDestructuring(){if(!this.match(g.LBRACKET))return!1;let e=1;for(;;){for(;this.peek(e).type===g.NEWLINE;)e++;if(this.peek(e).type!==g.IDENTIFIER)return!1;for(e++;this.peek(e).type===g.NEWLINE;)e++;if(this.peek(e).type===g.RBRACKET){e++;break}else if(this.peek(e).type===g.COMMA){e++;continue}else return!1}for(;this.peek(e).type===g.NEWLINE;)e++;return this.peek(e).type===g.OPERATOR&&this.peek(e).value==="="}parseTupleDestructuring(){this.expect(g.LBRACKET);const e=[];for(;!this.match(g.RBRACKET);){this.skipNewlines();let r=this.expect(g.IDENTIFIER).value;this.functionNames.has(r)&&(r=r+"_var"),e.push(new Z(r)),this.match(g.COMMA)&&this.advance()}this.expect(g.RBRACKET),this.skipNewlines(),this.expect(g.OPERATOR,"="),this.skipNewlines(!0);const i=this.parseExpression();return new Me([new Re(new rr(e),i)],Ve.CONST)}parseExpression(){return this.parseTernary()}parseTernary(){let e=this.parseLogicalOr();if(this.matchEx(g.OPERATOR,"?",!0)){this.advance(),this.skipNewlines(!0);const i=this.parseExpression();this.matchEx(g.COLON,null,!0)?this.advance():this.expect(g.COLON),this.skipNewlines(!0);const r=this.parseExpression();return new We(e,i,r)}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.matchEx(g.KEYWORD,"or",!0)||this.peekOperatorEx(["||"]);){this.advance(),this.skipNewlines(!0);const i=this.parseLogicalAnd();e=new Oe("||",e,i)}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.matchEx(g.KEYWORD,"and",!0)||this.peekOperatorEx(["&&"]);){this.advance(),this.skipNewlines(!0);const i=this.parseEquality();e=new Oe("&&",e,i)}return e}parseEquality(){let e=this.parseComparison();for(;this.peekOperatorEx(["==","!="]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseComparison();e=new Oe(i,e,r)}return e}parseComparison(){let e=this.parseAdditive();for(;this.peekOperatorEx(["<",">","<=",">="]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseAdditive();e=new Oe(i,e,r)}return e}parseAdditive(){let e=this.parseMultiplicative();for(;this.peekOperatorEx(["+","-"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseMultiplicative();e=new Oe(i,e,r)}return e}parseMultiplicative(){let e=this.parseUnary();for(;this.peekOperatorEx(["*","/","%"]);){const i=this.advance().value;this.skipNewlines(!0);const r=this.parseUnary();e=new Oe(i,e,r)}return e}parseUnary(){if(this.match(g.OPERATOR)){const e=this.peek().value;if(["+","-","!"].includes(e))return this.advance(),this.skipNewlines(),new Zi(e,this.parseUnary())}return this.match(g.KEYWORD,"not")?(this.advance(),this.skipNewlines(),new Zi("!",this.parseUnary())):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(g.OPERATOR,"<")){const i=this.pos;this.advance();let r=1,n=!0,a="";const s=new Set(["float","int","string","bool","color","line","label","box","linefill","table"]);for(;r>0&&!this.match(g.EOF);)if(this.match(g.OPERATOR,"<"))r++,this.advance();else if(this.match(g.OPERATOR,">"))r--,this.advance();else if(this.match(g.IDENTIFIER)||this.match(g.COMMA)||this.match(g.DOT))r===1&&this.match(g.IDENTIFIER)&&a===""&&(a=this.peek().value),this.advance();else{n=!1,this.pos=i;break}if(n&&e.type==="MemberExpression"&&e.property.name==="new"&&(e.object.name==="array"||e.object.name==="matrix")&&s.has(a)&&(e.property=new Z("new_"+a)),n&&this.match(g.LPAREN)){e=this.parseCallExpression(e);continue}else{if(n)continue;break}}else if(this.match(g.LPAREN))e=this.parseCallExpression(e);else if(this.match(g.DOT)){this.advance(),this.skipNewlines();const i=this.peek();if(i.type!==g.IDENTIFIER&&i.type!==g.KEYWORD)throw new Error(`Expected property name but got ${i.type} at ${i.line}:${i.column}`);this.advance(),e=new er(e,new Z(i.value),!1)}else if(this.match(g.LBRACKET)){if(this.isTupleDestructuring())break;this.advance(),this.skipNewlines();const i=this.parseExpression();this.expect(g.RBRACKET),e=new er(e,i,!0)}else break;return e}parseCallExpression(e){this.expect(g.LPAREN);const i=[],r=[];for(;!this.match(g.RPAREN)&&(this.skipNewlines(),!this.match(g.RPAREN));){if((this.peek().type===g.IDENTIFIER||this.peek().type===g.KEYWORD)&&this.peek(1).type===g.OPERATOR&&this.peek(1).value==="="){const n=this.advance().value;this.advance(),this.skipNewlines();const a=this.parseExpression();r.push(new ir(new Z(n),a))}else i.push(this.parseExpression());this.match(g.COMMA)&&this.advance(),this.skipNewlines()}return this.expect(g.RPAREN),r.length>0&&i.push(new tr(r)),new ya(e,i)}parsePrimary(){const e=this.peek();if(this.match(g.NUMBER)){const i=this.advance();return new Xe(i.value)}if(this.match(g.STRING)){const i=this.advance();return new Xe(i.value)}if(this.match(g.BOOLEAN)){const i=this.advance();return new Xe(i.value)}if(this.match(g.IDENTIFIER)){let i=this.advance().value;return this.functionNames.has(i)&&this.peek().type!==g.LPAREN&&(i=i+"_var"),new Z(i)}if(this.match(g.LBRACKET))return this.parseArrayLiteral();if(this.match(g.LPAREN)){this.advance(),this.skipNewlines();const i=this.parseExpression();return this.skipNewlines(),this.expect(g.RPAREN),i}if(this.match(g.KEYWORD,"if"))return this.parseIfExpression();if(this.match(g.KEYWORD,"switch"))return this.parseSwitchExpression();if(this.match(g.KEYWORD,"for"))return this.parseForExpression();if(this.match(g.KEYWORD,"while"))return this.parseWhileExpression();throw new Error(`Unexpected token ${e.type} '${e.value}' at ${e.line}:${e.column}`)}parseArrayLiteral(){this.expect(g.LBRACKET);const e=[];for(;!this.match(g.RBRACKET)&&(this.skipNewlines(),!this.match(g.RBRACKET));)e.push(this.parseExpression()),this.match(g.COMMA)&&this.advance(),this.skipNewlines();return this.expect(g.RBRACKET),new xa(e)}parseIfExpression(){this.expect(g.KEYWORD,"if");const e=this.parseExpression();this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&i.push(s)}this.advance();let r=[];if(this.match(g.KEYWORD,"else"))if(this.advance(),this.skipNewlines(),this.match(g.KEYWORD,"if")){const s=this.parseIfExpression();if(this.needsIIFE(i,r)){const o=new We(e,new $e(i),s);return o.needsIIFE=!0,o.consequentStmts=i,o.alternateExpr=s,o}else return new We(e,this.getBlockValue(i),s)}else{for(this.expect(g.INDENT);!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&r.push(s)}this.advance()}if(this.needsIIFE(i,r)){const s=new We(e,new $e(i),new $e(r));return s.needsIIFE=!0,s.consequentStmts=i,s.alternateStmts=r,s}const n=this.getBlockValue(i),a=r.length>0?this.getBlockValue(r):new Xe(null);return new We(e,n,a)}needsIIFE(e,i){if(e.length>1||i.length>1)return!0;const r=n=>n.some(a=>a.type==="IfStatement"||a.type==="ForStatement"||a.type==="WhileStatement"||a.type==="BlockStatement");return r(e)||r(i)}parseSwitchExpression(){this.expect(g.KEYWORD,"switch");let e=null;!this.match(g.NEWLINE)&&!this.match(g.INDENT)&&(e=this.parseExpression()),this.skipNewlines(),this.expect(g.INDENT);const i=[];for(;!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){let r=null;this.match(g.OPERATOR,"=>")||(r=this.parseExpression()),this.expect(g.OPERATOR,"=>"),this.skipNewlines();const n=[];if(this.match(g.INDENT)){for(this.advance();!this.match(g.DEDENT)&&!this.match(g.EOF)&&(this.skipNewlines(),!this.match(g.DEDENT));){const s=this.parseStatement();s&&n.push(s)}this.advance()}else n.push(new pe(this.parseExpression()));const a=this.getBlockValue(n);i.push(new ba(r,a,n)),this.skipNewlines()}return this.advance(),new _a(e,i)}parseForExpression(){const e=this.parseForStatement();return e.isExpression=!0,e}parseWhileExpression(){const e=this.parseWhileStatement();return e.isExpression=!0,e}getBlockValue(e){if(e.length===0)return new Xe(null);const i=e[e.length-1];return i.type==="ExpressionStatement"?i.expression:i.type==="VariableDeclaration"&&i.declarations.length>0?i.declarations[0].id:new Xe(null)}}const va=new Set(Ai);class Sa{indent;indentStr;output;sourceCode;sourceLines;lastCommentedLine;includeSourceComments;paramRenameCounter;functionParams;constructor(e={}){this.indent=0,this.indentStr=e.indentStr||" ",this.output=[],this.sourceCode=e.sourceCode||null,this.sourceLines=this.sourceCode?this.sourceCode.split(`
|
|
40
40
|
`):[],this.lastCommentedLine=-1,this.includeSourceComments=e.includeSourceComments||!1,this.paramRenameCounter=0,this.functionParams=new Map}generate(e){if(this.output=[],this.indent=0,this.lastCommentedLine=-1,this.functionParams=new Map,e.type==="Program")this.preProcessAST(e),this.generateProgram(e);else throw new Error(`Expected Program node, got ${e.type}`);return this.output.join("")}preProcessAST(e){this.collectFunctionParams(e)}collectFunctionParams(e){if(!(!e||typeof e!="object")){if(e.type==="FunctionDeclaration"&&e.id?.name){const i=[];for(const r of e.params)r.type==="Identifier"?i.push(r.name):r.type==="AssignmentPattern"&&r.left?.name&&i.push(r.left.name);this.functionParams.set(e.id.name,i)}if(Array.isArray(e.body))for(const i of e.body)this.collectFunctionParams(i);else e.body&&typeof e.body=="object"&&this.collectFunctionParams(e.body)}}writeSourceComment(e,i=null){if(!this.sourceLines.length)return;const r=i||e,n=[];for(let a=e-1;a<r&&a<this.sourceLines.length;a++)if(a>this.lastCommentedLine){const s=this.sourceLines[a].trim();s&&!s.startsWith("//@")&&!s.startsWith("//")&&n.push(this.sourceLines[a])}if(n.length>0){for(const a of n)this.write(this.indentStr.repeat(this.indent)),this.write("/// "),this.write(a.trimEnd()),this.write(`
|
|
41
41
|
`);this.lastCommentedLine=Math.max(this.lastCommentedLine,r-1)}}write(e){this.output.push(e)}writeLine(e=""){e?this.output.push(this.indentStr.repeat(this.indent)+e+`
|
|
42
42
|
`):this.output.push(`
|
|
43
43
|
`)}increaseIndent(){this.indent++}decreaseIndent(){this.indent--}generateProgram(e){for(let i=0;i<e.body.length;i++)if(this.generateStatement(e.body[i]),i<e.body.length-1){const r=e.body[i],n=e.body[i+1];(r.type==="FunctionDeclaration"||r.type==="TypeDefinition")&&(n.type==="FunctionDeclaration"||n.type==="TypeDefinition")&&this.writeLine()}}generateStatement(e){switch(this.includeSourceComments&&e._line&&this.sourceLines.length>0&&this.writeSourceComment(e._line),e.type){case"FunctionDeclaration":return this.generateFunctionDeclaration(e);case"VariableDeclaration":return this.generateVariableDeclaration(e);case"ExpressionStatement":return this.generateExpressionStatement(e);case"IfStatement":return this.generateIfStatement(e);case"ForStatement":return this.generateForStatement(e);case"WhileStatement":return this.generateWhileStatement(e);case"ReturnStatement":return this.generateReturnStatement(e);case"BlockStatement":return this.generateBlockStatement(e);case"TypeDefinition":return this.generateTypeDefinition(e);default:throw new Error(`Unknown statement type: ${e.type}`)}}generateTypeDefinition(e){if(this.write(this.indentStr.repeat(this.indent)),this.write(`const ${e.name} = Type({`),e.fields.length>0){this.write(" ");for(let i=0;i<e.fields.length;i++){const r=e.fields[i];r.defaultValue?(this.write(`${r.name}: ['${r.type}', `),this.generateExpression(r.defaultValue),this.write("]")):this.write(`${r.name}: '${r.type}'`),i<e.fields.length-1&&this.write(", ")}this.write(" ")}this.write(`});
|
|
44
|
-
`)}renameIdentifiersInAST(e,i){if(!(!e||typeof e!="object")){if(e.type==="Identifier"&&i.has(e.name)){e.name=i.get(e.name);return}if(e.type!=="FunctionDeclaration")for(const r of Object.keys(e)){if(r==="type")continue;const n=e[r];if(Array.isArray(n))for(const a of n)a&&typeof a=="object"&&this.renameIdentifiersInAST(a,i);else n&&typeof n=="object"&&n.type&&this.renameIdentifiersInAST(n,i)}}}generateFunctionDeclaration(e){this.write(this.indentStr.repeat(this.indent));const i=e.id.isMethod,r=new Map;for(const s of e.params){const o=s.type==="AssignmentPattern"?s.left.name:s.name;if(o&&
|
|
44
|
+
`)}renameIdentifiersInAST(e,i){if(!(!e||typeof e!="object")){if(e.type==="Identifier"&&i.has(e.name)){e.name=i.get(e.name);return}if(e.type!=="FunctionDeclaration")for(const r of Object.keys(e)){if(r==="type")continue;const n=e[r];if(Array.isArray(n))for(const a of n)a&&typeof a=="object"&&this.renameIdentifiersInAST(a,i);else n&&typeof n=="object"&&n.type&&this.renameIdentifiersInAST(n,i)}}}generateFunctionDeclaration(e){this.write(this.indentStr.repeat(this.indent));const i=e.id.isMethod,r=new Map;for(const s of e.params){const o=s.type==="AssignmentPattern"?s.left.name:s.name;if(o&&va.has(o)){const l=`${o}_$${this.paramRenameCounter++}`;r.set(o,l)}}if(r.size>0){for(const s of e.params)s.type==="AssignmentPattern"?(r.has(s.left.name)&&(s.left.name=r.get(s.left.name)),this.renameIdentifiersInAST(s.right,r)):s.type==="Identifier"&&r.has(s.name)&&(s.name=r.get(s.name));this.renameIdentifiersInAST(e.body,r)}this.write("function "),this.write(e.id.name),this.write("(");const n=e.params,a=i&&n.length>0&&n[0].type==="Identifier"&&n[0].name==="this"?1:0;for(let s=a;s<n.length;s++){const o=n[s];if(o.type==="Identifier")this.write(o.name);else if(o.type==="AssignmentPattern"){const l=o.left.name==="this"&&i?"self":o.left.name;this.write(l),this.write(" = "),this.generateExpression(o.right)}s<n.length-1&&this.write(", ")}this.write(") "),this.generateBlockStatement(e.body,!1),this.write(`
|
|
45
45
|
`),i&&(this.write(this.indentStr.repeat(this.indent)),this.write(`${e.id.name}.__pineMethod__ = true;
|
|
46
46
|
`))}generateVariableDeclaration(e){const i=e.kind==="var"||e.kind==="varip"?"var":"let";for(let r=0;r<e.declarations.length;r++){const n=e.declarations[r];if(n.init&&n.init.type==="ConditionalExpression"&&n.init.needsIIFE){const a=n.id.type==="Identifier"?n.id.name:null;if(a){this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),this.write(a),this.write(`;
|
|
47
47
|
`),this.generateIfStatementWithAssignment(n.init,a);continue}}if(this.write(this.indentStr.repeat(this.indent)),this.write(i),this.write(" "),n.id.type==="Identifier")this.write(n.id.name);else if(n.id.type==="ArrayPattern"){this.write("[");for(let a=0;a<n.id.elements.length;a++)this.write(n.id.elements[a].name),a<n.id.elements.length-1&&this.write(", ");this.write("]")}n.init&&(this.write(" = "),this.generateExpression(n.init)),this.write(`;
|
|
@@ -132,8 +132,8 @@ ${t}
|
|
|
132
132
|
`)}}generateLoopAsExpression(e,i){this.write(`(() => {
|
|
133
133
|
`),this.indent++,this.write(this.indentStr.repeat(this.indent)),this.write(`let __result;
|
|
134
134
|
`);const r=e.body;if(r&&r.body&&r.body.length>0){const n=r.body.length-1,a=r.body[n];a.type==="ExpressionStatement"&&(r.body[n]={type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"Identifier",name:"__result"},right:a.expression},_line:a._line})}i==="for"?this.generateForStatement(e):this.generateWhileStatement(e),this.write(this.indentStr.repeat(this.indent)),this.write(`return __result;
|
|
135
|
-
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateSequenceExpression(e){this.write("(");for(let i=0;i<e.expressions.length;i++)this.generateExpression(e.expressions[i]),i<e.expressions.length-1&&this.write(", ");this.write(")")}getPrecedence(e){switch(e.type){case"Literal":case"Identifier":case"ArrayExpression":case"ObjectExpression":return 20;case"CallExpression":case"MemberExpression":return 19;case"UnaryExpression":case"UpdateExpression":return 15;case"BinaryExpression":case"LogicalExpression":switch(e.operator){case"*":case"/":case"%":return 13;case"+":case"-":return 12;case"<":case"<=":case">":case">=":return 10;case"==":case"!=":return 9;case"and":case"&&":return 5;case"or":case"||":return 4;default:return 0}case"ConditionalExpression":return 3;case"AssignmentExpression":case"AssignmentPattern":return 2;case"SequenceExpression":return 1;default:return 0}}}function
|
|
136
|
-
`):[],a=
|
|
137
|
-
; return _r;`)(this)}function sa(t){return e=>new R(e.array.map(i=>Math.abs(i)),e.type,t)}function aa(t){return e=>{let i=0,r=0;for(const n of e.array){const a=Number(n);isNaN(a)||(r++,i+=(a-i)/r)}return r===0?NaN:t.precision(i)}}function oa(t){return(e,i)=>{const r=e.array;let n=0,a=r.length-1;for(;n<=a;){const s=Math.floor((n+a)/2),o=r[s];if(o===i)return s;o<i?n=s+1:a=s-1}return-1}}function la(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<i?n=s+1:a=s}return n<r.length&&r[n]===i?n:n-1}}function ca(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<=i?n=s+1:a=s}return n>0&&r[n-1]===i?n-1:n}}function ha(t){return e=>{e.array.length=0}}function ua(t){return(e,i)=>(e.array.push(...i.array),e)}function pa(t){return e=>new R([...e.array],e.type,t)}function fa(t){return(e,i,r=!0)=>{const n=e.array,a=i.array;if(n.length!==a.length)return NaN;let s=0,o=0,l=0;const c=[];for(let m=0;m<n.length;m++){const y=Number(n[m]),_=Number(a[m]);!isNaN(y)&&y!==null&&y!==void 0&&!isNaN(_)&&_!==null&&_!==void 0&&(s+=y,o+=_,l++,c.push(m))}if(l===0)return NaN;const h=s/l,p=o/l;let u=0;for(const m of c){const y=Number(n[m]),_=Number(a[m]);u+=(y-h)*(_-p)}const f=r?l:l-1;return f<=0?NaN:t.precision(u/f)}}function da(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function ma(t){return t.every(e=>typeof e=="number")?t.every(e=>(e|0)===e)?A.int:A.float:t.every(e=>typeof e=="string")?A.string:t.every(e=>typeof e=="boolean")?A.bool:A.any}function Ne(t){return typeof t=="number"?(t|0)===t?A.int:A.float:typeof t=="string"?A.string:typeof t=="boolean"?A.bool:A.any}function St(t,e){if(typeof t=="number"&&isNaN(t)||e===A.any)return!0;switch(e){case A.int:return typeof t=="number"&&((t|0)===t||isNaN(t));case A.float:return typeof t=="number";case A.string:return typeof t=="string";case A.bool:return typeof t=="boolean";case A.box:case A.label:case A.line:case A.linefill:case A.table:case A.color:return t===null||typeof t=="object"||typeof t=="string"}return!1}function xa(t){return(e,i,r=0,n)=>{const a=e.array.length,s=n!==void 0?Math.min(n,a):a;for(let o=r;o<s;o++){if(!St(i,e.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array[o]=typeof i=="number"?t.precision(i):i}}}function ga(t){return e=>e.array.length>0?e.array[0]:t.NA}function ya(t){return(e,i)=>i<0||i>=e.array.length?NaN:e.array[i]}function _a(t){return(e,i)=>e.array.includes(i)}function ba(t){return(e,i)=>typeof i=="number"&&i!==i?e.array.findIndex(r=>typeof r=="number"&&r!==r):e.array.indexOf(i)}function va(t){return(e,i,r)=>{if(!St(r,e.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);e.array.splice(i,0,r)}}function wa(t){return(e,i=",")=>e.array.join(i)}function Ea(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function Sa(t){return(e,i)=>e.array.lastIndexOf(i)}function Na(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let a=1;a<r.length;a++)r[a]>n&&(n=r[a]);return n??t.NA}return[...r].sort((n,a)=>a-n)[i]??t.NA}}function Ca(t){return e=>{const i=e.array;if(i.length===0)return NaN;const r=new Array(i.length);for(let a=0;a<i.length;a++)r[a]=i[a];r.sort((a,s)=>a-s);const n=Math.floor(r.length/2);return r.length%2!==0?r[n]:(r[n-1]+r[n])/2}}function Ia(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let a=1;a<r.length;a++)r[a]<n&&(n=r[a]);return n??t.NA}return[...r].sort((n,a)=>n-a)[i]??t.NA}}function ka(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const a of e.array){const s=(i.get(a)||0)+1;i.set(a,s),s>r&&(r=s)}const n=[];for(const[a,s]of i)s===r&&n.push(a);return n.sort((a,s)=>typeof a=="number"&&typeof s=="number"?a-s:typeof a=="string"&&typeof s=="string"?a<s?-1:a>s?1:0:0),n[0]}}function Aa(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const a=new Array(n);for(let c=0;c<n;c++){const h=Number(r[c]);if(isNaN(h)||h===null||h===void 0)return NaN;a[c]=h}a.sort((c,h)=>c-h),i<0&&(i=0),i>100&&(i=100);const s=i/100*n-.5;if(s<=0)return t.precision(a[0]);if(s>=n-1)return t.precision(a[n-1]);const o=Math.floor(s),l=s-o;return t.precision(a[o]*(1-l)+a[o+1]*l)}}function Ta(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const a=new Array;for(let o=0;o<n;o++){const l=Number(r[o]);!isNaN(l)&&l!==null&&l!==void 0&&a.push(l)}if(a.length===0)return NaN;a.sort((o,l)=>o-l),i<0&&(i=0),i>100&&(i=100);const s=Math.ceil(i/100*n);return s<=0?a[0]:s>a.length?NaN:a[s-1]}}function Pa(t){return(e,i)=>{if(e.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=e.array.length)return NaN;const n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let a=0;for(const o of e.array){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&l<n&&a++}const s=e.array.length-1;return s<=0?NaN:a/s*100}}function Da(t){return e=>e.array.pop()}function Ra(t){return(e,i)=>{if(!St(i,e.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.push(typeof i=="number"?t.precision(i):i)}}function Ma(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function Oa(t){return(e,i)=>i>=0&&i<e.array.length?e.array.splice(i,1)[0]:t.NA}function Va(t){return e=>{e.array.reverse()}}function La(t){return(e,i,r)=>{if(!St(r,e.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);e.array[i]=typeof r=="number"?t.precision(r):r}}function ja(t){return e=>e.array.shift()}function Ba(t){return e=>e.array.length}function Fa(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new R(e.array.slice(i,n),e.type,t)}}function Wa(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var lt=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(lt||{}),Zr=(t=>(t.AED="AED",t.ARS="ARS",t.AUD="AUD",t.BDT="BDT",t.BHD="BHD",t.BRL="BRL",t.BTC="BTC",t.CAD="CAD",t.CHF="CHF",t.CLP="CLP",t.CNY="CNY",t.COP="COP",t.CZK="CZK",t.DKK="DKK",t.EGP="EGP",t.ETH="ETH",t.EUR="EUR",t.GBP="GBP",t.HKD="HKD",t.HUF="HUF",t.IDR="IDR",t.ILS="ILS",t.INR="INR",t.ISK="ISK",t.JPY="JPY",t.KES="KES",t.KRW="KRW",t.KWD="KWD",t.LKR="LKR",t.MAD="MAD",t.MXN="MXN",t.MYR="MYR",t.NGN="NGN",t.NOK="NOK",t.NONE="NONE",t.NZD="NZD",t.PEN="PEN",t.PHP="PHP",t.PKR="PKR",t.PLN="PLN",t.QAR="QAR",t.RON="RON",t.RSD="RSD",t.RUB="RUB",t.SAR="SAR",t.SEK="SEK",t.SGD="SGD",t.THB="THB",t.TND="TND",t.TRY="TRY",t.TWD="TWD",t.USD="USD",t.USDT="USDT",t.VES="VES",t.VND="VND",t.ZAR="ZAR",t))(Zr||{}),Jr=(t=>(t[t.sunday=1]="sunday",t[t.monday=2]="monday",t[t.tuesday=3]="tuesday",t[t.wednesday=4]="wednesday",t[t.thursday=5]="thursday",t[t.friday=6]="friday",t[t.saturday=7]="saturday",t))(Jr||{}),en=(t=>(t.all="all",t.data_window="data_window",t.none="none",t.pane="pane",t.price_scale="price_scale",t.status_line="status_line",t))(en||{}),tn=(t=>(t.flag="shape_flag",t.arrowdown="shape_arrow_down",t.arrowup="shape_arrow_up",t.circle="shape_circle",t.cross="shape_cross",t.diamond="shape_diamond",t.labeldown="shape_label_down",t.labelup="shape_label_up",t.square="shape_square",t.triangledown="shape_triangle_down",t.triangleup="shape_triangle_up",t.xcross="shape_xcross",t))(tn||{}),rn=(t=>(t.abovebar="AboveBar",t.belowbar="BelowBar",t.absolute="Absolute",t.bottom="Bottom",t.top="Top",t))(rn||{}),nn=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(nn||{}),sn=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(sn||{}),$a=(t=>(t.linestyle_dashed="linestyle_dashed",t.linestyle_dotted="linestyle_dotted",t.linestyle_solid="linestyle_solid",t.style_area="style_area",t.style_areabr="style_areabr",t.style_circles="style_circles",t.style_columns="style_columns",t.style_cross="style_cross",t.style_histogram="style_histogram",t.style_line="style_line",t.style_linebr="style_linebr",t.style_stepline="style_stepline",t.style_stepline_diamond="style_stepline_diamond",t.style_steplinebr="style_steplinebr",t))($a||{}),an=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(an||{}),on=(t=>(t.bar_index="bi",t.bar_time="bt",t))(on||{}),ln=(t=>(t.price="pr",t.abovebar="ab",t.belowbar="bl",t))(ln||{}),cn=(t=>(t.left="l",t.right="r",t.both="b",t.none="n",t))(cn||{}),hn=(t=>(t.align_bottom="bottom",t.align_top="top",t.align_left="left",t.align_center="center",t.align_right="right",t.wrap_auto="auto",t.wrap_none="none",t.format_bold="bold",t.format_italic="italic",t.format_none="none",t))(hn||{}),un=(t=>(t.family_default="default",t.family_monospace="monospace",t))(un||{}),pn=(t=>(t.none="none",t.splits="splits",t.dividends="dividends",t))(pn||{}),fn=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(fn||{}),dn=(t=>(t.actual="earnings_actual",t.estimate="earnings_estimate",t.standardized="earnings_standardized",t.future_eps="earnings_future_eps",t.future_period_end_time="earnings_future_period_end_time",t.future_revenue="earnings_future_revenue",t.future_time="earnings_future_time",t))(dn||{}),mn=(t=>(t.gross="dividends_gross",t.net="dividends_net",t.future_amount="dividends_future_amount",t.future_ex_date="dividends_future_ex_date",t.future_pay_date="dividends_future_pay_date",t))(mn||{}),xn=(t=>(t.denominator="splits_denominator",t.numerator="splits_numerator",t))(xn||{}),gn=(t=>(t.top_left="top_left",t.top_center="top_center",t.top_right="top_right",t.middle_left="middle_left",t.middle_center="middle_center",t.middle_right="middle_right",t.bottom_left="bottom_left",t.bottom_center="bottom_center",t.bottom_right="bottom_right",t))(gn||{}),yn=(t=>(t.left="left",t.none="none",t.right="right",t))(yn||{}),_n=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(_n||{});const Ua={order:lt,currency:Zr,dayofweek:Jr,display:en,shape:tn,location:rn,size:nn,format:sn,barmerge:an,xloc:on,yloc:ln,extend:cn,text:hn,font:un,adjustment:pn,backadjustment:fn,earnings:dn,dividends:mn,splits:xn,position:gn,scale:yn,settlement_as_close:_n};function qa(t){return(e,i=lt.ascending)=>{e.array.sort((r,n)=>{let a=isNaN(r)?1/0:r,s=isNaN(n)?1/0:n;return i===lt.ascending?a-s:s-a})}}function za(t){return(e,i=lt.ascending)=>{const r=e.array.map((n,a)=>a);return r.sort((n,a)=>{const s=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[a])?1/0:e.array[a];return i===lt.ascending?s-o:o-s}),new R(r,A.int,t)}}function Ka(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new R(e.array.map(()=>NaN),A.int,t):r===0?new R(e.array.map(()=>1),A.int,t):new R(e.array.map(n=>(n-i)/r),A.int,t)}}function Ha(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let a=0,s=0,o=0;for(let h=0;h<n;h++){const p=Number(r[h]);!isNaN(p)&&p!==null&&p!==void 0&&(a+=p,s+=p*p,o++)}if(o===0)return NaN;const l=a/o;let c=s/o-l*l;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function Ga(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function Ya(t){return(e,i)=>{if(!St(i,e.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.unshift(typeof i=="number"?t.precision(i):i)}}function Qa(t){return(e,i=!0)=>{let r=0,n=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,n++)}if(n===0)return NaN;const a=r/n;let s=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(s+=(c-a)*(c-a))}const o=i?n:n-1;return o<=0?NaN:t.precision(s/o)}}var A=(t=>(t.any="",t.box="box",t.bool="bool",t.color="color",t.float="float",t.int="int",t.label="label",t.line="line",t.linefill="linefill",t.string="string",t.table="table",t))(A||{});class R{constructor(e,i,r){this.array=e,this.type=i,this.context=r,this._abs=sa(this.context),this._avg=aa(this.context),this._binary_search=oa(this.context),this._binary_search_leftmost=la(this.context),this._binary_search_rightmost=ca(this.context),this._clear=ha(this.context),this._concat=ua(this.context),this._copy=pa(this.context),this._covariance=fa(this.context),this._every=da(this.context),this._fill=xa(this.context),this._first=ga(this.context),this._get=ya(this.context),this._includes=_a(this.context),this._indexof=ba(this.context),this._insert=va(this.context),this._join=wa(this.context),this._last=Ea(this.context),this._lastindexof=Sa(this.context),this._max=Na(this.context),this._median=Ca(this.context),this._min=Ia(this.context),this._mode=ka(this.context),this._percentile_linear_interpolation=Aa(this.context),this._percentile_nearest_rank=Ta(this.context),this._percentrank=Pa(this.context),this._pop=Da(this.context),this._push=Ra(this.context),this._range=Ma(this.context),this._remove=Oa(this.context),this._reverse=Va(this.context),this._set=La(this.context),this._shift=ja(this.context),this._size=Ba(this.context),this._slice=Fa(this.context),this._some=Wa(this.context),this._sort=qa(this.context),this._sort_indices=za(this.context),this._standardize=Ka(this.context),this._stdev=Ha(this.context),this._sum=Ga(this.context),this._unshift=Ya(this.context),this._variance=Qa(this.context)}_abs;_avg;_binary_search;_binary_search_leftmost;_binary_search_rightmost;_clear;_concat;_copy;_covariance;_every;_fill;_first;_get;_includes;_indexof;_insert;_join;_last;_lastindexof;_max;_median;_min;_mode;_percentile_linear_interpolation;_percentile_nearest_rank;_percentrank;_pop;_push;_range;_remove;_reverse;_set;_shift;_size;_slice;_some;_sort;_sort_indices;_standardize;_stdev;_sum;_unshift;_variance;toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}[Symbol.iterator](){return this.array[Symbol.iterator]()}abs(...e){return this._abs(this,...e)}avg(...e){return this._avg(this,...e)}binary_search(...e){return this._binary_search(this,...e)}binary_search_leftmost(...e){return this._binary_search_leftmost(this,...e)}binary_search_rightmost(...e){return this._binary_search_rightmost(this,...e)}clear(...e){return this._clear(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}covariance(...e){return this._covariance(this,...e)}every(...e){return this._every(this,...e)}fill(...e){return this._fill(this,...e)}first(...e){return this._first(this,...e)}get(...e){return this._get(this,...e)}includes(...e){return this._includes(this,...e)}indexof(...e){return this._indexof(this,...e)}insert(...e){return this._insert(this,...e)}join(...e){return this._join(this,...e)}last(...e){return this._last(this,...e)}lastindexof(...e){return this._lastindexof(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}percentile_linear_interpolation(...e){return this._percentile_linear_interpolation(this,...e)}percentile_nearest_rank(...e){return this._percentile_nearest_rank(this,...e)}percentrank(...e){return this._percentrank(this,...e)}pop(...e){return this._pop(this,...e)}push(...e){return this._push(this,...e)}range(...e){return this._range(this,...e)}remove(...e){return this._remove(this,...e)}reverse(...e){return this._reverse(this,...e)}set(...e){return this._set(this,...e)}shift(...e){return this._shift(this,...e)}size(...e){return this._size(this,...e)}slice(...e){return this._slice(this,...e)}some(...e){return this._some(this,...e)}sort(...e){return this._sort(this,...e)}sort_indices(...e){return this._sort_indices(this,...e)}standardize(...e){return this._standardize(this,...e)}stdev(...e){return this._stdev(this,...e)}sum(...e){return this._sum(this,...e)}unshift(...e){return this._unshift(this,...e)}variance(...e){return this._variance(this,...e)}}function Xa(t){return(...e)=>new R([...e],ma(e),t)}function Za(t){return(e,i)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;if(i===void 0){const n=r?Array(r).fill(0):[];return new R(n,A.any,t)}return new R(Array(r).fill(t.precision(i||0)),Ne(i||0),t)}}function Ja(t){return(e=0,i=!1)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.bool,t)}}function eo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.box,t)}}function to(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.color,t)}}function io(t){return(e=0,i=NaN)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(t.precision(i)),A.float,t)}}function ro(t){return(e=0,i=0)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(t.precision(i)),A.int,t)}}function no(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.label,t)}}function so(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.line,t)}}function ao(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.linefill,t)}}function oo(t){return(e=0,i="")=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.string,t)}}function lo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),A.table,t)}}class g{constructor(e,i=0){this.data=e,this.offset=i}get(e){const i=this.data.length-1-(this.offset+e);return i<0||i>=this.data.length?NaN:this.data[i]}set(e,i){const r=this.data.length-1-(this.offset+e);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(e){return e instanceof g?e:Array.isArray(e)?new g(e):new g([e])}}function co(t){return(e,i=0)=>g.from(e).get(i)}class ho{constructor(e){this.context=e,this.abs=(i,...r)=>i.abs(...r),this.avg=(i,...r)=>i.avg(...r),this.binary_search=(i,...r)=>i.binary_search(...r),this.binary_search_leftmost=(i,...r)=>i.binary_search_leftmost(...r),this.binary_search_rightmost=(i,...r)=>i.binary_search_rightmost(...r),this.clear=(i,...r)=>i.clear(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.covariance=(i,...r)=>i.covariance(...r),this.every=(i,...r)=>i.every(...r),this.fill=(i,...r)=>i.fill(...r),this.first=(i,...r)=>i.first(...r),this.from=Xa(e),this.get=(i,...r)=>i.get(...r),this.includes=(i,...r)=>i.includes(...r),this.indexof=(i,...r)=>i.indexof(...r),this.insert=(i,...r)=>i.insert(...r),this.join=(i,...r)=>i.join(...r),this.last=(i,...r)=>i.last(...r),this.lastindexof=(i,...r)=>i.lastindexof(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.new=Za(e),this.new_bool=Ja(e),this.new_box=eo(e),this.new_color=to(e),this.new_float=io(e),this.new_int=ro(e),this.new_label=no(e),this.new_line=so(e),this.new_linefill=ao(e),this.new_string=oo(e),this.new_table=lo(e),this.param=co(),this.percentile_linear_interpolation=(i,...r)=>i.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(i,...r)=>i.percentile_nearest_rank(...r),this.percentrank=(i,...r)=>i.percentrank(...r),this.pop=(i,...r)=>i.pop(...r),this.push=(i,...r)=>i.push(...r),this.range=(i,...r)=>i.range(...r),this.remove=(i,...r)=>i.remove(...r),this.reverse=(i,...r)=>i.reverse(...r),this.set=(i,...r)=>i.set(...r),this.shift=(i,...r)=>i.shift(...r),this.size=(i,...r)=>i.size(...r),this.slice=(i,...r)=>i.slice(...r),this.some=(i,...r)=>i.some(...r),this.sort=(i,...r)=>i.sort(...r),this.sort_indices=(i,...r)=>i.sort_indices(...r),this.standardize=(i,...r)=>i.standardize(...r),this.stdev=(i,...r)=>i.stdev(...r),this.sum=(i,...r)=>i.sum(...r),this.unshift=(i,...r)=>i.unshift(...r),this.variance=(i,...r)=>i.variance(...r)}}function uo(t){return e=>{e.map.clear()}}function po(t){return(e,i)=>e.map.has(i)}function fo(t){return e=>{const i=new bn(t);return i.map=new Map(e.map),i}}function mo(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function xo(t){return e=>{const i=Array.from(e.map.keys()),r=Ne(i[0]);return new R(i,r,t)}}function go(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function yo(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function _o(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function bo(t){return e=>e.map.size}function vo(t){return e=>{const i=Array.from(e.map.values()),r=Ne(i[0]);return new R(i,r,t)}}class bn{constructor(e){this.context=e,this.map=new Map,this._clear=uo(this.context),this._contains=po(this.context),this._copy=fo(this.context),this._get=mo(this.context),this._keys=xo(this.context),this._put=go(this.context),this._put_all=yo(this.context),this._remove=_o(this.context),this._size=bo(this.context),this._values=vo(this.context)}map;_clear;_contains;_copy;_get;_keys;_put;_put_all;_remove;_size;_values;toString(){return`PineMapObject(${this.map.size})`}clear(...e){return this._clear(this,...e)}contains(...e){return this._contains(this,...e)}copy(...e){return this._copy(this,...e)}get(...e){return this._get(this,...e)}keys(...e){return this._keys(this,...e)}put(...e){return this._put(this,...e)}put_all(...e){return this._put_all(this,...e)}remove(...e){return this._remove(this,...e)}size(...e){return this._size(this,...e)}values(...e){return this._values(this,...e)}}function wo(t){return()=>new bn(t)}function Eo(t){return(e,i=0)=>g.from(e).get(i)}class So{constructor(e){this.context=e,this.clear=(i,...r)=>i.clear(...r),this.contains=(i,...r)=>i.contains(...r),this.copy=(i,...r)=>i.copy(...r),this.get=(i,...r)=>i.get(...r),this.keys=(i,...r)=>i.keys(...r),this.new=wo(e),this.param=Eo(),this.put=(i,...r)=>i.put(...r),this.put_all=(i,...r)=>i.put_all(...r),this.remove=(i,...r)=>i.remove(...r),this.size=(i,...r)=>i.size(...r),this.values=(i,...r)=>i.values(...r)}}function No(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r&&(r instanceof R?a=r.array:Array.isArray(r)?a=r:a=[r]),n===0){for(let l=0;l<a.length;l++){let c=a[l];c instanceof g&&(c=c.get(0)),e.matrix.push([c])}return}const s=e.matrix[0].length,o=i!==void 0?i:s;for(let l=0;l<n;l++){let c=l<a.length?a[l]:NaN;c instanceof g&&(c=c.get(0)),e.matrix[l].splice(o,0,c)}}}function Co(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r)if(r instanceof R)a=r.array;else if(Array.isArray(r))a=r;else if(r instanceof g){const c=r.get(0);Array.isArray(c)?a=c:a=[c]}else a=[r];const s=n>0?e.matrix[0].length:a.length,o=i!==void 0?i:n,l=[];for(let c=0;c<s;c++)if(c<a.length){let h=a[c];h instanceof g&&(h=h.get(0)),l.push(h)}else l.push(NaN);e.matrix.splice(o,0,l)}}function Io(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;if(r===0)return NaN;let n=0,a=0;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(n+=l,a++)}return a===0?NaN:n/a}}function ko(t){return(e,i)=>{const r=e.matrix.length,n=[];for(let s=0;s<r;s++)n.push(e.matrix[s][i]);const a=Ne(n[0]);return new R(n,a,t)}}function Ao(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function To(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const a=e.matrix[0].length,s=n>0?i.matrix[0].length:0;if(a!==s&&n>0){console.error(`matrix.concat: Column count mismatch ${a} vs ${s}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function Po(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new B(i,r,NaN,t);return n.matrix=e.matrix.map(a=>[...a]),n}}function Do(t){const e=t.length;if(e===0)return 0;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];const i=t.map(n=>[...n]);let r=1;for(let n=0;n<e;n++){let a=n;for(;a<e&&i[a][n]===0;)a++;if(a===e)return 0;a!==n&&([i[n],i[a]]=[i[a],i[n]],r*=-1),r*=i[n][n];for(let s=n+1;s<e;s++){const o=i[s][n]/i[n][n];for(let l=n;l<e;l++)i[s][l]-=o*i[n][l]}}return r}function Ro(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:Do(e.matrix)}}function Mo(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new B(0,0,NaN,t);const n=e.matrix[0].length,a=new B(r,n,NaN,t);if(i instanceof B)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l-c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]-s}return a}}function Oo(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],a=t[1][1],s=i+a,o=i*a-r*n,l=s*s-4*o;if(l<0)return[NaN,NaN];const c=(s+Math.sqrt(l))/2,h=(s-Math.sqrt(l))/2;return[c,h]}function Vo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const s=Ne(e.matrix[0][0]);return new R([],s,t)}const n=Oo(e.matrix),a=Ne(n[0]);return new R(n,a,t)}}function Lo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new B(0,0,NaN,t);const n=new B(i,r,0,t);for(let a=0;a<i;a++)n.matrix[a][a]=1;return n}}function jo(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function Bo(t){return(e,i,r,n,a,s)=>{const o=e.matrix.length;if(o===0)return;const l=e.matrix[0].length,c=r!==void 0?r:0,h=n!==void 0?n:o,p=a!==void 0?a:0,u=s!==void 0?s:l;for(let f=c;f<h&&!(f>=o);f++)for(let m=p;m<u&&!(m>=l);m++)e.matrix[f][m]=i}}function Fo(t){return(e,i,r)=>{if(!e.matrix[i])return NaN;const n=e.matrix[i][r];return n===void 0?NaN:n}}function Tt(t){const e=t.length;if(e===0)return[];const i=new Array(e);for(let n=0;n<e;n++){i[n]=new Array(2*e);for(let a=0;a<e;a++)i[n][a]=t[n][a];for(let a=0;a<e;a++)i[n][e+a]=n===a?1:0}for(let n=0;n<e;n++){let a=Math.abs(i[n][n]),s=n;for(let l=n+1;l<e;l++){const c=Math.abs(i[l][n]);c>a&&(a=c,s=l)}if(a<1e-14)return t.map(l=>l.map(()=>NaN));if(s!==n){const l=i[n];i[n]=i[s],i[s]=l}const o=i[n][n];for(let l=n;l<2*e;l++)i[n][l]/=o;for(let l=0;l<e;l++){if(l===n)continue;const c=i[l][n];if(c!==0)for(let h=n;h<2*e;h++)i[l][h]-=c*i[n][h]}}const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(e);for(let a=0;a<e;a++)r[n][a]=i[n][e+a]}return r}function Wo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new B(i,r,NaN,t);const n=Tt(e.matrix),a=new B(i,r,NaN,t);return a.matrix=n,a}}function $o(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n+a!==i-1&&e.matrix[n][a]!==0)return!1;return!0}}function Uo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[a][n]!==-e.matrix[n][a])return!1;return!0}}function qo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++){const s=e.matrix[n][a];if(s!==0&&s!==1)return!1}return!0}}function zo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n!==a&&e.matrix[n][a]!==0)return!1;return!0}}function Ko(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n===a){if(e.matrix[n][a]!==1)return!1}else if(e.matrix[n][a]!==0)return!1;return!0}}function Ho(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function Go(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let a=0;for(let s=0;s<r;s++){const o=e.matrix[n][s];if(o<0)return!1;a+=o}if(Math.abs(a-1)>1e-10)return!1}return!0}}function Yo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<n;a++)if(e.matrix[n][a]!==e.matrix[a][n])return!1;return!0}}function Qo(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;let n=!0,a=!0;for(let s=0;s<i;s++)for(let o=0;o<r;o++)s>o&&e.matrix[s][o]!==0&&(n=!1),s<o&&e.matrix[s][o]!==0&&(a=!1);return n||a}}function Xo(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[n][a]!==0)return!1;return!0}}function Zo(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,a=i.matrix.length,s=a>0?i.matrix[0].length:0,o=r*a,l=n*s,c=new B(o,l,NaN,t);for(let h=0;h<r;h++)for(let p=0;p<n;p++){const u=e.matrix[h][p];for(let f=0;f<a;f++)for(let m=0;m<s;m++){const y=i.matrix[f][m];c.matrix[h*a+f][p*s+m]=u*y}}return c}}function Jo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l>n&&(n=l),a=!0)}return a?n:NaN}}function el(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||n.push(l)}if(n.length===0)return NaN;n.sort((s,o)=>s-o);const a=Math.floor(n.length/2);return n.length%2!==0?n[a]:(n[a-1]+n[a])/2}}function tl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l<n&&(n=l),a=!0)}return a?n:NaN}}function il(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let a=0,s=NaN;for(let o=0;o<i;o++)for(let l=0;l<r;l++){const c=e.matrix[o][l];if(!isNaN(c)){const h=(n.get(c)||0)+1;n.set(c,h),h>a?(a=h,s=c):h===a&&c<s&&(s=c)}}return s}}function rl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof B){const a=i.matrix.length,s=a>0?i.matrix[0].length:0;if(n!==a)return new B(0,0,NaN,t);const o=new B(r,s,0,t);for(let l=0;l<r;l++)for(let c=0;c<s;c++){let h=0;for(let p=0;p<n;p++)h+=e.matrix[l][p]*i.matrix[p][c];o.matrix[l][c]=h}return o}else if(i instanceof R||Array.isArray(i.array||i)){const a=i.array||i;if(n!==a.length)return new B(0,0,NaN,t);const s=new B(r,1,0,t);for(let o=0;o<r;o++){let l=0;for(let c=0;c<n;c++)l+=e.matrix[o][c]*a[c];s.matrix[o][0]=l}return s}else{const a=i,s=new B(r,n,NaN,t);for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]*a;return s}}}function nl(t){return e=>{const i=e.matrix.length;if(i===0)return new B(0,0,NaN,t);const r=e.matrix[0].length;if(i===r){const h=Tt(e.matrix),p=new B(i,r,NaN,t);return p.matrix=h,p}const n=h=>{const p=h.length,u=h[0].length,f=new Array(u);for(let m=0;m<u;m++){f[m]=new Array(p);for(let y=0;y<p;y++)f[m][y]=h[y][m]}return f},a=(h,p)=>{const u=h.length,f=h[0].length,m=p[0].length,y=new Array(u);for(let _=0;_<u;_++){y[_]=new Array(m).fill(0);for(let b=0;b<f;b++){const w=h[_][b];if(w!==0)for(let v=0;v<m;v++)y[_][v]+=w*p[b][v]}}return y},s=e.matrix,o=n(s);let l;if(i>r){const h=a(o,s),p=Tt(h);l=a(p,o)}else{const h=a(s,o),p=Tt(h);l=a(o,p)}const c=new B(r,i,NaN,t);return c.matrix=l,c}}function sl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new B(0,0,NaN,t);let a=new B(r,n,0,t);for(let l=0;l<r;l++)a.matrix[l][l]=1;let s=new B(r,n,NaN,t);for(let l=0;l<r;l++)s.matrix[l]=[...e.matrix[l]];let o=Math.floor(i);if(o<0)return new B(r,n,NaN,t);for(;o>0;){if(o%2===1){const c=new B(r,n,0,t);for(let h=0;h<r;h++)for(let p=0;p<n;p++){let u=0;for(let f=0;f<r;f++)u+=a.matrix[h][f]*s.matrix[f][p];c.matrix[h][p]=u}a=c}const l=new B(r,n,0,t);for(let c=0;c<r;c++)for(let h=0;h<n;h++){let p=0;for(let u=0;u<r;u++)p+=s.matrix[c][u]*s.matrix[u][h];l.matrix[c][h]=p}s=l,o=Math.floor(o/2)}return a}}function al(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(s=>[...s]);let a=0;for(let s=0;s<r&&a<i;s++){let o=a;for(;o<i&&Math.abs(n[o][s])<1e-10;)o++;if(o<i){[n[a],n[o]]=[n[o],n[a]];const l=n[a][s];for(let c=s;c<r;c++)n[a][c]/=l;for(let c=0;c<i;c++)if(c!==a){const h=n[c][s];for(let p=s;p<r;p++)n[c][p]-=h*n[a][p]}a++}}return a}}function ol(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const s=Ne(e.matrix[0][0]);return new R([],s,t)}const n=[];for(let s=0;s<r;s++){const o=e.matrix[s].splice(i,1);n.push(o[0])}const a=Ne(n[0]);return new R(n,a,t)}}function ll(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=Ne(r[0][0]);return new R(r[0]||[],n,t)}}function cl(t){return(e,i,r)=>{const n=e.matrix.length,a=n>0?e.matrix[0].length:0,s=i*r,o=[];for(let h=0;h<n;h++)for(let p=0;p<a;p++)o.push(e.matrix[h][p]);for(;o.length<s;)o.push(NaN);o.length>s&&(o.length=s);const l=[];let c=0;for(let h=0;h<i;h++){const p=[];for(let u=0;u<r;u++)p.push(o[c++]);l.push(p)}e.matrix=l}}function hl(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function ul(t){return(e,i)=>{if(!e.matrix[i]){const n=Ne(e.matrix[0][0]);return new R([],n,t)}const r=Ne(e.matrix[i][0]);return new R([...e.matrix[i]],r,t)}}function pl(t){return e=>e.matrix.length}function fl(t){return(e,i,r,n)=>{e.matrix[i]&&(e.matrix[i][r]=n)}}function dl(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,a)=>{const s=n[i],o=a[i];return s<o?r==="asc"?-1:1:s>o?r==="asc"?1:-1:0})}}function ml(t){return(e,i,r,n,a)=>{const s=r-i,o=a-n,l=new B(s,o,NaN,t);for(let c=0;c<s;c++){const h=i+c;if(h>=e.matrix.length)break;for(let p=0;p<o;p++){const u=n+p;if(u>=e.matrix[h].length)break;l.matrix[c][p]=e.matrix[h][u]}}return l}}function xl(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new B(0,0,NaN,t);const n=e.matrix[0].length,a=new B(r,n,NaN,t);if(i instanceof B)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l+c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]+s}return a}}function gl(t){return(e,i,r)=>{const n=e.matrix.length;for(let a=0;a<n;a++){const s=e.matrix[a][i];e.matrix[a][i]=e.matrix[a][r],e.matrix[a][r]=s}}}function yl(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function _l(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let a=0;for(let s=0;s<n;s++)a+=e.matrix[s][s];return a}}function bl(t){return e=>{const i=e.matrix.length;if(i===0)return new B(0,0,NaN,t);const r=e.matrix[0].length,n=new B(r,i,NaN,t);for(let a=0;a<i;a++)for(let s=0;s<r;s++)n.matrix[s][a]=e.matrix[a][s];return n}}class B{constructor(e=0,i=0,r=NaN,n){if(this.context=n,this.matrix=[],e>0&&i>0)for(let a=0;a<e;a++)this.matrix.push(Array(i).fill(r));this._add_col=No(this.context),this._add_row=Co(this.context),this._avg=Io(this.context),this._col=ko(this.context),this._columns=Ao(this.context),this._concat=To(this.context),this._copy=Po(this.context),this._det=Ro(this.context),this._diff=Mo(this.context),this._eigenvalues=Vo(this.context),this._eigenvectors=Lo(this.context),this._elements_count=jo(this.context),this._fill=Bo(this.context),this._get=Fo(this.context),this._inv=Wo(this.context),this._is_antidiagonal=$o(this.context),this._is_antisymmetric=Uo(this.context),this._is_binary=qo(this.context),this._is_diagonal=zo(this.context),this._is_identity=Ko(this.context),this._is_square=Ho(this.context),this._is_stochastic=Go(this.context),this._is_symmetric=Yo(this.context),this._is_triangular=Qo(this.context),this._is_zero=Xo(this.context),this._kron=Zo(this.context),this._max=Jo(this.context),this._median=el(this.context),this._min=tl(this.context),this._mode=il(this.context),this._mult=rl(this.context),this._pinv=nl(this.context),this._pow=sl(this.context),this._rank=al(this.context),this._remove_col=ol(this.context),this._remove_row=ll(this.context),this._reshape=cl(this.context),this._reverse=hl(this.context),this._row=ul(this.context),this._rows=pl(this.context),this._set=fl(this.context),this._sort=dl(this.context),this._submatrix=ml(this.context),this._sum=xl(this.context),this._swap_columns=gl(this.context),this._swap_rows=yl(this.context),this._trace=_l(this.context),this._transpose=bl(this.context)}matrix;_add_col;_add_row;_avg;_col;_columns;_concat;_copy;_det;_diff;_eigenvalues;_eigenvectors;_elements_count;_fill;_get;_inv;_is_antidiagonal;_is_antisymmetric;_is_binary;_is_diagonal;_is_identity;_is_square;_is_stochastic;_is_symmetric;_is_triangular;_is_zero;_kron;_max;_median;_min;_mode;_mult;_pinv;_pow;_rank;_remove_col;_remove_row;_reshape;_reverse;_row;_rows;_set;_sort;_submatrix;_sum;_swap_columns;_swap_rows;_trace;_transpose;toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
|
|
138
|
-
`,e+="["+this.matrix[i].join(", ")+"]";return e}add_col(...e){return this._add_col(this,...e)}add_row(...e){return this._add_row(this,...e)}avg(...e){return this._avg(this,...e)}col(...e){return this._col(this,...e)}columns(...e){return this._columns(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}det(...e){return this._det(this,...e)}diff(...e){return this._diff(this,...e)}eigenvalues(...e){return this._eigenvalues(this,...e)}eigenvectors(...e){return this._eigenvectors(this,...e)}elements_count(...e){return this._elements_count(this,...e)}fill(...e){return this._fill(this,...e)}get(...e){return this._get(this,...e)}inv(...e){return this._inv(this,...e)}is_antidiagonal(...e){return this._is_antidiagonal(this,...e)}is_antisymmetric(...e){return this._is_antisymmetric(this,...e)}is_binary(...e){return this._is_binary(this,...e)}is_diagonal(...e){return this._is_diagonal(this,...e)}is_identity(...e){return this._is_identity(this,...e)}is_square(...e){return this._is_square(this,...e)}is_stochastic(...e){return this._is_stochastic(this,...e)}is_symmetric(...e){return this._is_symmetric(this,...e)}is_triangular(...e){return this._is_triangular(this,...e)}is_zero(...e){return this._is_zero(this,...e)}kron(...e){return this._kron(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}mult(...e){return this._mult(this,...e)}pinv(...e){return this._pinv(this,...e)}pow(...e){return this._pow(this,...e)}rank(...e){return this._rank(this,...e)}remove_col(...e){return this._remove_col(this,...e)}remove_row(...e){return this._remove_row(this,...e)}reshape(...e){return this._reshape(this,...e)}reverse(...e){return this._reverse(this,...e)}row(...e){return this._row(this,...e)}rows(...e){return this._rows(this,...e)}set(...e){return this._set(this,...e)}sort(...e){return this._sort(this,...e)}submatrix(...e){return this._submatrix(this,...e)}sum(...e){return this._sum(this,...e)}swap_columns(...e){return this._swap_columns(this,...e)}swap_rows(...e){return this._swap_rows(this,...e)}trace(...e){return this._trace(this,...e)}transpose(...e){return this._transpose(this,...e)}}function we(t){return(e,i,r)=>new B(e,i,r,t)}function vl(t){return(e,i=0)=>g.from(e).get(i)}class wl{constructor(e){this.context=e,this.add_col=(i,...r)=>i.add_col(...r),this.add_row=(i,...r)=>i.add_row(...r),this.avg=(i,...r)=>i.avg(...r),this.col=(i,...r)=>i.col(...r),this.columns=(i,...r)=>i.columns(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.det=(i,...r)=>i.det(...r),this.diff=(i,...r)=>i.diff(...r),this.eigenvalues=(i,...r)=>i.eigenvalues(...r),this.eigenvectors=(i,...r)=>i.eigenvectors(...r),this.elements_count=(i,...r)=>i.elements_count(...r),this.fill=(i,...r)=>i.fill(...r),this.get=(i,...r)=>i.get(...r),this.inv=(i,...r)=>i.inv(...r),this.is_antidiagonal=(i,...r)=>i.is_antidiagonal(...r),this.is_antisymmetric=(i,...r)=>i.is_antisymmetric(...r),this.is_binary=(i,...r)=>i.is_binary(...r),this.is_diagonal=(i,...r)=>i.is_diagonal(...r),this.is_identity=(i,...r)=>i.is_identity(...r),this.is_square=(i,...r)=>i.is_square(...r),this.is_stochastic=(i,...r)=>i.is_stochastic(...r),this.is_symmetric=(i,...r)=>i.is_symmetric(...r),this.is_triangular=(i,...r)=>i.is_triangular(...r),this.is_zero=(i,...r)=>i.is_zero(...r),this.kron=(i,...r)=>i.kron(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.mult=(i,...r)=>i.mult(...r),this.new=we(e),this.param=vl(),this.pinv=(i,...r)=>i.pinv(...r),this.pow=(i,...r)=>i.pow(...r),this.rank=(i,...r)=>i.rank(...r),this.remove_col=(i,...r)=>i.remove_col(...r),this.remove_row=(i,...r)=>i.remove_row(...r),this.reshape=(i,...r)=>i.reshape(...r),this.reverse=(i,...r)=>i.reverse(...r),this.row=(i,...r)=>i.row(...r),this.rows=(i,...r)=>i.rows(...r),this.set=(i,...r)=>i.set(...r),this.sort=(i,...r)=>i.sort(...r),this.submatrix=(i,...r)=>i.submatrix(...r),this.sum=(i,...r)=>i.sum(...r),this.swap_columns=(i,...r)=>i.swap_columns(...r),this.swap_rows=(i,...r)=>i.swap_rows(...r),this.trace=(i,...r)=>i.trace(...r),this.transpose=(i,...r)=>i.transpose(...r),this.new_float=we(e),this.new_int=we(e),this.new_string=we(e),this.new_bool=we(e),this.new_color=we(e),this.new_line=we(e),this.new_label=we(e),this.new_box=we(e),this.new_linefill=we(e),this.new_table=we(e)}}class El{constructor(e){this.context=e}_live=!1;setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.length-1}get isrealtime(){return this.context.idx===this.context.length-1}get isconfirmed(){return this.context.data.closeTime.data[this.context.idx]<=Date.now()}get islastconfirmedhistory(){const e=this.context.idx,i=this.context.length;if(e===i-1)return this.context.data.closeTime.data[e]<=Date.now();if(e===i-2){const r=this.context.marketData?.[i-1]?.closeTime;return r!==void 0?r>Date.now():!1}return!1}}class ot{constructor(e,i){this._definition=e,this.context=i;for(let r in e)this[r]=e[r]}get __def__(){return this._definition}copy(){return new ot(this.__def__,this.context)}toString(){const e={};for(let i in this.__def__){const r=this[i];r!=null&&typeof r=="object"&&typeof r.toString=="function"&&!(r instanceof Array)?e[i]=r.toString():e[i]=r}try{return JSON.stringify(e)}catch{return"{"+Object.keys(e).map(i=>`"${i}":${String(e[i])}`).join(",")+"}"}}}class ne{time;index;price;constructor(e,i,r){this.time=e,this.index=i,this.price=r}copy(){return new ne(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function Sl(t){return typeof t=="object"&&t&&(t.title!==void 0||t._plotKey!==void 0)&&t.data!==void 0&&t.options!==void 0}const Yi={series:t=>t instanceof g||typeof t=="number"||typeof t=="string"||typeof t=="boolean",string:t=>typeof t=="string",color:t=>typeof t=="string"||typeof t=="number"&&isNaN(t),number:t=>typeof t=="number",boolean:t=>typeof t=="boolean",array:t=>Array.isArray(t),object:t=>typeof t=="object",point:t=>t instanceof ne,primitive:t=>typeof t===null||typeof t!="object"&&typeof t!="function",function:t=>typeof t=="function",undefined:t=>t===void 0,null:t=>t===null,NaN:t=>isNaN(t),remaining_options:t=>typeof t=="object"&&!(t instanceof g)&&!(t instanceof ne)&&!Sl(t)};function Ie(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function G(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let a={};const s=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const l=t[o];if(Yi.remaining_options(l)){a=l;break}const c=e.map((h,p)=>s[p]?h[o]:void 0);for(let h=0;h<c.length;h++){const p=c[h];if(p===void 0){s[h]=!1;continue}const u=i[p];if(typeof l=="number"&&isNaN(l)&&(u==="number"||u==="series"))n[p]=l;else{const f=Yi[i[p]];typeof f=="function"&&f(l)?n[p]=l:s[h]=!1}}}return{...n,...a,...r}}const Nl=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Cl={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},Il=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],kl={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function Al(t){return G(t,Il,kl)}class dt{get __value(){return NaN}param(e,i=0){return g.from(e).get(i)}any(e){const i=g.from(e).get(0);return i==null?!0:typeof i=="number"?i!==i:!1}}class Tl{constructor(e){this.context=e}extractPlotOptions(e){const i={};for(let r in e)i[r]=g.from(e[r]).get(0);return i}indicator(...e){const i=Al(e),r={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"points",max_bars_back:0,timeframe:"",timeframe_gaps:!0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,max_polylines_count:50,dynamic_requests:!1,behind_chart:!0};return this.context.indicator={...r,...i},this.context.indicator}get bar_index(){return this.context.idx}na(e){return isNaN(g.from(e).get(0))}nz(e,i=0){const r=g.from(e).get(0),n=g.from(i).get(0);return isNaN(r)?n:r}fixnan(e){const i=g.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){}alert(...e){console.warn("alert called but is currently not implemented",e)}error(...e){console.error("error called but is currently not implemented",e)}max_bars_back(e,i){}timestamp(...e){const i=e.map(n=>n instanceof g?n.get(0):n),r=G(i,Nl,Cl);if(r.year!==void 0){const n=r.year,a=r.month,s=r.day,o=r.hour||0,l=r.minute||0,c=r.second||0,h=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(h,n,a,s,o,l,c)}return r.dateString!==void 0?new Date(r.dateString).getTime():NaN}_timestampFromComponents(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=e.trim();if(c==="UTC"||c==="GMT")return l.getTime();const h=c.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(h){const p=h[1]==="+"?1:-1,u=parseInt(h[2],10),f=parseInt(h[3]||"0",10),m=p*(u*60+f)*60*1e3;return l.getTime()-m}try{return this._timestampFromIANA(e,i,r,n,a,s,o)}catch{return l.getTime()}}_timestampFromIANA(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(l),h=v=>parseInt(c.find(S=>S.type===v)?.value||"0",10),p=h("year"),u=h("month"),f=h("day");let m=h("hour");m===24&&(m=0);const y=h("minute"),_=h("second"),b=new Date(Date.UTC(p,u-1,f,m,y,_));p>=0&&p<100&&b.setUTCFullYear(p);const w=b.getTime()-l.getTime();return l.getTime()-w}bool(e){const i=g.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=g.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "int" with argument "x"="${i}". An argument of "literal string" type was used but a "simple int" is expected.`);return Math.trunc(i)}float(e){const i=g.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "float" with argument "x"="${i}". An argument of "literal string" type was used but a "const float" is expected.`);return i}string(e){return g.from(e).get(0).toString()}Type(e){const i=Object.keys(e),r={};for(const n of i){let a=e[n];a instanceof g&&(a=a.data),Array.isArray(a)&&(a[0],r[n]=a[1])}return{new:function(...n){const a={};let s=null;if(n.length===1&&n[0]&&typeof n[0]=="object"&&!(n[0]instanceof g)&&!Array.isArray(n[0])&&!(n[0]instanceof ot)){const o=Object.keys(n[0]);o.length>0&&o.some(l=>i.includes(l))&&(s=n[0],n=[])}for(let o=0;o<i.length;o++){const l=i[o];s&&l in s?a[l]=s[l]:o<n.length?a[l]=n[o]:l in r&&(a[l]=g.from(r[l]).get(0))}return new ot(a,this.context)},copy:function(n){return new ot(n.__def__,this.context)}}}}function st(t){if(!t||typeof t!="string")return null;if(t.startsWith("#")){const i=t.slice(1);return i.length===6?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),1]:i.length===8?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),parseInt(i.slice(6,8),16)/255]:null}const e=t.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);return e?[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),e[4]?parseFloat(e[4]):1]:null}function Pl(t,e,i,r){const n=Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),a=Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0"),s=Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");if(r>=1)return`#${n}${a}${s}`.toUpperCase();const o=Math.round(Math.max(0,Math.min(255,r*255))).toString(16).padStart(2,"0");return`#${n}${a}${s}${o}`.toUpperCase()}const H={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#F23645",silver:"#B2B5BE",teal:"#089981",white:"#FFFFFF",yellow:"#FDD835"};function Ce(t){return typeof t=="function"&&(t=t()),t&&typeof t=="object"&&Array.isArray(t.data)&&typeof t.get=="function"&&(t=t.get(0)),t}class Dl{constructor(e){this.context=e}any(e){const i=g.from(e).get(0);return typeof i=="number"&&isNaN(i)?null:i}param(e,i=0){return g.from(e).get(i)}new(e,i){if(e=Ce(e),!e||typeof e!="string")return e;if(e.startsWith("#")){const r=e.slice(1),n=r.length===8?r.slice(0,6):r;return i!=null?`#${n}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=H[e];if(r)return i!=null?`#${r.slice(1)}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:r;const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(n){const a=n[1],s=n[2],o=n[3];if(i!=null){const l=parseInt(a).toString(16).padStart(2,"0"),c=parseInt(s).toString(16).padStart(2,"0"),h=parseInt(o).toString(16).padStart(2,"0"),p=Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase();return`#${l}${c}${h}${p}`}return e}return i!=null?`rgba(${e}, ${(100-i)/100})`:e}}rgb(e,i,r,n){return n!=null?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`}from_gradient(e,i,r,n,a){if(e=Ce(e),i=Ce(i),r=Ce(r),n=Ce(n),a=Ce(a),e==null||typeof e=="number"&&isNaN(e)||i==null||typeof i=="number"&&isNaN(i)||r==null||typeof r=="number"&&isNaN(r)||n==null||typeof n=="number"&&isNaN(n)||a==null||typeof a=="number"&&isNaN(a))return;let s=0;r!==i&&(s=(e-i)/(r-i)),s=Math.max(0,Math.min(1,s));const o=st(typeof n=="string"?n:"#000000")||[0,0,0,1],l=st(typeof a=="string"?a:"#FFFFFF")||[255,255,255,1],c=o[0]+(l[0]-o[0])*s,h=o[1]+(l[1]-o[1])*s,p=o[2]+(l[2]-o[2])*s,u=o[3]+(l[3]-o[3])*s;return Pl(c,h,p,u)}r(e){if(e=Ce(e),!e||typeof e!="string")return NaN;const i=st(e);return i?i[0]:NaN}g(e){if(e=Ce(e),!e||typeof e!="string")return NaN;const i=st(e);return i?i[1]:NaN}b(e){if(e=Ce(e),!e||typeof e!="string")return NaN;const i=st(e);return i?i[2]:NaN}t(e){if(e=Ce(e),!e||typeof e!="string")return NaN;const i=st(e);return i?Math.round(100-i[3]*100):NaN}aqua(){return H.aqua}black(){return H.black}blue(){return H.blue}fuchsia(){return H.fuchsia}gray(){return H.gray}green(){return H.green}lime(){return H.lime}maroon(){return H.maroon}navy(){return H.navy}olive(){return H.olive}orange(){return H.orange}purple(){return H.purple}red(){return H.red}silver(){return H.silver}teal(){return H.teal}white(){return H.white}yellow(){return H.yellow}}function Ot(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,a=parseInt(r[2],10),s=parseInt(r[3]||"0",10),o=n*(a*60+s)*60*1e3,l=new Date(t+o);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),dayOfWeek:l.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),a=c=>parseInt(n.find(h=>h.type===c)?.value||"0",10);let s=a("hour");s===24&&(s=0);const o=n.find(c=>c.type==="weekday")?.value||"Sun",l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:a("year"),month:a("month"),day:a("day"),hour:s,minute:a("minute"),second:a("second"),dayOfWeek:l[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function Rl(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const a=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-a.getTime())/864e5+1)/7)}const Ml=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],Ol={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class Qi{context;dataField;constructor(e,i="openTime"){this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return g.from(e).get(i)}any(...e){const i=e.map(c=>c instanceof g?c.get(0):c),r=G(i,Ml,Ol),n=r.bars_back??0,a=r.timeframe_bars_back??0,s=n+a,o=this.context.data[this.dataField],l=g.from(o).get(s);if(r.session!==void 0){const c=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(l,r.session,c)?l:NaN}return l}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const a=parseInt(n[1],10),s=parseInt(n[2],10),o=parseInt(n[3],10),l=parseInt(n[4],10),c=Ot(e,r),h=c.hour,p=c.minute,u=h*60+p,f=a*60+s,m=o*60+l;return f<=m?u>=f&&u<m:u>=f||u<m}}const Vl=[[],["time"],["time","timezone"]],Ll={time:"number",timezone:"string"};class We{context;extractor;constructor(e,i){this.context=e,this.extractor=i}get __value(){const e=g.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=Ot(e,i);return this.extractor(r)}param(e,i=0){return g.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof g?o.get(0):o);if(i.length===0)return this.__value;const r=G(i,Vl,Ll),n=r.time;if(n===void 0||isNaN(n))return NaN;const a=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",s=Ot(n,a);return this.extractor(s)}}const $e={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>Rl(t.year,t.month,t.day),year:t=>t.year},jl=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],Bl={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function ce(t){return G(t,jl,Bl)}function ve(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function Fl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Wl(t){return(...e)=>ce(e).defval}function $l(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Ul(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function ql(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function zl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Kl(t){return(e,i=0)=>g.from(e).get(i)}function Hl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Gl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Yl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Ql(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Xl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Zl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function Jl(t){return(...e)=>{const i=ce(e);return ve(t,i)}}function ec(t){return(...e)=>ce(e).defval}const tc={any:Fl,bool:Wl,color:$l,enum:Ul,float:ql,int:zl,param:Kl,price:Hl,session:Gl,source:Yl,string:Ql,symbol:Xl,text_area:Zl,time:Jl,timeframe:ec};class ic{constructor(e){this.context=e,Object.entries(tc).forEach(([i,r])=>{this[i]=r(e)})}any;bool;color;enum;float;int;param;price;session;source;string;symbol;text_area;time;timeframe}function rc(t){return e=>Math.abs(g.from(e).get(0))}function nc(t){return e=>Math.acos(g.from(e).get(0))}function sc(t){return e=>Math.asin(g.from(e).get(0))}function ac(t){return e=>Math.atan(g.from(e).get(0))}function oc(t){return(...e)=>{const i=e.map(r=>g.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function lc(t){return e=>Math.ceil(g.from(e).get(0))}function cc(t){return e=>Math.cos(g.from(e).get(0))}function hc(t){return()=>Math.E}function uc(t){return e=>Math.exp(g.from(e).get(0))}function pc(t){return e=>Math.floor(g.from(e).get(0))}function fc(t){return e=>Math.log(g.from(e).get(0))}function dc(t){return e=>Math.log(g.from(e).get(0))}function mc(t){return e=>Math.log10(g.from(e).get(0))}function xc(t){return(...e)=>{const i=e.map(r=>g.from(r).get(0));return Math.max(...i)}}function gc(t){return(...e)=>{const i=e.map(r=>g.from(r).get(0));return Math.min(...i)}}function yc(t){return(e,i,r)=>typeof e=="string"?e:e instanceof g?i?new g(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new g(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new g(t.params[r],i||0)))}function _c(t){return()=>1.618033988749895}function bc(t){return()=>Math.PI}function vc(t){return(e,i)=>Math.pow(g.from(e).get(0),g.from(i).get(0))}function wc(t){return()=>Math.random()}function Qt(t){return t!==t?NaN:Math.sign(t)*Math.round(Math.abs(t))}function Ec(t){return(e,i)=>{const r=g.from(e).get(0);if(i==null)return Qt(r);const n=g.from(i).get(0);if(n===0)return Qt(r);const a=Math.pow(10,n);return Qt(r*a)/a}}function Sc(t){return e=>t.precision(Math.round(g.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Nc(t){return()=>.6180339887498948}function Cc(t){return e=>Math.sign(g.from(e).get(0))}function Ic(t){return e=>Math.sin(g.from(e).get(0))}function kc(t){return e=>Math.sqrt(g.from(e).get(0))}function Ac(t){return(e,i)=>{const r=g.from(i).get(0),n=g.from(e);let a=0;for(let s=0;s<r;s++){const o=n.get(s);a+=o}return a}}function Tc(t){return e=>Math.tan(g.from(e).get(0))}function Pc(t){return e=>{const i=g.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function Dc(t){return e=>{const i=g.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function Rc(t){return(e,i)=>{const r=g.from(e).get(0),n=g.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-8:r===n}}function Mc(t){return(e,i)=>{const r=g.from(e).get(0),n=g.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)>=1e-8:r!==n}}const Oc={abs:rc,acos:nc,asin:sc,atan:ac,avg:oc,ceil:lc,cos:cc,e:hc,exp:uc,floor:pc,ln:fc,log:dc,log10:mc,max:xc,min:gc,param:yc,phi:_c,pi:bc,pow:vc,random:wc,round:Ec,round_to_mintick:Sc,rphi:Nc,sign:Cc,sin:Ic,sqrt:kc,sum:Ac,tan:Tc,todegrees:Pc,toradians:Dc,__eq:Rc,__neq:Mc};class Vc{constructor(e){this.context=e,Object.entries(Oc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};abs;acos;asin;atan;avg;ceil;cos;e;exp;floor;ln;log;log10;max;min;param;phi;pi;pow;random;round;round_to_mintick;rphi;sign;sin;sqrt;sum;tan;todegrees;toradians;__eq;__neq}function Lc(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof g)n=e.get(i||0);else if(Array.isArray(e)){const a=e.some(o=>o instanceof g),s=e.every(o=>!(o instanceof g)&&!Array.isArray(o));(a||s)&&e.length>=1?n=e.map(o=>o instanceof g?o.get(0):o):n=g.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,[n,r]}}const ct=["1","3","5","15","30","45","60","120","180","240","D","W","M"],kt={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function Vt(t){if(ct.includes(t))return t;if(kt[t])return kt[t];const e=t.toLowerCase();if(kt[e])return kt[e];const i=t.toUpperCase();return ct.includes(i)?i:t}function Xi(t,e,i,r,n=!1,a=!1){for(let s=0;s<i.length;s++)if(i[s]<=t&&t<r[s])return n||a||e>=r[s]?s:s-1;return-1}function Zi(t,e,i,r,n=!1,a,s=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const l=a&&e>a;if(s&&n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(l&&n&&!s)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}return o}if(r[o]<t)break}return-1}function hi(t){return t==null||typeof t!="object"?t:"__value"in t?t.__value:t instanceof g?t.get(0):Array.isArray(t)?t.map(hi):t}function jc(t){return async(e,i,r,n=!1,a=!1,s=!1,o=null,l=null)=>{const c=e[0]instanceof g?e[0].get(0):e[0],h=c===""?t.tickerId:c,p=typeof h=="string"&&h.includes(":")?h.split(":")[1]:h,u=i[0]instanceof g?i[0].get(0):i[0],f=u===""?t.timeframe:typeof u=="string"?u:String(u??""),m=r[0],y=r[1],_=Array.isArray(n)?n[0]:n,b=Array.isArray(a)?a[0]:a,w=_===!0||_==="gaps_on",v=b===!0||b==="lookahead_on";if(t.isSecondaryContext){const he=hi(m);return Array.isArray(he)?[he]:he}const S=ct.indexOf(Vt(t.timeframe)),N=ct.indexOf(Vt(f));if(S==-1||N==-1)throw new Error("Invalid timeframe");if(S===N){const he=hi(m);return Array.isArray(he)?[he]:he}const M=S>N,D=g.from(t.data.openTime).get(0),V=g.from(t.data.closeTime).get(0),W=t.idx===t.length-1&&V>Date.now(),F=`${p}_${f}_${y}`,P=`${F}_prevIdx`;if(t.cache[F]){const he=t.cache[F];t.dataVersion>he.dataVersion&&(await he.pineTS.updateTail(he.context),he.dataVersion=t.dataVersion);const mt=he.context,Nt=M?Zi(D,V,mt.data.openTime.data,mt.data.closeTime.data,v,t.eDate,w):Xi(D,V,mt.data.openTime.data,mt.data.closeTime.data,v,W);if(Nt==-1)return NaN;const it=mt.params[y][Nt];if(!M&&w){const Ci=t.cache[P];return Ci!==void 0&&Ci===Nt?NaN:(t.cache[P]=Nt,Array.isArray(it)?[it]:it)}return Array.isArray(it)?[it]:it}const q=1e3*60*60*24*30,ie=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),fe=ie?ie-q:void 0,de=t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0,me=t.eDate?Math.max(t.eDate,de):(de||Date.now())+q,He=new Ni(t.source,p,f,void 0,fe,me);He.markAsSecondary();const ee=await He.run(t.pineTSCode);t.cache[F]={pineTS:He,context:ee,dataVersion:t.dataVersion};const qt=M?Zi(D,V,ee.data.openTime.data,ee.data.closeTime.data,v,t.eDate,w):Xi(D,V,ee.data.openTime.data,ee.data.closeTime.data,v,W);if(qt==-1)return NaN;const zt=ee.params[y][qt];return!M&&w?(t.cache[P]=qt,NaN):Array.isArray(zt)?[zt]:zt}}function at(t){return typeof t=="number"?A.float:typeof t=="boolean"?A.bool:typeof t=="string"?A.string:A.any}function Bc(t){return async(e,i,r,n=!1,a=null,s=!1,o=0)=>{const l=e[0]instanceof g?e[0].get(0):e[0],c=l===""?t.tickerId:l,h=typeof c=="string"&&c.includes(":")?c.split(":")[1]:c,p=i[0]instanceof g?i[0].get(0):i[0],u=p===""?t.timeframe:typeof p=="string"?p:String(p??""),f=r[0],m=r[1];Array.isArray(n)&&n[0];const y=Array.isArray(s)?s[0]:s;if(t.isSecondaryContext)return Array.isArray(f)?[f.map(P=>new R([P],at(P),t))]:new R([f],at(f),t);const _=ct.indexOf(Vt(t.timeframe)),b=ct.indexOf(Vt(u));if(_===-1||b===-1){if(y)return NaN;throw new Error("Invalid timeframe")}if(b>_){if(y)return NaN;throw new Error(`Timeframe ${u} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(b===_)return Array.isArray(f)?[f.map(P=>new R([P],at(P),t))]:new R([f],at(f),t);const w=`${h}_${u}_${m}_lower`;if(!t.cache[w]){const P=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),q=P?P-2592e6:void 0,ie=t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0,fe=t.eDate?Math.max(t.eDate,ie):(ie||Date.now())+2592e6,de=new Ni(t.source,h,u,void 0,q,fe);de.markAsSecondary();const me=await de.run(t.pineTSCode);t.cache[w]={pineTS:de,context:me,dataVersion:t.dataVersion}}const v=t.cache[w];t.dataVersion>v.dataVersion&&(await v.pineTS.updateTail(v.context),v.dataVersion=t.dataVersion);const S=v.context,N=g.from(t.data.openTime).get(0),M=g.from(t.data.closeTime).get(0),D=S.data.openTime.data,V=S.data.closeTime.data,W=S.params[m];if(!W)return Array.isArray(f)?[f.map(()=>new R([],A.float,t))]:new R([],A.float,t);const F=[];for(let P=0;P<D.length;P++){const q=D[P];if(!(V[P]<=N)){if(q>=M)break;q>=N&&q<M&&F.push(W[P])}}if(F.length>0&&Array.isArray(F[0])){const P=F[0].length,q=[];for(let ie=0;ie<P;ie++){const fe=F.map(me=>me[ie]),de=fe.length>0?at(fe[0]):A.float;q.push(new R(fe,de,t))}return[q]}else{const P=F.length>0?at(F[0]):A.float;return new R(F,P,t)}}}const Fc={param:Lc,security:jc,security_lower_tf:Bc};class Wc{constructor(e){this.context=e,Object.entries(Fc).forEach(([i,r])=>{this[i]=r(e)})}_cache={};param;security;security_lower_tf}function $c(t){return e=>{t.taState||(t.taState={});const i=e||"accdist";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(a)||isNaN(s)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const l=a-s;let c=0;l!==0&&(c=(n-s-(a-n))/l*o);const h=r.prevCumulativeSum+c;return r.currentCumulativeSum=h,t.precision(h)}}function Uc(t){return(e,i,r,n,a)=>{const s=g.from(i).get(0),o=g.from(r).get(0),l=g.from(n).get(0);t.taState||(t.taState={});const c=a||`alma_${s}_${o}_${l}`;if(!t.taState[c]){const y=o*(s-1),_=s/l,b=[];let w=0;for(let v=0;v<s;v++){const S=Math.exp(-Math.pow(v-y,2)/(2*_*_));b.push(S),w+=S}for(let v=0;v<b.length;v++)b[v]/=w;t.taState[c]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0,weights:b}}const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.prevWindow=[...h.currentWindow],h.prevCallCount=h.currentCallCount),h.lastIdx=t.idx);const p=g.from(e).get(0),u=[...h.prevWindow];for(u.unshift(p);u.length>s;)u.pop();const f=h.prevCallCount+1;if(u.length<s&&(f>=s||t.idx>=s-1)){const y=g.from(e);for(;u.length<s;)u.push(y.get(u.length))}if(h.currentWindow=u,h.currentCallCount=f,u.length<s)return NaN;let m=0;for(let y=0;y<s;y++)m+=h.weights[y]*u[s-1-y];return t.precision(m)}}function qc(t){return(e,i)=>{const r=g.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,currentAtr:null,currentInitSum:0,currentInitCount:0});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevAtr=a.currentAtr,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return NaN;const c=t.idx>0?t.get(t.data.close,1):null;let h;if(c!==null&&!isNaN(c)){const y=s-o,_=Math.abs(s-c),b=Math.abs(o-c);h=Math.max(y,_,b)}else h=s-o;let p=a.prevInitCount,u=a.prevInitSum,f=a.prevAtr;if(p<r){if(u+=h,p++,a.currentInitSum=u,a.currentInitCount=p,p===r){const y=u/r;return a.currentAtr=y,t.precision(y)}return NaN}const m=(f*(r-1)+h)/r;return a.currentAtr=m,t.precision(m)}}function zc(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"barssince";t.taState[r]||(t.taState[r]={lastIdx:-1,prevLastTrueIndex:null,currentLastTrueIndex:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const a=g.from(e).get(0);let s=n.prevLastTrueIndex;return a&&(s=t.idx),n.currentLastTrueIndex=s,s===null?NaN:t.idx-s}}function Kc(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=g.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,[[NaN,NaN,NaN]];const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const b=h.pop();p-=b}if(h.length<a&&t.idx>=a-1){const b=g.from(e);for(;h.length<a;){const w=b.get(h.length);if(isNaN(w))break;h.push(w),p+=w}}if(l.currentWindow=h,l.currentSum=p,h.length<a)return[[NaN,NaN,NaN]];const u=p/a;let f=0;for(let b=0;b<a;b++)f+=Math.pow(h[b]-u,2);const m=Math.sqrt(f/a),y=u+s*m,_=u-s*m;return[[t.precision(u),t.precision(y),t.precision(_)]]}}function Hc(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=g.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,NaN;const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const w=h.pop();p-=w}if(h.length<a&&t.idx>=a-1){const w=g.from(e);for(;h.length<a;){const v=w.get(h.length);if(isNaN(v))break;h.push(v),p+=v}}if(l.currentWindow=h,l.currentSum=p,h.length<a)return NaN;const u=p/a;let f=0;for(let w=0;w<a;w++){const v=h[w]-u;f+=v*v}const m=f/a,y=Math.sqrt(m),_=s*y;if(u===0)return t.precision(0);const b=2*_/u*100;return t.precision(b)}}function Gc(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`cci_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0);if(isNaN(o))return NaN;const l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const y=l.pop();c-=y}const h=s.prevCallCount+1;if(l.length<n&&(h>=n||t.idx>=n-1)){const y=g.from(e);for(;l.length<n;){const _=y.get(l.length);if(isNaN(_))break;l.push(_),c+=_}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=h,l.length<n)return NaN;const p=c/n;let u=0;for(let y=0;y<n;y++)u+=Math.abs(l[y]-p);const f=u/n;if(f===0)return 0;const m=(o-p)/(.015*f);return t.precision(m)}}function Yc(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`change_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const p=g.from(e);for(;l.length<n+1;)l.push(p.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const h=o-l[n];return t.precision(h)}}function Qc(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`cmo_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevGainsWindow=[...s.currentGainsWindow],s.prevLossesWindow=[...s.currentLossesWindow],s.prevGainsSum=s.currentGainsSum,s.prevLossesSum=s.currentLossesSum),s.lastIdx=t.idx);const o=g.from(e).get(0),l=g.from(e).get(1);if(isNaN(o)||isNaN(l))return NaN;const c=o-l,h=c>=0?c:0,p=c>=0?0:-c,u=[...s.prevGainsWindow],f=[...s.prevLossesWindow];let m=s.prevGainsSum,y=s.prevLossesSum;if(u.unshift(h),f.unshift(p),m+=h,y+=p,u.length<n)return s.currentGainsWindow=u,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=y,NaN;if(u.length>n){const w=u.pop(),v=f.pop();m-=w,y-=v}s.currentGainsWindow=u,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=y;const _=m+y;if(_===0)return t.precision(0);const b=100*(m-y)/_;return t.precision(b)}}function Xc(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);let s=0,o=!1;for(let h=0;h<n;h++){const p=a.get(h);if(isNaN(p)){o=!0;break}s+=p}if(o)return NaN;let l=0;for(let h=0;h<n;h++){const p=a.get(h);l+=p*(h+1)}if(s===0)return NaN;const c=-l/s;return t.precision(c)}}function Zc(t){return(e,i,r,n)=>{const a=g.from(r).get(0),s=g.from(e),o=g.from(i);if(t.idx<a-1)return NaN;let l=0,c=0,h=0,p=0,u=0,f=0;for(let w=0;w<a;w++){const v=s.get(w),S=o.get(w);isNaN(v)||isNaN(S)||(l+=v,c+=S,h+=v*S,p+=v*v,u+=S*S,f++)}if(f<2)return NaN;const m=f*h-l*c,y=f*p-l*l,_=f*u-c*c;if(y<=0||_<=0)return t.precision(0);const b=m/Math.sqrt(y*_);return t.precision(b)}}function Jc(t){return(e,i,r)=>{const n=g.from(e),a=g.from(i),s=n.get(0),o=a.get(0),l=n.get(1),c=a.get(1);if(isNaN(s)||isNaN(o)||isNaN(l)||isNaN(c))return!1;const h=s>o&&l<=c,p=s<o&&l>=c;return h||p}}function eh(t){return(e,i)=>{const r=g.from(e),n=g.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o<l&&a>s}}function th(t){return(e,i)=>{const r=g.from(e),n=g.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o>l&&a<s}}function ih(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"cum";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const a=g.from(e).get(0);if(isNaN(a))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const s=n.prevCumulativeSum+a;return n.currentCumulativeSum=s,t.precision(s)}}function rh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`dev_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0)||0,l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const m=l.pop();c-=m}const h=s.prevCallCount+1;if(l.length<n&&(h>=n||t.idx>=n-1)){const m=g.from(e);for(;l.length<n;){const y=m.get(l.length);l.push(y),c+=y}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=h,l.length<n)return NaN;const p=c/n;let u=0;for(let m=0;m<n;m++)u+=Math.abs(l[m]-p);const f=u/n;return t.precision(f)}}function nh(t){return(e,i,r)=>{const n=g.from(e).get(0),a=g.from(i).get(0);t.taState||(t.taState={});const s=r||`dmi_${n}_${a}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevTrInitSum:0,prevPlusInitSum:0,prevMinusInitSum:0,prevInitCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,prevDxInitSum:0,prevAdxInitCount:0,prevADX:NaN,currentTrInitSum:0,currentPlusInitSum:0,currentMinusInitSum:0,currentInitCount:0,currentSmoothedTR:NaN,currentSmoothedPlus:NaN,currentSmoothedMinus:NaN,currentDxInitSum:0,currentAdxInitCount:0,currentADX:NaN});const o=t.taState[s];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrInitSum=o.currentTrInitSum,o.prevPlusInitSum=o.currentPlusInitSum,o.prevMinusInitSum=o.currentMinusInitSum,o.prevInitCount=o.currentInitCount,o.prevSmoothedTR=o.currentSmoothedTR,o.prevSmoothedPlus=o.currentSmoothedPlus,o.prevSmoothedMinus=o.currentSmoothedMinus,o.prevDxInitSum=o.currentDxInitSum,o.prevAdxInitCount=o.currentAdxInitCount,o.prevADX=o.currentADX),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(h))return[[NaN,NaN,NaN]];const p=t.idx>0?t.get(t.data.high,1):NaN,u=t.idx>0?t.get(t.data.low,1):NaN,f=t.idx>0?t.get(t.data.close,1):NaN;if(isNaN(p))return[[NaN,NaN,NaN]];const m=Math.max(l-c,Math.abs(l-f),Math.abs(c-f)),y=l-p,_=u-c,b=y>_&&y>0?y:0,w=_>y&&_>0?_:0;let v=o.prevInitCount,S=o.prevTrInitSum,N=o.prevPlusInitSum,M=o.prevMinusInitSum,D=o.prevSmoothedTR,V=o.prevSmoothedPlus,W=o.prevSmoothedMinus;if(v++,v<=n)S+=m,N+=b,M+=w,v===n&&(D=S/n,V=N/n,W=M/n);else{const ee=1/n;D=ee*m+(1-ee)*D,V=ee*b+(1-ee)*V,W=ee*w+(1-ee)*W}if(o.currentInitCount=v,o.currentTrInitSum=S,o.currentPlusInitSum=N,o.currentMinusInitSum=M,o.currentSmoothedTR=D,o.currentSmoothedPlus=V,o.currentSmoothedMinus=W,v<n)return[[NaN,NaN,NaN]];const F=D===0?0:100*V/D,P=D===0?0:100*W/D,q=F+P,ie=q===0?0:100*Math.abs(F-P)/q;let fe=o.prevAdxInitCount,de=o.prevDxInitSum,me=o.prevADX,He=NaN;if(fe++,fe<=a)de+=ie,fe===a&&(me=de/a,He=me);else{const ee=1/a;me=ee*ie+(1-ee)*me,He=me}return o.currentAdxInitCount=fe,o.currentDxInitSum=de,o.currentADX=me,[[t.precision(F),t.precision(P),t.precision(He)]]}}function sh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`ema_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevEma=s.currentEma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=g.from(e).get(0);if(o==null||isNaN(o))return NaN;let l=s.prevInitCount,c=s.prevInitSum,h=s.prevEma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentEma=f,t.precision(f)}return NaN}const p=2/(n+1),u=o*p+h*(1-p);return s.currentEma=u,t.precision(u)}}function ah(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o>=l)return!1}return!0}}function oh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`highest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const u=g.from(e);for(;l.length<n;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.filter(u=>!isNaN(u)&&u!==void 0);if(h.length===0)return NaN;const p=Math.max(...h);return t.precision(p)}}function lh(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);if(t.idx<n-1)return NaN;let s=-1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c>s)&&(s=c,o=-l)}return o}}function ch(t){return(e,i,r)=>{const n=g.from(i).get(0),a=Math.floor(n/2),s=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,l=o(e,a,r?`${r}_wma1`:void 0),c=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(l)||isNaN(c))return NaN;t.taState||(t.taState={});const h=r||`hma_raw_${n}`;t.taState[h]||(t.taState[h]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[h];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const u=2*l-c,f=[...p.prevValues];f.unshift(u),f.length>s+1&&f.pop(),p.currentValues=f;const m=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[m]||(t.taState[m]={lastIdx:-1,prevWindow:[],currentWindow:[]});const y=t.taState[m];t.idx>y.lastIdx&&(y.lastIdx>=0&&(y.prevWindow=[...y.currentWindow]),y.lastIdx=t.idx);const _=[...y.prevWindow];if(_.unshift(u),_.length<s)return y.currentWindow=_,NaN;for(;_.length>s;)_.pop();y.currentWindow=_;let b=0,w=0;for(let S=0;S<s;S++){const N=s-S;b+=_[S]*N,w+=N}const v=b/w;return t.precision(v)}}function hh(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a))return NaN;const s=(r-n)*a;if(s===0)return t.precision(0);const o=(2*i-r-n)/s;return t.precision(o)}}function uh(t){return(e,i,r,n,a)=>{const s=g.from(i).get(0),o=g.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=g.from(n).get(0));let c;const h=t.get(t.data.high,0),p=t.get(t.data.low,0);if(l){const S=t.get(t.data.close,1);isNaN(S)?c=NaN:c=Math.max(h-p,Math.abs(h-S),Math.abs(p-S))}else c=h-p;const u=g.from(e).get(0);t.taState||(t.taState={});const f=a||`kc_${s}_${o}_${l}`;t.taState[f]||(t.taState[f]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const m=t.taState[f];t.idx>m.lastIdx&&(m.lastIdx>=0&&(m.basisState={...m.currentBasisState},m.rangeState={...m.currentRangeState}),m.lastIdx=t.idx);const y=(S,N,M,D)=>{if(isNaN(M))return Object.assign(N,S),N.prevEma!==null?N.prevEma:NaN;let V=S.initCount,W=S.initSum,F=S.prevEma;if(V<D){if(W+=M,V++,N.initSum=W,N.initCount=V,N.prevEma=F,V===D){const ie=W/D;return N.prevEma=ie,ie}return NaN}const P=2/(D+1),q=M*P+F*(1-P);return N.prevEma=q,N.initSum=W,N.initCount=V,q},_=y(m.basisState,m.currentBasisState,u,s),b=y(m.rangeState,m.currentRangeState,c,s);if(isNaN(_)||isNaN(b))return[[NaN,NaN,NaN]];const w=_+b*o,v=_-b*o;return[[t.precision(_),t.precision(w),t.precision(v)]]}}function ph(t){return(e,i,r,n,a)=>{const s=g.from(i).get(0),o=g.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=g.from(n).get(0)),t.taState||(t.taState={});const c=a||`kcw_${s}_${o}_${l}`;t.taState[c]||(t.taState[c]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.basisState={...h.currentBasisState},h.rangeState={...h.currentRangeState}),h.lastIdx=t.idx);const p=(v,S,N,M)=>{if(isNaN(N))return Object.assign(S,v),S.prevEma!==null?S.prevEma:NaN;let D=v.initCount,V=v.initSum,W=v.prevEma;if(D<M){if(V+=N,D++,S.initSum=V,S.initCount=D,S.prevEma=W,D===M){const q=V/M;return S.prevEma=q,q}return NaN}const F=2/(M+1),P=N*F+W*(1-F);return S.prevEma=P,S.initSum=V,S.initCount=D,P};let u;const f=t.get(t.data.high,0),m=t.get(t.data.low,0);if(l){const v=t.get(t.data.close,1);isNaN(v)?u=NaN:u=Math.max(f-m,Math.abs(f-v),Math.abs(m-v))}else u=f-m;const y=g.from(e).get(0),_=p(h.basisState,h.currentBasisState,y,s),b=p(h.rangeState,h.currentRangeState,u,s);if(isNaN(_)||isNaN(b))return NaN;if(_===0)return t.precision(0);const w=2*b*o/_;return t.precision(w)}}function fh(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=g.from(e).get(0),h=[...l.prevWindow];for(h.unshift(c);h.length>a;)h.pop();const p=l.prevCallCount+1;if(h.length<a&&(p>=a||t.idx>=a-1)){const S=g.from(e);for(;h.length<a;)h.push(S.get(h.length))}if(l.currentWindow=h,l.currentCallCount=p,h.length<a)return NaN;let u=0,f=0,m=0,y=0;const _=a;for(let S=0;S<a;S++){const N=a-1-S,M=h[S];u+=N,f+=M,m+=N*M,y+=N*N}const b=_*y-u*u;if(b===0)return NaN;const w=(_*m-u*f)/b,v=(f-w*u)/_+w*(a-1-s);return t.precision(v)}}function dh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`lowest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const u=g.from(e);for(;l.length<n;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.filter(u=>!isNaN(u)&&u!==void 0);if(h.length===0)return NaN;const p=Math.min(...h);return t.precision(p)}}function mh(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);if(t.idx<n-1)return NaN;let s=1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c<s)&&(s=c,o=-l)}return o}}function xh(t){return(e,i,r,n,a)=>{const s=g.from(i).get(0),o=g.from(r).get(0),l=g.from(n).get(0),c=a||`macd_${s}_${o}_${l}`,h=`${c}_fast`,p=`${c}_slow`,u=`${c}_signal`,f=t.pine.ta.ema(e,s,h),m=t.pine.ta.ema(e,o,p);let y=NaN;!isNaN(f)&&!isNaN(m)&&(y=f-m);let _=NaN;isNaN(y)||(_=t.pine.ta.ema(y,l,u));let b=NaN;return!isNaN(y)&&!isNaN(_)&&(b=y-_),[[t.precision(y),t.precision(_),t.precision(b)]]}}function gh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`median_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=g.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.slice().sort((f,m)=>f-m),p=Math.floor(n/2),u=n%2===0?(h[p-1]+h[p])/2:h[p];return t.precision(u)}}function yh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`mfi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevUpperWindow=[...s.currentUpperWindow],s.prevLowerWindow=[...s.currentLowerWindow],s.prevUpperSum=s.currentUpperSum,s.prevLowerSum=s.currentLowerSum),s.lastIdx=t.idx);const o=g.from(e).get(0),l=g.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const h=isNaN(l)?NaN:o-l,p=c*(h<=0?0:o),u=c*(h>=0?0:o),f=[...s.prevUpperWindow],m=[...s.prevLowerWindow];let y=s.prevUpperSum,_=s.prevLowerSum;if(f.unshift(p),m.unshift(u),y+=p,_+=u,f.length<n)return s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=y,s.currentLowerSum=_,NaN;if(f.length>n){const w=f.pop(),v=m.pop();y-=w,_-=v}if(s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=y,s.currentLowerSum=_,_===0)return t.precision(100);if(y===0)return t.precision(0);const b=100-100/(1+y/_);return t.precision(b)}}function _h(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);if(t.idx<n-1)return NaN;const s=new Map;for(let c=0;c<n;c++){const h=a.get(c);isNaN(h)||s.set(h,(s.get(h)||0)+1)}if(s.size===0)return NaN;let o=NaN,l=-1;for(const[c,h]of s.entries())h>l?(l=h,o=c):h===l&&c<o&&(o=c);return o}}function bh(t){return(e,i,r)=>{const n=g.from(i).get(0);return t.pine.ta.change(e,n,r)}}function vh(t){return e=>{t.taState||(t.taState={});const i=e||"nvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedNVI:1,tentativeNVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedNVI=r.tentativeNVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,h=isNaN(s)?0:s,p=isNaN(o)?0:o;let u=r.committedNVI;if(!(l===0||c===0)&&h<p){const f=(l-c)/c;u=u+f*u}return r.tentativeNVI=u,t.precision(u)}}function wh(t){return()=>{t.taState||(t.taState={});const e="obv";t.taState[e]||(t.taState[e]={lastIdx:-1,committedOBV:0,tentativeOBV:0});const i=t.taState[e];t.idx>i.lastIdx&&(i.lastIdx>=0&&(i.committedOBV=i.tentativeOBV),i.lastIdx=t.idx);const r=t.get(t.data.close,0),n=t.get(t.data.volume,0),a=t.get(t.data.close,1);if(isNaN(a))return i.tentativeOBV=0,t.precision(0);let s=i.committedOBV;return r>a?s+=n:r<a&&(s-=n),i.tentativeOBV=s,t.precision(s)}}function Eh(t){return(e,i,r)=>e instanceof g?i?new g(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new g(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new g(t.params[r],i||0)))}function Sh(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0),o=g.from(e);if(t.idx<a-1)return NaN;const l=[];for(let m=0;m<a;m++){const y=o.get(m);if(isNaN(y))return NaN;l.push(y)}l.sort((m,y)=>m-y);let c=s/100*a-.5;c<0&&(c=0),c>a-1&&(c=a-1);const h=Math.floor(c),p=Math.ceil(c);if(h===p)return t.precision(l[h]);const u=c-h,f=l[h]+u*(l[p]-l[h]);return t.precision(f)}}function Nh(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0),o=g.from(e);if(t.idx<a-1)return NaN;const l=[];for(let h=0;h<a;h++){const p=o.get(h);isNaN(p)||l.push(p)}if(l.length===0)return NaN;l.sort((h,p)=>h-p);let c=Math.ceil(s/100*l.length)-1;return c<0&&(c=0),c>=l.length&&(c=l.length-1),t.precision(l[c])}}function Ch(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);if(t.idx<n)return NaN;const s=a.get(0);if(isNaN(s))return NaN;let o=0,l=0;for(let c=1;c<=n;c++){const h=a.get(c);isNaN(h)||(l++,h<=s&&o++)}return l===0?NaN:t.precision(o/l*100)}}function Ih(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]>=a){s=!1;break}}s&&(r[n]=a)}return r}function kh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const a=g.from(i).get(0),s=g.from(r).get(0),o=g.from(e).toArray(),l=Ih(o,a,s),c=t.idx;return t.precision(l[c])}}function Ah(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]<=a){s=!1;break}}s&&(r[n]=a)}return r}function Th(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const a=g.from(i).get(0),s=g.from(r).get(0),o=g.from(e).toArray(),l=Ah(o,a,s),c=t.idx;return t.precision(l[c])}}function Ph(t){return e=>{t.taState||(t.taState={});const i=e||"pvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedPVI:1,tentativePVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedPVI=r.tentativePVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,h=isNaN(s)?0:s,p=isNaN(o)?0:o;let u=r.committedPVI;if(!(l===0||c===0)&&h>p){const f=(l-c)/c;u=u+f*u}return r.tentativePVI=u,t.precision(u)}}function Dh(t){return e=>{t.taState||(t.taState={});const i=e||"pvt";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(a)&&!isNaN(s)&&a!==0){const l=(n-a)/a*s;o+=l}return r.currentCumulativeSum=o,t.precision(o)}}function Rh(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),a=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(a)?NaN:t.precision(n-a)}}function Mh(t){return(e,i,r)=>{const n=g.from(i).get(0),a=g.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o<=l)return!1}return!0}}function Oh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`rma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevRma=s.currentRma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=g.from(e).get(0)||0;let l=s.prevInitCount,c=s.prevInitSum,h=s.prevRma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentRma=f,t.precision(f)}return NaN}const p=1/n,u=o*p+h*(1-p);return s.currentRma=u,t.precision(u)}}function Vh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`roc_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const u=g.from(e);for(;l.length<n+1;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const h=l[n],p=(o-h)/h*100;return t.precision(p)}}function Lh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`rsi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevPrevValue:null,prevAvgGain:0,prevAvgLoss:0,prevInitGains:[],prevInitLosses:[],currentPrevValue:null,currentAvgGain:0,currentAvgLoss:0,currentInitGains:[],currentInitLosses:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevPrevValue=s.currentPrevValue,s.prevAvgGain=s.currentAvgGain,s.prevAvgLoss=s.currentAvgLoss,s.prevInitGains=[...s.currentInitGains],s.prevInitLosses=[...s.currentInitLosses]),s.lastIdx=t.idx);const o=g.from(e).get(0);if(o==null||isNaN(o))return NaN;const l=s.prevPrevValue;if(l===null||isNaN(l))return s.currentPrevValue=o,s.currentInitGains=[...s.prevInitGains],s.currentInitLosses=[...s.prevInitLosses],s.currentAvgGain=s.prevAvgGain,s.currentAvgLoss=s.prevAvgLoss,NaN;let c=s.prevAvgGain,h=s.prevAvgLoss;const p=[...s.prevInitGains],u=[...s.prevInitLosses],f=o-l,m=f>0?f:0,y=f<0?-f:0;if(p.length<n){if(p.push(m),u.push(y),s.currentInitGains=p,s.currentInitLosses=u,s.currentPrevValue=o,p.length===n){c=p.reduce((w,v)=>w+v,0)/n,h=u.reduce((w,v)=>w+v,0)/n,s.currentAvgGain=c,s.currentAvgLoss=h;const b=h===0?100:100-100/(1+c/h);return t.precision(b)}return NaN}c=(c*(n-1)+m)/n,h=(h*(n-1)+y)/n,s.currentAvgGain=c,s.currentAvgLoss=h,s.currentPrevValue=o;const _=h===0?100:100-100/(1+c/h);return t.precision(_)}}function jh(t){return(e,i,r,n)=>{const a=g.from(e).get(0),s=g.from(i).get(0),o=g.from(r).get(0);t.taState||(t.taState={});const l=n||`sar_${a}_${s}_${o}`;t.taState[l]||(t.taState[l]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const c=t.taState[l];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevResult=c.currentResult,c.prevMaxMin=c.currentMaxMin,c.prevAcceleration=c.currentAcceleration,c.prevIsBelow=c.currentIsBelow,c.prevBarIndex=c.currentBarIndex),c.lastIdx=t.idx);let h=c.prevResult,p=c.prevMaxMin,u=c.prevAcceleration,f=c.prevIsBelow,m=c.prevBarIndex;const y=t.get(t.data.high,0),_=t.get(t.data.low,0),b=t.get(t.data.close,0),w=t.get(t.data.close,1),v=t.get(t.data.high,1),S=t.get(t.data.low,1),N=t.get(t.data.high,2),M=t.get(t.data.low,2);if(isNaN(y)||isNaN(_)||isNaN(b))return c.currentResult=h,c.currentMaxMin=p,c.currentAcceleration=u,c.currentIsBelow=f,c.currentBarIndex=m,NaN;let D=!1;return m===1&&(b>w?(f=!0,p=y,h=S):(f=!1,p=_,h=v),D=!0,u=a),m>=1&&(h=h+u*(p-h),f?h>_&&(D=!0,f=!1,h=Math.max(y,p),p=_,u=a):h<y&&(D=!0,f=!0,h=Math.min(_,p),p=y,u=a),D||(f?y>p&&(p=y,u=Math.min(u+s,o)):_<p&&(p=_,u=Math.min(u+s,o))),f?(h=Math.min(h,S),m>1&&(h=Math.min(h,M))):(h=Math.max(h,v),m>1&&(h=Math.max(h,N)))),m++,c.currentResult=h,c.currentMaxMin=p,c.currentAcceleration=u,c.currentIsBelow=f,c.currentBarIndex=m,m<=1?NaN:t.precision(h)}}function Bh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`sma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;let h=!1;if(l.length<n&&(c>=n||t.idx>=n-1)){const y=g.from(e);for(;l.length<n;)l.push(y.get(l.length));h=!0}let p;const u=o==null||Number.isNaN(o);let f=!Number.isNaN(s.prevSum)&&!u&&!h;if(f){let y=s.prevSum+o;if(s.prevWindow.length>=n){const _=s.prevWindow[s.prevWindow.length-1];_==null||Number.isNaN(_)?f=!1:y-=_}f&&(p=y)}if(!f){p=0;let y=!1;for(const _ of l){if(_==null||Number.isNaN(_)){y=!0;break}p+=_}y&&(p=NaN)}if(s.currentWindow=l,s.currentSum=p,s.currentCallCount=c,l.length<n)return NaN;const m=p/n;return t.precision(m)}}function Fh(t){return(e,i,r=!0,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum,l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=g.from(e).get(0);if(c==null||isNaN(c))return NaN;const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const b=h.pop();p-=b}const u=l.prevCallCount+1;if(h.length<a&&(u>=a||t.idx>=a-1)){const b=g.from(e);for(;h.length<a;){const w=b.get(h.length);if(w==null||isNaN(w))break;h.push(w),p+=w}}if(l.currentWindow=h,l.currentSum=p,l.currentCallCount=u,h.length<a)return NaN;const f=p/a;let m=0;for(let b=0;b<a;b++)m+=Math.pow(h[b]-f,2);const y=s?a:a-1,_=Math.sqrt(m/y);return t.precision(_)}}function Wh(t){return(e,i,r,n,a)=>{const s=g.from(n).get(0);t.taState||(t.taState={});const o=a||`stoch_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevHighWindow=[...l.currentHighWindow],l.prevLowWindow=[...l.currentLowWindow]),l.lastIdx=t.idx);const c=g.from(e).get(0),h=g.from(i).get(0),p=g.from(r).get(0);if(isNaN(c)||isNaN(h)||isNaN(p))return l.currentHighWindow=[...l.prevHighWindow],l.currentLowWindow=[...l.prevLowWindow],NaN;const u=[...l.prevHighWindow],f=[...l.prevLowWindow];if(u.unshift(h),f.unshift(p),u.length>s&&(u.pop(),f.pop()),l.currentHighWindow=u,l.currentLowWindow=f,u.length<s)return NaN;let m=u[0],y=f[0];for(let w=1;w<s;w++)u[w]>m&&(m=u[w]),f[w]<y&&(y=f[w]);const _=m-y;if(_===0)return NaN;const b=100*(c-y)/_;return t.precision(b)}}function $h(t){return(e,i,r)=>{const n=g.from(e).get(0),a=g.from(i).get(0);t.taState||(t.taState={});const s=r||`supertrend_${n}_${a}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevTrSum:0,prevAtrValue:NaN,prevAtrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,currentTrSum:0,currentAtrValue:NaN,currentAtrCount:0,currentLowerBand:NaN,currentUpperBand:NaN,currentSuperTrend:NaN,currentDirection:NaN});const o=t.taState[s];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrSum=o.currentTrSum,o.prevAtrValue=o.currentAtrValue,o.prevAtrCount=o.currentAtrCount,o.prevLowerBand=o.currentLowerBand,o.prevUpperBand=o.currentUpperBand,o.prevSuperTrend=o.currentSuperTrend,o.prevDirection=o.currentDirection),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(h))return[[NaN,NaN]];const p=(l+c)/2,u=t.idx>0?t.get(t.data.close,1):NaN;let f;isNaN(u)?f=l-c:f=Math.max(l-c,Math.abs(l-u),Math.abs(c-u));let m=o.prevAtrCount,y=o.prevTrSum,_=o.prevAtrValue;m++,m<=a?(y+=f,m===a&&(_=y/a)):_=(_*(a-1)+f)/a;const b=_;if(o.currentAtrCount=m,o.currentTrSum=y,o.currentAtrValue=_,isNaN(b))return[[NaN,NaN]];let w=p+n*b,v=p-n*b;const S=isNaN(o.prevLowerBand)?0:o.prevLowerBand,N=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||v>S||u<S||(v=S),isNaN(o.prevUpperBand)||w<N||u>N||(w=N);let M,D;const V=o.prevSuperTrend;return m===a?M=1:V===o.prevUpperBand?M=h>w?-1:1:M=h<v?1:-1,D=M===-1?v:w,o.currentLowerBand=v,o.currentUpperBand=w,o.currentSuperTrend=D,o.currentDirection=M,[[t.precision(D),M]]}}function Uh(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const a=i||"swma";t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>4;)l.pop();if(l.length<4&&t.idx>=3){const h=g.from(e);for(;l.length<4;)l.push(h.get(l.length))}if(s.currentWindow=l,l.length<4)return NaN;let c=0;for(let h=0;h<4;h++)c+=r[h]*l[3-h];return c/=n,t.precision(c)}}function qh(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=g.from(e).get(0));const n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.close,1);if(isNaN(s))return r?t.precision(n-a):NaN;const o=Math.max(n-a,Math.abs(n-s),Math.abs(a-s));return t.precision(o)}}function zh(t){return(e,i,r,n)=>{const a=g.from(i).get(0),s=g.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevSource:NaN,prevEma1PcValue:NaN,prevEma1PcCount:0,prevEma1PcSum:0,prevEma2PcValue:NaN,prevEma2PcCount:0,prevEma2PcSum:0,prevEma1AbsValue:NaN,prevEma1AbsCount:0,prevEma1AbsSum:0,prevEma2AbsValue:NaN,prevEma2AbsCount:0,prevEma2AbsSum:0,currentSource:NaN,currentEma1PcValue:NaN,currentEma1PcCount:0,currentEma1PcSum:0,currentEma2PcValue:NaN,currentEma2PcCount:0,currentEma2PcSum:0,currentEma1AbsValue:NaN,currentEma1AbsCount:0,currentEma1AbsSum:0,currentEma2AbsValue:NaN,currentEma2AbsCount:0,currentEma2AbsSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevSource=l.currentSource,l.prevEma1PcValue=l.currentEma1PcValue,l.prevEma1PcCount=l.currentEma1PcCount,l.prevEma1PcSum=l.currentEma1PcSum,l.prevEma2PcValue=l.currentEma2PcValue,l.prevEma2PcCount=l.currentEma2PcCount,l.prevEma2PcSum=l.currentEma2PcSum,l.prevEma1AbsValue=l.currentEma1AbsValue,l.prevEma1AbsCount=l.currentEma1AbsCount,l.prevEma1AbsSum=l.currentEma1AbsSum,l.prevEma2AbsValue=l.currentEma2AbsValue,l.prevEma2AbsCount=l.currentEma2AbsCount,l.prevEma2AbsSum=l.currentEma2AbsSum),l.lastIdx=t.idx);const c=g.from(e).get(0);if(isNaN(c))return NaN;const h=isNaN(l.prevSource)?NaN:c-l.prevSource;if(l.currentSource=c,isNaN(h))return NaN;const p=Math.abs(h),u=2/(s+1),f=2/(a+1),m=2/(s+1),y=2/(a+1);let _=l.prevEma1PcCount,b=l.prevEma1PcSum,w=l.prevEma1PcValue;_++,_<=s?(b+=h,_===s&&(w=b/s)):w=h*u+w*(1-u);let v=l.prevEma1AbsCount,S=l.prevEma1AbsSum,N=l.prevEma1AbsValue;if(v++,v<=s?(S+=p,v===s&&(N=S/s)):N=p*m+N*(1-m),isNaN(w)||isNaN(N))return l.currentEma1PcCount=_,l.currentEma1PcSum=b,l.currentEma1PcValue=w,l.currentEma1AbsCount=v,l.currentEma1AbsSum=S,l.currentEma1AbsValue=N,NaN;let M=l.prevEma2PcCount,D=l.prevEma2PcSum,V=l.prevEma2PcValue;M++,M<=a?(D+=w,M===a&&(V=D/a)):V=w*f+V*(1-f);let W=l.prevEma2AbsCount,F=l.prevEma2AbsSum,P=l.prevEma2AbsValue;if(W++,W<=a?(F+=N,W===a&&(P=F/a)):P=N*y+P*(1-y),l.currentEma1PcCount=_,l.currentEma1PcSum=b,l.currentEma1PcValue=w,l.currentEma1AbsCount=v,l.currentEma1AbsSum=S,l.currentEma1AbsValue=N,l.currentEma2PcCount=M,l.currentEma2PcSum=D,l.currentEma2PcValue=V,l.currentEma2AbsCount=W,l.currentEma2AbsSum=F,l.currentEma2AbsValue=P,isNaN(V)||isNaN(P))return NaN;if(P===0)return t.precision(0);const q=V/P;return t.precision(q)}}function Kh(t){return(e,i,r,n)=>{t.taState||(t.taState={});const a=n||"valuewhen";t.taState[a]||(t.taState[a]={lastIdx:-1,prevValues:[],currentValues:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevValues=[...s.currentValues]),s.lastIdx=t.idx);const o=g.from(e).get(0),l=g.from(i).get(0),c=g.from(r).get(0),h=[...s.prevValues];if(o&&h.push(l),s.currentValues=h,isNaN(c)||c<0)return NaN;const p=h.length-1-c;if(p<0)return NaN;const u=h[p];return typeof u=="number"?t.precision(u):u}}function Hh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`variance_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const m=g.from(e);for(;l.length<n;)l.push(m.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let h=0,p=0;for(let m=0;m<n;m++)h+=l[m],p+=l[m]*l[m];const u=h/n,f=p/n-u*u;return t.precision(f)}}function Gh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"vwap";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativePV:0,prevCumulativeVolume:0,prevLastSessionDate:null,currentCumulativePV:0,currentCumulativeVolume:0,currentLastSessionDate:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const a=g.from(e).get(0),s=g.from(t.data.volume).get(0),o=g.from(t.data.openTime).get(0),l=new Date(o).toISOString().slice(0,10);let c=n.prevCumulativePV,h=n.prevCumulativeVolume,p=n.prevLastSessionDate;if(p!==l&&(c=0,h=0,p=l),c+=a*s,h+=s,n.currentCumulativePV=c,n.currentCumulativeVolume=h,n.currentLastSessionDate=p,h===0)return NaN;const u=c/h;return t.precision(u)}}function Yh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`vwma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevVolumeWindow=[...s.currentVolumeWindow]),s.lastIdx=t.idx);const o=g.from(e).get(0),l=t.get(t.data.volume,0),c=[...s.prevWindow],h=[...s.prevVolumeWindow];for(c.unshift(o),h.unshift(l);c.length>n;)c.pop(),h.pop();if(c.length<n&&t.idx>=n-1){const m=g.from(e),y=g.from(t.data.volume);for(;c.length<n;)c.push(m.get(c.length)),h.push(y.get(h.length))}if(s.currentWindow=c,s.currentVolumeWindow=h,c.length<n)return NaN;let p=0,u=0;for(let m=0;m<n;m++)p+=c[m]*h[m],u+=h[m];const f=p/u;return t.precision(f)}}function Qh(t){return e=>{t.taState||(t.taState={});const i=e||"wad";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(a)||isNaN(s))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let l=0;if(!isNaN(o)){const h=Math.max(a,o),p=Math.min(s,o),u=n-o;u>0?l=n-p:u<0&&(l=n-h)}const c=r.prevCumulativeSum+l;return r.currentCumulativeSum=c,t.precision(c)}}function Xh(t){return(e,i,r)=>{const n=g.from(i).get(0);t.taState||(t.taState={});const a=r||`wma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=g.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=g.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let h=0,p=0;for(let f=0;f<n;f++){const m=n-f;h+=l[f]*m,p+=m}const u=h/p;return t.precision(u)}}function Zh(t){return(e,i)=>{const r=g.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevHighWindow=[...a.currentHighWindow],a.prevLowWindow=[...a.currentLowWindow]),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return a.currentHighWindow=[...a.prevHighWindow],a.currentLowWindow=[...a.prevLowWindow],NaN;const c=[...a.prevHighWindow],h=[...a.prevLowWindow];if(c.unshift(s),h.unshift(o),c.length>r&&(c.pop(),h.pop()),a.currentHighWindow=c,a.currentLowWindow=h,c.length<r)return NaN;let p=c[0],u=h[0];for(let y=1;y<r;y++)c[y]>p&&(p=c[y]),h[y]<u&&(u=h[y]);const f=p-u;if(f===0)return t.precision(0);const m=(p-l)/f*-100;return t.precision(m)}}function Jh(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a)||isNaN(s))return NaN;const o=n-a;if(o===0)return t.precision(0);const l=(i-r)/o*s;return t.precision(l)}}const eu={accdist:$c,alma:Uc,atr:qc,barssince:zc,bb:Kc,bbw:Hc,cci:Gc,change:Yc,cmo:Qc,cog:Xc,correlation:Zc,cross:Jc,crossover:eh,crossunder:th,cum:ih,dev:rh,dmi:nh,ema:sh,falling:ah,highest:oh,highestbars:lh,hma:ch,iii:hh,kc:uh,kcw:ph,linreg:fh,lowest:dh,lowestbars:mh,macd:xh,median:gh,mfi:yh,mode:_h,mom:bh,nvi:vh,obv:wh,param:Eh,percentile_linear_interpolation:Sh,percentile_nearest_rank:Nh,percentrank:Ch,pivothigh:kh,pivotlow:Th,pvi:Ph,pvt:Dh,range:Rh,rising:Mh,rma:Oh,roc:Vh,rsi:Lh,sar:jh,sma:Bh,stdev:Fh,stoch:Wh,supertrend:$h,swma:Uh,tr:qh,tsi:zh,valuewhen:Kh,variance:Hh,vwap:Gh,vwma:Yh,wad:Qh,wma:Xh,wpr:Zh,wvad:Jh};class tu{constructor(e){this.context=e,Object.entries(eu).forEach(([i,r])=>{this[i]=r(e)})}accdist;alma;atr;barssince;bb;bbw;cci;change;cmo;cog;correlation;cross;crossover;crossunder;cum;dev;dmi;ema;falling;highest;highestbars;hma;iii;kc;kcw;linreg;lowest;lowestbars;macd;median;mfi;mode;mom;nvi;obv;param;percentile_linear_interpolation;percentile_nearest_rank;percentrank;pivothigh;pivotlow;pvi;pvt;range;rising;rma;roc;rsi;sar;sma;stdev;stoch;supertrend;swma;tr;tsi;valuewhen;variance;vwap;vwma;wad;wma;wpr;wvad}function Xt(t=new Date,e){const i=e??-t.getTimezoneOffset(),r=i>=0?"+":"-",n=s=>String(Math.floor(Math.abs(s))).padStart(2,"0"),a=r+n(i/60)+":"+n(i%60);return`[${t.toISOString().slice(0,-1)}${a}]`}class iu{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return g.from(e).get(i)}warning(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Xt(new Date(r),0);console.warn(`${n} ${this.logFormat(e,...i)}`)}error(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Xt(new Date(r),0);console.error(`${n} ${this.logFormat(e,...i)}`)}info(e,...i){if(this.context.isSecondaryContext)return;const r=this.context.data.openTime.data[this.context.idx],n=Xt(new Date(r),0);console.log(`${n} ${this.logFormat(e,...i)}`)}}class ru{constructor(e){this.context=e}param(e,i=0,r){return g.from(e).get(i)}tostring(e,i){if(typeof e!="number"||isNaN(e)||!i)return String(e);if(i==="mintick"){const n=this.context.pine?.syminfo?.mintick||.01,a=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(a)}if(i==="integer")return String(Math.round(e));if(i==="percent")return(e*100).toFixed(2)+"%";if(i==="price"){const n=this.context.pine?.syminfo?.mintick||.01,a=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(a)}if(i==="volume")return String(Math.round(e));const r=i.indexOf(".");if(r>=0){const n=i.substring(r+1).length;return e.toFixed(n)}return i.includes("#")||i.includes("0")?String(Math.round(e)):String(e)}tonumber(e){return Number(e)}lower(e){return String(e).toLowerCase()}upper(e){return String(e).toUpperCase()}trim(e){return String(e).trim()}repeat(e,i,r=""){return Array(i).fill(e).join(r||"")}replace_all(e,i,r){return String(e).replaceAll(i,r)}replace(e,i,r,n=0){const a=String(e),s=String(i),o=String(r),l=Math.floor(Number(n))||0;if(s==="")return a;let c=0,h=0;for(;;){const p=a.indexOf(s,c);if(p===-1)return a;if(h===l)return a.substring(0,p)+o+a.substring(p+s.length);h++,c=p+s.length}}contains(e,i){return String(e).includes(i)}endswith(e,i){return String(e).endsWith(i)}startswith(e,i){return String(e).startsWith(i)}pos(e,i){const r=String(e).indexOf(i);return r===-1?NaN:r}length(e){return String(e).length}match(e,i){return String(e).match(new RegExp(i))}split(e,i){return new R(String(e).split(i),A.string,this.context)}substring(e,i,r){return String(e).substring(i,r)}format(e,...i){return e.replace(/\{(\d+)(?:,number,([^}]+))?\}/g,(r,n,a)=>{const s=i[n];return a&&typeof s=="number"&&!isNaN(s)?this.tostring(s,a):String(s)})}}const At={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function Ji(t){if(!t||/^\d+$/.test(t))return t;if(At[t])return At[t];const e=t.toLowerCase();if(At[e])return At[e];if(t.length===1){const r=t.toUpperCase();if(["D","W","M","S"].includes(r))return r}const i=t.slice(-1).toUpperCase();if(["D","W","M","S"].includes(i)){const r=parseInt(t);if(!isNaN(r))return r+i}return t}class nu{constructor(e){this.context=e}_normalized=null;param(e,i=0,r){return g.from(e).get(i)}get normalized(){return this._normalized===null&&(this._normalized=Ji(this.context.timeframe)),this._normalized}get unit(){return this.normalized.slice(-1).toUpperCase()}get main_period(){return this.normalized}get period(){return this.normalized}get multiplier(){const e=parseInt(this.normalized);return isNaN(e)?1:e}get isdwm(){return["D","W","M"].includes(this.unit)}get isdaily(){return this.unit==="D"}get isweekly(){return this.unit==="W"}get ismonthly(){return this.unit==="M"}get isseconds(){return this.unit==="S"}get isminutes(){return/^\d+$/.test(this.normalized)}get isintraday(){return!this.isdwm}from_seconds(e){return e<60?Math.ceil(e/5)*5+"S":e<3600*24?Math.ceil(e/60):e<=3600*24*7*52?e%(3600*24*7)===0?Math.ceil(e/604800)+"W":Math.ceil(e/(3600*24))+"D":"12M"}in_seconds(e){e==null?e=this.normalized:e=Ji(e);const i=e.slice(-1).toUpperCase(),r=parseInt(e);return i==="S"?isNaN(r)?1:r:i==="D"?(isNaN(r)?1:r)*60*60*24:i==="W"?(isNaN(r)?1:r)*60*60*24*7:i==="M"?(isNaN(r)?1:r)*60*60*24*30:isNaN(r)?0:r*60}}const er=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],su=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],au=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],ou=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],lu=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],tr=["color","offset","editable","show_last","title","display","force_overlay"],cu=["price","title","color","linestyle","linewidth","editable","display"],hu=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],ir={series:"series",title:"string",color:"series",linewidth:"number",style:"string",trackprice:"boolean",histbase:"number",offset:"number",join:"bool",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},uu={series:"series",title:"string",style:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},pu={series:"series",title:"string",colorup:"color",colordown:"color",offset:"number",minheight:"number",maxheight:"number",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},fu={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},du={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",wickcolor:"color",bordercolor:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},rr={color:"color",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},mu={price:"series",title:"string",color:"color",linestyle:"string",linewidth:"number",editable:"boolean",display:"string"},xu={plot1:"object",plot2:"object",color:"color",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class gu{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=g.from(e[r]).get(0);return i}get linestyle_dashed(){return"linestyle_dashed"}get linestyle_dotted(){return"linestyle_dotted"}get linestyle_solid(){return"linestyle_solid"}get style_area(){return"style_area"}get style_areabr(){return"style_areabr"}get style_circles(){return"style_circles"}get style_columns(){return"style_columns"}get style_cross(){return"style_cross"}get style_histogram(){return"style_histogram"}get style_line(){return"style_line"}get style_linebr(){return"style_linebr"}get style_stepline(){return"style_stepline"}get style_stepline_diamond(){return"style_stepline_diamond"}get style_steplinebr(){return"style_steplinebr"}param(e,i=0,r){return g.from(e).get(i)}plotchar(...e){const i=Ie(e),r=G(e,er,ir),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);this.context.plots[l]||(this.context.plots[l]={data:[],options:{...o,style:"char"},title:a,_plotKey:l,_callsiteId:i});const c=g.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c}),this.context.plots[l]}any(...e){const i=Ie(e),r=G(e,er,ir),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,overlay:u},title:a,_plotKey:l,_callsiteId:i}}const c=g.from(n).get(0),h=o.color,p={color:"color"in s?typeof h=="string"?h:void 0:h||"#2962ff"};return"offset"in s&&(p.offset=o.offset),this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:p}),this.context.plots[l]}plotshape(...e){const i=Ie(e),r=G(e,su,uu),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const h=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,style:"shape",shape:o.style,overlay:h},title:a,_plotKey:l,_callsiteId:i}}const c=g.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:o?.location==="absolute"||c?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[l]}plotarrow(...e){const i=Ie(e),r=G(e,au,pu),{series:n,title:a,...s}=r,o=g.from(n).get(0),l=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);if(!this.context.plots[c]){const h=l.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...l,style:"shape",overlay:h},title:a,_plotKey:c,_callsiteId:i}}return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?l.colorup:l.colordown,offset:l.offset,shape:o>0?"shape_arrow_up":"shape_arrow_down",location:o>0?"BelowBar":"AboveBar",height:l.maxheight}:void 0}),this.context.plots[c]}plotbar(...e){const i=Ie(e),r=G(e,ou,fu),{open:n,high:a,low:s,close:o,title:l,...c}=r,h=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=h.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...h,style:"bar",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const u=[g.from(n).get(0),g.from(a).get(0),g.from(s).get(0),g.from(o).get(0)];this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:u,options:{color:h.color}})}plotcandle(...e){const i=Ie(e),r=G(e,lu,du),{open:n,high:a,low:s,close:o,title:l,...c}=r,h=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=h.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...h,style:"candle",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const u=[g.from(n).get(0),g.from(a).get(0),g.from(s).get(0),g.from(o).get(0)];return this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:u,options:{color:h.color,wickcolor:h.wickcolor,bordercolor:h.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=Ie(e),r=G(e,tr,rr),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const l=s.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...s,style:"background",overlay:l},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}})}barcolor(...e){const i=Ie(e),r=G(e,tr,rr),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...s,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}}),this.context.plots[o]}}class yu{constructor(e){this.context=e}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(e,i=0,r){return g.from(e).get(i)}any(...e){const i=Ie(e),r=G(e,cu,mu),{price:n,title:a,color:s,linestyle:o,linewidth:l,editable:c,display:h}=r,p=[n,{title:a,color:s,linestyle:o,linewidth:l,editable:c,display:h,style:"hline"}];return i&&p.push({__callsiteId:i}),this.context.pine.plot.any(...p)}}class _u{constructor(e){this.context=e}param(e,i=0,r){return g.from(e).get(i)}any(...e){const i=Ie(e);if(e.length>=6&&typeof e[2]=="number"){const r=e[0],n=e[1],a=e[2],s=e[3],o=e[4],l=e[5],c=e.length>6&&typeof e[6]=="string"?e[6]:void 0,h=r?._plotKey||r?.title,p=n?._plotKey||n?.title;let u=c||"fill";const f=this.context.plots[u];f&&i&&f._callsiteId!==i&&(u=i),this.context.plots[u]||(this.context.plots[u]={title:c||"Fill",plot1:h,plot2:p,data:[],options:{plot1:h,plot2:p,style:"fill",gradient:!0},_plotKey:u,_callsiteId:i}),this.context.plots[u].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{top_value:a,bottom_value:s,top_color:o,bottom_color:l}})}else{const r=G(e,hu,xu),{plot1:n,plot2:a,color:s,title:o,editable:l,show_last:c,fillgaps:h,display:p}=r;let u=o||"fill";const f=this.context.plots[u];f&&i&&f._callsiteId!==i&&(u=i);const m=g.from(s).get(0);if(!this.context.plots[u]){const y=n?._plotKey||n?.title,_=a?._plotKey||a?.title;this.context.plots[u]={title:o||"Fill",plot1:y,plot2:_,data:[],options:{plot1:y,plot2:_,color:m,editable:l,show_last:c,fillgaps:h,display:p,style:"fill"},_plotKey:u,_callsiteId:i}}this.context.plots[u].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{color:m}})}}}class bu{constructor(e){this.context=e;const i=this.context;this.point={new(r,n,a){return new ne(r,n,a??NaN)},from_index(r,n){return new ne(void 0,r,n)},from_time(r,n){return new ne(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,a=i.marketData[n]?.openTime;return new ne(a,n,r)}}}point;param(e,i=0,r){return g.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#d1d4dc"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}let vu=0;class wi{id;x;y;text;xloc;yloc;color;style;textcolor;size;textalign;tooltip;text_font_family;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",h="center",p="",u="default",f=!1){this.id=vu++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=a,this.color=s,this.style=o,this.textcolor=l,this.size=c,this.textalign=h,this.tooltip=p,this.text_font_family=u,this.force_overlay=f,this._deleted=!1,this._helper=null}set_x(e){this._helper?this._helper.set_x(this,e):this._deleted||(this.x=e)}set_y(e){this._helper?this._helper.set_y(this,e):this._deleted||(this.y=e)}set_xy(e,i){this._helper?this._helper.set_xy(this,e,i):this._deleted||(this.x=e,this.y=i)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_textcolor(e){this._helper?this._helper.set_textcolor(this,e):this._deleted||(this.textcolor=e)}set_size(e){this._helper?this._helper.set_size(this,e):this._deleted||(this.size=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_textalign(e){this._helper?this._helper.set_textalign(this,e):this._deleted||(this.textalign=e)}set_tooltip(e){this._helper?this._helper.set_tooltip(this,e):this._deleted||(this.tooltip=e)}set_xloc(e){this._helper?this._helper.set_xloc(this,e):this._deleted||(this.xloc=e)}set_yloc(e){this._helper?this._helper.set_yloc(this,e):this._deleted||(this.yloc=e)}set_point(e){this._helper&&this._helper.set_point(this,e)}set_text_font_family(e){this._deleted||(this.text_font_family=e)}get_x(){return this.x}get_y(){return this.y}get_text(){return this.text}delete(){this._deleted=!0}copy(){return new wi(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay}}}const wu=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],Eu={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"color",style:"string",textcolor:"color",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class Su{constructor(e){this.context=e}_labels=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__labels__.data=[{time:e,value:this._labels,options:{style:"label"}}]}_resolve(e){if(e==null)return e;if(e instanceof dt)return null;if(typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"){const i=e.get(0);return typeof i=="number"&&isNaN(i)?null:i}return typeof e=="function"?e():typeof e=="number"&&isNaN(e)?null:e}_createLabel(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",h="center",p="",u="default",f=!1){const m=new wi(e,i,this._resolve(r),this._resolve(n),this._resolve(a),this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c),this._resolve(h),this._resolve(p),this._resolve(u),f);return m._helper=this,m._createdAtBar=this.context.idx,this._labels.push(m),this._syncToPlot(),m}new(...e){const i=G(e,wu,Eu);let r,n,a=i.xloc;if(i.point instanceof ne){const s=i.point;s.index!==void 0?(r=s.index,a=a||"bi"):s.time!==void 0?(r=s.time,a=a||"bt"):(r=0,a=a||"bi"),n=s.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,a,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){e&&!e._deleted&&i&&(i.index!==void 0?(e.x=i.index,e.xloc="bi"):i.time!==void 0&&(e.x=i.time,e.xloc="bt"),e.y=i.price)}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._labels.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}rollbackFromBar(e){this._labels=this._labels.filter(i=>i._createdAtBar<e),this._syncToPlot()}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}let Nu=0;class Ei{id;x1;y1;x2;y2;xloc;extend;color;style;width;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,h=!1){this.id=Nu++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=a,this.extend=s,this.color=o,this.style=l,this.width=c,this.force_overlay=h,this._deleted=!1,this._helper=null}set_x1(e){this._helper?this._helper.set_x1(this,e):this._deleted||(this.x1=e)}set_y1(e){this._helper?this._helper.set_y1(this,e):this._deleted||(this.y1=e)}set_x2(e){this._helper?this._helper.set_x2(this,e):this._deleted||(this.x2=e)}set_y2(e){this._helper?this._helper.set_y2(this,e):this._deleted||(this.y2=e)}set_xy1(e,i){this._helper?this._helper.set_xy1(this,e,i):this._deleted||(this.x1=e,this.y1=i)}set_xy2(e,i){this._helper?this._helper.set_xy2(this,e,i):this._deleted||(this.x2=e,this.y2=i)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_width(e){this._helper?this._helper.set_width(this,e):this._deleted||(this.width=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.x1=e,this.x2=i,this.xloc=r)}set_first_point(e){this._helper&&this._helper.set_first_point(this,e)}set_second_point(e){this._helper&&this._helper.set_second_point(this,e)}get_x1(){return this.x1}get_y1(){return this.y1}get_x2(){return this.x2}get_y2(){return this.y2}get_price(e){return this._helper?this._helper.get_price(this,e):NaN}delete(){this._deleted=!0}copy(){return new Ei(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay}}}const Cu=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],Iu={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"color",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class ku{constructor(e){this.context=e}_lines=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__lines__.data=[{time:e,value:this._lines,options:{style:"drawing_line"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof dt?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLine(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,h=!1){const p=new Ei(e,i,r,n,a,this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c)||1,h);return p._helper=this,p._createdAtBar=this.context.idx,this._lines.push(p),this._syncToPlot(),p}new(...e){const i=G(e,Cu,Iu);let r,n,a,s,o=i.xloc;if(i.first_point instanceof ne){const l=i.first_point,c=i.second_point,h=this._resolvePoint(l);r=h.x,n=l.price,o=o||h.xloc,c instanceof ne?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=i.x1,n=i.y1,a=i.x2,s=i.y2;return this._createLine(r,n,a,s,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=i)}set_y1(e,i){e&&!e._deleted&&(e.y1=i)}set_x2(e,i){e&&!e._deleted&&(e.x2=i)}set_y2(e,i){e&&!e._deleted&&(e.y2=i)}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=i,e.y1=r)}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=i,e.y2=r)}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bi")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._lines.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}rollbackFromBar(e){this._lines=this._lines.filter(i=>i._createdAtBar<e),this._syncToPlot()}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}let Au=0;class Si{id;left;top;right;bottom;xloc;extend;border_color;border_style;border_width;bgcolor;text;text_color;text_size;text_halign;text_valign;text_wrap;text_font_family;text_formatting;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,h="#2962ff",p="",u="#000000",f="auto",m="center",y="center",_="wrap_none",b="default",w="format_none",v=!1){this.id=Au++,this.left=e,this.top=i,this.right=r,this.bottom=n,this.xloc=a,this.extend=s,this.border_color=o,this.border_style=l,this.border_width=c,this.bgcolor=h,this.text=p,this.text_color=u,this.text_size=f,this.text_halign=m,this.text_valign=y,this.text_wrap=_,this.text_font_family=b,this.text_formatting=w,this.force_overlay=v,this._deleted=!1,this._helper=null}set_left(e){this._helper?this._helper.set_left(this,e):this._deleted||(this.left=e)}set_right(e){this._helper?this._helper.set_right(this,e):this._deleted||(this.right=e)}set_top(e){this._helper?this._helper.set_top(this,e):this._deleted||(this.top=e)}set_bottom(e){this._helper?this._helper.set_bottom(this,e):this._deleted||(this.bottom=e)}set_lefttop(e,i){this._helper?this._helper.set_lefttop(this,e,i):this._deleted||(this.left=e,this.top=i)}set_rightbottom(e,i){this._helper?this._helper.set_rightbottom(this,e,i):this._deleted||(this.right=e,this.bottom=i)}set_top_left_point(e){this._helper&&this._helper.set_top_left_point(this,e)}set_bottom_right_point(e){this._helper&&this._helper.set_bottom_right_point(this,e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.left=e,this.right=i,this.xloc=r)}set_bgcolor(e){this._helper?this._helper.set_bgcolor(this,e):this._deleted||(this.bgcolor=e)}set_border_color(e){this._helper?this._helper.set_border_color(this,e):this._deleted||(this.border_color=e)}set_border_width(e){this._helper?this._helper.set_border_width(this,e):this._deleted||(this.border_width=e)}set_border_style(e){this._helper?this._helper.set_border_style(this,e):this._deleted||(this.border_style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_text_color(e){this._helper?this._helper.set_text_color(this,e):this._deleted||(this.text_color=e)}set_text_size(e){this._helper?this._helper.set_text_size(this,e):this._deleted||(this.text_size=e)}set_text_halign(e){this._helper?this._helper.set_text_halign(this,e):this._deleted||(this.text_halign=e)}set_text_valign(e){this._helper?this._helper.set_text_valign(this,e):this._deleted||(this.text_valign=e)}set_text_wrap(e){this._helper?this._helper.set_text_wrap(this,e):this._deleted||(this.text_wrap=e)}set_text_font_family(e){this._helper?this._helper.set_text_font_family(this,e):this._deleted||(this.text_font_family=e)}set_text_formatting(e){this._helper?this._helper.set_text_formatting(this,e):this._deleted||(this.text_formatting=e)}get_left(){return this.left}get_right(){return this.right}get_top(){return this.top}get_bottom(){return this.bottom}delete(){this._deleted=!0}copy(){return new Si(this.left,this.top,this.right,this.bottom,this.xloc,this.extend,this.border_color,this.border_style,this.border_width,this.bgcolor,this.text,this.text_color,this.text_size,this.text_halign,this.text_valign,this.text_wrap,this.text_font_family,this.text_formatting,this.force_overlay)}}const Tu=[["left","top","right","bottom","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"],["top_left","bottom_right","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"]],Pu={left:"number",top:"number",right:"number",bottom:"number",top_left:"point",bottom_right:"point",border_color:"color",border_width:"number",border_style:"string",extend:"string",xloc:"string",bgcolor:"color",text:"string",text_size:"string",text_color:"color",text_halign:"string",text_valign:"string",text_wrap:"string",text_font_family:"string",force_overlay:"boolean"};class Du{constructor(e){this.context=e}_boxes=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__boxes__||(this.context.plots.__boxes__={title:"__boxes__",data:[],options:{style:"drawing_box",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__boxes__.data=[{time:e,value:this._boxes,options:{style:"drawing_box"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof dt?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return typeof r=="number"&&isNaN(r)?NaN:r||i}_createBox(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,h="#2962ff",p="",u="#000000",f="auto",m="center",y="center",_="wrap_none",b="default",w="format_none",v=!1){const S=new Si(e,i,r,n,a,this._resolve(s),this._resolveColor(o,"#2962ff"),this._resolve(l)||"style_solid",this._resolve(c)??1,this._resolveColor(h,"#2962ff"),this._resolve(p)||"",this._resolveColor(u,"#000000"),this._resolve(f)||"auto",this._resolve(m)||"center",this._resolve(y)||"center",this._resolve(_)||"wrap_none",this._resolve(b)||"default",this._resolve(w)||"format_none",v);return S._helper=this,S._createdAtBar=this.context.idx,this._boxes.push(S),this._syncToPlot(),S}new(...e){const i=G(e,Tu,Pu);let r,n,a,s,o=i.xloc;if(i.top_left instanceof ne){const l=i.top_left,c=i.bottom_right,h=this._resolvePoint(l);r=h.x,n=l.price,o=o||h.xloc,c instanceof ne?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=this._resolve(i.left),n=this._resolve(i.top),a=this._resolve(i.right),s=this._resolve(i.bottom);return this._createBox(r,n,a,s,o,i.extend,i.border_color,i.border_style,i.border_width,i.bgcolor,i.text,i.text_color,i.text_size,i.text_halign,i.text_valign,i.text_wrap,i.text_font_family,void 0,i.force_overlay)}any(...e){return this.new(...e)}set_left(e,i){e&&!e._deleted&&(e.left=i)}set_right(e,i){e&&!e._deleted&&(e.right=i)}set_top(e,i){e&&!e._deleted&&(e.top=i)}set_bottom(e,i){e&&!e._deleted&&(e.bottom=i)}set_lefttop(e,i,r){e&&!e._deleted&&(e.left=i,e.top=r)}set_rightbottom(e,i,r){e&&!e._deleted&&(e.right=i,e.bottom=r)}set_top_left_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.left=r.x,e.top=i.price,e.xloc=r.xloc}}set_bottom_right_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.right=r.x,e.bottom=i.price,e.xloc=r.xloc}}set_xloc(e,i,r,n){e&&!e._deleted&&(e.left=i,e.right=r,e.xloc=n)}set_bgcolor(e,i){e&&!e._deleted&&(e.bgcolor=this._resolve(i))}set_border_color(e,i){e&&!e._deleted&&(e.border_color=this._resolve(i))}set_border_width(e,i){e&&!e._deleted&&(e.border_width=this._resolve(i)??1)}set_border_style(e,i){e&&!e._deleted&&(e.border_style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_text(e,i){e&&!e._deleted&&(e.text=this._resolve(i)||"")}set_text_color(e,i){e&&!e._deleted&&(e.text_color=this._resolve(i))}set_text_size(e,i){e&&!e._deleted&&(e.text_size=this._resolve(i))}set_text_halign(e,i){e&&!e._deleted&&(e.text_halign=this._resolve(i))}set_text_valign(e,i){e&&!e._deleted&&(e.text_valign=this._resolve(i))}set_text_wrap(e,i){e&&!e._deleted&&(e.text_wrap=this._resolve(i))}set_text_font_family(e,i){e&&!e._deleted&&(e.text_font_family=this._resolve(i))}set_text_formatting(e,i){e&&!e._deleted&&(e.text_formatting=this._resolve(i))}get_left(e){return e?e.left:NaN}get_right(e){return e?e.right:NaN}get_top(e){return e?e.top:NaN}get_bottom(e){return e?e.bottom:NaN}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._boxes.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._boxes.filter(e=>!e._deleted)}rollbackFromBar(e){this._boxes=this._boxes.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let Ru=0;class Mu{id;line1;line2;color;_deleted;_createdAtBar=-1;constructor(e,i,r){this.id=Ru++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}get_line1(){return this.line1}get_line2(){return this.line2}set_color(e){this._deleted||(typeof e=="function"&&(e=e()),e&&typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"&&(e=e.get(0)),this.color=e||"")}delete(){this._deleted=!0}}class Ou{constructor(e){this.context=e}_linefills=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__linefills__.data=[{time:e,value:this._linefills,options:{style:"linefill"}}]}_resolve(e){return e==null?e:e instanceof dt?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(e,i,r){const n=this._resolve(e),a=this._resolve(i),s=this._resolve(r)||"",o=new Mu(n,a,s);return o._createdAtBar=this.context.idx,this._linefills.push(o),this._syncToPlot(),o}any(...e){return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i)||"")}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}rollbackFromBar(e){this._linefills=this._linefills.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let Vu=0;class Lu{id;points;curved;closed;xloc;line_color;fill_color;line_style;line_width;force_overlay;_deleted;_createdAtBar=-1;constructor(e,i=!1,r=!1,n="bi",a="#2962ff",s="",o="style_solid",l=1,c=!1){this.id=Vu++,this.points=e,this.curved=i,this.closed=r,this.xloc=n,this.line_color=a,this.fill_color=s,this.line_style=o,this.line_width=l,this.force_overlay=c,this._deleted=!1}delete(){this._deleted=!0}}class ju{constructor(e){this.context=e}_polylines=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__polylines__||(this.context.plots.__polylines__={title:"__polylines__",data:[],options:{style:"drawing_polyline",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__polylines__.data=[{time:e,value:this._polylines,options:{style:"drawing_polyline"}}]}_resolve(e){return e==null?e:e instanceof dt?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return typeof r=="number"&&isNaN(r)?NaN:r||i}_extractPoints(e){let i=this._resolve(e);const r=i&&i.array?i.array:i;return Array.isArray(r)?r.filter(n=>n instanceof ne):[]}new(...e){let i,r=!1,n=!1,a="bi",s="#2962ff",o="",l="style_solid",c=1,h=!1;const p=_=>{r=_.curved??r,n=_.closed??n,a=_.xloc??a,s=_.line_color??s,o=_.fill_color??o,l=_.line_style??l,c=_.line_width??c,h=_.force_overlay??h},u=e.length>=1?e[e.length-1]:null,f=e.length>=2&&u&&typeof u=="object"&&!Array.isArray(u)&&!(u instanceof g)&&!(u instanceof ne);if(e.length===1&&u&&typeof u=="object"&&!Array.isArray(u)&&"points"in u)i=u.points,p(u);else{const _=f?e.slice(0,-1):e;i=_[0],r=_[1]??r,n=_[2]??n,a=_[3]??a,s=_[4]??s,o=_[5]??o,l=_[6]??l,c=_[7]??c,h=_[8]??h,f&&p(u)}const m=this._extractPoints(i),y=new Lu(m,this._resolve(r)??!1,this._resolve(n)??!1,this._resolve(a)||"bi",this._resolveColor(s,"#2962ff"),this._resolveColor(o,""),this._resolve(l)||"style_solid",this._resolve(c)||1,this._resolve(h)??!1);return y._createdAtBar=this.context.idx,this._polylines.push(y),this._syncToPlot(),y}any(...e){return this.new(...e)}delete(e){e&&(e._deleted=!0)}get all(){return this._polylines.filter(e=>!e._deleted)}rollbackFromBar(e){this._polylines=this._polylines.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let Bu=0;class Fu{id;position;columns;rows;bgcolor;frame_color;frame_width;border_color;border_width;force_overlay;_deleted;cells;merges;_helper;constructor(e="top_right",i=1,r=1,n="",a="",s=0,o="",l=0,c=!1){this.id=Bu++,this.position=e,this.columns=i,this.rows=r,this.bgcolor=n,this.frame_color=a,this.frame_width=s,this.border_color=o,this.border_width=l,this.force_overlay=c,this._deleted=!1,this.merges=[],this.cells=[];for(let h=0;h<r;h++){this.cells[h]=[];for(let p=0;p<i;p++)this.cells[h][p]=null}}delete(){this._deleted=!0}setCell(e,i,r){if(i<0||i>=this.rows||e<0||e>=this.columns)return;const n=this.cells[i][e];if(n&&n._merged&&n._merge_parent){const[s,o]=n._merge_parent;if(s===e&&o===i)n._merged=!1,n._merge_parent=void 0;else{this.setCell(s,o,r);return}}const a=n||this._defaultCell();Object.assign(a,r),this.cells[i][e]=a}getCell(e,i){return i<0||i>=this.rows||e<0||e>=this.columns?null:this.cells[i][e]}clearCell(e,i){i<0||i>=this.rows||e<0||e>=this.columns||(this.cells[i][e]=null)}_setHelper(e){this._helper=e}cell(...e){return this._helper.cell(this,...e)}clear(...e){return this._helper.clear(this,...e)}merge_cells(...e){return this._helper.merge_cells(this,...e)}cell_set_text(...e){return this._helper.cell_set_text(this,...e)}cell_set_bgcolor(...e){return this._helper.cell_set_bgcolor(this,...e)}cell_set_text_color(...e){return this._helper.cell_set_text_color(this,...e)}cell_set_text_size(...e){return this._helper.cell_set_text_size(this,...e)}cell_set_height(...e){return this._helper.cell_set_height(this,...e)}cell_set_width(...e){return this._helper.cell_set_width(this,...e)}cell_set_tooltip(...e){return this._helper.cell_set_tooltip(this,...e)}cell_set_text_halign(...e){return this._helper.cell_set_text_halign(this,...e)}cell_set_text_valign(...e){return this._helper.cell_set_text_valign(this,...e)}cell_set_text_font_family(...e){return this._helper.cell_set_text_font_family(this,...e)}set_position(...e){return this._helper.set_position(this,...e)}set_bgcolor(...e){return this._helper.set_bgcolor(this,...e)}set_border_color(...e){return this._helper.set_border_color(this,...e)}set_border_width(...e){return this._helper.set_border_width(this,...e)}set_frame_color(...e){return this._helper.set_frame_color(this,...e)}set_frame_width(...e){return this._helper.set_frame_width(this,...e)}_defaultCell(){return{text:"",width:0,height:0,text_color:"#000000",text_halign:"center",text_valign:"center",text_size:"normal",bgcolor:"",tooltip:"",text_font_family:"default",_merged:!1,_merge_parent:null}}}class Wu{constructor(e){this.context=e}_tables=[];param(e,i=0,r){return g.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__tables__||(this.context.plots.__tables__={title:"__tables__",data:[],options:{style:"table",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__tables__.data=[{time:e,value:this._tables,options:{style:"table"}}]}_resolve(e){return e==null?e:typeof e=="object"&&"__value"in e?e.__value:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(...e){let i="top_right",r=1,n=1,a="",s="",o=0,l="",c=0,h=!1;const p=e[e.length-1];if(p&&typeof p=="object"&&!Array.isArray(p)&&("bgcolor"in p||"frame_color"in p||"border_color"in p||"position"in p||"columns"in p||"rows"in p)){const f=p,m=e.slice(0,-1);i=m[0]??f.position??i,r=m[1]??f.columns??r,n=m[2]??f.rows??n,a=f.bgcolor??a,s=f.frame_color??s,o=f.frame_width??o,l=f.border_color??l,c=f.border_width??c,h=f.force_overlay??h}else i=e[0]??i,r=e[1]??r,n=e[2]??n,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,h=e[8]??h;const u=new Fu(this._resolve(i)||"top_right",this._resolve(r)||1,this._resolve(n)||1,this._resolve(a)||"",this._resolve(s)||"",this._resolve(o)||0,this._resolve(l)||"",this._resolve(c)||0,this._resolve(h)??!1);return u._setHelper(this),this._tables.push(u),this._syncToPlot(),u}any(...e){return this.new(...e)}cell(...e){let i,r,n,a="",s=0,o=0,l="#000000",c="center",h="center",p="normal",u="",f="",m="default";const y=e[e.length-1];if(y&&typeof y=="object"&&!Array.isArray(y)&&("text"in y||"bgcolor"in y||"text_color"in y||"text_size"in y||"text_halign"in y||"tooltip"in y||"column"in y||"row"in y||"height"in y||"width"in y||"text_valign"in y||"text_font_family"in y)){const v=y,S=e.slice(0,-1);i=S[0],r=S.length>1?S[1]:v.column??0,n=S.length>2?S[2]:v.row??0,a=S[3]??v.text??a,s=S[4]??v.width??s,o=S[5]??v.height??o,l=S[6]??v.text_color??l,c=S[7]??v.text_halign??c,h=S[8]??v.text_valign??h,p=S[9]??v.text_size??p,u=S[10]??v.bgcolor??u,f=S[11]??v.tooltip??f,m=S[12]??v.text_font_family??m}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,h=e[8]??h,p=e[9]??p,u=e[10]??u,f=e[11]??f,m=e[12]??m;const _=this._resolve(i);if(!_||_._deleted)return;const b=this._resolve(r)??0,w=this._resolve(n)??0;_.setCell(b,w,{text:this._resolveText(this._resolve(a)),width:this._resolve(s)||0,height:this._resolve(o)||0,text_color:this._resolve(l)||"#000000",text_halign:this._resolve(c)||"center",text_valign:this._resolve(h)||"center",text_size:this._resolve(p)||"normal",bgcolor:this._resolve(u)||"",tooltip:this._resolveText(this._resolve(f)),text_font_family:this._resolve(m)||"default"}),this._syncToPlot()}delete(e){e&&(e._deleted=!0)}clear(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:r),s=f.end_row??(e.length>5?e[4]:n)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??r,s=e[4]??n;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,h=this._resolve(n)??0,p=this._resolve(a)??c,u=this._resolve(s)??h;for(let f=h;f<=u;f++)for(let m=c;m<=p;m++)l.clearCell(m,f);this._syncToPlot()}merge_cells(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:0),s=f.end_row??(e.length>5?e[4]:0)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??0,s=e[4]??0;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,h=this._resolve(n)??0,p=this._resolve(a)??0,u=this._resolve(s)??0;for(let f=h;f<=u;f++)for(let m=c;m<=p;m++)f===h&&m===c||l.setCell(m,f,{_merged:!0,_merge_parent:[c,h]});l.merges.push({startCol:c,startRow:h,endCol:p,endRow:u}),this._syncToPlot()}cell_set_text(e,i,r,n){this._setCellProp(e,i,r,"text",n,!0)}cell_set_bgcolor(e,i,r,n){this._setCellProp(e,i,r,"bgcolor",n)}cell_set_text_color(e,i,r,n){this._setCellProp(e,i,r,"text_color",n)}cell_set_text_size(e,i,r,n){this._setCellProp(e,i,r,"text_size",n)}cell_set_height(e,i,r,n){this._setCellProp(e,i,r,"height",n)}cell_set_width(e,i,r,n){this._setCellProp(e,i,r,"width",n)}cell_set_tooltip(e,i,r,n){this._setCellProp(e,i,r,"tooltip",n,!0)}cell_set_text_halign(e,i,r,n){this._setCellProp(e,i,r,"text_halign",n)}cell_set_text_valign(e,i,r,n){this._setCellProp(e,i,r,"text_valign",n)}cell_set_text_font_family(e,i,r,n){this._setCellProp(e,i,r,"text_font_family",n)}set_position(e,i){const r=this._resolve(e);!r||r._deleted||(r.position=this._resolve(i)||r.position,this._syncToPlot())}set_bgcolor(e,i){const r=this._resolve(e);!r||r._deleted||(r.bgcolor=this._resolve(i)||"",this._syncToPlot())}set_border_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_color=this._resolve(i)||"",this._syncToPlot())}set_border_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_width=this._resolve(i)||0,this._syncToPlot())}set_frame_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_color=this._resolve(i)||"",this._syncToPlot())}set_frame_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_width=this._resolve(i)||0,this._syncToPlot())}get all(){return this._tables.filter(e=>!e._deleted)}_setCellProp(e,i,r,n,a,s=!1){const o=this._resolve(e);if(!o||o._deleted)return;const l=this._resolve(i)??0,c=this._resolve(r)??0,h=this._resolve(a);o.setCell(l,c,{[n]:s?this._resolveText(h):h}),this._syncToPlot()}_resolveText(e){return e==null||e!==e?"":String(e)}}class Qe{data={open:new g([]),high:new g([]),low:new g([]),close:new g([]),volume:new g([]),hl2:new g([]),hlc3:new g([]),ohlc4:new g([]),hlcc4:new g([]),bar_index:new g([])};indicator;cache={};taState={};isSecondaryContext=!1;dataVersion=0;NA=NaN;lang;length=0;_drawingHelpers=[];pine;static _deprecationWarningsShown=new Set;idx=0;params={};const={};var={};let={};lctx=new Map;result=void 0;plots={};marketData;source;tickerId;timeframe="";limit;sDate;eDate;fullContext;pineTSCode;inputs={};constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:a,sDate:s,eDate:o,fullContext:l,inputs:c}){this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=a,this.sDate=s,this.eDate=o,this.fullContext=l||this,this.inputs=c||{};const h=new Tl(this),p={Type:h.Type.bind(h),na:new dt,nz:h.nz.bind(h),indicator:h.indicator.bind(h),fixnan:h.fixnan.bind(h),alertcondition:h.alertcondition.bind(h),alert:h.alert.bind(h),error:h.error.bind(h),max_bars_back:h.max_bars_back.bind(h),timestamp:h.timestamp.bind(h),time:new Qi(this,"openTime"),time_close:new Qi(this,"closeTime"),dayofmonth:new We(this,$e.dayofmonth),dayofweek:new We(this,$e.dayofweek),hour:new We(this,$e.hour),minute:new We(this,$e.minute),month:new We(this,$e.month),second:new We(this,$e.second),weekofyear:new We(this,$e.weekofyear),year:new We(this,$e.year),bool:h.bool.bind(h),int:h.int.bind(h),float:h.float.bind(h),string:h.string.bind(h)},u=this;this.pine={input:new ic(this),ta:new tu(this),math:new Vc(this),request:new Wc(this),array:new ho(this),map:new So(this),matrix:new wl(this),syminfo:null,timeframe:new nu(this),barstate:new El(this),get bar_index(){return u.data.bar_index},get last_bar_index(){return u.data.close.length-1},get last_bar_time(){return u.data.openTime.get(u.data.openTime.length-1)},get timenow(){return new Date().getTime()},get time_tradingday(){const W=g.from(u.data.openTime).get(0);if(isNaN(W))return NaN;const F=u.pine?.syminfo?.timezone||"UTC",P=Ot(W,F);return Date.UTC(P.year,P.month-1,P.day,0,0,0)},get inputs(){return u.inputs},log:new iu(this),str:new ru(this),...p,...Ua};const f=p.dayofweek;Object.assign(f,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=f;const m=new gu(this),y=new yu(this),_=new _u(this);this.bindContextObject(m,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(m,["any","param","linestyle_dashed","linestyle_dotted","linestyle_solid","style_area","style_areabr","style_circles","style_columns","style_cross","style_histogram","style_line","style_linebr","style_stepline","style_stepline_diamond","style_steplinebr"],"plot"),this.bindContextObject(y,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(_,["any","param"],"fill");const b=new bu(this);this.pine.chart={param:b.param.bind(b),bg_color:b.bg_color.bind(b),fg_color:b.fg_color.bind(b),is_standard:b.is_standard.bind(b),is_heikinashi:b.is_heikinashi.bind(b),is_kagi:b.is_kagi.bind(b),is_linebreak:b.is_linebreak.bind(b),is_pnf:b.is_pnf.bind(b),is_range:b.is_range.bind(b),is_renko:b.is_renko.bind(b),point:b.point};const w=new Su(this);this.bindContextObject(w,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>w.all});const v=new ku(this);this.bindContextObject(v,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>v.all});const S=new Du(this);this.bindContextObject(S,["any","new","param","copy","delete","set_left","set_right","set_top","set_bottom","set_lefttop","set_rightbottom","set_top_left_point","set_bottom_right_point","set_bgcolor","set_border_color","set_border_width","set_border_style","set_extend","set_xloc","set_text","set_text_color","set_text_size","set_text_halign","set_text_valign","set_text_wrap","set_text_font_family","set_text_formatting","get_left","get_right","get_top","get_bottom"],"box"),Object.defineProperty(this.pine.box,"all",{get:()=>S.all});const N=new Ou(this);this.bindContextObject(N,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>N.all});const M=new ju(this);this.bindContextObject(M,["any","new","param","delete"],"polyline"),Object.defineProperty(this.pine.polyline,"all",{get:()=>M.all}),this._drawingHelpers=[w,v,S,N,M];const D=new Wu(this);this.bindContextObject(D,["any","new","param","cell","delete","clear","merge_cells","cell_set_text","cell_set_bgcolor","cell_set_text_color","cell_set_text_size","cell_set_height","cell_set_width","cell_set_tooltip","cell_set_text_halign","cell_set_text_valign","cell_set_text_font_family","set_position","set_bgcolor","set_border_color","set_border_width","set_frame_color","set_frame_width"],"table"),Object.defineProperty(this.pine.table,"all",{get:()=>D.all});const V=new Dl(this);this.bindContextObject(V,["any","param","new","rgb","from_gradient","r","g","b","t","aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"],"color")}rollbackDrawings(e){for(const i of this._drawingHelpers)i.rollbackFromBar(e)}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const a of i)typeof e[a]=="function"?n[a]=e[a].bind(e):n[a]=e[a]}init(e,i,r=0){let n;return i instanceof g?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof g?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new g(e)):new g([n]):new g([n])}initVar(e,i){if(e)return e;if(typeof i=="function"&&(i=i()),i instanceof ot){const n=i.__def__;for(const a in n)typeof i[a]=="function"&&(i[a]=i[a]())}let r;return i instanceof g?r=i.get(0):Array.isArray(i)?Array.isArray(i[0])?r=i[0]:r=this.precision(i[i.length-1]):r=this.precision(i),new g([r])}static PRECISION_EPSILON=10**10;precision(e,i=10){const r=i===10?Qe.PRECISION_EPSILON:10**i;return typeof e=="number"?Math.round(e*r)/r:e}param(e,i,r){return typeof e=="string"?e:e instanceof g?i?new g(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new g(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new g(this.params[r],i||0)))}get(e,i){if(e instanceof g)return e.get(i);if(Array.isArray(e)){const r=e.length-1-i;return r<0||r>=e.length?NaN:e[r]}return e}set(e,i){if(e instanceof g){e.set(0,i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}_callStack=[];pushId(e){this._callStack.push(e)}popId(){this._callStack.pop()}peekId(){return this._callStack.length>0?this._callStack[this._callStack.length-1]:""}peekCtx(){const e=this.peekId();if(!e)return this;let i=this.lctx.get(e);return i||(i={id:e,let:{},const:{},var:{}},this.lctx.set(e,i)),i}call(e,i,...r){this.pushId(i);try{return e(...r)}finally{this.popId()}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,fill:this.pine.fill,plotchar:this.pine.plotchar,plotshape:this.pine.plotshape,plotarrow:this.pine.plotarrow,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(e,i){const r=`${e}->${i}`;Qe._deprecationWarningsShown.has(r)||(Qe._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",e,i):console.warn(`\x1B[33m[WARNING] ${e} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}}class ui{source;inputs;constructor(e,i={}){this.source=e,this.inputs=i}}class Ni{constructor(e,i,r,n,a,s){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=a,this.eDate=s,this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,a,s).then(l=>{const c=l;this.data=c;const h=c.map(N=>N.open),p=c.map(N=>N.close),u=c.map(N=>N.high),f=c.map(N=>N.low),m=c.map(N=>N.volume),y=c.map(N=>(N.high+N.low+N.close)/3),_=c.map(N=>(N.high+N.low)/2),b=c.map(N=>(N.high+N.low+N.open+N.close)/4),w=c.map(N=>(N.high+N.low+N.close+N.close)/4),v=c.map(N=>N.openTime),S=c.map(N=>N.closeTime);this.open=h,this.close=p,this.high=u,this.low=f,this.volume=m,this.hl2=_,this.hlc3=y,this.ohlc4=b,this.hlcc4=w,this.openTime=v,this.closeTime=S,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(N=>{this._syminfo=N,this._ready=!0,o(!0)}).catch(N=>{console.warn("Failed to get symbol info, using default values:",N),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}data=[];open=[];high=[];low=[];close=[];volume=[];hl2=[];hlc3=[];ohlc4=[];hlcc4=[];openTime=[];closeTime=[];_readyPromise=null;_ready=!1;_debugSettings={ln:!1,debug:!1};_transpiledCode=null;get transpiledCode(){return this._transpiledCode}_isSecondaryContext=!1;markAsSecondary(){this._isSecondaryContext=!0}_syminfo;setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,a,s){return Array.isArray(e)?e:e.getMarketData(i,r,n,a,s)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(e,i,r){let n,a={};if(e instanceof ui?(n=e.source,a=e.inputs||{}):n=e,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,a,i,r,s)}else return this._runComplete(n,a,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,a=i.pageSize||this.data.length;let s,o={};e instanceof ui?(s=e.source,o=e.inputs||{}):s=e;const l={data:[],error:[]};let c=!1;const h=(f,...m)=>{l[f]&&l[f].forEach(y=>y(...m))},p=(f,m)=>{l[f]||(l[f]=[]),l[f].push(m)},u=()=>{c=!0};return(async()=>{try{const f=typeof this.eDate>"u"&&!Array.isArray(this.source)&&r,m=this._runPaginated(s,o,void 0,a,f);for await(const y of m){if(c)break;if(y===null){await new Promise(_=>setTimeout(_,n));continue}if(h("data",y),f&&!c){const _=y.marketData[y.idx];_&&_.closeTime<Date.now()||await new Promise(b=>setTimeout(b,n))}}}catch(f){h("error",f)}})(),{on:p,stop:u}}async _runComplete(e,i,r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(e,i,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(e),await this._executeIterations(n,this._transpiledCode,this.data.length-r,this.data.length),n}async*_runPaginated(e,i,r,n,a=!1){await this.ready(),r||(r=this.data.length);const s=this._initializeContext(e,i,this._isSecondaryContext);this._transpiledCode=this._transpileCode(e);let o=this.data.length-r;for(;;){const l=this.data.length-o;if(l>0){const p=Math.min(l,n),u=this._getResultLength(s.result);await this._executeIterations(s,this._transpiledCode,o,o+p),o+=p,yield this._createPageContext(s,u);continue}if(!a||Array.isArray(this.source))break;const{newCandles:c,updatedLastCandle:h}=await this._updateMarketData();if(c===0&&!h){yield null;continue}s.dataVersion++,s.length=this.data.length,this._removeLastResult(s),o=this.data.length-(c+1),s.rollbackDrawings(o),s.pine.barstate.setLive()}}_getResultLength(e){if(Array.isArray(e))return e.length;if(typeof e=="object"&&e!==null){const i=Object.keys(e);if(i.length>0&&Array.isArray(e[i[0]]))return e[i[0]].length}return 0}_createPageContext(e,i){const r=new Qe({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:e,inputs:e.inputs});if(r.pineTSCode=e.pineTSCode,r.idx=e.idx,Array.isArray(e.result))r.result=e.result.slice(i);else if(typeof e.result=="object"&&e.result!==null){r.result={};for(let n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}else r.result=e.result;return r.plots={...e.plots},r}async _updateMarketData(e){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const i=this.source,r=this.data.length-1,n=this.data[r].openTime;try{const a=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!a||a.length===0)return{newCandles:0,updatedLastCandle:!1};let s=!1,o=0;for(let l=0;l<a.length;l++){const c=a[l];c.openTime===n?(this._replaceCandle(r,c),s=!0):c.openTime>n&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:s}}catch(a){return console.error("Error updating market data:",a),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(e,i){this.data[e]=i,this.open[e]=i.open,this.close[e]=i.close,this.high[e]=i.high,this.low[e]=i.low,this.volume[e]=i.volume,this.hl2[e]=(i.high+i.low)/2,this.hlc3[e]=(i.high+i.low+i.close)/3,this.ohlc4[e]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[e]=(i.high+i.low+i.close+i.close)/4,this.openTime[e]=i.openTime,this.closeTime[e]=i.closeTime}_appendCandle(e){this.data.push(e),this.open.push(e.open),this.close.push(e.close),this.high.push(e.high),this.low.push(e.low),this.volume.push(e.volume),this.hl2.push((e.high+e.low)/2),this.hlc3.push((e.high+e.low+e.close)/3),this.ohlc4.push((e.high+e.low+e.open+e.close)/4),this.hlcc4.push((e.high+e.low+e.close+e.close)/4),this.openTime.push(e.openTime),this.closeTime.push(e.closeTime)}async updateTail(e){if(this.data.length===0||Array.isArray(this.source))return!1;const{newCandles:i,updatedLastCandle:r}=await this._updateMarketData();if(i===0&&!r)return!1;this._removeLastResult(e),e.length=this.data.length;const n=this.data.length-(i+1);return e.rollbackDrawings(n),await this._executeIterations(e,this._transpiledCode,n,this.data.length),!0}_removeLastResult(e){if(Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let n in e.result)Array.isArray(e.result[n])&&e.result[n].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop();const i=["const","var","let","params"],r=n=>{for(let a of i)if(n[a])for(let s in n[a]){const o=n[a][s];o instanceof g?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_initializeContext(e,i={},r=!1){const n=new Qe({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new g([]),n.data.open=new g([]),n.data.high=new g([]),n.data.low=new g([]),n.data.volume=new g([]),n.data.hl2=new g([]),n.data.hlc3=new g([]),n.data.ohlc4=new g([]),n.data.hlcc4=new g([]),n.data.openTime=new g([]),n.data.closeTime=new g([]),n.length=this.data.length,n}_transpileCode(e){return na.bind(this)(e,this._debugSettings)}async _executeIterations(e,i,r,n){const a=["const","var","let","params"];for(let s=r;s<n;s++){e.idx=s,e.data.close.data.push(this.close[s]),e.data.open.data.push(this.open[s]),e.data.high.data.push(this.high[s]),e.data.low.data.push(this.low[s]),e.data.volume.data.push(this.volume[s]),e.data.hl2.data.push(this.hl2[s]),e.data.hlc3.data.push(this.hlc3[s]),e.data.ohlc4.data.push(this.ohlc4[s]),e.data.hlcc4.data.push(this.hlcc4[s]),e.data.openTime.data.push(this.openTime[s]),e.data.closeTime.data.push(this.closeTime[s]),e.data.bar_index.data.push(s);const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let c in o){e.result[c]===void 0&&(e.result[c]=[]);let h;o[c]instanceof g?h=o[c].get(0):Array.isArray(o[c])?h=o[c][o[c].length-1]:h=o[c],e.result[c].push(h)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);const l=c=>{for(let h of a)if(c[h])for(let p in c[h]){const u=c[h][p];if(u instanceof g){const f=u.get(0);u.data.push(f)}else if(Array.isArray(u)){const f=u[u.length-1];u.push(f)}}};l(e),e.lctx&&e.lctx.forEach(c=>l(c))}}}const Zt="https://api.binance.com/api/v3",nr="https://api.binance.us/api/v3",Jt={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class $u{cache;cacheDuration;constructor(e=300*1e3){this.cache=new Map,this.cacheDuration=e}generateKey(e){return Object.entries(e).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(e){const i=this.generateKey(e),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(e,i){const r=this.generateKey(e);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const e=Date.now();for(const[i,r]of this.cache.entries())e-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class Uu{cacheManager;activeApiUrl=null;constructor(){this.cacheManager=new $u(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Zt}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Zt,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${nr}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=nr,this.activeApiUrl}catch{}return Zt}async getMarketDataInterval(e,i,r,n){try{const a=Jt[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];const s={"1m":60*1e3,"3m":180*1e3,"5m":300*1e3,"15m":900*1e3,"30m":1800*1e3,"1h":3600*1e3,"2h":7200*1e3,"4h":14400*1e3,"1d":1440*60*1e3,"1w":10080*60*1e3,"1M":720*60*60*1e3};let o=[],l=r;const c=n,h=s[a];if(!h)return console.error(`Duration not defined for interval: ${a}`),[];for(;l<c;){const p=Math.min(l+1e3*h,c),u=await this.getMarketData(e,i,1e3,l,p);if(u.length===0)break;o=o.concat(u),l=u[u.length-1].closeTime+1}return o}catch(a){return console.error("Error in getMarketDataInterval:",a),[]}}async getMarketDataBackwards(e,i,r,n){let a=r,s=[],o=n,l=0;const c=Math.ceil(r/1e3)+5;for(;a>0&&l<c;){l++;const h=Math.min(a,1e3),p=await this.getMarketData(e,i,h,void 0,o);if(p.length===0||(s=p.concat(s),a-=p.length,o=p[0].openTime-1,p.length<h))break}return s}async getMarketData(e,i,r,n,a){try{const s=a!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:a};if(s){const u=this.cacheManager.get(o);if(u)return u}const l=Jt[i.toUpperCase()];if(!l)return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,a)){if(n&&a){const u=await this.getMarketDataInterval(e,i,n,a),f=r?u.slice(0,r):u;return this.cacheManager.set(o,f),f}else if(r&&r>1e3){const u=await this.getMarketDataBackwards(e,i,r,a);return this.cacheManager.set(o,u),u}}let c=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${l}`;r&&(c+=`&limit=${Math.min(r,1e3)}`),n&&(c+=`&startTime=${n}`),a&&(c+=`&endTime=${a}`);const h=await fetch(c);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);const p=(await h.json()).map(u=>({openTime:parseInt(u[0]),open:parseFloat(u[1]),high:parseFloat(u[2]),low:parseFloat(u[3]),close:parseFloat(u[4]),volume:parseFloat(u[5]),closeTime:parseInt(u[6]),quoteAssetVolume:parseFloat(u[7]),numberOfTrades:parseInt(u[8]),takerBuyBaseAssetVolume:parseFloat(u[9]),takerBuyQuoteAssetVolume:parseFloat(u[10]),ignore:u[11]}));return s&&this.cacheManager.set(o,p),p}catch(s){return console.error("Error in binance.klines:",s),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const a=Jt[e.toUpperCase()],s={"1m":60*1e3,"3m":180*1e3,"5m":300*1e3,"15m":900*1e3,"30m":1800*1e3,"1h":3600*1e3,"2h":7200*1e3,"4h":14400*1e3,"1d":1440*60*1e3,"1w":10080*60*1e3,"1M":720*60*60*1e3}[a];if(s)return Math.ceil((n-r)/s)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,a="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",a="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",a="Delivery");const s=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const l=(await o.json()).symbols;if(!l||l.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?l.find(v=>v.symbol===n):l[0];if(!c)return console.error(`Symbol ${n} not found in exchange info`),null;const h=c.filters?.find(v=>v.filterType==="PRICE_FILTER"),p=c.filters?.find(v=>v.filterType==="LOT_SIZE"),u=h?parseFloat(h.tickSize):.01,f=p?parseFloat(p.minQty):0,m=Math.round(1/u),y=c.baseAsset,_=c.quoteAsset,b=a?` ${a}`:"",w=`${y} / ${_}${b}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:y,description:w,type:i,main_tickerid:`BINANCE:${e}`,current_contract:a,isin:"",basecurrency:y,currency:_,timezone:"Etc/UTC",country:"",mintick:u,pricescale:m,minmove:1,pointvalue:c.contractSize||1,mincontract:f,session:"24x7",volumetype:"base",expiration_date:c.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}configure(e){}}const qu=En.fileURLToPath(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||new URL("pinets.min.cjs",document.baseURI).href),zu=gt.dirname(qu);class Ku{dataCache=new Map;exchangeInfoCache={};dataDirectory;constructor(e){if(e)this.dataDirectory=e;else{const i=gt.resolve(zu,"../../../");this.dataDirectory=gt.join(i,"tests","compatibility","_data")}}configure({dataDirectory:e}){e&&(this.dataDirectory=e)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=gt.join(this.dataDirectory,e);if(!rt.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=rt.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.dataCache.set(i,a),a}findDataFile(e,i,r,n){if(!rt.existsSync(this.dataDirectory))return null;const a=rt.readdirSync(this.dataDirectory).filter(l=>l.endsWith(".json"));if(r&&n){const l=`${e}-${i}-${r}-${n}.json`;if(a.includes(l))return l}const s=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=a.filter(l=>s.test(l)).map(l=>{const c=l.match(s);return{file:l,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((l,c)=>c.endTime-l.endTime);if(o.length===0)return null;if(r&&n){const l=o.find(c=>c.startTime<=r&&c.endTime>=n);if(l)return l.file}return o[0].file}filterData(e,i,r,n){let a=e;return(i||r)&&(a=e.filter(s=>{const o=!i||s.openTime>=i,l=!r||s.openTime<=r;return o&&l})),a.sort((s,o)=>s.openTime-o.openTime),n&&n>0&&(a=a.slice(0,n)),a}normalizeTimeframe(e){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[e.toUpperCase()]||e.toLowerCase()}async getMarketData(e,i,r,n,a){try{const s=this.normalizeTimeframe(i),o=this.findDataFile(e,s,n,a);if(!o)return console.warn(`No mock data file found for ${e} ${s}. Searched in: ${this.dataDirectory}`),[];const l=this.loadDataFromFile(o);return this.filterData(l,n,a,r)}catch(s){return console.error("Error in MockProvider.getMarketData:",s),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=gt.join(this.dataDirectory,i);if(!rt.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=rt.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.exchangeInfoCache[e]=a,a}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const a=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!a||!a.symbols)return console.error(`Exchange info not available for ${i}`),null;const s=a.symbols.find(_=>_.symbol===r);if(!s)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=s.filters?.find(_=>_.filterType==="PRICE_FILTER"),l=s.filters?.find(_=>_.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,h=l?parseFloat(l.minQty):0,p=Math.round(1/c),u=s.baseAsset,f=s.quoteAsset,m=n?` ${n}`:"",y=`${u} / ${f}${m}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:u,description:y,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:u,currency:f,timezone:"Etc/UTC",country:"",mintick:c,pricescale:p,minmove:1,pointvalue:s.contractSize||1,mincontract:h,session:"24x7",volumetype:"base",expiration_date:s.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in MockProvider.getSymbolInfo:",i),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(e){this.dataDirectory=e,this.clearCache()}}const Hu=typeof process<"u"&&process.versions&&process.versions.node;let Lt=null;if(Hu)try{Lt=new Ku}catch{Lt=null}const Gu={Binance:new Uu,...Lt?{Mock:Lt}:{}};exports.Context=Qe;exports.Indicator=ui;exports.PineTS=Ni;exports.Provider=Gu;
|
|
135
|
+
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateSequenceExpression(e){this.write("(");for(let i=0;i<e.expressions.length;i++)this.generateExpression(e.expressions[i]),i<e.expressions.length-1&&this.write(", ");this.write(")")}getPrecedence(e){switch(e.type){case"Literal":case"Identifier":case"ArrayExpression":case"ObjectExpression":return 20;case"CallExpression":case"MemberExpression":return 19;case"UnaryExpression":case"UpdateExpression":return 15;case"BinaryExpression":case"LogicalExpression":switch(e.operator){case"*":case"/":case"%":return 13;case"+":case"-":return 12;case"<":case"<=":case">":case">=":return 10;case"==":case"!=":return 9;case"and":case"&&":return 5;case"or":case"||":return 4;default:return 0}case"ConditionalExpression":return 3;case"AssignmentExpression":case"AssignmentPattern":return 2;case"SequenceExpression":return 1;default:return 0}}}function mn(t){const e=/^\s*\/\/\s*@version\s*=\s*(\d+)\s*$/im,i=t.match(e);return i&&i[1]?parseInt(i[1],10):null}function Ea(t,e={}){const i=mn(t);if(i===null)return{success:!1,version:null,error:"Pine Script version not found. Please add //@version=X comment to your script."};if(i<5)return{success:!1,version:i,error:`Pine Script version ${i} is not supported. Only version 5 and above are supported.`};try{const r=new pa(t).tokenize(),n=new wa(r).parse(),a={...e,sourceCode:t},s=new Sa(a).generate(n);return{success:!0,version:i,code:s,ast:n,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}function Na(t){if(typeof t=="function")return t.toString();{const e=mn(t);if(e===null)return t;if(e>=5){const i=Ea(t);if(i.success)return i.code;throw new Error(`Failed to transpile Pine Script version ${e}: ${i.error}`)}else throw new Error(`Unsupported Pine Script version ${e}. Only version 5 and above are supported.`)}}function Ca(t,e={debug:!1,ln:!1}){typeof e=="boolean"&&(e={debug:e,ln:!0});const{debug:i}=e;let r=Na(t);r=Ys(r);const n=i?r.split(`
|
|
136
|
+
`):[],a=on(r,{ecmaVersion:"latest",sourceType:"module",locations:i});Xs(a),Ks(a),zs(a);const s=new js;Qs(a,s);const o=Js(a,s)||"";if(la(a,s,o,e,n),oa(a),aa(a),a.type==="Program"&&a.body.length>0){const p=a.body[0],u=p?.expression||p;u.body?.type==="BlockStatement"&&u.body.body.unshift({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"__maxLoops"},init:{type:"LogicalExpression",operator:"||",left:{type:"MemberExpression",object:{type:"Identifier",name:"$"},property:{type:"Identifier",name:"__maxLoops"},computed:!1},right:{type:"Literal",value:5e5}}}]})}const l=Os||Ii||void 0,c=Object.assign({},l,{LineComment(p,u){u.write("//"+p.value)}}),h=cn(a,{generator:c,comments:i});return new Function("",`var _r = ${h}
|
|
137
|
+
; return _r;`)(this)}function Ia(t){return e=>new R(e.array.map(i=>Math.abs(i)),e.type,t)}function ka(t){return e=>{let i=0,r=0;for(const n of e.array){const a=Number(n);isNaN(a)||(r++,i+=(a-i)/r)}return r===0?NaN:t.precision(i)}}function Aa(t){return(e,i)=>{const r=e.array;let n=0,a=r.length-1;for(;n<=a;){const s=Math.floor((n+a)/2),o=r[s];if(o===i)return s;o<i?n=s+1:a=s-1}return-1}}function Ta(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<i?n=s+1:a=s}return n<r.length&&r[n]===i?n:n-1}}function Pa(t){return(e,i)=>{const r=e.array;let n=0,a=r.length;for(;n<a;){const s=Math.floor((n+a)/2);r[s]<=i?n=s+1:a=s}return n>0&&r[n-1]===i?n-1:n}}function Da(t){return e=>{e.array.length=0}}function Ma(t){return(e,i)=>(e.array.push(...i.array),e)}function Ra(t){return e=>new R([...e.array],e.type,t)}function Oa(t){return(e,i,r=!0)=>{const n=e.array,a=i.array;if(n.length!==a.length)return NaN;let s=0,o=0,l=0;const c=[];for(let m=0;m<n.length;m++){const x=Number(n[m]),_=Number(a[m]);!isNaN(x)&&x!==null&&x!==void 0&&!isNaN(_)&&_!==null&&_!==void 0&&(s+=x,o+=_,l++,c.push(m))}if(l===0)return NaN;const h=s/l,p=o/l;let u=0;for(const m of c){const x=Number(n[m]),_=Number(a[m]);u+=(x-h)*(_-p)}const f=r?l:l-1;return f<=0?NaN:t.precision(u/f)}}function Va(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function La(t){return t.every(e=>typeof e=="number")?t.every(e=>Number.isInteger(e))?T.int:T.float:t.every(e=>typeof e=="string")?T.string:t.every(e=>typeof e=="boolean")?T.bool:T.any}function Pe(t){return typeof t=="number"?Number.isInteger(t)?T.int:T.float:typeof t=="string"?T.string:typeof t=="boolean"?T.bool:T.any}function At(t,e){if(typeof t=="number"&&isNaN(t)||e===T.any)return!0;switch(e){case T.int:return Number.isInteger(t)||isNaN(t);case T.float:return typeof t=="number";case T.string:return typeof t=="string";case T.bool:return typeof t=="boolean";case T.box:case T.label:case T.line:case T.linefill:case T.table:case T.color:return t===null||typeof t=="object"||typeof t=="string"}return!1}function Ba(t){return(e,i,r=0,n)=>{const a=e.array.length,s=n!==void 0?Math.min(n,a):a;for(let o=r;o<s;o++){if(!At(i,e.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array[o]=typeof i=="number"?t.precision(i):i}}}function ja(t){return e=>e.array.length>0?e.array[0]:t.NA}class Ce extends Error{method;constructor(e,i){super(e),this.name="PineRuntimeError",this.method=i}}function Fa(t){return(e,i)=>{if(i<0&&(i=e.array.length+i),i<0||i>=e.array.length)throw new Ce(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.get");return e.array[i]}}function $a(t){return(e,i)=>e.array.includes(i)}function Wa(t){return(e,i)=>typeof i=="number"&&i!==i?e.array.findIndex(r=>typeof r=="number"&&r!==r):e.array.indexOf(i)}function Ua(t){return(e,i,r)=>{if(!At(r,e.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>e.array.length)throw new Ce(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.insert");e.array.splice(i,0,r)}}function qa(t){return(e,i=",")=>e.array.join(i)}function za(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function Ka(t){return(e,i)=>e.array.lastIndexOf(i)}function Ha(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let a=1;a<r.length;a++)r[a]>n&&(n=r[a]);return n??t.NA}return[...r].sort((n,a)=>a-n)[i]??t.NA}}function Ga(t){return e=>{const i=e.array;if(i.length===0)return NaN;const r=new Array(i.length);for(let a=0;a<i.length;a++)r[a]=i[a];r.sort((a,s)=>a-s);const n=Math.floor(r.length/2);return r.length%2!==0?r[n]:(r[n-1]+r[n])/2}}function Ya(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let a=1;a<r.length;a++)r[a]<n&&(n=r[a]);return n??t.NA}return[...r].sort((n,a)=>n-a)[i]??t.NA}}function Xa(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const a of e.array){const s=(i.get(a)||0)+1;i.set(a,s),s>r&&(r=s)}const n=[];for(const[a,s]of i)s===r&&n.push(a);return n.sort((a,s)=>typeof a=="number"&&typeof s=="number"?a-s:typeof a=="string"&&typeof s=="string"?a<s?-1:a>s?1:0:0),n[0]}}function Qa(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const a=new Array(n);for(let c=0;c<n;c++){const h=Number(r[c]);if(isNaN(h)||h===null||h===void 0)return NaN;a[c]=h}a.sort((c,h)=>c-h),i<0&&(i=0),i>100&&(i=100);const s=i/100*n-.5;if(s<=0)return t.precision(a[0]);if(s>=n-1)return t.precision(a[n-1]);const o=Math.floor(s),l=s-o;return t.precision(a[o]*(1-l)+a[o+1]*l)}}function Za(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const a=new Array;for(let o=0;o<n;o++){const l=Number(r[o]);!isNaN(l)&&l!==null&&l!==void 0&&a.push(l)}if(a.length===0)return NaN;a.sort((o,l)=>o-l),i<0&&(i=0),i>100&&(i=100);const s=Math.ceil(i/100*n);return s<=0?a[0]:s>a.length?NaN:a[s-1]}}function Ja(t){return(e,i)=>{if(e.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=e.array.length)return NaN;const n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let a=0;for(const o of e.array){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&l<n&&a++}const s=e.array.length-1;return s<=0?NaN:a/s*100}}function eo(t){return e=>e.array.pop()}function to(t){return(e,i)=>{if(!At(i,e.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.push(typeof i=="number"?t.precision(i):i)}}function io(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function ro(t){return(e,i)=>{if(i<0&&(i=e.array.length+i),i<0||i>=e.array.length)throw new Ce(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.remove");return e.array.splice(i,1)[0]}}function no(t){return e=>{e.array.reverse()}}function so(t){return(e,i,r)=>{if(!At(r,e.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>=e.array.length)throw new Ce(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.set");e.array[i]=typeof r=="number"?t.precision(r):r}}function ao(t){return e=>e.array.shift()}function oo(t){return e=>e.array.length}function lo(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new R(e.array.slice(i,n),e.type,t)}}function co(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var pt=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(pt||{}),gn=(t=>(t.AED="AED",t.ARS="ARS",t.AUD="AUD",t.BDT="BDT",t.BHD="BHD",t.BRL="BRL",t.BTC="BTC",t.CAD="CAD",t.CHF="CHF",t.CLP="CLP",t.CNY="CNY",t.COP="COP",t.CZK="CZK",t.DKK="DKK",t.EGP="EGP",t.ETH="ETH",t.EUR="EUR",t.GBP="GBP",t.HKD="HKD",t.HUF="HUF",t.IDR="IDR",t.ILS="ILS",t.INR="INR",t.ISK="ISK",t.JPY="JPY",t.KES="KES",t.KRW="KRW",t.KWD="KWD",t.LKR="LKR",t.MAD="MAD",t.MXN="MXN",t.MYR="MYR",t.NGN="NGN",t.NOK="NOK",t.NONE="NONE",t.NZD="NZD",t.PEN="PEN",t.PHP="PHP",t.PKR="PKR",t.PLN="PLN",t.QAR="QAR",t.RON="RON",t.RSD="RSD",t.RUB="RUB",t.SAR="SAR",t.SEK="SEK",t.SGD="SGD",t.THB="THB",t.TND="TND",t.TRY="TRY",t.TWD="TWD",t.USD="USD",t.USDT="USDT",t.VES="VES",t.VND="VND",t.ZAR="ZAR",t))(gn||{}),yn=(t=>(t[t.sunday=1]="sunday",t[t.monday=2]="monday",t[t.tuesday=3]="tuesday",t[t.wednesday=4]="wednesday",t[t.thursday=5]="thursday",t[t.friday=6]="friday",t[t.saturday=7]="saturday",t))(yn||{}),xn=(t=>(t.all="all",t.data_window="data_window",t.none="none",t.pane="pane",t.price_scale="price_scale",t.status_line="status_line",t))(xn||{}),_n=(t=>(t.flag="shape_flag",t.arrowdown="shape_arrow_down",t.arrowup="shape_arrow_up",t.circle="shape_circle",t.cross="shape_cross",t.diamond="shape_diamond",t.labeldown="shape_label_down",t.labelup="shape_label_up",t.square="shape_square",t.triangledown="shape_triangle_down",t.triangleup="shape_triangle_up",t.xcross="shape_xcross",t))(_n||{}),bn=(t=>(t.abovebar="AboveBar",t.belowbar="BelowBar",t.absolute="Absolute",t.bottom="Bottom",t.top="Top",t))(bn||{}),wn=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(wn||{}),vn=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(vn||{}),ho=(t=>(t.linestyle_dashed="linestyle_dashed",t.linestyle_dotted="linestyle_dotted",t.linestyle_solid="linestyle_solid",t.style_area="style_area",t.style_areabr="style_areabr",t.style_circles="style_circles",t.style_columns="style_columns",t.style_cross="style_cross",t.style_histogram="style_histogram",t.style_line="style_line",t.style_linebr="style_linebr",t.style_stepline="style_stepline",t.style_stepline_diamond="style_stepline_diamond",t.style_steplinebr="style_steplinebr",t))(ho||{}),Sn=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(Sn||{}),En=(t=>(t.bar_index="bi",t.bar_time="bt",t))(En||{}),Nn=(t=>(t.price="pr",t.abovebar="ab",t.belowbar="bl",t))(Nn||{}),Cn=(t=>(t.left="l",t.right="r",t.both="b",t.none="n",t))(Cn||{}),In=(t=>(t.align_bottom="bottom",t.align_top="top",t.align_left="left",t.align_center="center",t.align_right="right",t.wrap_auto="auto",t.wrap_none="none",t.format_bold="bold",t.format_italic="italic",t.format_none="none",t))(In||{}),kn=(t=>(t.family_default="default",t.family_monospace="monospace",t))(kn||{}),An=(t=>(t.none="none",t.splits="splits",t.dividends="dividends",t))(An||{}),Tn=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(Tn||{}),Pn=(t=>(t.actual="earnings_actual",t.estimate="earnings_estimate",t.standardized="earnings_standardized",t.future_eps="earnings_future_eps",t.future_period_end_time="earnings_future_period_end_time",t.future_revenue="earnings_future_revenue",t.future_time="earnings_future_time",t))(Pn||{}),Dn=(t=>(t.gross="dividends_gross",t.net="dividends_net",t.future_amount="dividends_future_amount",t.future_ex_date="dividends_future_ex_date",t.future_pay_date="dividends_future_pay_date",t))(Dn||{}),Mn=(t=>(t.denominator="splits_denominator",t.numerator="splits_numerator",t))(Mn||{}),Rn=(t=>(t.top_left="top_left",t.top_center="top_center",t.top_right="top_right",t.middle_left="middle_left",t.middle_center="middle_center",t.middle_right="middle_right",t.bottom_left="bottom_left",t.bottom_center="bottom_center",t.bottom_right="bottom_right",t))(Rn||{}),On=(t=>(t.left="left",t.none="none",t.right="right",t))(On||{}),Vn=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(Vn||{});const uo={order:pt,currency:gn,dayofweek:yn,display:xn,shape:_n,location:bn,size:wn,format:vn,barmerge:Sn,xloc:En,yloc:Nn,extend:Cn,text:In,font:kn,adjustment:An,backadjustment:Tn,earnings:Pn,dividends:Dn,splits:Mn,position:Rn,scale:On,settlement_as_close:Vn};function po(t){return(e,i=pt.ascending)=>{e.array.sort((r,n)=>{let a=isNaN(r)?1/0:r,s=isNaN(n)?1/0:n;return i===pt.ascending?a-s:s-a})}}function fo(t){return(e,i=pt.ascending)=>{const r=e.array.map((n,a)=>a);return r.sort((n,a)=>{const s=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[a])?1/0:e.array[a];return i===pt.ascending?s-o:o-s}),new R(r,T.int,t)}}function mo(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new R(e.array.map(()=>NaN),T.int,t):r===0?new R(e.array.map(()=>1),T.int,t):new R(e.array.map(n=>(n-i)/r),T.int,t)}}function go(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let a=0,s=0,o=0;for(let h=0;h<n;h++){const p=Number(r[h]);!isNaN(p)&&p!==null&&p!==void 0&&(a+=p,s+=p*p,o++)}if(o===0)return NaN;const l=a/o;let c=s/o-l*l;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function yo(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function xo(t){return(e,i)=>{if(!At(i,e.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.unshift(typeof i=="number"?t.precision(i):i)}}function _o(t){return(e,i=!0)=>{let r=0,n=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,n++)}if(n===0)return NaN;const a=r/n;let s=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(s+=(c-a)*(c-a))}const o=i?n:n-1;return o<=0?NaN:t.precision(s/o)}}var T=(t=>(t.any="",t.box="box",t.bool="bool",t.color="color",t.float="float",t.int="int",t.label="label",t.line="line",t.linefill="linefill",t.string="string",t.table="table",t))(T||{});class R{constructor(e,i,r){this.array=e,this.type=i,this.context=r,this._abs=Ia(this.context),this._avg=ka(this.context),this._binary_search=Aa(this.context),this._binary_search_leftmost=Ta(this.context),this._binary_search_rightmost=Pa(this.context),this._clear=Da(this.context),this._concat=Ma(this.context),this._copy=Ra(this.context),this._covariance=Oa(this.context),this._every=Va(this.context),this._fill=Ba(this.context),this._first=ja(this.context),this._get=Fa(this.context),this._includes=$a(this.context),this._indexof=Wa(this.context),this._insert=Ua(this.context),this._join=qa(this.context),this._last=za(this.context),this._lastindexof=Ka(this.context),this._max=Ha(this.context),this._median=Ga(this.context),this._min=Ya(this.context),this._mode=Xa(this.context),this._percentile_linear_interpolation=Qa(this.context),this._percentile_nearest_rank=Za(this.context),this._percentrank=Ja(this.context),this._pop=eo(this.context),this._push=to(this.context),this._range=io(this.context),this._remove=ro(this.context),this._reverse=no(this.context),this._set=so(this.context),this._shift=ao(this.context),this._size=oo(this.context),this._slice=lo(this.context),this._some=co(this.context),this._sort=po(this.context),this._sort_indices=fo(this.context),this._standardize=mo(this.context),this._stdev=go(this.context),this._sum=yo(this.context),this._unshift=xo(this.context),this._variance=_o(this.context)}_abs;_avg;_binary_search;_binary_search_leftmost;_binary_search_rightmost;_clear;_concat;_copy;_covariance;_every;_fill;_first;_get;_includes;_indexof;_insert;_join;_last;_lastindexof;_max;_median;_min;_mode;_percentile_linear_interpolation;_percentile_nearest_rank;_percentrank;_pop;_push;_range;_remove;_reverse;_set;_shift;_size;_slice;_some;_sort;_sort_indices;_standardize;_stdev;_sum;_unshift;_variance;toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}[Symbol.iterator](){return this.array[Symbol.iterator]()}abs(...e){return this._abs(this,...e)}avg(...e){return this._avg(this,...e)}binary_search(...e){return this._binary_search(this,...e)}binary_search_leftmost(...e){return this._binary_search_leftmost(this,...e)}binary_search_rightmost(...e){return this._binary_search_rightmost(this,...e)}clear(...e){return this._clear(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}covariance(...e){return this._covariance(this,...e)}every(...e){return this._every(this,...e)}fill(...e){return this._fill(this,...e)}first(...e){return this._first(this,...e)}get(...e){return this._get(this,...e)}includes(...e){return this._includes(this,...e)}indexof(...e){return this._indexof(this,...e)}insert(...e){return this._insert(this,...e)}join(...e){return this._join(this,...e)}last(...e){return this._last(this,...e)}lastindexof(...e){return this._lastindexof(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}percentile_linear_interpolation(...e){return this._percentile_linear_interpolation(this,...e)}percentile_nearest_rank(...e){return this._percentile_nearest_rank(this,...e)}percentrank(...e){return this._percentrank(this,...e)}pop(...e){return this._pop(this,...e)}push(...e){return this._push(this,...e)}range(...e){return this._range(this,...e)}remove(...e){return this._remove(this,...e)}reverse(...e){return this._reverse(this,...e)}set(...e){return this._set(this,...e)}shift(...e){return this._shift(this,...e)}size(...e){return this._size(this,...e)}slice(...e){return this._slice(this,...e)}some(...e){return this._some(this,...e)}sort(...e){return this._sort(this,...e)}sort_indices(...e){return this._sort_indices(this,...e)}standardize(...e){return this._standardize(this,...e)}stdev(...e){return this._stdev(this,...e)}sum(...e){return this._sum(this,...e)}unshift(...e){return this._unshift(this,...e)}variance(...e){return this._variance(this,...e)}}function bo(t){return(...e)=>new R([...e],La(e),t)}function wo(t){return(e,i)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;if(i===void 0){const n=r?Array(r).fill(0):[];return new R(n,T.any,t)}return new R(Array(r).fill(t.precision(i||0)),Pe(i||0),t)}}function vo(t){return(e=0,i=!1)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.bool,t)}}function So(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.box,t)}}function Eo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.color,t)}}function No(t){return(e=0,i=NaN)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(t.precision(i)),T.float,t)}}function Co(t){return(e=0,i=0)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(t.precision(i)),T.int,t)}}function Io(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.label,t)}}function ko(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.line,t)}}function Ao(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.linefill,t)}}function To(t){return(e=0,i="")=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.string,t)}}function Po(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new R(Array(r).fill(i),T.table,t)}}class y{constructor(e,i=0){this.data=e,this.offset=i}get(e){const i=this.data.length-1-(this.offset+e);return i<0||i>=this.data.length?NaN:this.data[i]}set(e,i){const r=this.data.length-1-(this.offset+e);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(e){return e instanceof y?e:Array.isArray(e)?new y(e):e!=null&&typeof e=="object"&&"__value"in e&&e.__value instanceof y?e.__value:new y([e])}}function Do(t){return(e,i=0)=>y.from(e).get(i)}class Mo{constructor(e){this.context=e,this.abs=(i,...r)=>i.abs(...r),this.avg=(i,...r)=>i.avg(...r),this.binary_search=(i,...r)=>i.binary_search(...r),this.binary_search_leftmost=(i,...r)=>i.binary_search_leftmost(...r),this.binary_search_rightmost=(i,...r)=>i.binary_search_rightmost(...r),this.clear=(i,...r)=>i.clear(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.covariance=(i,...r)=>i.covariance(...r),this.every=(i,...r)=>i.every(...r),this.fill=(i,...r)=>i.fill(...r),this.first=(i,...r)=>i.first(...r),this.from=bo(e),this.get=(i,...r)=>i.get(...r),this.includes=(i,...r)=>i.includes(...r),this.indexof=(i,...r)=>i.indexof(...r),this.insert=(i,...r)=>i.insert(...r),this.join=(i,...r)=>i.join(...r),this.last=(i,...r)=>i.last(...r),this.lastindexof=(i,...r)=>i.lastindexof(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.new=wo(e),this.new_bool=vo(e),this.new_box=So(e),this.new_color=Eo(e),this.new_float=No(e),this.new_int=Co(e),this.new_label=Io(e),this.new_line=ko(e),this.new_linefill=Ao(e),this.new_string=To(e),this.new_table=Po(e),this.param=Do(),this.percentile_linear_interpolation=(i,...r)=>i.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(i,...r)=>i.percentile_nearest_rank(...r),this.percentrank=(i,...r)=>i.percentrank(...r),this.pop=(i,...r)=>i.pop(...r),this.push=(i,...r)=>i.push(...r),this.range=(i,...r)=>i.range(...r),this.remove=(i,...r)=>i.remove(...r),this.reverse=(i,...r)=>i.reverse(...r),this.set=(i,...r)=>i.set(...r),this.shift=(i,...r)=>i.shift(...r),this.size=(i,...r)=>i.size(...r),this.slice=(i,...r)=>i.slice(...r),this.some=(i,...r)=>i.some(...r),this.sort=(i,...r)=>i.sort(...r),this.sort_indices=(i,...r)=>i.sort_indices(...r),this.standardize=(i,...r)=>i.standardize(...r),this.stdev=(i,...r)=>i.stdev(...r),this.sum=(i,...r)=>i.sum(...r),this.unshift=(i,...r)=>i.unshift(...r),this.variance=(i,...r)=>i.variance(...r)}}function Ro(t){return e=>{e.map.clear()}}function Oo(t){return(e,i)=>e.map.has(i)}function Vo(t){return e=>{const i=new Ln(t);return i.map=new Map(e.map),i}}function Lo(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function Bo(t){return e=>{const i=Array.from(e.map.keys()),r=Pe(i[0]);return new R(i,r,t)}}function jo(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function Fo(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function $o(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function Wo(t){return e=>e.map.size}function Uo(t){return e=>{const i=Array.from(e.map.values()),r=Pe(i[0]);return new R(i,r,t)}}class Ln{constructor(e){this.context=e,this.map=new Map,this._clear=Ro(this.context),this._contains=Oo(this.context),this._copy=Vo(this.context),this._get=Lo(this.context),this._keys=Bo(this.context),this._put=jo(this.context),this._put_all=Fo(this.context),this._remove=$o(this.context),this._size=Wo(this.context),this._values=Uo(this.context)}map;_clear;_contains;_copy;_get;_keys;_put;_put_all;_remove;_size;_values;toString(){return`PineMapObject(${this.map.size})`}clear(...e){return this._clear(this,...e)}contains(...e){return this._contains(this,...e)}copy(...e){return this._copy(this,...e)}get(...e){return this._get(this,...e)}keys(...e){return this._keys(this,...e)}put(...e){return this._put(this,...e)}put_all(...e){return this._put_all(this,...e)}remove(...e){return this._remove(this,...e)}size(...e){return this._size(this,...e)}values(...e){return this._values(this,...e)}}function qo(t){return()=>new Ln(t)}function zo(t){return(e,i=0)=>y.from(e).get(i)}class Ko{constructor(e){this.context=e,this.clear=(i,...r)=>i.clear(...r),this.contains=(i,...r)=>i.contains(...r),this.copy=(i,...r)=>i.copy(...r),this.get=(i,...r)=>i.get(...r),this.keys=(i,...r)=>i.keys(...r),this.new=qo(e),this.param=zo(),this.put=(i,...r)=>i.put(...r),this.put_all=(i,...r)=>i.put_all(...r),this.remove=(i,...r)=>i.remove(...r),this.size=(i,...r)=>i.size(...r),this.values=(i,...r)=>i.values(...r)}}function Ho(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r&&(r instanceof R?a=r.array:Array.isArray(r)?a=r:a=[r]),n===0){for(let l=0;l<a.length;l++){let c=a[l];c instanceof y&&(c=c.get(0)),e.matrix.push([c])}return}const s=e.matrix[0].length,o=i!==void 0?i:s;for(let l=0;l<n;l++){let c=l<a.length?a[l]:NaN;c instanceof y&&(c=c.get(0)),e.matrix[l].splice(o,0,c)}}}function Go(t){return(e,i,r)=>{const n=e.matrix.length;let a=[];if(r)if(r instanceof R)a=r.array;else if(Array.isArray(r))a=r;else if(r instanceof y){const c=r.get(0);Array.isArray(c)?a=c:a=[c]}else a=[r];const s=n>0?e.matrix[0].length:a.length,o=i!==void 0?i:n,l=[];for(let c=0;c<s;c++)if(c<a.length){let h=a[c];h instanceof y&&(h=h.get(0)),l.push(h)}else l.push(NaN);e.matrix.splice(o,0,l)}}function Yo(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;if(r===0)return NaN;let n=0,a=0;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(n+=l,a++)}return a===0?NaN:n/a}}function Xo(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i<0||i>=n)throw new Ce(`Column index ${i} is out of bounds, matrix has ${n} columns.`,"matrix.col");const a=[];for(let o=0;o<r;o++)a.push(e.matrix[o][i]);const s=Pe(a[0]);return new R(a,s,t)}}function Qo(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function Zo(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const a=e.matrix[0].length,s=n>0?i.matrix[0].length:0;if(a!==s&&n>0){console.error(`matrix.concat: Column count mismatch ${a} vs ${s}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function Jo(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new j(i,r,NaN,t);return n.matrix=e.matrix.map(a=>[...a]),n}}function el(t){const e=t.length;if(e===0)return 0;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];const i=t.map(n=>[...n]);let r=1;for(let n=0;n<e;n++){let a=n;for(;a<e&&i[a][n]===0;)a++;if(a===e)return 0;a!==n&&([i[n],i[a]]=[i[a],i[n]],r*=-1),r*=i[n][n];for(let s=n+1;s<e;s++){const o=i[s][n]/i[n][n];for(let l=n;l<e;l++)i[s][l]-=o*i[n][l]}}return r}function tl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:el(e.matrix)}}function il(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new j(0,0,NaN,t);const n=e.matrix[0].length,a=new j(r,n,NaN,t);if(i instanceof j)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l-c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]-s}return a}}function rl(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],a=t[1][1],s=i+a,o=i*a-r*n,l=s*s-4*o;if(l<0)return[NaN,NaN];const c=(s+Math.sqrt(l))/2,h=(s-Math.sqrt(l))/2;return[c,h]}function nl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const s=Pe(e.matrix[0][0]);return new R([],s,t)}const n=rl(e.matrix),a=Pe(n[0]);return new R(n,a,t)}}function sl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new j(0,0,NaN,t);const n=new j(i,r,0,t);for(let a=0;a<i;a++)n.matrix[a][a]=1;return n}}function al(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function ol(t){return(e,i,r,n,a,s)=>{const o=e.matrix.length;if(o===0)return;const l=e.matrix[0].length,c=r!==void 0?r:0,h=n!==void 0?n:o,p=a!==void 0?a:0,u=s!==void 0?s:l;for(let f=c;f<h&&!(f>=o);f++)for(let m=p;m<u&&!(m>=l);m++)e.matrix[f][m]=i}}function ll(t){return(e,i,r)=>{const n=e.matrix.length,a=n>0?e.matrix[0].length:0;if(i<0||i>=n)throw new Ce(`Row index ${i} is out of bounds, matrix has ${n} rows.`,"matrix.get");if(r<0||r>=a)throw new Ce(`Column index ${r} is out of bounds, matrix has ${a} columns.`,"matrix.get");const s=e.matrix[i][r];return s===void 0?NaN:s}}function Bt(t){const e=t.length;if(e===0)return[];const i=new Array(e);for(let n=0;n<e;n++){i[n]=new Array(2*e);for(let a=0;a<e;a++)i[n][a]=t[n][a];for(let a=0;a<e;a++)i[n][e+a]=n===a?1:0}for(let n=0;n<e;n++){let a=Math.abs(i[n][n]),s=n;for(let l=n+1;l<e;l++){const c=Math.abs(i[l][n]);c>a&&(a=c,s=l)}if(a<1e-14)return t.map(l=>l.map(()=>NaN));if(s!==n){const l=i[n];i[n]=i[s],i[s]=l}const o=i[n][n];for(let l=n;l<2*e;l++)i[n][l]/=o;for(let l=0;l<e;l++){if(l===n)continue;const c=i[l][n];if(c!==0)for(let h=n;h<2*e;h++)i[l][h]-=c*i[n][h]}}const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(e);for(let a=0;a<e;a++)r[n][a]=i[n][e+a]}return r}function cl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new j(i,r,NaN,t);const n=Bt(e.matrix),a=new j(i,r,NaN,t);return a.matrix=n,a}}function hl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n+a!==i-1&&e.matrix[n][a]!==0)return!1;return!0}}function ul(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[a][n]!==-e.matrix[n][a])return!1;return!0}}function pl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++){const s=e.matrix[n][a];if(s!==0&&s!==1)return!1}return!0}}function fl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n!==a&&e.matrix[n][a]!==0)return!1;return!0}}function dl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(n===a){if(e.matrix[n][a]!==1)return!1}else if(e.matrix[n][a]!==0)return!1;return!0}}function ml(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function gl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let a=0;for(let s=0;s<r;s++){const o=e.matrix[n][s];if(o<0)return!1;a+=o}if(Math.abs(a-1)>1e-10)return!1}return!0}}function yl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let a=0;a<n;a++)if(e.matrix[n][a]!==e.matrix[a][n])return!1;return!0}}function xl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;let n=!0,a=!0;for(let s=0;s<i;s++)for(let o=0;o<r;o++)s>o&&e.matrix[s][o]!==0&&(n=!1),s<o&&e.matrix[s][o]!==0&&(a=!1);return n||a}}function _l(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let a=0;a<r;a++)if(e.matrix[n][a]!==0)return!1;return!0}}function bl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,a=i.matrix.length,s=a>0?i.matrix[0].length:0,o=r*a,l=n*s,c=new j(o,l,NaN,t);for(let h=0;h<r;h++)for(let p=0;p<n;p++){const u=e.matrix[h][p];for(let f=0;f<a;f++)for(let m=0;m<s;m++){const x=i.matrix[f][m];c.matrix[h*a+f][p*s+m]=u*x}}return c}}function wl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l>n&&(n=l),a=!0)}return a?n:NaN}}function vl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||n.push(l)}if(n.length===0)return NaN;n.sort((s,o)=>s-o);const a=Math.floor(n.length/2);return n.length%2!==0?n[a]:(n[a-1]+n[a])/2}}function Sl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,a=!1;for(let s=0;s<i;s++)for(let o=0;o<r;o++){const l=e.matrix[s][o];isNaN(l)||(l<n&&(n=l),a=!0)}return a?n:NaN}}function El(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let a=0,s=NaN;for(let o=0;o<i;o++)for(let l=0;l<r;l++){const c=e.matrix[o][l];if(!isNaN(c)){const h=(n.get(c)||0)+1;n.set(c,h),h>a?(a=h,s=c):h===a&&c<s&&(s=c)}}return s}}function Nl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof j){const a=i.matrix.length,s=a>0?i.matrix[0].length:0;if(n!==a)return new j(0,0,NaN,t);const o=new j(r,s,0,t);for(let l=0;l<r;l++)for(let c=0;c<s;c++){let h=0;for(let p=0;p<n;p++)h+=e.matrix[l][p]*i.matrix[p][c];o.matrix[l][c]=h}return o}else if(i instanceof R||Array.isArray(i.array||i)){const a=i.array||i;if(n!==a.length)return new j(0,0,NaN,t);const s=new j(r,1,0,t);for(let o=0;o<r;o++){let l=0;for(let c=0;c<n;c++)l+=e.matrix[o][c]*a[c];s.matrix[o][0]=l}return s}else{const a=i,s=new j(r,n,NaN,t);for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]*a;return s}}}function Cl(t){return e=>{const i=e.matrix.length;if(i===0)return new j(0,0,NaN,t);const r=e.matrix[0].length;if(i===r){const h=Bt(e.matrix),p=new j(i,r,NaN,t);return p.matrix=h,p}const n=h=>{const p=h.length,u=h[0].length,f=new Array(u);for(let m=0;m<u;m++){f[m]=new Array(p);for(let x=0;x<p;x++)f[m][x]=h[x][m]}return f},a=(h,p)=>{const u=h.length,f=h[0].length,m=p[0].length,x=new Array(u);for(let _=0;_<u;_++){x[_]=new Array(m).fill(0);for(let b=0;b<f;b++){const v=h[_][b];if(v!==0)for(let w=0;w<m;w++)x[_][w]+=v*p[b][w]}}return x},s=e.matrix,o=n(s);let l;if(i>r){const h=a(o,s),p=Bt(h);l=a(p,o)}else{const h=a(s,o),p=Bt(h);l=a(o,p)}const c=new j(r,i,NaN,t);return c.matrix=l,c}}function Il(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new j(0,0,NaN,t);let a=new j(r,n,0,t);for(let l=0;l<r;l++)a.matrix[l][l]=1;let s=new j(r,n,NaN,t);for(let l=0;l<r;l++)s.matrix[l]=[...e.matrix[l]];let o=Math.floor(i);if(o<0)return new j(r,n,NaN,t);for(;o>0;){if(o%2===1){const c=new j(r,n,0,t);for(let h=0;h<r;h++)for(let p=0;p<n;p++){let u=0;for(let f=0;f<r;f++)u+=a.matrix[h][f]*s.matrix[f][p];c.matrix[h][p]=u}a=c}const l=new j(r,n,0,t);for(let c=0;c<r;c++)for(let h=0;h<n;h++){let p=0;for(let u=0;u<r;u++)p+=s.matrix[c][u]*s.matrix[u][h];l.matrix[c][h]=p}s=l,o=Math.floor(o/2)}return a}}function kl(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(s=>[...s]);let a=0;for(let s=0;s<r&&a<i;s++){let o=a;for(;o<i&&Math.abs(n[o][s])<1e-10;)o++;if(o<i){[n[a],n[o]]=[n[o],n[a]];const l=n[a][s];for(let c=s;c<r;c++)n[a][c]/=l;for(let c=0;c<i;c++)if(c!==a){const h=n[c][s];for(let p=s;p<r;p++)n[c][p]-=h*n[a][p]}a++}}return a}}function Al(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const s=Pe(e.matrix[0][0]);return new R([],s,t)}const n=[];for(let s=0;s<r;s++){const o=e.matrix[s].splice(i,1);n.push(o[0])}const a=Pe(n[0]);return new R(n,a,t)}}function Tl(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=Pe(r[0][0]);return new R(r[0]||[],n,t)}}function Pl(t){return(e,i,r)=>{const n=e.matrix.length,a=n>0?e.matrix[0].length:0,s=i*r,o=[];for(let h=0;h<n;h++)for(let p=0;p<a;p++)o.push(e.matrix[h][p]);for(;o.length<s;)o.push(NaN);o.length>s&&(o.length=s);const l=[];let c=0;for(let h=0;h<i;h++){const p=[];for(let u=0;u<r;u++)p.push(o[c++]);l.push(p)}e.matrix=l}}function Dl(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function Ml(t){return(e,i)=>{const r=e.matrix.length;if(i<0||i>=r)throw new Ce(`Row index ${i} is out of bounds, matrix has ${r} rows.`,"matrix.row");const n=Pe(e.matrix[i][0]);return new R([...e.matrix[i]],n,t)}}function Rl(t){return e=>e.matrix.length}function Ol(t){return(e,i,r,n)=>{const a=e.matrix.length,s=a>0?e.matrix[0].length:0;if(i<0||i>=a)throw new Ce(`Row index ${i} is out of bounds, matrix has ${a} rows.`,"matrix.set");if(r<0||r>=s)throw new Ce(`Column index ${r} is out of bounds, matrix has ${s} columns.`,"matrix.set");e.matrix[i][r]=n}}function Vl(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,a)=>{const s=n[i],o=a[i];return s<o?r==="asc"?-1:1:s>o?r==="asc"?1:-1:0})}}function Ll(t){return(e,i,r,n,a)=>{const s=r-i,o=a-n,l=new j(s,o,NaN,t);for(let c=0;c<s;c++){const h=i+c;if(h>=e.matrix.length)break;for(let p=0;p<o;p++){const u=n+p;if(u>=e.matrix[h].length)break;l.matrix[c][p]=e.matrix[h][u]}}return l}}function Bl(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new j(0,0,NaN,t);const n=e.matrix[0].length,a=new j(r,n,NaN,t);if(i instanceof j)for(let s=0;s<r;s++)for(let o=0;o<n;o++){const l=e.matrix[s][o],c=i.matrix[s]&&i.matrix[s][o]!==void 0?i.matrix[s][o]:NaN;a.matrix[s][o]=l+c}else{const s=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]+s}return a}}function jl(t){return(e,i,r)=>{const n=e.matrix.length;for(let a=0;a<n;a++){const s=e.matrix[a][i];e.matrix[a][i]=e.matrix[a][r],e.matrix[a][r]=s}}}function Fl(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function $l(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let a=0;for(let s=0;s<n;s++)a+=e.matrix[s][s];return a}}function Wl(t){return e=>{const i=e.matrix.length;if(i===0)return new j(0,0,NaN,t);const r=e.matrix[0].length,n=new j(r,i,NaN,t);for(let a=0;a<i;a++)for(let s=0;s<r;s++)n.matrix[s][a]=e.matrix[a][s];return n}}class j{constructor(e=0,i=0,r=NaN,n){if(this.context=n,this.matrix=[],e>0&&i>0)for(let a=0;a<e;a++)this.matrix.push(Array(i).fill(r));this._add_col=Ho(this.context),this._add_row=Go(this.context),this._avg=Yo(this.context),this._col=Xo(this.context),this._columns=Qo(this.context),this._concat=Zo(this.context),this._copy=Jo(this.context),this._det=tl(this.context),this._diff=il(this.context),this._eigenvalues=nl(this.context),this._eigenvectors=sl(this.context),this._elements_count=al(this.context),this._fill=ol(this.context),this._get=ll(this.context),this._inv=cl(this.context),this._is_antidiagonal=hl(this.context),this._is_antisymmetric=ul(this.context),this._is_binary=pl(this.context),this._is_diagonal=fl(this.context),this._is_identity=dl(this.context),this._is_square=ml(this.context),this._is_stochastic=gl(this.context),this._is_symmetric=yl(this.context),this._is_triangular=xl(this.context),this._is_zero=_l(this.context),this._kron=bl(this.context),this._max=wl(this.context),this._median=vl(this.context),this._min=Sl(this.context),this._mode=El(this.context),this._mult=Nl(this.context),this._pinv=Cl(this.context),this._pow=Il(this.context),this._rank=kl(this.context),this._remove_col=Al(this.context),this._remove_row=Tl(this.context),this._reshape=Pl(this.context),this._reverse=Dl(this.context),this._row=Ml(this.context),this._rows=Rl(this.context),this._set=Ol(this.context),this._sort=Vl(this.context),this._submatrix=Ll(this.context),this._sum=Bl(this.context),this._swap_columns=jl(this.context),this._swap_rows=Fl(this.context),this._trace=$l(this.context),this._transpose=Wl(this.context)}matrix;_add_col;_add_row;_avg;_col;_columns;_concat;_copy;_det;_diff;_eigenvalues;_eigenvectors;_elements_count;_fill;_get;_inv;_is_antidiagonal;_is_antisymmetric;_is_binary;_is_diagonal;_is_identity;_is_square;_is_stochastic;_is_symmetric;_is_triangular;_is_zero;_kron;_max;_median;_min;_mode;_mult;_pinv;_pow;_rank;_remove_col;_remove_row;_reshape;_reverse;_row;_rows;_set;_sort;_submatrix;_sum;_swap_columns;_swap_rows;_trace;_transpose;toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
|
|
138
|
+
`,e+="["+this.matrix[i].join(", ")+"]";return e}add_col(...e){return this._add_col(this,...e)}add_row(...e){return this._add_row(this,...e)}avg(...e){return this._avg(this,...e)}col(...e){return this._col(this,...e)}columns(...e){return this._columns(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}det(...e){return this._det(this,...e)}diff(...e){return this._diff(this,...e)}eigenvalues(...e){return this._eigenvalues(this,...e)}eigenvectors(...e){return this._eigenvectors(this,...e)}elements_count(...e){return this._elements_count(this,...e)}fill(...e){return this._fill(this,...e)}get(...e){return this._get(this,...e)}inv(...e){return this._inv(this,...e)}is_antidiagonal(...e){return this._is_antidiagonal(this,...e)}is_antisymmetric(...e){return this._is_antisymmetric(this,...e)}is_binary(...e){return this._is_binary(this,...e)}is_diagonal(...e){return this._is_diagonal(this,...e)}is_identity(...e){return this._is_identity(this,...e)}is_square(...e){return this._is_square(this,...e)}is_stochastic(...e){return this._is_stochastic(this,...e)}is_symmetric(...e){return this._is_symmetric(this,...e)}is_triangular(...e){return this._is_triangular(this,...e)}is_zero(...e){return this._is_zero(this,...e)}kron(...e){return this._kron(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}mult(...e){return this._mult(this,...e)}pinv(...e){return this._pinv(this,...e)}pow(...e){return this._pow(this,...e)}rank(...e){return this._rank(this,...e)}remove_col(...e){return this._remove_col(this,...e)}remove_row(...e){return this._remove_row(this,...e)}reshape(...e){return this._reshape(this,...e)}reverse(...e){return this._reverse(this,...e)}row(...e){return this._row(this,...e)}rows(...e){return this._rows(this,...e)}set(...e){return this._set(this,...e)}sort(...e){return this._sort(this,...e)}submatrix(...e){return this._submatrix(this,...e)}sum(...e){return this._sum(this,...e)}swap_columns(...e){return this._swap_columns(this,...e)}swap_rows(...e){return this._swap_rows(this,...e)}trace(...e){return this._trace(this,...e)}transpose(...e){return this._transpose(this,...e)}}function ve(t){return(e,i,r)=>new j(e,i,r,t)}function Ul(t){return(e,i=0)=>y.from(e).get(i)}class ql{constructor(e){this.context=e,this.add_col=(i,...r)=>i.add_col(...r),this.add_row=(i,...r)=>i.add_row(...r),this.avg=(i,...r)=>i.avg(...r),this.col=(i,...r)=>i.col(...r),this.columns=(i,...r)=>i.columns(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.det=(i,...r)=>i.det(...r),this.diff=(i,...r)=>i.diff(...r),this.eigenvalues=(i,...r)=>i.eigenvalues(...r),this.eigenvectors=(i,...r)=>i.eigenvectors(...r),this.elements_count=(i,...r)=>i.elements_count(...r),this.fill=(i,...r)=>i.fill(...r),this.get=(i,...r)=>i.get(...r),this.inv=(i,...r)=>i.inv(...r),this.is_antidiagonal=(i,...r)=>i.is_antidiagonal(...r),this.is_antisymmetric=(i,...r)=>i.is_antisymmetric(...r),this.is_binary=(i,...r)=>i.is_binary(...r),this.is_diagonal=(i,...r)=>i.is_diagonal(...r),this.is_identity=(i,...r)=>i.is_identity(...r),this.is_square=(i,...r)=>i.is_square(...r),this.is_stochastic=(i,...r)=>i.is_stochastic(...r),this.is_symmetric=(i,...r)=>i.is_symmetric(...r),this.is_triangular=(i,...r)=>i.is_triangular(...r),this.is_zero=(i,...r)=>i.is_zero(...r),this.kron=(i,...r)=>i.kron(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.mult=(i,...r)=>i.mult(...r),this.new=ve(e),this.param=Ul(),this.pinv=(i,...r)=>i.pinv(...r),this.pow=(i,...r)=>i.pow(...r),this.rank=(i,...r)=>i.rank(...r),this.remove_col=(i,...r)=>i.remove_col(...r),this.remove_row=(i,...r)=>i.remove_row(...r),this.reshape=(i,...r)=>i.reshape(...r),this.reverse=(i,...r)=>i.reverse(...r),this.row=(i,...r)=>i.row(...r),this.rows=(i,...r)=>i.rows(...r),this.set=(i,...r)=>i.set(...r),this.sort=(i,...r)=>i.sort(...r),this.submatrix=(i,...r)=>i.submatrix(...r),this.sum=(i,...r)=>i.sum(...r),this.swap_columns=(i,...r)=>i.swap_columns(...r),this.swap_rows=(i,...r)=>i.swap_rows(...r),this.trace=(i,...r)=>i.trace(...r),this.transpose=(i,...r)=>i.transpose(...r),this.new_float=ve(e),this.new_int=ve(e),this.new_string=ve(e),this.new_bool=ve(e),this.new_color=ve(e),this.new_line=ve(e),this.new_label=ve(e),this.new_box=ve(e),this.new_linefill=ve(e),this.new_table=ve(e)}}class zl{constructor(e){this.context=e}_live=!1;setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.length-1}get isrealtime(){return this.context.idx===this.context.length-1}get isconfirmed(){return this.context.data.closeTime.data[this.context.idx]<=Date.now()}get islastconfirmedhistory(){const e=this.context.idx,i=this.context.length;if(e===i-1)return this.context.data.closeTime.data[e]<=Date.now();if(e===i-2){const r=this.context.marketData?.[i-1]?.closeTime;return r!==void 0?r>Date.now():!1}return!1}}class ct{constructor(e,i){this._definition=e,this.context=i;for(let r in e)this[r]=e[r]}get __def__(){return this._definition}copy(){return new ct(this.__def__,this.context)}toString(){const e={};for(let i in this.__def__){const r=this[i];r!=null&&typeof r=="object"&&typeof r.toString=="function"&&!(r instanceof Array)?e[i]=r.toString():e[i]=r}try{return JSON.stringify(e)}catch{return"{"+Object.keys(e).map(i=>`"${i}":${String(e[i])}`).join(",")+"}"}}}class se{time;index;price;constructor(e,i,r){this.time=e,this.index=i,this.price=r}copy(){return new se(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function Kl(t){return typeof t=="object"&&t&&(t.title!==void 0||t._plotKey!==void 0)&&t.data!==void 0&&t.options!==void 0}const sr={series:t=>t instanceof y||typeof t=="number"||typeof t=="string"||typeof t=="boolean",string:t=>typeof t=="string",color:t=>typeof t=="string"||typeof t=="number"&&isNaN(t),number:t=>typeof t=="number",boolean:t=>typeof t=="boolean",array:t=>Array.isArray(t),object:t=>typeof t=="object",point:t=>t instanceof se,primitive:t=>typeof t===null||typeof t!="object"&&typeof t!="function",function:t=>typeof t=="function",undefined:t=>t===void 0,null:t=>t===null,NaN:t=>isNaN(t),remaining_options:t=>typeof t=="object"&&!(t instanceof y)&&!(t instanceof se)&&!Kl(t)};function ke(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function X(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let a={};const s=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const l=t[o];if(sr.remaining_options(l)){a=l;break}const c=e.map((h,p)=>s[p]?h[o]:void 0);for(let h=0;h<c.length;h++){const p=c[h];if(p===void 0){s[h]=!1;continue}const u=i[p];if(typeof l=="number"&&isNaN(l)&&(u==="number"||u==="series"))n[p]=l;else{const f=sr[i[p]];typeof f=="function"&&f(l)?n[p]=l:s[h]=!1}}}return{...n,...a,...r}}const Hl=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Gl={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},Yl=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],Xl={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function Ql(t){return X(t,Yl,Xl)}class _t{get __value(){return NaN}param(e,i=0){return y.from(e).get(i)}any(e){const i=y.from(e).get(0);return i==null?!0:typeof i=="number"?i!==i:!1}}class Zl{constructor(e){this.context=e}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}indicator(...e){const i=Ql(e),r={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"points",max_bars_back:0,timeframe:"",timeframe_gaps:!0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,max_polylines_count:50,dynamic_requests:!1,behind_chart:!0};return this.context.indicator={...r,...i},this.context.indicator}get bar_index(){return this.context.idx}na(e){return isNaN(y.from(e).get(0))}nz(e,i=0){const r=y.from(e).get(0),n=y.from(i).get(0);return isNaN(r)?n:r}fixnan(e){const i=y.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){}alert(...e){console.warn("alert called but is currently not implemented",e)}error(...e){console.error("error called but is currently not implemented",e)}max_bars_back(e,i){}timestamp(...e){const i=e.map(n=>n instanceof y?n.get(0):n),r=X(i,Hl,Gl);if(r.year!==void 0){const n=r.year,a=r.month,s=r.day,o=r.hour||0,l=r.minute||0,c=r.second||0,h=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(h,n,a,s,o,l,c)}if(r.dateString!==void 0){const n=r.dateString.trim();if(/[Zz]$/.test(n)||/[+-]\d{2}:?\d{2}$/.test(n))return new Date(n).getTime();const a=n.includes("T")?n+"Z":n.replace(/\s+/,"T")+"Z",s=new Date(a);if(!isNaN(s.getTime())){const o=this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(o,s.getUTCFullYear(),s.getUTCMonth()+1,s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds())}return new Date(n).getTime()}return NaN}_timestampFromComponents(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=e.trim();if(c==="UTC"||c==="GMT"||c==="Etc/UTC")return l.getTime();const h=c.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(h){const p=h[1]==="+"?1:-1,u=parseInt(h[2],10),f=parseInt(h[3]||"0",10),m=p*(u*60+f)*60*1e3;return l.getTime()-m}try{return this._timestampFromIANA(e,i,r,n,a,s,o)}catch{return l.getTime()}}_timestampFromIANA(e,i,r,n,a,s,o){const l=new Date(Date.UTC(i,r-1,n,a,s,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(l),h=w=>parseInt(c.find(E=>E.type===w)?.value||"0",10),p=h("year"),u=h("month"),f=h("day");let m=h("hour");m===24&&(m=0);const x=h("minute"),_=h("second"),b=new Date(Date.UTC(p,u-1,f,m,x,_));p>=0&&p<100&&b.setUTCFullYear(p);const v=b.getTime()-l.getTime();return l.getTime()-v}bool(e){const i=y.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "int" with argument "x"="${i}". An argument of "literal string" type was used but a "simple int" is expected.`);return Math.trunc(i)}float(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "float" with argument "x"="${i}". An argument of "literal string" type was used but a "const float" is expected.`);return i}string(e){return y.from(e).get(0).toString()}Type(e){const i=Object.keys(e),r={};for(const n of i){let a=e[n];a instanceof y&&(a=a.data),Array.isArray(a)&&(a[0],r[n]=a[1])}return{new:function(...n){const a={};let s=null;if(n.length===1&&n[0]&&typeof n[0]=="object"&&!(n[0]instanceof y)&&!Array.isArray(n[0])&&!(n[0]instanceof ct)){const o=Object.keys(n[0]);o.length>0&&o.some(l=>i.includes(l))&&(s=n[0],n=[])}for(let o=0;o<i.length;o++){const l=i[o];s&&l in s?a[l]=s[l]:o<n.length?a[l]=n[o]:l in r&&(a[l]=y.from(r[l]).get(0))}return new ct(a,this.context)},copy:function(n){return new ct(n.__def__,this.context)}}}}function ot(t){if(!t||typeof t!="string")return null;if(t.startsWith("#")){const i=t.slice(1);return i.length===6?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),1]:i.length===8?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),parseInt(i.slice(6,8),16)/255]:null}const e=t.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);return e?[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),e[4]?parseFloat(e[4]):1]:null}function Jl(t,e,i,r){const n=Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),a=Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0"),s=Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");if(r>=1)return`#${n}${a}${s}`.toUpperCase();const o=Math.round(Math.max(0,Math.min(255,r*255))).toString(16).padStart(2,"0");return`#${n}${a}${s}${o}`.toUpperCase()}const Y={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#F23645",silver:"#B2B5BE",teal:"#089981",white:"#FFFFFF",yellow:"#FDD835"};function Ie(t){return typeof t=="function"&&(t=t()),t&&typeof t=="object"&&Array.isArray(t.data)&&typeof t.get=="function"&&(t=t.get(0)),t}class ec{constructor(e){this.context=e}any(e){const i=y.from(e).get(0);return typeof i=="number"&&isNaN(i)?null:i}param(e,i=0){return y.from(e).get(i)}new(e,i){if(e=Ie(e),!e||typeof e!="string")return e;if(e.startsWith("#")){const r=e.slice(1),n=r.length===8?r.slice(0,6):r;return i!=null?`#${n}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=Y[e];if(r)return i!=null?`#${r.slice(1)}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:r;const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(n){const a=n[1],s=n[2],o=n[3];if(i!=null){const l=parseInt(a).toString(16).padStart(2,"0"),c=parseInt(s).toString(16).padStart(2,"0"),h=parseInt(o).toString(16).padStart(2,"0"),p=Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase();return`#${l}${c}${h}${p}`}return e}return i!=null?`rgba(${e}, ${(100-i)/100})`:e}}rgb(e,i,r,n){return n!=null?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`}from_gradient(e,i,r,n,a){if(e=Ie(e),i=Ie(i),r=Ie(r),n=Ie(n),a=Ie(a),e==null||typeof e=="number"&&isNaN(e)||i==null||typeof i=="number"&&isNaN(i)||r==null||typeof r=="number"&&isNaN(r)||n==null||typeof n=="number"&&isNaN(n)||a==null||typeof a=="number"&&isNaN(a))return;let s=0;r!==i&&(s=(e-i)/(r-i)),s=Math.max(0,Math.min(1,s));const o=ot(typeof n=="string"?n:"#000000")||[0,0,0,1],l=ot(typeof a=="string"?a:"#FFFFFF")||[255,255,255,1],c=o[0]+(l[0]-o[0])*s,h=o[1]+(l[1]-o[1])*s,p=o[2]+(l[2]-o[2])*s,u=o[3]+(l[3]-o[3])*s;return Jl(c,h,p,u)}r(e){if(e=Ie(e),!e||typeof e!="string")return NaN;const i=ot(e);return i?i[0]:NaN}g(e){if(e=Ie(e),!e||typeof e!="string")return NaN;const i=ot(e);return i?i[1]:NaN}b(e){if(e=Ie(e),!e||typeof e!="string")return NaN;const i=ot(e);return i?i[2]:NaN}t(e){if(e=Ie(e),!e||typeof e!="string")return NaN;const i=ot(e);return i?Math.round(100-i[3]*100):NaN}aqua(){return Y.aqua}black(){return Y.black}blue(){return Y.blue}fuchsia(){return Y.fuchsia}gray(){return Y.gray}green(){return Y.green}lime(){return Y.lime}maroon(){return Y.maroon}navy(){return Y.navy}olive(){return Y.olive}orange(){return Y.orange}purple(){return Y.purple}red(){return Y.red}silver(){return Y.silver}teal(){return Y.teal}white(){return Y.white}yellow(){return Y.yellow}}function ft(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,a=parseInt(r[2],10),s=parseInt(r[3]||"0",10),o=n*(a*60+s)*60*1e3,l=new Date(t+o);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),dayOfWeek:l.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),a=c=>parseInt(n.find(h=>h.type===c)?.value||"0",10);let s=a("hour");s===24&&(s=0);const o=n.find(c=>c.type==="weekday")?.value||"Sun",l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:a("year"),month:a("month"),day:a("day"),hour:s,minute:a("minute"),second:a("second"),dayOfWeek:l[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function tc(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const a=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-a.getTime())/864e5+1)/7)}const ic=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],rc={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class ar{context;dataField;constructor(e,i="openTime"){this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(c=>c instanceof y?c.get(0):c),r=X(i,ic,rc),n=r.bars_back??0,a=r.timeframe_bars_back??0,s=n+a,o=this.context.data[this.dataField],l=y.from(o).get(s);if(r.session!==void 0){const c=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(l,r.session,c)?l:NaN}return l}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const a=parseInt(n[1],10),s=parseInt(n[2],10),o=parseInt(n[3],10),l=parseInt(n[4],10),c=ft(e,r),h=c.hour,p=c.minute,u=h*60+p,f=a*60+s,m=o*60+l;return f<=m?u>=f&&u<m:u>=f||u<m}}const nc=[[],["time"],["time","timezone"]],sc={time:"number",timezone:"string"};class Ue{context;extractor;constructor(e,i){this.context=e,this.extractor=i}get __value(){const e=y.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=ft(e,i);return this.extractor(r)}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof y?o.get(0):o);if(i.length===0)return this.__value;const r=X(i,nc,sc),n=r.time;if(n===void 0||isNaN(n))return NaN;const a=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",s=ft(n,a);return this.extractor(s)}}const qe={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>tc(t.year,t.month,t.day),year:t=>t.year},ac=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],oc={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function he(t){return X(t,ac,oc)}function we(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function lc(t){return(...e)=>{const i=he(e);return we(t,i)}}function cc(t){return(...e)=>he(e).defval}function hc(t){return(...e)=>{const i=he(e);return we(t,i)}}function uc(t){return(...e)=>{const i=he(e);return we(t,i)}}function pc(t){return(...e)=>{const i=he(e);return we(t,i)}}function fc(t){return(...e)=>{const i=he(e);return we(t,i)}}function dc(t){return(e,i=0)=>y.from(e).get(i)}function mc(t){return(...e)=>{const i=he(e);return we(t,i)}}function gc(t){return(...e)=>{const i=he(e);return we(t,i)}}function yc(t){return(...e)=>{const i=he(e);return we(t,i)}}function xc(t){return(...e)=>{const i=he(e);return we(t,i)}}function _c(t){return(...e)=>{const i=he(e);return we(t,i)}}function bc(t){return(...e)=>{const i=he(e);return we(t,i)}}function wc(t){return(...e)=>{const i=he(e);return we(t,i)}}function vc(t){return(...e)=>he(e).defval}const Sc={any:lc,bool:cc,color:hc,enum:uc,float:pc,int:fc,param:dc,price:mc,session:gc,source:yc,string:xc,symbol:_c,text_area:bc,time:wc,timeframe:vc};class Ec{constructor(e){this.context=e,Object.entries(Sc).forEach(([i,r])=>{this[i]=r(e)})}any;bool;color;enum;float;int;param;price;session;source;string;symbol;text_area;time;timeframe}function Nc(t){return e=>Math.abs(y.from(e).get(0))}function Cc(t){return e=>Math.acos(y.from(e).get(0))}function Ic(t){return e=>Math.asin(y.from(e).get(0))}function kc(t){return e=>Math.atan(y.from(e).get(0))}function Ac(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function Tc(t){return e=>Math.ceil(y.from(e).get(0))}function Pc(t){return e=>Math.cos(y.from(e).get(0))}function Dc(t){return()=>Math.E}function Mc(t){return e=>Math.exp(y.from(e).get(0))}function Rc(t){return e=>Math.floor(y.from(e).get(0))}function Oc(t){return e=>Math.log(y.from(e).get(0))}function Vc(t){return e=>Math.log(y.from(e).get(0))}function Lc(t){return e=>Math.log10(y.from(e).get(0))}function Bc(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.max(...i)}}function jc(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.min(...i)}}function Fc(t){return(e,i,r)=>typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function $c(t){return()=>1.618033988749895}function Wc(t){return()=>Math.PI}function Uc(t){return(e,i)=>Math.pow(y.from(e).get(0),y.from(i).get(0))}function qc(t){return()=>Math.random()}function ni(t){return t!==t?NaN:Math.sign(t)*Math.round(Math.abs(t))}function zc(t){return(e,i)=>{const r=y.from(e).get(0);if(i==null)return ni(r);const n=y.from(i).get(0);if(n===0)return ni(r);const a=Math.pow(10,n);return ni(r*a)/a}}function Kc(t){return e=>t.precision(Math.round(y.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Hc(t){return()=>.6180339887498948}function Gc(t){return e=>Math.sign(y.from(e).get(0))}function Yc(t){return e=>Math.sin(y.from(e).get(0))}function Xc(t){return e=>Math.sqrt(y.from(e).get(0))}function Qc(t){return(e,i)=>{const r=y.from(i).get(0),n=y.from(e);let a=0;for(let s=0;s<r;s++){const o=n.get(s);a+=o}return a}}function Zc(t){return e=>Math.tan(y.from(e).get(0))}function Jc(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function eh(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function th(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-9:r===n}}function ih(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)>=1e-9:r!==n}}const rh={abs:Nc,acos:Cc,asin:Ic,atan:kc,avg:Ac,ceil:Tc,cos:Pc,e:Dc,exp:Mc,floor:Rc,ln:Oc,log:Vc,log10:Lc,max:Bc,min:jc,param:Fc,phi:$c,pi:Wc,pow:Uc,random:qc,round:zc,round_to_mintick:Kc,rphi:Hc,sign:Gc,sin:Yc,sqrt:Xc,sum:Qc,tan:Zc,todegrees:Jc,toradians:eh,__eq:th,__neq:ih};class nh{constructor(e){this.context=e,Object.entries(rh).forEach(([i,r])=>{this[i]=r(e)})}_cache={};abs;acos;asin;atan;avg;ceil;cos;e;exp;floor;ln;log;log10;max;min;param;phi;pi;pow;random;round;round_to_mintick;rphi;sign;sin;sqrt;sum;tan;todegrees;toradians;__eq;__neq}function sh(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof y)n=e.get(i||0);else if(Array.isArray(e)){const a=e.some(o=>o instanceof y),s=e.every(o=>!(o instanceof y)&&!Array.isArray(o));(a||s)&&e.length>=1?n=e.map(o=>o instanceof y?o.get(0):o):n=y.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,[n,r]}}const dt=["1","3","5","15","30","45","60","120","180","240","D","W","M"],Rt={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function Ut(t){if(dt.includes(t))return t;if(Rt[t])return Rt[t];const e=t.toLowerCase();if(Rt[e])return Rt[e];const i=t.toUpperCase();return dt.includes(i)?i:t}function or(t,e,i,r,n=!1,a=!1){for(let s=0;s<i.length;s++)if(i[s]<=t&&t<r[s])return n||a||e>=r[s]?s:s-1;return-1}function lr(t,e,i,r,n=!1,a,s=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const l=a&&e>a;if(s&&n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(l&&n&&!s)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}return o}if(r[o]<t)break}return-1}function yi(t){return t==null||typeof t!="object"?t:"__value"in t?t.__value:t instanceof y?t.get(0):Array.isArray(t)?t.map(yi):t}function ah(t){return async(e,i,r,n=!1,a=!1,s=!1,o=null,l=null)=>{const c=e[0]instanceof y?e[0].get(0):e[0],h=c===""?t.tickerId:c,p=typeof h=="string"&&h.includes(":")?h.split(":")[1]:h,u=i[0]instanceof y?i[0].get(0):i[0],f=u===""?t.timeframe:typeof u=="string"?u:String(u??""),m=r[0],x=r[1],_=Array.isArray(n)?n[0]:n,b=Array.isArray(a)?a[0]:a,v=_===!0||_==="gaps_on",w=b===!0||b==="lookahead_on";if(t.isSecondaryContext){const ue=yi(m);return Array.isArray(ue)?[ue]:ue}const E=dt.indexOf(Ut(t.timeframe)),A=dt.indexOf(Ut(f));if(E==-1||A==-1)throw new Error("Invalid timeframe");if(E===A){const ue=yi(m);return Array.isArray(ue)?[ue]:ue}const C=E>A,M=y.from(t.data.openTime).get(0),V=y.from(t.data.closeTime).get(0),$=t.idx===t.length-1&&V>Date.now(),F=`${p}_${f}_${x}`,D=`${F}_prevIdx`;if(t.cache[F]){const ue=t.cache[F];t.dataVersion>ue.dataVersion&&(await ue.pineTS.updateTail(ue.context),ue.dataVersion=t.dataVersion);const bt=ue.context,Pt=C?lr(M,V,bt.data.openTime.data,bt.data.closeTime.data,w,t.eDate,v):or(M,V,bt.data.openTime.data,bt.data.closeTime.data,w,$);if(Pt==-1)return NaN;const nt=bt.params[x][Pt];if(!C&&v){const Vi=t.cache[D];return Vi!==void 0&&Vi===Pt?NaN:(t.cache[D]=Pt,Array.isArray(nt)?[nt]:nt)}return Array.isArray(nt)?[nt]:nt}const q=1e3*60*60*24*30,re=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),fe=re?re-q:void 0,de=t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0,me=t.eDate?Math.max(t.eDate,de):(de||Date.now())+q,Ye=new Ri(t.source,p,f,void 0,fe,me);Ye.markAsSecondary();const ee=await Ye.run(t.pineTSCode);t.cache[F]={pineTS:Ye,context:ee,dataVersion:t.dataVersion};const Zt=C?lr(M,V,ee.data.openTime.data,ee.data.closeTime.data,w,t.eDate,v):or(M,V,ee.data.openTime.data,ee.data.closeTime.data,w,$);if(Zt==-1)return NaN;const Jt=ee.params[x][Zt];return!C&&v?(t.cache[D]=Zt,NaN):Array.isArray(Jt)?[Jt]:Jt}}function lt(t){return typeof t=="number"?T.float:typeof t=="boolean"?T.bool:typeof t=="string"?T.string:T.any}function oh(t){return async(e,i,r,n=!1,a=null,s=!1,o=0)=>{const l=e[0]instanceof y?e[0].get(0):e[0],c=l===""?t.tickerId:l,h=typeof c=="string"&&c.includes(":")?c.split(":")[1]:c,p=i[0]instanceof y?i[0].get(0):i[0],u=p===""?t.timeframe:typeof p=="string"?p:String(p??""),f=r[0],m=r[1];Array.isArray(n)&&n[0];const x=Array.isArray(s)?s[0]:s;if(t.isSecondaryContext)return Array.isArray(f)?[f.map(D=>new R([D],lt(D),t))]:new R([f],lt(f),t);const _=dt.indexOf(Ut(t.timeframe)),b=dt.indexOf(Ut(u));if(_===-1||b===-1){if(x)return NaN;throw new Error("Invalid timeframe")}if(b>_){if(x)return NaN;throw new Error(`Timeframe ${u} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(b===_)return Array.isArray(f)?[f.map(D=>new R([D],lt(D),t))]:new R([f],lt(f),t);const v=`${h}_${u}_${m}_lower`;if(!t.cache[v]){const D=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),q=D?D-2592e6:void 0,re=t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0,fe=t.eDate?Math.max(t.eDate,re):(re||Date.now())+2592e6,de=new Ri(t.source,h,u,void 0,q,fe);de.markAsSecondary();const me=await de.run(t.pineTSCode);t.cache[v]={pineTS:de,context:me,dataVersion:t.dataVersion}}const w=t.cache[v];t.dataVersion>w.dataVersion&&(await w.pineTS.updateTail(w.context),w.dataVersion=t.dataVersion);const E=w.context,A=y.from(t.data.openTime).get(0),C=y.from(t.data.closeTime).get(0),M=E.data.openTime.data,V=E.data.closeTime.data,$=E.params[m];if(!$)return Array.isArray(f)?[f.map(()=>new R([],T.float,t))]:new R([],T.float,t);const F=[];for(let D=0;D<M.length;D++){const q=M[D];if(!(V[D]<=A)){if(q>=C)break;q>=A&&q<C&&F.push($[D])}}if(F.length>0&&Array.isArray(F[0])){const D=F[0].length,q=[];for(let re=0;re<D;re++){const fe=F.map(me=>me[re]),de=fe.length>0?lt(fe[0]):T.float;q.push(new R(fe,de,t))}return[q]}else{const D=F.length>0?lt(F[0]):T.float;return new R(F,D,t)}}}const lh={param:sh,security:ah,security_lower_tf:oh};class ch{constructor(e){this.context=e,Object.entries(lh).forEach(([i,r])=>{this[i]=r(e)})}_cache={};param;security;security_lower_tf}function hh(t){return e=>{t.taState||(t.taState={});const i=e||"accdist";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(a)||isNaN(s)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const l=a-s;let c=0;l!==0&&(c=(n-s-(a-n))/l*o);const h=r.prevCumulativeSum+c;return r.currentCumulativeSum=h,t.precision(h)}}function uh(t){return(e,i,r,n,a)=>{const s=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0);t.taState||(t.taState={});const c=a||`alma_${s}_${o}_${l}`;if(!t.taState[c]){const x=o*(s-1),_=s/l,b=[];let v=0;for(let w=0;w<s;w++){const E=Math.exp(-Math.pow(w-x,2)/(2*_*_));b.push(E),v+=E}for(let w=0;w<b.length;w++)b[w]/=v;t.taState[c]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0,weights:b}}const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.prevWindow=[...h.currentWindow],h.prevCallCount=h.currentCallCount),h.lastIdx=t.idx);const p=y.from(e).get(0),u=[...h.prevWindow];for(u.unshift(p);u.length>s;)u.pop();const f=h.prevCallCount+1;if(u.length<s&&(f>=s||t.idx>=s-1)){const x=y.from(e);for(;u.length<s;)u.push(x.get(u.length))}if(h.currentWindow=u,h.currentCallCount=f,u.length<s)return NaN;let m=0;for(let x=0;x<s;x++)m+=h.weights[x]*u[s-1-x];return t.precision(m)}}function ph(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,currentAtr:null,currentInitSum:0,currentInitCount:0});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevAtr=a.currentAtr,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return NaN;const c=t.idx>0?t.get(t.data.close,1):null;let h;if(c!==null&&!isNaN(c)){const x=s-o,_=Math.abs(s-c),b=Math.abs(o-c);h=Math.max(x,_,b)}else h=s-o;let p=a.prevInitCount,u=a.prevInitSum,f=a.prevAtr;if(p<r){if(u+=h,p++,a.currentInitSum=u,a.currentInitCount=p,p===r){const x=u/r;return a.currentAtr=x,t.precision(x)}return NaN}const m=(f*(r-1)+h)/r;return a.currentAtr=m,t.precision(m)}}function fh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"barssince";t.taState[r]||(t.taState[r]={lastIdx:-1,prevLastTrueIndex:null,currentLastTrueIndex:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const a=y.from(e).get(0);let s=n.prevLastTrueIndex;return a&&(s=t.idx),n.currentLastTrueIndex=s,s===null?NaN:t.idx-s}}function dh(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,[[NaN,NaN,NaN]];const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const b=h.pop();p-=b}if(h.length<a&&t.idx>=a-1){const b=y.from(e);for(;h.length<a;){const v=b.get(h.length);if(isNaN(v))break;h.push(v),p+=v}}if(l.currentWindow=h,l.currentSum=p,h.length<a)return[[NaN,NaN,NaN]];const u=p/a;let f=0;for(let b=0;b<a;b++)f+=Math.pow(h[b]-u,2);const m=Math.sqrt(f/a),x=u+s*m,_=u-s*m;return[[t.precision(u),t.precision(x),t.precision(_)]]}}function mh(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,NaN;const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const v=h.pop();p-=v}if(h.length<a&&t.idx>=a-1){const v=y.from(e);for(;h.length<a;){const w=v.get(h.length);if(isNaN(w))break;h.push(w),p+=w}}if(l.currentWindow=h,l.currentSum=p,h.length<a)return NaN;const u=p/a;let f=0;for(let v=0;v<a;v++){const w=h[v]-u;f+=w*w}const m=f/a,x=Math.sqrt(m),_=s*x;if(u===0)return t.precision(0);const b=2*_/u*100;return t.precision(b)}}function gh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`cci_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0);if(isNaN(o))return NaN;const l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const x=l.pop();c-=x}const h=s.prevCallCount+1;if(l.length<n&&(h>=n||t.idx>=n-1)){const x=y.from(e);for(;l.length<n;){const _=x.get(l.length);if(isNaN(_))break;l.push(_),c+=_}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=h,l.length<n)return NaN;const p=c/n;let u=0;for(let x=0;x<n;x++)u+=Math.abs(l[x]-p);const f=u/n;if(f===0)return 0;const m=(o-p)/(.015*f);return t.precision(m)}}function yh(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`change_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const p=y.from(e);for(;l.length<n+1;)l.push(p.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const h=o-l[n];return t.precision(h)}}function xh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`cmo_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevGainsWindow=[...s.currentGainsWindow],s.prevLossesWindow=[...s.currentLossesWindow],s.prevGainsSum=s.currentGainsSum,s.prevLossesSum=s.currentLossesSum),s.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1);if(isNaN(o)||isNaN(l))return NaN;const c=o-l,h=c>=0?c:0,p=c>=0?0:-c,u=[...s.prevGainsWindow],f=[...s.prevLossesWindow];let m=s.prevGainsSum,x=s.prevLossesSum;if(u.unshift(h),f.unshift(p),m+=h,x+=p,u.length<n)return s.currentGainsWindow=u,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=x,NaN;if(u.length>n){const v=u.pop(),w=f.pop();m-=v,x-=w}s.currentGainsWindow=u,s.currentLossesWindow=f,s.currentGainsSum=m,s.currentLossesSum=x;const _=m+x;if(_===0)return t.precision(0);const b=100*(m-x)/_;return t.precision(b)}}function _h(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);let s=0,o=!1;for(let h=0;h<n;h++){const p=a.get(h);if(isNaN(p)){o=!0;break}s+=p}if(o)return NaN;let l=0;for(let h=0;h<n;h++){const p=a.get(h);l+=p*(h+1)}if(s===0)return NaN;const c=-l/s;return t.precision(c)}}function bh(t){return(e,i,r,n)=>{const a=y.from(r).get(0),s=y.from(e),o=y.from(i);if(t.idx<a-1)return NaN;let l=0,c=0,h=0,p=0,u=0,f=0;for(let v=0;v<a;v++){const w=s.get(v),E=o.get(v);isNaN(w)||isNaN(E)||(l+=w,c+=E,h+=w*E,p+=w*w,u+=E*E,f++)}if(f<2)return NaN;const m=f*h-l*c,x=f*p-l*l,_=f*u-c*c;if(x<=0||_<=0)return t.precision(0);const b=m/Math.sqrt(x*_);return t.precision(b)}}function wh(t){return(e,i,r)=>{const n=y.from(e),a=y.from(i),s=n.get(0),o=a.get(0),l=n.get(1),c=a.get(1);if(isNaN(s)||isNaN(o)||isNaN(l)||isNaN(c))return!1;const h=s>o&&l<=c,p=s<o&&l>=c;return h||p}}function vh(t){return(e,i)=>{const r=y.from(e),n=y.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o<l&&a>s}}function Sh(t){return(e,i)=>{const r=y.from(e),n=y.from(i),a=r.get(0),s=n.get(0),o=r.get(1),l=n.get(1);return o>l&&a<s}}function Eh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"cum";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const a=y.from(e).get(0);if(isNaN(a))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const s=n.prevCumulativeSum+a;return n.currentCumulativeSum=s,t.precision(s)}}function Nh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`dev_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0)||0,l=[...s.prevWindow];let c=s.prevSum;for(l.unshift(o),c+=o;l.length>n;){const m=l.pop();c-=m}const h=s.prevCallCount+1;if(l.length<n&&(h>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;){const x=m.get(l.length);l.push(x),c+=x}}if(s.currentWindow=l,s.currentSum=c,s.currentCallCount=h,l.length<n)return NaN;const p=c/n;let u=0;for(let m=0;m<n;m++)u+=Math.abs(l[m]-p);const f=u/n;return t.precision(f)}}function Ch(t){return(e,i,r)=>{const n=y.from(e).get(0),a=y.from(i).get(0);t.taState||(t.taState={});const s=r||`dmi_${n}_${a}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevTrInitSum:0,prevPlusInitSum:0,prevMinusInitSum:0,prevInitCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,prevDxInitSum:0,prevAdxInitCount:0,prevADX:NaN,currentTrInitSum:0,currentPlusInitSum:0,currentMinusInitSum:0,currentInitCount:0,currentSmoothedTR:NaN,currentSmoothedPlus:NaN,currentSmoothedMinus:NaN,currentDxInitSum:0,currentAdxInitCount:0,currentADX:NaN});const o=t.taState[s];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrInitSum=o.currentTrInitSum,o.prevPlusInitSum=o.currentPlusInitSum,o.prevMinusInitSum=o.currentMinusInitSum,o.prevInitCount=o.currentInitCount,o.prevSmoothedTR=o.currentSmoothedTR,o.prevSmoothedPlus=o.currentSmoothedPlus,o.prevSmoothedMinus=o.currentSmoothedMinus,o.prevDxInitSum=o.currentDxInitSum,o.prevAdxInitCount=o.currentAdxInitCount,o.prevADX=o.currentADX),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(h))return[[NaN,NaN,NaN]];const p=t.idx>0?t.get(t.data.high,1):NaN,u=t.idx>0?t.get(t.data.low,1):NaN,f=t.idx>0?t.get(t.data.close,1):NaN;if(isNaN(p))return[[NaN,NaN,NaN]];const m=Math.max(l-c,Math.abs(l-f),Math.abs(c-f)),x=l-p,_=u-c,b=x>_&&x>0?x:0,v=_>x&&_>0?_:0;let w=o.prevInitCount,E=o.prevTrInitSum,A=o.prevPlusInitSum,C=o.prevMinusInitSum,M=o.prevSmoothedTR,V=o.prevSmoothedPlus,$=o.prevSmoothedMinus;if(w++,w<=n)E+=m,A+=b,C+=v,w===n&&(M=E/n,V=A/n,$=C/n);else{const ee=1/n;M=ee*m+(1-ee)*M,V=ee*b+(1-ee)*V,$=ee*v+(1-ee)*$}if(o.currentInitCount=w,o.currentTrInitSum=E,o.currentPlusInitSum=A,o.currentMinusInitSum=C,o.currentSmoothedTR=M,o.currentSmoothedPlus=V,o.currentSmoothedMinus=$,w<n)return[[NaN,NaN,NaN]];const F=M===0?0:100*V/M,D=M===0?0:100*$/M,q=F+D,re=q===0?0:100*Math.abs(F-D)/q;let fe=o.prevAdxInitCount,de=o.prevDxInitSum,me=o.prevADX,Ye=NaN;if(fe++,fe<=a)de+=re,fe===a&&(me=de/a,Ye=me);else{const ee=1/a;me=ee*re+(1-ee)*me,Ye=me}return o.currentAdxInitCount=fe,o.currentDxInitSum=de,o.currentADX=me,[[t.precision(F),t.precision(D),t.precision(Ye)]]}}function Ih(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`ema_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevEma=s.currentEma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;let l=s.prevInitCount,c=s.prevInitSum,h=s.prevEma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentEma=f,t.precision(f)}return NaN}const p=2/(n+1),u=o*p+h*(1-p);return s.currentEma=u,t.precision(u)}}function kh(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o>=l)return!1}return!0}}function Ah(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`highest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const u=y.from(e);for(;l.length<n;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.filter(u=>!isNaN(u)&&u!==void 0);if(h.length===0)return NaN;const p=Math.max(...h);return t.precision(p)}}function Th(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);if(t.idx<n-1)return NaN;let s=-1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c>s)&&(s=c,o=-l)}return o}}function Ph(t){return(e,i,r)=>{const n=y.from(i).get(0),a=Math.floor(n/2),s=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,l=o(e,a,r?`${r}_wma1`:void 0),c=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(l)||isNaN(c))return NaN;t.taState||(t.taState={});const h=r||`hma_raw_${n}`;t.taState[h]||(t.taState[h]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[h];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const u=2*l-c,f=[...p.prevValues];f.unshift(u),f.length>s+1&&f.pop(),p.currentValues=f;const m=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[m]||(t.taState[m]={lastIdx:-1,prevWindow:[],currentWindow:[]});const x=t.taState[m];t.idx>x.lastIdx&&(x.lastIdx>=0&&(x.prevWindow=[...x.currentWindow]),x.lastIdx=t.idx);const _=[...x.prevWindow];if(_.unshift(u),_.length<s)return x.currentWindow=_,NaN;for(;_.length>s;)_.pop();x.currentWindow=_;let b=0,v=0;for(let E=0;E<s;E++){const A=s-E;b+=_[E]*A,v+=A}const w=b/v;return t.precision(w)}}function Dh(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a))return NaN;const s=(r-n)*a;if(s===0)return t.precision(0);const o=(2*i-r-n)/s;return t.precision(o)}}function Mh(t){return(e,i,r,n,a)=>{const s=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=y.from(n).get(0));let c;const h=t.get(t.data.high,0),p=t.get(t.data.low,0);if(l){const E=t.get(t.data.close,1);isNaN(E)?c=NaN:c=Math.max(h-p,Math.abs(h-E),Math.abs(p-E))}else c=h-p;const u=y.from(e).get(0);t.taState||(t.taState={});const f=a||`kc_${s}_${o}_${l}`;t.taState[f]||(t.taState[f]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const m=t.taState[f];t.idx>m.lastIdx&&(m.lastIdx>=0&&(m.basisState={...m.currentBasisState},m.rangeState={...m.currentRangeState}),m.lastIdx=t.idx);const x=(E,A,C,M)=>{if(isNaN(C))return Object.assign(A,E),A.prevEma!==null?A.prevEma:NaN;let V=E.initCount,$=E.initSum,F=E.prevEma;if(V<M){if($+=C,V++,A.initSum=$,A.initCount=V,A.prevEma=F,V===M){const re=$/M;return A.prevEma=re,re}return NaN}const D=2/(M+1),q=C*D+F*(1-D);return A.prevEma=q,A.initSum=$,A.initCount=V,q},_=x(m.basisState,m.currentBasisState,u,s),b=x(m.rangeState,m.currentRangeState,c,s);if(isNaN(_)||isNaN(b))return[[NaN,NaN,NaN]];const v=_+b*o,w=_-b*o;return[[t.precision(_),t.precision(v),t.precision(w)]]}}function Rh(t){return(e,i,r,n,a)=>{const s=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?a=n:n!==void 0&&(l=y.from(n).get(0)),t.taState||(t.taState={});const c=a||`kcw_${s}_${o}_${l}`;t.taState[c]||(t.taState[c]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const h=t.taState[c];t.idx>h.lastIdx&&(h.lastIdx>=0&&(h.basisState={...h.currentBasisState},h.rangeState={...h.currentRangeState}),h.lastIdx=t.idx);const p=(w,E,A,C)=>{if(isNaN(A))return Object.assign(E,w),E.prevEma!==null?E.prevEma:NaN;let M=w.initCount,V=w.initSum,$=w.prevEma;if(M<C){if(V+=A,M++,E.initSum=V,E.initCount=M,E.prevEma=$,M===C){const q=V/C;return E.prevEma=q,q}return NaN}const F=2/(C+1),D=A*F+$*(1-F);return E.prevEma=D,E.initSum=V,E.initCount=M,D};let u;const f=t.get(t.data.high,0),m=t.get(t.data.low,0);if(l){const w=t.get(t.data.close,1);isNaN(w)?u=NaN:u=Math.max(f-m,Math.abs(f-w),Math.abs(m-w))}else u=f-m;const x=y.from(e).get(0),_=p(h.basisState,h.currentBasisState,x,s),b=p(h.rangeState,h.currentRangeState,u,s);if(isNaN(_)||isNaN(b))return NaN;if(_===0)return t.precision(0);const v=2*b*o/_;return t.precision(v)}}function Oh(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0),h=[...l.prevWindow];for(h.unshift(c);h.length>a;)h.pop();const p=l.prevCallCount+1;if(h.length<a&&(p>=a||t.idx>=a-1)){const E=y.from(e);for(;h.length<a;)h.push(E.get(h.length))}if(l.currentWindow=h,l.currentCallCount=p,h.length<a)return NaN;let u=0,f=0,m=0,x=0;const _=a;for(let E=0;E<a;E++){const A=a-1-E,C=h[E];u+=A,f+=C,m+=A*C,x+=A*A}const b=_*x-u*u;if(b===0)return NaN;const v=(_*m-u*f)/b,w=(f-v*u)/_+v*(a-1-s);return t.precision(w)}}function Vh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`lowest_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const u=y.from(e);for(;l.length<n;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.filter(u=>!isNaN(u)&&u!==void 0);if(h.length===0)return NaN;const p=Math.min(...h);return t.precision(p)}}function Lh(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);if(t.idx<n-1)return NaN;let s=1/0,o=NaN;for(let l=0;l<n;l++){const c=a.get(l);isNaN(c)||(isNaN(o)||c<s)&&(s=c,o=-l)}return o}}function Bh(t){return(e,i,r,n,a)=>{const s=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0),c=a||`macd_${s}_${o}_${l}`,h=`${c}_fast`,p=`${c}_slow`,u=`${c}_signal`,f=t.pine.ta.ema(e,s,h),m=t.pine.ta.ema(e,o,p);let x=NaN;!isNaN(f)&&!isNaN(m)&&(x=f-m);let _=NaN;isNaN(x)||(_=t.pine.ta.ema(x,l,u));let b=NaN;return!isNaN(x)&&!isNaN(_)&&(b=x-_),[[t.precision(x),t.precision(_),t.precision(b)]]}}function jh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`median_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;const h=l.slice().sort((f,m)=>f-m),p=Math.floor(n/2),u=n%2===0?(h[p-1]+h[p])/2:h[p];return t.precision(u)}}function Fh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`mfi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevUpperWindow=[...s.currentUpperWindow],s.prevLowerWindow=[...s.currentLowerWindow],s.prevUpperSum=s.currentUpperSum,s.prevLowerSum=s.currentLowerSum),s.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const h=isNaN(l)?NaN:o-l,p=c*(h<=0?0:o),u=c*(h>=0?0:o),f=[...s.prevUpperWindow],m=[...s.prevLowerWindow];let x=s.prevUpperSum,_=s.prevLowerSum;if(f.unshift(p),m.unshift(u),x+=p,_+=u,f.length<n)return s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=x,s.currentLowerSum=_,NaN;if(f.length>n){const v=f.pop(),w=m.pop();x-=v,_-=w}if(s.currentUpperWindow=f,s.currentLowerWindow=m,s.currentUpperSum=x,s.currentLowerSum=_,_===0)return t.precision(100);if(x===0)return t.precision(0);const b=100-100/(1+x/_);return t.precision(b)}}function $h(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);if(t.idx<n-1)return NaN;const s=new Map;for(let c=0;c<n;c++){const h=a.get(c);isNaN(h)||s.set(h,(s.get(h)||0)+1)}if(s.size===0)return NaN;let o=NaN,l=-1;for(const[c,h]of s.entries())h>l?(l=h,o=c):h===l&&c<o&&(o=c);return o}}function Wh(t){return(e,i,r)=>{const n=y.from(i).get(0);return t.pine.ta.change(e,n,r)}}function Uh(t){return e=>{t.taState||(t.taState={});const i=e||"nvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedNVI:1,tentativeNVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedNVI=r.tentativeNVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,h=isNaN(s)?0:s,p=isNaN(o)?0:o;let u=r.committedNVI;if(!(l===0||c===0)&&h<p){const f=(l-c)/c;u=u+f*u}return r.tentativeNVI=u,t.precision(u)}}function qh(t){return()=>{t.taState||(t.taState={});const e="obv";t.taState[e]||(t.taState[e]={lastIdx:-1,committedOBV:0,tentativeOBV:0});const i=t.taState[e];t.idx>i.lastIdx&&(i.lastIdx>=0&&(i.committedOBV=i.tentativeOBV),i.lastIdx=t.idx);const r=t.get(t.data.close,0),n=t.get(t.data.volume,0),a=t.get(t.data.close,1);if(isNaN(a))return i.tentativeOBV=0,t.precision(0);let s=i.committedOBV;return r>a?s+=n:r<a&&(s-=n),i.tentativeOBV=s,t.precision(s)}}function zh(t){return(e,i,r)=>e instanceof y?i?new y(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function Kh(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0),o=y.from(e);if(t.idx<a-1)return NaN;const l=[];for(let m=0;m<a;m++){const x=o.get(m);if(isNaN(x))return NaN;l.push(x)}l.sort((m,x)=>m-x);let c=s/100*a-.5;c<0&&(c=0),c>a-1&&(c=a-1);const h=Math.floor(c),p=Math.ceil(c);if(h===p)return t.precision(l[h]);const u=c-h,f=l[h]+u*(l[p]-l[h]);return t.precision(f)}}function Hh(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0),o=y.from(e);if(t.idx<a-1)return NaN;const l=[];for(let h=0;h<a;h++){const p=o.get(h);isNaN(p)||l.push(p)}if(l.length===0)return NaN;l.sort((h,p)=>h-p);let c=Math.ceil(s/100*l.length)-1;return c<0&&(c=0),c>=l.length&&(c=l.length-1),t.precision(l[c])}}function Gh(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);if(t.idx<n)return NaN;const s=a.get(0);if(isNaN(s))return NaN;let o=0,l=0;for(let c=1;c<=n;c++){const h=a.get(c);isNaN(h)||(l++,h<=s&&o++)}return l===0?NaN:t.precision(o/l*100)}}function Yh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]>=a){s=!1;break}}s&&(r[n]=a)}return r}function Xh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const a=y.from(i).get(0),s=y.from(r).get(0),o=y.from(e).toArray(),l=Yh(o,a,s),c=t.idx;return t.precision(l[c])}}function Qh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const a=t[n-i];let s=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=a){s=!1;break}if(s){for(let o=1;o<=i;o++)if(t[n-i+o]<=a){s=!1;break}}s&&(r[n]=a)}return r}function Zh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const a=y.from(i).get(0),s=y.from(r).get(0),o=y.from(e).toArray(),l=Qh(o,a,s),c=t.idx;return t.precision(l[c])}}function Jh(t){return e=>{t.taState||(t.taState={});const i=e||"pvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedPVI:1,tentativePVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedPVI=r.tentativePVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(a)?0:a,h=isNaN(s)?0:s,p=isNaN(o)?0:o;let u=r.committedPVI;if(!(l===0||c===0)&&h>p){const f=(l-c)/c;u=u+f*u}return r.tentativePVI=u,t.precision(u)}}function eu(t){return e=>{t.taState||(t.taState={});const i=e||"pvt";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.close,1),s=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(a)&&!isNaN(s)&&a!==0){const l=(n-a)/a*s;o+=l}return r.currentCumulativeSum=o,t.precision(o)}}function tu(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),a=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(a)?NaN:t.precision(n-a)}}function iu(t){return(e,i,r)=>{const n=y.from(i).get(0),a=y.from(e);for(let s=0;s<n;s++){const o=a.get(s),l=a.get(s+1);if(isNaN(o)||isNaN(l)||o<=l)return!1}return!0}}function ru(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`rma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevRma=s.currentRma,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const o=y.from(e).get(0)||0;let l=s.prevInitCount,c=s.prevInitSum,h=s.prevRma;if(l<n){if(c+=o,l++,s.currentInitSum=c,s.currentInitCount=l,l===n){const f=c/n;return s.currentRma=f,t.precision(f)}return NaN}const p=1/n,u=o*p+h*(1-p);return s.currentRma=u,t.precision(u)}}function nu(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`roc_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=s.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const u=y.from(e);for(;l.length<n+1;)l.push(u.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<=n)return NaN;const h=l[n],p=(o-h)/h*100;return t.precision(p)}}function su(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`rsi_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevPrevValue:null,prevAvgGain:0,prevAvgLoss:0,prevInitGains:[],prevInitLosses:[],currentPrevValue:null,currentAvgGain:0,currentAvgLoss:0,currentInitGains:[],currentInitLosses:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevPrevValue=s.currentPrevValue,s.prevAvgGain=s.currentAvgGain,s.prevAvgLoss=s.currentAvgLoss,s.prevInitGains=[...s.currentInitGains],s.prevInitLosses=[...s.currentInitLosses]),s.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;const l=s.prevPrevValue;if(l===null||isNaN(l))return s.currentPrevValue=o,s.currentInitGains=[...s.prevInitGains],s.currentInitLosses=[...s.prevInitLosses],s.currentAvgGain=s.prevAvgGain,s.currentAvgLoss=s.prevAvgLoss,NaN;let c=s.prevAvgGain,h=s.prevAvgLoss;const p=[...s.prevInitGains],u=[...s.prevInitLosses],f=o-l,m=f>0?f:0,x=f<0?-f:0;if(p.length<n){if(p.push(m),u.push(x),s.currentInitGains=p,s.currentInitLosses=u,s.currentPrevValue=o,p.length===n){c=p.reduce((v,w)=>v+w,0)/n,h=u.reduce((v,w)=>v+w,0)/n,s.currentAvgGain=c,s.currentAvgLoss=h;const b=h===0?100:100-100/(1+c/h);return t.precision(b)}return NaN}c=(c*(n-1)+m)/n,h=(h*(n-1)+x)/n,s.currentAvgGain=c,s.currentAvgLoss=h,s.currentPrevValue=o;const _=h===0?100:100-100/(1+c/h);return t.precision(_)}}function au(t){return(e,i,r,n)=>{const a=y.from(e).get(0),s=y.from(i).get(0),o=y.from(r).get(0);t.taState||(t.taState={});const l=n||`sar_${a}_${s}_${o}`;t.taState[l]||(t.taState[l]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const c=t.taState[l];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevResult=c.currentResult,c.prevMaxMin=c.currentMaxMin,c.prevAcceleration=c.currentAcceleration,c.prevIsBelow=c.currentIsBelow,c.prevBarIndex=c.currentBarIndex),c.lastIdx=t.idx);let h=c.prevResult,p=c.prevMaxMin,u=c.prevAcceleration,f=c.prevIsBelow,m=c.prevBarIndex;const x=t.get(t.data.high,0),_=t.get(t.data.low,0),b=t.get(t.data.close,0),v=t.get(t.data.close,1),w=t.get(t.data.high,1),E=t.get(t.data.low,1),A=t.get(t.data.high,2),C=t.get(t.data.low,2);if(isNaN(x)||isNaN(_)||isNaN(b))return c.currentResult=h,c.currentMaxMin=p,c.currentAcceleration=u,c.currentIsBelow=f,c.currentBarIndex=m,NaN;let M=!1;return m===1&&(b>v?(f=!0,p=x,h=E):(f=!1,p=_,h=w),M=!0,u=a),m>=1&&(h=h+u*(p-h),f?h>_&&(M=!0,f=!1,h=Math.max(x,p),p=_,u=a):h<x&&(M=!0,f=!0,h=Math.min(_,p),p=x,u=a),M||(f?x>p&&(p=x,u=Math.min(u+s,o)):_<p&&(p=_,u=Math.min(u+s,o))),f?(h=Math.min(h,E),m>1&&(h=Math.min(h,C))):(h=Math.max(h,w),m>1&&(h=Math.max(h,A)))),m++,c.currentResult=h,c.currentMaxMin=p,c.currentAcceleration=u,c.currentIsBelow=f,c.currentBarIndex=m,m<=1?NaN:t.precision(h)}}function ou(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`sma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevSum=s.currentSum,s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;let h=!1;if(l.length<n&&(c>=n||t.idx>=n-1)){const x=y.from(e);for(;l.length<n;)l.push(x.get(l.length));h=!0}let p;const u=o==null||Number.isNaN(o);let f=!Number.isNaN(s.prevSum)&&!u&&!h;if(f){let x=s.prevSum+o;if(s.prevWindow.length>=n){const _=s.prevWindow[s.prevWindow.length-1];_==null||Number.isNaN(_)?f=!1:x-=_}f&&(p=x)}if(!f){p=0;let x=!1;for(const _ of l){if(_==null||Number.isNaN(_)){x=!0;break}p+=_}x&&(p=NaN)}if(s.currentWindow=l,s.currentSum=p,s.currentCallCount=c,l.length<n)return NaN;const m=p/n;return t.precision(m)}}function lu(t){return(e,i,r=!0,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum,l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0);if(c==null||isNaN(c))return NaN;const h=[...l.prevWindow];let p=l.prevSum;for(h.unshift(c),p+=c;h.length>a;){const b=h.pop();p-=b}const u=l.prevCallCount+1;if(h.length<a&&(u>=a||t.idx>=a-1)){const b=y.from(e);for(;h.length<a;){const v=b.get(h.length);if(v==null||isNaN(v))break;h.push(v),p+=v}}if(l.currentWindow=h,l.currentSum=p,l.currentCallCount=u,h.length<a)return NaN;const f=p/a;let m=0;for(let b=0;b<a;b++)m+=Math.pow(h[b]-f,2);const x=s?a:a-1,_=Math.sqrt(m/x);return t.precision(_)}}function cu(t){return(e,i,r,n,a)=>{const s=y.from(n).get(0);t.taState||(t.taState={});const o=a||`stoch_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevHighWindow=[...l.currentHighWindow],l.prevLowWindow=[...l.currentLowWindow]),l.lastIdx=t.idx);const c=y.from(e).get(0),h=y.from(i).get(0),p=y.from(r).get(0);if(isNaN(c)||isNaN(h)||isNaN(p))return l.currentHighWindow=[...l.prevHighWindow],l.currentLowWindow=[...l.prevLowWindow],NaN;const u=[...l.prevHighWindow],f=[...l.prevLowWindow];if(u.unshift(h),f.unshift(p),u.length>s&&(u.pop(),f.pop()),l.currentHighWindow=u,l.currentLowWindow=f,u.length<s)return NaN;let m=u[0],x=f[0];for(let v=1;v<s;v++)u[v]>m&&(m=u[v]),f[v]<x&&(x=f[v]);const _=m-x;if(_===0)return NaN;const b=100*(c-x)/_;return t.precision(b)}}function hu(t){return(e,i,r)=>{const n=y.from(e).get(0),a=y.from(i).get(0);t.taState||(t.taState={});const s=r||`supertrend_${n}_${a}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevTrSum:0,prevAtrValue:NaN,prevAtrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,currentTrSum:0,currentAtrValue:NaN,currentAtrCount:0,currentLowerBand:NaN,currentUpperBand:NaN,currentSuperTrend:NaN,currentDirection:NaN});const o=t.taState[s];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrSum=o.currentTrSum,o.prevAtrValue=o.currentAtrValue,o.prevAtrCount=o.currentAtrCount,o.prevLowerBand=o.currentLowerBand,o.prevUpperBand=o.currentUpperBand,o.prevSuperTrend=o.currentSuperTrend,o.prevDirection=o.currentDirection),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),h=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(h))return[[NaN,NaN]];const p=(l+c)/2,u=t.idx>0?t.get(t.data.close,1):NaN;let f;isNaN(u)?f=l-c:f=Math.max(l-c,Math.abs(l-u),Math.abs(c-u));let m=o.prevAtrCount,x=o.prevTrSum,_=o.prevAtrValue;m++,m<=a?(x+=f,m===a&&(_=x/a)):_=(_*(a-1)+f)/a;const b=_;if(o.currentAtrCount=m,o.currentTrSum=x,o.currentAtrValue=_,isNaN(b))return[[NaN,NaN]];let v=p+n*b,w=p-n*b;const E=isNaN(o.prevLowerBand)?0:o.prevLowerBand,A=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||w>E||u<E||(w=E),isNaN(o.prevUpperBand)||v<A||u>A||(v=A);let C,M;const V=o.prevSuperTrend;return m===a?C=1:V===o.prevUpperBand?C=h>v?-1:1:C=h<w?1:-1,M=C===-1?w:v,o.currentLowerBand=w,o.currentUpperBand=v,o.currentSuperTrend=M,o.currentDirection=C,[[t.precision(M),C]]}}function uu(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const a=i||"swma";t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],currentWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow]),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>4;)l.pop();if(l.length<4&&t.idx>=3){const h=y.from(e);for(;l.length<4;)l.push(h.get(l.length))}if(s.currentWindow=l,l.length<4)return NaN;let c=0;for(let h=0;h<4;h++)c+=r[h]*l[3-h];return c/=n,t.precision(c)}}function pu(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=y.from(e).get(0));const n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.close,1);if(isNaN(s))return r?t.precision(n-a):NaN;const o=Math.max(n-a,Math.abs(n-s),Math.abs(a-s));return t.precision(o)}}function fu(t){return(e,i,r,n)=>{const a=y.from(i).get(0),s=y.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${a}_${s}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevSource:NaN,prevEma1PcValue:NaN,prevEma1PcCount:0,prevEma1PcSum:0,prevEma2PcValue:NaN,prevEma2PcCount:0,prevEma2PcSum:0,prevEma1AbsValue:NaN,prevEma1AbsCount:0,prevEma1AbsSum:0,prevEma2AbsValue:NaN,prevEma2AbsCount:0,prevEma2AbsSum:0,currentSource:NaN,currentEma1PcValue:NaN,currentEma1PcCount:0,currentEma1PcSum:0,currentEma2PcValue:NaN,currentEma2PcCount:0,currentEma2PcSum:0,currentEma1AbsValue:NaN,currentEma1AbsCount:0,currentEma1AbsSum:0,currentEma2AbsValue:NaN,currentEma2AbsCount:0,currentEma2AbsSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevSource=l.currentSource,l.prevEma1PcValue=l.currentEma1PcValue,l.prevEma1PcCount=l.currentEma1PcCount,l.prevEma1PcSum=l.currentEma1PcSum,l.prevEma2PcValue=l.currentEma2PcValue,l.prevEma2PcCount=l.currentEma2PcCount,l.prevEma2PcSum=l.currentEma2PcSum,l.prevEma1AbsValue=l.currentEma1AbsValue,l.prevEma1AbsCount=l.currentEma1AbsCount,l.prevEma1AbsSum=l.currentEma1AbsSum,l.prevEma2AbsValue=l.currentEma2AbsValue,l.prevEma2AbsCount=l.currentEma2AbsCount,l.prevEma2AbsSum=l.currentEma2AbsSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return NaN;const h=isNaN(l.prevSource)?NaN:c-l.prevSource;if(l.currentSource=c,isNaN(h))return NaN;const p=Math.abs(h),u=2/(s+1),f=2/(a+1),m=2/(s+1),x=2/(a+1);let _=l.prevEma1PcCount,b=l.prevEma1PcSum,v=l.prevEma1PcValue;_++,_<=s?(b+=h,_===s&&(v=b/s)):v=h*u+v*(1-u);let w=l.prevEma1AbsCount,E=l.prevEma1AbsSum,A=l.prevEma1AbsValue;if(w++,w<=s?(E+=p,w===s&&(A=E/s)):A=p*m+A*(1-m),isNaN(v)||isNaN(A))return l.currentEma1PcCount=_,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=E,l.currentEma1AbsValue=A,NaN;let C=l.prevEma2PcCount,M=l.prevEma2PcSum,V=l.prevEma2PcValue;C++,C<=a?(M+=v,C===a&&(V=M/a)):V=v*f+V*(1-f);let $=l.prevEma2AbsCount,F=l.prevEma2AbsSum,D=l.prevEma2AbsValue;if($++,$<=a?(F+=A,$===a&&(D=F/a)):D=A*x+D*(1-x),l.currentEma1PcCount=_,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=E,l.currentEma1AbsValue=A,l.currentEma2PcCount=C,l.currentEma2PcSum=M,l.currentEma2PcValue=V,l.currentEma2AbsCount=$,l.currentEma2AbsSum=F,l.currentEma2AbsValue=D,isNaN(V)||isNaN(D))return NaN;if(D===0)return t.precision(0);const q=V/D;return t.precision(q)}}function du(t){return(e,i,r,n)=>{t.taState||(t.taState={});const a=n||"valuewhen";t.taState[a]||(t.taState[a]={lastIdx:-1,prevValues:[],currentValues:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevValues=[...s.currentValues]),s.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(i).get(0),c=y.from(r).get(0),h=[...s.prevValues];if(o&&h.push(l),s.currentValues=h,isNaN(c)||c<0)return NaN;const p=h.length-1-c;if(p<0)return NaN;const u=h[p];return typeof u=="number"?t.precision(u):u}}function mu(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`variance_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;)l.push(m.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let h=0,p=0;for(let m=0;m<n;m++)h+=l[m],p+=l[m]*l[m];const u=h/n,f=p/n-u*u;return t.precision(f)}}function gu(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"vwap";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativePV:0,prevCumulativeVolume:0,prevLastSessionDate:null,currentCumulativePV:0,currentCumulativeVolume:0,currentLastSessionDate:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const a=y.from(e).get(0),s=y.from(t.data.volume).get(0),o=y.from(t.data.openTime).get(0),l=t.pine?.syminfo?.timezone||"UTC",c=ft(o,l),h=`${c.year}-${String(c.month).padStart(2,"0")}-${String(c.day).padStart(2,"0")}`;let p=n.prevCumulativePV,u=n.prevCumulativeVolume,f=n.prevLastSessionDate;if(f!==h&&(p=0,u=0,f=h),p+=a*s,u+=s,n.currentCumulativePV=p,n.currentCumulativeVolume=u,n.currentLastSessionDate=f,u===0)return NaN;const m=p/u;return t.precision(m)}}function yu(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`vwma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevVolumeWindow=[...s.currentVolumeWindow]),s.lastIdx=t.idx);const o=y.from(e).get(0),l=t.get(t.data.volume,0),c=[...s.prevWindow],h=[...s.prevVolumeWindow];for(c.unshift(o),h.unshift(l);c.length>n;)c.pop(),h.pop();if(c.length<n&&t.idx>=n-1){const m=y.from(e),x=y.from(t.data.volume);for(;c.length<n;)c.push(m.get(c.length)),h.push(x.get(h.length))}if(s.currentWindow=c,s.currentVolumeWindow=h,c.length<n)return NaN;let p=0,u=0;for(let m=0;m<n;m++)p+=c[m]*h[m],u+=h[m];const f=p/u;return t.precision(f)}}function xu(t){return e=>{t.taState||(t.taState={});const i=e||"wad";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),a=t.get(t.data.high,0),s=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(a)||isNaN(s))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let l=0;if(!isNaN(o)){const h=Math.max(a,o),p=Math.min(s,o),u=n-o;u>0?l=n-p:u<0&&(l=n-h)}const c=r.prevCumulativeSum+l;return r.currentCumulativeSum=c,t.precision(c)}}function _u(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const a=r||`wma_${n}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const s=t.taState[a];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevWindow=[...s.currentWindow],s.prevCallCount=s.currentCallCount),s.lastIdx=t.idx);const o=y.from(e).get(0),l=[...s.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=s.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(s.currentWindow=l,s.currentCallCount=c,l.length<n)return NaN;let h=0,p=0;for(let f=0;f<n;f++){const m=n-f;h+=l[f]*m,p+=m}const u=h/p;return t.precision(u)}}function bu(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const a=t.taState[n];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevHighWindow=[...a.currentHighWindow],a.prevLowWindow=[...a.currentLowWindow]),a.lastIdx=t.idx);const s=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(s)||isNaN(o)||isNaN(l))return a.currentHighWindow=[...a.prevHighWindow],a.currentLowWindow=[...a.prevLowWindow],NaN;const c=[...a.prevHighWindow],h=[...a.prevLowWindow];if(c.unshift(s),h.unshift(o),c.length>r&&(c.pop(),h.pop()),a.currentHighWindow=c,a.currentLowWindow=h,c.length<r)return NaN;let p=c[0],u=h[0];for(let x=1;x<r;x++)c[x]>p&&(p=c[x]),h[x]<u&&(u=h[x]);const f=p-u;if(f===0)return t.precision(0);const m=(p-l)/f*-100;return t.precision(m)}}function wu(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),a=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(a)||isNaN(s))return NaN;const o=n-a;if(o===0)return t.precision(0);const l=(i-r)/o*s;return t.precision(l)}}const vu={accdist:hh,alma:uh,atr:ph,barssince:fh,bb:dh,bbw:mh,cci:gh,change:yh,cmo:xh,cog:_h,correlation:bh,cross:wh,crossover:vh,crossunder:Sh,cum:Eh,dev:Nh,dmi:Ch,ema:Ih,falling:kh,highest:Ah,highestbars:Th,hma:Ph,iii:Dh,kc:Mh,kcw:Rh,linreg:Oh,lowest:Vh,lowestbars:Lh,macd:Bh,median:jh,mfi:Fh,mode:$h,mom:Wh,nvi:Uh,obv:qh,param:zh,percentile_linear_interpolation:Kh,percentile_nearest_rank:Hh,percentrank:Gh,pivothigh:Xh,pivotlow:Zh,pvi:Jh,pvt:eu,range:tu,rising:iu,rma:ru,roc:nu,rsi:su,sar:au,sma:ou,stdev:lu,stoch:cu,supertrend:hu,swma:uu,tr:pu,tsi:fu,valuewhen:du,variance:mu,vwap:gu,vwma:yu,wad:xu,wma:_u,wpr:bu,wvad:wu};class Su{constructor(e){this.context=e,Object.entries(vu).forEach(([i,r])=>{this[i]=r(e)})}accdist;alma;atr;barssince;bb;bbw;cci;change;cmo;cog;correlation;cross;crossover;crossunder;cum;dev;dmi;ema;falling;highest;highestbars;hma;iii;kc;kcw;linreg;lowest;lowestbars;macd;median;mfi;mode;mom;nvi;obv;param;percentile_linear_interpolation;percentile_nearest_rank;percentrank;pivothigh;pivotlow;pvi;pvt;range;rising;rma;roc;rsi;sar;sma;stdev;stoch;supertrend;swma;tr;tsi;valuewhen;variance;vwap;vwma;wad;wma;wpr;wvad}function Eu(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC")return 0;const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const s=r[1]==="+"?1:-1,o=parseInt(r[2],10),l=parseInt(r[3]||"0",10);return s*(o*60+l)}const n=ft(t,e),a=new Date(Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second));return Math.round((a.getTime()-t)/6e4)}function Nu(t,e){const i=e>=0?"+":"-",r=a=>String(Math.floor(Math.abs(a))).padStart(2,"0"),n=i+r(e/60)+":"+r(e%60);return`[${new Date(t+e*6e4).toISOString().slice(0,-1)}${n}]`}class Cu{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return y.from(e).get(i)}_formatTimestamp(){const e=this.context.data.openTime.data[this.context.idx],i=this.context.chartTimezone||this.context.pine?.syminfo?.timezone||"UTC",r=Eu(e,i);return Nu(e,r)}warning(e,...i){this.context.isSecondaryContext||console.warn(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}error(e,...i){this.context.isSecondaryContext||console.error(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}info(e,...i){this.context.isSecondaryContext||console.log(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}}class Iu{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}tostring(e,i){if(typeof e!="number"||isNaN(e)||!i)return String(e);if(i==="mintick"){const n=this.context.pine?.syminfo?.mintick||.01,a=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(a)}if(i==="integer")return String(Math.round(e));if(i==="percent")return(e*100).toFixed(2)+"%";if(i==="price"){const n=this.context.pine?.syminfo?.mintick||.01,a=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(a)}if(i==="volume")return String(Math.round(e));const r=i.indexOf(".");if(r>=0){const n=i.substring(r+1).length;return e.toFixed(n)}return i.includes("#")||i.includes("0")?String(Math.round(e)):String(e)}tonumber(e){return Number(e)}lower(e){return String(e).toLowerCase()}upper(e){return String(e).toUpperCase()}trim(e){return String(e).trim()}repeat(e,i,r=""){return Array(i).fill(e).join(r||"")}replace_all(e,i,r){return String(e).replaceAll(i,r)}replace(e,i,r,n=0){const a=String(e),s=String(i),o=String(r),l=Math.floor(Number(n))||0;if(s==="")return a;let c=0,h=0;for(;;){const p=a.indexOf(s,c);if(p===-1)return a;if(h===l)return a.substring(0,p)+o+a.substring(p+s.length);h++,c=p+s.length}}contains(e,i){return String(e).includes(i)}endswith(e,i){return String(e).endsWith(i)}startswith(e,i){return String(e).startsWith(i)}pos(e,i){const r=String(e).indexOf(i);return r===-1?NaN:r}length(e){return String(e).length}match(e,i){return String(e).match(new RegExp(i))}split(e,i){return new R(String(e).split(i),T.string,this.context)}substring(e,i,r){return String(e).substring(i,r)}format(e,...i){return e.replace(/\{(\d+)(?:,number,([^}]+))?\}/g,(r,n,a)=>{const s=i[n];return a&&typeof s=="number"&&!isNaN(s)?this.tostring(s,a):String(s)})}}const Ot={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function cr(t){if(!t||/^\d+$/.test(t))return t;if(Ot[t])return Ot[t];const e=t.toLowerCase();if(Ot[e])return Ot[e];if(t.length===1){const r=t.toUpperCase();if(["D","W","M","S"].includes(r))return r}const i=t.slice(-1).toUpperCase();if(["D","W","M","S"].includes(i)){const r=parseInt(t);if(!isNaN(r))return r+i}return t}class ku{constructor(e){this.context=e}_normalized=null;param(e,i=0,r){return y.from(e).get(i)}get normalized(){return this._normalized===null&&(this._normalized=cr(this.context.timeframe)),this._normalized}get unit(){return this.normalized.slice(-1).toUpperCase()}get main_period(){return this.normalized}get period(){return this.normalized}get multiplier(){const e=parseInt(this.normalized);return isNaN(e)?1:e}get isdwm(){return["D","W","M"].includes(this.unit)}get isdaily(){return this.unit==="D"}get isweekly(){return this.unit==="W"}get ismonthly(){return this.unit==="M"}get isseconds(){return this.unit==="S"}get isminutes(){return/^\d+$/.test(this.normalized)}get isintraday(){return!this.isdwm}from_seconds(e){return e<60?Math.ceil(e/5)*5+"S":e<3600*24?Math.ceil(e/60):e<=3600*24*7*52?e%(3600*24*7)===0?Math.ceil(e/604800)+"W":Math.ceil(e/(3600*24))+"D":"12M"}in_seconds(e){e==null?e=this.normalized:e=cr(e);const i=e.slice(-1).toUpperCase(),r=parseInt(e);return i==="S"?isNaN(r)?1:r:i==="D"?(isNaN(r)?1:r)*60*60*24:i==="W"?(isNaN(r)?1:r)*60*60*24*7:i==="M"?(isNaN(r)?1:r)*60*60*24*30:isNaN(r)?0:r*60}}const hr=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],Au=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],Tu=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],Pu=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],Du=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],ur=["color","offset","editable","show_last","title","display","force_overlay"],Mu=["price","title","color","linestyle","linewidth","editable","display"],Ru=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],pr={series:"series",title:"string",color:"series",linewidth:"number",style:"string",trackprice:"boolean",histbase:"number",offset:"number",join:"bool",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Ou={series:"series",title:"string",style:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Vu={series:"series",title:"string",colorup:"color",colordown:"color",offset:"number",minheight:"number",maxheight:"number",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Lu={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},Bu={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",wickcolor:"color",bordercolor:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},fr={color:"color",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},ju={price:"series",title:"string",color:"color",linestyle:"string",linewidth:"number",editable:"boolean",display:"string"},Fu={plot1:"object",plot2:"object",color:"color",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class $u{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}get linestyle_dashed(){return"linestyle_dashed"}get linestyle_dotted(){return"linestyle_dotted"}get linestyle_solid(){return"linestyle_solid"}get style_area(){return"style_area"}get style_areabr(){return"style_areabr"}get style_circles(){return"style_circles"}get style_columns(){return"style_columns"}get style_cross(){return"style_cross"}get style_histogram(){return"style_histogram"}get style_line(){return"style_line"}get style_linebr(){return"style_linebr"}get style_stepline(){return"style_stepline"}get style_stepline_diamond(){return"style_stepline_diamond"}get style_steplinebr(){return"style_steplinebr"}param(e,i=0,r){return y.from(e).get(i)}plotchar(...e){const i=ke(e),r=X(e,hr,pr),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);this.context.plots[l]||(this.context.plots[l]={data:[],options:{...o,style:"char"},title:a,_plotKey:l,_callsiteId:i});const c=y.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c}),this.context.plots[l]}any(...e){const i=ke(e),r=X(e,hr,pr),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,overlay:u},title:a,_plotKey:l,_callsiteId:i}}const c=y.from(n).get(0),h=o.color,p={color:"color"in s?typeof h=="string"?h:void 0:h||"#2962ff"};return"offset"in s&&(p.offset=o.offset),this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:p}),this.context.plots[l]}plotshape(...e){const i=ke(e),r=X(e,Au,Ou),{series:n,title:a,...s}=r,o=this.extractPlotOptions(s),l=this._resolvePlotKey(a,i);if(!this.context.plots[l]){const h=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,style:"shape",shape:o.style,overlay:h},title:a,_plotKey:l,_callsiteId:i}}const c=y.from(n).get(0);return this.context.plots[l].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:c,options:o?.location==="absolute"||c?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[l]}plotarrow(...e){const i=ke(e),r=X(e,Tu,Vu),{series:n,title:a,...s}=r,o=y.from(n).get(0),l=this.extractPlotOptions(s),c=this._resolvePlotKey(a,i);if(!this.context.plots[c]){const h=l.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...l,style:"shape",overlay:h},title:a,_plotKey:c,_callsiteId:i}}return this.context.plots[c].data.push({title:a,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?l.colorup:l.colordown,offset:l.offset,shape:o>0?"shape_arrow_up":"shape_arrow_down",location:o>0?"BelowBar":"AboveBar",height:l.maxheight}:void 0}),this.context.plots[c]}plotbar(...e){const i=ke(e),r=X(e,Pu,Lu),{open:n,high:a,low:s,close:o,title:l,...c}=r,h=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=h.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...h,style:"bar",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const u=[y.from(n).get(0),y.from(a).get(0),y.from(s).get(0),y.from(o).get(0)];this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:u,options:{color:h.color}})}plotcandle(...e){const i=ke(e),r=X(e,Du,Bu),{open:n,high:a,low:s,close:o,title:l,...c}=r,h=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=h.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...h,style:"candle",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const u=[y.from(n).get(0),y.from(a).get(0),y.from(s).get(0),y.from(o).get(0)];return this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:u,options:{color:h.color,wickcolor:h.wickcolor,bordercolor:h.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=ke(e),r=X(e,ur,fr),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const l=s.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...s,style:"background",overlay:l},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}})}barcolor(...e){const i=ke(e),r=X(e,ur,fr),{title:n,...a}=r,s=this.extractPlotOptions(a),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...s,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:s.color&&s.color!=="na"&&s?.color.toString()!=="NaN",options:{color:s.color}}),this.context.plots[o]}}class Wu{constructor(e){this.context=e}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=ke(e),r=X(e,Mu,ju),{price:n,title:a,color:s,linestyle:o,linewidth:l,editable:c,display:h}=r,p=[n,{title:a,color:s,linestyle:o,linewidth:l,editable:c,display:h,style:"hline"}];return i&&p.push({__callsiteId:i}),this.context.pine.plot.any(...p)}}class Uu{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=ke(e);if(e.length>=6&&typeof e[2]=="number"){const r=e[0],n=e[1],a=e[2],s=e[3],o=e[4],l=e[5],c=e.length>6&&typeof e[6]=="string"?e[6]:void 0,h=r?._plotKey||r?.title,p=n?._plotKey||n?.title;let u=c||"fill";const f=this.context.plots[u];f&&i&&f._callsiteId!==i&&(u=i),this.context.plots[u]||(this.context.plots[u]={title:c||"Fill",plot1:h,plot2:p,data:[],options:{plot1:h,plot2:p,style:"fill",gradient:!0},_plotKey:u,_callsiteId:i}),this.context.plots[u].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{top_value:a,bottom_value:s,top_color:o,bottom_color:l}})}else{const r=X(e,Ru,Fu),{plot1:n,plot2:a,color:s,title:o,editable:l,show_last:c,fillgaps:h,display:p}=r;let u=o||"fill";const f=this.context.plots[u];f&&i&&f._callsiteId!==i&&(u=i);const m=y.from(s).get(0);if(!this.context.plots[u]){const x=n?._plotKey||n?.title,_=a?._plotKey||a?.title;this.context.plots[u]={title:o||"Fill",plot1:x,plot2:_,data:[],options:{plot1:x,plot2:_,color:m,editable:l,show_last:c,fillgaps:h,display:p,style:"fill"},_plotKey:u,_callsiteId:i}}this.context.plots[u].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{color:m}})}}}class qu{constructor(e){this.context=e;const i=this.context;this.point={new(r,n,a){return new se(r,n,a??NaN)},from_index(r,n){return new se(void 0,r,n)},from_time(r,n){return new se(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,a=i.marketData[n]?.openTime;return new se(a,n,r)}}}point;param(e,i=0,r){return y.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#d1d4dc"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}let zu=0;class Pi{id;x;y;text;xloc;yloc;color;style;textcolor;size;textalign;tooltip;text_font_family;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",h="center",p="",u="default",f=!1){this.id=zu++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=a,this.color=s,this.style=o,this.textcolor=l,this.size=c,this.textalign=h,this.tooltip=p,this.text_font_family=u,this.force_overlay=f,this._deleted=!1,this._helper=null}set_x(e){this._helper?this._helper.set_x(this,e):this._deleted||(this.x=e)}set_y(e){this._helper?this._helper.set_y(this,e):this._deleted||(this.y=e)}set_xy(e,i){this._helper?this._helper.set_xy(this,e,i):this._deleted||(this.x=e,this.y=i)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_textcolor(e){this._helper?this._helper.set_textcolor(this,e):this._deleted||(this.textcolor=e)}set_size(e){this._helper?this._helper.set_size(this,e):this._deleted||(this.size=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_textalign(e){this._helper?this._helper.set_textalign(this,e):this._deleted||(this.textalign=e)}set_tooltip(e){this._helper?this._helper.set_tooltip(this,e):this._deleted||(this.tooltip=e)}set_xloc(e){this._helper?this._helper.set_xloc(this,e):this._deleted||(this.xloc=e)}set_yloc(e){this._helper?this._helper.set_yloc(this,e):this._deleted||(this.yloc=e)}set_point(e){this._helper&&this._helper.set_point(this,e)}set_text_font_family(e){this._deleted||(this.text_font_family=e)}get_x(){return this.x}get_y(){return this.y}get_text(){return this.text}delete(){this._deleted=!0}copy(){return new Pi(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay}}}const Ku=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],Hu={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"color",style:"string",textcolor:"color",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class Gu{constructor(e){this.context=e}_labels=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__labels__.data=[{time:e,value:this._labels,options:{style:"label"}}]}_resolve(e){if(e==null)return e;if(e instanceof _t)return null;if(typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"){const i=e.get(0);return typeof i=="number"&&isNaN(i)?null:i}return typeof e=="function"?e():typeof e=="number"&&isNaN(e)?null:e}_createLabel(e,i,r="",n="bi",a="pr",s="",o="style_label_down",l="",c="normal",h="center",p="",u="default",f=!1){const m=new Pi(e,i,this._resolve(r),this._resolve(n),this._resolve(a),this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c),this._resolve(h),this._resolve(p),this._resolve(u),f);return m._helper=this,m._createdAtBar=this.context.idx,this._labels.push(m),this._syncToPlot(),m}new(...e){const i=X(e,Ku,Hu);let r,n,a=i.xloc;if(i.point instanceof se){const s=i.point;s.index!==void 0?(r=s.index,a=a||"bi"):s.time!==void 0?(r=s.time,a=a||"bt"):(r=0,a=a||"bi"),n=s.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,a,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){e&&!e._deleted&&i&&(i.index!==void 0?(e.x=i.index,e.xloc="bi"):i.time!==void 0&&(e.x=i.time,e.xloc="bt"),e.y=i.price)}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._labels.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}rollbackFromBar(e){this._labels=this._labels.filter(i=>i._createdAtBar<e),this._syncToPlot()}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}let Yu=0;class Di{id;x1;y1;x2;y2;xloc;extend;color;style;width;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,h=!1){this.id=Yu++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=a,this.extend=s,this.color=o,this.style=l,this.width=c,this.force_overlay=h,this._deleted=!1,this._helper=null}set_x1(e){this._helper?this._helper.set_x1(this,e):this._deleted||(this.x1=e)}set_y1(e){this._helper?this._helper.set_y1(this,e):this._deleted||(this.y1=e)}set_x2(e){this._helper?this._helper.set_x2(this,e):this._deleted||(this.x2=e)}set_y2(e){this._helper?this._helper.set_y2(this,e):this._deleted||(this.y2=e)}set_xy1(e,i){this._helper?this._helper.set_xy1(this,e,i):this._deleted||(this.x1=e,this.y1=i)}set_xy2(e,i){this._helper?this._helper.set_xy2(this,e,i):this._deleted||(this.x2=e,this.y2=i)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_width(e){this._helper?this._helper.set_width(this,e):this._deleted||(this.width=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.x1=e,this.x2=i,this.xloc=r)}set_first_point(e){this._helper&&this._helper.set_first_point(this,e)}set_second_point(e){this._helper&&this._helper.set_second_point(this,e)}get_x1(){return this.x1}get_y1(){return this.y1}get_x2(){return this.x2}get_y2(){return this.y2}get_price(e){return this._helper?this._helper.get_price(this,e):NaN}delete(){this._deleted=!0}copy(){return new Di(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay}}}const Xu=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],Qu={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"color",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class Zu{constructor(e){this.context=e}_lines=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__lines__.data=[{time:e,value:this._lines,options:{style:"drawing_line"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof _t?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_createLine(e,i,r,n,a="bi",s="none",o="",l="style_solid",c=1,h=!1){const p=new Di(e,i,r,n,a,this._resolve(s),this._resolve(o),this._resolve(l),this._resolve(c)||1,h);return p._helper=this,p._createdAtBar=this.context.idx,this._lines.push(p),this._syncToPlot(),p}new(...e){const i=X(e,Xu,Qu);let r,n,a,s,o=i.xloc;if(i.first_point instanceof se){const l=i.first_point,c=i.second_point,h=this._resolvePoint(l);r=h.x,n=l.price,o=o||h.xloc,c instanceof se?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=i.x1,n=i.y1,a=i.x2,s=i.y2;return this._createLine(r,n,a,s,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=i)}set_y1(e,i){e&&!e._deleted&&(e.y1=i)}set_x2(e,i){e&&!e._deleted&&(e.x2=i)}set_y2(e,i){e&&!e._deleted&&(e.y2=i)}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=i,e.y1=r)}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=i,e.y2=r)}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bi")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._lines.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}rollbackFromBar(e){this._lines=this._lines.filter(i=>i._createdAtBar<e),this._syncToPlot()}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}let Ju=0;class Mi{id;left;top;right;bottom;xloc;extend;border_color;border_style;border_width;bgcolor;text;text_color;text_size;text_halign;text_valign;text_wrap;text_font_family;text_formatting;force_overlay;_deleted;_helper;_createdAtBar=-1;constructor(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,h="#2962ff",p="",u="#000000",f="auto",m="center",x="center",_="wrap_none",b="default",v="format_none",w=!1){this.id=Ju++,this.left=e,this.top=i,this.right=r,this.bottom=n,this.xloc=a,this.extend=s,this.border_color=o,this.border_style=l,this.border_width=c,this.bgcolor=h,this.text=p,this.text_color=u,this.text_size=f,this.text_halign=m,this.text_valign=x,this.text_wrap=_,this.text_font_family=b,this.text_formatting=v,this.force_overlay=w,this._deleted=!1,this._helper=null}set_left(e){this._helper?this._helper.set_left(this,e):this._deleted||(this.left=e)}set_right(e){this._helper?this._helper.set_right(this,e):this._deleted||(this.right=e)}set_top(e){this._helper?this._helper.set_top(this,e):this._deleted||(this.top=e)}set_bottom(e){this._helper?this._helper.set_bottom(this,e):this._deleted||(this.bottom=e)}set_lefttop(e,i){this._helper?this._helper.set_lefttop(this,e,i):this._deleted||(this.left=e,this.top=i)}set_rightbottom(e,i){this._helper?this._helper.set_rightbottom(this,e,i):this._deleted||(this.right=e,this.bottom=i)}set_top_left_point(e){this._helper&&this._helper.set_top_left_point(this,e)}set_bottom_right_point(e){this._helper&&this._helper.set_bottom_right_point(this,e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.left=e,this.right=i,this.xloc=r)}set_bgcolor(e){this._helper?this._helper.set_bgcolor(this,e):this._deleted||(this.bgcolor=e)}set_border_color(e){this._helper?this._helper.set_border_color(this,e):this._deleted||(this.border_color=e)}set_border_width(e){this._helper?this._helper.set_border_width(this,e):this._deleted||(this.border_width=e)}set_border_style(e){this._helper?this._helper.set_border_style(this,e):this._deleted||(this.border_style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_text_color(e){this._helper?this._helper.set_text_color(this,e):this._deleted||(this.text_color=e)}set_text_size(e){this._helper?this._helper.set_text_size(this,e):this._deleted||(this.text_size=e)}set_text_halign(e){this._helper?this._helper.set_text_halign(this,e):this._deleted||(this.text_halign=e)}set_text_valign(e){this._helper?this._helper.set_text_valign(this,e):this._deleted||(this.text_valign=e)}set_text_wrap(e){this._helper?this._helper.set_text_wrap(this,e):this._deleted||(this.text_wrap=e)}set_text_font_family(e){this._helper?this._helper.set_text_font_family(this,e):this._deleted||(this.text_font_family=e)}set_text_formatting(e){this._helper?this._helper.set_text_formatting(this,e):this._deleted||(this.text_formatting=e)}get_left(){return this.left}get_right(){return this.right}get_top(){return this.top}get_bottom(){return this.bottom}delete(){this._deleted=!0}copy(){return new Mi(this.left,this.top,this.right,this.bottom,this.xloc,this.extend,this.border_color,this.border_style,this.border_width,this.bgcolor,this.text,this.text_color,this.text_size,this.text_halign,this.text_valign,this.text_wrap,this.text_font_family,this.text_formatting,this.force_overlay)}}const ep=[["left","top","right","bottom","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"],["top_left","bottom_right","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"]],tp={left:"number",top:"number",right:"number",bottom:"number",top_left:"point",bottom_right:"point",border_color:"color",border_width:"number",border_style:"string",extend:"string",xloc:"string",bgcolor:"color",text:"string",text_size:"string",text_color:"color",text_halign:"string",text_valign:"string",text_wrap:"string",text_font_family:"string",force_overlay:"boolean"};class ip{constructor(e){this.context=e}_boxes=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__boxes__||(this.context.plots.__boxes__={title:"__boxes__",data:[],options:{style:"drawing_box",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__boxes__.data=[{time:e,value:this._boxes,options:{style:"drawing_box"}}]}_resolvePoint(e){return e.index!==void 0?{x:e.index,xloc:"bi"}:e.time!==void 0?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof _t?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return typeof r=="number"&&isNaN(r)?NaN:r||i}_createBox(e,i,r,n,a="bi",s="none",o="#2962ff",l="style_solid",c=1,h="#2962ff",p="",u="#000000",f="auto",m="center",x="center",_="wrap_none",b="default",v="format_none",w=!1){const E=new Mi(e,i,r,n,a,this._resolve(s),this._resolveColor(o,"#2962ff"),this._resolve(l)||"style_solid",this._resolve(c)??1,this._resolveColor(h,"#2962ff"),this._resolve(p)||"",this._resolveColor(u,"#000000"),this._resolve(f)||"auto",this._resolve(m)||"center",this._resolve(x)||"center",this._resolve(_)||"wrap_none",this._resolve(b)||"default",this._resolve(v)||"format_none",w);return E._helper=this,E._createdAtBar=this.context.idx,this._boxes.push(E),this._syncToPlot(),E}new(...e){const i=X(e,ep,tp);let r,n,a,s,o=i.xloc;if(i.top_left instanceof se){const l=i.top_left,c=i.bottom_right,h=this._resolvePoint(l);r=h.x,n=l.price,o=o||h.xloc,c instanceof se?(a=this._resolvePoint(c).x,s=c.price):(a=0,s=NaN)}else r=this._resolve(i.left),n=this._resolve(i.top),a=this._resolve(i.right),s=this._resolve(i.bottom);return this._createBox(r,n,a,s,o,i.extend,i.border_color,i.border_style,i.border_width,i.bgcolor,i.text,i.text_color,i.text_size,i.text_halign,i.text_valign,i.text_wrap,i.text_font_family,void 0,i.force_overlay)}any(...e){return this.new(...e)}set_left(e,i){e&&!e._deleted&&(e.left=i)}set_right(e,i){e&&!e._deleted&&(e.right=i)}set_top(e,i){e&&!e._deleted&&(e.top=i)}set_bottom(e,i){e&&!e._deleted&&(e.bottom=i)}set_lefttop(e,i,r){e&&!e._deleted&&(e.left=i,e.top=r)}set_rightbottom(e,i,r){e&&!e._deleted&&(e.right=i,e.bottom=r)}set_top_left_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.left=r.x,e.top=i.price,e.xloc=r.xloc}}set_bottom_right_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.right=r.x,e.bottom=i.price,e.xloc=r.xloc}}set_xloc(e,i,r,n){e&&!e._deleted&&(e.left=i,e.right=r,e.xloc=n)}set_bgcolor(e,i){e&&!e._deleted&&(e.bgcolor=this._resolve(i))}set_border_color(e,i){e&&!e._deleted&&(e.border_color=this._resolve(i))}set_border_width(e,i){e&&!e._deleted&&(e.border_width=this._resolve(i)??1)}set_border_style(e,i){e&&!e._deleted&&(e.border_style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_text(e,i){e&&!e._deleted&&(e.text=this._resolve(i)||"")}set_text_color(e,i){e&&!e._deleted&&(e.text_color=this._resolve(i))}set_text_size(e,i){e&&!e._deleted&&(e.text_size=this._resolve(i))}set_text_halign(e,i){e&&!e._deleted&&(e.text_halign=this._resolve(i))}set_text_valign(e,i){e&&!e._deleted&&(e.text_valign=this._resolve(i))}set_text_wrap(e,i){e&&!e._deleted&&(e.text_wrap=this._resolve(i))}set_text_font_family(e,i){e&&!e._deleted&&(e.text_font_family=this._resolve(i))}set_text_formatting(e,i){e&&!e._deleted&&(e.text_formatting=this._resolve(i))}get_left(e){return e?e.left:NaN}get_right(e){return e?e.right:NaN}get_top(e){return e?e.top:NaN}get_bottom(e){return e?e.bottom:NaN}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._boxes.push(i),this._syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._boxes.filter(e=>!e._deleted)}rollbackFromBar(e){this._boxes=this._boxes.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let rp=0;class np{id;line1;line2;color;_deleted;_createdAtBar=-1;constructor(e,i,r){this.id=rp++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}get_line1(){return this.line1}get_line2(){return this.line2}set_color(e){this._deleted||(typeof e=="function"&&(e=e()),e&&typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"&&(e=e.get(0)),this.color=e||"")}delete(){this._deleted=!0}}class sp{constructor(e){this.context=e}_linefills=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__linefills__.data=[{time:e,value:this._linefills,options:{style:"linefill"}}]}_resolve(e){return e==null?e:e instanceof _t?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(e,i,r){const n=this._resolve(e),a=this._resolve(i),s=this._resolve(r)||"",o=new np(n,a,s);return o._createdAtBar=this.context.idx,this._linefills.push(o),this._syncToPlot(),o}any(...e){return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolve(i)||"")}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}rollbackFromBar(e){this._linefills=this._linefills.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let ap=0;class op{id;points;curved;closed;xloc;line_color;fill_color;line_style;line_width;force_overlay;_deleted;_createdAtBar=-1;constructor(e,i=!1,r=!1,n="bi",a="#2962ff",s="",o="style_solid",l=1,c=!1){this.id=ap++,this.points=e,this.curved=i,this.closed=r,this.xloc=n,this.line_color=a,this.fill_color=s,this.line_style=o,this.line_width=l,this.force_overlay=c,this._deleted=!1}delete(){this._deleted=!0}}class lp{constructor(e){this.context=e}_polylines=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__polylines__||(this.context.plots.__polylines__={title:"__polylines__",data:[],options:{style:"drawing_polyline",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__polylines__.data=[{time:e,value:this._polylines,options:{style:"drawing_polyline"}}]}_resolve(e){return e==null?e:e instanceof _t?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return typeof r=="number"&&isNaN(r)?NaN:r||i}_extractPoints(e){let i=this._resolve(e);const r=i&&i.array?i.array:i;return Array.isArray(r)?r.filter(n=>n instanceof se):[]}new(...e){let i,r=!1,n=!1,a="bi",s="#2962ff",o="",l="style_solid",c=1,h=!1;const p=_=>{r=_.curved??r,n=_.closed??n,a=_.xloc??a,s=_.line_color??s,o=_.fill_color??o,l=_.line_style??l,c=_.line_width??c,h=_.force_overlay??h},u=e.length>=1?e[e.length-1]:null,f=e.length>=2&&u&&typeof u=="object"&&!Array.isArray(u)&&!(u instanceof y)&&!(u instanceof se);if(e.length===1&&u&&typeof u=="object"&&!Array.isArray(u)&&"points"in u)i=u.points,p(u);else{const _=f?e.slice(0,-1):e;i=_[0],r=_[1]??r,n=_[2]??n,a=_[3]??a,s=_[4]??s,o=_[5]??o,l=_[6]??l,c=_[7]??c,h=_[8]??h,f&&p(u)}const m=this._extractPoints(i),x=new op(m,this._resolve(r)??!1,this._resolve(n)??!1,this._resolve(a)||"bi",this._resolveColor(s,"#2962ff"),this._resolveColor(o,""),this._resolve(l)||"style_solid",this._resolve(c)||1,this._resolve(h)??!1);return x._createdAtBar=this.context.idx,this._polylines.push(x),this._syncToPlot(),x}any(...e){return this.new(...e)}delete(e){e&&(e._deleted=!0)}get all(){return this._polylines.filter(e=>!e._deleted)}rollbackFromBar(e){this._polylines=this._polylines.filter(i=>i._createdAtBar<e),this._syncToPlot()}}let cp=0;class hp{id;position;columns;rows;bgcolor;frame_color;frame_width;border_color;border_width;force_overlay;_deleted;cells;merges;_helper;constructor(e="top_right",i=1,r=1,n="",a="",s=0,o="",l=0,c=!1){this.id=cp++,this.position=e,this.columns=i,this.rows=r,this.bgcolor=n,this.frame_color=a,this.frame_width=s,this.border_color=o,this.border_width=l,this.force_overlay=c,this._deleted=!1,this.merges=[],this.cells=[];for(let h=0;h<r;h++){this.cells[h]=[];for(let p=0;p<i;p++)this.cells[h][p]=null}}delete(){this._deleted=!0}setCell(e,i,r){if(i<0||i>=this.rows||e<0||e>=this.columns)return;const n=this.cells[i][e];if(n&&n._merged&&n._merge_parent){const[s,o]=n._merge_parent;if(s===e&&o===i)n._merged=!1,n._merge_parent=void 0;else{this.setCell(s,o,r);return}}const a=n||this._defaultCell();Object.assign(a,r),this.cells[i][e]=a}getCell(e,i){return i<0||i>=this.rows||e<0||e>=this.columns?null:this.cells[i][e]}clearCell(e,i){i<0||i>=this.rows||e<0||e>=this.columns||(this.cells[i][e]=null)}_setHelper(e){this._helper=e}cell(...e){return this._helper.cell(this,...e)}clear(...e){return this._helper.clear(this,...e)}merge_cells(...e){return this._helper.merge_cells(this,...e)}cell_set_text(...e){return this._helper.cell_set_text(this,...e)}cell_set_bgcolor(...e){return this._helper.cell_set_bgcolor(this,...e)}cell_set_text_color(...e){return this._helper.cell_set_text_color(this,...e)}cell_set_text_size(...e){return this._helper.cell_set_text_size(this,...e)}cell_set_height(...e){return this._helper.cell_set_height(this,...e)}cell_set_width(...e){return this._helper.cell_set_width(this,...e)}cell_set_tooltip(...e){return this._helper.cell_set_tooltip(this,...e)}cell_set_text_halign(...e){return this._helper.cell_set_text_halign(this,...e)}cell_set_text_valign(...e){return this._helper.cell_set_text_valign(this,...e)}cell_set_text_font_family(...e){return this._helper.cell_set_text_font_family(this,...e)}set_position(...e){return this._helper.set_position(this,...e)}set_bgcolor(...e){return this._helper.set_bgcolor(this,...e)}set_border_color(...e){return this._helper.set_border_color(this,...e)}set_border_width(...e){return this._helper.set_border_width(this,...e)}set_frame_color(...e){return this._helper.set_frame_color(this,...e)}set_frame_width(...e){return this._helper.set_frame_width(this,...e)}_defaultCell(){return{text:"",width:0,height:0,text_color:"#000000",text_halign:"center",text_valign:"center",text_size:"normal",bgcolor:"",tooltip:"",text_font_family:"default",_merged:!1,_merge_parent:null}}}class up{constructor(e){this.context=e}_tables=[];param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__tables__||(this.context.plots.__tables__={title:"__tables__",data:[],options:{style:"table",overlay:!0}})}_syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__tables__.data=[{time:e,value:this._tables,options:{style:"table"}}]}_resolve(e){return e==null?e:typeof e=="object"&&"__value"in e?e.__value:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(...e){let i="top_right",r=1,n=1,a="",s="",o=0,l="",c=0,h=!1;const p=e[e.length-1];if(p&&typeof p=="object"&&!Array.isArray(p)&&("bgcolor"in p||"frame_color"in p||"border_color"in p||"position"in p||"columns"in p||"rows"in p)){const f=p,m=e.slice(0,-1);i=m[0]??f.position??i,r=m[1]??f.columns??r,n=m[2]??f.rows??n,a=f.bgcolor??a,s=f.frame_color??s,o=f.frame_width??o,l=f.border_color??l,c=f.border_width??c,h=f.force_overlay??h}else i=e[0]??i,r=e[1]??r,n=e[2]??n,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,h=e[8]??h;const u=new hp(this._resolve(i)||"top_right",this._resolve(r)||1,this._resolve(n)||1,this._resolve(a)||"",this._resolve(s)||"",this._resolve(o)||0,this._resolve(l)||"",this._resolve(c)||0,this._resolve(h)??!1);return u._setHelper(this),this._tables.push(u),this._syncToPlot(),u}any(...e){return this.new(...e)}cell(...e){let i,r,n,a="",s=0,o=0,l="#000000",c="center",h="center",p="normal",u="",f="",m="default";const x=e[e.length-1];if(x&&typeof x=="object"&&!Array.isArray(x)&&("text"in x||"bgcolor"in x||"text_color"in x||"text_size"in x||"text_halign"in x||"tooltip"in x||"column"in x||"row"in x||"height"in x||"width"in x||"text_valign"in x||"text_font_family"in x)){const w=x,E=e.slice(0,-1);i=E[0],r=E.length>1?E[1]:w.column??0,n=E.length>2?E[2]:w.row??0,a=E[3]??w.text??a,s=E[4]??w.width??s,o=E[5]??w.height??o,l=E[6]??w.text_color??l,c=E[7]??w.text_halign??c,h=E[8]??w.text_valign??h,p=E[9]??w.text_size??p,u=E[10]??w.bgcolor??u,f=E[11]??w.tooltip??f,m=E[12]??w.text_font_family??m}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??a,s=e[4]??s,o=e[5]??o,l=e[6]??l,c=e[7]??c,h=e[8]??h,p=e[9]??p,u=e[10]??u,f=e[11]??f,m=e[12]??m;const _=this._resolve(i);if(!_||_._deleted)return;const b=this._resolve(r)??0,v=this._resolve(n)??0;_.setCell(b,v,{text:this._resolveText(this._resolve(a)),width:this._resolve(s)||0,height:this._resolve(o)||0,text_color:this._resolve(l)||"#000000",text_halign:this._resolve(c)||"center",text_valign:this._resolve(h)||"center",text_size:this._resolve(p)||"normal",bgcolor:this._resolve(u)||"",tooltip:this._resolveText(this._resolve(f)),text_font_family:this._resolve(m)||"default"}),this._syncToPlot()}delete(e){e&&(e._deleted=!0)}clear(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:r),s=f.end_row??(e.length>5?e[4]:n)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??r,s=e[4]??n;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,h=this._resolve(n)??0,p=this._resolve(a)??c,u=this._resolve(s)??h;for(let f=h;f<=u;f++)for(let m=c;m<=p;m++)l.clearCell(m,f);this._syncToPlot()}merge_cells(...e){let i,r,n,a,s;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,a=f.end_column??(e.length>4?e[3]:0),s=f.end_row??(e.length>5?e[4]:0)}else i=e[0],r=e[1]??0,n=e[2]??0,a=e[3]??0,s=e[4]??0;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,h=this._resolve(n)??0,p=this._resolve(a)??0,u=this._resolve(s)??0;for(let f=h;f<=u;f++)for(let m=c;m<=p;m++)f===h&&m===c||l.setCell(m,f,{_merged:!0,_merge_parent:[c,h]});l.merges.push({startCol:c,startRow:h,endCol:p,endRow:u}),this._syncToPlot()}cell_set_text(e,i,r,n){this._setCellProp(e,i,r,"text",n,!0)}cell_set_bgcolor(e,i,r,n){this._setCellProp(e,i,r,"bgcolor",n)}cell_set_text_color(e,i,r,n){this._setCellProp(e,i,r,"text_color",n)}cell_set_text_size(e,i,r,n){this._setCellProp(e,i,r,"text_size",n)}cell_set_height(e,i,r,n){this._setCellProp(e,i,r,"height",n)}cell_set_width(e,i,r,n){this._setCellProp(e,i,r,"width",n)}cell_set_tooltip(e,i,r,n){this._setCellProp(e,i,r,"tooltip",n,!0)}cell_set_text_halign(e,i,r,n){this._setCellProp(e,i,r,"text_halign",n)}cell_set_text_valign(e,i,r,n){this._setCellProp(e,i,r,"text_valign",n)}cell_set_text_font_family(e,i,r,n){this._setCellProp(e,i,r,"text_font_family",n)}set_position(e,i){const r=this._resolve(e);!r||r._deleted||(r.position=this._resolve(i)||r.position,this._syncToPlot())}set_bgcolor(e,i){const r=this._resolve(e);!r||r._deleted||(r.bgcolor=this._resolve(i)||"",this._syncToPlot())}set_border_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_color=this._resolve(i)||"",this._syncToPlot())}set_border_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_width=this._resolve(i)||0,this._syncToPlot())}set_frame_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_color=this._resolve(i)||"",this._syncToPlot())}set_frame_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_width=this._resolve(i)||0,this._syncToPlot())}get all(){return this._tables.filter(e=>!e._deleted)}_setCellProp(e,i,r,n,a,s=!1){const o=this._resolve(e);if(!o||o._deleted)return;const l=this._resolve(i)??0,c=this._resolve(r)??0,h=this._resolve(a);o.setCell(l,c,{[n]:s?this._resolveText(h):h}),this._syncToPlot()}_resolveText(e){return e==null||e!==e?"":String(e)}}class Ze{data={open:new y([]),high:new y([]),low:new y([]),close:new y([]),volume:new y([]),hl2:new y([]),hlc3:new y([]),ohlc4:new y([]),hlcc4:new y([]),bar_index:new y([])};indicator;cache={};taState={};isSecondaryContext=!1;chartTimezone=null;dataVersion=0;__maxLoops=5e5;NA=NaN;lang;length=0;_drawingHelpers=[];pine;static _deprecationWarningsShown=new Set;idx=0;params={};const={};var={};let={};lctx=new Map;result=void 0;plots={};marketData;source;tickerId;timeframe="";limit;sDate;eDate;fullContext;pineTSCode;inputs={};constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:a,sDate:s,eDate:o,fullContext:l,inputs:c}){this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=a,this.sDate=s,this.eDate=o,this.fullContext=l||this,this.inputs=c||{};const h=new Zl(this),p={Type:h.Type.bind(h),na:new _t,nz:h.nz.bind(h),indicator:h.indicator.bind(h),fixnan:h.fixnan.bind(h),alertcondition:h.alertcondition.bind(h),alert:h.alert.bind(h),error:h.error.bind(h),max_bars_back:h.max_bars_back.bind(h),timestamp:h.timestamp.bind(h),time:new ar(this,"openTime"),time_close:new ar(this,"closeTime"),dayofmonth:new Ue(this,qe.dayofmonth),dayofweek:new Ue(this,qe.dayofweek),hour:new Ue(this,qe.hour),minute:new Ue(this,qe.minute),month:new Ue(this,qe.month),second:new Ue(this,qe.second),weekofyear:new Ue(this,qe.weekofyear),year:new Ue(this,qe.year),bool:h.bool.bind(h),int:h.int.bind(h),float:h.float.bind(h),string:h.string.bind(h)},u=this;this.pine={input:new Ec(this),ta:new Su(this),math:new nh(this),request:new ch(this),array:new Mo(this),map:new Ko(this),matrix:new ql(this),syminfo:null,timeframe:new ku(this),barstate:new zl(this),get bar_index(){return u.data.bar_index},get last_bar_index(){return u.data.close.length-1},get last_bar_time(){return u.data.openTime.get(u.data.openTime.length-1)},get timenow(){return new Date().getTime()},get time_tradingday(){const $=y.from(u.data.closeTime).get(0);if(isNaN($))return NaN;const F=u.pine?.syminfo?.timezone||"UTC",D=ft($,F);return Date.UTC(D.year,D.month-1,D.day,0,0,0)},get inputs(){return u.inputs},log:new Cu(this),str:new Iu(this),...p,...uo};const f=p.dayofweek;Object.assign(f,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=f;const m=new $u(this),x=new Wu(this),_=new Uu(this);this.bindContextObject(m,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(m,["any","param","linestyle_dashed","linestyle_dotted","linestyle_solid","style_area","style_areabr","style_circles","style_columns","style_cross","style_histogram","style_line","style_linebr","style_stepline","style_stepline_diamond","style_steplinebr"],"plot"),this.bindContextObject(x,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(_,["any","param"],"fill");const b=new qu(this);this.pine.chart={param:b.param.bind(b),bg_color:b.bg_color.bind(b),fg_color:b.fg_color.bind(b),is_standard:b.is_standard.bind(b),is_heikinashi:b.is_heikinashi.bind(b),is_kagi:b.is_kagi.bind(b),is_linebreak:b.is_linebreak.bind(b),is_pnf:b.is_pnf.bind(b),is_range:b.is_range.bind(b),is_renko:b.is_renko.bind(b),point:b.point};const v=new Gu(this);this.bindContextObject(v,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>v.all});const w=new Zu(this);this.bindContextObject(w,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>w.all});const E=new ip(this);this.bindContextObject(E,["any","new","param","copy","delete","set_left","set_right","set_top","set_bottom","set_lefttop","set_rightbottom","set_top_left_point","set_bottom_right_point","set_bgcolor","set_border_color","set_border_width","set_border_style","set_extend","set_xloc","set_text","set_text_color","set_text_size","set_text_halign","set_text_valign","set_text_wrap","set_text_font_family","set_text_formatting","get_left","get_right","get_top","get_bottom"],"box"),Object.defineProperty(this.pine.box,"all",{get:()=>E.all});const A=new sp(this);this.bindContextObject(A,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>A.all});const C=new lp(this);this.bindContextObject(C,["any","new","param","delete"],"polyline"),Object.defineProperty(this.pine.polyline,"all",{get:()=>C.all}),this._drawingHelpers=[v,w,E,A,C];const M=new up(this);this.bindContextObject(M,["any","new","param","cell","delete","clear","merge_cells","cell_set_text","cell_set_bgcolor","cell_set_text_color","cell_set_text_size","cell_set_height","cell_set_width","cell_set_tooltip","cell_set_text_halign","cell_set_text_valign","cell_set_text_font_family","set_position","set_bgcolor","set_border_color","set_border_width","set_frame_color","set_frame_width"],"table"),Object.defineProperty(this.pine.table,"all",{get:()=>M.all});const V=new ec(this);this.bindContextObject(V,["any","param","new","rgb","from_gradient","r","g","b","t","aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"],"color")}rollbackDrawings(e){for(const i of this._drawingHelpers)i.rollbackFromBar(e)}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const a of i)typeof e[a]=="function"?n[a]=e[a].bind(e):n[a]=e[a]}init(e,i,r=0){let n;return i instanceof y?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof y?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new y(e)):new y([n]):new y([n])}initVar(e,i){if(e)return e;if(typeof i=="function"&&(i=i()),i instanceof ct){const n=i.__def__;for(const a in n)typeof i[a]=="function"&&(i[a]=i[a]())}let r;return i instanceof y?r=i.get(0):Array.isArray(i)?Array.isArray(i[0])?r=i[0]:r=this.precision(i[i.length-1]):r=this.precision(i),new y([r])}static PRECISION_EPSILON=10**10;precision(e,i=10){const r=i===10?Ze.PRECISION_EPSILON:10**i;return typeof e=="number"?Math.round(e*r)/r:e}param(e,i,r){return typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new y(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new y(this.params[r],i||0)))}get(e,i){if(e instanceof y)return e.get(i);if(Array.isArray(e)){const r=e.length-1-i;return r<0||r>=e.length?NaN:e[r]}return e}set(e,i){if(e instanceof y){e.set(0,typeof i=="number"?this.precision(i):i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}_callStack=[];pushId(e){this._callStack.push(e)}popId(){this._callStack.pop()}peekId(){return this._callStack.length>0?this._callStack[this._callStack.length-1]:""}peekCtx(){const e=this.peekId();if(!e)return this;let i=this.lctx.get(e);return i||(i={id:e,let:{},const:{},var:{}},this.lctx.set(e,i)),i}call(e,i,...r){this.pushId(i);try{return e(...r)}finally{this.popId()}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,fill:this.pine.fill,plotchar:this.pine.plotchar,plotshape:this.pine.plotshape,plotarrow:this.pine.plotarrow,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(e,i){const r=`${e}->${i}`;Ze._deprecationWarningsShown.has(r)||(Ze._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",e,i):console.warn(`\x1B[33m[WARNING] ${e} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}}class xi{source;inputs;constructor(e,i={}){this.source=e,this.inputs=i}}const dr={1:6e4,3:18e4,5:3e5,15:9e5,30:18e5,60:36e5,120:72e5,180:108e5,240:144e5,"4H":144e5,"1D":864e5,D:864e5,"1W":6048e5,W:6048e5,"1M":30*864e5,M:30*864e5};function pp(t){return t?dr[t]??dr[t.toUpperCase()]??864e5:864e5}class Ri{constructor(e,i,r,n,a,s){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=a,this.eDate=s,this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,a,s).then(l=>{const c=l;this.data=c;const h=c.map(C=>C.open),p=c.map(C=>C.close),u=c.map(C=>C.high),f=c.map(C=>C.low),m=c.map(C=>C.volume),x=c.map(C=>(C.high+C.low+C.close)/3),_=c.map(C=>(C.high+C.low)/2),b=c.map(C=>(C.high+C.low+C.open+C.close)/4),v=c.map(C=>(C.high+C.low+C.close+C.close)/4),w=c.map(C=>C.openTime),E=pp(this.timeframe),A=c.map(C=>C.closeTime!=null?C.closeTime:C.openTime+E);this.open=h,this.close=p,this.high=u,this.low=f,this.volume=m,this.hl2=_,this.hlc3=x,this.ohlc4=b,this.hlcc4=v,this.openTime=w,this.closeTime=A,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(C=>{this._syminfo=C,this._ready=!0,o(!0)}).catch(C=>{console.warn("Failed to get symbol info, using default values:",C),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}data=[];open=[];high=[];low=[];close=[];volume=[];hl2=[];hlc3=[];ohlc4=[];hlcc4=[];openTime=[];closeTime=[];_readyPromise=null;_ready=!1;_debugSettings={ln:!1,debug:!1};_transpiledCode=null;get transpiledCode(){return this._transpiledCode}_isSecondaryContext=!1;markAsSecondary(){this._isSecondaryContext=!0}_syminfo;_chartTimezone=null;setTimezone(e){this._chartTimezone=e}_maxLoops=5e5;setMaxLoops(e){this._maxLoops=e}setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,a,s){return Array.isArray(e)?e:e.getMarketData(i,r,n,a,s)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(e,i,r){let n,a={};if(e instanceof xi?(n=e.source,a=e.inputs||{}):n=e,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,a,i,r,s)}else return this._runComplete(n,a,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,a=i.pageSize||this.data.length;let s,o={};e instanceof xi?(s=e.source,o=e.inputs||{}):s=e;const l={data:[],error:[]};let c=!1;const h=(f,...m)=>{l[f]&&l[f].forEach(x=>x(...m))},p=(f,m)=>{l[f]||(l[f]=[]),l[f].push(m)},u=()=>{c=!0};return(async()=>{try{const f=typeof this.eDate>"u"&&!Array.isArray(this.source)&&r,m=this._runPaginated(s,o,void 0,a,f);for await(const x of m){if(c)break;if(x===null){await new Promise(_=>setTimeout(_,n));continue}if(h("data",x),f&&!c){const _=x.marketData[x.idx];_&&_.closeTime<Date.now()||await new Promise(b=>setTimeout(b,n))}}}catch(f){h("error",f)}})(),{on:p,stop:u}}async _runComplete(e,i,r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(e,i,this._isSecondaryContext);return this._transpiledCode=this._transpileCode(e),await this._executeIterations(n,this._transpiledCode,this.data.length-r,this.data.length),n}async*_runPaginated(e,i,r,n,a=!1){await this.ready(),r||(r=this.data.length);const s=this._initializeContext(e,i,this._isSecondaryContext);this._transpiledCode=this._transpileCode(e);let o=this.data.length-r;for(;;){const l=this.data.length-o;if(l>0){const p=Math.min(l,n),u=this._getResultLength(s.result);await this._executeIterations(s,this._transpiledCode,o,o+p),o+=p,yield this._createPageContext(s,u);continue}if(!a||Array.isArray(this.source))break;const{newCandles:c,updatedLastCandle:h}=await this._updateMarketData();if(c===0&&!h){yield null;continue}s.dataVersion++,s.length=this.data.length,this._removeLastResult(s),o=this.data.length-(c+1),s.rollbackDrawings(o),s.pine.barstate.setLive()}}_getResultLength(e){if(Array.isArray(e))return e.length;if(typeof e=="object"&&e!==null){const i=Object.keys(e);if(i.length>0&&Array.isArray(e[i[0]]))return e[i[0]].length}return 0}_createPageContext(e,i){const r=new Ze({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:e,inputs:e.inputs});if(r.pineTSCode=e.pineTSCode,r.idx=e.idx,Array.isArray(e.result))r.result=e.result.slice(i);else if(typeof e.result=="object"&&e.result!==null){r.result={};for(let n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}else r.result=e.result;return r.plots={...e.plots},r}async _updateMarketData(e){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const i=this.source,r=this.data.length-1,n=this.data[r].openTime;try{const a=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!a||a.length===0)return{newCandles:0,updatedLastCandle:!1};let s=!1,o=0;for(let l=0;l<a.length;l++){const c=a[l];c.openTime===n?(this._replaceCandle(r,c),s=!0):c.openTime>n&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:s}}catch(a){return console.error("Error updating market data:",a),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(e,i){this.data[e]=i,this.open[e]=i.open,this.close[e]=i.close,this.high[e]=i.high,this.low[e]=i.low,this.volume[e]=i.volume,this.hl2[e]=(i.high+i.low)/2,this.hlc3[e]=(i.high+i.low+i.close)/3,this.ohlc4[e]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[e]=(i.high+i.low+i.close+i.close)/4,this.openTime[e]=i.openTime,this.closeTime[e]=i.closeTime}_appendCandle(e){this.data.push(e),this.open.push(e.open),this.close.push(e.close),this.high.push(e.high),this.low.push(e.low),this.volume.push(e.volume),this.hl2.push((e.high+e.low)/2),this.hlc3.push((e.high+e.low+e.close)/3),this.ohlc4.push((e.high+e.low+e.open+e.close)/4),this.hlcc4.push((e.high+e.low+e.close+e.close)/4),this.openTime.push(e.openTime),this.closeTime.push(e.closeTime)}async updateTail(e){if(this.data.length===0||Array.isArray(this.source))return!1;const{newCandles:i,updatedLastCandle:r}=await this._updateMarketData();if(i===0&&!r)return!1;this._removeLastResult(e),e.length=this.data.length;const n=this.data.length-(i+1);return e.rollbackDrawings(n),await this._executeIterations(e,this._transpiledCode,n,this.data.length),!0}_removeLastResult(e){if(Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let n in e.result)Array.isArray(e.result[n])&&e.result[n].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop();const i=["const","var","let","params"],r=n=>{for(let a of i)if(n[a])for(let s in n[a]){const o=n[a][s];o instanceof y?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_initializeContext(e,i={},r=!1){const n=new Ze({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,this._chartTimezone&&(n.chartTimezone=this._chartTimezone),n.__maxLoops=this._maxLoops,n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new y([]),n.data.open=new y([]),n.data.high=new y([]),n.data.low=new y([]),n.data.volume=new y([]),n.data.hl2=new y([]),n.data.hlc3=new y([]),n.data.ohlc4=new y([]),n.data.hlcc4=new y([]),n.data.openTime=new y([]),n.data.closeTime=new y([]),n.length=this.data.length,n}_transpileCode(e){return Ca.bind(this)(e,this._debugSettings)}async _executeIterations(e,i,r,n){const a=["const","var","let","params"];for(let s=r;s<n;s++){e.idx=s,e.data.close.data.push(this.close[s]),e.data.open.data.push(this.open[s]),e.data.high.data.push(this.high[s]),e.data.low.data.push(this.low[s]),e.data.volume.data.push(this.volume[s]),e.data.hl2.data.push(this.hl2[s]),e.data.hlc3.data.push(this.hlc3[s]),e.data.ohlc4.data.push(this.ohlc4[s]),e.data.hlcc4.data.push(this.hlcc4[s]),e.data.openTime.data.push(this.openTime[s]),e.data.closeTime.data.push(this.closeTime[s]),e.data.bar_index.data.push(s);const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let c in o){e.result[c]===void 0&&(e.result[c]=[]);let h;o[c]instanceof y?h=o[c].get(0):Array.isArray(o[c])?h=o[c][o[c].length-1]:h=o[c],e.result[c].push(h)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);const l=c=>{for(let h of a)if(c[h])for(let p in c[h]){const u=c[h][p];if(u instanceof y){const f=u.get(0);u.data.push(f)}else if(Array.isArray(u)){const f=u[u.length-1];u.push(f)}}};l(e),e.lctx&&e.lctx.forEach(c=>l(c))}}}const mr={"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6},ht={"1S":1,"5S":5,"10S":10,"15S":15,"30S":30,1:60,3:180,5:300,15:900,30:1800,45:2700,60:3600,120:7200,180:10800,240:14400,D:86400,W:604800,M:2592e3},fp={"1S":{periodType:"second",multiplier:1},"5S":{periodType:"second",multiplier:5},"10S":{periodType:"second",multiplier:10},"15S":{periodType:"second",multiplier:15},"30S":{periodType:"second",multiplier:30},1:{periodType:"minute",multiplier:1},3:{periodType:"minute",multiplier:3},5:{periodType:"minute",multiplier:5},15:{periodType:"minute",multiplier:15},30:{periodType:"minute",multiplier:30},45:{periodType:"minute",multiplier:45},60:{periodType:"hour",multiplier:1},120:{periodType:"hour",multiplier:2},180:{periodType:"hour",multiplier:3},240:{periodType:"hour",multiplier:4},D:{periodType:"day",multiplier:1},W:{periodType:"week",multiplier:1},M:{periodType:"month",multiplier:1}};function ut(t,e,i=1){if(e==="month"){const n=new Date(t);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+i,1,n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),n.getUTCMilliseconds())}const r={second:1e3,minute:6e4,hour:36e5,day:864e5,week:7*864e5};return t+i*r[e]}function Ne(t,e,i){const[r,n,a]=t.split("-").map(Number),[s,o]=e.split(":").map(Number),l=Date.UTC(r,n-1,a,s,o,0,0),c=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(new Date(l)),h=b=>parseInt(c.find(v=>v.type===b).value,10);let p=h("year"),u=h("month"),f=h("day"),m=h("hour");m===24&&(m=0);let x=h("minute");const _=Date.UTC(p,u-1,f,m,x,0,0)-l;return l-_}function _i(t,e,i,r,n=1){if(e==="24x7")return ut(t,r,n);const a=e.split("-")[1];if(!a||a.length!==4)return ut(t,r,n);const s=a.slice(0,2),o=a.slice(2,4),l=`${s}:${o}`,c=gr(t,i);if(r==="second"||r==="minute"||r==="hour"){const h=t+n*{second:1e3,minute:6e4,hour:36e5}[r],p=Ne(c,l,i);return Math.min(h,p)}if(r==="day")return Ne(c,l,i);if(r==="week"){const h=new Date(t).getUTCDay(),p=h<=5?5-h:5-h+7,u=t+p*864e5,f=gr(u,i);return Ne(f,l,i)}if(r==="month"){const h=new Date(t),p=h.getUTCFullYear(),u=h.getUTCMonth()+n,f=new Date(Date.UTC(p,u,1)),m=new Date(f.getTime()-864e5);for(;m.getUTCDay()===0||m.getUTCDay()===6;)m.setUTCDate(m.getUTCDate()-1);const x=m.toISOString().split("T")[0];return Ne(x,l,i)}return ut(t,r,n)}function gr(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(t))}function dp(t){for(let e=0;e<t.length-1;e++)t[e].closeTime=t[e+1].openTime;t.length>0&&(t[t.length-1].closeTime=t[t.length-1].closeTime+1)}const mp=["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"];function Bn(t,e){if(t==="W"||t==="M")return e.has("D")?"D":null;const i=ht[t];if(!i)return null;const r=mp.filter(n=>n!=="W"&&n!=="M"&&e.has(n)&&ht[n]<i&&i%ht[n]===0);return r.length===0?null:r[r.length-1]}function Oi(t,e){if(t==="W"||t==="M")return 1/0;const i=ht[t],r=ht[e];return!i||!r||r===0?1/0:i/r}function jn(t,e,i){if(t.length===0)return[];if(e==="W")return yp(t);if(e==="M")return xp(t);const r=Oi(e,i);return gp(t,r)}function gp(t,e){if(t.length===0)return[];const i=[];let r=[t[0]];const n=_p(t),a=n>0?n*1.5:0;for(let s=1;s<t.length;s++){const o=t[s].openTime-t[s-1].openTime;(a>0&&o>a||r.length>=e)&&(i.push(qt(r)),r=[]),r.push(t[s])}return r.length>0&&i.push(qt(r)),i}function yp(t){const e=[];let i=[],r="";for(const n of t){const a=bp(n.openTime);a!==r&&i.length>0&&(e.push(i),i=[]),r=a,i.push(n)}return i.length>0&&e.push(i),e.map(qt)}function xp(t){const e=[];let i=[],r="";for(const n of t){const a=new Date(n.openTime),s=`${a.getUTCFullYear()}-${a.getUTCMonth()}`;s!==r&&i.length>0&&(e.push(i),i=[]),r=s,i.push(n)}return i.length>0&&e.push(i),e.map(qt)}function qt(t){const e=t[0],i=t[t.length-1];let r=e.high,n=e.low,a=0,s=0,o=0,l=0,c=0;for(let h=0;h<t.length;h++){const p=t[h];p.high>r&&(r=p.high),p.low<n&&(n=p.low),a+=p.volume,s+=p.quoteAssetVolume,o+=p.numberOfTrades,l+=p.takerBuyBaseAssetVolume,c+=p.takerBuyQuoteAssetVolume}return{openTime:e.openTime,open:e.open,high:r,low:n,close:i.close,volume:a,closeTime:i.closeTime,quoteAssetVolume:s,numberOfTrades:o,takerBuyBaseAssetVolume:l,takerBuyQuoteAssetVolume:c,ignore:0}}function _p(t){if(t.length<2)return 0;const e=Math.min(t.length-1,20);let i=1/0;for(let r=0;r<e;r++){const n=t[r+1].openTime-t[r].openTime;n>0&&n<i&&(i=n)}return i===1/0?0:i}function bp(t){const e=new Date(t),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1)),n=Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${n}`}const Vt={"1s":"1S","5s":"5S","10s":"10S","15s":"15S","30s":"30S","1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1D":"D","1W":"W","1M":"M","4H":"240",D:"D",W:"W",M:"M"};function wp(t){if(Vt[t]!==void 0)return Vt[t];const e=t.toLowerCase();return Vt[e]!==void 0?Vt[e]:/^\d+$/.test(t)?t:/^\d+S$/i.test(t)?t.toUpperCase():t}class Tt{_configured;_requiresApiKey;_providerName;_aggregationSubTimeframe=null;constructor(e){this._requiresApiKey=e.requiresApiKey,this._providerName=e.providerName,this._configured=!e.requiresApiKey}ensureConfigured(){if(!this._configured)throw new Error(`${this._providerName} requires configuration before use. Call Provider.${this._providerName}.configure({ apiKey: '...' }) or instantiate directly: new ${this._providerName}Provider({ apiKey: '...' })`)}configure(e){this._configured=!0}get isConfigured(){return this._configured}normalizeCloseTime(e){dp(e)}setAggregationSubTimeframe(e){this._aggregationSubTimeframe=e}getSupportedTimeframes(){return new Set(["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"])}async getMarketData(e,i,r,n,a){const s=wp(i),o=this.getSupportedTimeframes();if(o.has(s))return this._getMarketDataNative(e,s,r,n,a);const l=this._aggregationSubTimeframe,c=l&&o.has(l)?l:Bn(s,o);if(!c)return console.error(`${this._providerName}: Timeframe '${i}' is not supported and no valid sub-timeframe found for aggregation.`),[];const h=this._computeSubLimit(s,c,r),p=await this._getMarketDataNative(e,c,h,n,a);if(p.length===0)return[];const u=jn(p,s,c);return r&&r>0&&u.length>r?u.slice(u.length-r):u}_computeSubLimit(e,i,r){if(!r)return;const n=Oi(e,i);return n===1/0?e==="W"?r*7+14:e==="M"?r*31+31:r*30:Math.ceil(r*n)+Math.ceil(n)}}const si="https://api.binance.com/api/v3",yr="https://api.binance.us/api/v3",Lt={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class vp{cache;cacheDuration;constructor(e=300*1e3){this.cache=new Map,this.cacheDuration=e}generateKey(e){return Object.entries(e).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(e){const i=this.generateKey(e),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(e,i){const r=this.generateKey(e);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const e=Date.now();for(const[i,r]of this.cache.entries())e-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class Fn extends Tt{cacheManager;activeApiUrl=null;constructor(){super({requiresApiKey:!1,providerName:"Binance"}),this.cacheManager=new vp(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${si}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=si,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${yr}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=yr,this.activeApiUrl}catch{}return si}async _fetchRawChunk(e,i,r,n,a){const s=Lt[i.toUpperCase()];if(!s)return console.error(`Unsupported timeframe: ${i}`),[];let o=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${s}`;r&&(o+=`&limit=${Math.min(r,1e3)}`),n&&(o+=`&startTime=${n}`),a&&(o+=`&endTime=${a}`);const l=await fetch(o);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).map(c=>({openTime:parseInt(c[0]),open:parseFloat(c[1]),high:parseFloat(c[2]),low:parseFloat(c[3]),close:parseFloat(c[4]),volume:parseFloat(c[5]),closeTime:parseInt(c[6]),quoteAssetVolume:parseFloat(c[7]),numberOfTrades:parseInt(c[8]),takerBuyBaseAssetVolume:parseFloat(c[9]),takerBuyQuoteAssetVolume:parseFloat(c[10]),ignore:c[11]}))}async getMarketDataInterval(e,i,r,n){try{const a=Lt[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];let s=[],o=r;const l=n,c=mr[a];if(!c)return console.error(`Duration not defined for interval: ${a}`),[];for(;o<l;){const h=Math.min(o+1e3*c,l),p=await this._fetchRawChunk(e,i,1e3,o,h);if(p.length===0)break;s=s.concat(p),o=p[p.length-1].closeTime+1}return this.normalizeCloseTime(s),s}catch(a){return console.error("Error in getMarketDataInterval:",a),[]}}async getMarketDataBackwards(e,i,r,n){let a=r,s=[],o=n,l=0;const c=Math.ceil(r/1e3)+5;for(;a>0&&l<c;){l++;const h=Math.min(a,1e3),p=await this._fetchRawChunk(e,i,h,void 0,o);if(p.length===0||(s=p.concat(s),a-=p.length,o=p[0].openTime-1,p.length<h))break}return this.normalizeCloseTime(s),s}getSupportedTimeframes(){return new Set(["1","3","5","15","30","60","120","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,a){try{const s=a!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:a};if(s){const c=this.cacheManager.get(o);if(c)return c}if(!Lt[i.toUpperCase()])return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,a)){if(n&&a){const c=await this.getMarketDataInterval(e,i,n,a),h=r?c.slice(0,r):c;return this.cacheManager.set(o,h),h}else if(r&&r>1e3){const c=await this.getMarketDataBackwards(e,i,r,a);return this.cacheManager.set(o,c),c}}const l=await this._fetchRawChunk(e,i,r,n,a);return this.normalizeCloseTime(l),s&&this.cacheManager.set(o,l),l}catch(s){return console.error("Error in binance.klines:",s),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const a=Lt[e.toUpperCase()],s=mr[a];if(s)return Math.ceil((n-r)/s)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,a="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",a="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",a="Delivery");const s=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const l=(await o.json()).symbols;if(!l||l.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?l.find(w=>w.symbol===n):l[0];if(!c)return console.error(`Symbol ${n} not found in exchange info`),null;const h=c.filters?.find(w=>w.filterType==="PRICE_FILTER"),p=c.filters?.find(w=>w.filterType==="LOT_SIZE"),u=h?parseFloat(h.tickSize):.01,f=p?parseFloat(p.minQty):0,m=Math.round(1/u),x=c.baseAsset,_=c.quoteAsset,b=a?` ${a}`:"",v=`${x} / ${_}${b}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:x,description:v,type:i,main_tickerid:`BINANCE:${e}`,current_contract:a,isin:"",basecurrency:x,currency:_,timezone:"Etc/UTC",country:"",mintick:u,pricescale:m,minmove:1,pointvalue:c.contractSize||1,mincontract:f,session:"24x7",volumetype:"base",expiration_date:c.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}}const Sp="https://financialmodelingprep.com",xr={"1D":{endpoint:"/stable/historical-price-eod/full",type:"daily"},D:{endpoint:"/stable/historical-price-eod/full",type:"daily"},1:{endpoint:"/stable/historical-chart/1min",interval:"1min",type:"intraday"},5:{endpoint:"/stable/historical-chart/5min",interval:"5min",type:"intraday"},15:{endpoint:"/stable/historical-chart/15min",interval:"15min",type:"intraday"},30:{endpoint:"/stable/historical-chart/30min",interval:"30min",type:"intraday"},60:{endpoint:"/stable/historical-chart/1hour",interval:"1hour",type:"intraday"},240:{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"},"4H":{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"}},_r={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",NYSEArca:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",PNK:"America/New_York",TSX:"America/Toronto",TSXV:"America/Toronto",LSE:"Europe/London",EURONEXT:"Europe/Paris",XETRA:"Europe/Berlin",JPX:"Asia/Tokyo",HKSE:"Asia/Hong_Kong",SSE:"Asia/Shanghai",SHZ:"Asia/Shanghai",ASX:"Australia/Sydney",NSE:"Asia/Kolkata",BSE:"Asia/Kolkata",KRX:"Asia/Seoul",CRYPTO:"Etc/UTC"},br={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",NYSEArca:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",PNK:"0930-1600",TSX:"0930-1600",TSXV:"0930-1600",LSE:"0800-1630",EURONEXT:"0900-1730",XETRA:"0900-1730",JPX:"0900-1530",HKSE:"0930-1600",SSE:"0930-1500",SHZ:"0930-1500",ASX:"1000-1600",NSE:"0915-1530",BSE:"0915-1530",KRX:"0900-1530",CRYPTO:"24x7"},Ep={daily:{periodType:"day",multiplier:1},"1min":{periodType:"minute",multiplier:1},"5min":{periodType:"minute",multiplier:5},"15min":{periodType:"minute",multiplier:15},"30min":{periodType:"minute",multiplier:30},"1hour":{periodType:"hour",multiplier:1},"4hour":{periodType:"hour",multiplier:4}};class $n extends Tt{_apiKey=null;_baseUrl=Sp;_profileCache=new Map;constructor(e){super({requiresApiKey:!0,providerName:"FMP"}),e?.apiKey&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,e.baseUrl&&(this._baseUrl=e.baseUrl)}getSupportedTimeframes(){return new Set(["1","5","15","30","60","240","D"])}async _getMarketDataNative(e,i,r,n,a){this.ensureConfigured();try{const s=i.toUpperCase(),o=xr[s]||xr[i];return o?o.type==="intraday"?this._fetchIntradayData(e,o.endpoint,o.interval,n,a,r):this._fetchDailyData(e,n,a,r):(console.error(`FMP: Unsupported timeframe: ${i}`),[])}catch(s){return console.error("Error in FMPProvider.getMarketData:",s),[]}}async _fetchDailyData(e,i,r,n){let a=`${this._baseUrl}/stable/historical-price-eod/full?symbol=${e}&apikey=${this._apiKey}`;i&&(a+=`&from=${this._msToDateStr(i)}`),r&&(a+=`&to=${this._msToDateStr(r)}`);const s=await fetch(a);if(!s.ok){const p=await s.text();throw new Error(`FMP HTTP ${s.status}: ${p}`)}const o=await s.json();if(!Array.isArray(o)||o.length===0)return[];o.reverse();const l=n&&n>0&&n<o.length?o.slice(o.length-n):o,{session:c,timezone:h}=await this._resolveSessionInfo(e);return l.map(p=>{const u=this._dateStrToMs(p.date),f=_i(u,c,h,"day");return{openTime:u,open:p.open,high:p.high,low:p.low,close:p.close,volume:p.volume,closeTime:f,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async _fetchIntradayData(e,i,r,n,a,s){let o=`${this._baseUrl}${i}?symbol=${e}&apikey=${this._apiKey}`;n&&(o+=`&from=${this._msToDateStr(n)}`),a&&(o+=`&to=${this._msToDateStr(a)}`);const l=await fetch(o);if(!l.ok){const x=await l.text();if(l.status===403||x.includes("Restricted Endpoint"))return console.error(`FMP: Intraday data (${r}) requires a paid plan. Use daily timeframe ('D') with a free API key, or upgrade at https://financialmodelingprep.com/`),[];throw new Error(`FMP HTTP ${l.status}: ${x}`)}const c=await l.json();if(!Array.isArray(c)||c.length===0)return[];c.reverse();const h=s&&s>0&&s<c.length?c.slice(c.length-s):c,{periodType:p,multiplier:u}=Ep[r]||{periodType:"minute",multiplier:1},{session:f,timezone:m}=await this._resolveSessionInfo(e);return h.map(x=>{const _=this._dateTimeStrToMs(x.date),b=_i(_,f,m,p,u);return{openTime:_,open:x.open,high:x.high,low:x.low,close:x.close,volume:x.volume,closeTime:b,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async getSymbolInfo(e){this.ensureConfigured();try{const i=await this._fetchProfile(e);if(!i)return console.error(`FMP: Symbol ${e} not found`),null;const r=i.exchange||"",n=_r[r]||"America/New_York",a=br[r]||"0930-1600";let s="stock";return i.isEtf?s="etf":i.isFund?s="fund":this._isCrypto(e)?s="crypto":this._isForex(e)&&(s="forex"),{ticker:i.symbol,tickerid:`${r}:${i.symbol}`,prefix:r,root:i.symbol,description:i.companyName||i.symbol,type:s,main_tickerid:`${r}:${i.symbol}`,current_contract:"",isin:i.isin||"",basecurrency:i.currency||"USD",currency:i.currency||"USD",timezone:s==="crypto"?"Etc/UTC":n,country:i.country||"",mintick:.01,pricescale:100,minmove:1,pointvalue:1,mincontract:0,session:s==="crypto"?"24x7":a,volumetype:"base",expiration_date:0,employees:parseInt(i.fullTimeEmployees)||0,industry:i.industry||"",sector:i.sector||"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in FMPProvider.getSymbolInfo:",i),null}}async _fetchProfile(e){if(this._profileCache.has(e))return this._profileCache.get(e);const i=`${this._baseUrl}/stable/profile?symbol=${e}&apikey=${this._apiKey}`,r=await fetch(i);if(!r.ok)return null;const n=await r.json();if(!Array.isArray(n)||n.length===0)return null;const a=n[0];return this._profileCache.set(e,a),a}async _resolveSessionInfo(e){try{const i=await this._fetchProfile(e);if(i){const r=i.exchange||"",n=this._isCrypto(e),a=n?"Etc/UTC":_r[r]||"America/New_York";return{session:n?"24x7":br[r]||"0930-1600",timezone:a}}}catch{}return{session:"0930-1600",timezone:"America/New_York"}}_msToDateStr(e){return new Date(e).toISOString().split("T")[0]}_dateStrToMs(e){return new Date(e+"T00:00:00Z").getTime()}_dateTimeStrToMs(e){return new Date(e.replace(" ","T")+"Z").getTime()}_isCrypto(e){return/^[A-Z]+(USD|USDT|BTC|ETH)$/.test(e)&&e.length<=10}_isForex(e){return/^[A-Z]{6}$/.test(e)&&!this._isCrypto(e)}}const Np="https://data.alpaca.markets",Cp="https://paper-api.alpaca.markets/v2",Ip="https://api.alpaca.markets/v2",ai=1e4,wr={1:"1Min",3:"3Min",5:"5Min",15:"15Min",30:"30Min",60:"1Hour",120:"2Hour",240:"4Hour","4H":"4Hour","1D":"1Day",D:"1Day","1W":"1Week",W:"1Week","1M":"1Month",M:"1Month"},kp={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",ARCA:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",CRYPTO:"Etc/UTC"},Ap={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",ARCA:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",CRYPTO:"24x7"},Tp={Min:"minute",Hour:"hour",Day:"day",Week:"week",Month:"month"};class Wn extends Tt{_apiKey=null;_apiSecret=null;_dataUrl=Np;_tradingUrl=Cp;_feed=null;_assetCache=new Map;_calendarCache=new Map;constructor(e){super({requiresApiKey:!0,providerName:"Alpaca"}),e?.apiKey&&e?.apiSecret&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,this._apiSecret=e.apiSecret,e.feed&&(this._feed=e.feed),e.dataUrl&&(this._dataUrl=e.dataUrl),e.tradingUrl?this._tradingUrl=e.tradingUrl:e.paper===!1&&(this._tradingUrl=Ip)}_headers(){return{"APCA-API-KEY-ID":this._apiKey,"APCA-API-SECRET-KEY":this._apiSecret}}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,a){this.ensureConfigured();try{const s=this._resolveTimeframe(i);if(!s)return console.error(`Alpaca: Unsupported timeframe: ${i}`),[];const o=this._isCrypto(e),l=await this._fetchAllBars(e,s,o,n,a,r);if(l.length===0)return[];const{periodType:c,multiplier:h}=this._parseAlpacaTimeframe(s);if(o)return this._convertBarsCrypto(l,c,h);const p=l[0].t.slice(0,10),u=l[l.length-1].t.slice(0,10),f=this._addDaysToDate(u,40);return await this._ensureCalendar(p,f),this._convertBarsStock(l,c,h)}catch(s){return console.error("Error in AlpacaProvider.getMarketData:",s),[]}}async _fetchAllBars(e,i,r,n,a,s){const o=[];let l=null;const c=s||1/0,h=Math.min(s||ai,ai);do{const p=this._buildBarsUrl(e,i,r,n,a,h,l),u=await fetch(p,{headers:this._headers()});if(!u.ok){const x=await u.text();throw new Error(`Alpaca HTTP ${u.status}: ${x}`)}const f=await u.json(),m=Object.keys(f.bars||{})[0];if(!m||!f.bars[m]||(o.push(...f.bars[m]),l=f.next_page_token,o.length>=c))break}while(l);return s&&s>0&&o.length>s?o.slice(0,s):o}_buildBarsUrl(e,i,r,n,a,s,o){const l=r?`${this._dataUrl}/v1beta3/crypto/us/bars`:`${this._dataUrl}/v2/stocks/bars`,c=new URLSearchParams;return c.set("symbols",e),c.set("timeframe",i),c.set("sort","asc"),n&&c.set("start",new Date(n).toISOString()),a&&c.set("end",new Date(a).toISOString()),s&&c.set("limit",String(Math.min(s,ai))),o&&c.set("page_token",o),!r&&this._feed&&c.set("feed",this._feed),`${l}?${c.toString()}`}async getSymbolInfo(e){this.ensureConfigured();try{const i=await this._fetchAsset(e);if(!i)return console.error(`Alpaca: Symbol ${e} not found`),null;const r=i.exchange||"",n=i.class==="crypto",a=n?"Etc/UTC":kp[r]||"America/New_York",s=n?"24x7":Ap[r]||"0930-1600";let o="stock";n&&(o="crypto");const l=n&&e.split("/")[1]||"USD",c=n?e.split("/")[0]||e:l,h=i.price_increment?parseFloat(i.price_increment):.01,p=Math.round(1/h);return{ticker:i.symbol,tickerid:`${r}:${i.symbol}`,prefix:r,root:n?e.split("/")[0]:i.symbol,description:i.name||i.symbol,type:o,main_tickerid:`${r}:${i.symbol}`,current_contract:"",isin:"",basecurrency:c,currency:l,timezone:a,country:n?"":"US",mintick:h,pricescale:p,minmove:1,pointvalue:1,mincontract:i.min_order_size?parseFloat(i.min_order_size):0,session:s,volumetype:"base",expiration_date:0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in AlpacaProvider.getSymbolInfo:",i),null}}_convertBarsCrypto(e,i,r){return e.map((n,a,s)=>{const o=new Date(n.t).getTime(),l=a<s.length-1?new Date(s[a+1].t).getTime():ut(o,i,r);return this._toKline(n,o,l)})}_convertBarsStock(e,i,r){const n="America/New_York";return e.map(a=>{const s=new Date(a.t).getTime(),o=a.t.slice(0,10);let l;if(i==="day"){const c=this._calendarCache.get(o),h=c?c.close:"16:00";l=Ne(o,h,n)}else if(i==="minute"||i==="hour"){const c=s+r*{minute:6e4,hour:36e5}[i],h=this._calendarCache.get(o),p=h?h.close:"16:00",u=Ne(o,p,n);l=Math.min(c,u)}else i==="week"?l=this._weeklyCloseFromCalendar(o,n):i==="month"?l=this._monthlyCloseFromCalendar(o,n):l=ut(s,i,r);return this._toKline(a,s,l)})}_toKline(e,i,r){return{openTime:i,open:e.o,high:e.h,low:e.l,close:e.c,volume:e.v,closeTime:r,quoteAssetVolume:0,numberOfTrades:e.n,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}}_weeklyCloseFromCalendar(e,i){const r=new Date(e+"T00:00:00Z"),n=r.getUTCDay(),a=n<=5?5-n:5-n+7;for(let l=a;l>=0;l--){const c=r.getTime()+l*864e5,h=new Date(c).toISOString().split("T")[0],p=this._calendarCache.get(h);if(p)return Ne(h,p.close,i)}const s=r.getTime()+a*864e5,o=new Date(s).toISOString().split("T")[0];return Ne(o,"16:00",i)}_monthlyCloseFromCalendar(e,i){const[r,n]=e.split("-").map(Number),a=new Date(Date.UTC(r,n,0)).getUTCDate();for(let o=a;o>=1;o--){const l=`${r}-${String(n).padStart(2,"0")}-${String(o).padStart(2,"0")}`,c=this._calendarCache.get(l);if(c)return Ne(l,c.close,i)}const s=new Date(Date.UTC(r,n,0));for(;s.getUTCDay()===0||s.getUTCDay()===6;)s.setUTCDate(s.getUTCDate()-1);return Ne(s.toISOString().split("T")[0],"16:00",i)}async _ensureCalendar(e,i){if(this._calendarCache.has(e)&&this._calendarCache.has(i))return;const r=`${this._tradingUrl}/calendar?start=${e}&end=${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok){console.warn(`Alpaca calendar API returned ${n.status}, falling back to defaults`);return}const a=await n.json();for(const s of a)this._calendarCache.set(s.date,s)}async _fetchAsset(e){if(this._assetCache.has(e))return this._assetCache.get(e);const i=encodeURIComponent(e),r=`${this._tradingUrl}/assets/${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok)return null;const a=await n.json();return this._assetCache.set(e,a),a}_parseAlpacaTimeframe(e){const i=e.match(/^(\d+)(Min|Hour|Day|Week|Month)$/);if(i){const r=parseInt(i[1],10),n=Tp[i[2]];if(n)return{periodType:n,multiplier:r}}return{periodType:"day",multiplier:1}}_resolveTimeframe(e){return wr[e.toUpperCase()]||wr[e]||null}_isCrypto(e){return e.includes("/")}_addDaysToDate(e,i){const r=new Date(e+"T00:00:00Z");return r.setUTCDate(r.getUTCDate()+i),r.toISOString().split("T")[0]}}const Pp=zn.fileURLToPath(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||new URL("pinets.min.cjs",document.baseURI).href),Dp=vt.dirname(Pp);class Mp extends Tt{dataCache=new Map;exchangeInfoCache={};dataDirectory;constructor(e){super({requiresApiKey:!1,providerName:"Mock"});const i=typeof e=="string"?e:e?.dataDirectory;if(i)this.dataDirectory=i;else{const r=vt.resolve(Dp,"../../../");this.dataDirectory=vt.join(r,"tests","compatibility","_data")}}configure(e){super.configure(e),e.dataDirectory&&(this.dataDirectory=e.dataDirectory)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=vt.join(this.dataDirectory,e);if(!st.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=st.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.dataCache.set(i,a),a}findDataFile(e,i,r,n){if(!st.existsSync(this.dataDirectory))return null;const a=st.readdirSync(this.dataDirectory).filter(l=>l.endsWith(".json"));if(r&&n){const l=`${e}-${i}-${r}-${n}.json`;if(a.includes(l))return l}const s=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=a.filter(l=>s.test(l)).map(l=>{const c=l.match(s);return{file:l,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((l,c)=>c.endTime-l.endTime);if(o.length===0)return null;if(r&&n){const l=o.find(c=>c.startTime<=r&&c.endTime>=n);if(l)return l.file}return o[0].file}filterData(e,i,r,n){let a=e;return(i||r)&&(a=e.filter(s=>{const o=!i||s.openTime>=i,l=!r||s.openTime<=r;return o&&l})),a.sort((s,o)=>s.openTime-o.openTime),n&&n>0&&(a=a.slice(0,n)),a}normalizeTimeframe(e){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[e.toUpperCase()]||e.toLowerCase()}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,a){try{const s=this.normalizeTimeframe(i),o=this.findDataFile(e,s,n,a);if(!o)return console.warn(`No mock data file found for ${e} ${s}. Searched in: ${this.dataDirectory}`),[];const l=this.loadDataFromFile(o),c=this.filterData(l,n,a,r);return this.normalizeCloseTime(c),c}catch(s){return console.error("Error in MockProvider.getMarketData:",s),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=vt.join(this.dataDirectory,i);if(!st.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=st.readFileSync(r,"utf-8"),a=JSON.parse(n);return this.exchangeInfoCache[e]=a,a}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const a=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!a||!a.symbols)return console.error(`Exchange info not available for ${i}`),null;const s=a.symbols.find(_=>_.symbol===r);if(!s)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=s.filters?.find(_=>_.filterType==="PRICE_FILTER"),l=s.filters?.find(_=>_.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,h=l?parseFloat(l.minQty):0,p=Math.round(1/c),u=s.baseAsset,f=s.quoteAsset,m=n?` ${n}`:"",x=`${u} / ${f}${m}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:u,description:x,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:u,currency:f,timezone:"Etc/UTC",country:"",mintick:c,pricescale:p,minmove:1,pointvalue:s.contractSize||1,mincontract:h,session:"24x7",volumetype:"base",expiration_date:s.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in MockProvider.getSymbolInfo:",i),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(e){this.dataDirectory=e,this.clearCache()}}const Rp=typeof process<"u"&&process.versions&&process.versions.node;let zt=null;if(Rp)try{zt=new Mp}catch{zt=null}const Op={Binance:new Fn,FMP:new $n,Alpaca:new Wn,...zt?{Mock:zt}:{}};exports.AlpacaProvider=Wn;exports.BaseProvider=Tt;exports.BinanceProvider=Fn;exports.Context=Ze;exports.FMPProvider=$n;exports.Indicator=xi;exports.PineRuntimeError=Ce;exports.PineTS=Ri;exports.Provider=Op;exports.TIMEFRAME_PERIOD_INFO=fp;exports.TIMEFRAME_SECONDS=ht;exports.aggregateCandles=jn;exports.computeNextPeriodStart=ut;exports.computeSessionClose=_i;exports.getAggregationRatio=Oi;exports.localTimeToUTC=Ne;exports.selectSubTimeframe=Bn;
|
|
139
139
|
//# sourceMappingURL=pinets.min.cjs.map
|