tjs-lang 0.9.0 → 0.9.1
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/CLAUDE.md +7 -1
- package/dist/index.js +111 -107
- package/dist/index.js.map +3 -3
- package/dist/src/lang/emitters/js-wasm.d.ts +2 -0
- package/dist/src/lang/parser-types.d.ts +7 -0
- package/dist/tjs-browser-from-ts.js +1 -1
- package/dist/tjs-browser-from-ts.js.map +1 -1
- package/dist/tjs-browser.js +93 -89
- package/dist/tjs-browser.js.map +3 -3
- package/dist/tjs-eval.js +14 -14
- package/dist/tjs-eval.js.map +2 -2
- package/dist/tjs-from-ts.js +1 -1
- package/dist/tjs-from-ts.js.map +1 -1
- package/dist/tjs-lang.js +94 -90
- package/dist/tjs-lang.js.map +3 -3
- package/dist/tjs-runtime.js +1 -1
- package/dist/tjs-runtime.js.map +1 -1
- package/dist/tjs-vm.js +2 -2
- package/dist/tjs-vm.js.map +2 -2
- package/docs/type-system-north-star.md +100 -0
- package/package.json +1 -1
- package/src/lang/emitters/js-wasm.ts +8 -4
- package/src/lang/emitters/js.ts +36 -11
- package/src/lang/parser-transforms.ts +4 -1
- package/src/lang/parser-types.ts +7 -0
- package/src/lang/parser.ts +9 -1
- package/src/lang/predicate-report.test.ts +24 -0
- package/src/lang/wasm-fallback-warning.test.ts +50 -0
- package/src/lang/wasm-intdiv-lint.test.ts +45 -0
- package/src/lang/wasm-ready.test.ts +94 -0
- package/src/lang/wasm-simd-ops.test.ts +84 -0
- package/src/lang/wasm.ts +61 -2
package/dist/tjs-browser.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
var Sa=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bi=Sa((tl,ru)=>{ru.exports={name:"tjs-lang",version:"0.9.0",description:"Type-safe JavaScript dialect with runtime validation, sandboxed VM execution, and AI agent orchestration. Transpiles TypeScript to validated JS with fuel-metered execution for untrusted code.",keywords:["typescript","transpiler","runtime-validation","type-safety","sandbox","virtual-machine","wasm-alternative","ai-agents","llm","orchestration","security","fuel-metering","capability-based","json-ast","untrusted-code"],license:"Apache-2.0",main:"./dist/index.js",types:"./dist/src/index.d.ts",typesVersions:{"*":{eval:["./dist/src/lang/eval.d.ts"],lang:["./dist/src/lang/transpiler.d.ts"],"lang/from-ts":["./dist/src/lang/emitters/from-ts.d.ts"],browser:["./dist/src/lang/browser.d.ts"],"browser/from-ts":["./dist/src/lang/browser-from-ts.d.ts"],vm:["./dist/src/vm/index.d.ts"],batteries:["./dist/src/batteries/index.d.ts"],css:["./dist/src/css/index.d.ts"],schema:["./dist/src/schema/index.d.ts"],runtime:["./dist/src/lang/runtime.d.ts"]}},exports:{".":{bun:"./src/index.ts",types:"./dist/src/index.d.ts",default:"./dist/index.js"},"./eval":{bun:"./src/lang/eval.ts",types:"./dist/src/lang/eval.d.ts",default:"./dist/tjs-eval.js"},"./lang":{bun:"./src/lang/transpiler.ts",types:"./dist/src/lang/transpiler.d.ts",default:"./dist/tjs-lang.js"},"./lang/from-ts":{bun:"./src/lang/emitters/from-ts.ts",types:"./dist/src/lang/emitters/from-ts.d.ts",default:"./dist/tjs-from-ts.js"},"./browser":{types:"./dist/src/lang/browser.d.ts",default:"./dist/tjs-browser.js"},"./browser/from-ts":{types:"./dist/src/lang/browser-from-ts.d.ts",default:"./dist/tjs-browser-from-ts.js"},"./vm":{bun:"./src/vm/index.ts",types:"./dist/src/vm/index.d.ts",default:"./dist/tjs-vm.js"},"./batteries":{bun:"./src/batteries/index.ts",types:"./dist/src/batteries/index.d.ts",default:"./dist/tjs-batteries.js"},"./linalg":{bun:"./src/linalg/index.tjs",default:"./dist/tjs-linalg.js"},"./css":{bun:"./src/css/index.ts",types:"./dist/src/css/index.d.ts",default:"./dist/tjs-css.js"},"./schema":{bun:"./src/schema/index.ts",types:"./dist/src/schema/index.d.ts",default:"./dist/tjs-schema.js"},"./runtime":{bun:"./src/lang/runtime.ts",types:"./dist/src/lang/runtime.d.ts",default:"./dist/tjs-runtime.js"},"./bun-plugin":{bun:"./src/bun-plugin/tjs-plugin.ts"},"./src":"./src/index.ts","./editors/monaco":"./editors/monaco/ajs-monarch.js","./editors/codemirror":"./editors/codemirror/ajs-language.js","./editors/ace":"./editors/ace/ajs-mode.js"},bin:{tjs:"./src/cli/tjs.ts",tjsx:"./src/cli/tjsx.ts","tjs-playground":"./src/cli/playground.ts","create-tjs-app":"./src/cli/create-app.ts","ajs-install-vscode":"./bin/install-vscode.sh","ajs-install-cursor":"./bin/install-cursor.sh"},type:"module",files:["dist","src","docs","editors","bin","demo","tjs-lang.svg","CONTEXT.md","CLAUDE.md","llms.txt"],sideEffects:["./src/schema/index.ts","./dist/tjs-schema.js"],repository:{type:"git",url:"https://github.com/tonioloewald/tjs-lang.git"},devDependencies:{"@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.11","@codemirror/lang-javascript":"^6.2.4","@codemirror/lang-markdown":"^6.5.0","@codemirror/state":"^6.5.3","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.39.9","@eslint/js":"^10.0.1","@happy-dom/global-registrator":"^20.1.0","@types/bun":"latest","@types/jsdom":"^21.1.7","acorn-walk":"^8.3.4",chokidar:"^4.0.3",codemirror:"^6.0.2",esbuild:"^0.28.0",eslint:"^10.4.1",firebase:"^10.12.0","firebase-admin":"^13.6.0","firebase-functions":"^7.0.5",globals:"^17.6.0",marked:"^9.1.6",prettier:"^2.8.8",tosijs:"^1.5.6","tosijs-ui":"^1.4.7",typescript:"^5.6.2","typescript-eslint":"^8.61.0",valibot:"^0.36.0",vitest:"^2.0.5"},scripts:{format:"bun eslint src --fix && bun prettier --write .",lint:"eslint src","build:grammars":"bun editors/build-grammars.ts","build:editors":"bun scripts/build-editors.ts","test:fast":"SKIP_LLM_TESTS=1 SKIP_BENCHMARKS=1 bun test","test:llm":"bun test src/batteries/models.integration.test.ts",bench:"bun bin/benchmarks.ts",make:"rm -rf dist && bun format && bun run build:grammars && bun run build:editors && tsc -p tsconfig.build.json && bun scripts/build.ts","build:bundles":"bun scripts/build.ts",typecheck:"tsc --noEmit",latest:"rm -rf node_modules && bun install",docs:"node bin/docs.js",dev:"bun run bin/dev.ts","build:demo":"bun scripts/build-demo.ts","build:cli":"bun build src/cli/tjs.ts --compile --outfile=dist/tjs && bun build src/cli/tjsx.ts --compile --outfile=dist/tjsx","functions:build":"cd functions && npm run build","functions:deploy":"cd functions && npm run deploy","functions:serve":"cd functions && npm run serve","deploy:hosting":"bun run build:demo && firebase deploy --only hosting",deploy:"bun run build:demo && bun run functions:deploy && firebase deploy --only hosting",start:"bun run build:demo && bun run dev"},dependencies:{acorn:"^8.15.0","acorn-loose":"^8.5.2","acorn-walk":"^8.3.4","tosijs-schema":"^1.4.0"}}});var va=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],is=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],ka="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",as="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Fn={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"},Ln="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",Ea={5:Ln,"5module":Ln+" export import",6:Ln+" const class extends export import super"},Ta=/^in(stanceof)?$/,$a=new RegExp("["+as+"]"),Ca=new RegExp("["+as+ka+"]");function qn(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Ce(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&$a.test(String.fromCharCode(e)):t===!1?!1:qn(e,is)}function Je(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Ca.test(String.fromCharCode(e)):t===!1?!1:qn(e,is)||qn(e,va)}var q=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function be(e,t){return new q(e,{beforeExpr:!0,binop:t})}var xe={beforeExpr:!0},de={startsExpr:!0},zn={};function L(e,t){return t===void 0&&(t={}),t.keyword=e,zn[e]=new q(e,t)}var h={num:new q("num",de),regexp:new q("regexp",de),string:new q("string",de),name:new q("name",de),privateId:new q("privateId",de),eof:new q("eof"),bracketL:new q("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new q("]"),braceL:new q("{",{beforeExpr:!0,startsExpr:!0}),braceR:new q("}"),parenL:new q("(",{beforeExpr:!0,startsExpr:!0}),parenR:new q(")"),comma:new q(",",xe),semi:new q(";",xe),colon:new q(":",xe),dot:new q("."),question:new q("?",xe),questionDot:new q("?."),arrow:new q("=>",xe),template:new q("template"),invalidTemplate:new q("invalidTemplate"),ellipsis:new q("...",xe),backQuote:new q("`",de),dollarBraceL:new q("${",{beforeExpr:!0,startsExpr:!0}),eq:new q("=",{beforeExpr:!0,isAssign:!0}),assign:new q("_=",{beforeExpr:!0,isAssign:!0}),incDec:new q("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new q("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:be("||",1),logicalAND:be("&&",2),bitwiseOR:be("|",3),bitwiseXOR:be("^",4),bitwiseAND:be("&",5),equality:be("==/!=/===/!==",6),relational:be("</>/<=/>=",7),bitShift:be("<</>>/>>>",8),plusMin:new q("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:be("%",10),star:be("*",10),slash:be("/",10),starstar:new q("**",{beforeExpr:!0}),coalesce:be("??",1),_break:L("break"),_case:L("case",xe),_catch:L("catch"),_continue:L("continue"),_debugger:L("debugger"),_default:L("default",xe),_do:L("do",{isLoop:!0,beforeExpr:!0}),_else:L("else",xe),_finally:L("finally"),_for:L("for",{isLoop:!0}),_function:L("function",de),_if:L("if"),_return:L("return",xe),_switch:L("switch"),_throw:L("throw",xe),_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",de),_super:L("super",de),_class:L("class",de),_extends:L("extends",xe),_export:L("export"),_import:L("import",de),_null:L("null",de),_true:L("true",de),_false:L("false",de),_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})},me=/\r\n?|\n|\u2028|\u2029/,Aa=new RegExp(me.source,"g");function pt(e){return e===10||e===13||e===8232||e===8233}function os(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(pt(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var us=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,oe=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,cs=Object.prototype,Pa=cs.hasOwnProperty,ja=cs.toString,ht=Object.hasOwn||(function(e,t){return Pa.call(e,t)}),es=Array.isArray||(function(e){return ja.call(e)==="[object Array]"}),ts=Object.create(null);function We(e){return ts[e]||(ts[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Be(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Ia=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Tt=function(t,n){this.line=t,this.column=n};Tt.prototype.offset=function(t){return new Tt(this.line,this.column+t)};var nn=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ls(e,t){for(var n=1,r=0;;){var s=os(e,r,t);if(s<0)return new Tt(n,t-r);++n,r=s}}var Un={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},ns=!1;function Na(e){var t={};for(var n in Un)t[n]=e&&ht(e,n)?e[n]:Un[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ns&&typeof console=="object"&&console.warn&&(ns=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
-
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),
|
|
3
|
-
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(me).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope($t),this.regexpState=null,this.privateNameStack=[]},Ae={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};ne.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};Ae.inFunction.get=function(){return(this.currentVarScope().flags&dt)>0};Ae.inGenerator.get=function(){return(this.currentVarScope().flags&fs)>0};Ae.inAsync.get=function(){return(this.currentVarScope().flags&Gn)>0};Ae.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct))return!1;if(n&dt)return(n&Gn)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ae.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&rn)>0||this.options.allowSuperOutsideMethod};Ae.allowDirectSuper.get=function(){return(this.currentThisScope().flags&hs)>0};Ae.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ae.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct)||n&dt&&!(n&Hn))return!0}return!1};Ae.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ye)>0};ne.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};ne.parse=function(t,n){return new this(n,t).parse()};ne.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};ne.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(ne.prototype,Ae);var pe=ne.prototype,Ma=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pe.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=e,e+=oe.exec(this.input)[0].length;var t=Ma.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){oe.lastIndex=e+t[0].length;var n=oe.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||me.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,oe.lastIndex=e,e+=oe.exec(this.input)[0].length,this.input[e]===";"&&e++}};pe.eat=function(e){return this.type===e?(this.next(),!0):!1};pe.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc};pe.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};pe.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};pe.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||me.test(this.input.slice(this.lastTokEnd,this.start))};pe.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};pe.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()};pe.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};pe.expect=function(e){this.eat(e)||this.unexpected()};pe.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var an=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pe.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};pe.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};pe.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")};pe.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var I=ne.prototype;I.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Qn={kind:"loop"},Oa={kind:"switch"};I.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var t=oe.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(Ce(r,!0)){for(var s=n+1;Je(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,s);if(!Ta.test(a))return!0}return!1};I.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var e=oe.exec(this.input),t=this.pos+e[0].length,n;return!me.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(Je(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};I.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;oe.lastIndex=this.pos;var n=oe.exec(this.input),r=this.pos+n[0].length;if(me.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||Je(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;oe.lastIndex=s;var i=oe.exec(this.input);if(i&&me.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,u;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!Je(u=this.input.charCodeAt(o))&&!(u>55295&&u<56320)))return!1}var c=this.input.charCodeAt(r);return Ce(c,!0)||c===92};I.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};I.isUsing=function(e){return this.isUsingKeyword(!1,e)};I.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=h._var,a="let"),r){case h._break:case h._continue:return this.parseBreakContinueStatement(s,r.keyword);case h._debugger:return this.parseDebuggerStatement(s);case h._do:return this.parseDoStatement(s);case h._for:return this.parseForStatement(s);case h._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(s,!0);case h._if:return this.parseIfStatement(s);case h._return:return this.parseReturnStatement(s);case h._switch:return this.parseSwitchStatement(s);case h._throw:return this.parseThrowStatement(s);case h._try:return this.parseTryStatement(s);case h._const:case h._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case h._while:return this.parseWhileStatement(s);case h._with:return this.parseWithStatement(s);case h.braceL:return this.parseBlock(!0,s);case h.semi:return this.parseEmptyStatement(s);case h._export:case h._import:if(this.options.ecmaVersion>10&&r===h._import){oe.lastIndex=this.pos;var i=oe.exec(this.input),o=this.pos+i[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===h._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,c),this.semicolon(),this.finishNode(s,"VariableDeclaration");var l=this.value,p=this.parseExpression();return r===h.name&&p.type==="Identifier"&&this.eat(h.colon)?this.parseLabeledStatement(s,l,p,e):this.parseExpressionStatement(s,p)}};I.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(n||s.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};I.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};I.parseDoStatement=function(e){return this.next(),this.labels.push(Qn),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};I.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Qn),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var r=this.startNode(),s=n?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var u=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(u,!0,o),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var c=this.containsEsc,l=new an,p=this.start,f=t>-1?this.parseExprSubscripts(l,"await"):this.parseExpression(!0,l);return this.type===h._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===p&&!c&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,l),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(l,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))};I.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))};I.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Et|(n?0:Wn),!1,t)};I.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};I.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};I.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Oa),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var r=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};I.parseThrowStatement=function(e){return this.next(),me.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ba=[];I.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?ps:0),this.checkLValPattern(e,t?ms:Fe),this.expect(h.parenR),e};I.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};I.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};I.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Qn),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};I.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};I.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};I.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===h._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var c=this.labels[u];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")};I.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};I.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};I.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};I.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")};I.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var s=this.startNode();if(this.parseVarId(s,n),this.eat(h.eq)?s.init=this.parseMaybeAssign(t):!r&&n==="const"&&!(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==h._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!r&&s.id.type!=="Identifier"&&!(t&&(this.type===h._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(h.comma))break}return e};I.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Zn:Fe,!1)};var Et=1,Wn=2,ys=4;I.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===h.star&&t&Wn&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Et&&(e.id=t&ys&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&Wn)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Zn:Fe:ds));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kn(e.async,e.generator)),t&Et||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&Et?"FunctionDeclaration":"FunctionExpression")};I.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};I.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(h.braceL);this.type!==h.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&Da(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};I.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:r="static"}if(n.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===h.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(h.star)&&(s=!0),!r&&!a&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=u:r=u)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||i!=="method"||s||a){var c=!n.static&&Xt(n,"constructor"),l=c&&e;c&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=c?"constructor":i,this.parseClassMethod(n,s,a,l)}else this.parseClassField(n);return n};I.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword};I.parseClassElementName=function(e){this.type===h.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};I.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Xt(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};I.parseClassField=function(e){return Xt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Xt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Ct|rn),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};I.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ye|rn);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};I.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Fe,!1)):(t===!0&&this.unexpected(),e.id=null)};I.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null};I.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};I.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var i=n[a];ht(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function Da(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Xt(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}I.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};I.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var s=r[n];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};I.parseExportDeclaration=function(e){return this.parseStatement(null)};I.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Et|ys,!1,e)}else if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};I.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),ht(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};I.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var u=o[i];u&&this.checkPatternExport(e,u)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};I.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var s=r[n];this.checkPatternExport(e,s.id)}};I.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};I.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};I.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t};I.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=Ba,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};I.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportSpecifier")};I.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportDefaultSpecifier")};I.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportNamespaceSpecifier")};I.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e};I.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;ht(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};I.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};I.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return Ia.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};I.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};I.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var we=ne.prototype;we.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e};we.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};we.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};we.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};we.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()};we.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(h.comma),t&&this.type===h.comma)s.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};we.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};we.parseBindingListItem=function(e){return e};we.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};we.checkLValSimple=function(e,t,n){t===void 0&&(t=Yt);var r=t!==Yt;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===Fe&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(ht(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==gs&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};we.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var u=o[i];u&&this.checkLValInnerPattern(u,t,n)}break;default:this.checkLValSimple(e,t,n)}};we.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ke=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},Q={b_stat:new ke("{",!1),b_expr:new ke("{",!0),b_tmpl:new ke("${",!1),p_stat:new ke("(",!1),p_expr:new ke("(",!0),q_tmpl:new ke("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ke("function",!1),f_expr:new ke("function",!0),f_expr_gen:new ke("function",!0,!1,null,!0),f_gen:new ke("function",!1,!1,null,!0)},mt=ne.prototype;mt.initialContext=function(){return[Q.b_stat]};mt.curContext=function(){return this.context[this.context.length-1]};mt.braceIsBlock=function(e){var t=this.curContext();return t===Q.f_expr||t===Q.f_stat?!0:e===h.colon&&(t===Q.b_stat||t===Q.b_expr)?!t.isExpr:e===h._return||e===h.name&&this.exprAllowed?me.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow?!0:e===h.braceL?t===Q.b_stat:e===h._var||e===h._const||e===h.name?!1:!this.exprAllowed};mt.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};mt.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};mt.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};h.parenR.updateContext=h.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===Q.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Q.b_stat:Q.b_expr),this.exprAllowed=!0};h.dollarBraceL.updateContext=function(){this.context.push(Q.b_tmpl),this.exprAllowed=!0};h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?Q.p_stat:Q.p_expr),this.exprAllowed=!0};h.incDec.updateContext=function(){};h._function.updateContext=h._class.updateContext=function(e){e.beforeExpr&&e!==h._else&&!(e===h.semi&&this.curContext()!==Q.p_stat)&&!(e===h._return&&me.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===h.colon||e===h.braceL)&&this.curContext()===Q.b_stat)?this.context.push(Q.f_expr):this.context.push(Q.f_stat),this.exprAllowed=!1};h.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};h.backQuote.updateContext=function(){this.curContext()===Q.q_tmpl?this.context.pop():this.context.push(Q.q_tmpl),this.exprAllowed=!1};h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===Q.f_expr?this.context[t]=Q.f_expr_gen:this.context[t]=Q.f_gen}this.exprAllowed=!0};h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var M=ne.prototype;M.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};M.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===h.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(h.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};M.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new an,r=!0);var o=this.start,u=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var c=this.parseMaybeConditional(e,t);if(n&&(c=n.call(this,c,o,u)),this.type.isAssign){var l=this.startNodeAt(o,u);return l.operator=this.value,this.type===h.eq&&(c=this.toAssignable(c,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=c.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(l,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),c};M.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(h.question)){var a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(h.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};M.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};M.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==h._in)&&a>r){var i=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(a=h.logicalAND.binop);var u=this.value;this.next();var c=this.start,l=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,l,a,s),f=this.buildBinary(t,n,e,p,u,i||o);return(i&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,t,n,r,s)}return e};M.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};M.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&bs(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Jn(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===h.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,a);c.operator=this.value,c.prefix=!1,c.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(c,"UpdateExpression")}}if(!n&&this.eat(h.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function bs(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&bs(e.expression)}function Jn(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Jn(e.expression)||e.type==="ParenthesizedExpression"&&Jn(e.expression)}M.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};M.parseSubscripts=function(e,t,n,r,s){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var u=this.startNodeAt(t,n);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}e=o}};M.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)};M.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};M.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,u=o&&this.eat(h.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(h.bracketL);if(c||u&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var l=this.startNodeAt(t,n);l.object=e,c?(l.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&e.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!c,o&&(l.optional=u),e=this.finishNode(l,"MemberExpression")}else if(!r&&this.eat(h.parenL)){var p=new an,f=this.yieldPos,d=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,p);if(s&&!u&&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=f,this.awaitPos=d,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,y,i);this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var x=this.startNodeAt(t,n);x.callee=e,x.arguments=y,o&&(x.optional=u),e=this.finishNode(x,"CallExpression")}else if(this.type===h.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var S=this.startNodeAt(t,n);S.tag=e,S.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(S,"TaggedTemplateExpression")}return e};M.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(r,"Super");case h._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case h.name:var a=this.start,i=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(Q.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[u],!0,t)}return u;case h.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return r=this.startNode(),r.value=this.type===h._null?null:this.type===h._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case h.parenL:var l=this.start,p=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),p;case h.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case h.braceL:return this.overrideContext(Q.b_expr),this.parseObj(!1,e);case h._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};M.parseExprAtomDefault=function(){this.unexpected()};M.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};M.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};M.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};M.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};M.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e};M.shouldParseArrow=function(e){return!this.canInsertSemicolon()};M.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,u=[],c=!0,l=!1,p=new an,f=this.yieldPos,d=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;)if(c?c=!1:this.expect(h.comma),a&&this.afterTrailingComma(h.parenR,!0)){l=!0;break}else if(this.type===h.ellipsis){m=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(u)&&this.eat(h.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=d,this.parseParenArrowList(n,r,u,t);(!u.length||l)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,u.length>1?(s=this.startNodeAt(i,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",y,x)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var S=this.startNodeAt(n,r);return S.expression=s,this.finishNode(S,"ParenthesizedExpression")}else return s};M.parseParenItem=function(e){return e};M.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Fa=[];M.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Fa,this.finishNode(e,"NewExpression")};M.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
1
|
+
var ka=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fi=ka((rl,iu)=>{iu.exports={name:"tjs-lang",version:"0.9.1",description:"Type-safe JavaScript dialect with runtime validation, sandboxed VM execution, and AI agent orchestration. Transpiles TypeScript to validated JS with fuel-metered execution for untrusted code.",keywords:["typescript","transpiler","runtime-validation","type-safety","sandbox","virtual-machine","wasm-alternative","ai-agents","llm","orchestration","security","fuel-metering","capability-based","json-ast","untrusted-code"],license:"Apache-2.0",main:"./dist/index.js",types:"./dist/src/index.d.ts",typesVersions:{"*":{eval:["./dist/src/lang/eval.d.ts"],lang:["./dist/src/lang/transpiler.d.ts"],"lang/from-ts":["./dist/src/lang/emitters/from-ts.d.ts"],browser:["./dist/src/lang/browser.d.ts"],"browser/from-ts":["./dist/src/lang/browser-from-ts.d.ts"],vm:["./dist/src/vm/index.d.ts"],batteries:["./dist/src/batteries/index.d.ts"],css:["./dist/src/css/index.d.ts"],schema:["./dist/src/schema/index.d.ts"],runtime:["./dist/src/lang/runtime.d.ts"]}},exports:{".":{bun:"./src/index.ts",types:"./dist/src/index.d.ts",default:"./dist/index.js"},"./eval":{bun:"./src/lang/eval.ts",types:"./dist/src/lang/eval.d.ts",default:"./dist/tjs-eval.js"},"./lang":{bun:"./src/lang/transpiler.ts",types:"./dist/src/lang/transpiler.d.ts",default:"./dist/tjs-lang.js"},"./lang/from-ts":{bun:"./src/lang/emitters/from-ts.ts",types:"./dist/src/lang/emitters/from-ts.d.ts",default:"./dist/tjs-from-ts.js"},"./browser":{types:"./dist/src/lang/browser.d.ts",default:"./dist/tjs-browser.js"},"./browser/from-ts":{types:"./dist/src/lang/browser-from-ts.d.ts",default:"./dist/tjs-browser-from-ts.js"},"./vm":{bun:"./src/vm/index.ts",types:"./dist/src/vm/index.d.ts",default:"./dist/tjs-vm.js"},"./batteries":{bun:"./src/batteries/index.ts",types:"./dist/src/batteries/index.d.ts",default:"./dist/tjs-batteries.js"},"./linalg":{bun:"./src/linalg/index.tjs",default:"./dist/tjs-linalg.js"},"./css":{bun:"./src/css/index.ts",types:"./dist/src/css/index.d.ts",default:"./dist/tjs-css.js"},"./schema":{bun:"./src/schema/index.ts",types:"./dist/src/schema/index.d.ts",default:"./dist/tjs-schema.js"},"./runtime":{bun:"./src/lang/runtime.ts",types:"./dist/src/lang/runtime.d.ts",default:"./dist/tjs-runtime.js"},"./bun-plugin":{bun:"./src/bun-plugin/tjs-plugin.ts"},"./src":"./src/index.ts","./editors/monaco":"./editors/monaco/ajs-monarch.js","./editors/codemirror":"./editors/codemirror/ajs-language.js","./editors/ace":"./editors/ace/ajs-mode.js"},bin:{tjs:"./src/cli/tjs.ts",tjsx:"./src/cli/tjsx.ts","tjs-playground":"./src/cli/playground.ts","create-tjs-app":"./src/cli/create-app.ts","ajs-install-vscode":"./bin/install-vscode.sh","ajs-install-cursor":"./bin/install-cursor.sh"},type:"module",files:["dist","src","docs","editors","bin","demo","tjs-lang.svg","CONTEXT.md","CLAUDE.md","llms.txt"],sideEffects:["./src/schema/index.ts","./dist/tjs-schema.js"],repository:{type:"git",url:"https://github.com/tonioloewald/tjs-lang.git"},devDependencies:{"@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.11","@codemirror/lang-javascript":"^6.2.4","@codemirror/lang-markdown":"^6.5.0","@codemirror/state":"^6.5.3","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.39.9","@eslint/js":"^10.0.1","@happy-dom/global-registrator":"^20.1.0","@types/bun":"latest","@types/jsdom":"^21.1.7","acorn-walk":"^8.3.4",chokidar:"^4.0.3",codemirror:"^6.0.2",esbuild:"^0.28.0",eslint:"^10.4.1",firebase:"^10.12.0","firebase-admin":"^13.6.0","firebase-functions":"^7.0.5",globals:"^17.6.0",marked:"^9.1.6",prettier:"^2.8.8",tosijs:"^1.5.6","tosijs-ui":"^1.4.7",typescript:"^5.6.2","typescript-eslint":"^8.61.0",valibot:"^0.36.0",vitest:"^2.0.5"},scripts:{format:"bun eslint src --fix && bun prettier --write .",lint:"eslint src","build:grammars":"bun editors/build-grammars.ts","build:editors":"bun scripts/build-editors.ts","test:fast":"SKIP_LLM_TESTS=1 SKIP_BENCHMARKS=1 bun test","test:llm":"bun test src/batteries/models.integration.test.ts",bench:"bun bin/benchmarks.ts",make:"rm -rf dist && bun format && bun run build:grammars && bun run build:editors && tsc -p tsconfig.build.json && bun scripts/build.ts","build:bundles":"bun scripts/build.ts",typecheck:"tsc --noEmit",latest:"rm -rf node_modules && bun install",docs:"node bin/docs.js",dev:"bun run bin/dev.ts","build:demo":"bun scripts/build-demo.ts","build:cli":"bun build src/cli/tjs.ts --compile --outfile=dist/tjs && bun build src/cli/tjsx.ts --compile --outfile=dist/tjsx","functions:build":"cd functions && npm run build","functions:deploy":"cd functions && npm run deploy","functions:serve":"cd functions && npm run serve","deploy:hosting":"bun run build:demo && firebase deploy --only hosting",deploy:"bun run build:demo && bun run functions:deploy && firebase deploy --only hosting",start:"bun run build:demo && bun run dev"},dependencies:{acorn:"^8.15.0","acorn-loose":"^8.5.2","acorn-walk":"^8.3.4","tosijs-schema":"^1.4.0"}}});var Ea=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],os=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Ta="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",us="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Un={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"},Wn="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",$a={5:Wn,"5module":Wn+" export import",6:Wn+" const class extends export import super"},Ca=/^in(stanceof)?$/,Aa=new RegExp("["+us+"]"),Pa=new RegExp("["+us+Ta+"]");function zn(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Ce(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Aa.test(String.fromCharCode(e)):t===!1?!1:zn(e,os)}function Je(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Pa.test(String.fromCharCode(e)):t===!1?!1:zn(e,os)||zn(e,Ea)}var W=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function be(e,t){return new W(e,{beforeExpr:!0,binop:t})}var xe={beforeExpr:!0},me={startsExpr:!0},Zn={};function V(e,t){return t===void 0&&(t={}),t.keyword=e,Zn[e]=new W(e,t)}var h={num:new W("num",me),regexp:new W("regexp",me),string:new W("string",me),name:new W("name",me),privateId:new W("privateId",me),eof:new W("eof"),bracketL:new W("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new W("]"),braceL:new W("{",{beforeExpr:!0,startsExpr:!0}),braceR:new W("}"),parenL:new W("(",{beforeExpr:!0,startsExpr:!0}),parenR:new W(")"),comma:new W(",",xe),semi:new W(";",xe),colon:new W(":",xe),dot:new W("."),question:new W("?",xe),questionDot:new W("?."),arrow:new W("=>",xe),template:new W("template"),invalidTemplate:new W("invalidTemplate"),ellipsis:new W("...",xe),backQuote:new W("`",me),dollarBraceL:new W("${",{beforeExpr:!0,startsExpr:!0}),eq:new W("=",{beforeExpr:!0,isAssign:!0}),assign:new W("_=",{beforeExpr:!0,isAssign:!0}),incDec:new W("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new W("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:be("||",1),logicalAND:be("&&",2),bitwiseOR:be("|",3),bitwiseXOR:be("^",4),bitwiseAND:be("&",5),equality:be("==/!=/===/!==",6),relational:be("</>/<=/>=",7),bitShift:be("<</>>/>>>",8),plusMin:new W("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:be("%",10),star:be("*",10),slash:be("/",10),starstar:new W("**",{beforeExpr:!0}),coalesce:be("??",1),_break:V("break"),_case:V("case",xe),_catch:V("catch"),_continue:V("continue"),_debugger:V("debugger"),_default:V("default",xe),_do:V("do",{isLoop:!0,beforeExpr:!0}),_else:V("else",xe),_finally:V("finally"),_for:V("for",{isLoop:!0}),_function:V("function",me),_if:V("if"),_return:V("return",xe),_switch:V("switch"),_throw:V("throw",xe),_try:V("try"),_var:V("var"),_const:V("const"),_while:V("while",{isLoop:!0}),_with:V("with"),_new:V("new",{beforeExpr:!0,startsExpr:!0}),_this:V("this",me),_super:V("super",me),_class:V("class",me),_extends:V("extends",xe),_export:V("export"),_import:V("import",me),_null:V("null",me),_true:V("true",me),_false:V("false",me),_in:V("in",{beforeExpr:!0,binop:7}),_instanceof:V("instanceof",{beforeExpr:!0,binop:7}),_typeof:V("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:V("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:V("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},ge=/\r\n?|\n|\u2028|\u2029/,ja=new RegExp(ge.source,"g");function pt(e){return e===10||e===13||e===8232||e===8233}function cs(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(pt(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ls=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,oe=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,fs=Object.prototype,Ia=fs.hasOwnProperty,Na=fs.toString,ht=Object.hasOwn||(function(e,t){return Ia.call(e,t)}),ns=Array.isArray||(function(e){return Na.call(e)==="[object Array]"}),rs=Object.create(null);function We(e){return rs[e]||(rs[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Be(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Ra=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Tt=function(t,n){this.line=t,this.column=n};Tt.prototype.offset=function(t){return new Tt(this.line,this.column+t)};var nn=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ps(e,t){for(var n=1,r=0;;){var s=cs(e,r,t);if(s<0)return new Tt(n,t-r);++n,r=s}}var Gn={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},ss=!1;function Ma(e){var t={};for(var n in Gn)t[n]=e&&ht(e,n)?e[n]:Gn[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ss&&typeof console=="object"&&console.warn&&(ss=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),ns(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return ns(t.onComment)&&(t.onComment=Oa(t,t.onComment)),t}function Oa(e,t){return function(n,r,s,a,i,o){var u={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(u.loc=new nn(this,i,o)),e.ranges&&(u.range=[s,a]),t.push(u)}}var $t=1,dt=2,Qn=4,hs=8,Yn=16,ds=32,rn=64,ms=128,Ye=256,Ct=512,sn=$t|dt|Ye;function Xn(e,t){return dt|(e?Qn:0)|(t?hs:0)}var Yt=0,er=1,Fe=2,gs=3,ys=4,bs=5,re=function(t,n,r){this.options=t=Ma(t),this.sourceFile=t.sourceFile,this.keywords=We($a[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=Un[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=We(s);var a=(s?s+" ":"")+Un.strict;this.reservedWordsStrict=We(a),this.reservedWordsStrictBind=We(a+" "+Un.strictBind),this.input=String(n),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(ge).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope($t),this.regexpState=null,this.privateNameStack=[]},Ae={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};re.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};Ae.inFunction.get=function(){return(this.currentVarScope().flags&dt)>0};Ae.inGenerator.get=function(){return(this.currentVarScope().flags&hs)>0};Ae.inAsync.get=function(){return(this.currentVarScope().flags&Qn)>0};Ae.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct))return!1;if(n&dt)return(n&Qn)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ae.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&rn)>0||this.options.allowSuperOutsideMethod};Ae.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ms)>0};Ae.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ae.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct)||n&dt&&!(n&Yn))return!0}return!1};Ae.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ye)>0};re.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};re.parse=function(t,n){return new this(n,t).parse()};re.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};re.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(re.prototype,Ae);var pe=re.prototype,Ba=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pe.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=e,e+=oe.exec(this.input)[0].length;var t=Ba.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){oe.lastIndex=e+t[0].length;var n=oe.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||ge.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,oe.lastIndex=e,e+=oe.exec(this.input)[0].length,this.input[e]===";"&&e++}};pe.eat=function(e){return this.type===e?(this.next(),!0):!1};pe.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc};pe.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};pe.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};pe.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||ge.test(this.input.slice(this.lastTokEnd,this.start))};pe.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};pe.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()};pe.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};pe.expect=function(e){this.eat(e)||this.unexpected()};pe.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var an=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pe.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};pe.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};pe.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")};pe.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var I=re.prototype;I.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var tr={kind:"loop"},Da={kind:"switch"};I.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var t=oe.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(Ce(r,!0)){for(var s=n+1;Je(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,s);if(!Ca.test(a))return!0}return!1};I.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var e=oe.exec(this.input),t=this.pos+e[0].length,n;return!ge.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(Je(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};I.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;oe.lastIndex=this.pos;var n=oe.exec(this.input),r=this.pos+n[0].length;if(ge.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||Je(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;oe.lastIndex=s;var i=oe.exec(this.input);if(i&&ge.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,u;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!Je(u=this.input.charCodeAt(o))&&!(u>55295&&u<56320)))return!1}var c=this.input.charCodeAt(r);return Ce(c,!0)||c===92};I.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};I.isUsing=function(e){return this.isUsingKeyword(!1,e)};I.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=h._var,a="let"),r){case h._break:case h._continue:return this.parseBreakContinueStatement(s,r.keyword);case h._debugger:return this.parseDebuggerStatement(s);case h._do:return this.parseDoStatement(s);case h._for:return this.parseForStatement(s);case h._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(s,!0);case h._if:return this.parseIfStatement(s);case h._return:return this.parseReturnStatement(s);case h._switch:return this.parseSwitchStatement(s);case h._throw:return this.parseThrowStatement(s);case h._try:return this.parseTryStatement(s);case h._const:case h._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case h._while:return this.parseWhileStatement(s);case h._with:return this.parseWithStatement(s);case h.braceL:return this.parseBlock(!0,s);case h.semi:return this.parseEmptyStatement(s);case h._export:case h._import:if(this.options.ecmaVersion>10&&r===h._import){oe.lastIndex=this.pos;var i=oe.exec(this.input),o=this.pos+i[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===h._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,c),this.semicolon(),this.finishNode(s,"VariableDeclaration");var l=this.value,p=this.parseExpression();return r===h.name&&p.type==="Identifier"&&this.eat(h.colon)?this.parseLabeledStatement(s,l,p,e):this.parseExpressionStatement(s,p)}};I.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(n||s.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};I.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};I.parseDoStatement=function(e){return this.next(),this.labels.push(tr),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};I.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(tr),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var r=this.startNode(),s=n?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var u=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(u,!0,o),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var c=this.containsEsc,l=new an,p=this.start,f=t>-1?this.parseExprSubscripts(l,"await"):this.parseExpression(!0,l);return this.type===h._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===p&&!c&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,l),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(l,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))};I.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))};I.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Et|(n?0:Hn),!1,t)};I.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};I.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};I.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Da),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var r=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};I.parseThrowStatement=function(e){return this.next(),ge.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Fa=[];I.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?ds:0),this.checkLValPattern(e,t?ys:Fe),this.expect(h.parenR),e};I.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};I.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};I.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(tr),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};I.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};I.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};I.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===h._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var c=this.labels[u];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")};I.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};I.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};I.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};I.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")};I.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var s=this.startNode();if(this.parseVarId(s,n),this.eat(h.eq)?s.init=this.parseMaybeAssign(t):!r&&n==="const"&&!(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==h._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!r&&s.id.type!=="Identifier"&&!(t&&(this.type===h._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(h.comma))break}return e};I.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?er:Fe,!1)};var Et=1,Hn=2,xs=4;I.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===h.star&&t&Hn&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Et&&(e.id=t&xs&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&Hn)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?er:Fe:gs));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Xn(e.async,e.generator)),t&Et||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&Et?"FunctionDeclaration":"FunctionExpression")};I.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};I.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(h.braceL);this.type!==h.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&La(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};I.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:r="static"}if(n.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===h.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(h.star)&&(s=!0),!r&&!a&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=u:r=u)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||i!=="method"||s||a){var c=!n.static&&Xt(n,"constructor"),l=c&&e;c&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=c?"constructor":i,this.parseClassMethod(n,s,a,l)}else this.parseClassField(n);return n};I.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword};I.parseClassElementName=function(e){this.type===h.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};I.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Xt(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};I.parseClassField=function(e){return Xt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Xt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Ct|rn),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};I.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ye|rn);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};I.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Fe,!1)):(t===!0&&this.unexpected(),e.id=null)};I.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null};I.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};I.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var i=n[a];ht(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function La(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Xt(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}I.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};I.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var s=r[n];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};I.parseExportDeclaration=function(e){return this.parseStatement(null)};I.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Et|xs,!1,e)}else if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};I.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),ht(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};I.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var u=o[i];u&&this.checkPatternExport(e,u)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};I.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var s=r[n];this.checkPatternExport(e,s.id)}};I.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};I.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};I.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t};I.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=Fa,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};I.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportSpecifier")};I.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportDefaultSpecifier")};I.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportNamespaceSpecifier")};I.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e};I.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;ht(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};I.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};I.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return Ra.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};I.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};I.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var we=re.prototype;we.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e};we.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};we.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};we.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};we.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()};we.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(h.comma),t&&this.type===h.comma)s.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};we.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};we.parseBindingListItem=function(e){return e};we.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};we.checkLValSimple=function(e,t,n){t===void 0&&(t=Yt);var r=t!==Yt;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===Fe&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(ht(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==bs&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};we.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var u=o[i];u&&this.checkLValInnerPattern(u,t,n)}break;default:this.checkLValSimple(e,t,n)}};we.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ke=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},Y={b_stat:new ke("{",!1),b_expr:new ke("{",!0),b_tmpl:new ke("${",!1),p_stat:new ke("(",!1),p_expr:new ke("(",!0),q_tmpl:new ke("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ke("function",!1),f_expr:new ke("function",!0),f_expr_gen:new ke("function",!0,!1,null,!0),f_gen:new ke("function",!1,!1,null,!0)},mt=re.prototype;mt.initialContext=function(){return[Y.b_stat]};mt.curContext=function(){return this.context[this.context.length-1]};mt.braceIsBlock=function(e){var t=this.curContext();return t===Y.f_expr||t===Y.f_stat?!0:e===h.colon&&(t===Y.b_stat||t===Y.b_expr)?!t.isExpr:e===h._return||e===h.name&&this.exprAllowed?ge.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow?!0:e===h.braceL?t===Y.b_stat:e===h._var||e===h._const||e===h.name?!1:!this.exprAllowed};mt.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};mt.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};mt.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};h.parenR.updateContext=h.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===Y.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Y.b_stat:Y.b_expr),this.exprAllowed=!0};h.dollarBraceL.updateContext=function(){this.context.push(Y.b_tmpl),this.exprAllowed=!0};h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?Y.p_stat:Y.p_expr),this.exprAllowed=!0};h.incDec.updateContext=function(){};h._function.updateContext=h._class.updateContext=function(e){e.beforeExpr&&e!==h._else&&!(e===h.semi&&this.curContext()!==Y.p_stat)&&!(e===h._return&&ge.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===h.colon||e===h.braceL)&&this.curContext()===Y.b_stat)?this.context.push(Y.f_expr):this.context.push(Y.f_stat),this.exprAllowed=!1};h.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};h.backQuote.updateContext=function(){this.curContext()===Y.q_tmpl?this.context.pop():this.context.push(Y.q_tmpl),this.exprAllowed=!1};h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===Y.f_expr?this.context[t]=Y.f_expr_gen:this.context[t]=Y.f_gen}this.exprAllowed=!0};h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var M=re.prototype;M.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};M.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===h.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(h.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};M.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new an,r=!0);var o=this.start,u=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var c=this.parseMaybeConditional(e,t);if(n&&(c=n.call(this,c,o,u)),this.type.isAssign){var l=this.startNodeAt(o,u);return l.operator=this.value,this.type===h.eq&&(c=this.toAssignable(c,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=c.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(l,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),c};M.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(h.question)){var a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(h.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};M.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};M.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==h._in)&&a>r){var i=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(a=h.logicalAND.binop);var u=this.value;this.next();var c=this.start,l=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,l,a,s),f=this.buildBinary(t,n,e,p,u,i||o);return(i&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,t,n,r,s)}return e};M.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};M.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&_s(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Kn(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===h.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,a);c.operator=this.value,c.prefix=!1,c.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(c,"UpdateExpression")}}if(!n&&this.eat(h.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function _s(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&_s(e.expression)}function Kn(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Kn(e.expression)||e.type==="ParenthesizedExpression"&&Kn(e.expression)}M.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};M.parseSubscripts=function(e,t,n,r,s){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var u=this.startNodeAt(t,n);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}e=o}};M.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)};M.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};M.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,u=o&&this.eat(h.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(h.bracketL);if(c||u&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var l=this.startNodeAt(t,n);l.object=e,c?(l.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&e.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!c,o&&(l.optional=u),e=this.finishNode(l,"MemberExpression")}else if(!r&&this.eat(h.parenL)){var p=new an,f=this.yieldPos,d=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,p);if(s&&!u&&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=f,this.awaitPos=d,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,y,i);this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var x=this.startNodeAt(t,n);x.callee=e,x.arguments=y,o&&(x.optional=u),e=this.finishNode(x,"CallExpression")}else if(this.type===h.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var S=this.startNodeAt(t,n);S.tag=e,S.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(S,"TaggedTemplateExpression")}return e};M.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(r,"Super");case h._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case h.name:var a=this.start,i=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(Y.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[u],!0,t)}return u;case h.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return r=this.startNode(),r.value=this.type===h._null?null:this.type===h._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case h.parenL:var l=this.start,p=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),p;case h.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case h.braceL:return this.overrideContext(Y.b_expr),this.parseObj(!1,e);case h._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};M.parseExprAtomDefault=function(){this.unexpected()};M.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};M.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};M.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};M.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};M.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e};M.shouldParseArrow=function(e){return!this.canInsertSemicolon()};M.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,u=[],c=!0,l=!1,p=new an,f=this.yieldPos,d=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;)if(c?c=!1:this.expect(h.comma),a&&this.afterTrailingComma(h.parenR,!0)){l=!0;break}else if(this.type===h.ellipsis){m=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(u)&&this.eat(h.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=d,this.parseParenArrowList(n,r,u,t);(!u.length||l)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,u.length>1?(s=this.startNodeAt(i,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",y,x)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var S=this.startNodeAt(n,r);return S.expression=s,this.finishNode(S,"ParenthesizedExpression")}else return s};M.parseParenItem=function(e){return e};M.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Va=[];M.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Va,this.finishNode(e,"NewExpression")};M.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
4
|
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
-
`),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")};M.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};M.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!me.test(this.input.slice(this.lastTokEnd,this.start))};M.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(r)r=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};M.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,i=this.startLoc),e||(r=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(n),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(n)):s=!1,this.parsePropertyValue(n,e,r,s,a,i,t,o),this.finishNode(n,"Property")};M.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};M.parsePropertyValue=function(e,t,n,r,s,a,i,o){(n||r)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,i),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==h.comma&&this.type!==h.braceR&&this.type!==h.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key)):this.type===h.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};M.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};M.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};M.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kn(t,r.generator)|rn|(n?hs:0)),this.expect(h.parenL),r.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};M.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.enterScope(Kn(n,!1)|Hn),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};M.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==h.braceL,a=this.strict,i=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,gs),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};M.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};M.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Zn,t?null:n)}};M.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===h.comma?i=null:this.type===h.ellipsis?(i=this.parseSpread(r),r&&this.type===h.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};M.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&sn)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};M.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};M.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=h.name):this.unexpected(),e};M.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};M.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};M.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var en=ne.prototype;en.raise=function(e,t){var n=ls(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};en.raiseRecoverable=en.raise;en.curPosition=function(){if(this.options.locations)return new Tt(this.curLine,this.pos-this.lineStart)};var ze=ne.prototype,La=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};ze.enterScope=function(e){this.scopeStack.push(new La(e))};ze.exitScope=function(){this.scopeStack.pop()};ze.treatFunctionsAsVarInScope=function(e){return e.flags&dt||!this.inModule&&e.flags&$t};ze.declareName=function(e,t,n){var r=!1;if(t===Fe){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&$t&&delete this.undefinedExports[e]}else if(t===ms){var a=this.currentScope();a.lexical.push(e)}else if(t===ds){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(e)>-1&&!(u.flags&ps&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){r=!0;break}if(u.var.push(e),this.inModule&&u.flags&$t&&delete this.undefinedExports[e],u.flags&sn)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};ze.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};ze.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ze.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye))return t}};ze.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye)&&!(t.flags&Hn))return t}};var on=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new nn(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},At=ne.prototype;At.startNode=function(){return new on(this,this.start,this.startLoc)};At.startNodeAt=function(e,t){return new on(this,e,t)};function xs(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}At.finishNode=function(e,t){return xs.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};At.finishNodeAt=function(e,t,n,r){return xs.call(this,e,t,n,r)};At.copyNode=function(e){var t=new on(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Va="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",_s="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",ws=_s+" Extended_Pictographic",Ss=ws,vs=Ss+" EBase EComp EMod EPres ExtPict",ks=vs,qa=ks,Ua={9:_s,10:ws,11:Ss,12:vs,13:ks,14:qa},Wa="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Ja={9:"",10:"",11:"",12:"",13:"",14:Wa},rs="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",Es="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",Ts=Es+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",$s=Ts+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Cs=$s+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",As=Cs+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",za=As+" "+Va,Ga={9:Es,10:Ts,11:$s,12:Cs,13:As,14:za},Ps={};function Ha(e){var t=Ps[e]={binary:We(Ua[e]+" "+rs),binaryOfStrings:We(Ja[e]),nonBinary:{General_Category:We(rs),Script:We(Ga[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Qt=0,Vn=[9,10,11,12,13,14];Qt<Vn.length;Qt+=1)ss=Vn[Qt],Ha(ss);var ss,Qt,Vn,j=ne.prototype,tn=function(t,n){this.parent=t,this.base=n||this};tn.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};tn.prototype.sibling=function(){return new tn(this.parent,this.base)};var Pe=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Ps[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};Pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};Pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};Pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};Pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};Pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};Pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};Pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};j.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Ka(e){for(var t in e)return!0;return!1}j.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ka(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};j.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};j.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new tn(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};j.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};j.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};j.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1};j.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};j.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};j.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};j.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};j.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};j.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var s=0;s<n.length;s++){var a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var u=i.charAt(o);(i.indexOf(u,o+1)>-1||n.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};j.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};j.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&Za(n);)t+=Be(n),e.advance();return t};function Za(e){return e===105||e===109||e===115}j.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};j.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};j.regexp_eatSyntaxCharacter=function(e){var t=e.current();return js(t)?(e.lastIntValue=t,e.advance(),!0):!1};function js(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}j.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!js(n);)e.advance();return e.pos!==t};j.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};j.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,s=n;r<s.length;r+=1){var a=s[r];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};j.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};j.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Be(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Be(e.lastIntValue);return!0}return!1};j.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Qa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Qa(e){return Ce(e,!0)||e===36||e===95}j.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Ya(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ya(e){return Je(e,!0)||e===36||e===95||e===8204||e===8205}j.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};j.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1};j.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};j.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};j.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};j.regexp_eatZero=function(e){return e.current()===48&&!un(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};j.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};j.regexp_eatControlLetter=function(e){var t=e.current();return Is(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Is(e){return e>=65&&e<=90||e>=97&&e<=122}j.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Xa(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function Xa(e){return e>=0&&e<=1114111}j.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};j.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ns=0,De=1,_e=2;j.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(eo(t))return e.lastIntValue=-1,e.advance(),De;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===_e&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Ns};function eo(e){return e===100||e===68||e===115||e===83||e===119||e===87}j.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),De}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Ns};j.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){ht(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};j.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return De;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return _e;e.raise("Invalid property name")};j.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Rs(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function Rs(e){return Is(e)||e===95}j.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";to(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function to(e){return Rs(e)||un(e)}j.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};j.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===_e&&e.raise("Negated character class may contain strings"),!0}return!1};j.regexp_classContents=function(e){return e.current()===93?De:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),De)};j.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}};j.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Bs(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};j.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};j.regexp_classSetExpression=function(e){var t=De,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===_e&&(t=_e);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==_e&&(t=De);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===_e&&(t=_e)}};j.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};j.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?De:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};j.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===_e&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};j.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null};j.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===_e&&(t=_e);return t};j.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?De:_e};j.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&no(n)||ro(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function no(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function ro(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}j.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return so(t)?(e.lastIntValue=t,e.advance(),!0):!1};function so(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}j.regexp_eatClassControlLetter=function(e){var t=e.current();return un(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};j.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};j.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;un(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function un(e){return e>=48&&e<=57}j.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ms(n=e.current());)e.lastIntValue=16*e.lastIntValue+Os(n),e.advance();return e.pos!==t};function Ms(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Os(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}j.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1};j.regexp_eatOctalDigit=function(e){var t=e.current();return Bs(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Bs(e){return e>=48&&e<=55}j.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Ms(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Os(s),e.advance()}return!0};var Yn=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new nn(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},F=ne.prototype;F.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Yn(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};F.getToken=function(){return this.next(),new Yn(this)};typeof Symbol<"u"&&(F[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}});F.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(h.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};F.readToken=function(e){return Ce(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};F.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};F.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=os(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};F.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!pt(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};F.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&us.test(String.fromCharCode(e)))++this.pos;else break e}}};F.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};F.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))};F.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(h.assign,2):this.finishOp(h.slash,1)};F.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?h.star:h.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=h.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(h.assign,n+1):this.finishOp(r,n)};F.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(h.assign,3)}return this.finishOp(e===124?h.logicalOR:h.logicalAND,2)}return t===61?this.finishOp(h.assign,2):this.finishOp(e===124?h.bitwiseOR:h.bitwiseAND,1)};F.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)};F.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||me.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(h.incDec,2):t===61?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)};F.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(h.relational,n))};F.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(h.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(e===61?h.eq:h.prefix,1)};F.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(h.assign,3)}return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)};F.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ce(t,!0)||t===92))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Be(t)+"'")};F.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Be(e)+"'")};F.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};F.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(me.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,i)}catch{}return this.finishToken(h.regexp,{pattern:s,flags:i,value:u})};F.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,u=0,c=t??1/0;u<c;++u,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(r&&l===95){s&&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"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;continue}if(l>=97?p=l-97+10:l>=65?p=l-65+10:l>=48&&l<=57?p=l-48:p=1/0,p>=e)break;o=l,i=i*e+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function io(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ds(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}F.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ds(this.input.slice(t,this.pos)),++this.pos):Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)};F.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=Ds(this.input.slice(t,this.pos));return++this.pos,Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,s)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=io(this.input.slice(t,this.pos),n);return this.finishToken(h.num,a)};F.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};F.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=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)):(pt(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var Fs={};F.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Fs)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};F.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Fs;this.raise(e,t)};F.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===h.template||this.type===h.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(pt(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
-
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};
|
|
5
|
+
`),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")};M.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};M.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!ge.test(this.input.slice(this.lastTokEnd,this.start))};M.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(r)r=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};M.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,i=this.startLoc),e||(r=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(n),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(n)):s=!1,this.parsePropertyValue(n,e,r,s,a,i,t,o),this.finishNode(n,"Property")};M.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};M.parsePropertyValue=function(e,t,n,r,s,a,i,o){(n||r)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,i),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==h.comma&&this.type!==h.braceR&&this.type!==h.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key)):this.type===h.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};M.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};M.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};M.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Xn(t,r.generator)|rn|(n?ms:0)),this.expect(h.parenL),r.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};M.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.enterScope(Xn(n,!1)|Yn),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};M.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==h.braceL,a=this.strict,i=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,bs),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};M.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};M.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,er,t?null:n)}};M.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===h.comma?i=null:this.type===h.ellipsis?(i=this.parseSpread(r),r&&this.type===h.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};M.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&sn)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};M.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};M.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=h.name):this.unexpected(),e};M.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};M.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};M.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var en=re.prototype;en.raise=function(e,t){var n=ps(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};en.raiseRecoverable=en.raise;en.curPosition=function(){if(this.options.locations)return new Tt(this.curLine,this.pos-this.lineStart)};var ze=re.prototype,qa=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};ze.enterScope=function(e){this.scopeStack.push(new qa(e))};ze.exitScope=function(){this.scopeStack.pop()};ze.treatFunctionsAsVarInScope=function(e){return e.flags&dt||!this.inModule&&e.flags&$t};ze.declareName=function(e,t,n){var r=!1;if(t===Fe){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&$t&&delete this.undefinedExports[e]}else if(t===ys){var a=this.currentScope();a.lexical.push(e)}else if(t===gs){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(e)>-1&&!(u.flags&ds&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){r=!0;break}if(u.var.push(e),this.inModule&&u.flags&$t&&delete this.undefinedExports[e],u.flags&sn)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};ze.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};ze.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ze.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye))return t}};ze.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye)&&!(t.flags&Yn))return t}};var on=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new nn(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},At=re.prototype;At.startNode=function(){return new on(this,this.start,this.startLoc)};At.startNodeAt=function(e,t){return new on(this,e,t)};function ws(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}At.finishNode=function(e,t){return ws.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};At.finishNodeAt=function(e,t,n,r){return ws.call(this,e,t,n,r)};At.copyNode=function(e){var t=new on(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Ua="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",Ss="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",vs=Ss+" Extended_Pictographic",ks=vs,Es=ks+" EBase EComp EMod EPres ExtPict",Ts=Es,Wa=Ts,Ja={9:Ss,10:vs,11:ks,12:Es,13:Ts,14:Wa},za="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Ga={9:"",10:"",11:"",12:"",13:"",14:za},is="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",$s="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",Cs=$s+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",As=Cs+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Ps=As+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",js=Ps+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ha=js+" "+Ua,Ka={9:$s,10:Cs,11:As,12:Ps,13:js,14:Ha},Is={};function Za(e){var t=Is[e]={binary:We(Ja[e]+" "+is),binaryOfStrings:We(Ga[e]),nonBinary:{General_Category:We(is),Script:We(Ka[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Qt=0,Jn=[9,10,11,12,13,14];Qt<Jn.length;Qt+=1)as=Jn[Qt],Za(as);var as,Qt,Jn,j=re.prototype,tn=function(t,n){this.parent=t,this.base=n||this};tn.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};tn.prototype.sibling=function(){return new tn(this.parent,this.base)};var Pe=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Is[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};Pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};Pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};Pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};Pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};Pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};Pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};Pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};j.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Qa(e){for(var t in e)return!0;return!1}j.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Qa(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};j.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};j.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new tn(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};j.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};j.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};j.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1};j.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};j.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};j.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};j.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};j.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};j.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var s=0;s<n.length;s++){var a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var u=i.charAt(o);(i.indexOf(u,o+1)>-1||n.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};j.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};j.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&Ya(n);)t+=Be(n),e.advance();return t};function Ya(e){return e===105||e===109||e===115}j.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};j.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};j.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Ns(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ns(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}j.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Ns(n);)e.advance();return e.pos!==t};j.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};j.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,s=n;r<s.length;r+=1){var a=s[r];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};j.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};j.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Be(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Be(e.lastIntValue);return!0}return!1};j.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Xa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Xa(e){return Ce(e,!0)||e===36||e===95}j.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),eo(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function eo(e){return Je(e,!0)||e===36||e===95||e===8204||e===8205}j.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};j.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1};j.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};j.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};j.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};j.regexp_eatZero=function(e){return e.current()===48&&!un(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};j.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};j.regexp_eatControlLetter=function(e){var t=e.current();return Rs(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Rs(e){return e>=65&&e<=90||e>=97&&e<=122}j.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&to(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function to(e){return e>=0&&e<=1114111}j.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};j.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ms=0,De=1,_e=2;j.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(no(t))return e.lastIntValue=-1,e.advance(),De;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===_e&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Ms};function no(e){return e===100||e===68||e===115||e===83||e===119||e===87}j.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),De}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Ms};j.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){ht(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};j.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return De;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return _e;e.raise("Invalid property name")};j.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Os(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function Os(e){return Rs(e)||e===95}j.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";ro(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function ro(e){return Os(e)||un(e)}j.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};j.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===_e&&e.raise("Negated character class may contain strings"),!0}return!1};j.regexp_classContents=function(e){return e.current()===93?De:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),De)};j.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}};j.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Fs(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};j.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};j.regexp_classSetExpression=function(e){var t=De,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===_e&&(t=_e);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==_e&&(t=De);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===_e&&(t=_e)}};j.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};j.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?De:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};j.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===_e&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};j.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null};j.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===_e&&(t=_e);return t};j.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?De:_e};j.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&so(n)||io(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function so(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function io(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}j.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return ao(t)?(e.lastIntValue=t,e.advance(),!0):!1};function ao(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}j.regexp_eatClassControlLetter=function(e){var t=e.current();return un(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};j.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};j.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;un(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function un(e){return e>=48&&e<=57}j.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Bs(n=e.current());)e.lastIntValue=16*e.lastIntValue+Ds(n),e.advance();return e.pos!==t};function Bs(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ds(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}j.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1};j.regexp_eatOctalDigit=function(e){var t=e.current();return Fs(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Fs(e){return e>=48&&e<=55}j.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Bs(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Ds(s),e.advance()}return!0};var nr=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new nn(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},L=re.prototype;L.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new nr(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};L.getToken=function(){return this.next(),new nr(this)};typeof Symbol<"u"&&(L[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}});L.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(h.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};L.readToken=function(e){return Ce(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};L.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};L.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=cs(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};L.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!pt(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};L.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&ls.test(String.fromCharCode(e)))++this.pos;else break e}}};L.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};L.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))};L.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(h.assign,2):this.finishOp(h.slash,1)};L.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?h.star:h.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=h.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(h.assign,n+1):this.finishOp(r,n)};L.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(h.assign,3)}return this.finishOp(e===124?h.logicalOR:h.logicalAND,2)}return t===61?this.finishOp(h.assign,2):this.finishOp(e===124?h.bitwiseOR:h.bitwiseAND,1)};L.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)};L.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||ge.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(h.incDec,2):t===61?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)};L.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(h.relational,n))};L.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(h.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(e===61?h.eq:h.prefix,1)};L.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(h.assign,3)}return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)};L.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ce(t,!0)||t===92))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Be(t)+"'")};L.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Be(e)+"'")};L.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};L.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(ge.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,i)}catch{}return this.finishToken(h.regexp,{pattern:s,flags:i,value:u})};L.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,u=0,c=t??1/0;u<c;++u,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(r&&l===95){s&&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"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;continue}if(l>=97?p=l-97+10:l>=65?p=l-65+10:l>=48&&l<=57?p=l-48:p=1/0,p>=e)break;o=l,i=i*e+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function oo(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ls(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}L.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ls(this.input.slice(t,this.pos)),++this.pos):Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)};L.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=Ls(this.input.slice(t,this.pos));return++this.pos,Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,s)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=oo(this.input.slice(t,this.pos),n);return this.finishToken(h.num,a)};L.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};L.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=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)):(pt(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var Vs={};L.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Vs)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};L.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Vs;this.raise(e,t)};L.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===h.template||this.type===h.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(pt(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
+
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};L.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(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
7
|
`&&++this.pos;case`
|
|
8
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};
|
|
9
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Be(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return pt(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};L.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Be(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return pt(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};L.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};L.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(Je(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var i=this.readCodePoint();(t?Ce:Je)(i,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Be(i),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};L.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=Zn[e]),this.finishToken(t,e)};var uo="8.15.0";re.acorn={Parser:re,version:uo,defaultOptions:Gn,Position:Tt,SourceLocation:nn,getLineInfo:ps,Node:on,TokenType:W,tokTypes:h,keywordTypes:Zn,TokContext:ke,tokContexts:Y,isIdentifierChar:Je,isIdentifierStart:Ce,Token:nr,isNewLine:pt,lineBreak:ge,lineBreakG:ja,nonASCIIwhitespace:ls};function je(e,t){return re.parse(e,t)}function Pt(e,t,n){return re.parseExpressionAt(e,t,n)}var K=class extends Error{line;column;source;filename;constructor(t,n,r,s){let a=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${a}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},ne=class extends K{constructor(t,n,r,s){super(t,n,r,s),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
|
|
10
10
|
`),r=this.line-1,s=Math.max(0,r-t),a=Math.min(n.length-1,r+t),i=[],o=String(a+1).length;for(let u=s;u<=a;u++){let c=String(u+1).padStart(o),l=u===r?">":" ";if(i.push(`${l} ${c} | ${n[u]}`),u===r){let p=" ".repeat(o+4+this.column);i.push(`${p}^ ${this.message.split(" at ")[0]}`)}}return i.join(`
|
|
11
|
-
`)}};function Se(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function Z(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Ee(e,t,n,r,s){n||(n
|
|
12
|
-
`)}var ln=e=>e&&e.type==="Literal"&&typeof e.value=="string";function
|
|
13
|
-
${fn(r.diagnostics)}`);let s=n.fuel??1e6,a=
|
|
11
|
+
`)}};function Se(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function Z(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Ee(e,t,n,r,s){n||(n=C),(function a(i,o,u){var c=u||i.type;n[c](i,o,a),t[c]&&t[c](i,o)})(e,r,s)}function qs(e,t,n,r,s){var a=[];n||(n=C),(function i(o,u,c){var l=c||o.type,p=o!==a[a.length-1];p&&a.push(o),n[l](o,u,i),t[l]&&t[l](o,u||a,a),p&&a.pop()})(e,r,s)}function rr(e,t,n){n(e,t)}function Xe(e,t,n){}var C={};C.Program=C.BlockStatement=C.StaticBlock=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};C.Statement=rr;C.EmptyStatement=Xe;C.ExpressionStatement=C.ParenthesizedExpression=C.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")};C.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")};C.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")};C.BreakStatement=C.ContinueStatement=Xe;C.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")};C.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var r=0,s=e.cases;r<s.length;r+=1){var a=s[r];n(a,t)}};C.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var r=0,s=e.consequent;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};C.ReturnStatement=C.YieldExpression=C.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")};C.ThrowStatement=C.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")};C.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")};C.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")};C.WhileStatement=C.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")};C.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")};C.ForInStatement=C.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")};C.ForInit=function(e,t,n){e.type==="VariableDeclaration"?n(e,t):n(e,t,"Expression")};C.DebuggerStatement=Xe;C.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")};C.VariableDeclaration=function(e,t,n){for(var r=0,s=e.declarations;r<s.length;r+=1){var a=s[r];n(a,t)}};C.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")};C.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var r=0,s=e.params;r<s.length;r+=1){var a=s[r];n(a,t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")};C.Pattern=function(e,t,n){e.type==="Identifier"?n(e,t,"VariablePattern"):e.type==="MemberExpression"?n(e,t,"MemberPattern"):n(e,t)};C.VariablePattern=Xe;C.MemberPattern=rr;C.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")};C.ArrayPattern=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Pattern")}};C.ObjectPattern=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];a.type==="Property"?(a.computed&&n(a.key,t,"Expression"),n(a.value,t,"Pattern")):a.type==="RestElement"&&n(a.argument,t,"Pattern")}};C.Expression=rr;C.ThisExpression=C.Super=C.MetaProperty=Xe;C.ArrayExpression=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Expression")}};C.ObjectExpression=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];n(a,t)}};C.FunctionExpression=C.ArrowFunctionExpression=C.FunctionDeclaration;C.SequenceExpression=function(e,t,n){for(var r=0,s=e.expressions;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};C.TemplateLiteral=function(e,t,n){for(var r=0,s=e.quasis;r<s.length;r+=1){var a=s[r];n(a,t)}for(var i=0,o=e.expressions;i<o.length;i+=1){var u=o[i];n(u,t,"Expression")}};C.TemplateElement=Xe;C.UnaryExpression=C.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")};C.BinaryExpression=C.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")};C.AssignmentExpression=C.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")};C.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")};C.NewExpression=C.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var r=0,s=e.arguments;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};C.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")};C.ExportNamedDeclaration=C.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,e.type==="ExportNamedDeclaration"||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")};C.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")};C.ImportDeclaration=function(e,t,n){for(var r=0,s=e.specifiers;r<s.length;r+=1){var a=s[r];n(a,t)}n(e.source,t,"Expression")};C.ImportExpression=function(e,t,n){n(e.source,t,"Expression")};C.ImportSpecifier=C.ImportDefaultSpecifier=C.ImportNamespaceSpecifier=C.Identifier=C.PrivateIdentifier=C.Literal=Xe;C.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")};C.ClassDeclaration=C.ClassExpression=function(e,t,n){return n(e,t,"Class")};C.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)};C.ClassBody=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t)}};C.MethodDefinition=C.PropertyDefinition=C.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};var co=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","String","Number","Boolean","Array","Object","Eq","NotEq","Is","IsNot","TypeOf"]),lo=new Set(["Math","JSON","Object","Array","String","Number"]),fo=new Set(["Math.random","Date.now"]);function Ws(e,t){let n=e[t],r=0;if(n==="*"||n==="+")r=1;else if(n==="{"){let s=e.slice(t).match(/^\{\d+,\}/);s&&(r=s[0].length)}return r===0?0:(e[t+r]==="?"&&r++,r)}function po(e){let t=[],n=0,r=!1;for(;n<e.length;){let s=e[n];if(s==="\\"){n+=2;continue}if(r){s==="]"&&(r=!1),n++;continue}if(s==="["){r=!0,n++;continue}if(s==="("){t.push({hadUnbounded:!1}),n++;continue}if(s===")"){let i=t.pop()??{hadUnbounded:!1},o=Ws(e,n+1);if(o>0){if(i.hadUnbounded)return"an unbounded quantifier is nested inside another (e.g. `(a+)+`)";t.length&&(t[t.length-1].hadUnbounded=!0),n+=1+o;continue}i.hadUnbounded&&t.length&&(t[t.length-1].hadUnbounded=!0),n++;continue}let a=Ws(e,n);if(a>0){t.length&&(t[t.length-1].hadUnbounded=!0),n+=a;continue}n++}return null}var ho=new Set(["startsWith","endsWith","includes","indexOf","lastIndexOf","slice","substring","substr","toLowerCase","toUpperCase","trim","trimStart","trimEnd","split","replace","replaceAll","match","matchAll","charAt","charCodeAt","codePointAt","padStart","padEnd","repeat","concat","at","normalize","search","localeCompare","every","some","map","filter","reduce","reduceRight","find","findIndex","findLast","findLastIndex","flat","flatMap","join","keys","entries","values","forEach","test","exec","toFixed","toPrecision","toString","valueOf","hasOwnProperty"]),sr=["fetch","XMLHttpRequest","WebSocket","Date","console","setTimeout","setInterval","requestAnimationFrame","queueMicrotask","localStorage","sessionStorage","indexedDB","document","window","globalThis","self","process","require","eval","Function","import","crypto","performance","navigator"];function mo(e){let t=new Set(sr);for(let[n,r]of Object.entries(e))r?.effects==="io"&&t.add(r.op??n);return t}function et(e,t={}){let n=t.effectful??new Set(sr),r;try{r=je(e,{ecmaVersion:"latest",locations:!0})}catch(i){return{safe:!1,predicates:[],diagnostics:[{predicate:"<source>",message:`parse error: ${i.message}`,line:i.loc?.line??0,column:i.loc?.column??0}]}}let s=new Set(t.knownPredicates??[]);for(let i of r.body)i.type==="FunctionDeclaration"&&i.id&&s.add(i.id.name);let a=[];for(let i of r.body){if(i.type!=="FunctionDeclaration"||!i.id)continue;let o=i.id.name,u=(l,p)=>a.push({predicate:o,message:l,line:p?.loc?.start?.line??0,column:p?.loc?.start?.column??0}),c=l=>u("loops are not allowed \u2014 iterate with recursion or array methods (every/some/map/filter/reduce) so work stays fuel-bounded",l);Ee(i,{AwaitExpression(l){u("`await` not allowed \u2014 predicates must be synchronous",l)},NewExpression(l){u("`new` not allowed in a predicate (non-pure construction)",l)},WhileStatement:c,DoWhileStatement:c,ForStatement:c,ForInStatement:c,ForOfStatement:c,Literal(l){if(l.regex&&typeof l.regex.pattern=="string"){let p=po(l.regex.pattern);p&&u(`regex /${l.regex.pattern}/ risks catastrophic backtracking (ReDoS): ${p}. A single match is not fuel-bounded, so it can't be certified predicate-safe \u2014 simplify the pattern or validate without it.`,l)}},CallExpression(l){let p=l.callee;if(p.type==="Identifier"){let f=p.name;n.has(f)?u(`'${f}' is effectful \u2014 not allowed in a predicate`,p):s.has(f)||co.has(f)||u(`unknown reference '${f}' \u2014 not a predicate or pure builtin`,p);return}if(p.type==="MemberExpression"&&!p.computed){let f=p.property.name,d=p.object;d.type==="Identifier"&&n.has(d.name)?u(`'${d.name}.${f}' is effectful`,p):d.type==="Identifier"&&lo.has(d.name)?fo.has(`${d.name}.${f}`)&&u(`'${d.name}.${f}' is nondeterministic`,p):ho.has(f)||u(`method '.${f}()' is not a known pure method`,p.property);return}u("unsupported call form in a predicate",p)}})}return{safe:a.length===0,predicates:[...s],diagnostics:a}}function fn(e){return e.map(t=>` ${t.predicate} (${t.line}:${t.column}): ${t.message}`).join(`
|
|
12
|
+
`)}var ln=e=>e&&e.type==="Literal"&&typeof e.value=="string";function go(e,t={}){let n;try{n=je(e,{ecmaVersion:"latest"})}catch{return[]}let r=new Set,s=new Set;Ee(n,{BinaryExpression(u){(u.operator==="=="||u.operator==="===")&&(ln(u.left)&&r.add(u.left.value),ln(u.right)&&r.add(u.right.value))},ArrayExpression(u){for(let c of u.elements)ln(c)&&r.add(c.value)},CallExpression(u){let c=u.callee;if(c.type!=="MemberExpression"||c.computed)return;let l=c.property.name,p=u.arguments[0];ln(p)&&l==="startsWith"&&s.add(p.value)}});let a=null;if(t.validate!==!1){let u=et(e,t);if(u.safe&&u.predicates.length){let c=t.entry??u.predicates[u.predicates.length-1];try{let p=It(e,[c],t)[c];a=f=>{try{return p(f)===!0}catch{return!1}}}catch{a=null}}}let i=[];for(let u of r)(!a||a(u))&&i.push({value:u,kind:"value"});for(let u of s)i.push({value:u,kind:"stub"});let o=i;if(t.prefix){let u=t.prefix;o=i.filter(c=>c.value.startsWith(u)||c.kind==="stub"&&u.startsWith(c.value))}return o.sort((u,c)=>(u.kind===c.kind?0:u.kind==="value"?-1:1)||u.value.localeCompare(c.value)),t.limit?o.slice(0,t.limit):o}var jt=class extends Error{constructor(t){super(`predicate exceeded its fuel budget (${t})`),this.name="PredicateFuelExhausted"}};function Js(e){let t=je(e,{ecmaVersion:"latest"}),n=[],r=a=>n.push([a.body.start+1,"__fuel();"]);Ee(t,{FunctionDeclaration:r,FunctionExpression:r,ArrowFunctionExpression(a){a.body.type==="BlockStatement"?n.push([a.body.start+1,"__fuel();"]):(n.push([a.body.start,"(__fuel(), "]),n.push([a.body.end,")"]))}}),n.sort((a,i)=>i[0]-a[0]);let s=e;for(let[a,i]of n)s=s.slice(0,a)+i+s.slice(a);return s}function It(e,t,n={}){let r=et(e,n);if(!r.safe)throw new Error(`Not predicate-safe:
|
|
13
|
+
${fn(r.diagnostics)}`);let s=n.fuel??1e6,a=Js(e),i=sr.filter(f=>f!=="import"&&f!=="eval"&&f!=="arguments"),o=new Function("__fuel",...i,`"use strict";
|
|
14
14
|
${a}
|
|
15
|
-
;return { ${t.join(", ")} };`),u=0,l=o(()=>{if(--u<0)throw new jt(s)},...i.map(()=>{})),p={};for(let f of t){let d=l[f];p[f]=(...m)=>{u=s;try{return d(...m)}catch(y){throw y instanceof RangeError&&/stack/i.test(y.message)?new jt(s):y}}}return p}function
|
|
16
|
-
`);if(
|
|
17
|
-
${l}${
|
|
15
|
+
;return { ${t.join(", ")} };`),u=0,l=o(()=>{if(--u<0)throw new jt(s)},...i.map(()=>{})),p={};for(let f of t){let d=l[f];p[f]=(...m)=>{u=s;try{return d(...m)}catch(y){throw y instanceof RangeError&&/stack/i.test(y.message)?new jt(s):y}}}return p}function ir(e,t,n={}){let r=et(e,n);if(!r.safe)return{safe:!1,diagnostics:r.diagnostics};if(!r.predicates.includes(t))return{safe:!1,diagnostics:[{predicate:t,message:`entry predicate '${t}' not found in the verified cluster`,line:0,column:0}]};let s=n.fuel??1e6;return{safe:!0,code:`(() => {let __f = 0;const __fuel = () => { if (--__f < 0) throw new RangeError('tjs:predicate-fuel'); };${Js(e)}return (...__a) => {__f = ${s};try { return !!${t}(...__a); }catch (e) {if (e instanceof RangeError && /tjs:predicate-fuel|stack/i.test(e.message)) return false;throw e;}};})()`,diagnostics:[]}}function yo(e={}){let{onUnsafe:t,...n}=e,r=new Map,s=new Set;return(a,i)=>{let o=r.get(a);if(o===void 0){try{let u=et(a,n).predicates,c=u[u.length-1];if(!c)throw new Error("$predicate declares no function");o=It(a,[c],n)[c]}catch(u){if(o=null,!s.has(a)){s.add(a);let c=u instanceof Error?u:new Error(String(u));t?t(a,c):console.warn(`[tjs-lang] $predicate not verifiable \u2014 failing closed: ${c.message}`)}}r.set(a,o)}if(o===null)return!1;try{return o(i)===!0}catch{return!1}}}function bo(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,a=r+1;for(;a<e.length&&s>0;)e[a]==="{"?s++:e[a]==="}"&&s--,a++;if(s!==0)return null;let i=e.slice(r,a),o=[n[0].slice(0,-1)+i,i];return o.index=n.index,o}function ar(e,t,n,r,s,a){let i=`__pred_${e}`,o=`function ${i}(${n}) { ${r} }`,u=ir(o,i,s?{knownPredicates:new Set(s)}:{});return u.safe?(a?.push({name:e,kind:t,verified:!0}),u.code):(a?.push({name:e,kind:t,verified:!1,reason:fn(u.diagnostics).replace(/__pred_/g,"")}),null)}function Zs(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let a=n+r[0].length-1+1,i=1,o=a;for(;o<e.length&&i>0;){let c=e[o];c==="{"?i++:c==="}"&&i--,o++}if(i!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let c=e.slice(a,o-1);t+=`try {${c}} catch (__try_err) { return new (__tjs?.MonadicError ?? Error)(__try_err?.message || String(__try_err), 'try', undefined, undefined, __tjs?.getStack?.()) }`,n=o}}else t+=e[n],n++}return t}function Qs(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let i=r,o=r+a[0].length,u=1,c=o;for(;c<e.length&&u>0;){let w=e[c];w==="{"?u++:w==="}"&&u--,c++}if(u!==0){n+=e[r],r++;continue}let l=e.slice(o,c-1),p,f=c,d=e.slice(c).match(/^\s*fallback\s*\{/);if(d){let w=c+d[0].length;u=1;let E=w;for(;E<e.length&&u>0;){let $=e[E];$==="{"?u++:$==="}"&&u--,E++}u===0&&(p=e.slice(w,E-1),f=E)}let y=wo(l).map(w=>{let E=So(e,i,w);return E?`${w}: ${E}`:w}),x={id:`__tjs_wasm_${s}`,body:l,fallback:p,captures:y,start:i,end:f};t.push(x);let S=p??l,v=y.map(w=>w.split(":")[0].trim()),b=v.length>0?v.join(", "):"",_=v.length>0?`globalThis.${x.id}(${b})`:`globalThis.${x.id}()`,k=`((globalThis.__tjs_wasm_enabled !== false && globalThis.${x.id}) ? ${_} : (() => {${S}})())`;n+=k,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Ys(e){let t=[],n="",r=0;for(;r<e.length;){let s=/^\b(export\s+)?wasm\s+function\s+(\w+)\s*\(/,a=e.slice(r).match(s);if(!a){n+=e[r],r++;continue}let i=!!a[1],o=a[2],u=r,c=r+a[0].length,l=1,p=c;for(;p<e.length&&l>0;)e[p]==="("?l++:e[p]===")"&&l--,p++;if(l!==0){n+=e[r],r++;continue}let f=e.slice(c,p-1);if(f.match(/^\s*!/))throw new ne(`Unsafe wasm functions (with \`!\` marker) are reserved for a future phase. Remove the bang from \`wasm function ${o}\` to declare it as a regular (pure) wasm function, or wait until the unsafe variant is implemented.`,Le(e,u));let m,y=p,x=e.slice(p).match(/^\s*:\s*(\w+)/);x&&(m=x[1],y=p+x[0].length);let S=e.slice(y).match(/^\s*\{/);if(!S){n+=e[r],r++;continue}let v=y+S[0].length,b=1,_=v;for(;_<e.length&&b>0;)e[_]==="{"?b++:e[_]==="}"&&b--,_++;if(b!==0){n+=e[r],r++;continue}let k=e.slice(v,_-1),w=xo(f),E=`__tjs_wasm_${o}`,$={id:E,name:o,returnType:m,body:k,captures:w,start:u,end:_};t.push($);let T=w.map(F=>F.split(":")[0].trim()),P=`${i?"export ":""}function ${o}(${T.join(", ")}) { return globalThis.${E}(${T.join(", ")}) }`;n+=P,r=_}return{source:n,blocks:t}}function Xs(e,t){let{loader:n,importerPath:r}=t;if(!n)return{source:e,blocks:[]};let s=[],a=new Set;function i(c,l){if(!a.has(c.id)){s.push(c),a.add(c.id);for(let[p,f]of l){if(p===c.name||a.has(f.id))continue;new RegExp(`\\b${p}\\s*\\(`).test(c.body)&&i(f,l)}}}let o=/^(\s*)import\s*\{([^}]*?)\}\s*from\s*(['"])([^'"]+)\3\s*;?\s*$/gm;return{source:e.replace(o,(c,l,p,f,d)=>{let m=n.load(d,r);if(!m)return c;let y=new Map;for(let k of m.parseResult.wasmBlocks)k.name&&y.set(k.name,k);if(y.size===0)return c;let x=p.split(",").map(k=>k.trim()).filter(k=>k.length>0),S=[],v=[];for(let k of x){let w=k.match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!w){v.push(k);continue}let E=w[1],$=w[2]??w[1],T=y.get(E);if(!T){v.push(k);continue}i(T,y);let N=T.captures.map(P=>P.split(":")[0].trim());S.push(`function ${$}(${N.join(", ")}) { return globalThis.${T.id}(${N.join(", ")}) }`)}let b=S.join(`
|
|
16
|
+
`);if(v.length===0)return b?`${l}${b}`:`${l}`;let _=`${l}import { ${v.join(", ")} } from '${d}'`;return b?`${_}
|
|
17
|
+
${l}${b}`:_}),blocks:s}}function xo(e){let t=e.trim();return t?t.split(",").map(n=>n.trim()).filter(n=>n.length>0):[]}function _o(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function wo(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s;for(;(s=r.exec(t))!==null;)n.add(s[1]);let a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i=new Set;for(;(s=a.exec(t))!==null;)i.add(s[1]);for(let f of n){if(!i.has(f))continue;let d=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),m=new RegExp(`\\.${f}\\b`,"g"),y=t.match(d)?.length||0,x=t.match(m)?.length||0;y<=x&&i.delete(f)}let o=new Set,u=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.exec(t))!==null;)o.add(s[1]);let c=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=c.exec(t))!==null;)o.add(s[1]);let l=new Set(["if","else","for","while","do","switch","case","break","continue","return","function","let","const","var","new","this","true","false","null","undefined","typeof","instanceof","in","of","try","catch","finally","throw","async","await","class","extends","super","import","export","default","from","as","static","get","set","yield","console","Math","Array","Object","String","Number","Boolean","Date","JSON","Promise","Map","Set","WeakMap","WeakSet","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","ArrayBuffer","DataView","Error","TypeError","RangeError","length","push","pop","shift","unshift","slice","splice","map","filter","reduce","forEach","find","findIndex","indexOf","includes","globalThis","window","document","Infinity","NaN","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","eval","wasmBuffer"]),p=[];for(let f of i)!o.has(f)&&!l.has(f)&&!_o(f)&&p.push(f);return p.sort()}function So(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(s);if(!a){let i=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(i);return o?zs(o[1],n):void 0}return zs(a[1],n)}function zs(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let s=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(s)return s[1];let a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function Rt(e){let t=`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,n=new RegExp(t+"\\s+IsNot\\s+"+t,"g");e=e.replace(n,"IsNot($1, $2)");let r=new RegExp(t+"\\s+Is\\s+"+t,"g");return e=e.replace(r,"Is($1, $2)"),e}function ei(e){let t=/^[\s]*[([`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,s=e.split(`
|
|
18
18
|
`),a=[],i=!1;for(let o=0;o<s.length;o++){let u=s[o],c=o>0?s[o-1]:"";if(i){a.push(u),u.includes("*/")&&(i=!1);continue}let l=u.indexOf("/*"),p=u.indexOf("*/");if(l!==-1&&(p===-1||p<l)){i=!0,a.push(u);continue}if(o>0&&t.test(u)){let f=c.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!n.test(f)&&!r.test(f)){let d=u.match(/^(\s*)/),m=d?d[1]:"",y=u.slice(m.length);a.push(m+";"+y);continue}}a.push(u)}return a.join(`
|
|
19
|
-
`)}function
|
|
20
|
-
`&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let u=n+6;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let c=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;for(;u<e.length;)if(e[u]==="."&&/[a-zA-Z_$]/.test(e[u+1]??""))for(u++;u<e.length&&/[\w$]/.test(e[u]);)u++;else if(e[u]==="?"&&e[u+1]==="."&&/[a-zA-Z_$]/.test(e[u+2]??""))for(u+=2;u<e.length&&/[\w$]/.test(e[u]);)u++;else break;t.push({keywordStart:n,operandEnd:u,operand:e.slice(c,u)}),n=u;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Mt(e){e=
|
|
21
|
-
`&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:u}=t[i],c=u==="=="?"Eq":"NotEq",l=
|
|
22
|
-
`,i);o===-1&&(o=e.length);let u=e.slice(i,o).trim();if(u){let c=
|
|
23
|
-
`||e[r-1]===";"||e[r-1]==="}"){let
|
|
19
|
+
`)}function vo(e){let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
|
|
20
|
+
`&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let u=n+6;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let c=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;for(;u<e.length;)if(e[u]==="."&&/[a-zA-Z_$]/.test(e[u+1]??""))for(u++;u<e.length&&/[\w$]/.test(e[u]);)u++;else if(e[u]==="?"&&e[u+1]==="."&&/[a-zA-Z_$]/.test(e[u+2]??""))for(u+=2;u<e.length&&/[\w$]/.test(e[u]);)u++;else break;t.push({keywordStart:n,operandEnd:u,operand:e.slice(c,u)}),n=u;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Mt(e){e=vo(e);let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
|
|
21
|
+
`&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:u}=t[i],c=u==="=="?"Eq":"NotEq",l=ko(a,o),p=Eo(a,o+2),f=a.slice(l,o).trim(),d=a.slice(o+2,p).trim();if(f&&d){let m=a.slice(0,l),y=a.slice(p),S=/[a-zA-Z0-9_$]$/.test(m)?" ":"";a=`${m}${S}${c}(${f}, ${d})${y}`}}return a}function ko(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,a="";for(;n>=0;){let i=e[n],o=n>0?e[n-1]:"";if(s){i===a&&o!=="\\"&&(s=!1),n--;continue}if((i==='"'||i==="'"||i==="`")&&o!=="\\"){s=!0,a=i,n--;continue}if(i===")"||i==="]"||i==="}"){r++,n--;continue}if(i==="("||i==="["){if(r>0){r--,n--;continue}return n+1}if(i==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(i===";")return n+1;if(/[a-z]/.test(i)){let u=n+1,c=n;for(;c>0&&/[a-z]/i.test(e[c-1]);)c--;let l=e.slice(c,u),p=c>0?e[c-1]:"";if(!/[a-zA-Z0-9_$]/.test(p)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(l))return u;if(l==="new")return c}}if(i===">"&&o==="="||i==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===",")return n+1;n--}return 0}function Eo(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return e.length;let r=0,s=!1,a="";for(;n<e.length;){let i=e[n],o=n+1<e.length?e[n+1]:"";if(s){i===a&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((i==='"'||i==="'"||i==="`")&&e[n-1]!=="\\"){s=!0,a=i,n++;continue}if(i==="("||i==="["||i==="{"){r++,n++;continue}if(i===")"||i==="]"||i==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(i===";"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===","||(i==="="||i==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function ti(e,t){let n="",r=0;for(;r<e.length;){let s=e.slice(r).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(s){let a=s[1],i=r+s[0].length,o=a,u=!1,c=e.slice(i).match(/^(['"`])([^]*?)\1\s*/);if(c){let d=i+c[0].length,m=e[d],y=m===void 0||d>=e.length||m!=="="&&m!=="{";if(m==="="||m==="{")o=c[2],u=!0,i=d;else if(y){let x=c[0].trim(),S=c[0].slice(x.length);n+=`const ${a} = Type('${a}', ${x})${S}`,r=d;continue}}let l,p=i,f=e.slice(i).match(/^=\s*/);if(f){i+=f[0].length;let d=e.slice(i).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(d){l=d[0],i+=d[0].length,p=i;let m=e.slice(i).match(/^\s*/);m&&(i+=m[0].length)}}if(e[i]==="{"){let d=i+1,m=1,y=d;for(;y<e.length&&m>0;){let w=e[y];w==="{"?m++:w==="}"&&m--,y++}if(m!==0){n+=e[r],r++;continue}let x=e.slice(d,y-1).trim(),S=y,v=x.match(/description\s*:\s*(['"`])([^]*?)\1/);v&&!u&&(o=v[2]);let b,_=x.match(/example\s*:\s*/);if(_){let w=_.index+_[0].length,E=xi(x,w);E&&(b=E.value.trim())}let k=x.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(k&&b){let w=k[1].trim(),E=k[2].trim(),$=l?`, ${l}`:"",T=`globalThis.__tjs?.validate(${w}, globalThis.__tjs?.infer(${b}))`,N=ar(a,"Type",w,E,void 0,t),P=N?`(__g => (${w}) => (${T} ? __g(${w}) : false))(${N})`:`(${w}) => { if (!${T}) return false; ${E} }`;n+=`const ${a} = Type('${o}', ${P}, ${b}${$})`}else if(k){let w=k[1].trim(),E=k[2].trim(),$=l?`, undefined, ${l}`:"",N=ar(a,"Type",w,E,void 0,t)??`(${w}) => { ${E} }`;n+=`const ${a} = Type('${o}', ${N}${$})`}else if(b){let w=l?`, ${l}`:"";n+=`const ${a} = Type('${o}', undefined, ${b}${w})`}else l?n+=`const ${a} = Type('${o}', ${l})`:n+=`const ${a} = Type('${o}')`;r=S;continue}else if(l){n+=`const ${a} = Type('${o}', ${l})`,r=p;continue}else if(!c){let d=e.slice(i).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(d){let m=d[0];n+=`const ${a} = Type('${a}', ${m})`,r=i+d[0].length;continue}}}n+=e[r],r++}return n}function ni(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(r){let s=r[1],a=r[2],i=n+r[0].length;if(e[i]==="{"){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=bo(c,/params\s*:\s*\{/),p=c.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=c.match(/returnContract\s*:\s*['"](\w+)['"]/),d=c.match(/description\s*:\s*(['"])([^]*?)\1/),m=[];l&&m.push(`params: ${l[1]}`),p&&m.push(`returns: ${p[1].trim()}`),f&&m.push(`returnContract: '${f[1]}'`);let y=d?d[2]:s;if(a){let x=a.split(",").map(v=>{let b=v.trim().split("=").map(_=>_.trim());if(b.length===2){let _=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${_}]`}return`'${b[0]}'`}),S=a.split(",").map(v=>v.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${y}', [${x.join(", ")}], (${S.join(", ")}) => ({ ${m.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${y}', { ${m.join(", ")} })`;n=u;continue}}if(e[i]==="("){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="("?o++:e[u]===")"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=c.indexOf(",");if(l!==-1){let p=c.slice(0,l).trim(),f=c.slice(l+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${p})`}else t+=`const ${s} = FunctionPredicate('${s}', ${c})`;n=u;continue}}}t+=e[n],n++}return t}function ri(e,t){let n="",r=0;for(;r<e.length;){let s=e.slice(r).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(s){let a=s[1],i=s[2],u=r+s[0].length-1+1,c=1,l=u;for(;l<e.length&&c>0;){let b=e[l];b==="{"?c++:b==="}"&&c--,l++}if(c!==0){n+=e[r],r++;continue}let p=e.slice(u,l-1).trim(),f=l,d=i.split(",").map(b=>{let _=b.trim().split("=").map(k=>k.trim());if(_.length===2){let k=_[1]==="any"||_[1]==="undefined"?"null":_[1];return`['${_[0]}', ${k}]`}return`'${_[0]}'`}),m=p,y=m.search(/\bdeclaration\s*\{/);if(y!==-1){let b=m.indexOf("{",y),_=1,k=b+1;for(;k<m.length&&_>0;)m[k]==="{"?_++:m[k]==="}"&&_--,k++;m=m.slice(0,y)+m.slice(k)}let x=m.match(/description\s*:\s*(['"`])([^]*?)\1/),S=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),v=x?x[2]:a;if(S){let b=S[1].trim().split(",").map(P=>P.trim()),_=S[2].trim(),k=b[0]||"x",w=b.slice(1),E=w.map(P=>`check${P}`);w.forEach((P,F)=>{_=_.replace(new RegExp(`\\b${P}\\s*\\(`,"g"),`${E[F]}(`)});let $=[k,...E].join(", "),N=ar(a,"Generic",$,_,E,t)??`(${$}) => { ${_} }`;n+=`const ${a} = Generic([${d.join(", ")}], ${N}, '${v}')`}else n+=`const ${a} = Generic([${d.join(", ")}], () => true, '${v}')`;r=f;continue}n+=e[r],r++}return n}function si(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(r){let s=r[1],a=r[3],i=n+r[0].length;if(e[i]==="{"){let o=i+1,u=1,c=o;for(;c<e.length&&u>0;){let d=e[c];d==="{"?u++:d==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,f=Gs(l);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=p;continue}else{let o=e.indexOf(`
|
|
22
|
+
`,i);o===-1&&(o=e.length);let u=e.slice(i,o).trim();if(u){let c=Gs(u);t+=`const ${s} = Union('${a}', [${c.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Gs(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function ii(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(r){let s=r[1],a=r[3],o=n+r[0].length-1+1,u=1,c=o;for(;c<e.length&&u>0;){let m=e[c];m==="{"?u++:m==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,d=To(l).map(([m,y])=>`${m}: ${y}`).join(", ");t+=`const ${s} = Enum('${a}', { ${d} })`,n=p;continue}t+=e[n],n++}return t}function To(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let a=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let i=a[1],o=a[2]?.trim();if(o!==void 0){t.push([i,o]);let u=Number(o);isNaN(u)||(n=u+1)}else t.push([i,String(n)]),n++}}return t}function ai(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),a=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){if(r===0||e[r-1]===`
|
|
23
|
+
`||e[r-1]===";"||e[r-1]==="}"){let b=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}n+=e[r],r++;continue}let i=a[1],o=a[2],u=r+a[0].length-1,c=Nt(e,u),l=e.slice(u+1,c-1).trim(),p=[],f=0,d=e.slice(u+1,c-1);for(;f<d.length;){let b=d.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!b){f++;continue}let _=b[1],k=!!b[2],w=b[3],E=f+b[0].length-1,$=1,T=E+1;for(;T<d.length&&$>0;)d[T]==="("&&$++,d[T]===")"&&$--,T++;let N=d.slice(E+1,T-1),P=T;for(;P<d.length&&/\s/.test(d[P]);)P++;if(d[P]==="="&&d[P+1]===">"){let te=Le(e,u+1+f);throw new ne(`Arrow functions are not allowed in extend blocks (method '${w}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,te)}if(d[P]!=="{"){f++;continue}let F=Nt(d,P),R=d.slice(f,F).trim(),J=N.split(",").map(te=>te.trim()).filter(te=>te.length>0).map(te=>{let ce=te.match(/^(\w+)\s*:\s*(.+)$/);return ce?`${ce[1]} = ${ce[2]}`:te}).join(", "),z=k?"async ":"",ee=d.slice(P+1,F-1);p.push({name:w,isAsync:k,fullText:`${w}: ${z}function(${J}) {${ee}}`}),f=F}let m=!t.has(o);m&&t.set(o,new Set);let y=t.get(o);for(let v of p)y.add(v.name);let x=p.map(v=>` ${v.fullText}`).join(`,
|
|
24
24
|
`),S;m?S=`${i}const __ext_${o} = {
|
|
25
25
|
${x}
|
|
26
26
|
${i}}
|
|
27
27
|
`:S=`${i}Object.assign(__ext_${o}, {
|
|
28
28
|
${x}
|
|
29
29
|
${i}})
|
|
30
|
-
`;for(let
|
|
30
|
+
`;for(let v of p)S+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${v.name}', __ext_${o}.${v.name}) }
|
|
31
31
|
`;n+=S,r=c}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function Ot(e,t){if(t.size===0)return e;let n=new Map;for(let[s,a]of t)for(let i of a)n.has(i)||n.set(i,[]),n.get(i).push(s);let r=e;for(let[s,a]of n){if(!a.includes("String"))continue;let i=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(i,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let u=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(u,(c,l,p)=>p?`__ext_String.${s}.call(${l})`:`__ext_String.${s}.call(${l}, `)}for(let[s,a]of n){if(!a.includes("Array"))continue;let i=`].${s}(`,o=0,u;for(;(u=r.indexOf(i,o))!==-1;){let c=1,l=u-1,p=!1;for(;l>=0&&c>0;){let f=r[l];p?f===p&&(l===0||r[l-1]!=="\\")&&(p=!1):(f==="]"&&c++,f==="["&&c--,(f==="'"||f==='"'||f==="`")&&(p=f)),l--}if(c===0){let f=r.slice(l+1,u+1),d=r.slice(0,l+1),m=r.slice(u+i.length);m[0]===")"?r=`${d}__ext_Array.${s}.call(${f})${m.slice(1)}`:r=`${d}__ext_Array.${s}.call(${f}, ${m}`}o=u+1}}for(let[s,a]of n){if(!a.includes("Number"))continue;let i=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(i,(o,u,c,l)=>l?`__ext_Number.${c}.call(${u})`:`__ext_Number.${c}.call(${u}, `)}return r}function Le(e,t){let n=1,r=0;for(let s=0;s<t&&s<e.length;s++)e[s]===`
|
|
32
|
-
`?(n++,r=0):r++;return{line:n,column:r}}function
|
|
33
|
-
`&&(a=!1),r++;continue}if(i){if(o==="*"&&u==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&u==="/"){a=!0,r+=2;continue}if(o==="/"&&u==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function
|
|
32
|
+
`?(n++,r=0):r++;return{line:n,column:r}}function oi(e,t){let n=t.trim();return/^['"`]/.test(n)?`typeof ${e} === 'string'`:n==="true"||n==="false"?`typeof ${e} === 'boolean'`:n==="null"?`${e} === null`:n==="undefined"?`${e} === undefined`:n.startsWith("[")?`Array.isArray(${e})`:n.startsWith("{")?`(typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e}))`:/^\+\d+/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}) && ${e} >= 0)`:/^-?\d+\.\d+/.test(n)?`typeof ${e} === 'number'`:/^-?\d+$/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}))`:"true"}function pn(e){let t=e.trim();return/^['"`]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":t.startsWith("[")?"array":t.startsWith("{")?"object":/^\+\d+/.test(t)?"non-negative-integer":/^-?\d+\.\d+/.test(t)?"number":/^-?\d+$/.test(t)?"integer":"any"}function or(e,t){let n=[],r=0,s="",a=!1;for(let o=0;o<e.length;o++){let u=e[o];if(!a&&(u==="'"||u==='"'||u==="`")){a=u,s+=u;continue}if(a){if(s+=u,u==="\\"){o++,o<e.length&&(s+=e[o]);continue}u===a&&(a=!1);continue}if(u==="("||u==="["||u==="{"){r++,s+=u;continue}if(u===")"||u==="]"||u==="}"){r--,s+=u;continue}if(u===","&&r===0){let c=Hs(s.trim(),t);c&&n.push(c),s="";continue}s+=u}let i=s.trim();if(i){let o=Hs(i,t);o&&n.push(o)}return n}function Hs(e,t){let n=e.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(n.startsWith("..."))return null;let r=n.indexOf("=");if(r===-1)return{name:n.trim(),defaultValue:"",required:!0};let s=n.slice(0,r).trim(),a=n.slice(r+1).trim();return{name:s,defaultValue:a,required:t.has(s)}}function Nt(e,t){let n=1,r=t+1,s=!1,a=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r],u=r+1<e.length?e[r+1]:"";if(a){o===`
|
|
33
|
+
`&&(a=!1),r++;continue}if(i){if(o==="*"&&u==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&u==="/"){a=!0,r+=2;continue}if(o==="/"&&u==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function ui(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,a,i=[];for(;(a=r.exec(e))!==null;){let p=!!a[1],f=!!a[2],d=a[3],m=a.index,y=m,S=a[0].indexOf("function");S>=0&&(y=m+S),i.push({name:d,fullMatchStart:m,funcKeywordStart:y,exported:p,isAsync:f})}for(let p of i)s.has(p.name)||s.set(p.name,[]);let o=new Map;for(let p of i)o.set(p.name,(o.get(p.name)||0)+1);let u=new Set;for(let[p,f]of o)f>1&&u.add(p);if(u.size===0)return{source:e,polymorphicNames:n};for(let p of i){if(!u.has(p.name))continue;let f=e.indexOf("(",p.funcKeywordStart);if(f===-1)continue;let d=1,m=f+1;for(;m<e.length&&d>0;)e[m]==="("&&d++,e[m]===")"&&d--,m++;let y=m-1,x=e.slice(f+1,y),S=m;for(;S<e.length&&e[S]!=="{";)S++;if(S>=e.length)continue;let v=Nt(e,S),b=p.fullMatchStart;for(;b>0&&e[b-1]===" ";)b--;let _=s.get(p.name),k=or(x,t);if(x.includes("...")){let E=Le(e,p.funcKeywordStart);throw new ne(`Rest parameters are not supported in polymorphic function '${p.name}'. Use separate function names instead.`,E)}_.push({index:_.length+1,start:b,end:v,text:e.slice(b,v),exported:p.exported,isAsync:p.isAsync,params:k})}for(let[p,f]of s){if(f.length<2)continue;let d=f.filter(m=>m.isAsync).length;if(d>0&&d<f.length){let m=Le(e,f[0].start);throw new ne(`Polymorphic function '${p}': all variants must be either sync or async, not mixed.`,m)}for(let m=0;m<f.length;m++)for(let y=m+1;y<f.length;y++){let x=f[m],S=f[y];if(x.params.length!==S.params.length)continue;let v=!0;for(let b=0;b<x.params.length;b++){let _=x.params[b].defaultValue?pn(x.params[b].defaultValue):"any",k=S.params[b].defaultValue?pn(S.params[b].defaultValue):"any";if(_!==k){v=!1;break}}if(v){let b=Le(e,S.start);throw new ne(`Polymorphic function '${p}': variants ${m+1} and ${y+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,b)}}}let c=[];for(let[p,f]of s)if(!(f.length<2))for(let d of f)c.push({name:p,variant:d});c.sort((p,f)=>f.variant.start-p.variant.start);let l=e;for(let{name:p,variant:f}of c){let d=f.isAsync?"async ":"",m=f.text.replace(new RegExp(`(?:export\\s+)?${d?d.replace(/\s+$/,"\\s+"):""}function\\s+${p}\\s*\\(`),`${d}function ${p}$$${f.index}(`);l=l.slice(0,f.start)+m+l.slice(f.end)}for(let[p,f]of s){if(f.length<2)continue;n.add(p);let d=f[0].isAsync,m=f.some(_=>_.exported),y=d?"async ":"",x=m?"export ":"",S=[...f].sort((_,k)=>{if(_.params.length!==k.params.length)return 0;let w=0,E=0;for(let $ of _.params){let T=$.defaultValue?pn($.defaultValue):"any";T==="non-negative-integer"?w+=3:T==="integer"?w+=2:T!=="any"&&(w+=1)}for(let $ of k.params){let T=$.defaultValue?pn($.defaultValue):"any";T==="non-negative-integer"?E+=3:T==="integer"?E+=2:T!=="any"&&(E+=1)}return E-w}),v=[];for(let _ of S){let k=[`__args.length === ${_.params.length}`],w=[];for(let E=0;E<_.params.length;E++){let $=_.params[E];if(w.push(`__args[${E}]`),$.defaultValue){let T=oi(`__args[${E}]`,$.defaultValue);T!=="true"&&k.push(T)}}v.push(` if (${k.join(" && ")}) return ${p}$${_.index}(${w.join(", ")})`)}let b=`
|
|
34
34
|
${x}${y}function ${p}(...__args) {
|
|
35
|
-
${
|
|
35
|
+
${v.join(`
|
|
36
36
|
`)}
|
|
37
37
|
return __tjs.typeError('${p}', 'no matching overload', __args)
|
|
38
38
|
}
|
|
39
|
-
`;l+=
|
|
40
|
-
`,d);d=S===-1?e.length:S+1;continue}if(x==="/"&&e[d+1]==="*"){let S=e.indexOf("*/",d+2);d=S===-1?e.length:S+2;continue}if(x==="'"||x==='"'||x==="`"){m=x,d++;continue}x==="{"?f++:x==="}"&&f--,d++}if(f===0){let x=e.slice(p,d-1).trim(),S=d,
|
|
41
|
-
${
|
|
42
|
-
`.repeat(
|
|
43
|
-
`&&
|
|
44
|
-
function ${u}$ctor$${w.index}(${w.paramStr}) {`,
|
|
45
|
-
const __obj = Object.create(${u}.prototype)`,
|
|
46
|
-
;(function() {${w.bodyText}}).call(__obj)`,
|
|
47
|
-
return __obj`,
|
|
39
|
+
`;l+=b}return{source:l,polymorphicNames:n}}function ci(e){let t=new Set,n=/\b(?:let|const|var|function|class)\s+([A-Z][a-zA-Z0-9_]*)/g;for(let r;r=n.exec(e);)t.add(r[1]);return e.replace(/(?<=^|[;\n{])(\s*)([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(r,s,a)=>t.has(a)?r:r.replace(a,`const ${a}`))}function li(e,t=!1){let n=[],r=[],s="",a=0;for(;a<e.length;){let i=e.slice(a).match(/^\btest\s+/);if(i){let o=a,u=a+i[0].length,c,l=e.slice(u).match(/^(['"`])([^]*?)\1\s*/);if(l&&(c=l[2],u+=l[0].length),e[u]==="{"){let p=u+1,f=1,d=p,m=null,y=!1;for(;d<e.length&&f>0;){let x=e[d];if(y){y=!1,d++;continue}if(x==="\\"&&m){y=!0,d++;continue}if(m){x===m&&(m=null),d++;continue}if(x==="/"&&e[d+1]==="/"){let S=e.indexOf(`
|
|
40
|
+
`,d);d=S===-1?e.length:S+1;continue}if(x==="/"&&e[d+1]==="*"){let S=e.indexOf("*/",d+2);d=S===-1?e.length:S+2;continue}if(x==="'"||x==='"'||x==="`"){m=x,d++;continue}x==="{"?f++:x==="}"&&f--,d++}if(f===0){let x=e.slice(p,d-1).trim(),S=d,v=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:c,body:x,start:o,end:S,line:v}),!t)try{new Function(x)()}catch(k){let w=c||`test at line ${v}`;r.push(`Test failed: ${w} (line ${v})
|
|
41
|
+
${k.message||k}`)}let _=(e.slice(o,S).match(/\n/g)||[]).length;s+=`
|
|
42
|
+
`.repeat(_),a=S;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function fi(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,a=[];for(;(s=r.exec(e))!==null;){let o=s[1],u=s[2]?.trim()||"",c=s.index+s[0].length-1,l=Nt(e,c),p=e.slice(c,l);a.push({className:o,extendsClause:u,bodyStart:c,bodyEnd:l,body:p})}let i=e;for(let o=a.length-1;o>=0;o--){let{className:u,extendsClause:c,bodyStart:l,bodyEnd:p,body:f}=a[o],d=/\bconstructor\s*\(/g,m,y=[];for(;(m=d.exec(f))!==null;)y.push(m.index);if(y.length<2)continue;n.add(u);let x=[];for(let k=0;k<y.length;k++){let w=y[k],E=f.indexOf("(",w),$=1,T=E+1;for(;T<f.length&&$>0;)f[T]==="("&&$++,f[T]===")"&&$--,T++;let N=f.slice(E+1,T-1),P=T;for(;P<f.length&&f[P]!=="{";)P++;let F=Nt(f,P),R=f.slice(P+1,F-1);x.push({index:k+1,paramStr:N,bodyText:R,fullStart:w,fullEnd:F})}let S=f;for(let k=x.length-1;k>=1;k--){let w=x[k],E=w.fullStart;for(;E>0&&S[E-1]===" ";)E--;E>0&&S[E-1]===`
|
|
43
|
+
`&&E--,S=S.slice(0,E)+S.slice(w.fullEnd)}let v="";for(let k=1;k<x.length;k++){let w=x[k],E=or(w.paramStr,t);if(w.paramStr.includes("...")){let T=Le(e,l+w.fullStart);throw new ne(`Rest parameters are not supported in polymorphic constructors for '${u}'.`,T)}v+=`
|
|
44
|
+
function ${u}$ctor$${w.index}(${w.paramStr}) {`,v+=`
|
|
45
|
+
const __obj = Object.create(${u}.prototype)`,v+=`
|
|
46
|
+
;(function() {${w.bodyText}}).call(__obj)`,v+=`
|
|
47
|
+
return __obj`,v+=`
|
|
48
48
|
}
|
|
49
|
-
`}let
|
|
49
|
+
`}let b=[];for(let k=0;k<x.length;k++){let w=x[k],E=or(w.paramStr,t),$=[`a.length === ${E.length}`];for(let T=0;T<E.length;T++){let N=E[T];if(N.defaultValue){let P=oi(`a[${T}]`,N.defaultValue);P!=="true"&&$.push(P)}}if(k===0)b.push(` if (${$.join(" && ")}) return Reflect.construct(t, a)`);else{let T=E.map((N,P)=>`a[${P}]`).join(", ");b.push(` if (${$.join(" && ")}) return ${u}$ctor$${w.index}(${T})`)}}v+=`
|
|
50
50
|
function ${u}$dispatch(t, a) {
|
|
51
|
-
`,
|
|
51
|
+
`,v+=b.join(`
|
|
52
52
|
`)+`
|
|
53
|
-
`,
|
|
54
|
-
`,
|
|
55
|
-
`,i=i.slice(0,l)+S+i.slice(p);let
|
|
56
|
-
`&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function
|
|
57
|
-
`&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&u==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&u==="/"){r+=2,s="line-comment";continue}if(o==="/"&&u==="*"){r+=2,s="block-comment";continue}if(o==="/"){let c=r-1;for(;c>=0&&/\s/.test(e[c]);)c--;let l=c>=0?e[c]:"";if(!l||/[=(!,;:{[&|?+\-*%<>~^]/.test(l)||c>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,c-10),c+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let c=r+4;for(;c<e.length&&/\s/.test(e[c]);)c++;if(c<e.length&&/[a-zA-Z_$]/.test(e[c])){let l=c;for(;c<e.length&&/[\w$]/.test(e[c]);)c++;let p=c,f=e.slice(l,p),d=c;for(;d<e.length&&/\s/.test(e[d]);)d++;if(d<e.length&&e[d]===":"&&e[d+1]!==":"){let y=d+1;for(;y<e.length&&/[ \t]/.test(e[y]);)y++;let x=
|
|
53
|
+
`,v+=` return __tjs.typeError('${u}', 'no matching constructor', a)
|
|
54
|
+
`,v+=`}
|
|
55
|
+
`,i=i.slice(0,l)+S+i.slice(p);let _=l+S.length;i=i.slice(0,_)+v+i.slice(_)}return{source:i,polyCtorClasses:n}}function pi(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,a;for(;(a=n.exec(e))!==null;){let i=a[1],o=a[2]||"",u=a.index,c=u+a[0].length-1,l=1,p=c+1;for(;p<e.length&&l>0;){let f=e[p];f==="{"?l++:f==="}"&&l--,p++}if(l===0){let f=p,d=e.slice(c,f);r+=e.slice(s,u),r+=`let ${i} = class ${i}${o} ${d}; `,t.has(i)?r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return ${i}$dispatch(t, a) }, construct(t, a) { return ${i}$dispatch(t, a) } });`:r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function hi(e){let t=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now()/Timestamp.from() for wall-clock dates, or performance.now() for a monotonic counter (timing, id generation)"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now() for a wall-clock date, or performance.now() for a monotonic counter (timing, id generation)"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:n,message:r}of t)if(n.test(e))throw new Error(r);return e}function di(e){let t=new Set,n=/\bconst!\s+(\w+)\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);if(t.size===0)return e;e=e.replace(/\bconst!\s+/g,"const ");let s=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);let c="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${a}\\s*\\.\\s*(?:${c})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function mi(e){if(/(?<![a-zA-Z_$])\bvar\s+/.test(e))throw new Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return e}function gi(e){if(/(?<![A-Za-z_$])\beval\s*\(/.test(e))throw new Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(e))throw new Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return e}function yi(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let a=e[n],i=e[n+1];if(r==="normal"){if(a==="/"&&i==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&i==="*"){r="block-comment",t+=a,n++;continue}if(a==="'"){r="string-single",t+=a,n++;continue}if(a==='"'){r="string-double",t+=a,n++;continue}if(a==="`"){r="string-template",s++,t+=a,n++;continue}if(a==="!"&&i==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,u=$o(t);if(u<o){let c=t.slice(u);t=t.slice(0,u);let l=n+2;for(;l<e.length&&/[\w$]/.test(e[l]);)l++;let p=e.slice(n+2,l);t+=`__tjs.bang(${c},'${p}')`,n=l;continue}}t+=a,n++}else r==="line-comment"?(t+=a,a===`
|
|
56
|
+
`&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function $o(e){let t=e.length-1;for(;t>=0&&/\s/.test(e[t]);)t--;if(t<0)return e.length;for(;t>=0;){let n=e[t];if(/[\w$]/.test(n)){for(;t>=0&&/[\w$]/.test(e[t]);)t--;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n===")"){if(t=Ks(e,t,"(",")"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n==="]"){if(t=Ks(e,t,"[","]"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else return t+1}return 0}function Ks(e,t,n,r){let s=1;for(t--;t>=0&&s>0;)e[t]===r?s++:e[t]===n&&s--,s>0&&t--;return t}function bi(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,s="normal",a=[];for(;r<e.length;){let o=e[r],u=e[r+1];switch(s){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(s="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(s="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&u==="{"){r+=2,a.push(1),s="normal";continue}o==="`"&&(s="normal"),r++;continue;case"line-comment":o===`
|
|
57
|
+
`&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&u==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&u==="/"){r+=2,s="line-comment";continue}if(o==="/"&&u==="*"){r+=2,s="block-comment";continue}if(o==="/"){let c=r-1;for(;c>=0&&/\s/.test(e[c]);)c--;let l=c>=0?e[c]:"";if(!l||/[=(!,;:{[&|?+\-*%<>~^]/.test(l)||c>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,c-10),c+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let c=r+4;for(;c<e.length&&/\s/.test(e[c]);)c++;if(c<e.length&&/[a-zA-Z_$]/.test(e[c])){let l=c;for(;c<e.length&&/[\w$]/.test(e[c]);)c++;let p=c,f=e.slice(l,p),d=c;for(;d<e.length&&/\s/.test(e[d]);)d++;if(d<e.length&&e[d]===":"&&e[d+1]!==":"){let y=d+1;for(;y<e.length&&/[ \t]/.test(e[y]);)y++;let x=Co(e,y);if(x>y){let S=e.slice(y,x).trim();t.set(f,S),n.push({start:p,end:x,replacement:""}),r=x;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let i=e;for(let o=n.length-1;o>=0;o--){let u=n[o];i=i.slice(0,u.start)+u.replacement+i.slice(u.end)}return{source:i,annotations:t}}function Co(e,t){let n=t,r=0,s=0,a=0,i="normal",o=[];for(;n<e.length;){let u=e[n];if(i==="sq"){if(u==="\\"){n+=2;continue}u==="'"&&(i="normal"),n++;continue}if(i==="dq"){if(u==="\\"){n+=2;continue}u==='"'&&(i="normal"),n++;continue}if(i==="tpl"){if(u==="\\"){n+=2;continue}if(u==="$"&&e[n+1]==="{"){o.push(1),i="normal",n+=2;continue}u==="`"&&(i="normal"),n++;continue}if(o.length>0){if(u==="{")o[o.length-1]++;else if(u==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),i="tpl",n++;continue}}if(u==="'"){i="sq",n++;continue}if(u==='"'){i="dq",n++;continue}if(u==="`"){i="tpl",n++;continue}if(u==="("?r++:u===")"?r--:u==="{"?s++:u==="}"?s--:u==="["?a++:u==="]"&&a--,r===0&&s===0&&a===0&&(u==="="||u===","||u===";"||u===`
|
|
58
58
|
`))return n;n++}return n}function gn(e,t){let n="",r=0,s,a,i="normal",o=[],u=[{type:"top-level",braceDepth:0}],c=0,l=()=>u[u.length-1]?.type||"top-level",p=()=>{let f=u[u.length-1];return f?.type==="class-body"&&c===f.braceDepth+1};for(;r<e.length;){let f=e[r],d=e[r+1];switch(i){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==="'"&&(i="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==='"'&&(i="normal"),r++;continue;case"template-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="$"&&d==="{"){n+=d,r+=2,o.push(1),i="normal";continue}f==="`"&&(i="normal"),r++;continue;case"line-comment":n+=f,f===`
|
|
59
|
-
`&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&d==="/"){n+=d,r+=2,i="normal";continue}r++;continue;case"regex":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="["){for(r++;r<e.length&&e[r]!=="]";)n+=e[r],e[r]==="\\"&&r+1<e.length?(n+=e[r+1],r+=2):r++;r<e.length&&(n+=e[r],r++);continue}if(f==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)n+=e[r],r++;i="normal";continue}r++;continue;case"normal":if(o.length>0){if(f==="{")o[o.length-1]++;else if(f==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),n+=f,r++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&d==="/"){n+=f+d,r+=2,i="line-comment";continue}if(f==="/"&&d==="*"){n+=f+d,r+=2,i="block-comment";continue}if(f==="/"){let
|
|
60
|
-
`})(),
|
|
61
|
-
`){s=!1,n+=o,i++;continue}if(a&&o==="*"&&u==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function
|
|
62
|
-
`,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function bn(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),u=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,c=u?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0};u&&(r="none");let l=e.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);l&&(r=l[2],e=e.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1"));let p=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval|TjsSafeAssign)\b/,f;for(;f=e.match(p);){let P=f[2];P==="TjsStrict"?(c.tjsEquals=!0,c.tjsClass=!0,c.tjsDate=!0,c.tjsNoeval=!0,c.tjsNoVar=!0,c.tjsStandard=!0,c.tjsSafeAssign=!0):P==="TjsCompat"?(c.tjsEquals=!1,c.tjsClass=!1,c.tjsDate=!1,c.tjsNoeval=!1,c.tjsNoVar=!1,c.tjsStandard=!1,c.tjsSafeEval=!1,c.tjsSafeAssign=!1):P==="TjsEquals"?c.tjsEquals=!0:P==="TjsClass"?c.tjsClass=!0:P==="TjsDate"?c.tjsDate=!0:P==="TjsNoeval"?c.tjsNoeval=!0:P==="TjsNoVar"?c.tjsNoVar=!0:P==="TjsStandard"?c.tjsStandard=!0:P==="TjsSafeEval"?c.tjsSafeEval=!0:P==="TjsSafeAssign"&&(c.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${P}\\s*`),"$1")}e=
|
|
59
|
+
`&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&d==="/"){n+=d,r+=2,i="normal";continue}r++;continue;case"regex":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="["){for(r++;r<e.length&&e[r]!=="]";)n+=e[r],e[r]==="\\"&&r+1<e.length?(n+=e[r+1],r+=2):r++;r<e.length&&(n+=e[r],r++);continue}if(f==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)n+=e[r],r++;i="normal";continue}r++;continue;case"normal":if(o.length>0){if(f==="{")o[o.length-1]++;else if(f==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),n+=f,r++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&d==="/"){n+=f+d,r+=2,i="line-comment";continue}if(f==="/"&&d==="*"){n+=f+d,r+=2,i="block-comment";continue}if(f==="/"){let b=n.trimEnd();if(!b[b.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(b)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(b)){n+=f,r++,i="regex";continue}}break}if(f==="{"){c++,n+=f,r++;continue}if(f==="}"){c--;let b=u[u.length-1];b&&c===b.braceDepth&&u.pop(),n+=f,r++;continue}let m=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(m){let b=m[0].slice(0,-1);n+=b,r+=b.length,u.push({type:"class-body",braceDepth:c});continue}let y=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(y){let b=y[1],_=y[0].length,k=e[r+_],w,E=r+_;(k==="?"||k==="!")&&(w=k,E++,w==="!"?t.unsafeFunctions.add(b):t.safeFunctions.add(b)),n+=`function ${b}(`,r=E;let $=hn(e,r,"(",")");if(!$){n+=e[r],r++;continue}let{content:T,endPos:N}=$;r=N;let P=cr(T,t,!0);n+=P+")";let F=r;for(;F<e.length&&/\s/.test(e[F]);)F++;if(e[F]===":"){let J=e.slice(F,F+2),z;for(J===":?"||J===":!"?(F+=2,z=J===":?"?"safe":"unsafe"):F+=1;F<e.length&&/\s/.test(e[F]);)F++;let ee=ur(e,F);ee&&(s===void 0&&(s=ee.type,z&&(a=z)),r=ee.endPos)}let R=r;for(;R<e.length&&/\s/.test(e[R]);)R++;if(e[R]==="="&&e[R+1]===">")throw new ne("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,R),t.originalSource);continue}let x=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),S=(()=>{for(let b=n.length-1;b>=0;b--)if(!/\s/.test(n[b]))return n[b];return`
|
|
60
|
+
`})(),v=S!=="="&&S!==","&&S!=="("&&S!=="["&&S!==">";if(x&&p()&&!v){let b=x[1].length;n+=e.slice(r,r+b),r+=b;continue}if(x&&p()&&v){let b=x[1],_=x[0].length,k=r+_;n+=b+"(",r=k;let w=hn(e,r,"(",")");if(!w){n+=e[r],r++;continue}let{content:E,endPos:$}=w;r=$;let T=cr(E,t,!0);n+=T+")";let N=r;for(;N<e.length&&/\s/.test(e[N]);)N++;if(e[N]===":"){let F=e.slice(N,N+2);for(F===":?"||F===":!"?N+=2:N++;N<e.length&&/\s/.test(e[N]);)N++;let R=ur(e,N);R&&(r=R.endPos)}let P=r;for(;P<e.length&&/\s/.test(e[P]);)P++;if(e[P]==="="&&e[P+1]===">")throw new ne("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,P),t.originalSource);continue}if(e[r]==="("){let b=hn(e,r+1,"(",")");if(!b){n+=e[r],r++;continue}let _=b.content,k=b.endPos,w=k;for(;w<e.length&&/\s/.test(e[w]);)w++;let E;if(e[w]===":"){let $=e.slice(w,w+2);for($===":?"||$===":!"?w+=2:w++;w<e.length&&/\s/.test(e[w]);)w++;let T=ur(e,w);if(T)for(E=T.type,w=T.endPos;w<e.length&&/\s/.test(e[w]);)w++}if(e.slice(w,w+2)==="=>"){let $=null,T=_,N=_.trimStart();N.startsWith("?")&&(N.length===1||/\s/.test(N[1]))?($="?",T=N.slice(1)):N.startsWith("!")&&(N.length===1||/\s/.test(N[1]))&&($="!",T=N.slice(1));let P=cr(T,t,!1);for(n+=`(${$==="?"?"/* safe */ ":$==="!"?"/* unsafe */ ":""}${P})`,r=k;r<w&&/\s/.test(e[r]);)n+=e[r],r++;E&&(r=w)}else{let $=gn(_,t);n+=`(${$.source})`,r=k}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:a}}function hn(e,t,n,r){let s=1,a=t,i=!1,o="";for(;a<e.length&&s>0;){let u=e[a];!i&&(u==="'"||u==='"'||u==="`")?(i=!0,o=u):i&&u===o&&e[a-1]!=="\\"?i=!1:i||(u===n?s++:u===r&&s--),a++}return s!==0?null:{content:e.slice(t,a-1),endPos:a}}function xi(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,s=e[n];if(s==="{"||s==="["){let i=s==="{"?"}":"]",o=hn(e,n+1,s,i);return o?{value:e.slice(r,o.endPos),endPos:o.endPos}:null}if(s==="'"||s==='"'||s==="`"){for(n++;n<e.length;){if(e[n]===s&&e[n-1]!=="\\")return n++,{value:e.slice(r,n),endPos:n};n++}return null}if(/[-+\d]/.test(s)){for(;n<e.length&&/[\d.eE+-]/.test(e[n]);)n++;return{value:e.slice(r,n),endPos:n}}let a=e.slice(n).match(/^(true|false|null|undefined)\b/);return a?{value:a[1],endPos:n+a[1].length}:null}function Bt(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function ur(e,t){let n=t,r=0,s=!1,a="",i=!1,o=u=>({type:Bt(e.slice(t,u).trim()),endPos:u});for(;n<e.length;){let u=e[n];if(!s&&(u==="'"||u==='"'||u==="`")){s=!0,a=u,i=!0,n++;continue}if(s){if(u===a&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="{"&&!e.slice(c+1).match(/^\s*(\w+)\s*:/)||e[c]!=="|"&&e[c]!=="&")return o(n)}continue}n++;continue}if(u==="{"||u==="["||u==="("){r++,i=!0,n++;continue}if(u==="}"||u==="]"||u===")"){if(r--,r===0){n++;let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="|"||e[c]==="&")continue;return o(n)}n++;continue}if(r===0&&u==="{"){if(i)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,i=!0,n++;continue}return o(n)}if(r===0&&(u==="|"||u==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(u)||u==="-"&&/\d/.test(e[n+1]))){let c=n;for(e[c]==="-"&&c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&e[c]==="."&&/\d/.test(e[c+1]))for(c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&(e[c]==="e"||e[c]==="E"))for(c++,c<e.length&&(e[c]==="+"||e[c]==="-")&&c++;c<e.length&&/\d/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:Bt(e.slice(t,c).trim()),endPos:c};if(e[n]!=="|"&&e[n]!=="&")return{type:Bt(e.slice(t,c).trim()),endPos:c};continue}if(r===0&&/[a-zA-Z_]/.test(u)){let c=n;for(;c<e.length&&/\w/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="("){r++,n++;continue}if(n<e.length&&e[n]==="{"&&!e.slice(n+1).match(/^\s*(\w+)\s*:/)){let p=c;for(;p>t&&/\s/.test(e[p-1]);)p--;return{type:Bt(e.slice(t,p).trim()),endPos:c}}if(e[n]!=="|"&&e[n]!=="&")return{type:Bt(e.slice(t,c).trim()),endPos:c};continue}n++}return i?o(n):null}function yn(e){let t=[],n="",r=0,s=!1,a=!1,i=0;for(;i<e.length;){let o=e[i],u=e[i+1];if(!a&&o==="/"&&u==="/"){s=!0,n+="//",i+=2;continue}if(!s&&o==="/"&&u==="*"){a=!0,n+="/*",i+=2;continue}if(s&&o===`
|
|
61
|
+
`){s=!1,n+=o,i++;continue}if(a&&o==="*"&&u==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function cr(e,t,n){let r=gn(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=yn(r),a=!1,i=new Set,o=c=>{if(n&&/^\w+$/.test(c)){if(i.has(c))throw new Error(`Duplicate parameter name '${c}'`);i.add(c)}};return s.map(c=>{let l=c.trim();if(!l)return c;if(n&&l.startsWith("{")&&l.endsWith("}")){let d=l.slice(1,-1);return`{ ${_i(d,t)} }`}if(n&&l.startsWith("[")&&l.endsWith("]")){let d=l.slice(1,-1);return`[ ${_i(d,t)} ]`}if(l.startsWith("...")){let d=wi(l);return d!==-1?l.slice(0,d).trim():c}let p=l.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(p){let[,d,m]=p;return o(d),a=!0,`${d} = ${m}`}if(!Ao(l)){let d=l.match(/^(\w+)\s*=/);return d&&o(d[1]),a=!0,c}let f=wi(l);if(f!==-1){let d=l.slice(0,f).trim(),m=l.slice(f+1).trim();return o(d),a&&n&&/^\w+$/.test(d),n&&/^\w+$/.test(d)&&t.requiredParams.add(d),`${d} = ${m}`}return c}).join(",")}function _i(e,t){return yn(e).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,c,l]=i;t.requiredParams.add(c);let p=dn(l);return`${c} = ${p}`}let o=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,c,l]=o;t.requiredParams.add(c);let p=mn(l);return`${c} = ${p}`}let u=a.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(u){let[,c,l]=u;return t.requiredParams.add(c),`${c} = ${l}`}return s}).join(", ")}function dn(e){let t=e.slice(1,-1).trim();return`{ ${yn(t).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,p,f]=i;return`${p}: ${dn(f)}`}let o=a.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,p,f]=o;return`${p}: ${dn(f)}`}let u=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(u){let[,p,f]=u;return`${p}: ${mn(f)}`}let c=a.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(c){let[,p,f]=c;return`${p}: ${mn(f)}`}let l=a.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(l){let[,p,f]=l;return`${p}: ${f}`}return s}).join(", ")} }`}function mn(e){let t=e.slice(1,-1).trim();return`[ ${yn(t).map(s=>{let a=s.trim();return a?a.startsWith("{")&&a.endsWith("}")?dn(a):a.startsWith("[")&&a.endsWith("]")?mn(a):s:s}).join(", ")} ]`}function Ao(e){let t=0,n=!1,r=!1,s=!1,a="";for(let i=0;i<e.length;i++){let o=e[i];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,a=o;continue}if(s){o===a&&e[i-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[i+1]!==">"&&(r=!0))}return n&&!r}function wi(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let a=e[s];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[s-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return s}return-1}function lr(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let s=r;for(t+=r,n++;n<e.length&&e[n]!==s;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2),a=s===-1?e.slice(n):e.slice(n,s+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let s=e.indexOf(`
|
|
62
|
+
`,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function bn(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),u=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,c=u?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1,tjsStrict:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0,tjsStrict:!1};u&&(r="none");let l=e.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);l&&(r=l[2],e=e.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1"));let p=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval|TjsSafeAssign)\b/,f;for(;f=e.match(p);){let P=f[2];P==="TjsStrict"?(c.tjsEquals=!0,c.tjsClass=!0,c.tjsDate=!0,c.tjsNoeval=!0,c.tjsNoVar=!0,c.tjsStandard=!0,c.tjsSafeAssign=!0,c.tjsStrict=!0):P==="TjsCompat"?(c.tjsEquals=!1,c.tjsClass=!1,c.tjsDate=!1,c.tjsNoeval=!1,c.tjsNoVar=!1,c.tjsStandard=!1,c.tjsSafeEval=!1,c.tjsSafeAssign=!1):P==="TjsEquals"?c.tjsEquals=!0:P==="TjsClass"?c.tjsClass=!0:P==="TjsDate"?c.tjsDate=!0:P==="TjsNoeval"?c.tjsNoeval=!0:P==="TjsNoVar"?c.tjsNoVar=!0:P==="TjsStandard"?c.tjsStandard=!0:P==="TjsSafeEval"?c.tjsSafeEval=!0:P==="TjsSafeAssign"&&(c.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${P}\\s*`),"$1")}e=lr(e),c.tjsStandard&&(e=ei(e)),e=di(e),e=yi(e);let d=bi(e);e=d.source;let m=d.annotations,y=Ys(e);e=y.source,e=Rt(e),c.tjsEquals&&!t.vmTarget&&(e=Mt(e));let x=[];e=ti(e,x),e=ri(e,x),e=ni(e),e=si(e),e=ii(e),c.tjsSafeAssign&&(e=ci(e));let S=Xs(e,{loader:t.moduleLoader,importerPath:t.filename});e=S.source;let{source:v,returnType:b,returnSafety:_}=gn(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=v;let k=ai(e);e=k.source,e=Zs(e);let w=ui(e,s);e=w.source;let E=Qs(e);e=E.source;let $=[...y.blocks,...S.blocks,...E.blocks],T=li(e,t.dangerouslySkipTests);e=T.source;let N=fi(e,s);e=N.source;for(let P of N.polyCtorClasses)a.add(`${P}$dispatch`);return c.tjsClass&&(e=pi(e,N.polyCtorClasses)),c.tjsDate&&(e=hi(e)),c.tjsNoeval&&(e=gi(e)),c.tjsNoVar&&(e=mi(e)),e=Ot(e,k.extensions),{source:e,returnType:b,returnSafety:_,moduleSafety:r,tjsModes:c,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:$,tests:T.tests,testErrors:T.errors,polymorphicNames:w.polymorphicNames,extensions:k.extensions,letAnnotations:m,predicates:x}}function tt(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1,dialect:a}=t,{source:i,returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:m,tests:y,testErrors:x,letAnnotations:S,tjsModes:v}=r?bn(e,{vmTarget:s,dialect:a,moduleLoader:t.moduleLoader,filename:t.filename}):{source:e,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:e,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[],letAnnotations:new Map,tjsModes:{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1,tjsStrict:!1}};try{return{ast:je(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:m,tests:y,testErrors:x,letAnnotations:S,tjsModes:v}}catch(b){let _=b.loc||{line:1,column:0};throw new ne(b.message.replace(/\s*\(\d+:\d+\)$/,""),_,l,n)}}function Si(e,t){for(let a of e.body){if(a.type==="ImportDeclaration")throw new ne("Imports are not supported. All atoms must be registered with the VM.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration")throw new ne("Exports are not supported. The function is automatically exported.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ClassDeclaration")throw new ne("Classes are not supported. Agent99 uses functional composition.",a.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(a=>a.type==="FunctionDeclaration");if(n.length===0)throw new ne("Source must contain a function declaration",{line:1,column:0},void 0,t);let r=n[n.length-1],s=new Map;for(let a=0;a<n.length-1;a++){let i=n[a],o=i.id?.name;if(!o)throw new ne("Helper function must have a name",i.loc?.start||{line:1,column:0},void 0,t);if(s.has(o))throw new ne(`Duplicate helper function name: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);if(o===r.id?.name)throw new ne(`Helper function cannot share a name with the entry function: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);s.set(o,i)}return{entry:r,helpers:s}}function Dt(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),s=[...r.matchAll(/(?<=^[ \t]*)\/\*#([\s\S]*?)\*\//gm)];if(s.length>0){let l=s[s.length-1],p=r.substring(l.index+l[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(p)){let f=l[1],d=f.split(`
|
|
63
63
|
`),m=d.filter(y=>y.trim().length>0).reduce((y,x)=>{let S=x.match(/^(\s*)/)?.[1].length||0;return Math.min(y,S)},1/0);return m>0&&m<1/0&&(f=d.map(y=>y.slice(m)).join(`
|
|
64
|
-
`)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let u=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,c;for(;(c=u.exec(i))!==null;)n.params[c[1]]=c[2].trim();return n}function ue(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(i=>i!=null).map(i=>ue(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}let s=[...r.values()];return{kind:"array",items:s.length===1?s[0]:{kind:"union",members:s}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let s=r.key.name;n[s]=ue(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ue(n):t==="&&"||t==="??"?ue(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ue(n),a=ue(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>Co(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ue(t.body)),{kind:"function",params:n,returns:r}}case"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function Co(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ue(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Ge(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new K("Only simple parameter names are supported",Z(e));let s=n.name,a=t?.has(s)??!1,i=ue(r),o=Ie(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ge(a.value,t),u=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:u,default:u?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new K(`Unsupported parameter pattern: ${e.type}`,Z(e))}function Ie(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?Ie(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=Ie(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=Ie(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=Ie(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?Ie(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?Ie(n)??Ie(r):void 0}default:return}}function wi(e){try{let t=Pt(e,0,{ecmaVersion:2022});return ue(t)}catch{return{kind:"any"}}}function or(e){switch(e.kind){case"string":return e.nullable?"string | null":"string";case"number":return e.nullable?"number | null":"number";case"integer":return e.nullable?"integer | null":"integer";case"non-negative-integer":return e.nullable?"non-negative integer | null":"non-negative integer";case"boolean":return e.nullable?"boolean | null":"boolean";case"null":return"null";case"any":return"any";case"array":{let t=e.items?or(e.items):"any";return e.nullable?`${t}[] | null`:`${t}[]`}case"object":{if(!e.shape||Object.keys(e.shape).length===0)return e.nullable?"object | null":"object";let t=Object.entries(e.shape).map(([n,r])=>`${n}: ${or(r)}`).join(", ");return e.nullable?`{ ${t} } | null`:`{ ${t} }`}case"union":return e.members?.map(or).join(" | ")||"any";default:return"any"}}function xn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?xn(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=xn(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(xn)}:{};default:return{}}}function Ao(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=xn(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function ur(e,t,n,r={},s,a){let i=Dt(t,e),o=new Map;for(let E of e.params){let _=Ge(E,s);if(_.name==="__destructured__"&&_.type.kind==="object"&&_.type.destructuredParams)for(let[b,v]of Object.entries(_.type.destructuredParams))o.set(b,{...v,description:i.params[b]});else _.description=i.params[_.name],o.set(_.name,_)}let u;n&&(u=wi(n));let c={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},l=Te(e.body,c),p=[],f=[],d=[];for(let[E,_]of o.entries())_.required?f.push(E):_.default!==void 0?d.push({name:E,defaultValue:_.default}):f.push(E);f.length>0&&p.push({op:"varsImport",keys:f});for(let{name:E,defaultValue:_}of d)p.push({op:"varsImport",keys:[E]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:E},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:E,value:_}]});p.push(...l);let m=Object.fromEntries(o),y={name:e.id?.name||"anonymous",description:i.description,parameters:m,returns:u},x=Ao(m),S=c.helperSteps&&c.helperSteps.size>0?Object.fromEntries(c.helperSteps):void 0;return{ast:{op:"seq",steps:p,inputSchema:x,...S&&{helpers:S}},signature:y,warnings:c.warnings}}function Te(e,t){let n=[];for(let r of e.body){let s=Ft(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Ft(e,t){switch(e.type){case"VariableDeclaration":return Po(e,t);case"ExpressionStatement":return jo(e,t);case"IfStatement":return No(e,t);case"WhileStatement":return Ro(e,t);case"ForOfStatement":return Mo(e,t);case"TryStatement":return Oo(e,t);case"ReturnStatement":return Bo(e,t);case"ThrowStatement":throw new K("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",Z(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:Te(e,Se(t))};case"EmptyStatement":return null;default:throw new K(`Unsupported statement type: ${e.type}`,Z(e),t.source,t.filename)}}function Po(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new K("Only simple variable names are supported",Z(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:u}=nt(a.init,t,i,r);o?n.push(o):u!==i&&n.push({op:s,key:i,value:u});let c=ue(a.init);t.locals.set(i,c)}else{if(r)throw new K("const declarations must be initialized",Z(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function jo(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Io(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=nt(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:Z(e).line,column:Z(e).column}),null}function Io(e,t){if(e.left.type!=="Identifier")throw new K("Only simple variable assignment is supported",Z(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=nt(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function No(e,t){let n=G(e.test,t),r=e.consequent.type==="BlockStatement"?Te(e.consequent,Se(t)):[Ft(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?Te(e.alternate,Se(t)):[Ft(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function Ro(e,t){let n=G(e.test,t),r=e.body.type==="BlockStatement"?Te(e.body,Se(t)):[Ft(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Mo(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new K("Only simple variable names are supported in for...of",Z(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new K("Unsupported for...of left-hand side",Z(e.left),t.source,t.filename);let r=ie(e.right,t),s=Se(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?Te(e.body,s):[Ft(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function Oo(e,t){let n=Te(e.block,Se(t)),r,s;if(e.handler){let a=Se(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=Te(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function Bo(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=nt(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:ie(e.argument,t)}}var vi=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Do=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),Lt=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),Fo=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function Lo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Do.has(t)||Lt.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(vi.has(n)||Lt.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Fo.has(n))return!0}}return!1}function Vo(e){if(e.object.type==="Identifier"){let t=e.object.name;return vi.has(t)||Lt.has(t)}return!1}var Si={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function qo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(Lt.has(t))return Si[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Lt.has(n))return Si[n]||`${n} is not available in AsyncJS.`}}return null}function ki(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function nt(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return nt(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let u=ki(o);throw new K(`The 'new' keyword is not supported in AsyncJS.${u}`,Z(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=qo(e);if(i)throw new K(i,Z(e),t.source,t.filename)}if(e.type==="CallExpression"&&Lo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&Vo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return Uo(e,t,n,r);if(e.type==="TemplateLiteral")return zo(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:ie(e,t)}}function Uo(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let u=e.callee;if(u.property.type==="Identifier")s=u.property.name,a=!0,i=ie(u.object,t);else throw new K("Computed method names are not supported",Z(e),t.source,t.filename)}else throw new K("Only named function calls are supported",Z(e),t.source,t.filename);if(a)return Jo(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let u=Wo(s,t,e),c=e.arguments.map(l=>ie(l,t));if(c.length!==u.length)throw new K(`Helper '${s}' expects ${u.length} argument(s), got ${c.length}`,Z(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:c,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=Go(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function Wo(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new K(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??Z(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=Te(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function Jo(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")l=Te(i.body,c);else{let{step:p,resultVar:f}=nt(i.body,c,"result");l=p?[p]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:u,steps:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("filter callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"filter",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("find callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"find",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=i.params[1],c=o?.type==="Identifier"?o.name:"acc",l=u?.type==="Identifier"?u.name:"item",p=Se(r);p.locals.set(c,{kind:"any"}),p.locals.set(l,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=Te(i.body,p);else{let{step:m,resultVar:y}=nt(i.body,p,"result");f=m?[m]:[{op:"varSet",key:"result",value:y}]}let d=ie(n[1],r);return{step:{op:"reduce",items:t,as:l,accumulator:c,initial:d,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:ie(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(i=>ie(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function zo(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],u=`_${i}`;a[u]=ie(o,t),s+=`{{${u}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function G(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=G(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:G(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return G(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:G(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:G(n.test,t),consequent:G(n.consequent,t),alternate:G(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>G(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:G(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:G(r.object,t),method:s,arguments:n.arguments.map(i=>G(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new K(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,Z(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>G(s,t))}}throw new K("Complex function calls in expressions should be lifted to statements",Z(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=ki(r);throw new K(`The 'new' keyword is not supported in AsyncJS.${s}`,Z(e),t.source,t.filename)}case"TemplateLiteral":throw new K("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",Z(e),t.source,t.filename);default:throw new K(`Unsupported expression type in condition: ${e.type}`,Z(e),t.source,t.filename)}}function ie(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return G(e,t);let s=ie(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return G(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return ie(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?ie(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=ie(r.value,t)}return n}case"TemplateLiteral":return G(e,t);case"CallExpression":return G(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return G(e,t);default:return null}}function Go(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=ie(s.value,t)}return r}return{args:e.arguments.map(n=>ie(n,t))}}function Ho(e,t){let n=t;for(;n>0&&e[n-1]!==`
|
|
65
|
-
`;)n--;if(e.slice(n,t).includes("//"))return!0;let s=0,a=!1;for(;s<t;)!a&&e.slice(s,s+2)==="/*"?(a=!0,s+=2):a&&e.slice(s,s+2)==="*/"?(a=!1,s+=2):s++;return a}function
|
|
64
|
+
`)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let u=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,c;for(;(c=u.exec(i))!==null;)n.params[c[1]]=c[2].trim();return n}function ue(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(i=>i!=null).map(i=>ue(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}let s=[...r.values()];return{kind:"array",items:s.length===1?s[0]:{kind:"union",members:s}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let s=r.key.name;n[s]=ue(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ue(n):t==="&&"||t==="??"?ue(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ue(n),a=ue(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>Po(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ue(t.body)),{kind:"function",params:n,returns:r}}case"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function Po(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ue(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Ge(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new K("Only simple parameter names are supported",Z(e));let s=n.name,a=t?.has(s)??!1,i=ue(r),o=Ie(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ge(a.value,t),u=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:u,default:u?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new K(`Unsupported parameter pattern: ${e.type}`,Z(e))}function Ie(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?Ie(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=Ie(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=Ie(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=Ie(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?Ie(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?Ie(n)??Ie(r):void 0}default:return}}function vi(e){try{let t=Pt(e,0,{ecmaVersion:2022});return ue(t)}catch{return{kind:"any"}}}function fr(e){switch(e.kind){case"string":return e.nullable?"string | null":"string";case"number":return e.nullable?"number | null":"number";case"integer":return e.nullable?"integer | null":"integer";case"non-negative-integer":return e.nullable?"non-negative integer | null":"non-negative integer";case"boolean":return e.nullable?"boolean | null":"boolean";case"null":return"null";case"any":return"any";case"array":{let t=e.items?fr(e.items):"any";return e.nullable?`${t}[] | null`:`${t}[]`}case"object":{if(!e.shape||Object.keys(e.shape).length===0)return e.nullable?"object | null":"object";let t=Object.entries(e.shape).map(([n,r])=>`${n}: ${fr(r)}`).join(", ");return e.nullable?`{ ${t} } | null`:`{ ${t} }`}case"union":return e.members?.map(fr).join(" | ")||"any";default:return"any"}}function xn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?xn(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=xn(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(xn)}:{};default:return{}}}function jo(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=xn(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function pr(e,t,n,r={},s,a){let i=Dt(t,e),o=new Map;for(let v of e.params){let b=Ge(v,s);if(b.name==="__destructured__"&&b.type.kind==="object"&&b.type.destructuredParams)for(let[_,k]of Object.entries(b.type.destructuredParams))o.set(_,{...k,description:i.params[_]});else b.description=i.params[b.name],o.set(b.name,b)}let u;n&&(u=vi(n));let c={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},l=Te(e.body,c),p=[],f=[],d=[];for(let[v,b]of o.entries())b.required?f.push(v):b.default!==void 0?d.push({name:v,defaultValue:b.default}):f.push(v);f.length>0&&p.push({op:"varsImport",keys:f});for(let{name:v,defaultValue:b}of d)p.push({op:"varsImport",keys:[v]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:v},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:v,value:b}]});p.push(...l);let m=Object.fromEntries(o),y={name:e.id?.name||"anonymous",description:i.description,parameters:m,returns:u},x=jo(m),S=c.helperSteps&&c.helperSteps.size>0?Object.fromEntries(c.helperSteps):void 0;return{ast:{op:"seq",steps:p,inputSchema:x,...S&&{helpers:S}},signature:y,warnings:c.warnings}}function Te(e,t){let n=[];for(let r of e.body){let s=Ft(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Ft(e,t){switch(e.type){case"VariableDeclaration":return Io(e,t);case"ExpressionStatement":return No(e,t);case"IfStatement":return Mo(e,t);case"WhileStatement":return Oo(e,t);case"ForOfStatement":return Bo(e,t);case"TryStatement":return Do(e,t);case"ReturnStatement":return Fo(e,t);case"ThrowStatement":throw new K("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",Z(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:Te(e,Se(t))};case"EmptyStatement":return null;default:throw new K(`Unsupported statement type: ${e.type}`,Z(e),t.source,t.filename)}}function Io(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new K("Only simple variable names are supported",Z(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:u}=nt(a.init,t,i,r);o?n.push(o):u!==i&&n.push({op:s,key:i,value:u});let c=ue(a.init);t.locals.set(i,c)}else{if(r)throw new K("const declarations must be initialized",Z(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function No(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Ro(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=nt(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:Z(e).line,column:Z(e).column}),null}function Ro(e,t){if(e.left.type!=="Identifier")throw new K("Only simple variable assignment is supported",Z(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=nt(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function Mo(e,t){let n=G(e.test,t),r=e.consequent.type==="BlockStatement"?Te(e.consequent,Se(t)):[Ft(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?Te(e.alternate,Se(t)):[Ft(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function Oo(e,t){let n=G(e.test,t),r=e.body.type==="BlockStatement"?Te(e.body,Se(t)):[Ft(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Bo(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new K("Only simple variable names are supported in for...of",Z(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new K("Unsupported for...of left-hand side",Z(e.left),t.source,t.filename);let r=ae(e.right,t),s=Se(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?Te(e.body,s):[Ft(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function Do(e,t){let n=Te(e.block,Se(t)),r,s;if(e.handler){let a=Se(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=Te(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function Fo(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=nt(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:ae(e.argument,t)}}var Ei=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Lo=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),Lt=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),Vo=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function qo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Lo.has(t)||Lt.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Ei.has(n)||Lt.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Vo.has(n))return!0}}return!1}function Uo(e){if(e.object.type==="Identifier"){let t=e.object.name;return Ei.has(t)||Lt.has(t)}return!1}var ki={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function Wo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(Lt.has(t))return ki[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Lt.has(n))return ki[n]||`${n} is not available in AsyncJS.`}}return null}function Ti(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function nt(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return nt(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let u=Ti(o);throw new K(`The 'new' keyword is not supported in AsyncJS.${u}`,Z(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=Wo(e);if(i)throw new K(i,Z(e),t.source,t.filename)}if(e.type==="CallExpression"&&qo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&Uo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return Jo(e,t,n,r);if(e.type==="TemplateLiteral")return Ho(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:ae(e,t)}}function Jo(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let u=e.callee;if(u.property.type==="Identifier")s=u.property.name,a=!0,i=ae(u.object,t);else throw new K("Computed method names are not supported",Z(e),t.source,t.filename)}else throw new K("Only named function calls are supported",Z(e),t.source,t.filename);if(a)return Go(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let u=zo(s,t,e),c=e.arguments.map(l=>ae(l,t));if(c.length!==u.length)throw new K(`Helper '${s}' expects ${u.length} argument(s), got ${c.length}`,Z(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:c,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=Ko(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function zo(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new K(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??Z(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=Te(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function Go(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")l=Te(i.body,c);else{let{step:p,resultVar:f}=nt(i.body,c,"result");l=p?[p]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:u,steps:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("filter callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"filter",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("find callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"find",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=i.params[1],c=o?.type==="Identifier"?o.name:"acc",l=u?.type==="Identifier"?u.name:"item",p=Se(r);p.locals.set(c,{kind:"any"}),p.locals.set(l,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=Te(i.body,p);else{let{step:m,resultVar:y}=nt(i.body,p,"result");f=m?[m]:[{op:"varSet",key:"result",value:y}]}let d=ae(n[1],r);return{step:{op:"reduce",items:t,as:l,accumulator:c,initial:d,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:ae(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?ae(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?ae(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(i=>ae(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function Ho(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],u=`_${i}`;a[u]=ae(o,t),s+=`{{${u}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function G(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=G(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:G(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return G(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:G(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:G(n.test,t),consequent:G(n.consequent,t),alternate:G(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>G(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:G(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:G(r.object,t),method:s,arguments:n.arguments.map(i=>G(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new K(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,Z(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>G(s,t))}}throw new K("Complex function calls in expressions should be lifted to statements",Z(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=Ti(r);throw new K(`The 'new' keyword is not supported in AsyncJS.${s}`,Z(e),t.source,t.filename)}case"TemplateLiteral":throw new K("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",Z(e),t.source,t.filename);default:throw new K(`Unsupported expression type in condition: ${e.type}`,Z(e),t.source,t.filename)}}function ae(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return G(e,t);let s=ae(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return G(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return ae(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?ae(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=ae(r.value,t)}return n}case"TemplateLiteral":return G(e,t);case"CallExpression":return G(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return G(e,t);default:return null}}function Ko(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=ae(s.value,t)}return r}return{args:e.arguments.map(n=>ae(n,t))}}function Zo(e,t){let n=t;for(;n>0&&e[n-1]!==`
|
|
65
|
+
`;)n--;if(e.slice(n,t).includes("//"))return!0;let s=0,a=!1;for(;s<t;)!a&&e.slice(s,s+2)==="/*"?(a=!0,s+=2):a&&e.slice(s,s+2)==="*/"?(a=!1,s+=2):s++;return a}function Qo(e){let t=[],n=/\/\*test\s+'([^']*)'\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+"([^"]*)"\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+`([^`]*)`\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s*\{([\s\S]*?)\}\s*\*\//g,r;for(;(r=n.exec(e))!==null;){let s=r[1]||r[3]||r[5]||`embedded test ${t.length+1}`,a=(r[2]||r[4]||r[6]||r[7]||"").trim();t.push({description:s,body:a,line:hr(e,r.index)})}return t}function dr(e){let t=[],n=[],r=Qo(e);t.push(...r);let s=/test\s+'([^']*)'\s*\{|test\s+"([^"]*)"\s*\{|test\s+`([^`]*)`\s*\{|test\s*\(\s*'([^']*)'\s*\)\s*\{|test\s*\(\s*"([^"]*)"\s*\)\s*\{|test\s*\(\s*`([^`]*)`\s*\)\s*\{|test\s*\{/g,a=/mock\s*\{/g,i=e,o,u=[];for(;(o=s.exec(e))!==null;){let f=o.index;if(Zo(e,f))continue;let d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6]||`test ${t.length+1}`,m=o.index+o[0].length,y=$i(e,m-1);if(y===-1)continue;let x=e.slice(m,y).trim();t.push({description:d,body:x,line:hr(e,f)}),u.push({start:f,end:y+1,desc:d})}let c=[];for(;(o=a.exec(e))!==null;){let f=o.index,d=o.index+o[0].length,m=$i(e,d-1);if(m===-1)continue;let y=e.slice(d,m).trim();n.push({body:y,line:hr(e,f)}),c.push({start:f,end:m+1})}let l=[...u,...c].sort((f,d)=>d.start-f.start);for(let f of l)i=i.slice(0,f.start)+i.slice(f.end);i=i.replace(/\n\s*\n\s*\n/g,`
|
|
66
66
|
|
|
67
|
-
`).trim();let p=
|
|
68
|
-
`).length}function
|
|
67
|
+
`).trim();let p=Yo(t,n);return{code:i,tests:t,mocks:n,testRunner:p}}function $i(e,t){let n=0,r=null,s=!1;for(let a=t;a<e.length;a++){let i=e[a];if(s){s=!1;continue}if(i==="\\"){s=!0;continue}if(!r&&(i==='"'||i==="'"||i==="`")){r=i;continue}if(r===i){r=null;continue}if(!r&&(i==="{"&&n++,i==="}"&&(n--,n===0)))return a}return-1}function hr(e,t){return e.slice(0,t).split(`
|
|
68
|
+
`).length}function Yo(e,t){if(e.length===0)return"// No tests defined";let n=t.map(s=>s.body).join(`
|
|
69
69
|
`);return`(async () => {
|
|
70
70
|
const __results = []
|
|
71
71
|
|
|
@@ -88,13 +88,13 @@ const __failed = __results.filter(r => !r.passed).length
|
|
|
88
88
|
|
|
89
89
|
// Return summary
|
|
90
90
|
return { passed: __passed, failed: __failed, results: __results }
|
|
91
|
-
})()`.trim()}var
|
|
91
|
+
})()`.trim()}var Ci=`
|
|
92
92
|
function assert(condition, message) {
|
|
93
93
|
if (!condition) {
|
|
94
94
|
throw new Error(message || 'Assertion failed')
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
`,Ai=`
|
|
98
98
|
function expect(actual) {
|
|
99
99
|
const deepEqual = (a, b) => {
|
|
100
100
|
if (a === b) return true
|
|
@@ -185,52 +185,52 @@ function expect(actual) {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
`,
|
|
189
|
-
`+$i;var O=e=>({schema:e,_type:null,validate:(t,n)=>Ne(t,e,n),get optional(){return O({...e,type:Array.isArray(e.type)?[...e.type,"null"]:[e.type,"null"]})},title:t=>O({...e,title:t}),describe:t=>O({...e,description:t}),default:t=>O({...e,default:t}),meta:t=>O({...t,...e,...t}),min:t=>{let n=e.type==="string"?"minLength":e.type==="array"?"minItems":e.type==="object"?"minProperties":"minimum";return O({...e,[n]:t})},max:t=>{let n=e.type==="string"?"maxLength":e.type==="array"?"maxItems":e.type==="object"?"maxProperties":"maximum";return O({...e,[n]:t})},pattern:t=>O({...e,pattern:typeof t=="string"?t:t.source}),get email(){return O({...e,format:"email"})},get uuid(){return O({...e,format:"uuid"})},get ipv4(){return O({...e,format:"ipv4"})},get url(){return O({...e,format:"uri"})},get datetime(){return O({...e,format:"date-time"})},get emoji(){return O({...e,pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get int(){return O({...e,type:"integer"})},step:t=>O({...e,multipleOf:t})}),Ci=null;var fr={get email(){return O({type:"string",format:"email"})},get uuid(){return O({type:"string",format:"uuid"})},get ipv4(){return O({type:"string",format:"ipv4"})},get url(){return O({type:"string",format:"uri"})},get datetime(){return O({type:"string",format:"date-time"})},get emoji(){return O({type:"string",pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get null(){return O({type:"null"})},get undefined(){return O({type:"null","x-tjs-undefined":!0})},get any(){return O({})},pattern:e=>O({type:"string",pattern:typeof e=="string"?e:e.source}),union:e=>O({anyOf:e.map(t=>t.schema)}),enum:e=>O({type:typeof e[0],enum:e}),const:e=>O({const:e}),array:e=>O({type:"array",items:e.schema}),tuple:e=>O({type:"array",items:e.map(t=>t.schema),minItems:e.length,maxItems:e.length}),object:e=>{let t={},n=[];for(let r in e)t[r]=e[r].schema,(!Array.isArray(t[r].type)||!t[r].type.includes("null"))&&n.push(r);return O({type:"object",properties:t,required:n,additionalProperties:!1})},record:e=>O({type:"object",additionalProperties:e.schema}),infer:e=>{if(e===null)return O({type:"null"});if(e===void 0)return O({type:"null","x-tjs-undefined":!0});let t=typeof e;if(t==="string")return O({type:"string"});if(t==="number")return O({type:Number.isInteger(e)?"integer":"number"});if(t==="boolean")return O({type:"boolean"});if(Array.isArray(e))return e.length===0?O({type:"array"}):O({type:"array",items:fr.infer(e[0]).schema});if(t==="object"){let n={},r=[];for(let s in e)n[s]=fr.infer(e[s]).schema,r.push(s);return O({type:"object",properties:n,required:r,additionalProperties:!1})}return O({})}},ye=new Proxy(fr,{get(e,t){if(t in e)return e[t];if(t==="string"||t==="number"||t==="boolean"||t==="integer"){let n=O({type:t});return e[t]=n,n}}}),_n=97,Ai={email:e=>/^\S+@\S+\.\S+$/.test(e),uuid:e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),uri:e=>{try{return new URL(e),!0}catch{return!1}},ipv4:e=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e),"date-time":e=>!isNaN(Date.parse(e)),emoji:e=>new RegExp("\\p{Extended_Pictographic}","u").test(e)};function Ne(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1,i=[],o=c=>(s&&s(i.join(".")||"root",c),!1),u=(c,l)=>{if(l.anyOf){for(let f of l.anyOf)if(Ne(c,f))return!0;return o("Union mismatch")}if(l.const!==void 0)return c===l.const||o("Const mismatch");if(c===null){let f=l.type==="null"&&!l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got null")}if(c===void 0){let f=l.type==="null"&&l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got undefined")}let p=Array.isArray(l.type)?l.type[0]:l.type;if(l.enum&&!l.enum.includes(c))return o("Enum mismatch");if(p==="integer"){if(typeof c!="number"||!Number.isInteger(c))return o("Expected integer")}else if(p==="array"){if(!Array.isArray(c))return o("Expected array")}else if(p==="object"){if(typeof c!="object"||Array.isArray(c))return o("Expected object")}else if(p&&typeof c!==p)return o(`Expected ${p}`);if(l.$predicate&&Ci&&!Ci(l.$predicate,c))return o("Predicate mismatch");if(typeof c=="number"){if(!Number.isFinite(c))return o("Expected finite number");if(l.minimum!==void 0&&c<l.minimum)return o("Value < min");if(l.maximum!==void 0&&c>l.maximum)return o("Value > max");if(l.multipleOf!==void 0){let f=Math.abs(c%l.multipleOf),d=1e-10;if(f>1e-10&&Math.abs(f-Math.abs(l.multipleOf))>1e-10)return o("Value not step")}}if(typeof c=="string"){if(l.minLength!==void 0&&c.length<l.minLength)return o("Len < min");if(l.maxLength!==void 0&&c.length>l.maxLength)return o("Len > max");if(l.pattern&&!new RegExp(l.pattern,l.format==="emoji"?"u":"").test(c))return o("Pattern mismatch");if(l.format&&Ai[l.format]&&!Ai[l.format](c))return o("Format invalid")}if(p==="object"){let f=l.minProperties!==void 0,d=a&&l.maxProperties!==void 0;if(f||d){let m=0;for(let y in c)Object.prototype.hasOwnProperty.call(c,y)&&m++;if(f&&m<l.minProperties)return o("Too few props");if(d&&m>l.maxProperties)return o("Too many props")}if(l.required){for(let m of l.required)if(!(m in c))return o(`Missing ${m}`)}if(l.properties){for(let m in l.properties)if(m in c){i.push(m);let y=u(c[m],l.properties[m]);if(i.pop(),!y)return!1}}if(l.additionalProperties){let m=[];for(let S in c)l.properties&&S in l.properties||m.push(S);let y=m.length,x=a||y<=_n?1:Math.floor(y/_n);for(let S=0;S<y;S+=x){let E=x>1&&S>y-1-x?y-1:S,_=m[E];i.push(_);let b=u(c[_],l.additionalProperties);if(i.pop(),!b)return!1;if(E===y-1)break}}return!0}if(p==="array"&&l.items){let f=c.length;if(l.minItems!==void 0&&f<l.minItems)return o("Array too short");if(l.maxItems!==void 0&&f>l.maxItems)return o("Array too long");if(Array.isArray(l.items)){for(let m=0;m<l.items.length;m++){if(i.push(String(m)),!u(c[m],l.items[m]))return i.pop(),!1;i.pop()}return!0}let d=a||f<=_n?1:Math.floor(f/_n);for(let m=0;m<f;m+=d){let y=d>1&&m>f-1-d?f-1:m;i.push(String(y));let x=u(c[y],l.items);if(i.pop(),!x)return!1;if(y===f-1)break}return!0}return!0};return u(e,r)}function Pi(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1;if(!(typeof n=="object"&&n?.skipValidation)){let i="",o="";if(!Ne(e,r,{onError:(u,c)=>{i||(i=u,o=c),s&&s(u,c)},fullScan:a}))return Error(`${i}: ${o}`)}return wn(e,r)}function wn(e,t){if(e==null)return e;let n=t.type;if(n==="object"&&t.properties&&typeof e=="object"&&!Array.isArray(e)){let r={};for(let s of Object.keys(t.properties))s in e&&(r[s]=wn(e[s],t.properties[s]));return r}return n==="array"&&Array.isArray(e)&&t.items?Array.isArray(t.items)?e.slice(0,t.items.length).map((r,s)=>wn(r,t.items[s])):e.map(r=>wn(r,t.items)):e}function gt(e){if(e.nullable)return{anyOf:[gt({...e,nullable:!1}),{type:"null"}]};switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"integer":return{type:"integer"};case"non-negative-integer":return{type:"integer",minimum:0};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"undefined":return{};case"any":return{};case"array":return e.items?{type:"array",items:gt(e.items)}:{type:"array"};case"object":if(e.shape){let t={},n=[];for(let[r,s]of Object.entries(e.shape))t[r]=gt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{anyOf:e.members.map(gt)}:{};default:return{}}}function yt(e){if(e===null)return{type:"null"};if(e===void 0)return{};switch(typeof e){case"string":return{type:"string"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:yt(e[0])};let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=yt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}default:return{}}}function pr(e){let t={},n=[];for(let[a,i]of Object.entries(e.params))i?.type?.kind?t[a]=gt(i.type):i?.example!==void 0?t[a]=yt(i.example):t[a]={},i?.required!==!1&&n.push(a),i?.example!==void 0&&(t[a].examples=[i.example]);let r={type:"object",properties:t,required:n},s;return e.returns&&(e.returns.type?.kind?s=gt(e.returns.type):e.returns.example!==void 0&&(s=yt(e.returns.example))),{input:r,output:s}}function rt(e){return e!==null&&typeof e=="object"&&"__runtimeType"in e&&e.__runtimeType===!0}function ji(e){return e!==null&&typeof e=="object"&&"schema"in e&&typeof e.schema=="object"}function Yo(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function se(e,t,n,r){let s,a,i,o=n,u=r;if(typeof e=="string")if(s=e,typeof t=="function")a=t,o!==void 0&&(i=ye.infer(o));else if(t===void 0&&o!==void 0)i=ye.infer(o);else if(ji(t))i=t;else if(Yo(t))i=t;else if(t!==void 0)o=t,u=o,i=ye.infer(o);else throw new Error("Type(description) requires a predicate, schema, or example");else ji(e),i=e,s=Xo(i);let c;if(i){let p=i?.schema??i;p&&typeof p=="object"&&Array.isArray(p.examples)&&(c=p.examples)}return o===void 0&&c&&c.length>0&&(o=c[0]),{description:s,check:p=>a?a(p):i?Ne(p,i):!1,schema:i,predicate:a,example:o,examples:c,default:u,toJSONSchema(){if(i){let p=i?.schema??i;if(p&&typeof p=="object"&&"type"in p)return p}return o!==void 0?yt(o):{description:s}},strip(p){return i?Pi(p,i):p},__runtimeType:!0}}function Xo(e){let t=e?.schema??e;if(t&&typeof t=="object"&&"type"in t){let n=t;switch(n.type){case"string":return n.format?`string (${n.format})`:n.pattern?`string matching ${n.pattern}`:n.minLength!==void 0&&n.maxLength!==void 0?`string (${n.minLength}-${n.maxLength} chars)`:"string";case"number":case"integer":return n.minimum!==void 0&&n.maximum!==void 0?`${n.type} (${n.minimum}-${n.maximum})`:n.minimum!==void 0?`${n.type} >= ${n.minimum}`:n.maximum!==void 0?`${n.type} <= ${n.maximum}`:n.type;case"boolean":return"boolean";case"array":return"array";case"object":return"object";case"null":return"null"}}return"value"}var hr=se("string",e=>typeof e=="string"?!0:`expected string, got ${e===null?"null":typeof e}`),dr=se("number",e=>typeof e=="number"?!0:`expected number, got ${e===null?"null":typeof e}`),mr=se("boolean",e=>typeof e=="boolean"?!0:`expected boolean, got ${e===null?"null":typeof e}`),gr=se("integer",e=>typeof e!="number"?`expected integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?!0:`${e} is not an integer`),yr=se("positive integer",e=>typeof e!="number"?`expected positive integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?e<=0?`${e} is not positive`:!0:`${e} is not an integer`),br=se("non-empty string",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:e.length===0?"string is empty":!0),xr=se("email address",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?!0:`"${e}" is not a valid email`),Ii=e=>{try{return new URL(e),!0}catch{return!1}},_r=se("URL",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:Ii(e)?!0:`"${e}" is not a valid URL`),wr=se("UUID",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?!0:`"${e}" is not a valid UUID`),Ni=e=>{let t=new Date(e);return!isNaN(t.getTime())&&e.includes("T")},Ri=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(e+"T00:00:00Z");return!isNaN(t.getTime())},Mi=se("ISO 8601 timestamp",e=>typeof e=="string"&&Ni(e)),Oi=se("date (YYYY-MM-DD)",e=>typeof e=="string"&&Ri(e));function Sr(e){return se(`${e.description} or null`,t=>t===null||e.check(t)===!0)}function vr(e){return se(`${e.description} (optional)`,t=>t==null||e.check(t)===!0)}function kr(e,t,...n){if(typeof e=="string"&&Array.isArray(t)){let a=e,i=t,o=new Set(i);return{description:a,check:c=>o.has(c),toJSONSchema:()=>({enum:i}),strip:c=>c,__runtimeType:!0,values:i}}let r=[];rt(e)&&r.push(e),rt(t)&&r.push(t),r.push(...n);let s=r.map(a=>a.description).join(" | ");return se(s,a=>r.some(i=>i.check(a)===!0))}function Er(e){return se(`array of ${e.description}`,t=>Array.isArray(t)&&t.every(n=>e.check(n)===!0))}function eu(e){if(rt(e))return n=>e.check(n)===!0;if(e&&typeof e=="object"&&"schema"in e)return n=>Ne(n,e);let t=ye.infer(e);return n=>Ne(n,t)}function Vt(e,t,n){let r=[],s=[];for(let i of e)typeof i=="string"?(r.push(i),s.push(void 0)):(r.push(i[0]),s.push(i[1]));let a=(...i)=>{let o=r.map((c,l)=>{let p=l<i.length?i[l]:s[l];return p===void 0?()=>!0:eu(p)}),u=n;return r.forEach((c,l)=>{let p=l<i.length?i[l]:s[l],f="any";rt(p)?f=p.description:p!==void 0&&(f=typeof p=="string"?"string":JSON.stringify(p)),u=u.replace(new RegExp(`\\b${c}\\b`,"g"),f)}),se(u,c=>t(c,...o))};return a.params=r,a.description=n,a}var Tr=Vt(["T","U"],(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),"Pair<T, U>"),$r=Vt(["V"],(e,t)=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.values(e).every(t),"Record<string, V>");function Cr(e,t){let n=Object.values(t),r=new Set(n),s=Object.keys(t),a={};for(let[o,u]of Object.entries(t))a[u]=o;return{description:e,check:o=>r.has(o),toJSONSchema:()=>({enum:n}),strip:o=>o,__runtimeType:!0,members:t,names:a,values:n,keys:s}}function tu(e){if(e===null)return"null";if(e===void 0)return"undefined";switch(typeof e){case"string":return"string";case"boolean":return"boolean";case"number":return Number.isInteger(e)?"integer":"number";case"object":return Array.isArray(e)?"array":"object";default:return null}}function Sn(e,t,n){if(Array.isArray(t)&&n){let r=t,s=[],a=[];for(let o of r)Array.isArray(o)?(s.push(o[0]),a.push(o[1])):(s.push(o),a.push(void 0));let i=((...o)=>{let u=s.map((l,p)=>p<o.length?o[p]:a[p]),c=n(...u);return Sn(e,c)});return Object.defineProperties(i,{typeParamNames:{value:s,enumerable:!0},description:{value:e,enumerable:!0},__runtimeType:{value:!0,enumerable:!0}}),i}return nu(e,t)}function nu(e,t){let n={},r,s="assertReturns";if(typeof t=="function"){let i=t.__tjs;if(i){if(i.params)for(let[o,u]of Object.entries(i.params))n[o]=u?.example??null;i.returns&&(r=i.returns?.example??null),i.safeReturn?s="checkedReturns":i.unsafe?s="assertReturns":s="returns"}}else n=t.params??{},r=t.returns,s=t.returnContract??"assertReturns";return{description:e,params:n,returns:r,returnContract:s,toJSONSchema:()=>({description:e,type:"function"}),strip:i=>i,check:i=>{if(typeof i!="function")return`expected function, got ${i===null?"null":typeof i}`;let o=Object.keys(n).length;if(o>0){let c=i.__tjs;if(c?.params){let l=Object.keys(c.params).length;if(l!==o)return`expected ${o} params, got ${l}`;let p=Object.keys(n),f=Object.keys(c.params);for(let d=0;d<p.length;d++){let m=c.params[f[d]],y=n[p[d]];if(m?.type?.kind&&y!==void 0){let x=tu(y);if(x&&m.type.kind!==x&&m.type.kind!=="any")return`param '${p[d]}' expected ${x}, got ${m.type.kind}`}}}}return!0},__runtimeType:!0}}var su=Bi(),Ve=su.version,qt=Symbol.for("tjs.equals");function kn(e){let[t=0,n=0,r=0]=e.split(".").map(Number);return{major:t,minor:n,patch:r}}function Pr(e,t){let n=kn(e),r=kn(t);return n.major!==r.major?n.major<r.major?-1:1:n.minor!==r.minor?n.minor<r.minor?-1:1:n.patch!==r.patch?n.patch<r.patch?-1:1:0}function jr(e,t){let n=kn(e),r=kn(t);return n.major===r.major}var He=class e extends Error{path;expected;actual;callStack;reason;constructor(t,n,r,s,a,i){super(t),this.name="MonadicError",this.path=n,this.expected=r,this.actual=s,this.callStack=a,this.reason=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function iu(e,t,n,r){let s=n===null?"null":typeof n,a=H.callStacks||H.debug?Nr():void 0,i=r?`Expected ${t} for '${e}': ${r}`:`Expected ${t} for '${e}', got ${s}`,o=new He(i,e,t,s,a,r);if(H.trackErrors!==!1){let u=H.maxErrors??En;Fi[bt]=o,bt=(bt+1)%u,at<u&&at++,Tn++}if(H.logTypeErrors&&console.error(`[TJS TypeError] ${o.message}`),H.throwTypeErrors)throw o;return o}function Ar(e){return e instanceof Error&&e.name==="MonadicError"&&"path"in e}var Ir={debug:!1,safety:"inputs",requireReturnTypes:!1,callStacks:!1,maxStackSize:64,trackErrors:!0,maxErrors:64},H={...Ir},Ut=64,Di=new Array(Ut).fill(""),it=0,Ue=0,En=64,Fi=new Array(En).fill(null),bt=0,at=0,Tn=0,wt=0;function au(){wt++}function ou(){wt>0&&wt--}function uu(){return wt>0}function cu(e){H={...H,...e}}function lu(){return{...H}}function Li(e){if((H.callStacks||H.debug)&&e){let t=H.maxStackSize??Ut;Di[it]=e,it=(it+1)%t,Ue<t&&Ue++}}function vn(){if((H.callStacks||H.debug)&&Ue>0){let e=H.maxStackSize??Ut;it=(it-1+e)%e,Ue--}}function Nr(){if(Ue===0)return[];let e=H.maxStackSize??Ut,t=[],n=(it-Ue+e)%e;for(let r=0;r<Ue;r++)t.push(Di[(n+r)%e]);return t}function Vi(){if(H.trackErrors===!1||at===0)return[];let e=H.maxErrors??En,t=[],n=(bt-at+e)%e;for(let r=0;r<at;r++)t.push(Fi[(n+r)%e]);return t}function fu(){let e=Vi();return bt=0,at=0,Tn=0,e}function pu(){return Tn}function hu(){H={...Ir},it=0,Ue=0,bt=0,at=0,Tn=0,wt=0}function xt(e,t){if(e!==null&&typeof e=="object"&&typeof e[qt]=="function")return e[qt](t);if(t!==null&&typeof t=="object"&&typeof t[qt]=="function")return t[qt](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if((e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[s,a]of e)if(!t.has(s)||!xt(a,t.get(s)))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>xt(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>xt(e[s],t[s]))}function qi(e,t){return!xt(e,t)}function Ui(e){return e===null?"null":typeof e}function Wi(e){return e instanceof Boolean||e instanceof Number||e instanceof String?!!e.valueOf():!!e}function Rr(e,t){return(e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),!!(e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)}function Ji(e,t){return!Rr(e,t)}function qe(e){return e!==null&&typeof e=="object"&&e.$error===!0}function Re(e,t){let n={$error:!0,message:e,...t};if((H.callStacks||H.debug)&&Ue>0){let r=Nr(),s=t?.path?[...r,t.path]:r;n.stack=s}return n}function Mr(e,t){if(e.length===0)return Re("Unknown error");if(e.length===1)return e[0];let n=e.map(s=>{if(s.path){let a=s.path.split(".");return a[a.length-1]}return"unknown"}).join(", "),r=`Multiple parameter errors in ${t||"function"}: ${n}`;return Re(r,{path:t,errors:e})}function _t(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;if(t!=="object")return t;let n=e.constructor?.name;return n&&n!=="Object"?n:"object"}function zi(e,t){if(e==null||typeof e!="object"&&typeof e!="function")return!1;let n=e;for(;n!==null;){if(n.constructor?.name===t)return!0;n=Object.getPrototypeOf(n)}return!1}function ot(e,t,n){if(qe(e))return e;if(typeof t=="object"&&t!==null&&"check"in t){let s=t.check(e);if(s===!0)return null;let a=typeof s=="string"?s:void 0,i=a?`Expected ${t.description} for '${n}': ${a}`:`Expected ${t.description} but got ${_t(e)}`;return Re(i,{path:n,expected:t.description,actual:_t(e),reason:a})}let r=_t(e);return t==="any"||t===r||t==="number"&&r==="number"||t==="integer"&&r==="number"&&Number.isInteger(e)||t==="non-negative-integer"&&r==="number"&&Number.isInteger(e)&&e>=0||t==="object"&&r==="object"?null:Re(`Expected ${t} but got ${r}`,{path:n,expected:t,actual:r})}function Gi(e,t,n,r){if(typeof e!="function")return e;let s=e.__tjs;if(!s||!s.params)return e;let a=Object.entries(s.params);for(let i=0;i<t.length;i++){let o=t[i];if(o==="any")continue;let u=a[i];if(!u)continue;let c=u[1]?.type?.kind;if(!(!c||c==="any")&&c!==o)return new He(`Expected (...arg${i}: ${o}, ...) for '${r}', but callback declares arg${i} as ${c}`,`${r}(arg${i})`,o,c)}if(n!=="any"&&s.returns){let i=s.returns.type?.kind??s.returns.kind;if(i&&i!=="any"&&i!==n)return new He(`Expected callback returning ${n} for '${r}', but callback returns ${i}`,`${r}(return)`,n,i)}return e}function Or(e,t,n){for(let[r,s]of Object.entries(t.params)){let a=e[r];if(qe(a))return a;if(s.required&&a===void 0){let o=typeof s.type=="string"?s.type:s.type.description;return Re(`Missing required parameter '${r}'`,{path:n?`${n}.${r}`:r,expected:o,actual:"undefined",loc:s.loc})}if(a===void 0)continue;let i=ot(a,s.type,n?`${n}.${r}`:r);if(i)return s.loc&&(i.loc=s.loc),i}return null}function Br(e,t){if(e.__tjs=t,e.__tjs.schema=()=>pr(t),!(!t.polymorphic&&(t.safe||t.safeReturn||H.safety!=="none"&&!t.unsafe||t.returns&&H.safety==="all"&&!t.unsafeReturn)))return e;let r=!!t.returns,s=!!t.unsafe,a=!!t.safe,i=!!t.unsafeReturn,o=!!t.safeReturn,u=t.returns?.defaults,c=Object.entries(t.params),l=c.length,p=e.name||t.name||"anonymous",f=function(...d){if(wt>0)return e.apply(this,d);let m=a||!s&&H.safety!=="none",y=r&&(o||!i&&H.safety==="all");if(!m&&!y)return e.apply(this,d);if(d.length>0&&qe(d[0]))return d[0];if(m){let S=d.length===1&&typeof d[0]=="object"&&d[0]!==null&&!Array.isArray(d[0]),E=[];if(S){let _=d[0];for(let b=0;b<l;b++){let[v,w]=c[b],k=_[v];if(qe(k)){E.push(k);continue}if(w.required&&k===void 0){E.push(Re(`Missing required parameter '${v}'`,{path:`${p}.${v}`,expected:typeof w.type=="string"?w.type:w.type?.description||"value",actual:"undefined",loc:w.loc}));continue}if(k!==void 0){let T=ot(k,w.type,`${p}.${v}`);T&&(w.loc&&(T.loc=w.loc),E.push(T))}}}else for(let _=0;_<l;_++){let[b,v]=c[_],w=d[_];if(qe(w)){E.push(w);continue}if(v.required&&w===void 0){E.push(Re(`Missing required parameter '${b}'`,{path:`${p}.${b}`,expected:typeof v.type=="string"?v.type:v.type?.description||"value",actual:"undefined",loc:v.loc}));continue}if(w!==void 0){let k=ot(w,v.type,`${p}.${b}`);k&&(v.loc&&(k.loc=v.loc),E.push(k))}}if(E.length>0)return Mr(E,p)}let x=H.callStacks||H.debug;x&&Li(p);try{let S=e.apply(this,d);if(y&&t.returns&&!qe(S)){let E=u&&typeof S=="object"&&S!==null?Object.assign({},u,S):S,_=ot(E,t.returns.type,`${p}()`);if(_)return x&&vn(),_}return x&&vn(),S}catch(S){return x&&vn(),Re(S.message||String(S),{path:p,cause:S})}};return Object.defineProperty(f,"name",{value:e.name}),f.__tjs=t,f.__tjs.schema=()=>pr(t),f}function Hi(e){let t=new Proxy(e,{construct(n,r,s){return Reflect.construct(n,r,s)},apply(n,r,s){return Reflect.construct(n,s)}});Object.defineProperty(t,"name",{value:e.name});for(let n of Object.getOwnPropertyNames(e))n!=="length"&&n!=="name"&&n!=="prototype"&&Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n));return t}function Ki(){let e={...H},t=e.maxStackSize??Ut,n=new Array(t).fill(""),r=0,s=0,a=e.maxErrors??En,i=new Array(a).fill(null),o=0,u=0,c=0,l=0;function p(R){e={...e,...R}}function f(){return{...e}}function d(R){(e.callStacks||e.debug)&&R&&(n[r]=R,r=(r+1)%t,s<t&&s++)}function m(){(e.callStacks||e.debug)&&s>0&&(r=(r-1+t)%t,s--)}function y(){if(s===0)return[];let R=[],U=(r-s+t)%t;for(let J=0;J<s;J++)R.push(n[(U+J)%t]);return R}function x(){e={...Ir},r=0,s=0,o=0,u=0,c=0,l=0}function S(){l++}function E(){l>0&&l--}function _(){return l>0}let b=new Map;function v(R,U,J){b.has(R)||b.set(R,new Map),b.get(R).set(U,J)}function w(R,U){let J=typeof R,X;if(R==null)return;if(J==="string")X="String";else if(J==="number")X="Number";else if(J==="boolean")X="Boolean";else if(Array.isArray(R))X="Array";else if(J==="object")X=R.constructor?.name||"Object";else return;let ee=X;for(;ee;){let lt=b.get(ee);if(lt?.has(U))return lt.get(U);if(J==="object"&&!Array.isArray(R)){if(ee=Object.getPrototypeOf(ee===X?R:Object.getPrototypeOf(R))?.constructor?.name,ee==="Object"||ee===X)break}else break}let ce=b.get("Object");if(ce?.has(U))return ce.get(U)}function k(R,U,J){let X=J===null?"null":typeof J,ee=e.callStacks||e.debug?y():void 0,ce=new He(`Expected ${U} for '${R}', got ${X}`,R,U,X,ee);if(e.trackErrors!==!1&&(i[o]=ce,o=(o+1)%a,u<a&&u++,c++),e.logTypeErrors&&console.error(`[TJS TypeError] ${ce.message}`),e.throwTypeErrors)throw ce;return ce}function T(){if(e.trackErrors===!1||u===0)return[];let R=[],U=(o-u+a)%a;for(let J=0;J<u;J++)R.push(i[(U+J)%a]);return R}function C(){let R=T();return o=0,u=0,c=0,R}function N(){return c}function P(R,U){let J={$error:!0,message:R,...U};if((e.callStacks||e.debug)&&s>0){let X=U?.path?[...y(),U.path]:y();J.stack=X}return J}function D(R,U){return R==null?k(`bang.${U}`,"non-null",R):Ar(R)?R:R[U]}return{version:Ve,MonadicError:He,typeError:k,isMonadicError:Ar,bang:D,isError:qe,error:P,composeErrors:Mr,typeOf:_t,isNativeType:zi,checkType:ot,validateArgs:Or,wrap:Br,checkFnShape:Gi,wrapClass:Hi,compareVersions:Pr,versionsCompatible:jr,createRuntime:Ki,configure:p,getConfig:f,pushStack:d,popStack:m,getStack:y,errors:T,clearErrors:C,getErrorCount:N,resetRuntime:x,enterUnsafe:S,exitUnsafe:E,isUnsafeMode:_,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:rt,Union:kr,Generic:Vt,Enum:Cr,FunctionPredicate:Sn,Nullable:Sr,Optional:vr,TArray:Er,TString:hr,TNumber:dr,TBoolean:mr,TInteger:gr,TPositiveInt:yr,TNonEmptyString:br,TEmail:xr,TUrl:_r,TUuid:wr,TPair:Tr,TRecord:$r,Is:xt,IsNot:qi,Eq:Rr,NotEq:Ji,TypeOf:Ui,toBool:Wi,tjsEquals:qt,registerExtension:v,resolveExtension:w}}var st={version:Ve,MonadicError:He,typeError:iu,isMonadicError:Ar,isError:qe,error:Re,composeErrors:Mr,typeOf:_t,isNativeType:zi,checkType:ot,validateArgs:Or,wrap:Br,checkFnShape:Gi,wrapClass:Hi,compareVersions:Pr,versionsCompatible:jr,configure:cu,getConfig:lu,pushStack:Li,popStack:vn,getStack:Nr,errors:Vi,clearErrors:fu,getErrorCount:pu,resetRuntime:hu,enterUnsafe:au,exitUnsafe:ou,isUnsafeMode:uu,createRuntime:Ki,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:rt,Union:kr,Generic:Vt,Enum:Cr,FunctionPredicate:Sn,Nullable:Sr,Optional:vr,TArray:Er,TString:hr,TNumber:dr,TBoolean:mr,TInteger:gr,TPositiveInt:yr,TNonEmptyString:br,TEmail:xr,TUrl:_r,TUuid:wr,Timestamp:Mi,LegalDate:Oi,TPair:Tr,TRecord:$r,Is:xt,IsNot:qi,Eq:Rr,NotEq:Ji,TypeOf:Ui,toBool:Wi};function Dr(){let e=globalThis;if(e.__tjs){let t=e.__tjs.version;if(typeof t!="string")return e.__tjs=st,st;let n=Pr(Ve,t);return n===0||(jr(Ve,t)?n>0?(console.info(`TJS runtime: upgrading ${t} \u2192 ${Ve}`),e.__tjs=st):console.info(`TJS runtime: keeping ${t} (newer than ${Ve})`):(console.warn(`TJS runtime version conflict: ${t} vs ${Ve} (major version mismatch)`),n>0&&(console.warn(`Upgrading to ${Ve} - check for breaking changes`),e.__tjs=st))),e.__tjs}return e.__tjs=st,st}function du(e){return`
|
|
188
|
+
`,Xo=Ci+`
|
|
189
|
+
`+Ai;var O=e=>({schema:e,_type:null,validate:(t,n)=>Ne(t,e,n),get optional(){return O({...e,type:Array.isArray(e.type)?[...e.type,"null"]:[e.type,"null"]})},title:t=>O({...e,title:t}),describe:t=>O({...e,description:t}),default:t=>O({...e,default:t}),meta:t=>O({...t,...e,...t}),min:t=>{let n=e.type==="string"?"minLength":e.type==="array"?"minItems":e.type==="object"?"minProperties":"minimum";return O({...e,[n]:t})},max:t=>{let n=e.type==="string"?"maxLength":e.type==="array"?"maxItems":e.type==="object"?"maxProperties":"maximum";return O({...e,[n]:t})},pattern:t=>O({...e,pattern:typeof t=="string"?t:t.source}),get email(){return O({...e,format:"email"})},get uuid(){return O({...e,format:"uuid"})},get ipv4(){return O({...e,format:"ipv4"})},get url(){return O({...e,format:"uri"})},get datetime(){return O({...e,format:"date-time"})},get emoji(){return O({...e,pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get int(){return O({...e,type:"integer"})},step:t=>O({...e,multipleOf:t})}),Pi=null;var mr={get email(){return O({type:"string",format:"email"})},get uuid(){return O({type:"string",format:"uuid"})},get ipv4(){return O({type:"string",format:"ipv4"})},get url(){return O({type:"string",format:"uri"})},get datetime(){return O({type:"string",format:"date-time"})},get emoji(){return O({type:"string",pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get null(){return O({type:"null"})},get undefined(){return O({type:"null","x-tjs-undefined":!0})},get any(){return O({})},pattern:e=>O({type:"string",pattern:typeof e=="string"?e:e.source}),union:e=>O({anyOf:e.map(t=>t.schema)}),enum:e=>O({type:typeof e[0],enum:e}),const:e=>O({const:e}),array:e=>O({type:"array",items:e.schema}),tuple:e=>O({type:"array",items:e.map(t=>t.schema),minItems:e.length,maxItems:e.length}),object:e=>{let t={},n=[];for(let r in e)t[r]=e[r].schema,(!Array.isArray(t[r].type)||!t[r].type.includes("null"))&&n.push(r);return O({type:"object",properties:t,required:n,additionalProperties:!1})},record:e=>O({type:"object",additionalProperties:e.schema}),infer:e=>{if(e===null)return O({type:"null"});if(e===void 0)return O({type:"null","x-tjs-undefined":!0});let t=typeof e;if(t==="string")return O({type:"string"});if(t==="number")return O({type:Number.isInteger(e)?"integer":"number"});if(t==="boolean")return O({type:"boolean"});if(Array.isArray(e))return e.length===0?O({type:"array"}):O({type:"array",items:mr.infer(e[0]).schema});if(t==="object"){let n={},r=[];for(let s in e)n[s]=mr.infer(e[s]).schema,r.push(s);return O({type:"object",properties:n,required:r,additionalProperties:!1})}return O({})}},ye=new Proxy(mr,{get(e,t){if(t in e)return e[t];if(t==="string"||t==="number"||t==="boolean"||t==="integer"){let n=O({type:t});return e[t]=n,n}}}),_n=97,ji={email:e=>/^\S+@\S+\.\S+$/.test(e),uuid:e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),uri:e=>{try{return new URL(e),!0}catch{return!1}},ipv4:e=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e),"date-time":e=>!isNaN(Date.parse(e)),emoji:e=>new RegExp("\\p{Extended_Pictographic}","u").test(e)};function Ne(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1,i=[],o=c=>(s&&s(i.join(".")||"root",c),!1),u=(c,l)=>{if(l.anyOf){for(let f of l.anyOf)if(Ne(c,f))return!0;return o("Union mismatch")}if(l.const!==void 0)return c===l.const||o("Const mismatch");if(c===null){let f=l.type==="null"&&!l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got null")}if(c===void 0){let f=l.type==="null"&&l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got undefined")}let p=Array.isArray(l.type)?l.type[0]:l.type;if(l.enum&&!l.enum.includes(c))return o("Enum mismatch");if(p==="integer"){if(typeof c!="number"||!Number.isInteger(c))return o("Expected integer")}else if(p==="array"){if(!Array.isArray(c))return o("Expected array")}else if(p==="object"){if(typeof c!="object"||Array.isArray(c))return o("Expected object")}else if(p&&typeof c!==p)return o(`Expected ${p}`);if(l.$predicate&&Pi&&!Pi(l.$predicate,c))return o("Predicate mismatch");if(typeof c=="number"){if(!Number.isFinite(c))return o("Expected finite number");if(l.minimum!==void 0&&c<l.minimum)return o("Value < min");if(l.maximum!==void 0&&c>l.maximum)return o("Value > max");if(l.multipleOf!==void 0){let f=Math.abs(c%l.multipleOf),d=1e-10;if(f>1e-10&&Math.abs(f-Math.abs(l.multipleOf))>1e-10)return o("Value not step")}}if(typeof c=="string"){if(l.minLength!==void 0&&c.length<l.minLength)return o("Len < min");if(l.maxLength!==void 0&&c.length>l.maxLength)return o("Len > max");if(l.pattern&&!new RegExp(l.pattern,l.format==="emoji"?"u":"").test(c))return o("Pattern mismatch");if(l.format&&ji[l.format]&&!ji[l.format](c))return o("Format invalid")}if(p==="object"){let f=l.minProperties!==void 0,d=a&&l.maxProperties!==void 0;if(f||d){let m=0;for(let y in c)Object.prototype.hasOwnProperty.call(c,y)&&m++;if(f&&m<l.minProperties)return o("Too few props");if(d&&m>l.maxProperties)return o("Too many props")}if(l.required){for(let m of l.required)if(!(m in c))return o(`Missing ${m}`)}if(l.properties){for(let m in l.properties)if(m in c){i.push(m);let y=u(c[m],l.properties[m]);if(i.pop(),!y)return!1}}if(l.additionalProperties){let m=[];for(let S in c)l.properties&&S in l.properties||m.push(S);let y=m.length,x=a||y<=_n?1:Math.floor(y/_n);for(let S=0;S<y;S+=x){let v=x>1&&S>y-1-x?y-1:S,b=m[v];i.push(b);let _=u(c[b],l.additionalProperties);if(i.pop(),!_)return!1;if(v===y-1)break}}return!0}if(p==="array"&&l.items){let f=c.length;if(l.minItems!==void 0&&f<l.minItems)return o("Array too short");if(l.maxItems!==void 0&&f>l.maxItems)return o("Array too long");if(Array.isArray(l.items)){for(let m=0;m<l.items.length;m++){if(i.push(String(m)),!u(c[m],l.items[m]))return i.pop(),!1;i.pop()}return!0}let d=a||f<=_n?1:Math.floor(f/_n);for(let m=0;m<f;m+=d){let y=d>1&&m>f-1-d?f-1:m;i.push(String(y));let x=u(c[y],l.items);if(i.pop(),!x)return!1;if(y===f-1)break}return!0}return!0};return u(e,r)}function Ii(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1;if(!(typeof n=="object"&&n?.skipValidation)){let i="",o="";if(!Ne(e,r,{onError:(u,c)=>{i||(i=u,o=c),s&&s(u,c)},fullScan:a}))return Error(`${i}: ${o}`)}return wn(e,r)}function wn(e,t){if(e==null)return e;let n=t.type;if(n==="object"&&t.properties&&typeof e=="object"&&!Array.isArray(e)){let r={};for(let s of Object.keys(t.properties))s in e&&(r[s]=wn(e[s],t.properties[s]));return r}return n==="array"&&Array.isArray(e)&&t.items?Array.isArray(t.items)?e.slice(0,t.items.length).map((r,s)=>wn(r,t.items[s])):e.map(r=>wn(r,t.items)):e}function gt(e){if(e.nullable)return{anyOf:[gt({...e,nullable:!1}),{type:"null"}]};switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"integer":return{type:"integer"};case"non-negative-integer":return{type:"integer",minimum:0};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"undefined":return{};case"any":return{};case"array":return e.items?{type:"array",items:gt(e.items)}:{type:"array"};case"object":if(e.shape){let t={},n=[];for(let[r,s]of Object.entries(e.shape))t[r]=gt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{anyOf:e.members.map(gt)}:{};default:return{}}}function yt(e){if(e===null)return{type:"null"};if(e===void 0)return{};switch(typeof e){case"string":return{type:"string"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:yt(e[0])};let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=yt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}default:return{}}}function gr(e){let t={},n=[];for(let[a,i]of Object.entries(e.params))i?.type?.kind?t[a]=gt(i.type):i?.example!==void 0?t[a]=yt(i.example):t[a]={},i?.required!==!1&&n.push(a),i?.example!==void 0&&(t[a].examples=[i.example]);let r={type:"object",properties:t,required:n},s;return e.returns&&(e.returns.type?.kind?s=gt(e.returns.type):e.returns.example!==void 0&&(s=yt(e.returns.example))),{input:r,output:s}}function rt(e){return e!==null&&typeof e=="object"&&"__runtimeType"in e&&e.__runtimeType===!0}function Ni(e){return e!==null&&typeof e=="object"&&"schema"in e&&typeof e.schema=="object"}function eu(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function ie(e,t,n,r){let s,a,i,o=n,u=r;if(typeof e=="string")if(s=e,typeof t=="function")a=t,o!==void 0&&(i=ye.infer(o));else if(t===void 0&&o!==void 0)i=ye.infer(o);else if(Ni(t))i=t;else if(eu(t))i=t;else if(t!==void 0)o=t,u=o,i=ye.infer(o);else throw new Error("Type(description) requires a predicate, schema, or example");else Ni(e),i=e,s=tu(i);let c;if(i){let p=i?.schema??i;p&&typeof p=="object"&&Array.isArray(p.examples)&&(c=p.examples)}return o===void 0&&c&&c.length>0&&(o=c[0]),{description:s,check:p=>a?a(p):i?Ne(p,i):!1,schema:i,predicate:a,example:o,examples:c,default:u,toJSONSchema(){if(i){let p=i?.schema??i;if(p&&typeof p=="object"&&"type"in p)return p}return o!==void 0?yt(o):{description:s}},strip(p){return i?Ii(p,i):p},__runtimeType:!0}}function tu(e){let t=e?.schema??e;if(t&&typeof t=="object"&&"type"in t){let n=t;switch(n.type){case"string":return n.format?`string (${n.format})`:n.pattern?`string matching ${n.pattern}`:n.minLength!==void 0&&n.maxLength!==void 0?`string (${n.minLength}-${n.maxLength} chars)`:"string";case"number":case"integer":return n.minimum!==void 0&&n.maximum!==void 0?`${n.type} (${n.minimum}-${n.maximum})`:n.minimum!==void 0?`${n.type} >= ${n.minimum}`:n.maximum!==void 0?`${n.type} <= ${n.maximum}`:n.type;case"boolean":return"boolean";case"array":return"array";case"object":return"object";case"null":return"null"}}return"value"}var yr=ie("string",e=>typeof e=="string"?!0:`expected string, got ${e===null?"null":typeof e}`),br=ie("number",e=>typeof e=="number"?!0:`expected number, got ${e===null?"null":typeof e}`),xr=ie("boolean",e=>typeof e=="boolean"?!0:`expected boolean, got ${e===null?"null":typeof e}`),_r=ie("integer",e=>typeof e!="number"?`expected integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?!0:`${e} is not an integer`),wr=ie("positive integer",e=>typeof e!="number"?`expected positive integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?e<=0?`${e} is not positive`:!0:`${e} is not an integer`),Sr=ie("non-empty string",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:e.length===0?"string is empty":!0),vr=ie("email address",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?!0:`"${e}" is not a valid email`),Ri=e=>{try{return new URL(e),!0}catch{return!1}},kr=ie("URL",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:Ri(e)?!0:`"${e}" is not a valid URL`),Er=ie("UUID",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?!0:`"${e}" is not a valid UUID`),Mi=e=>{let t=new Date(e);return!isNaN(t.getTime())&&e.includes("T")},Oi=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(e+"T00:00:00Z");return!isNaN(t.getTime())},Bi=ie("ISO 8601 timestamp",e=>typeof e=="string"&&Mi(e)),Di=ie("date (YYYY-MM-DD)",e=>typeof e=="string"&&Oi(e));function Tr(e){return ie(`${e.description} or null`,t=>t===null||e.check(t)===!0)}function $r(e){return ie(`${e.description} (optional)`,t=>t==null||e.check(t)===!0)}function Cr(e,t,...n){if(typeof e=="string"&&Array.isArray(t)){let a=e,i=t,o=new Set(i);return{description:a,check:c=>o.has(c),toJSONSchema:()=>({enum:i}),strip:c=>c,__runtimeType:!0,values:i}}let r=[];rt(e)&&r.push(e),rt(t)&&r.push(t),r.push(...n);let s=r.map(a=>a.description).join(" | ");return ie(s,a=>r.some(i=>i.check(a)===!0))}function Ar(e){return ie(`array of ${e.description}`,t=>Array.isArray(t)&&t.every(n=>e.check(n)===!0))}function nu(e){if(rt(e))return n=>e.check(n)===!0;if(e&&typeof e=="object"&&"schema"in e)return n=>Ne(n,e);let t=ye.infer(e);return n=>Ne(n,t)}function Vt(e,t,n){let r=[],s=[];for(let i of e)typeof i=="string"?(r.push(i),s.push(void 0)):(r.push(i[0]),s.push(i[1]));let a=(...i)=>{let o=r.map((c,l)=>{let p=l<i.length?i[l]:s[l];return p===void 0?()=>!0:nu(p)}),u=n;return r.forEach((c,l)=>{let p=l<i.length?i[l]:s[l],f="any";rt(p)?f=p.description:p!==void 0&&(f=typeof p=="string"?"string":JSON.stringify(p)),u=u.replace(new RegExp(`\\b${c}\\b`,"g"),f)}),ie(u,c=>t(c,...o))};return a.params=r,a.description=n,a}var Pr=Vt(["T","U"],(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),"Pair<T, U>"),jr=Vt(["V"],(e,t)=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.values(e).every(t),"Record<string, V>");function Ir(e,t){let n=Object.values(t),r=new Set(n),s=Object.keys(t),a={};for(let[o,u]of Object.entries(t))a[u]=o;return{description:e,check:o=>r.has(o),toJSONSchema:()=>({enum:n}),strip:o=>o,__runtimeType:!0,members:t,names:a,values:n,keys:s}}function ru(e){if(e===null)return"null";if(e===void 0)return"undefined";switch(typeof e){case"string":return"string";case"boolean":return"boolean";case"number":return Number.isInteger(e)?"integer":"number";case"object":return Array.isArray(e)?"array":"object";default:return null}}function Sn(e,t,n){if(Array.isArray(t)&&n){let r=t,s=[],a=[];for(let o of r)Array.isArray(o)?(s.push(o[0]),a.push(o[1])):(s.push(o),a.push(void 0));let i=((...o)=>{let u=s.map((l,p)=>p<o.length?o[p]:a[p]),c=n(...u);return Sn(e,c)});return Object.defineProperties(i,{typeParamNames:{value:s,enumerable:!0},description:{value:e,enumerable:!0},__runtimeType:{value:!0,enumerable:!0}}),i}return su(e,t)}function su(e,t){let n={},r,s="assertReturns";if(typeof t=="function"){let i=t.__tjs;if(i){if(i.params)for(let[o,u]of Object.entries(i.params))n[o]=u?.example??null;i.returns&&(r=i.returns?.example??null),i.safeReturn?s="checkedReturns":i.unsafe?s="assertReturns":s="returns"}}else n=t.params??{},r=t.returns,s=t.returnContract??"assertReturns";return{description:e,params:n,returns:r,returnContract:s,toJSONSchema:()=>({description:e,type:"function"}),strip:i=>i,check:i=>{if(typeof i!="function")return`expected function, got ${i===null?"null":typeof i}`;let o=Object.keys(n).length;if(o>0){let c=i.__tjs;if(c?.params){let l=Object.keys(c.params).length;if(l!==o)return`expected ${o} params, got ${l}`;let p=Object.keys(n),f=Object.keys(c.params);for(let d=0;d<p.length;d++){let m=c.params[f[d]],y=n[p[d]];if(m?.type?.kind&&y!==void 0){let x=ru(y);if(x&&m.type.kind!==x&&m.type.kind!=="any")return`param '${p[d]}' expected ${x}, got ${m.type.kind}`}}}}return!0},__runtimeType:!0}}var au=Fi(),Ve=au.version,qt=Symbol.for("tjs.equals");function kn(e){let[t=0,n=0,r=0]=e.split(".").map(Number);return{major:t,minor:n,patch:r}}function Rr(e,t){let n=kn(e),r=kn(t);return n.major!==r.major?n.major<r.major?-1:1:n.minor!==r.minor?n.minor<r.minor?-1:1:n.patch!==r.patch?n.patch<r.patch?-1:1:0}function Mr(e,t){let n=kn(e),r=kn(t);return n.major===r.major}var He=class e extends Error{path;expected;actual;callStack;reason;constructor(t,n,r,s,a,i){super(t),this.name="MonadicError",this.path=n,this.expected=r,this.actual=s,this.callStack=a,this.reason=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function ou(e,t,n,r){let s=n===null?"null":typeof n,a=H.callStacks||H.debug?Br():void 0,i=r?`Expected ${t} for '${e}': ${r}`:`Expected ${t} for '${e}', got ${s}`,o=new He(i,e,t,s,a,r);if(H.trackErrors!==!1){let u=H.maxErrors??En;Vi[bt]=o,bt=(bt+1)%u,at<u&&at++,Tn++}if(H.logTypeErrors&&console.error(`[TJS TypeError] ${o.message}`),H.throwTypeErrors)throw o;return o}function Nr(e){return e instanceof Error&&e.name==="MonadicError"&&"path"in e}var Or={debug:!1,safety:"inputs",requireReturnTypes:!1,callStacks:!1,maxStackSize:64,trackErrors:!0,maxErrors:64},H={...Or},Ut=64,Li=new Array(Ut).fill(""),it=0,Ue=0,En=64,Vi=new Array(En).fill(null),bt=0,at=0,Tn=0,wt=0;function uu(){wt++}function cu(){wt>0&&wt--}function lu(){return wt>0}function fu(e){H={...H,...e}}function pu(){return{...H}}function qi(e){if((H.callStacks||H.debug)&&e){let t=H.maxStackSize??Ut;Li[it]=e,it=(it+1)%t,Ue<t&&Ue++}}function vn(){if((H.callStacks||H.debug)&&Ue>0){let e=H.maxStackSize??Ut;it=(it-1+e)%e,Ue--}}function Br(){if(Ue===0)return[];let e=H.maxStackSize??Ut,t=[],n=(it-Ue+e)%e;for(let r=0;r<Ue;r++)t.push(Li[(n+r)%e]);return t}function Ui(){if(H.trackErrors===!1||at===0)return[];let e=H.maxErrors??En,t=[],n=(bt-at+e)%e;for(let r=0;r<at;r++)t.push(Vi[(n+r)%e]);return t}function hu(){let e=Ui();return bt=0,at=0,Tn=0,e}function du(){return Tn}function mu(){H={...Or},it=0,Ue=0,bt=0,at=0,Tn=0,wt=0}function xt(e,t){if(e!==null&&typeof e=="object"&&typeof e[qt]=="function")return e[qt](t);if(t!==null&&typeof t=="object"&&typeof t[qt]=="function")return t[qt](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if((e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[s,a]of e)if(!t.has(s)||!xt(a,t.get(s)))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>xt(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>xt(e[s],t[s]))}function Wi(e,t){return!xt(e,t)}function Ji(e){return e===null?"null":typeof e}function zi(e){return e instanceof Boolean||e instanceof Number||e instanceof String?!!e.valueOf():!!e}function Dr(e,t){return(e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),!!(e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)}function Gi(e,t){return!Dr(e,t)}function qe(e){return e!==null&&typeof e=="object"&&e.$error===!0}function Re(e,t){let n={$error:!0,message:e,...t};if((H.callStacks||H.debug)&&Ue>0){let r=Br(),s=t?.path?[...r,t.path]:r;n.stack=s}return n}function Fr(e,t){if(e.length===0)return Re("Unknown error");if(e.length===1)return e[0];let n=e.map(s=>{if(s.path){let a=s.path.split(".");return a[a.length-1]}return"unknown"}).join(", "),r=`Multiple parameter errors in ${t||"function"}: ${n}`;return Re(r,{path:t,errors:e})}function _t(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;if(t!=="object")return t;let n=e.constructor?.name;return n&&n!=="Object"?n:"object"}function Hi(e,t){if(e==null||typeof e!="object"&&typeof e!="function")return!1;let n=e;for(;n!==null;){if(n.constructor?.name===t)return!0;n=Object.getPrototypeOf(n)}return!1}function ot(e,t,n){if(qe(e))return e;if(typeof t=="object"&&t!==null&&"check"in t){let s=t.check(e);if(s===!0)return null;let a=typeof s=="string"?s:void 0,i=a?`Expected ${t.description} for '${n}': ${a}`:`Expected ${t.description} but got ${_t(e)}`;return Re(i,{path:n,expected:t.description,actual:_t(e),reason:a})}let r=_t(e);return t==="any"||t===r||t==="number"&&r==="number"||t==="integer"&&r==="number"&&Number.isInteger(e)||t==="non-negative-integer"&&r==="number"&&Number.isInteger(e)&&e>=0||t==="object"&&r==="object"?null:Re(`Expected ${t} but got ${r}`,{path:n,expected:t,actual:r})}function Ki(e,t,n,r){if(typeof e!="function")return e;let s=e.__tjs;if(!s||!s.params)return e;let a=Object.entries(s.params);for(let i=0;i<t.length;i++){let o=t[i];if(o==="any")continue;let u=a[i];if(!u)continue;let c=u[1]?.type?.kind;if(!(!c||c==="any")&&c!==o)return new He(`Expected (...arg${i}: ${o}, ...) for '${r}', but callback declares arg${i} as ${c}`,`${r}(arg${i})`,o,c)}if(n!=="any"&&s.returns){let i=s.returns.type?.kind??s.returns.kind;if(i&&i!=="any"&&i!==n)return new He(`Expected callback returning ${n} for '${r}', but callback returns ${i}`,`${r}(return)`,n,i)}return e}function Lr(e,t,n){for(let[r,s]of Object.entries(t.params)){let a=e[r];if(qe(a))return a;if(s.required&&a===void 0){let o=typeof s.type=="string"?s.type:s.type.description;return Re(`Missing required parameter '${r}'`,{path:n?`${n}.${r}`:r,expected:o,actual:"undefined",loc:s.loc})}if(a===void 0)continue;let i=ot(a,s.type,n?`${n}.${r}`:r);if(i)return s.loc&&(i.loc=s.loc),i}return null}function Vr(e,t){if(e.__tjs=t,e.__tjs.schema=()=>gr(t),!(!t.polymorphic&&(t.safe||t.safeReturn||H.safety!=="none"&&!t.unsafe||t.returns&&H.safety==="all"&&!t.unsafeReturn)))return e;let r=!!t.returns,s=!!t.unsafe,a=!!t.safe,i=!!t.unsafeReturn,o=!!t.safeReturn,u=t.returns?.defaults,c=Object.entries(t.params),l=c.length,p=e.name||t.name||"anonymous",f=function(...d){if(wt>0)return e.apply(this,d);let m=a||!s&&H.safety!=="none",y=r&&(o||!i&&H.safety==="all");if(!m&&!y)return e.apply(this,d);if(d.length>0&&qe(d[0]))return d[0];if(m){let S=d.length===1&&typeof d[0]=="object"&&d[0]!==null&&!Array.isArray(d[0]),v=[];if(S){let b=d[0];for(let _=0;_<l;_++){let[k,w]=c[_],E=b[k];if(qe(E)){v.push(E);continue}if(w.required&&E===void 0){v.push(Re(`Missing required parameter '${k}'`,{path:`${p}.${k}`,expected:typeof w.type=="string"?w.type:w.type?.description||"value",actual:"undefined",loc:w.loc}));continue}if(E!==void 0){let $=ot(E,w.type,`${p}.${k}`);$&&(w.loc&&($.loc=w.loc),v.push($))}}}else for(let b=0;b<l;b++){let[_,k]=c[b],w=d[b];if(qe(w)){v.push(w);continue}if(k.required&&w===void 0){v.push(Re(`Missing required parameter '${_}'`,{path:`${p}.${_}`,expected:typeof k.type=="string"?k.type:k.type?.description||"value",actual:"undefined",loc:k.loc}));continue}if(w!==void 0){let E=ot(w,k.type,`${p}.${_}`);E&&(k.loc&&(E.loc=k.loc),v.push(E))}}if(v.length>0)return Fr(v,p)}let x=H.callStacks||H.debug;x&&qi(p);try{let S=e.apply(this,d);if(y&&t.returns&&!qe(S)){let v=u&&typeof S=="object"&&S!==null?Object.assign({},u,S):S,b=ot(v,t.returns.type,`${p}()`);if(b)return x&&vn(),b}return x&&vn(),S}catch(S){return x&&vn(),Re(S.message||String(S),{path:p,cause:S})}};return Object.defineProperty(f,"name",{value:e.name}),f.__tjs=t,f.__tjs.schema=()=>gr(t),f}function Zi(e){let t=new Proxy(e,{construct(n,r,s){return Reflect.construct(n,r,s)},apply(n,r,s){return Reflect.construct(n,s)}});Object.defineProperty(t,"name",{value:e.name});for(let n of Object.getOwnPropertyNames(e))n!=="length"&&n!=="name"&&n!=="prototype"&&Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n));return t}function Qi(){let e={...H},t=e.maxStackSize??Ut,n=new Array(t).fill(""),r=0,s=0,a=e.maxErrors??En,i=new Array(a).fill(null),o=0,u=0,c=0,l=0;function p(R){e={...e,...R}}function f(){return{...e}}function d(R){(e.callStacks||e.debug)&&R&&(n[r]=R,r=(r+1)%t,s<t&&s++)}function m(){(e.callStacks||e.debug)&&s>0&&(r=(r-1+t)%t,s--)}function y(){if(s===0)return[];let R=[],J=(r-s+t)%t;for(let z=0;z<s;z++)R.push(n[(J+z)%t]);return R}function x(){e={...Or},r=0,s=0,o=0,u=0,c=0,l=0}function S(){l++}function v(){l>0&&l--}function b(){return l>0}let _=new Map;function k(R,J,z){_.has(R)||_.set(R,new Map),_.get(R).set(J,z)}function w(R,J){let z=typeof R,ee;if(R==null)return;if(z==="string")ee="String";else if(z==="number")ee="Number";else if(z==="boolean")ee="Boolean";else if(Array.isArray(R))ee="Array";else if(z==="object")ee=R.constructor?.name||"Object";else return;let te=ee;for(;te;){let lt=_.get(te);if(lt?.has(J))return lt.get(J);if(z==="object"&&!Array.isArray(R)){if(te=Object.getPrototypeOf(te===ee?R:Object.getPrototypeOf(R))?.constructor?.name,te==="Object"||te===ee)break}else break}let ce=_.get("Object");if(ce?.has(J))return ce.get(J)}function E(R,J,z){let ee=z===null?"null":typeof z,te=e.callStacks||e.debug?y():void 0,ce=new He(`Expected ${J} for '${R}', got ${ee}`,R,J,ee,te);if(e.trackErrors!==!1&&(i[o]=ce,o=(o+1)%a,u<a&&u++,c++),e.logTypeErrors&&console.error(`[TJS TypeError] ${ce.message}`),e.throwTypeErrors)throw ce;return ce}function $(){if(e.trackErrors===!1||u===0)return[];let R=[],J=(o-u+a)%a;for(let z=0;z<u;z++)R.push(i[(J+z)%a]);return R}function T(){let R=$();return o=0,u=0,c=0,R}function N(){return c}function P(R,J){let z={$error:!0,message:R,...J};if((e.callStacks||e.debug)&&s>0){let ee=J?.path?[...y(),J.path]:y();z.stack=ee}return z}function F(R,J){return R==null?E(`bang.${J}`,"non-null",R):Nr(R)?R:R[J]}return{version:Ve,MonadicError:He,typeError:E,isMonadicError:Nr,bang:F,isError:qe,error:P,composeErrors:Fr,typeOf:_t,isNativeType:Hi,checkType:ot,validateArgs:Lr,wrap:Vr,checkFnShape:Ki,wrapClass:Zi,compareVersions:Rr,versionsCompatible:Mr,createRuntime:Qi,configure:p,getConfig:f,pushStack:d,popStack:m,getStack:y,errors:$,clearErrors:T,getErrorCount:N,resetRuntime:x,enterUnsafe:S,exitUnsafe:v,isUnsafeMode:b,validate:Ne,infer:ye.infer.bind(ye),Type:ie,isRuntimeType:rt,Union:Cr,Generic:Vt,Enum:Ir,FunctionPredicate:Sn,Nullable:Tr,Optional:$r,TArray:Ar,TString:yr,TNumber:br,TBoolean:xr,TInteger:_r,TPositiveInt:wr,TNonEmptyString:Sr,TEmail:vr,TUrl:kr,TUuid:Er,TPair:Pr,TRecord:jr,Is:xt,IsNot:Wi,Eq:Dr,NotEq:Gi,TypeOf:Ji,toBool:zi,tjsEquals:qt,registerExtension:k,resolveExtension:w}}var st={version:Ve,MonadicError:He,typeError:ou,isMonadicError:Nr,isError:qe,error:Re,composeErrors:Fr,typeOf:_t,isNativeType:Hi,checkType:ot,validateArgs:Lr,wrap:Vr,checkFnShape:Ki,wrapClass:Zi,compareVersions:Rr,versionsCompatible:Mr,configure:fu,getConfig:pu,pushStack:qi,popStack:vn,getStack:Br,errors:Ui,clearErrors:hu,getErrorCount:du,resetRuntime:mu,enterUnsafe:uu,exitUnsafe:cu,isUnsafeMode:lu,createRuntime:Qi,validate:Ne,infer:ye.infer.bind(ye),Type:ie,isRuntimeType:rt,Union:Cr,Generic:Vt,Enum:Ir,FunctionPredicate:Sn,Nullable:Tr,Optional:$r,TArray:Ar,TString:yr,TNumber:br,TBoolean:xr,TInteger:_r,TPositiveInt:wr,TNonEmptyString:Sr,TEmail:vr,TUrl:kr,TUuid:Er,Timestamp:Bi,LegalDate:Di,TPair:Pr,TRecord:jr,Is:xt,IsNot:Wi,Eq:Dr,NotEq:Gi,TypeOf:Ji,toBool:zi};function qr(){let e=globalThis;if(e.__tjs){let t=e.__tjs.version;if(typeof t!="string")return e.__tjs=st,st;let n=Rr(Ve,t);return n===0||(Mr(Ve,t)?n>0?(console.info(`TJS runtime: upgrading ${t} \u2192 ${Ve}`),e.__tjs=st):console.info(`TJS runtime: keeping ${t} (newer than ${Ve})`):(console.warn(`TJS runtime version conflict: ${t} vs ${Ve} (major version mismatch)`),n>0&&(console.warn(`Upgrading to ${Ve} - check for breaking changes`),e.__tjs=st))),e.__tjs}return e.__tjs=st,st}function gu(e){return`
|
|
190
190
|
// TJS runtime wrapper (skips unsafe functions)
|
|
191
191
|
if (typeof ${e}.__tjs === 'object' && !${e}.__tjs.unsafe && typeof globalThis.__tjs?.wrap === 'function') {
|
|
192
192
|
${e} = globalThis.__tjs.wrap(${e}, ${e}.__tjs)
|
|
193
193
|
}
|
|
194
|
-
`.trim()}function
|
|
194
|
+
`.trim()}function yu(e,t,n=1e-9){if(e===t)return!0;if(typeof e=="number"&&typeof t=="number"&&(!Number.isInteger(e)||!Number.isInteger(t))){let r=Math.abs(e-t),s=Math.max(Math.abs(e),Math.abs(t),1);return r/s<n}return!1}function Wr(e,t){if(e===t||typeof e=="number"&&typeof t=="number"&&Number.isNaN(e)&&Number.isNaN(t)||yu(e,t))return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>Wr(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>Wr(e[s],t[s]))}function Jr(e,t,n=""){if(t===null)return e===null?{matches:!0}:{matches:!1,error:`Expected null at '${n}', got ${ut(e)}`};if(t===void 0)return e===void 0?{matches:!0}:{matches:!1,error:`Expected undefined at '${n}', got ${ut(e)}`};if(typeof t=="number")return typeof e=="number"?{matches:!0}:{matches:!1,error:`Expected number at '${n}', got ${ut(e)}`};if(typeof t=="string")return typeof e=="string"?{matches:!0}:{matches:!1,error:`Expected string at '${n}', got ${ut(e)}`};if(typeof t=="boolean")return typeof e=="boolean"?{matches:!0}:{matches:!1,error:`Expected boolean at '${n}', got ${ut(e)}`};if(Array.isArray(t)){if(!Array.isArray(e))return{matches:!1,error:`Expected array at '${n}', got ${ut(e)}`};if(t.length===0)return{matches:!0};let r=t[0];for(let s=0;s<e.length;s++){let a=Jr(e[s],r,`${n}[${s}]`);if(!a.matches)return a}return{matches:!0}}if(typeof t=="object"&&t!==null){if(typeof e!="object"||e===null||Array.isArray(e))return{matches:!1,error:`Expected object at '${n}', got ${ut(e)}`};for(let r of Object.keys(t)){let s=n?`${n}.${r}`:r;if(!(r in e))return{matches:!1,error:`Missing property '${s}'`};let a=Jr(e[r],t[r],s);if(!a.matches)return a}return{matches:!0}}return e===t?{matches:!0}:{matches:!1,error:`Type mismatch at '${n}'`}}function ut(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Wt(e,t=0){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":e.length<=3?`[${e.map(n=>Wt(n,t)).join(", ")}]`:`[${e.slice(0,3).map(n=>Wt(n,t)).join(", ")}, ...]`;if(typeof e=="object"){let n=Object.entries(e);if(n.length===0)return"{}";let r=u=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u)?u:JSON.stringify(u);if(n.length<=2)return`{${n.map(([c,l])=>`${r(c)}: ${Wt(l,t)}`).join(", ")}}`;let s=" ".repeat(t+1),a=" ".repeat(t),i=n.slice(0,8).map(([u,c])=>`${s}${r(u)}: ${Wt(c,t+1)}`).join(`,
|
|
195
195
|
`),o=n.length>8?`,
|
|
196
196
|
${s}...`:"";return`{
|
|
197
197
|
${i}${o}
|
|
198
|
-
${a}}`}return String(e)}function
|
|
198
|
+
${a}}`}return String(e)}function bu(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{let r=n.split(`
|
|
199
199
|
`).length-1;return`
|
|
200
|
-
`.repeat(r)});return t=t.replace(/\/\/[^\n]*/g,""),t}function
|
|
201
|
-
`)}function
|
|
202
|
-
`).length;if(l===":!")continue;let f=n.slice(s.index+s[0].length),d=$n(f);if(!d)continue;let m=
|
|
203
|
-
`).length,
|
|
204
|
-
`),f="const { Is, IsNot, Eq, NotEq, TypeOf } = globalThis.__tjs ?? {};",d=e.map((
|
|
205
|
-
// Test ${
|
|
200
|
+
`.repeat(r)});return t=t.replace(/\/\/[^\n]*/g,""),t}function Xi(e){let t=e.replace(/^import\s+.*?from\s+['"][^'"]+['"];?\s*$/gm,"");return t=t.replace(/^import\s+['"][^'"]+['"];?\s*$/gm,""),t=t.replace(/^export\s+default\s+/gm,""),t=t.replace(/^export\s+/gm,""),t=t.replace(/^(\s*)((?:const|let|var)\s+\w+\s*=\s*)?await\s+.+$/gm,"$1/* top-level await removed for test execution */"),t}function xu(e){if(Object.keys(e).length===0)return"";let t=[];for(let[n,r]of Object.entries(e)){let s=Xi(r);t.push(`// Resolved import: ${n}`),t.push(s)}return t.join(`
|
|
201
|
+
`)}function Yi(e){let t={},n=e.trim();if(!n.startsWith("{")||!n.includes("="))try{return{pattern:new Function(`return ${e}`)(),defaults:t}}catch{return null}let r="",s=0,a=0;for(;a<n.length;){let i=n[a];if(i==="{"||i==="["||i==="(")s++,r+=i,a++;else if(i==="}"||i==="]"||i===")")s--,r+=i,a++;else if(i==="'"||i==='"'||i==="`"){let o=i;for(r+=i,a++;a<n.length&&n[a]!==o;)n[a]==="\\"&&(r+=n[a++]),r+=n[a++];a<n.length&&(r+=n[a++])}else if(s===1&&i==="="){let c=(r.slice(r.lastIndexOf("{")+1).split(",").pop()||"").match(/\s*(\w+)\s*$/);if(c){let l=a+1;for(;l<n.length&&/\s/.test(n[l]);)l++;let p="",f=0;for(;l<n.length;){let d=n[l];if(d==="{"||d==="["||d==="(")f++;else if(d==="}"||d==="]"||d===")"){if(f===0)break;f--}else if(d===","&&f===0)break;p+=d,l++}try{t[c[1]]=new Function(`return ${p.trim()}`)()}catch{}r+=":",a++;continue}r+=i,a++}else r+=i,a++}try{return{pattern:new Function(`return ${r}`)(),defaults:t}}catch{return null}}function ea(e){let t=[],n=bu(e),r=/(async\s+)?function\s+(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,s;for(;(s=r.exec(n))!==null;){let o=!!s[1],u=s[2],c=s[3],l=s[4],p=n.slice(0,s.index).split(`
|
|
202
|
+
`).length;if(l===":!")continue;let f=n.slice(s.index+s[0].length),d=$n(f);if(!d)continue;let m=Ur(c);if(!(c.trim()&&m.length===0))try{let y=Yi(d);if(!y)continue;let x=m.map(S=>new Function(`return ${S}`)());t.push({funcName:u,args:x,expected:y.pattern,defaults:Object.keys(y.defaults).length>0?y.defaults:void 0,line:p,isAsync:o})}catch{}}let a=/class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g,i;for(;(i=a.exec(n))!==null;){let o=i[1],u=i.index+i[0].length,c=1,l=u;for(let b=u;b<n.length;b++)if(n[b]==="{")c++;else if(n[b]==="}"&&(c--,c===0)){l=b;break}let p=n.slice(u,l),d=/constructor\s*\(([^)]*)\)/.exec(p);if(!d)continue;let m=d[1],y=Ur(m);if(m.trim()&&y.length===0)continue;let x;try{x=y.map(b=>new Function(`return ${b}`)())}catch{continue}let S=/(async\s+)?(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,v;for(;(v=S.exec(p))!==null;){let b=v[2];if(b==="constructor")continue;let _=!!v[1],k=v[3];if(v[4]===":!")continue;let E=u+v.index,$=n.slice(0,E).split(`
|
|
203
|
+
`).length,T=p.slice(v.index+v[0].length),N=$n(T);if(!N)continue;let P=Ur(k);if(!(k.trim()&&P.length===0))try{let F=Yi(N);if(!F)continue;let R=P.map(J=>new Function(`return ${J}`)());t.push({funcName:b,args:R,expected:F.pattern,defaults:Object.keys(F.defaults).length>0?F.defaults:void 0,line:$,isAsync:_,className:o,constructorArgs:x})}catch{}}}return t}function ta(e,t,n,r,s={},a=new Map){let i=[];if(e.length===0&&n.length===0)return i;let o=r.match(/^import\s+.*?from\s+['"]([^'"]+)['"];?\s*$/gm)||[],u=o.length>0&&o.some(_=>{let k=_.match(/from\s+['"]([^'"]+)['"]/);return k&&!(k[1]in s)}),c=Xi(r),l=xu(s),p=t.map(_=>_.body).join(`
|
|
204
|
+
`),f="const { Is, IsNot, Eq, NotEq, TypeOf } = globalThis.__tjs ?? {};",d=e.map((_,k)=>{let w=a.size>0?Ot(_.body,a):_.body;return`
|
|
205
|
+
// Test ${k}: ${_.description}
|
|
206
206
|
try {
|
|
207
207
|
${f}
|
|
208
208
|
${w}
|
|
209
|
-
__testResults.push({ idx: ${
|
|
209
|
+
__testResults.push({ idx: ${k}, passed: true });
|
|
210
210
|
} catch (e) {
|
|
211
|
-
__testResults.push({ idx: ${
|
|
211
|
+
__testResults.push({ idx: ${k}, passed: false, isRef: e instanceof ReferenceError, error: e.message || String(e) });
|
|
212
212
|
}
|
|
213
213
|
`}).join(`
|
|
214
|
-
`),m=n.filter(
|
|
215
|
-
// Signature test ${
|
|
214
|
+
`),m=n.filter(_=>!_.isAsync),y=n.filter(_=>_.isAsync),x=m.map((_,k)=>{let w=_.className?`${_.className}.${_.funcName}`:_.funcName,E=_.className?`new ${_.className}(${(_.constructorArgs||[]).map($=>JSON.stringify($)).join(", ")}).${_.funcName}(${_.args.map($=>JSON.stringify($)).join(", ")})`:`${_.funcName}(${_.args.map($=>JSON.stringify($)).join(", ")})`;return`
|
|
215
|
+
// Signature test ${k}: ${w}
|
|
216
216
|
try {
|
|
217
|
-
let __actual = ${
|
|
218
|
-
const __expected = ${JSON.stringify(
|
|
219
|
-
const __defaults = ${JSON.stringify(
|
|
217
|
+
let __actual = ${E};
|
|
218
|
+
const __expected = ${JSON.stringify(_.expected)};${_.defaults?`
|
|
219
|
+
const __defaults = ${JSON.stringify(_.defaults)};
|
|
220
220
|
if (typeof __actual === 'object' && __actual !== null) __actual = Object.assign({}, __defaults, __actual);`:""}
|
|
221
221
|
if (__deepEqual(__actual, __expected)) {
|
|
222
|
-
__sigTestResults.push({ idx: ${
|
|
222
|
+
__sigTestResults.push({ idx: ${k}, passed: true });
|
|
223
223
|
} else {
|
|
224
|
-
__sigTestResults.push({ idx: ${
|
|
224
|
+
__sigTestResults.push({ idx: ${k}, passed: false, error: 'Expected ' + __format(__expected) + ' at \\'${w}\\', got ' + __format(__actual) });
|
|
225
225
|
}
|
|
226
226
|
} catch (e) {
|
|
227
227
|
// The function threw on its example inputs \u2014 the example couldn't be
|
|
228
228
|
// *evaluated* (e.g. it calls an atom that doesn't exist at build time).
|
|
229
229
|
// That's inconclusive, not a mismatch. Never block transpilation on it.
|
|
230
|
-
__sigTestResults.push({ idx: ${
|
|
230
|
+
__sigTestResults.push({ idx: ${k}, passed: false, threw: true, error: e.message || String(e) });
|
|
231
231
|
}
|
|
232
232
|
`}).join(`
|
|
233
|
-
`);
|
|
233
|
+
`);qr();let b=`
|
|
234
234
|
|
|
235
235
|
const __saved_tjs = globalThis.__tjs;
|
|
236
236
|
|
|
@@ -314,15 +314,17 @@ ${a}}`}return String(e)}function gu(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{l
|
|
|
314
314
|
globalThis.__tjs = __saved_tjs;
|
|
315
315
|
}
|
|
316
316
|
return { testResults: __testResults, sigTestResults: __sigTestResults };
|
|
317
|
-
`;try{let
|
|
318
|
-
`)}var An={Int8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_s,storeOp:g.i32_store8},Uint8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Uint8ClampedArray:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Int16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_s,storeOp:g.i32_store16},Uint16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_u,storeOp:g.i32_store16},Int32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Uint32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Float32Array:{elementType:"f32",bytesPerElement:4,loadOp:g.f32_load,storeOp:g.f32_store},Float64Array:{elementType:"f64",bytesPerElement:8,loadOp:g.f64_load,storeOp:g.f64_store}};function vu(e,t=new Map){let n={params:e,locals:new Map,nextLocalIndex:e.length,localTypes:[],warnings:[],errors:[],loopDepth:0,needsMathImports:new Set,needsMemory:!1,hasReturn:!1,wat:[],watIndent:1,moduleFunctions:t};return e.forEach((r,s)=>{n.locals.set(r.name,{index:s,type:r.type})}),n}function Cn(e,t,n){if(e.locals.has(t))return e.errors.push(`Duplicate local declaration: ${t}`),e.locals.get(t).index;let r=e.nextLocalIndex++;return e.locals.set(t,{index:r,type:n}),e.localTypes.push(n),r}function ct(e,t){return e.locals.get(t)}function St(e,t){switch(e.type){case"ExpressionStatement":{let n=e.expression;return[...z(n,t),g.drop]}case"ReturnStatement":{let n=e;if(t.hasReturn=!0,!n.argument)return[g.return];let r=z(n.argument,t),s=Y(n.argument,t);return s==="i32"?r.push(g.f64_convert_i32_s):s==="f32"&&r.push(g.f64_promote_f32),r.push(g.return),r}case"VariableDeclaration":{let n=e,r=[];for(let s of n.declarations){if(s.id.type!=="Identifier"){t.errors.push("Destructuring not supported in WASM blocks");continue}let a=s.id.name,i="f64";s.init&&(i=Y(s.init,t));let o=Cn(t,a,i);s.init&&(r.push(...z(s.init,t)),r.push(g.local_set,...B(o)))}return r}case"ForStatement":return ku(e,t);case"IfStatement":return Eu(e,t);case"BlockStatement":{let n=e,r=[];for(let s of n.body)r.push(...St(s,t));return r}default:return t.errors.push(`Unsupported statement type: ${e.type}`),[]}}function ku(e,t){let n=[];return e.init&&(e.init.type==="VariableDeclaration"?n.push(...St(e.init,t)):n.push(...z(e.init,t))),n.push(g.block,$e.void),n.push(g.loop,$e.void),e.test&&(n.push(...z(e.test,t)),n.push(g.i32_eqz),n.push(g.br_if,1)),t.loopDepth++,e.body&&n.push(...St(e.body,t)),t.loopDepth--,e.update&&(n.push(...z(e.update,t)),n.push(g.drop)),n.push(g.br,0),n.push(g.end),n.push(g.end),n}function Eu(e,t){let n=[];return n.push(...z(e.test,t)),n.push(g.if,$e.void),n.push(...St(e.consequent,t)),e.alternate&&(n.push(g.else),n.push(...St(e.alternate,t))),n.push(g.end),n}function Y(e,t){switch(e.type){case"Literal":{let n=e;return typeof n.value=="number"?n.raw&&(n.raw.includes(".")||n.raw.includes("e"))?"f64":Number.isInteger(n.value)&&n.value>=-2147483648&&n.value<=2147483647?"i32":"f64":"f64"}case"Identifier":return ct(t,e.name)?.type??"f64";case"BinaryExpression":case"AssignmentExpression":{let n=e;if(["<",">","<=",">=","==","!=","===","!=="].includes(n.operator)||["|","&","^","<<",">>",">>>"].includes(n.operator))return"i32";let r=Y(n.left,t),s=Y(n.right,t);return r==="v128"||s==="v128"?"v128":r==="f64"||s==="f64"?"f64":r==="f32"||s==="f32"?"f32":"i32"}case"UnaryExpression":{let n=e;return n.operator==="!"?"i32":Y(n.argument,t)}case"MemberExpression":{let n=e;if(n.object.type==="Identifier"&&ct(t,n.object.name)){let s=t.params.find(a=>a.name===n.object.name);if(s?.arrayType){let a=An[s.arrayType];if(a)return a.elementType}}return"f64"}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee;if(r.object.type==="Identifier"&&r.object.name==="Math")return"f64"}if(n.callee.type==="Identifier"){let r=n.callee.name;if(r==="f32x4_extract_lane")return"f32";if(r.startsWith("f32x4_")||r==="v128_load")return"v128";let s=t.moduleFunctions.get(r);if(s)return s.hasReturn?"f64":"i32"}return"f64"}default:return"f64"}}function z(e,t){switch(e.type){case"Literal":{let n=e;if(typeof n.value=="number"){let r=Y(e,t);return r==="i32"?[g.i32_const,...Ht(n.value|0)]:r==="f32"?[g.f32_const,...Ur(n.value)]:[g.f64_const,...ge(n.value)]}return t.errors.push(`Unsupported literal type: ${typeof n.value}`),[g.f64_const,...ge(0)]}case"Identifier":{let n=e.name,r=ct(t,n);return r?[g.local_get,...B(r.index)]:(t.errors.push(`Unknown identifier: ${n}`),[g.f64_const,...ge(0)])}case"BinaryExpression":return Tu(e,t);case"UnaryExpression":return $u(e,t);case"AssignmentExpression":return Cu(e,t);case"UpdateExpression":return Au(e,t);case"MemberExpression":return Pu(e,t);case"CallExpression":return Iu(e,t);case"SequenceExpression":{let n=e,r=[];for(let s=0;s<n.expressions.length;s++)r.push(...z(n.expressions[s],t)),s<n.expressions.length-1&&r.push(g.drop);return r}default:return t.errors.push(`Unsupported expression type: ${e.type}`),[g.f64_const,...ge(0)]}}function Tu(e,t){let n=z(e.left,t),r=z(e.right,t),s=Y(e,t),a=Y(e.left,t),i=Y(e.right,t),o=["<",">","<=",">=","==","===","!=","!=="].includes(e.operator),u;a==="f64"||i==="f64"?u="f64":a==="f32"||i==="f32"?u="f32":u="i32",!o&&s==="f64"&&(u="f64");let c=n,l=r;u==="f64"?(a==="i32"?c=[...n,g.f64_convert_i32_s]:a==="f32"&&(c=[...n,g.f64_promote_f32]),i==="i32"?l=[...r,g.f64_convert_i32_s]:i==="f32"&&(l=[...r,g.f64_promote_f32])):u==="f32"&&(a==="i32"&&(c=[...n,g.f32_convert_i32_s]),i==="i32"&&(l=[...r,g.f32_convert_i32_s]));let f={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div},"%":{i32:g.i32_rem_s},"<":{i32:g.i32_lt_s,f32:g.f32_lt,f64:g.f64_lt},">":{i32:g.i32_gt_s,f32:g.f32_gt,f64:g.f64_gt},"<=":{i32:g.i32_le_s,f32:g.f32_le,f64:g.f64_le},">=":{i32:g.i32_ge_s,f32:g.f32_ge,f64:g.f64_ge},"==":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"===":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"!=":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"!==":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"|":{i32:g.i32_or},"&":{i32:g.i32_and},"^":{i32:g.i32_xor},"<<":{i32:g.i32_shl},">>":{i32:g.i32_shr_s},">>>":{i32:g.i32_shr_u}}[e.operator];if(!f)return t.errors.push(`Unsupported operator: ${e.operator}`),[g.f64_const,...ge(0)];let d=f[u]??f.f64??f.i32;return d===void 0?(t.errors.push(`Operator ${e.operator} not supported for type ${u}`),[g.f64_const,...ge(0)]):[...c,...l,d]}function $u(e,t){let n=z(e.argument,t),r=Y(e.argument,t);switch(e.operator){case"-":return r==="i32"?[g.i32_const,0,...n,g.i32_sub]:r==="f32"?[...n,g.f32_neg]:[...n,g.f64_neg];case"!":return[...n,g.i32_eqz];case"~":return[...n,g.i32_const,...Ht(-1),g.i32_xor];default:return t.errors.push(`Unsupported unary operator: ${e.operator}`),n}}function Cu(e,t){if(e.left.type==="MemberExpression")return ju(e.left,e.right,e.operator,t);if(e.left.type!=="Identifier")return t.errors.push("Assignment target must be identifier or array element"),[];let n=e.left.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[];if(e.operator==="="){s.push(...z(e.right,t));let a=Y(e.right,t);r.type==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):r.type==="f64"&&a==="f32"?s.push(g.f64_promote_f32):r.type==="i32"&&a==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&a==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&a==="i32"?s.push(g.f32_convert_i32_s):r.type==="f32"&&a==="f64"&&s.push(g.f32_demote_f64)}else{let a=Y(e.right,t),i=r.type;a==="f64"||r.type==="f64"?i="f64":(a==="f32"||r.type==="f32")&&(i="f32"),s.push(g.local_get,...B(r.index)),i==="f64"&&r.type==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&r.type==="f32"?s.push(g.f64_promote_f32):i==="f32"&&r.type==="i32"&&s.push(g.f32_convert_i32_s),s.push(...z(e.right,t)),i==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&a==="f32"?s.push(g.f64_promote_f32):i==="f32"&&a==="i32"&&s.push(g.f32_convert_i32_s);let o=e.operator.slice(0,-1),c={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div}}[o]?.[i];if(!c)return t.errors.push(`Unsupported compound assignment: ${e.operator}`),[];s.push(c),r.type==="i32"&&i==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&i==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&i==="f64"&&s.push(g.f32_demote_f64)}return s.push(g.local_tee,...B(r.index)),s}function Au(e,t){if(e.argument.type!=="Identifier")return t.errors.push("Update expression argument must be identifier"),[];let n=e.argument.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[],a=r.type==="i32";return e.prefix?(s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...ge(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_tee,...B(r.index))):(s.push(g.local_get,...B(r.index)),s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...ge(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_set,...B(r.index))),s}function Pu(e,t){if(e.object.type!=="Identifier")return t.errors.push("Array access requires identifier"),[];let n=e.object.name,r=t.params.find(c=>c.name===n);if(!r?.isArray||!r.arrayType)return t.errors.push(`${n} is not a typed array parameter`),[];let s=An[r.arrayType];if(!s)return t.errors.push(`Unknown array type: ${r.arrayType}`),[];t.needsMemory=!0;let a=[],i=ct(t,n);if(!i)return t.errors.push(`Unknown array: ${n}`),[];if(a.push(g.local_get,...B(i.index)),!e.computed||!e.property)return t.errors.push("Array access requires computed index"),[];let o=z(e.property,t),u=Y(e.property,t);return a.push(...o),u==="f64"&&a.push(g.i32_trunc_f64_s),s.bytesPerElement>1&&(a.push(g.i32_const,...Ht(s.bytesPerElement)),a.push(g.i32_mul)),a.push(g.i32_add),a.push(s.loadOp,0,0),a}function ju(e,t,n,r){if(e.object.type!=="Identifier")return r.errors.push("Array store requires identifier"),[];let s=e.object.name,a=r.params.find(m=>m.name===s);if(!a?.isArray||!a.arrayType)return r.errors.push(`${s} is not a typed array parameter`),[];let i=An[a.arrayType];if(!i)return r.errors.push(`Unknown array type: ${a.arrayType}`),[];r.needsMemory=!0;let o=[],u=ct(r,s);if(!u)return[];if(!e.computed||!e.property)return r.errors.push("Array store requires computed index"),[];let c=z(e.property,r),l=Y(e.property,r),p=()=>{let m=[];return m.push(g.local_get,...B(u.index)),m.push(...c),l==="f64"&&m.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(m.push(g.i32_const,...Ht(i.bytesPerElement)),m.push(g.i32_mul)),m.push(g.i32_add),m};if(n==="=")o.push(...z(t,r));else{let m=Cn(r,`__addr_${r.nextLocalIndex}`,"i32");o.push(...p()),o.push(g.local_tee,...B(m)),o.push(i.loadOp,0,0),o.push(...z(t,r));let y=Y(t,r);i.elementType==="f32"&&y==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&y==="f32"?o.push(g.f64_promote_f32):i.elementType==="f32"&&y==="i32"?o.push(g.f32_convert_i32_s):i.elementType==="f64"&&y==="i32"?o.push(g.f64_convert_i32_s):i.elementType==="i32"&&y==="f64"?o.push(g.i32_trunc_f64_s):i.elementType==="i32"&&y==="f32"&&o.push(g.i32_trunc_f32_s);let x=n.slice(0,-1),S={"+":i.elementType==="i32"?g.i32_add:i.elementType==="f32"?g.f32_add:g.f64_add,"-":i.elementType==="i32"?g.i32_sub:i.elementType==="f32"?g.f32_sub:g.f64_sub,"*":i.elementType==="i32"?g.i32_mul:i.elementType==="f32"?g.f32_mul:g.f64_mul};o.push(S[x]??g.f64_add);let E=Cn(r,`__val_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(E)),o.push(g.local_get,...B(m)),o.push(g.local_get,...B(E)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(E)),o}let f=Y(t,r);i.elementType==="f32"&&f==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&f==="f32"?o.push(g.f64_promote_f32):i.elementType==="i32"&&f==="f64"&&o.push(g.i32_trunc_f64_s);let d=Cn(r,`__tmp_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(d)),o.push(g.local_get,...B(u.index)),o.push(...c),l==="f64"&&o.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(o.push(g.i32_const,...Ht(i.bytesPerElement)),o.push(g.i32_mul)),o.push(g.i32_add),o.push(g.local_get,...B(d)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(d)),o}function Iu(e,t){if(e.callee.type==="MemberExpression"){let n=e.callee;if(n.object.type==="Identifier"&&n.object.name==="Math"&&n.property.type==="Identifier"){let r=n.property.name;return Ou(r,e.arguments,t)}}if(e.callee.type==="Identifier"){let n=e.callee.name;if(n.startsWith("f32x4_")||n.startsWith("v128_"))return Mu(n,e.arguments,t);let r=t.moduleFunctions.get(n);if(r)return Nu(r,n,e.arguments,t)}return t.errors.push(`Unsupported function call: ${e.callee.type}`),[g.f64_const,...ge(0)]}function Nu(e,t,n,r){if(n.length!==e.params.length)return r.errors.push(`wasm function ${t} expects ${e.params.length} arguments, got ${n.length}`),[g.f64_const,...ge(0)];let s=[];for(let a=0;a<n.length;a++){let i=n[a],o=e.params[a].type,u=Y(i,r);if(s.push(...z(i,r)),u!==o){let c=Ru(u,o);c===void 0?r.errors.push(`wasm function ${t} param ${a} expects ${o}, got ${u} (no conversion available)`):c!==null&&s.push(c)}}return s.push(g.call,...B(e.index)),e.hasReturn||s.push(g.i32_const,0),s}function Ru(e,t){if(e===t)return null;if(!(e==="v128"||t==="v128")&&!(e==="i64"||t==="i64"))switch(`${e}->${t}`){case"f64->i32":return g.i32_trunc_f64_s;case"f32->i32":return g.i32_trunc_f32_s;case"i32->f64":return g.f64_convert_i32_s;case"i32->f32":return g.f32_convert_i32_s;case"f32->f64":return g.f64_promote_f32;case"f64->f32":return g.f32_demote_f64;default:return}}function Mu(e,t,n){n.needsMemory=!0;let r=[];switch(e){case"v128_load":case"f32x4_load":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...ea(ae.v128_load,2,0)),r}case"v128_store":case"f32x4_store":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...z(t[2],n)),r.push(...ea(ae.v128_store,2,0)),r.push(g.i32_const,0),r}case"f32x4_splat":{r.push(...z(t[0],n));let s=Y(t[0],n);return s==="i32"?r.push(g.f32_convert_i32_s):s==="f64"&&r.push(g.f32_demote_f64),r.push(...qr(ae.f32x4_splat)),r}case"f32x4_extract_lane":{r.push(...z(t[0],n));let s=t[1].value;return!Number.isInteger(s)||s<0||s>3?(n.errors.push(`f32x4_extract_lane: lane must be 0-3, got ${s}`),[g.f32_const,...Ur(0)]):(r.push(Gt,...B(ae.f32x4_extract_lane),s),r)}case"f32x4_replace_lane":{r.push(...z(t[0],n));let s=t[1].value;if(!Number.isInteger(s)||s<0||s>3)return n.errors.push(`f32x4_replace_lane: lane must be 0-3, got ${s}`),[g.f32_const,...Ur(0)];r.push(...z(t[2],n));let a=Y(t[2],n);return a==="i32"?r.push(g.f32_convert_i32_s):a==="f64"&&r.push(g.f32_demote_f64),r.push(Gt,...B(ae.f32x4_replace_lane),s),r}case"f32x4_add":case"f32x4_sub":case"f32x4_mul":case"f32x4_div":{r.push(...z(t[0],n)),r.push(...z(t[1],n));let s={f32x4_add:ae.f32x4_add,f32x4_sub:ae.f32x4_sub,f32x4_mul:ae.f32x4_mul,f32x4_div:ae.f32x4_div};return r.push(...qr(s[e])),r}case"f32x4_neg":case"f32x4_sqrt":{r.push(...z(t[0],n));let s={f32x4_neg:ae.f32x4_neg,f32x4_sqrt:ae.f32x4_sqrt};return r.push(...qr(s[e])),r}default:return n.errors.push(`Unknown SIMD intrinsic: ${e}`),[g.f64_const,...ge(0)]}}function Ou(e,t,n){let r=[];for(let o of t){r.push(...z(o,n));let u=Y(o,n);u==="i32"?r.push(g.f64_convert_i32_s):u==="f32"&&r.push(g.f64_promote_f32)}let a={abs:g.f64_abs,ceil:g.f64_ceil,floor:g.f64_floor,trunc:g.f64_trunc,sqrt:g.f64_sqrt,min:g.f64_min,max:g.f64_max}[e];return a!==void 0?(r.push(a),r):["sin","cos","tan","asin","acos","atan","atan2","exp","log","pow"].includes(e)?(n.needsMathImports.add(e),n.errors.push(`Math.${e} requires JS import (not yet implemented)`),[g.f64_const,...ge(0)]):(n.errors.push(`Unknown Math method: ${e}`),[g.f64_const,...ge(0)])}function ta(e){let t=e.split(":").map(a=>a.trim()),n=t[0];if(t.length===1)return{name:n,type:"f64"};let r=t[1];return An[r]?{name:n,type:"i32",isArray:!0,arrayType:r}:{name:n,type:{i32:"i32",i64:"i64",f32:"f32",f64:"f64",number:"f64",int:"i32"}[r]??"f64"}}function Bu(e,t){let n=e.map(s=>$e[s.type]),r=t?[1,$e.f64]:[0];return[96,...B(e.length),...n,...r]}function Du(e,t){let n=[];if(t.length>0){let a=t[0],i=1;for(let o=1;o<t.length;o++)t[o]===a?i++:(n.push([...B(i),$e[a]]),a=t[o],i=1);n.push([...B(i),$e[a]])}let s=[...[...B(n.length),...n.flat()],...e,g.end];return[...B(s.length),...s]}function Fu(){return zt(Jt.import,[1,...Wr("env"),...Wr("memory"),2,0,1])}function Lu(e,t){if(e.length!==t.length)throw new Error("functions and exportNames length mismatch");let n=[0,97,115,109,1,0,0,0],r=e.map(f=>Bu(f.params,f.hasReturn)),s=zt(Jt.type,[...B(r.length),...r.flat()]),i=e.some(f=>f.needsMemory)?Fu():[],o=zt(Jt.function,[...B(e.length),...e.map((f,d)=>B(d)).flat()]),u=zt(Jt.export,[...B(e.length),...t.map((f,d)=>[...Wr(f),0,...B(d)]).flat()]),c=e.map(f=>Du(f.bodyCode,f.localTypes)),l=zt(Jt.code,[...B(c.length),...c.flat()]),p=[...n,...s];return i.length>0&&p.push(...i),p.push(...o,...u,...l),p}function Vu(e,t=new Map){try{let n=e.captures.map(ta),r;try{let u=`function __wasm__(${n.map(c=>c.name).join(", ")}) { ${e.body} }`;r=je(u,{ecmaVersion:2022})}catch(u){return{success:!1,warnings:[],error:`Parse error: ${u.message}`}}let a=r.body[0].body.body,i=vu(n,t),o=[];for(let u of a)o.push(...St(u,i));return i.errors.length>0?{success:!1,warnings:i.warnings,error:i.errors.join("; ")}:{success:!0,fn:{params:n,bodyCode:o,localTypes:i.localTypes,needsMemory:i.needsMemory,hasReturn:i.hasReturn},wat:Su(o,n,i.localTypes),warnings:i.warnings}}catch(n){return{success:!1,warnings:[],error:n.message}}}function na(e){let t=new Map,n=[];for(let u=0;u<e.length;u++){let c=e[u],l=c.captures.map(ta),p=c.returnType!==void 0;n.push({params:l,hasReturn:p}),c.name&&t.set(c.name,{index:u,params:l,hasReturn:p})}let r=[],s=[],a=[],i=[];for(let u=0;u<e.length;u++){let c=e[u],l=Vu(c,t);if(i.push(...l.warnings),!l.success||!l.fn){r.push({id:c.id,success:!1,error:l.error}),s.push(qu(n[u])),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:!1,wat:`(failed: ${l.error??"unknown error"})`});continue}s.push(l.fn),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:l.fn.needsMemory,wat:l.wat??""}),r.push({id:c.id,success:!0,exportIndex:u})}if(s.length===0)return{bytes:new Uint8Array,results:r,exports:[],needsMemory:!1,warnings:i};let o=Lu(s,a.map(u=>u.exportName));return{bytes:new Uint8Array(o),results:r,exports:a,needsMemory:a.some(u=>u.needsMemory),warnings:i}}function qu(e){let t=e.hasReturn?[g.f64_const,...ge(0)]:[];return{params:e.params,bodyCode:t,localTypes:[],needsMemory:!1,hasReturn:e.hasReturn}}function ra(e){let t=na(e),n=new Map(t.exports.map(l=>[l.id,l])),r=t.results.map(l=>{if(!l.success)return{id:l.id,success:!1,error:l.error};let p=n.get(l.id);return{id:l.id,success:!0,byteLength:t.bytes.length,_exportName:p.exportName}});if(t.exports.length===0)return{code:"",results:r};let s=t.exports.map(l=>{let p=l.wat.split(`
|
|
317
|
+
`;try{let _=new Function("__deepEqual","__format","__typeMatches",b),{testResults:k,sigTestResults:w}=_(Wr,Wt,Jr);for(let E of k){let $=e[E.idx],T=!E.passed&&(E.isRef||u&&E.error&&/is not defined$/.test(E.error));i.push({description:$.description,passed:E.passed,inconclusive:T||void 0,error:E.error,line:$.line})}for(let E of w){let $=m[E.idx],T=!E.passed&&(E.threw||u&&E.error&&/is not defined$/.test(E.error)),N=$.className?`${$.className}.${$.funcName}`:$.funcName;i.push({description:`${N} signature example`,passed:E.passed,inconclusive:T||void 0,error:E.error,isSignatureTest:!0,line:$.line})}}catch(_){let k=`Module could not be executed for testing: ${_.message}`;for(let w of e)i.push({description:w.description,passed:!1,inconclusive:!0,error:k});for(let w of m){let E=w.className?`${w.className}.${w.funcName}`:w.funcName;i.push({description:`${E} signature example`,passed:!1,inconclusive:!0,error:k,isSignatureTest:!0})}}for(let _ of y){let k=_.className?`${_.className}.${_.funcName}`:_.funcName;i.push({description:`${k} signature example`,passed:!0,isSignatureTest:!0,line:_.line})}return i}function $n(e){let t="",n=0,r=!1;for(let a=0;a<e.length;a++){let i=e[a];if(i==="{"||i==="["||i==="("){if(i==="{"&&n===0&&r)break;n++,t+=i,r=!0}else i==="}"||i==="]"||i===")"?(n--,t+=i):/\s/.test(i)?t+=i:(t+=i,r=!0)}return t.trim()||null}function Ur(e){if(!e.trim())return[];let t=[],n=_u(e);for(let r of n){let s=r.trim(),a=s.match(/^\.\.\.(\w+)\s*[:=]\s*(\[.+\])$/);if(a){try{let o=new Function(`return ${a[2]}`)();if(Array.isArray(o))for(let u of o)t.push(JSON.stringify(u))}catch{}continue}if(s.startsWith("..."))continue;let i=s.match(/(?:\(\s*[?!]\s*)?(\w+)\s*[:=]\s*(.+?)(?:\))?$/);if(i)t.push(i[2].trim());else return[]}return t}function _u(e){let t=[],n="",r=0;for(let s of e){if(s==="("||s==="["||s==="{")r++;else if(s===")"||s==="]"||s==="}")r--;else if(s===","&&r===0){t.push(n.trim()),n="";continue}n+=s}return n.trim()&&t.push(n.trim()),t}var $e={i32:127,i64:126,f32:125,f64:124,v128:123,funcref:112,externref:111,void:64},Jt={custom:0,type:1,import:2,function:3,table:4,memory:5,global:6,export:7,start:8,element:9,code:10,data:11},g={unreachable:0,nop:1,block:2,loop:3,if:4,else:5,end:11,br:12,br_if:13,br_table:14,return:15,call:16,call_indirect:17,drop:26,select:27,local_get:32,local_set:33,local_tee:34,global_get:35,global_set:36,i32_load:40,i64_load:41,f32_load:42,f64_load:43,i32_load8_s:44,i32_load8_u:45,i32_load16_s:46,i32_load16_u:47,i32_store:54,i64_store:55,f32_store:56,f64_store:57,i32_store8:58,i32_store16:59,memory_size:63,memory_grow:64,i32_const:65,i64_const:66,f32_const:67,f64_const:68,i32_eqz:69,i32_eq:70,i32_ne:71,i32_lt_s:72,i32_lt_u:73,i32_gt_s:74,i32_gt_u:75,i32_le_s:76,i32_le_u:77,i32_ge_s:78,i32_ge_u:79,i64_eqz:80,i64_eq:81,i64_ne:82,i64_lt_s:83,i64_lt_u:84,i64_gt_s:85,i64_gt_u:86,i64_le_s:87,i64_le_u:88,i64_ge_s:89,i64_ge_u:90,f32_eq:91,f32_ne:92,f32_lt:93,f32_gt:94,f32_le:95,f32_ge:96,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_clz:103,i32_ctz:104,i32_popcnt:105,i32_add:106,i32_sub:107,i32_mul:108,i32_div_s:109,i32_div_u:110,i32_rem_s:111,i32_rem_u:112,i32_and:113,i32_or:114,i32_xor:115,i32_shl:116,i32_shr_s:117,i32_shr_u:118,i32_rotl:119,i32_rotr:120,i64_add:124,i64_sub:125,i64_mul:126,i64_div_s:127,f32_abs:139,f32_neg:140,f32_ceil:141,f32_floor:142,f32_trunc:143,f32_nearest:144,f32_sqrt:145,f32_add:146,f32_sub:147,f32_mul:148,f32_div:149,f32_min:150,f32_max:151,f32_copysign:152,f64_abs:153,f64_neg:154,f64_ceil:155,f64_floor:156,f64_trunc:157,f64_nearest:158,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,f64_copysign:166,i32_wrap_i64:167,i32_trunc_f32_s:168,i32_trunc_f32_u:169,i32_trunc_f64_s:170,i32_trunc_f64_u:171,i64_extend_i32_s:172,i64_extend_i32_u:173,f32_convert_i32_s:178,f32_convert_i32_u:179,f32_convert_i64_s:180,f32_demote_f64:182,f64_convert_i32_s:183,f64_convert_i32_u:184,f64_convert_i64_s:185,f64_promote_f32:187,i32_reinterpret_f32:188,f32_reinterpret_i32:190,f64_reinterpret_i64:191,i32_extend8_s:192,i32_extend16_s:193},wu=Object.fromEntries(Object.entries(g).map(([e,t])=>[t,e.replace(/_/g,".")])),Gt=253,Q={v128_load:0,v128_store:11,v128_const:12,f32x4_splat:19,f32x4_extract_lane:31,f32x4_replace_lane:32,f32x4_neg:225,f32x4_sqrt:227,f32x4_add:228,f32x4_sub:229,f32x4_mul:230,f32x4_div:231,f32x4_min:232,f32x4_max:233,f32x4_eq:65,f32x4_ne:66,f32x4_lt:67,f32x4_gt:68,f32x4_le:69,f32x4_ge:70,v128_bitselect:82},Su=Object.fromEntries(Object.entries(Q).map(([e,t])=>[t,e.replace(/_/g,".")]));function Cn(e){return[Gt,...B(e)]}function na(e,t,n){return[Gt,...B(e),...B(t),...B(n)]}function B(e){let t=[];do{let n=e&127;e>>>=7,e!==0&&(n|=128),t.push(n)}while(e!==0);return t}function Ht(e){let t=[],n=!0;for(;n;){let r=e&127;e>>=7,e===0&&(r&64)===0||e===-1&&(r&64)!==0?n=!1:r|=128,t.push(r)}return t}function zr(e){let t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,[...new Uint8Array(t)]}function he(e){let t=new ArrayBuffer(8);return new Float64Array(t)[0]=e,[...new Uint8Array(t)]}function Gr(e){let t=new TextEncoder().encode(e);return[...B(t.length),...t]}function zt(e,t){return[e,...B(t.length),...t]}function Ke(e,t){let n=0,r=0,s=t;for(;s<e.length;){let a=e[s];if(n|=(a&127)<<r,s++,(a&128)===0)break;r+=7}return[n,s-t]}function vu(e,t){let n=new ArrayBuffer(8),r=new Uint8Array(n);for(let s=0;s<8;s++)r[s]=e[t+s];return new Float64Array(n)[0]}function ku(e,t,n){let r=[],s=1,a=()=>" ".repeat(s),i=t.map((c,l)=>`(param $${c.name} ${c.type})`).join(" "),o=n.map((c,l)=>`(local $L${t.length+l} ${c})`).join(" ");r.push(`(func (export "compute") ${i} (result f64)`),o&&r.push(` ${o}`);let u=0;for(;u<e.length;){let c=e[u],l=wu[c]||`unknown(0x${c.toString(16)})`;if(u++,c===g.local_get||c===g.local_set||c===g.local_tee){let[p,f]=Ke(e,u);u+=f;let d=p<t.length?`$${t[p].name}`:`$L${p}`;r.push(`${a()}${l} ${d}`)}else if(c===g.br||c===g.br_if){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}${l} ${p}`)}else if(c===g.i32_const){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}i32.const ${p}`)}else if(c===g.f32_const){let p=new ArrayBuffer(4),f=new Uint8Array(p);for(let m=0;m<4;m++)f[m]=e[u+m];let d=new Float32Array(p)[0];u+=4,r.push(`${a()}f32.const ${d}`)}else if(c===g.f64_const){let p=vu(e,u);u+=8,r.push(`${a()}f64.const ${p}`)}else if(c===g.block||c===g.loop){let p=e[u];u++,r.push(`${a()}${l}${p===$e.void?"":` (result ${p===$e.f64?"f64":"i32"})`}`),s++}else if(c===g.if){let p=e[u];u++,r.push(`${a()}if${p===$e.void?"":` (result ${p===$e.f64?"f64":"i32"})`}`),s++}else if(c===g.else)s--,r.push(`${a()}else`),s++;else if(c===g.end)s=Math.max(1,s-1),r.push(`${a()}end`);else if(c===g.f64_load||c===g.f64_store||c===g.f32_load||c===g.f32_store||c===g.i32_load||c===g.i32_store){let[p,f]=Ke(e,u);u+=f;let[d,m]=Ke(e,u);u+=m,r.push(`${a()}${l}${d?` offset=${d}`:""}`)}else if(c===Gt){let[p,f]=Ke(e,u);u+=f;let d=Su[p]||`simd.unknown(0x${p.toString(16)})`;if(p===Q.v128_load||p===Q.v128_store){let[m,y]=Ke(e,u);u+=y;let[x,S]=Ke(e,u);u+=S,r.push(`${a()}${d}${x?` offset=${x}`:""}`)}else if(p===Q.v128_const){let m=e.slice(u,u+16);u+=16,r.push(`${a()}v128.const ${m.map(y=>"0x"+y.toString(16).padStart(2,"0")).join(" ")}`)}else if(p===Q.f32x4_extract_lane||p===Q.f32x4_replace_lane){let m=e[u];u++,r.push(`${a()}${d} ${m}`)}else r.push(`${a()}${d}`)}else r.push(`${a()}${l}`)}return r.push(")"),r.join(`
|
|
318
|
+
`)}var Pn={Int8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_s,storeOp:g.i32_store8},Uint8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Uint8ClampedArray:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Int16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_s,storeOp:g.i32_store16},Uint16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_u,storeOp:g.i32_store16},Int32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Uint32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Float32Array:{elementType:"f32",bytesPerElement:4,loadOp:g.f32_load,storeOp:g.f32_store},Float64Array:{elementType:"f64",bytesPerElement:8,loadOp:g.f64_load,storeOp:g.f64_store}};function Eu(e,t=new Map){let n={params:e,locals:new Map,nextLocalIndex:e.length,localTypes:[],warnings:[],errors:[],loopDepth:0,needsMathImports:new Set,needsMemory:!1,hasReturn:!1,wat:[],watIndent:1,moduleFunctions:t};return e.forEach((r,s)=>{n.locals.set(r.name,{index:s,type:r.type})}),n}function An(e,t,n){if(e.locals.has(t))return e.errors.push(`Duplicate local declaration: ${t}`),e.locals.get(t).index;let r=e.nextLocalIndex++;return e.locals.set(t,{index:r,type:n}),e.localTypes.push(n),r}function ct(e,t){return e.locals.get(t)}function St(e,t){switch(e.type){case"ExpressionStatement":{let n=e.expression;return[...U(n,t),g.drop]}case"ReturnStatement":{let n=e;if(t.hasReturn=!0,!n.argument)return[g.return];let r=U(n.argument,t),s=X(n.argument,t);return s==="i32"?r.push(g.f64_convert_i32_s):s==="f32"&&r.push(g.f64_promote_f32),r.push(g.return),r}case"VariableDeclaration":{let n=e,r=[];for(let s of n.declarations){if(s.id.type!=="Identifier"){t.errors.push("Destructuring not supported in WASM blocks");continue}let a=s.id.name,i="f64";s.init&&(i=X(s.init,t));let o=An(t,a,i);s.init&&(r.push(...U(s.init,t)),r.push(g.local_set,...B(o)))}return r}case"ForStatement":return Tu(e,t);case"IfStatement":return $u(e,t);case"BlockStatement":{let n=e,r=[];for(let s of n.body)r.push(...St(s,t));return r}default:return t.errors.push(`Unsupported statement type: ${e.type}`),[]}}function Tu(e,t){let n=[];return e.init&&(e.init.type==="VariableDeclaration"?n.push(...St(e.init,t)):n.push(...U(e.init,t))),n.push(g.block,$e.void),n.push(g.loop,$e.void),e.test&&(n.push(...U(e.test,t)),n.push(g.i32_eqz),n.push(g.br_if,1)),t.loopDepth++,e.body&&n.push(...St(e.body,t)),t.loopDepth--,e.update&&(n.push(...U(e.update,t)),n.push(g.drop)),n.push(g.br,0),n.push(g.end),n.push(g.end),n}function $u(e,t){let n=[];return n.push(...U(e.test,t)),n.push(g.if,$e.void),n.push(...St(e.consequent,t)),e.alternate&&(n.push(g.else),n.push(...St(e.alternate,t))),n.push(g.end),n}function X(e,t){switch(e.type){case"Literal":{let n=e;return typeof n.value=="number"?n.raw&&(n.raw.includes(".")||n.raw.includes("e"))?"f64":Number.isInteger(n.value)&&n.value>=-2147483648&&n.value<=2147483647?"i32":"f64":"f64"}case"Identifier":return ct(t,e.name)?.type??"f64";case"BinaryExpression":case"AssignmentExpression":{let n=e;if(["<",">","<=",">=","==","!=","===","!=="].includes(n.operator)||["|","&","^","<<",">>",">>>"].includes(n.operator))return"i32";let r=X(n.left,t),s=X(n.right,t);return r==="v128"||s==="v128"?"v128":r==="f64"||s==="f64"?"f64":r==="f32"||s==="f32"?"f32":"i32"}case"UnaryExpression":{let n=e;return n.operator==="!"?"i32":X(n.argument,t)}case"MemberExpression":{let n=e;if(n.object.type==="Identifier"&&ct(t,n.object.name)){let s=t.params.find(a=>a.name===n.object.name);if(s?.arrayType){let a=Pn[s.arrayType];if(a)return a.elementType}}return"f64"}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee;if(r.object.type==="Identifier"&&r.object.name==="Math")return"f64"}if(n.callee.type==="Identifier"){let r=n.callee.name;if(r==="f32x4_extract_lane")return"f32";if(r.startsWith("f32x4_")||r==="v128_load")return"v128";let s=t.moduleFunctions.get(r);if(s)return s.hasReturn?"f64":"i32"}return"f64"}default:return"f64"}}function U(e,t){switch(e.type){case"Literal":{let n=e;if(typeof n.value=="number"){let r=X(e,t);return r==="i32"?[g.i32_const,...Ht(n.value|0)]:r==="f32"?[g.f32_const,...zr(n.value)]:[g.f64_const,...he(n.value)]}return t.errors.push(`Unsupported literal type: ${typeof n.value}`),[g.f64_const,...he(0)]}case"Identifier":{let n=e.name,r=ct(t,n);return r?[g.local_get,...B(r.index)]:(t.errors.push(`Unknown identifier: ${n}`),[g.f64_const,...he(0)])}case"BinaryExpression":return Cu(e,t);case"UnaryExpression":return Au(e,t);case"AssignmentExpression":return Pu(e,t);case"UpdateExpression":return ju(e,t);case"MemberExpression":return Iu(e,t);case"CallExpression":return Ru(e,t);case"SequenceExpression":{let n=e,r=[];for(let s=0;s<n.expressions.length;s++)r.push(...U(n.expressions[s],t)),s<n.expressions.length-1&&r.push(g.drop);return r}default:return t.errors.push(`Unsupported expression type: ${e.type}`),[g.f64_const,...he(0)]}}function Cu(e,t){let n=U(e.left,t),r=U(e.right,t),s=X(e,t),a=X(e.left,t),i=X(e.right,t),o=["<",">","<=",">=","==","===","!=","!=="].includes(e.operator),u;a==="f64"||i==="f64"?u="f64":a==="f32"||i==="f32"?u="f32":u="i32",!o&&s==="f64"&&(u="f64");let c=n,l=r;u==="f64"?(a==="i32"?c=[...n,g.f64_convert_i32_s]:a==="f32"&&(c=[...n,g.f64_promote_f32]),i==="i32"?l=[...r,g.f64_convert_i32_s]:i==="f32"&&(l=[...r,g.f64_promote_f32])):u==="f32"&&(a==="i32"&&(c=[...n,g.f32_convert_i32_s]),i==="i32"&&(l=[...r,g.f32_convert_i32_s]));let f={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div},"%":{i32:g.i32_rem_s},"<":{i32:g.i32_lt_s,f32:g.f32_lt,f64:g.f64_lt},">":{i32:g.i32_gt_s,f32:g.f32_gt,f64:g.f64_gt},"<=":{i32:g.i32_le_s,f32:g.f32_le,f64:g.f64_le},">=":{i32:g.i32_ge_s,f32:g.f32_ge,f64:g.f64_ge},"==":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"===":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"!=":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"!==":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"|":{i32:g.i32_or},"&":{i32:g.i32_and},"^":{i32:g.i32_xor},"<<":{i32:g.i32_shl},">>":{i32:g.i32_shr_s},">>>":{i32:g.i32_shr_u}}[e.operator];if(!f)return t.errors.push(`Unsupported operator: ${e.operator}`),[g.f64_const,...he(0)];let d=f[u]??f.f64??f.i32;if(d===void 0)return t.errors.push(`Operator ${e.operator} not supported for type ${u}`),[g.f64_const,...he(0)];if(e.operator==="/"&&u==="i32"){let m="integer division: '/' with two i32 operands truncates (result coerces to f64 only at the next operator). Add `+ 0.0` to an operand to force f64 division.";t.warnings.includes(m)||t.warnings.push(m)}return[...c,...l,d]}function Au(e,t){let n=U(e.argument,t),r=X(e.argument,t);switch(e.operator){case"-":return r==="i32"?[g.i32_const,0,...n,g.i32_sub]:r==="f32"?[...n,g.f32_neg]:[...n,g.f64_neg];case"!":return[...n,g.i32_eqz];case"~":return[...n,g.i32_const,...Ht(-1),g.i32_xor];default:return t.errors.push(`Unsupported unary operator: ${e.operator}`),n}}function Pu(e,t){if(e.left.type==="MemberExpression")return Nu(e.left,e.right,e.operator,t);if(e.left.type!=="Identifier")return t.errors.push("Assignment target must be identifier or array element"),[];let n=e.left.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[];if(e.operator==="="){s.push(...U(e.right,t));let a=X(e.right,t);r.type==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):r.type==="f64"&&a==="f32"?s.push(g.f64_promote_f32):r.type==="i32"&&a==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&a==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&a==="i32"?s.push(g.f32_convert_i32_s):r.type==="f32"&&a==="f64"&&s.push(g.f32_demote_f64)}else{let a=X(e.right,t),i=r.type;a==="f64"||r.type==="f64"?i="f64":(a==="f32"||r.type==="f32")&&(i="f32"),s.push(g.local_get,...B(r.index)),i==="f64"&&r.type==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&r.type==="f32"?s.push(g.f64_promote_f32):i==="f32"&&r.type==="i32"&&s.push(g.f32_convert_i32_s),s.push(...U(e.right,t)),i==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&a==="f32"?s.push(g.f64_promote_f32):i==="f32"&&a==="i32"&&s.push(g.f32_convert_i32_s);let o=e.operator.slice(0,-1),c={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div}}[o]?.[i];if(!c)return t.errors.push(`Unsupported compound assignment: ${e.operator}`),[];s.push(c),r.type==="i32"&&i==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&i==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&i==="f64"&&s.push(g.f32_demote_f64)}return s.push(g.local_tee,...B(r.index)),s}function ju(e,t){if(e.argument.type!=="Identifier")return t.errors.push("Update expression argument must be identifier"),[];let n=e.argument.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[],a=r.type==="i32";return e.prefix?(s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...he(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_tee,...B(r.index))):(s.push(g.local_get,...B(r.index)),s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...he(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_set,...B(r.index))),s}function Iu(e,t){if(e.object.type!=="Identifier")return t.errors.push("Array access requires identifier"),[];let n=e.object.name,r=t.params.find(c=>c.name===n);if(!r?.isArray||!r.arrayType)return t.errors.push(`${n} is not a typed array parameter`),[];let s=Pn[r.arrayType];if(!s)return t.errors.push(`Unknown array type: ${r.arrayType}`),[];t.needsMemory=!0;let a=[],i=ct(t,n);if(!i)return t.errors.push(`Unknown array: ${n}`),[];if(a.push(g.local_get,...B(i.index)),!e.computed||!e.property)return t.errors.push("Array access requires computed index"),[];let o=U(e.property,t),u=X(e.property,t);return a.push(...o),u==="f64"&&a.push(g.i32_trunc_f64_s),s.bytesPerElement>1&&(a.push(g.i32_const,...Ht(s.bytesPerElement)),a.push(g.i32_mul)),a.push(g.i32_add),a.push(s.loadOp,0,0),a}function Nu(e,t,n,r){if(e.object.type!=="Identifier")return r.errors.push("Array store requires identifier"),[];let s=e.object.name,a=r.params.find(m=>m.name===s);if(!a?.isArray||!a.arrayType)return r.errors.push(`${s} is not a typed array parameter`),[];let i=Pn[a.arrayType];if(!i)return r.errors.push(`Unknown array type: ${a.arrayType}`),[];r.needsMemory=!0;let o=[],u=ct(r,s);if(!u)return[];if(!e.computed||!e.property)return r.errors.push("Array store requires computed index"),[];let c=U(e.property,r),l=X(e.property,r),p=()=>{let m=[];return m.push(g.local_get,...B(u.index)),m.push(...c),l==="f64"&&m.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(m.push(g.i32_const,...Ht(i.bytesPerElement)),m.push(g.i32_mul)),m.push(g.i32_add),m};if(n==="=")o.push(...U(t,r));else{let m=An(r,`__addr_${r.nextLocalIndex}`,"i32");o.push(...p()),o.push(g.local_tee,...B(m)),o.push(i.loadOp,0,0),o.push(...U(t,r));let y=X(t,r);i.elementType==="f32"&&y==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&y==="f32"?o.push(g.f64_promote_f32):i.elementType==="f32"&&y==="i32"?o.push(g.f32_convert_i32_s):i.elementType==="f64"&&y==="i32"?o.push(g.f64_convert_i32_s):i.elementType==="i32"&&y==="f64"?o.push(g.i32_trunc_f64_s):i.elementType==="i32"&&y==="f32"&&o.push(g.i32_trunc_f32_s);let x=n.slice(0,-1),S={"+":i.elementType==="i32"?g.i32_add:i.elementType==="f32"?g.f32_add:g.f64_add,"-":i.elementType==="i32"?g.i32_sub:i.elementType==="f32"?g.f32_sub:g.f64_sub,"*":i.elementType==="i32"?g.i32_mul:i.elementType==="f32"?g.f32_mul:g.f64_mul};o.push(S[x]??g.f64_add);let v=An(r,`__val_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(v)),o.push(g.local_get,...B(m)),o.push(g.local_get,...B(v)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(v)),o}let f=X(t,r);i.elementType==="f32"&&f==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&f==="f32"?o.push(g.f64_promote_f32):i.elementType==="i32"&&f==="f64"&&o.push(g.i32_trunc_f64_s);let d=An(r,`__tmp_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(d)),o.push(g.local_get,...B(u.index)),o.push(...c),l==="f64"&&o.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(o.push(g.i32_const,...Ht(i.bytesPerElement)),o.push(g.i32_mul)),o.push(g.i32_add),o.push(g.local_get,...B(d)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(d)),o}function Ru(e,t){if(e.callee.type==="MemberExpression"){let n=e.callee;if(n.object.type==="Identifier"&&n.object.name==="Math"&&n.property.type==="Identifier"){let r=n.property.name;return Du(r,e.arguments,t)}}if(e.callee.type==="Identifier"){let n=e.callee.name;if(n.startsWith("f32x4_")||n.startsWith("v128_"))return Bu(n,e.arguments,t);let r=t.moduleFunctions.get(n);if(r)return Mu(r,n,e.arguments,t)}return t.errors.push(`Unsupported function call: ${e.callee.type}`),[g.f64_const,...he(0)]}function Mu(e,t,n,r){if(n.length!==e.params.length)return r.errors.push(`wasm function ${t} expects ${e.params.length} arguments, got ${n.length}`),[g.f64_const,...he(0)];let s=[];for(let a=0;a<n.length;a++){let i=n[a],o=e.params[a].type,u=X(i,r);if(s.push(...U(i,r)),u!==o){let c=Ou(u,o);c===void 0?r.errors.push(`wasm function ${t} param ${a} expects ${o}, got ${u} (no conversion available)`):c!==null&&s.push(c)}}return s.push(g.call,...B(e.index)),e.hasReturn||s.push(g.i32_const,0),s}function Ou(e,t){if(e===t)return null;if(!(e==="v128"||t==="v128")&&!(e==="i64"||t==="i64"))switch(`${e}->${t}`){case"f64->i32":return g.i32_trunc_f64_s;case"f32->i32":return g.i32_trunc_f32_s;case"i32->f64":return g.f64_convert_i32_s;case"i32->f32":return g.f32_convert_i32_s;case"f32->f64":return g.f64_promote_f32;case"f64->f32":return g.f32_demote_f64;default:return}}function Bu(e,t,n){n.needsMemory=!0;let r=[];switch(e){case"v128_load":case"f32x4_load":{r.push(...U(t[0],n)),X(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...U(t[1],n));let a=X(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...na(Q.v128_load,2,0)),r}case"v128_store":case"f32x4_store":{r.push(...U(t[0],n)),X(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...U(t[1],n));let a=X(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...U(t[2],n)),r.push(...na(Q.v128_store,2,0)),r.push(g.i32_const,0),r}case"f32x4_splat":{r.push(...U(t[0],n));let s=X(t[0],n);return s==="i32"?r.push(g.f32_convert_i32_s):s==="f64"&&r.push(g.f32_demote_f64),r.push(...Cn(Q.f32x4_splat)),r}case"f32x4_extract_lane":{r.push(...U(t[0],n));let s=t[1].value;return!Number.isInteger(s)||s<0||s>3?(n.errors.push(`f32x4_extract_lane: lane must be 0-3, got ${s}`),[g.f32_const,...zr(0)]):(r.push(Gt,...B(Q.f32x4_extract_lane),s),r)}case"f32x4_replace_lane":{r.push(...U(t[0],n));let s=t[1].value;if(!Number.isInteger(s)||s<0||s>3)return n.errors.push(`f32x4_replace_lane: lane must be 0-3, got ${s}`),[g.f32_const,...zr(0)];r.push(...U(t[2],n));let a=X(t[2],n);return a==="i32"?r.push(g.f32_convert_i32_s):a==="f64"&&r.push(g.f32_demote_f64),r.push(Gt,...B(Q.f32x4_replace_lane),s),r}case"f32x4_add":case"f32x4_sub":case"f32x4_mul":case"f32x4_div":case"f32x4_min":case"f32x4_max":case"f32x4_eq":case"f32x4_ne":case"f32x4_lt":case"f32x4_gt":case"f32x4_le":case"f32x4_ge":{r.push(...U(t[0],n)),r.push(...U(t[1],n));let s={f32x4_add:Q.f32x4_add,f32x4_sub:Q.f32x4_sub,f32x4_mul:Q.f32x4_mul,f32x4_div:Q.f32x4_div,f32x4_min:Q.f32x4_min,f32x4_max:Q.f32x4_max,f32x4_eq:Q.f32x4_eq,f32x4_ne:Q.f32x4_ne,f32x4_lt:Q.f32x4_lt,f32x4_gt:Q.f32x4_gt,f32x4_le:Q.f32x4_le,f32x4_ge:Q.f32x4_ge};return r.push(...Cn(s[e])),r}case"f32x4_select":return t.length!==3?(n.errors.push(`f32x4_select expects (mask, a, b) \u2014 3 args, got ${t.length}`),[g.f64_const,...he(0)]):(r.push(...U(t[1],n)),r.push(...U(t[2],n)),r.push(...U(t[0],n)),r.push(...Cn(Q.v128_bitselect)),r);case"f32x4_neg":case"f32x4_sqrt":{r.push(...U(t[0],n));let s={f32x4_neg:Q.f32x4_neg,f32x4_sqrt:Q.f32x4_sqrt};return r.push(...Cn(s[e])),r}default:return n.errors.push(`Unknown SIMD intrinsic: ${e}`),[g.f64_const,...he(0)]}}function Du(e,t,n){let r=[];for(let o of t){r.push(...U(o,n));let u=X(o,n);u==="i32"?r.push(g.f64_convert_i32_s):u==="f32"&&r.push(g.f64_promote_f32)}let a={abs:g.f64_abs,ceil:g.f64_ceil,floor:g.f64_floor,trunc:g.f64_trunc,sqrt:g.f64_sqrt,min:g.f64_min,max:g.f64_max}[e];return a!==void 0?(r.push(a),r):["sin","cos","tan","asin","acos","atan","atan2","exp","log","pow"].includes(e)?(n.needsMathImports.add(e),n.errors.push(`Math.${e} requires JS import (not yet implemented)`),[g.f64_const,...he(0)]):(n.errors.push(`Unknown Math method: ${e}`),[g.f64_const,...he(0)])}function ra(e){let t=e.split(":").map(a=>a.trim()),n=t[0];if(t.length===1)return{name:n,type:"f64"};let r=t[1];return Pn[r]?{name:n,type:"i32",isArray:!0,arrayType:r}:{name:n,type:{i32:"i32",i64:"i64",f32:"f32",f64:"f64",number:"f64",int:"i32"}[r]??"f64"}}function Fu(e,t){let n=e.map(s=>$e[s.type]),r=t?[1,$e.f64]:[0];return[96,...B(e.length),...n,...r]}function Lu(e,t){let n=[];if(t.length>0){let a=t[0],i=1;for(let o=1;o<t.length;o++)t[o]===a?i++:(n.push([...B(i),$e[a]]),a=t[o],i=1);n.push([...B(i),$e[a]])}let s=[...[...B(n.length),...n.flat()],...e,g.end];return[...B(s.length),...s]}function Vu(){return zt(Jt.import,[1,...Gr("env"),...Gr("memory"),2,0,1])}function qu(e,t){if(e.length!==t.length)throw new Error("functions and exportNames length mismatch");let n=[0,97,115,109,1,0,0,0],r=e.map(f=>Fu(f.params,f.hasReturn)),s=zt(Jt.type,[...B(r.length),...r.flat()]),i=e.some(f=>f.needsMemory)?Vu():[],o=zt(Jt.function,[...B(e.length),...e.map((f,d)=>B(d)).flat()]),u=zt(Jt.export,[...B(e.length),...t.map((f,d)=>[...Gr(f),0,...B(d)]).flat()]),c=e.map(f=>Lu(f.bodyCode,f.localTypes)),l=zt(Jt.code,[...B(c.length),...c.flat()]),p=[...n,...s];return i.length>0&&p.push(...i),p.push(...o,...u,...l),p}function Uu(e,t=new Map){try{let n=e.captures.map(ra),r;try{let u=`function __wasm__(${n.map(c=>c.name).join(", ")}) { ${e.body} }`;r=je(u,{ecmaVersion:2022})}catch(u){return{success:!1,warnings:[],error:`Parse error: ${u.message}`}}let a=r.body[0].body.body,i=Eu(n,t),o=[];for(let u of a)o.push(...St(u,i));return i.errors.length>0?{success:!1,warnings:i.warnings,error:i.errors.join("; ")}:{success:!0,fn:{params:n,bodyCode:o,localTypes:i.localTypes,needsMemory:i.needsMemory,hasReturn:i.hasReturn},wat:ku(o,n,i.localTypes),warnings:i.warnings}}catch(n){return{success:!1,warnings:[],error:n.message}}}function sa(e){let t=new Map,n=[];for(let u=0;u<e.length;u++){let c=e[u],l=c.captures.map(ra),p=c.returnType!==void 0;n.push({params:l,hasReturn:p}),c.name&&t.set(c.name,{index:u,params:l,hasReturn:p})}let r=[],s=[],a=[],i=[];for(let u=0;u<e.length;u++){let c=e[u],l=Uu(c,t);if(i.push(...l.warnings),!l.success||!l.fn){r.push({id:c.id,success:!1,error:l.error}),s.push(Wu(n[u])),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:!1,wat:`(failed: ${l.error??"unknown error"})`});continue}s.push(l.fn),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:l.fn.needsMemory,wat:l.wat??""}),r.push({id:c.id,success:!0,exportIndex:u})}if(s.length===0)return{bytes:new Uint8Array,results:r,exports:[],needsMemory:!1,warnings:i};let o=qu(s,a.map(u=>u.exportName));return{bytes:new Uint8Array(o),results:r,exports:a,needsMemory:a.some(u=>u.needsMemory),warnings:i}}function Wu(e){let t=e.hasReturn?[g.f64_const,...he(0)]:[];return{params:e.params,bodyCode:t,localTypes:[],needsMemory:!1,hasReturn:e.hasReturn}}function ia(e){let t=sa(e),n=new Map(t.exports.map(l=>[l.id,l])),r=t.results.map(l=>{if(!l.success)return{id:l.id,success:!1,error:l.error};let p=n.get(l.id);return{id:l.id,success:!0,byteLength:t.bytes.length,_exportName:p.exportName}});if(t.exports.length===0)return{code:"",results:r,warnings:t.warnings};let s=t.exports.map(l=>{let p=l.wat.split(`
|
|
319
319
|
`).map(f=>` * ${f}`);return`/**
|
|
320
320
|
* WASM: ${l.id} (export: ${l.exportName})
|
|
321
321
|
${p.join(`
|
|
322
322
|
`)}
|
|
323
323
|
*/`}).join(`
|
|
324
324
|
`),a=t.exports.map(l=>`{id:${JSON.stringify(l.id)},n:${JSON.stringify(l.exportName)},c:${JSON.stringify(l.captures)},m:${l.needsMemory}}`).join(","),i=btoa(String.fromCharCode(...t.bytes)),o=t.needsMemory,u=`${s}
|
|
325
|
-
;(
|
|
325
|
+
;(globalThis.__tjs_wasm_pending??=[]);
|
|
326
|
+
globalThis.__tjs_wasm_ready??=(()=>Promise.all(globalThis.__tjs_wasm_pending));
|
|
327
|
+
globalThis.__tjs_wasm_pending.push((async()=>{
|
|
326
328
|
const __wasmExports=[${a}];
|
|
327
329
|
const __wasmModuleB64=${JSON.stringify(i)};
|
|
328
330
|
const __b64ToBytes=s=>{const b=atob(s),a=new Uint8Array(b.length);for(let i=0;i<b.length;i++)a[i]=b.charCodeAt(i);return a};
|
|
@@ -349,32 +351,34 @@ for(const{id,n,c,m}of __wasmExports){
|
|
|
349
351
|
if(a.buffer===__wasmMem.buffer) continue;
|
|
350
352
|
const ab=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);off=(off+15)&~15;ab.set(mv.slice(off,off+ab.length));off+=ab.length}}
|
|
351
353
|
return r};
|
|
352
|
-
}})();
|
|
353
|
-
`.trim(),c=r.map(({_exportName:l,...p})=>p);return{code:u,results:c}}function
|
|
354
|
-
`),suffix:"__tjs.popStack();"})}let i=Object.entries(t.params);if(i.length===0)return null;for(let[o]of i)r.push(`if (${o} instanceof Error) return ${o};`);for(let[o,u]of i){let c=`${s}${e}.${o}`;u.type.kind==="array"&&r.push(`if (Array.isArray(${o})) { for (const __i of ${o}) { if (__i instanceof Error && __i.path !== undefined) return __i } }`);let l=
|
|
355
|
-
`),suffix:"__tjs.popStack();"})}function
|
|
356
|
-
${
|
|
354
|
+
}})().catch(()=>{}));
|
|
355
|
+
`.trim(),c=r.map(({_exportName:l,...p})=>p);return{code:u,results:c,warnings:t.warnings}}function Kr(e,t){let n=[];function r(a){n.push({start:a.start,end:a.end,newText:`__tjs.toBool(${de(a,t)})`})}function s(a){if(!(!a||typeof a!="object"||!("type"in a))){switch(a.type){case"IfStatement":case"WhileStatement":case"DoWhileStatement":{let i=a;r(i.test),i.consequent&&s(i.consequent),i.alternate&&s(i.alternate),i.body&&s(i.body);return}case"ForStatement":{let i=a;i.init&&s(i.init),i.test&&r(i.test),i.update&&s(i.update),i.body&&s(i.body);return}case"ConditionalExpression":{let i=a;n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${de(i.test,t)})?(${de(i.consequent,t)}):(${de(i.alternate,t)})`});return}case"LogicalExpression":{let i=a;if(i.operator==="&&"||i.operator==="||"){n.push({start:i.start,end:i.end,newText:de(a,t)});return}break}case"UnaryExpression":{let i=a;if(i.operator==="!"){n.push({start:i.start,end:i.end,newText:`!__tjs.toBool(${de(i.argument,t)})`});return}break}case"CallExpression":{let i=a;if(i.callee&&i.callee.type==="Identifier"&&i.callee.name==="Boolean"&&i.arguments.length===1&&i.arguments[0].type!=="SpreadElement"){n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${de(i.arguments[0],t)})`});return}break}}Ju(a,s)}}return s(e),zu(n)}function de(e,t){if(!e)return"";switch(e.type){case"LogicalExpression":{let n=e,r=de(n.left,t),s=de(n.right,t);return n.operator==="&&"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?(${s}):__tjs__t)(${r})`:n.operator==="||"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?__tjs__t:(${s}))(${r})`:`(${r})??(${s})`}case"ConditionalExpression":{let n=e;return`__tjs.toBool(${de(n.test,t)})?(${de(n.consequent,t)}):(${de(n.alternate,t)})`}case"UnaryExpression":{let n=e;return n.operator==="!"?`!__tjs.toBool(${de(n.argument,t)})`:Hr(e,t)}case"CallExpression":{let n=e;return n.callee&&n.callee.type==="Identifier"&&n.callee.name==="Boolean"&&n.arguments.length===1&&n.arguments[0].type!=="SpreadElement"?`__tjs.toBool(${de(n.arguments[0],t)})`:Hr(e,t)}}return Hr(e,t)}function Hr(e,t){let n=e.start,r=e.end;if(typeof n!="number"||typeof r!="number")return"";let s=aa(e);if(s.length===0)return t.slice(n,r);s.sort((o,u)=>o.start-u.start);let a="",i=n;for(let o of s)o.start<i||(o.start>i&&(a+=t.slice(i,o.start)),a+=de(o,t),i=o.end);return i<r&&(a+=t.slice(i,r)),a}function Ju(e,t){for(let n of aa(e))t(n)}function aa(e){let t=[];for(let n in e){if(n==="type"||n==="start"||n==="end"||n==="loc")continue;let r=e[n];if(Array.isArray(r))for(let s of r)s&&typeof s=="object"&&typeof s.type=="string"&&t.push(s);else r&&typeof r=="object"&&typeof r.type=="string"&&t.push(r)}return t}function zu(e){let t=[...e].sort((s,a)=>s.start-a.start||a.end-s.end),n=[],r=-1;for(let s of t)s.start>=r&&(n.push(s),r=s.end);return n}function Zr(e){let t;try{t=je(`function __wrap__(){${e}}`,{ecmaVersion:2022,sourceType:"module",locations:!1})}catch{return e}let n=`function __wrap__(){${e}}`,r=Kr(t,n);if(r.length===0)return e;r.sort((o,u)=>u.start-o.start);let s=n;for(let o of r)s=s.slice(0,o.start)+o.newText+s.slice(o.end);return s.slice("function __wrap__(){".length,s.length-"}".length)}function Gu(e,t,n){if(!e||!t)return!1;let r=new RegExp(`function\\s+${t}\\s*\\([^)]*?\\b${n}\\s*([=:])`,"s"),s=e.match(r);return s?s[1]===":":!1}function Hu(e,t,n,r,s){let a=[],i=Dt(t,e),o={},u=!1,c,l;if(e.params.length===1&&(e.params[0].type==="ObjectPattern"||e.params[0].type==="AssignmentPattern"&&e.params[0].left.type==="ObjectPattern")){u=!0;let d=e.params[0],m=d.type==="ObjectPattern"?d:d.left,y=Ge(m,n);if(y.type.kind==="object"&&y.type.destructuredParams){c={},l=new Set;for(let[x,S]of Object.entries(y.type.destructuredParams))o[x]={...S,description:i.params[x]},c[x]=S.type,S.required&&l.add(x)}}else for(let d of e.params)if(d.type==="Identifier"){let m=Ge(d,n);o[d.name]={...m,required:n.has(d.name),description:i.params[d.name]}}else if(d.type==="AssignmentPattern"&&d.left.type==="Identifier"){let m=Ge(d,n),y=Gu(s||"",e.id?.name||"",d.left.name);o[d.left.name]={...m,required:y,default:y?null:m.example??m.default,description:i.params[d.left.name]}}else if(d.type==="ObjectPattern"){let m=Ge(d,n);if(m.type.kind==="object"&&m.type.destructuredParams)for(let[y,x]of Object.entries(m.type.destructuredParams))o[y]={...x,description:i.params[y]}}else if(d.type==="RestElement"&&d.argument?.type==="Identifier"){let m=d.argument.name,y=t.match(new RegExp(`\\.\\.\\.${m}\\s*:\\s*([^)]+?)\\s*\\)`));if(y)try{let x=Pt(y[1].trim(),0,{ecmaVersion:2022}),S=ue(x);o[m]={name:m,type:S,required:!1,description:i.params[m]}}catch{o[m]={name:m,type:{kind:"array"},required:!1,description:i.params[m]}}else o[m]={name:m,type:{kind:"array"},required:!1,description:i.params[m]}}let p;if(r)try{let d=r.includes("=")?ua(r):r,m=Pt(d,0,{ecmaVersion:2022});p=ue(m)}catch{p={kind:"any"},a.push(`Could not parse return type: ${r}`)}return{types:{name:e.id?.name||"anonymous",params:o,returns:p,description:i.description,isDestructuredParam:u,destructuredShape:c,destructuredRequired:l},warnings:a}}function Ku(e,t,n){let r=[],s=n?`${n}:`:"",a=n?`${n}:${e}`:e;if(t.isDestructuredParam&&t.destructuredShape){let o=t.destructuredShape,u=t.destructuredRequired||new Set,c=Object.keys(o);if(c.length===0)return null;for(let l of c)r.push(`if (${l} instanceof Error) return ${l};`);for(let[l,p]of Object.entries(o)){let f=u.has(l),d=`${s}${e}.${l}`,m=jn(l,p);if(m){let y=p.kind;f?r.push(`if (${m}) return __tjs.typeError('${d}', '${y}', ${l});`):r.push(`if (${l} !== undefined && ${m}) return __tjs.typeError('${d}', '${y}', ${l});`)}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
|
|
356
|
+
`),suffix:"__tjs.popStack();"})}let i=Object.entries(t.params);if(i.length===0)return null;for(let[o]of i)r.push(`if (${o} instanceof Error) return ${o};`);for(let[o,u]of i){let c=`${s}${e}.${o}`;u.type.kind==="array"&&r.push(`if (Array.isArray(${o})) { for (const __i of ${o}) { if (__i instanceof Error && __i.path !== undefined) return __i } }`);let l=jn(o,u.type);if(l){let p=u.type.kind==="union"?u.type.members.map(f=>f.kind).join(" | "):u.type.kind;u.required?r.push(`if (${l}) return __tjs.typeError('${c}', '${p}', ${o});`):r.push(`if (${o} !== undefined && ${l}) return __tjs.typeError('${c}', '${p}', ${o});`)}if(u.type.kind==="function"){let p=nc(o,u.type,c);p&&(r.push(p),r.push(`if (${o} instanceof Error) return ${o};`))}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
|
|
357
|
+
`),suffix:"__tjs.popStack();"})}function ua(e){let t="",n=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="{"||s==="["||s==="(")n++,t+=s;else if(s==="}"||s==="]"||s===")")n--,t+=s;else if(s==="'"||s==='"'||s==="`"){for(t+=s,r++;r<e.length&&e[r]!==s;)e[r]==="\\"&&(t+=e[r++]),t+=e[r++];r<e.length&&(t+=e[r])}else n===1&&s==="="&&e[r-1]!=="!"&&e[r+1]!=="="?t+=":":t+=s}return t}function Zu(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*(:[?!]?)\\s*`,"g").exec(e);if(!r)return null;let s=e.slice(r.index+r[0].length);return $n(s)}function Qu(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*:([?!]?)`,"g").exec(e);if(!r)return;let s=r[1];if(s==="?")return"safe";if(s==="!")return"unsafe"}function Yu(e){let t=e.match(/^\/\*\s*tjs\s*<-\s*([^*]+?)\s*\*\//);return t?t[1].trim():void 0}function Xu(e,t){let n=new RegExp(`\\/\\*\\s*line\\s+(\\d+)\\s*\\*\\/\\s*(?:async\\s+)?function\\s+${t}\\s*\\(`,"m"),r=e.match(n);return r?parseInt(r[1],10):void 0}function In(e,t={}){let{filename:n="<source>",runTests:r=!0,debug:s=!1,resolvedImports:a={}}=t,i=[];e=lr(e);let u=Yu(e)||n,{code:c,tests:l,mocks:p,testRunner:f}=dr(e),{ast:d,originalSource:m,requiredParams:y,unsafeFunctions:x}=tt(c,{filename:n,colonShorthand:!0,dialect:t.dialect,moduleLoader:t.moduleLoader}),S=ec(d),v=bn(c,{dialect:t.dialect,moduleLoader:t.moduleLoader,filename:n}),b=v.predicates.filter(A=>!A.verified),_=A=>`${A.kind} '${A.name}': predicate is not verifiable, compiled as a plain function (not fuel-bounded, not safe on untrusted data)${A.reason?` \u2014 ${A.reason.replace(/\s+/g," ").trim()}`:""}`;if(b.length&&v.tjsModes.tjsStrict)throw new Error(`TjsStrict: ${b.length} predicate(s) could not be verified:
|
|
358
|
+
${b.map(A=>` ${_(A)}`).join(`
|
|
359
|
+
`)}`);for(let A of b)i.push(_(A));let k=v.predicates.length?v.predicates:void 0;for(let A of l)A.body=Rt(A.body),v.tjsModes.tjsEquals&&(A.body=Mt(A.body)),v.tjsModes.tjsStandard&&(A.body=Zr(A.body));for(let A of p)A.body=Rt(A.body),v.tjsModes.tjsEquals&&(A.body=Mt(A.body)),v.tjsModes.tjsStandard&&(A.body=Zr(A.body));let w={},E=[],$=[];for(let A of S){let D=A.id?.name||"anonymous",q=Zu(c,D),ve;if(q&&q.includes("="))try{let se=q.matchAll(/(\w+)\s*=\s*/g),le=ua(q),Oe=new Function(`return ${le}`)(),fe={};for(let qn of se){let kt=qn[1];kt in Oe&&(fe[kt]=Oe[kt])}Object.keys(fe).length>0&&(ve=fe)}catch{}let{types:Me,warnings:ya}=Hu(A,m,y,q,c);i.push(...ya),w[D]=Me;for(let se of A.params)if(se.type==="AssignmentPattern"&&se.left.type==="Identifier"&&se.right.type==="Identifier"){let le=se.left.name,Oe=se.right.name,fe=w[Oe];if(fe&&Me.params[le]){let qn=Object.entries(fe.params).map(([Sa,va])=>({name:Sa,type:va.type})),kt=fe.returns??{kind:"any"};Me.params[le].type={kind:"function",params:qn,returns:kt}}}for(let se of A.params)if(se.type==="AssignmentPattern"){let le=se.left?.name||se.left?.value,Oe=le?Me.params[le]:null;if(Oe?.required&&Oe.default===null)$.push({start:se.left.end,end:se.right.end});else{let fe=se.right;fe.type==="BinaryExpression"&&fe.operator==="|"&&$.push({start:fe.left.end,end:fe.end})}}let es=v.moduleSafety==="none"||x.has(D),ba=v.safeFunctions.has(D),xa=Qu(c,D),_a=Xu(e,D),ft={file:u,line:_a??A.loc?.start.line??0,column:A.loc?.start.column??0},wa={unsafe:es,safe:ba,returnSafety:xa},ts=v.polymorphicNames.has(D),Vn;if(ts){let se=[];for(let Oe of S){let fe=Oe.id?.name||"";fe.startsWith(D+"$")&&se.push(fe)}let le={polymorphic:!0,variants:se};ft&&(le.source=`${ft.file}:${ft.line}`),Vn=`${D}.__tjs = ${JSON.stringify(le,null,2)}`}else Vn=tc(D,Me,wa,{debug:s,source:ft,returnDefaults:ve});if(E.push({position:A.end,text:`
|
|
360
|
+
${Vn}`}),!es&&!ts){let se=`${ft.file}:${ft.line}`,le=Ku(D,Me,se);le&&A.body&&A.body.start!==void 0&&(E.push({position:A.body.start+1,text:`
|
|
357
361
|
${le.preamble}
|
|
358
|
-
`}),le.suffix&&
|
|
362
|
+
`}),le.suffix&&E.push({position:A.body.end-1,text:`
|
|
359
363
|
${le.suffix}
|
|
360
|
-
`}))}}if(
|
|
364
|
+
`}))}}if(v.tjsModes.tjsStandard){let A=Kr(d,v.source);for(let D of A)$.push({start:D.start,end:D.end}),E.push({position:D.start,text:D.newText})}$.sort((A,D)=>D.start-A.start);let T=v.source;for(let{start:A,end:D}of $)T=T.slice(0,A)+T.slice(D);for(let A of E){let D=0;for(let q of $)q.start<A.position&&(D+=q.end-q.start);A.position-=D}E.sort((A,D)=>D.position-A.position);for(let{position:A,text:D}of E)T=T.slice(0,A)+D+T.slice(A);let N=T.includes("__tjs.typeError("),P=T.includes("__tjs.pushStack("),F=T.includes("Is("),R=T.includes("IsNot("),J=T.includes("Eq("),z=T.includes("NotEq("),ee=T.includes("TypeOf("),te=/\bType\(/.test(T),ce=/\bGeneric\(/.test(T),lt=/\bFunctionPredicate\(/.test(T),Zt=/\bEnum\(/.test(T),On=/\bUnion\(/.test(T),Bn=T.includes("__tjs.bang("),Dn=T.includes("__tjs.toBool("),Fn=T.includes("__tjs.checkFnShape("),Xr=v.tjsModes.tjsSafeEval;if(N||P||F||R||J||z||ee||te||ce||lt||Zt||On||Bn||Dn||Fn||Xr){let A=[];N&&A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),P&&A.push("const __stack=[];function pushStack(n){__stack.push(n)}function popStack(){__stack.pop()}function getStack(){return[...__stack]}"),J&&A.push("function Eq(a,b){if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a===null||a===undefined)&&(b===null||b===undefined))return true;return false}"),z&&A.push("function NotEq(a,b){return!Eq(a,b)}"),ee&&A.push("function TypeOf(v){return v===null?'null':typeof v}"),F&&A.push("const tjsEquals=Symbol.for('tjs.equals');function Is(a,b){if(a!=null&&typeof a==='object'&&typeof a[tjsEquals]==='function')return a[tjsEquals](b);if(b!=null&&typeof b==='object'&&typeof b[tjsEquals]==='function')return b[tjsEquals](a);if(a!=null&&typeof a==='object'&&typeof a.Equals==='function')return a.Equals(b);if(b!=null&&typeof b==='object'&&typeof b.Equals==='function')return b.Equals(a);if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a==null)&&(b==null))return true;if(a==null||b==null)return false;if(typeof a!==typeof b)return false;if(typeof a!=='object')return false;if(a instanceof Set&&b instanceof Set){if(a.size!==b.size)return false;for(const v of a)if(!b.has(v))return false;return true}if(a instanceof Map&&b instanceof Map){if(a.size!==b.size)return false;for(const[k,v]of a)if(!b.has(k)||!Is(v,b.get(k)))return false;return true}if(a instanceof Date&&b instanceof Date)return a.getTime()===b.getTime();if(a instanceof RegExp&&b instanceof RegExp)return a.toString()===b.toString();if(Array.isArray(a)&&Array.isArray(b)){if(a.length!==b.length)return false;return a.every((v,i)=>Is(v,b[i]))}if(Array.isArray(a)!==Array.isArray(b))return false;const ka=Object.keys(a),kb=Object.keys(b);if(ka.length!==kb.length)return false;return ka.every(k=>Is(a[k],b[k]))}"),R&&A.push("function IsNot(a,b){return!Is(a,b)}"),te&&A.push("function Type(d,p,e){const t={description:d,__runtimeType:true};if(typeof p==='function'){t.check=p;t.default=e??null}else{const ex=e??p;t.default=ex;t.check=v=>{if(ex===null)return true;return typeof v===typeof ex}}return t}"),ce&&A.push("function Generic(tp,pred,d){const f=(...args)=>{const t={description:d||'generic',__runtimeType:true,check:v=>pred(v,...args)};return t};f.__runtimeType=true;f.description=d;return f}"),lt&&A.push("function FunctionPredicate(n,s,b){if(Array.isArray(s)&&b){const f=(...a)=>FunctionPredicate(n,b(...a));f.typeParamNames=s.map(p=>Array.isArray(p)?p[0]:p);f.description=n;f.__runtimeType=true;return f}const spec=typeof s==='function'?{}:s||{};return{description:n,params:spec.params||{},returns:spec.returns,returnContract:spec.returnContract||'assertReturns',check:v=>typeof v==='function',__runtimeType:true}}"),Zt&&A.push("function Enum(d,m){const vals=typeof m==='object'?Object.values(m):[];return{description:d,check:v=>vals.includes(v),values:vals,__runtimeType:true}}"),On&&A.push("function Union(d,...v){const vals=v.flat();return{description:d,check:x=>vals.includes(x),values:vals,__runtimeType:true}}"),Dn&&A.push("function toBool(v){if(v instanceof Boolean||v instanceof Number||v instanceof String)return Boolean(v.valueOf());return Boolean(v)}"),Fn&&(N||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push(`function checkFnShape(fn,expectedParams,expectedReturn,path){if(typeof fn!=='function')return fn;const meta=fn.__tjs;if(!meta||!meta.params)return fn;const entries=Object.entries(meta.params);for(let i=0;i<expectedParams.length;i++){const e=expectedParams[i];if(e==='any')continue;const a=entries[i];if(!a)continue;const ak=a[1]&&a[1].type&&a[1].type.kind;if(!ak||ak==='any')continue;if(ak!==e)return new MonadicError("Expected (...arg"+i+": "+e+", ...) for '"+path+"', but callback declares arg"+i+" as "+ak,path+"(arg"+i+")",e,ak)}if(expectedReturn!=='any'&&meta.returns){const ar=(meta.returns.type&&meta.returns.type.kind)||meta.returns.kind;if(ar&&ar!=='any'&&ar!==expectedReturn)return new MonadicError("Expected callback returning "+expectedReturn+" for '"+path+"', but callback returns "+ar,path+"(return)",expectedReturn,ar)}return fn}`)),Bn&&(N||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push("function bang(o,p){if(o===null||o===undefined)return typeError('bang.'+p,'non-null',o);if(isMonadicError(o))return o;return o[p]}"));let D=A.length>0?A.join(`;
|
|
361
365
|
`)+`;
|
|
362
|
-
`:"",
|
|
363
|
-
`+
|
|
364
|
-
`+
|
|
366
|
+
`:"",q=[];N&&q.push("typeError","isMonadicError"),P&&q.push("pushStack","popStack","getStack"),J&&q.push("Eq"),z&&q.push("NotEq"),ee&&q.push("TypeOf"),F&&q.push("Is","tjsEquals"),R&&q.push("IsNot"),te&&q.push("Type"),ce&&q.push("Generic"),lt&&q.push("FunctionPredicate"),Zt&&q.push("Enum"),On&&q.push("Union"),Dn&&q.push("toBool"),Fn&&(q.push("checkFnShape"),N||q.push("typeError","isMonadicError")),Bn&&(q.push("bang"),N||q.push("typeError","isMonadicError"));let ve=q.length>0?`{${q.join(",")}}`:"undefined";T=D+`const __tjs = globalThis.__tjs?.createRuntime?.() ?? ${ve};
|
|
367
|
+
`+T}Xr&&(T=`import { Eval, SafeFunction } from 'tjs-lang';
|
|
368
|
+
`+T);let vt;if(r){let A=ea(e);vt=ta(l,p,A,T,a,v.extensions);let D=vt.filter(q=>!q.passed&&!q.inconclusive);if(D.length>0&&r===!0){let q=D.map(ve=>{if(ve.isSignatureTest)return` Function signature example is inconsistent:
|
|
365
369
|
${ve.error}`;let Me=ve.line?` (line ${ve.line})`:"";return` Test '${ve.description}'${Me} failed:
|
|
366
370
|
${ve.error}`});throw new Error(`Transpile-time test failures:
|
|
367
|
-
${
|
|
368
|
-
`)}`)}}if(r==="only")return{code:"",types:
|
|
369
|
-
`+k),Qr=A.results}return{code:k,types:b,metadata:b,warnings:i.length>0?i:void 0,predicates:_,testRunner:l.length>0?f:void 0,testCount:l.length>0?l.length:void 0,testResults:vt,wasmCompiled:Qr}}function Yu(e){let t=[];for(let n of e.body)n.type==="FunctionDeclaration"?t.push(n):(n.type==="ExportNamedDeclaration"&&n.declaration?.type==="FunctionDeclaration"||n.type==="ExportDefaultDeclaration"&&n.declaration?.type==="FunctionDeclaration")&&t.push(n.declaration);return t}function Kt(e){let t={kind:e.kind};return e.nullable&&(t.nullable=!0),e.items&&(t.items=Kt(e.items)),e.shape&&(t.shape=Object.fromEntries(Object.entries(e.shape).map(([n,r])=>[n,Kt(r)]))),e.members&&(t.members=e.members.map(Kt)),t}function Xu(e,t,n={},r={}){let s={};for(let[i,o]of Object.entries(t.params))s[i]={type:Kt(o.type),required:o.required},o.default!==void 0&&(s[i].default=o.default),o.description&&(s[i].description=o.description);let a={params:s};if(t.returns&&(a.returns={type:Kt(t.returns)},r.returnDefaults&&(a.returns.defaults=r.returnDefaults),n.returnSafety==="safe"?a.safeReturn=!0:n.returnSafety==="unsafe"&&(a.unsafeReturn=!0)),t.description&&(a.description=t.description),n.unsafe&&(a.unsafe=!0),n.safe&&(a.safe=!0),r.source){let{file:i,line:o}=r.source;a.source=`${i}:${o}`}return`${e}.__tjs = ${JSON.stringify(a,null,2)}`}function Pn(e,t){let n;switch(t.kind){case"string":n=`typeof ${e} !== 'string'`;break;case"number":n=`typeof ${e} !== 'number'`;break;case"integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}))`;break;case"non-negative-integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}) || ${e} < 0)`;break;case"boolean":n=`typeof ${e} !== 'boolean'`;break;case"null":return`${e} !== null`;case"undefined":return`${e} !== undefined`;case"array":{let r=t.items&&t.items.kind!=="any"?Pn("__a",t.items):null;r?n=`(!Array.isArray(${e}) || ${e}.some(__a => ${r}))`:n=`!Array.isArray(${e})`;break}case"object":n=`(typeof ${e} !== 'object' || ${e} === null || Array.isArray(${e}))`;break;case"function":n=`typeof ${e} !== 'function'`;break;case"union":{let r=t.members.map(s=>Pn(e,s)).filter(s=>s!==null);if(r.length===0)return null;n=`(${r.join(" && ")})`;break}case"any":return null;default:return null}return n&&t.nullable&&(n=`(${e} !== null && ${n})`),n}var ia=new Set(["string","number","integer","non-negative-integer","boolean","function","any","undefined","null","object"]);function ec(e,t,n){let r=t.params??[],s=t.returns??{kind:"any"},a=r.map(c=>c.type?.kind),i=a.every(c=>c&&ia.has(c))&&ia.has(s.kind),o=a.some(c=>c!=="any")||s.kind!=="any";if(!i||!o)return null;let u=JSON.stringify(a);return`if (typeof ${e} === 'function') ${e} = __tjs.checkFnShape(${e}, ${u}, '${s.kind}', '${n}');`}function Nn(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=tt(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=_i(n,t.filename),{ast:u,signature:c,warnings:l}=ur(i,s,r,t,a,o.size>0?o:void 0);return{ast:u,signature:c,warnings:l}}function tc(e,...t){if(typeof e=="string")return Nn(e).ast;let n=e.reduce((r,s,a)=>r+s+(t[a]!==void 0?String(t[a]):""),"");return Nn(n).ast}function nc(e,t,n){let{ast:r,signature:s}=Nn(e),a=async i=>(await t.run(r,i,n)).result;return a.signature=s,a.ast=r,a}function In(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"array":return{type:"array",items:e.items?In(e.items):{}};case"object":return e.shape?{type:"object",properties:Object.fromEntries(Object.entries(e.shape).map(([t,n])=>[t,In(n)]))}:{type:"object"};case"union":return e.members?{anyOf:e.members.map(In)}:{};default:return{}}}function rc(e){return Object.entries(e).map(([t,n])=>{let r=n.signature,s={},a=[];for(let[i,o]of Object.entries(r.parameters))s[i]=In(o.type),o.description&&(s[i].description=o.description),o.required&&a.push(i);return{type:"function",function:{name:t,description:r.description,parameters:{type:"object",properties:s,required:a}}}})}function sc(e,t,...n){if(typeof e=="string")return jn(e,t);let r=t!==void 0?[t,...n]:n,s=e.reduce((a,i,o)=>a+i+(r[o]!==void 0?String(r[o]):""),"");return jn(s)}var ic=/\.[mc]?js$/i,ac=/\.[mc]?ts$/i,oc=/\.tjs$/i;function oa(e){return oc.test(e)?"tjs":ic.test(e)?"js":ac.test(e)?"ts":"tjs"}function uc(e){return oa(e)==="js"?"js":"tjs"}var ua=e=>e===null?"null":Array.isArray(e)?"array":typeof e;function cc(e,t){return t==="integer"?typeof e=="number"&&Number.isInteger(e):ua(e)===t}function ca(e,t={}){let{ignorePredicates:n,...r}=t,s=new Map,a=o=>{if(o.$predicate&&!n&&!s.has(o.$predicate)){let u=o.$predicate,c=et(u,r).predicates,l=c[c.length-1];if(!l)throw new Error("$predicate must declare at least one function");let p=It(u,[l],r);s.set(u,p[l])}if(o.properties)for(let u of Object.values(o.properties))a(u);o.items&&a(o.items)};a(e);let i=(o,u,c,l)=>{if(o.type&&!cc(u,o.type)){l.push({path:c||"/",message:`expected ${o.type}, got ${ua(u)}`});return}if(o.type==="object"&&o.properties&&u&&typeof u=="object"){let p=u;for(let f of o.required??[])f in p||l.push({path:`${c}/${f}`,message:`missing required '${f}'`});for(let[f,d]of Object.entries(o.properties))f in p&&i(d,p[f],`${c}/${f}`,l)}o.type==="array"&&o.items&&Array.isArray(u)&&u.forEach((p,f)=>i(o.items,p,`${c}/${f}`,l)),o.$predicate&&!n&&(s.get(o.$predicate)(u)||l.push({path:c||"/",message:`failed predicate at ${c||"/"}`}))};return o=>{let u=[];return i(e,o,"",u),{valid:u.length===0,errors:u}}}function lc(e,t,n){return ca(e,n)(t)}function Ze(e){let t;switch(e.kind){case"string":t="string";break;case"number":case"integer":case"non-negative-integer":t="number";break;case"boolean":t="boolean";break;case"null":return"null";case"undefined":return"undefined";case"any":t="any";break;case"array":if(e.items){let n=Ze(e.items);t=n.includes("|")?`(${n})[]`:`${n}[]`}else t="any[]";break;case"object":e.shape&&Object.keys(e.shape).length>0?t=`{ ${Object.entries(e.shape).map(([r,s])=>`${r}: ${Ze(s)}`).join("; ")} }`:t="Record<string, any>";break;case"union":if(e.members&&e.members.length>0)return e.members.map(Ze).join(" | ");t="any";break;case"function":{let n=e.params??[],r=e.returns?Ze(e.returns):"any";t=`(${n.map(a=>`${a.name}: ${Ze(a.type)}`).join(", ")}) => ${r}`;break}default:t="any"}return e.nullable?`${t} | null`:t}function fc(e,t,n,r){let s=Object.entries(t.params),a=new Array(s.length),i=!1;for(let l=s.length-1;l>=0;l--){let p=s[l][1],f=!p.required&&p.default!==void 0;a[l]=f&&!i,a[l]||(i=!0)}let o=s.map(([l,p],f)=>{let d=Ze(p.type);return a[f]?`${l}?: ${d}`:`${l}: ${d}`}).join(", "),u=t.returns?Ze(t.returns):"any";return`${n?r?"export default function":"export declare function":"declare function"} ${e}(${o}): ${u};`}function pc(e){let t=new Map,n,r=/^[ \t]*export\s+(default\s+)?function\s+(\w+)/gm;for(;(n=r.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let s=/^[ \t]*export\s+(default\s+)?class\s+(\w+)/gm;for(;(n=s.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let a=/^[ \t]*export\s+(default\s+)?(?:const|let|var)\s+(\w+)/gm;for(;(n=a.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let i=/^[ \t]*export\s+Type\s+(\w+)/gm;for(;(n=i.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let o=/^[ \t]*export\s+Generic\s+(\w+)/gm;for(;(n=o.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let u=/^[ \t]*export\s+FunctionPredicate\s+(\w+)/gm;for(;(n=u.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let c=/^[ \t]*export\s*\{([^}]+)\}/gm;for(;(n=c.exec(e))!==null;){let l=n[1].split(",").map(p=>p.trim().split(/\s+as\s+/));for(let p of l){let f=p.length>1?p[1]:p[0];f&&/^\w+$/.test(f)&&t.set(f,{exported:!0,isDefault:!1})}}return t}function hc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?FunctionPredicate\s+(\w+)\s*(?:<([^>]+)>)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2],i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l;a&&(l=a.split(",").map(y=>y.trim()));let p=[],f=c.match(/params\s*:\s*\{([^}]*)\}/);if(f){let y=f[1],x=fa(y);for(let S of x){let E=S.match(/^(\w+)\s*:\s*(.+)$/);E&&p.push({name:E[1],example:E[2].trim()})}}let d,m=c.match(/returns\s*:\s*(.+?)(?:\n|$)/);m&&(d=m[1].trim()),t.set(s,{params:p,returns:d,typeParams:l})}return t}function dc(e){let t=new Map,n=/^[ \t]*(?:export\s+(?:default\s+)?)?class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r.index+r[0].length-1,i=1,o=a+1;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,o++;let u=e.slice(a+1,o-1),c=u.indexOf("constructor"),l="";if(c!==-1){let f=u.indexOf("(",c);if(f!==-1){let d=1,m=f+1;for(;m<u.length&&d>0;)u[m]==="("?d++:u[m]===")"&&d--,m++;l=u.slice(f+1,m-1).trim()}}let p=[];{let f=0,d=0;for(;f<u.length;){let m=u[f];if(m==="{"){d++,f++;continue}if(m==="}"){d--,f++;continue}if(d===0){let y=u.slice(f).match(/^(\w+)\s*\(/);if(y){let x=y[1];if(x==="constructor"||x==="get"||x==="set"){f+=x.length;continue}else{let S=f+y[0].length-1,E=1,_=S+1;for(;_<u.length&&E>0;)u[_]==="("?E++:u[_]===")"&&E--,_++;let b=u.slice(S+1,_-1).trim(),v=u.slice(_).match(/^\s*->\s*(.+?)\s*\{/),w=v?v[1].trim():null;p.push({name:x,params:b,returnType:w}),f=_;continue}}}f++}}t.set(s,{name:s,constructorParams:l,methods:p})}return t}function fa(e){let t=[],n=0,r="";for(let s of e)s==="{"||s==="["||s==="("?n++:(s==="}"||s==="]"||s===")")&&n--,s===","&&n===0?(t.push(r.trim()),r=""):r+=s;return r.trim()&&t.push(r.trim()),t}function la(e){return e.trim()?fa(e).map(t=>{let n=t.match(/^(\w+)\s*:\s*(.+)$/);if(n){let s=n[1],a=Qe(n[2].trim());return`${s}: ${a}`}let r=t.match(/^(\w+)\s*=\s*(.+)$/);if(r){let s=r[1],a=Qe(r[2].trim());return`${s}?: ${a}`}return t.startsWith("{")?"options: any":`${t}: any`}).join(", "):""}function mc(e){let t=new Map,n,r=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*=\s*(.+)$/gm;for(;(n=r.exec(e))!==null;)t.set(n[1],n[2].trim());let s=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s+([^{=].*)$/gm;for(;(n=s.exec(e))!==null;)t.has(n[1])||t.set(n[1],n[2].trim());let a=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*example\s*:\s*(.+?)(?:\n|\s*[,}])/gm;for(;(n=a.exec(e))!==null;)t.set(n[1],n[2].trim());let i=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*\/\/\s*TS:\s*(.+?)(?:\n|\s*\})/gm;for(;(n=i.exec(e))!==null;)t.has(n[1])||t.set(n[1],`__ts__:${n[2].trim()}`);let o=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{\s*\}/gm;for(;(n=o.exec(e))!==null;)t.has(n[1])||t.set(n[1],"");return t}function gc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?Generic\s+(\w+)\s*<([^>]+)>\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2].split(",").map(f=>f.trim().split(/\s*=/)[0].trim()),i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l,p=c.match(/\bdeclaration\s*\{/);if(p&&p.index!==void 0){let f=p.index+p[0].length-1,d=1,m=f+1;for(;m<c.length&&d>0;)c[m]==="{"?d++:c[m]==="}"&&d--,m++;l=c.slice(f+1,m-1).trim()}t.set(s,{typeParams:a,declaration:l})}return t}function yc(e){let t=[],n=/^[ \t]*export\s+(?:default\s+)?(const|let|var)\s+(\w+)\s*(?::\s*\w+\s*)?=\s*(.+)/gm,r;for(;(r=n.exec(e))!==null;){let s=r[3].trim();s.endsWith(";")&&(s=s.slice(0,-1).trim()),t.push({name:r[2],value:s,kind:r[1]})}return t}function bc(e){return/^['"]/.test(e)||e.startsWith("`")?"string":e==="true"||e==="false"?"boolean":/^[+-]?\d+(\.\d+)?$/.test(e)?"number":e.startsWith("Symbol(")||e.startsWith("Symbol.")?"symbol":e.startsWith("[")?"any[]":e.startsWith("new WeakMap")?"WeakMap<any, any>":e.startsWith("new Map")?"Map<any, any>":e.startsWith("new Set")?"Set<any>":e.startsWith("new ")?"any":e.startsWith("{")?"Record<string, any>":e==="null"?"null":e==="undefined"?"undefined":"any"}function xc(e,t,n={}){let r=[],s=pc(t),a=mc(t),i=dc(t),o=gc(t),u=s.size>0,c=new Set;for(let[f,d]of Object.entries(e.types)){if(f.includes("$"))continue;let m=s.get(f),y=u?!!m?.exported:!0,x=m?.isDefault??!1;y&&(d.description&&r.push(`/** ${d.description} */`),r.push(fc(f,d,!0,x)),c.add(f))}for(let[f,d]of i){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.constructorParams?la(d.constructorParams):"";if(r.push(`export declare function ${f}(${x}): any;`),x||d.methods.length>0){r.push(`export declare class ${f} {`),d.constructorParams&&r.push(` constructor(${x});`);for(let S of d.methods){let E=S.params?la(S.params):"";r.push(` ${S.name}(${E}): any;`)}r.push("}")}c.add(f)}for(let[f,d]of a){if(c.has(f))continue;let m=s.get(f);if(!u||m?.exported){if(d.startsWith("__ts__:")){let x=d.slice(7);r.push(`export type ${f} = ${x};`)}else if(d==="")r.push(`export type ${f} = any;`);else{let x=Qe(d);r.push(`export declare const ${f}: { check(value: any): boolean; default: ${x}; (value: any): boolean; };`)}c.add(f)}}for(let[f,d]of o){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.typeParams.length>0?`<${d.typeParams.join(", ")}>`:"";if(d.declaration){let S=d.declaration.trim(),E=S.match(/^\/\/\s*TS:\s*(.+)$/s);if(E)r.push(`export type ${f}${x} = ${E[1].trim()};`);else{let _=S.split(`
|
|
370
|
-
`).map(
|
|
371
|
+
${q.join(`
|
|
372
|
+
`)}`)}}if(r==="only")return{code:"",types:w,metadata:w,testResults:vt,testCount:vt?.length,predicates:k};let Ln;if(v.wasmBlocks.length>0){let A=ia(v.wasmBlocks);A.code&&(T=A.code+`
|
|
373
|
+
`+T),Ln=A.results;for(let D of Ln)D.success||i.push(`wasm{} block '${D.id}' did not compile \u2014 running the fallback{} (JS)${D.error?`: ${D.error}`:""}`);for(let D of A.warnings)i.push(`wasm{}: ${D}`)}return{code:T,types:w,metadata:w,warnings:i.length>0?i:void 0,predicates:k,testRunner:l.length>0?f:void 0,testCount:l.length>0?l.length:void 0,testResults:vt,wasmCompiled:Ln}}function ec(e){let t=[];for(let n of e.body)n.type==="FunctionDeclaration"?t.push(n):(n.type==="ExportNamedDeclaration"&&n.declaration?.type==="FunctionDeclaration"||n.type==="ExportDefaultDeclaration"&&n.declaration?.type==="FunctionDeclaration")&&t.push(n.declaration);return t}function Kt(e){let t={kind:e.kind};return e.nullable&&(t.nullable=!0),e.items&&(t.items=Kt(e.items)),e.shape&&(t.shape=Object.fromEntries(Object.entries(e.shape).map(([n,r])=>[n,Kt(r)]))),e.members&&(t.members=e.members.map(Kt)),t}function tc(e,t,n={},r={}){let s={};for(let[i,o]of Object.entries(t.params))s[i]={type:Kt(o.type),required:o.required},o.default!==void 0&&(s[i].default=o.default),o.description&&(s[i].description=o.description);let a={params:s};if(t.returns&&(a.returns={type:Kt(t.returns)},r.returnDefaults&&(a.returns.defaults=r.returnDefaults),n.returnSafety==="safe"?a.safeReturn=!0:n.returnSafety==="unsafe"&&(a.unsafeReturn=!0)),t.description&&(a.description=t.description),n.unsafe&&(a.unsafe=!0),n.safe&&(a.safe=!0),r.source){let{file:i,line:o}=r.source;a.source=`${i}:${o}`}return`${e}.__tjs = ${JSON.stringify(a,null,2)}`}function jn(e,t){let n;switch(t.kind){case"string":n=`typeof ${e} !== 'string'`;break;case"number":n=`typeof ${e} !== 'number'`;break;case"integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}))`;break;case"non-negative-integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}) || ${e} < 0)`;break;case"boolean":n=`typeof ${e} !== 'boolean'`;break;case"null":return`${e} !== null`;case"undefined":return`${e} !== undefined`;case"array":{let r=t.items&&t.items.kind!=="any"?jn("__a",t.items):null;r?n=`(!Array.isArray(${e}) || ${e}.some(__a => ${r}))`:n=`!Array.isArray(${e})`;break}case"object":n=`(typeof ${e} !== 'object' || ${e} === null || Array.isArray(${e}))`;break;case"function":n=`typeof ${e} !== 'function'`;break;case"union":{let r=t.members.map(s=>jn(e,s)).filter(s=>s!==null);if(r.length===0)return null;n=`(${r.join(" && ")})`;break}case"any":return null;default:return null}return n&&t.nullable&&(n=`(${e} !== null && ${n})`),n}var oa=new Set(["string","number","integer","non-negative-integer","boolean","function","any","undefined","null","object"]);function nc(e,t,n){let r=t.params??[],s=t.returns??{kind:"any"},a=r.map(c=>c.type?.kind),i=a.every(c=>c&&oa.has(c))&&oa.has(s.kind),o=a.some(c=>c!=="any")||s.kind!=="any";if(!i||!o)return null;let u=JSON.stringify(a);return`if (typeof ${e} === 'function') ${e} = __tjs.checkFnShape(${e}, ${u}, '${s.kind}', '${n}');`}function Rn(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=tt(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=Si(n,t.filename),{ast:u,signature:c,warnings:l}=pr(i,s,r,t,a,o.size>0?o:void 0);return{ast:u,signature:c,warnings:l}}function rc(e,...t){if(typeof e=="string")return Rn(e).ast;let n=e.reduce((r,s,a)=>r+s+(t[a]!==void 0?String(t[a]):""),"");return Rn(n).ast}function sc(e,t,n){let{ast:r,signature:s}=Rn(e),a=async i=>(await t.run(r,i,n)).result;return a.signature=s,a.ast=r,a}function Nn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"array":return{type:"array",items:e.items?Nn(e.items):{}};case"object":return e.shape?{type:"object",properties:Object.fromEntries(Object.entries(e.shape).map(([t,n])=>[t,Nn(n)]))}:{type:"object"};case"union":return e.members?{anyOf:e.members.map(Nn)}:{};default:return{}}}function ic(e){return Object.entries(e).map(([t,n])=>{let r=n.signature,s={},a=[];for(let[i,o]of Object.entries(r.parameters))s[i]=Nn(o.type),o.description&&(s[i].description=o.description),o.required&&a.push(i);return{type:"function",function:{name:t,description:r.description,parameters:{type:"object",properties:s,required:a}}}})}function ac(e,t,...n){if(typeof e=="string")return In(e,t);let r=t!==void 0?[t,...n]:n,s=e.reduce((a,i,o)=>a+i+(r[o]!==void 0?String(r[o]):""),"");return In(s)}var oc=/\.[mc]?js$/i,uc=/\.[mc]?ts$/i,cc=/\.tjs$/i;function ca(e){return cc.test(e)?"tjs":oc.test(e)?"js":uc.test(e)?"ts":"tjs"}function lc(e){return ca(e)==="js"?"js":"tjs"}var la=e=>e===null?"null":Array.isArray(e)?"array":typeof e;function fc(e,t){return t==="integer"?typeof e=="number"&&Number.isInteger(e):la(e)===t}function fa(e,t={}){let{ignorePredicates:n,...r}=t,s=new Map,a=o=>{if(o.$predicate&&!n&&!s.has(o.$predicate)){let u=o.$predicate,c=et(u,r).predicates,l=c[c.length-1];if(!l)throw new Error("$predicate must declare at least one function");let p=It(u,[l],r);s.set(u,p[l])}if(o.properties)for(let u of Object.values(o.properties))a(u);o.items&&a(o.items)};a(e);let i=(o,u,c,l)=>{if(o.type&&!fc(u,o.type)){l.push({path:c||"/",message:`expected ${o.type}, got ${la(u)}`});return}if(o.type==="object"&&o.properties&&u&&typeof u=="object"){let p=u;for(let f of o.required??[])f in p||l.push({path:`${c}/${f}`,message:`missing required '${f}'`});for(let[f,d]of Object.entries(o.properties))f in p&&i(d,p[f],`${c}/${f}`,l)}o.type==="array"&&o.items&&Array.isArray(u)&&u.forEach((p,f)=>i(o.items,p,`${c}/${f}`,l)),o.$predicate&&!n&&(s.get(o.$predicate)(u)||l.push({path:c||"/",message:`failed predicate at ${c||"/"}`}))};return o=>{let u=[];return i(e,o,"",u),{valid:u.length===0,errors:u}}}function pc(e,t,n){return fa(e,n)(t)}function Ze(e){let t;switch(e.kind){case"string":t="string";break;case"number":case"integer":case"non-negative-integer":t="number";break;case"boolean":t="boolean";break;case"null":return"null";case"undefined":return"undefined";case"any":t="any";break;case"array":if(e.items){let n=Ze(e.items);t=n.includes("|")?`(${n})[]`:`${n}[]`}else t="any[]";break;case"object":e.shape&&Object.keys(e.shape).length>0?t=`{ ${Object.entries(e.shape).map(([r,s])=>`${r}: ${Ze(s)}`).join("; ")} }`:t="Record<string, any>";break;case"union":if(e.members&&e.members.length>0)return e.members.map(Ze).join(" | ");t="any";break;case"function":{let n=e.params??[],r=e.returns?Ze(e.returns):"any";t=`(${n.map(a=>`${a.name}: ${Ze(a.type)}`).join(", ")}) => ${r}`;break}default:t="any"}return e.nullable?`${t} | null`:t}function hc(e,t,n,r){let s=Object.entries(t.params),a=new Array(s.length),i=!1;for(let l=s.length-1;l>=0;l--){let p=s[l][1],f=!p.required&&p.default!==void 0;a[l]=f&&!i,a[l]||(i=!0)}let o=s.map(([l,p],f)=>{let d=Ze(p.type);return a[f]?`${l}?: ${d}`:`${l}: ${d}`}).join(", "),u=t.returns?Ze(t.returns):"any";return`${n?r?"export default function":"export declare function":"declare function"} ${e}(${o}): ${u};`}function dc(e){let t=new Map,n,r=/^[ \t]*export\s+(default\s+)?function\s+(\w+)/gm;for(;(n=r.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let s=/^[ \t]*export\s+(default\s+)?class\s+(\w+)/gm;for(;(n=s.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let a=/^[ \t]*export\s+(default\s+)?(?:const|let|var)\s+(\w+)/gm;for(;(n=a.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let i=/^[ \t]*export\s+Type\s+(\w+)/gm;for(;(n=i.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let o=/^[ \t]*export\s+Generic\s+(\w+)/gm;for(;(n=o.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let u=/^[ \t]*export\s+FunctionPredicate\s+(\w+)/gm;for(;(n=u.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let c=/^[ \t]*export\s*\{([^}]+)\}/gm;for(;(n=c.exec(e))!==null;){let l=n[1].split(",").map(p=>p.trim().split(/\s+as\s+/));for(let p of l){let f=p.length>1?p[1]:p[0];f&&/^\w+$/.test(f)&&t.set(f,{exported:!0,isDefault:!1})}}return t}function mc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?FunctionPredicate\s+(\w+)\s*(?:<([^>]+)>)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2],i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l;a&&(l=a.split(",").map(y=>y.trim()));let p=[],f=c.match(/params\s*:\s*\{([^}]*)\}/);if(f){let y=f[1],x=ha(y);for(let S of x){let v=S.match(/^(\w+)\s*:\s*(.+)$/);v&&p.push({name:v[1],example:v[2].trim()})}}let d,m=c.match(/returns\s*:\s*(.+?)(?:\n|$)/);m&&(d=m[1].trim()),t.set(s,{params:p,returns:d,typeParams:l})}return t}function gc(e){let t=new Map,n=/^[ \t]*(?:export\s+(?:default\s+)?)?class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r.index+r[0].length-1,i=1,o=a+1;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,o++;let u=e.slice(a+1,o-1),c=u.indexOf("constructor"),l="";if(c!==-1){let f=u.indexOf("(",c);if(f!==-1){let d=1,m=f+1;for(;m<u.length&&d>0;)u[m]==="("?d++:u[m]===")"&&d--,m++;l=u.slice(f+1,m-1).trim()}}let p=[];{let f=0,d=0;for(;f<u.length;){let m=u[f];if(m==="{"){d++,f++;continue}if(m==="}"){d--,f++;continue}if(d===0){let y=u.slice(f).match(/^(\w+)\s*\(/);if(y){let x=y[1];if(x==="constructor"||x==="get"||x==="set"){f+=x.length;continue}else{let S=f+y[0].length-1,v=1,b=S+1;for(;b<u.length&&v>0;)u[b]==="("?v++:u[b]===")"&&v--,b++;let _=u.slice(S+1,b-1).trim(),k=u.slice(b).match(/^\s*->\s*(.+?)\s*\{/),w=k?k[1].trim():null;p.push({name:x,params:_,returnType:w}),f=b;continue}}}f++}}t.set(s,{name:s,constructorParams:l,methods:p})}return t}function ha(e){let t=[],n=0,r="";for(let s of e)s==="{"||s==="["||s==="("?n++:(s==="}"||s==="]"||s===")")&&n--,s===","&&n===0?(t.push(r.trim()),r=""):r+=s;return r.trim()&&t.push(r.trim()),t}function pa(e){return e.trim()?ha(e).map(t=>{let n=t.match(/^(\w+)\s*:\s*(.+)$/);if(n){let s=n[1],a=Qe(n[2].trim());return`${s}: ${a}`}let r=t.match(/^(\w+)\s*=\s*(.+)$/);if(r){let s=r[1],a=Qe(r[2].trim());return`${s}?: ${a}`}return t.startsWith("{")?"options: any":`${t}: any`}).join(", "):""}function yc(e){let t=new Map,n,r=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*=\s*(.+)$/gm;for(;(n=r.exec(e))!==null;)t.set(n[1],n[2].trim());let s=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s+([^{=].*)$/gm;for(;(n=s.exec(e))!==null;)t.has(n[1])||t.set(n[1],n[2].trim());let a=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*example\s*:\s*(.+?)(?:\n|\s*[,}])/gm;for(;(n=a.exec(e))!==null;)t.set(n[1],n[2].trim());let i=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*\/\/\s*TS:\s*(.+?)(?:\n|\s*\})/gm;for(;(n=i.exec(e))!==null;)t.has(n[1])||t.set(n[1],`__ts__:${n[2].trim()}`);let o=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{\s*\}/gm;for(;(n=o.exec(e))!==null;)t.has(n[1])||t.set(n[1],"");return t}function bc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?Generic\s+(\w+)\s*<([^>]+)>\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2].split(",").map(f=>f.trim().split(/\s*=/)[0].trim()),i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l,p=c.match(/\bdeclaration\s*\{/);if(p&&p.index!==void 0){let f=p.index+p[0].length-1,d=1,m=f+1;for(;m<c.length&&d>0;)c[m]==="{"?d++:c[m]==="}"&&d--,m++;l=c.slice(f+1,m-1).trim()}t.set(s,{typeParams:a,declaration:l})}return t}function xc(e){let t=[],n=/^[ \t]*export\s+(?:default\s+)?(const|let|var)\s+(\w+)\s*(?::\s*\w+\s*)?=\s*(.+)/gm,r;for(;(r=n.exec(e))!==null;){let s=r[3].trim();s.endsWith(";")&&(s=s.slice(0,-1).trim()),t.push({name:r[2],value:s,kind:r[1]})}return t}function _c(e){return/^['"]/.test(e)||e.startsWith("`")?"string":e==="true"||e==="false"?"boolean":/^[+-]?\d+(\.\d+)?$/.test(e)?"number":e.startsWith("Symbol(")||e.startsWith("Symbol.")?"symbol":e.startsWith("[")?"any[]":e.startsWith("new WeakMap")?"WeakMap<any, any>":e.startsWith("new Map")?"Map<any, any>":e.startsWith("new Set")?"Set<any>":e.startsWith("new ")?"any":e.startsWith("{")?"Record<string, any>":e==="null"?"null":e==="undefined"?"undefined":"any"}function wc(e,t,n={}){let r=[],s=dc(t),a=yc(t),i=gc(t),o=bc(t),u=s.size>0,c=new Set;for(let[f,d]of Object.entries(e.types)){if(f.includes("$"))continue;let m=s.get(f),y=u?!!m?.exported:!0,x=m?.isDefault??!1;y&&(d.description&&r.push(`/** ${d.description} */`),r.push(hc(f,d,!0,x)),c.add(f))}for(let[f,d]of i){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.constructorParams?pa(d.constructorParams):"";if(r.push(`export declare function ${f}(${x}): any;`),x||d.methods.length>0){r.push(`export declare class ${f} {`),d.constructorParams&&r.push(` constructor(${x});`);for(let S of d.methods){let v=S.params?pa(S.params):"";r.push(` ${S.name}(${v}): any;`)}r.push("}")}c.add(f)}for(let[f,d]of a){if(c.has(f))continue;let m=s.get(f);if(!u||m?.exported){if(d.startsWith("__ts__:")){let x=d.slice(7);r.push(`export type ${f} = ${x};`)}else if(d==="")r.push(`export type ${f} = any;`);else{let x=Qe(d);r.push(`export declare const ${f}: { check(value: any): boolean; default: ${x}; (value: any): boolean; };`)}c.add(f)}}for(let[f,d]of o){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.typeParams.length>0?`<${d.typeParams.join(", ")}>`:"";if(d.declaration){let S=d.declaration.trim(),v=S.match(/^\/\/\s*TS:\s*(.+)$/s);if(v)r.push(`export type ${f}${x} = ${v[1].trim()};`);else{let b=S.split(`
|
|
374
|
+
`).map(_=>_.trim()).filter(_=>_.length>0).map(_=>` ${_}`).join(`
|
|
371
375
|
`);r.push(`export interface ${f}${x} {
|
|
372
|
-
${
|
|
373
|
-
}`)}}else r.push(`export declare function ${f}(...args: any[]): { check(value: any): boolean; (value: any): boolean; };`);c.add(f)}let l=
|
|
376
|
+
${b}
|
|
377
|
+
}`)}}else r.push(`export declare function ${f}(...args: any[]): { check(value: any): boolean; (value: any): boolean; };`);c.add(f)}let l=mc(t);for(let[f,d]of l){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=new Set(d.typeParams?.map(_=>_.split("=")[0].trim())??[]),S=d.typeParams?`<${d.typeParams.join(", ")}>`:"",v=d.params.map((_,k)=>{let w=k===d.params.length-1;if(_.example.startsWith("[")&&_.example.endsWith("]")&&w){let $=_.example.slice(1,-1).trim(),T=!$||$==="null"?"any":x.has($)?$:Qe($);return`...${_.name}: ${T}[]`}if(_.example.startsWith("[")&&_.example.endsWith("]")){let $=_.example.slice(1,-1).trim(),T=!$||$==="null"?"any":x.has($)?$:Qe($);return`${_.name}: ${T}[]`}let E=_.example==="null"?"any":x.has(_.example)?_.example:Qe(_.example);return`${_.name}: ${E}`}).join(", "),b=d.returns!==void 0?d.returns==="null"?"any":x.has(d.returns)?d.returns:Qe(d.returns):"void";r.push(`export type ${f}${S} = (${v}) => ${b};`),c.add(f)}let p=xc(t);for(let f of p){if(c.has(f.name))continue;let d=s.get(f.name);if(!(u?!!d?.exported:!0))continue;let y=_c(f.value);r.push(`export declare const ${f.name}: ${y};`),c.add(f.name)}if(n.moduleName){let f=r.map(d=>` ${d}`).join(`
|
|
374
378
|
`);return`declare module '${n.moduleName}' {
|
|
375
379
|
${f}
|
|
376
380
|
}
|
|
377
381
|
`}return r.join(`
|
|
378
382
|
`)+`
|
|
379
|
-
`}function Qe(e){let t=e.trim();if(
|
|
383
|
+
`}function Qe(e){let t=e.trim();if(Sc(t)){let n=vc(t).map(r=>Qe(r.trim()));return[...new Set(n)].join(" | ")}return/^['"]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":/^[+-]?\d+\.\d+$/.test(t)||/^[+-]?\d+$/.test(t)?"number":t.startsWith("[")?"any[]":t.startsWith("{")?"Record<string, any>":"any"}function Sc(e){let t=0,n=null;for(let r of e){if(n){r===n&&(n=null);continue}if(r==="'"||r==='"'||r==="`"){n=r;continue}if(r==="{"||r==="["||r==="(")t++;else if(r==="}"||r==="]"||r===")")t--;else if(r==="|"&&t===0)return!0}return!1}function vc(e){let t=[],n=0,r=null,s="";for(let a of e){if(r){s+=a,a===r&&(r=null);continue}if(a==="'"||a==='"'||a==="`"){r=a,s+=a;continue}a==="{"||a==="["||a==="("?n++:(a==="}"||a==="]"||a===")")&&n--,a==="|"&&n===0?(t.push(s),s=""):s+=a}return s&&t.push(s),t}function da(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Mn(e){return ye.infer(e)}function Qr(e){return Mn(e)}Qr.type=da;Qr.infer=Mn;var kc=new Proxy(Qr,{get(e,t){return t==="type"?da:t==="infer"?Mn:ye[t]},apply(e,t,n){return Mn(n[0])}});var Ec={unusedVariables:!0,undefinedVariables:!0,unreachableCode:!0,noExplicitNew:!0};function Tc(e,t={}){let n={...Ec,...t},r=[],s,a=new Map,i;try{let l=tt(e,{filename:n.filename,colonShorthand:!0});s=l.ast,a=l.letAnnotations,i=l.tjsModes.tjsSafeAssign}catch(l){return{diagnostics:[{severity:"error",message:l.message,line:l.loc?.line,column:l.loc?.column,rule:"parse-error"}],valid:!1}}let o=n.safeAssign!==void 0?n.safeAssign:i,u=n.strict?"error":"warning",c=[ma()];if(qs(s,{FunctionDeclaration(l,p,f){let d=ma();c.push(d);for(let m of l.params)$c(d,m,"parameter");l.id&&(c[c.length-2]||c[0]).declarations.set(l.id.name,{node:l.id,kind:"function",used:!1})},VariableDeclaration(l){let p=c[c.length-1];for(let f of l.declarations)f.id.type==="Identifier"&&p.declarations.set(f.id.name,{node:f.id,kind:l.kind,used:!1})}}),Ee(s,{Identifier(l){for(let p=c.length-1;p>=0;p--){let f=c[p].declarations.get(l.name);if(f){f.used=!0;break}}}}),n.unusedVariables)for(let l of c)for(let[p,f]of l.declarations)p.startsWith("_")||!f.used&&f.kind!=="function"&&r.push({severity:"warning",message:`'${p}' is declared but never used`,line:f.node.loc?.start?.line,column:f.node.loc?.start?.column,rule:"no-unused-vars"});if(n.unreachableCode&&Ee(s,{BlockStatement(l){let p=!1;for(let f of l.body){if(p){r.push({severity:"warning",message:"Unreachable code after return statement",line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"no-unreachable"});break}f.type==="ReturnStatement"&&(p=!0)}}}),o){let l=new Set;Ee(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name,m=a.has(d),y=f.init;(m||y&&!Yr(y))&&l.add(d)}}}),Ee(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name;a.has(d)||(f.init?Yr(f.init)&&r.push({severity:u,message:`'let ${d}' is initialized to ${ga(f.init)} with no type annotation. Annotate (let ${d}: <example>) to record the intended type.`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}):r.push({severity:u,message:`'let ${d}' has no initializer or type annotation. Add an initializer (let ${d} = ...) or annotate (let ${d}: <example>).`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}))}}}),Ee(s,{AssignmentExpression(p){if(p.operator!=="="||p.left.type!=="Identifier")return;let f=p.left.name;l.has(f)&&Yr(p.right)&&r.push({severity:u,message:`Cannot assign ${ga(p.right)} to typed let '${f}'.`,line:p.loc?.start?.line,column:p.loc?.start?.column,rule:"safe-assign-no-nullish"})}})}return n.noExplicitNew&&Ee(s,{NewExpression(l){let p="class";l.callee.type==="Identifier"?p=l.callee.name:l.callee.type==="MemberExpression"&&l.callee.property.type==="Identifier"&&(p=l.callee.property.name),r.push({severity:"warning",message:`Unnecessary 'new' keyword. In TJS, classes are callable without 'new': ${p}(...) instead of new ${p}(...)`,line:l.loc?.start?.line,column:l.loc?.start?.column,rule:"no-explicit-new"})}}),{diagnostics:r,valid:r.filter(l=>l.severity==="error").length===0}}function ma(){return{declarations:new Map}}function Yr(e){return e?e.type==="Identifier"&&e.name==="undefined"||e.type==="Literal"&&e.value===null||e.type==="UnaryExpression"&&e.operator==="void":!1}function ga(e){return e.type==="Identifier"?"undefined":e.type==="Literal"&&e.value===null?"null":e.type==="UnaryExpression"&&e.operator==="void"?"void <expr> (undefined)":"a nullish value"}function $c(e,t,n){t.type==="Identifier"?e.declarations.set(t.name,{node:t,kind:n,used:!1}):t.type==="AssignmentPattern"&&t.left.type==="Identifier"&&e.declarations.set(t.left.name,{node:t.left,kind:n,used:!1})}export{jt as PredicateFuelExhausted,kc as Schema,Ve as TJS_VERSION,rc as ajs,Ci as assertFunction,ot as checkType,It as compilePredicate,fa as compilePredicateSchema,sc as createAgent,yo as createPredicateEvaluator,lc as dialectForFilename,mo as effectfulFromAtoms,gu as emitRuntimeWrapper,ir as emitVerifiedPredicate,Re as error,Ai as expectFunction,Ie as extractLiteralValue,Dt as extractTDoc,dr as extractTests,fn as formatPredicateDiagnostics,wc as generateDTS,ic as getToolDefinitions,ue as inferTypeFromValue,qr as installRuntime,qe as isError,Tc as lint,tt as parse,Ge as parseParameter,vi as parseReturnType,bn as preprocess,st as runtime,ca as sourceKindForFilename,go as suggest,Xo as testUtils,ac as tjs,pr as transformFunction,Rn as transpile,In as transpileToJS,Ze as typeDescriptorToTS,_t as typeOf,fr as typeToString,Lr as validateArgs,pc as validatePredicateSchema,et as verifyPredicate,Vr as wrap};
|
|
380
384
|
//# sourceMappingURL=tjs-browser.js.map
|