@xnoxs/flux-lang 3.5.3 → 4.0.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/CHANGELOG.md +44 -0
- package/README.md +3 -1
- package/dist/flux-cli.js +171 -11
- package/dist/flux.cjs.js +64 -1
- package/dist/flux.esm.js +64 -1
- package/dist/flux.min.js +20 -20
- package/package.json +1 -1
- package/scripts/build.js +0 -0
- package/src/config.js +0 -0
- package/src/self/bundler.flux +0 -0
- package/src/self/checker.flux +0 -0
- package/src/self/cli.flux +0 -0
- package/src/self/codegen.flux +5 -2
- package/src/self/codegen.js +8 -3
- package/src/self/config.flux +0 -0
- package/src/self/css-preprocessor.flux +0 -0
- package/src/self/formatter.flux +0 -0
- package/src/self/jsx.flux +0 -0
- package/src/self/lexer.flux +2 -2
- package/src/self/lexer.js +2 -2
- package/src/self/linter.flux +0 -0
- package/src/self/mangler.flux +0 -0
- package/src/self/parser.flux +41 -0
- package/src/self/parser.js +49 -0
- package/src/self/pkg.flux +76 -0
- package/src/self/pkg.js +82 -0
- package/src/self/sourcemap.flux +0 -0
- package/src/self/stdlib.flux +0 -0
- package/src/self/test-runner.flux +0 -0
- package/src/self/transpiler.flux +14 -4
- package/src/self/transpiler.js +13 -2
- package/src/self/type-checker.flux +12 -0
- package/src/self/type-checker.js +17 -0
package/dist/flux.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* flux-lang
|
|
2
|
+
* flux-lang v4.0.1
|
|
3
3
|
* Flux — A modern language that transpiles to JavaScript. Python-clean syntax, TypeScript-level safety, Rust-inspired pattern matching.
|
|
4
4
|
* (c) 2026 Flux Lang Contributors
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var _=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var J=_((xs,Ct)=>{"use strict";var o={NUMBER:"NUMBER",STRING:"STRING",BOOL:"BOOL",NULL:"NULL",IDENT:"IDENT",VAR:"VAR",VAL:"VAL",FN:"FN",RETURN:"RETURN",IF:"IF",ELSE:"ELSE",FOR:"FOR",IN:"IN",WHILE:"WHILE",BREAK:"BREAK",CONTINUE:"CONTINUE",DO:"DO",CLASS:"CLASS",EXTENDS:"EXTENDS",SELF:"SELF",NEW:"NEW",INTERFACE:"INTERFACE",IMPLEMENTS:"IMPLEMENTS",PRIVATE:"PRIVATE",PUBLIC:"PUBLIC",PROTECTED:"PROTECTED",READONLY:"READONLY",STATIC:"STATIC",ABSTRACT:"ABSTRACT",OVERRIDE:"OVERRIDE",MATCH:"MATCH",WHEN:"WHEN",IMPORT:"IMPORT",EXPORT:"EXPORT",FROM:"FROM",AS:"AS",DEFAULT:"DEFAULT",AND:"AND",OR:"OR",NOT:"NOT",ASYNC:"ASYNC",AWAIT:"AWAIT",TRY:"TRY",CATCH:"CATCH",FINALLY:"FINALLY",THROW:"THROW",TYPEOF:"TYPEOF",INSTANCEOF:"INSTANCEOF",TYPE:"TYPE",ENUM:"ENUM",SATISFIES:"SATISFIES",IS:"IS",CONST:"CONST",PLUS:"PLUS",MINUS:"MINUS",STAR:"STAR",SLASH:"SLASH",PERCENT:"PERCENT",REGEX:"REGEX",STARSTAR:"STARSTAR",EQ:"EQ",EQEQ:"EQEQ",NEQ:"NEQ",EQEQEQ:"EQEQEQ",NEQEQ:"NEQEQ",LT:"LT",LTE:"LTE",GT:"GT",GTE:"GTE",PLUSEQ:"PLUSEQ",MINUSEQ:"MINUSEQ",STAREQ:"STAREQ",SLASHEQ:"SLASHEQ",PERCENTEQ:"PERCENTEQ",PLUSPLUS:"PLUSPLUS",MINUSMINUS:"MINUSMINUS",AMPERSAND:"AMPERSAND",ANDAND:"ANDAND",PIPEB:"PIPEB",OROR:"OROR",CARET:"CARET",TILDE:"TILDE",LSHIFT:"LSHIFT",RSHIFT:"RSHIFT",ARROW:"ARROW",FATARROW:"FATARROW",PIPE:"PIPE",DOTDOT:"DOTDOT",DOTDOTDOT:"DOTDOTDOT",WILDCARD:"WILDCARD",NULLISH:"NULLISH",QUESTIONDOT:"QUESTIONDOT",BANG:"BANG",AT:"AT",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",QUESTION:"QUESTION",NEWLINE:"NEWLINE",INDENT:"INDENT",DEDENT:"DEDENT",EOF:"EOF"},Lt={var:o.VAR,val:o.VAL,fn:o.FN,return:o.RETURN,if:o.IF,else:o.ELSE,for:o.FOR,in:o.IN,while:o.WHILE,break:o.BREAK,continue:o.CONTINUE,do:o.DO,class:o.CLASS,extends:o.EXTENDS,self:o.SELF,new:o.NEW,interface:o.INTERFACE,implements:o.IMPLEMENTS,private:o.PRIVATE,public:o.PUBLIC,protected:o.PROTECTED,readonly:o.READONLY,static:o.STATIC,abstract:o.ABSTRACT,override:o.OVERRIDE,match:o.MATCH,when:o.WHEN,import:o.IMPORT,export:o.EXPORT,from:o.FROM,as:o.AS,default:o.DEFAULT,and:o.AND,or:o.OR,not:o.NOT,async:o.ASYNC,await:o.AWAIT,try:o.TRY,catch:o.CATCH,finally:o.FINALLY,throw:o.THROW,typeof:o.TYPEOF,instanceof:o.INSTANCEOF,type:o.TYPE,enum:o.ENUM,satisfies:o.SATISFIES,is:o.IS,const:o.CONST,true:"__TRUE__",false:"__FALSE__",null:"__NULL__"},kt=class extends Error{constructor(t,e,s){super(t),this.name="LexerError",this.line=e,this.col=s}},Et=class{constructor(t){this.src=t.replace(/\r\n/g,`
|
|
7
|
+
"use strict";var _=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var J=_((xs,Ct)=>{"use strict";var o={NUMBER:"NUMBER",STRING:"STRING",BOOL:"BOOL",NULL:"NULL",IDENT:"IDENT",VAR:"VAR",VAL:"VAL",FN:"FN",RETURN:"RETURN",DECLARE:"DECLARE",IF:"IF",ELSE:"ELSE",FOR:"FOR",IN:"IN",WHILE:"WHILE",BREAK:"BREAK",CONTINUE:"CONTINUE",DO:"DO",CLASS:"CLASS",EXTENDS:"EXTENDS",SELF:"SELF",NEW:"NEW",INTERFACE:"INTERFACE",IMPLEMENTS:"IMPLEMENTS",PRIVATE:"PRIVATE",PUBLIC:"PUBLIC",PROTECTED:"PROTECTED",READONLY:"READONLY",STATIC:"STATIC",ABSTRACT:"ABSTRACT",OVERRIDE:"OVERRIDE",MATCH:"MATCH",WHEN:"WHEN",IMPORT:"IMPORT",EXPORT:"EXPORT",FROM:"FROM",AS:"AS",DEFAULT:"DEFAULT",AND:"AND",OR:"OR",NOT:"NOT",ASYNC:"ASYNC",AWAIT:"AWAIT",TRY:"TRY",CATCH:"CATCH",FINALLY:"FINALLY",THROW:"THROW",TYPEOF:"TYPEOF",INSTANCEOF:"INSTANCEOF",TYPE:"TYPE",ENUM:"ENUM",SATISFIES:"SATISFIES",IS:"IS",CONST:"CONST",PLUS:"PLUS",MINUS:"MINUS",STAR:"STAR",SLASH:"SLASH",PERCENT:"PERCENT",REGEX:"REGEX",STARSTAR:"STARSTAR",EQ:"EQ",EQEQ:"EQEQ",NEQ:"NEQ",EQEQEQ:"EQEQEQ",NEQEQ:"NEQEQ",LT:"LT",LTE:"LTE",GT:"GT",GTE:"GTE",PLUSEQ:"PLUSEQ",MINUSEQ:"MINUSEQ",STAREQ:"STAREQ",SLASHEQ:"SLASHEQ",PERCENTEQ:"PERCENTEQ",PLUSPLUS:"PLUSPLUS",MINUSMINUS:"MINUSMINUS",AMPERSAND:"AMPERSAND",ANDAND:"ANDAND",PIPEB:"PIPEB",OROR:"OROR",CARET:"CARET",TILDE:"TILDE",LSHIFT:"LSHIFT",RSHIFT:"RSHIFT",ARROW:"ARROW",FATARROW:"FATARROW",PIPE:"PIPE",DOTDOT:"DOTDOT",DOTDOTDOT:"DOTDOTDOT",WILDCARD:"WILDCARD",NULLISH:"NULLISH",QUESTIONDOT:"QUESTIONDOT",BANG:"BANG",AT:"AT",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",QUESTION:"QUESTION",NEWLINE:"NEWLINE",INDENT:"INDENT",DEDENT:"DEDENT",EOF:"EOF"},Lt={var:o.VAR,val:o.VAL,fn:o.FN,return:o.RETURN,declare:o.DECLARE,if:o.IF,else:o.ELSE,for:o.FOR,in:o.IN,while:o.WHILE,break:o.BREAK,continue:o.CONTINUE,do:o.DO,class:o.CLASS,extends:o.EXTENDS,self:o.SELF,new:o.NEW,interface:o.INTERFACE,implements:o.IMPLEMENTS,private:o.PRIVATE,public:o.PUBLIC,protected:o.PROTECTED,readonly:o.READONLY,static:o.STATIC,abstract:o.ABSTRACT,override:o.OVERRIDE,match:o.MATCH,when:o.WHEN,import:o.IMPORT,export:o.EXPORT,from:o.FROM,as:o.AS,default:o.DEFAULT,and:o.AND,or:o.OR,not:o.NOT,async:o.ASYNC,await:o.AWAIT,try:o.TRY,catch:o.CATCH,finally:o.FINALLY,throw:o.THROW,typeof:o.TYPEOF,instanceof:o.INSTANCEOF,type:o.TYPE,enum:o.ENUM,satisfies:o.SATISFIES,is:o.IS,const:o.CONST,true:"__TRUE__",false:"__FALSE__",null:"__NULL__"},kt=class extends Error{constructor(t,e,s){super(t),this.name="LexerError",this.line=e,this.col=s}},Et=class{constructor(t){this.src=t.replace(/\r\n/g,`
|
|
8
8
|
`).replace(/\r/g,`
|
|
9
9
|
`),this.pos=0,this.line=1,this.col=1,this.tokens=[],this.indentStack=[0],this.nestDepth=0}err(t){throw new kt(t,this.line,this.col)}ch(t=0){return this.src[this.pos+t]||""}adv(){let t=this.src[this.pos++];return t===`
|
|
10
10
|
`?(this.line++,this.col=1):this.col++,t}tok(t,e,s,r){this.tokens.push({type:t,value:e!==void 0?e:t,line:s||this.line,col:r||this.col})}applyIndent(t){if(this.nestDepth>0)return;let e=this.indentStack[this.indentStack.length-1];if(t>e)this.indentStack.push(t),this.tok(o.INDENT,t,this.line,1);else if(t<e){for(;this.indentStack.length>1&&this.indentStack[this.indentStack.length-1]>t;)this.indentStack.pop(),this.tok(o.DEDENT,null,this.line,1);this.indentStack[this.indentStack.length-1]!==t&&this.err(`Inconsistent indentation (${t} spaces)`)}}scanBacktick(t,e){this.adv();let s="";for(;this.pos<this.src.length&&this.ch()!=="`";)if(this.ch()==="\\"){this.adv();let l=this.adv();s+={n:`
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
`&&(this.adv(),t=!0);continue}if(this.ch()==="/"&&this.ch(1)==="*"){this.scanBlockComment();continue}if(this.ch()==="|"&&this.ch(1)===">"||this.ch()==="."||this.ch()==="?"&&this.ch(1)==="."){let l=this.tokens[this.tokens.length-1];l&&l.type===o.NEWLINE&&this.tokens.pop()}else this.applyIndent(c)}let s=this.line,r=this.col,a=this.ch();if(a===`
|
|
20
20
|
`){if(this.adv(),t=!0,this.nestDepth===0){let c=this.tokens[this.tokens.length-1];c&&c.type!==o.NEWLINE&&c.type!==o.INDENT&&c.type!==o.DEDENT&&this.tok(o.NEWLINE,null,s,r)}continue}if(a===" "||a===" "){this.adv();continue}if(a==="/"&&this.ch(1)==="/"){for(;this.pos<this.src.length&&this.ch()!==`
|
|
21
21
|
`;)this.adv();continue}if(a==="/"&&this.ch(1)==="*"){this.scanBlockComment();continue}if(a>="0"&&a<="9"){if(a==="0"&&(this.ch(1)==="x"||this.ch(1)==="X")){this.adv(),this.adv();let h="";for(;/[0-9a-fA-F_]/.test(this.ch());){let l=this.adv();l!=="_"&&(h+=l)}this.tok(o.NUMBER,parseInt(h||"0",16),s,r);continue}if(a==="0"&&(this.ch(1)==="b"||this.ch(1)==="B")){this.adv(),this.adv();let h="";for(;/[01_]/.test(this.ch());){let l=this.adv();l!=="_"&&(h+=l)}this.tok(o.NUMBER,parseInt(h||"0",2),s,r);continue}let c="";for(;this.pos<this.src.length&&!(this.ch()==="."&&this.ch(1)===".");)if(this.ch()>="0"&&this.ch()<="9"||this.ch()===".")c+=this.adv();else if(this.ch()==="_")this.adv();else if((this.ch()==="e"||this.ch()==="E")&&c.length>0){for(c+=this.adv(),(this.ch()==="+"||this.ch()==="-")&&(c+=this.adv());this.ch()>="0"&&this.ch()<="9";)c+=this.adv();break}else break;this.tok(o.NUMBER,parseFloat(c),s,r);continue}if(a==='"'){this.scanStr(s,r);continue}if(a==="`"){this.scanBacktick(s,r);continue}if(a==="'"){this.adv();let c="";for(;this.pos<this.src.length&&this.ch()!=="'";)if(this.ch()==="\\"){this.adv();let h=this.adv();if(h==="u"){let l=this.src.slice(this.pos,this.pos+4);this.pos+=4,c+=String.fromCharCode(parseInt(l,16))}else if(h==="x"){let l=this.src.slice(this.pos,this.pos+2);this.pos+=2,c+=String.fromCharCode(parseInt(l,16))}else c+={n:`
|
|
22
|
-
`,t:" ",r:"\r","'":"'","\\":"\\"}[h]||"\\"+h}else c+=this.adv();this.ch()!=="'"&&this.err("Unterminated string"),this.adv(),this.tok(o.STRING,c,s,r);continue}if(a>="a"&&a<="z"||a>="A"&&a<="Z"||a==="_"){let c="";for(;/[a-zA-Z0-9_]/.test(this.ch());)c+=this.adv();if(c==="_"&&!/[a-zA-Z0-9_]/.test(this.ch())){this.tok(o.WILDCARD,"_",s,r);continue}let h=Object.prototype.hasOwnProperty.call(Lt,c)?Lt[c]:void 0;h==="__TRUE__"?this.tok(o.BOOL,!0,s,r):h==="__FALSE__"?this.tok(o.BOOL,!1,s,r):h==="__NULL__"?this.tok(o.NULL,null,s,r):h?this.tok(h,c,s,r):this.tok(o.IDENT,c,s,r);continue}switch(this.adv(),a){case"+":this.ch()==="+"?(this.adv(),this.tok(o.PLUSPLUS,"++",s,r)):this.ch()==="="?(this.adv(),this.tok(o.PLUSEQ,"+=",s,r)):this.tok(o.PLUS,"+",s,r);break;case"-":this.ch()==="-"?(this.adv(),this.tok(o.MINUSMINUS,"--",s,r)):this.ch()===">"?(this.adv(),this.tok(o.ARROW,"->",s,r)):this.ch()==="="?(this.adv(),this.tok(o.MINUSEQ,"-=",s,r)):this.tok(o.MINUS,"-",s,r);break;case"*":this.ch()==="*"?(this.adv(),this.tok(o.STARSTAR,"**",s,r)):this.ch()==="="?(this.adv(),this.tok(o.STAREQ,"*=",s,r)):this.tok(o.STAR,"*",s,r);break;case"/":if(this.ch()==="=")this.adv(),this.tok(o.SLASHEQ,"/=",s,r);else{let c=this.tokens[this.tokens.length-1];c&&(c.type===o.IDENT||c.type===o.NUMBER||c.type===o.STRING||c.type===o.BOOL||c.type===o.NULL||c.type===o.REGEX||c.type===o.RPAREN||c.type===o.RBRACKET||c.type===o.PLUSPLUS||c.type===o.MINUSMINUS||c.type===o.BANG)?this.tok(o.SLASH,"/",s,r):this.scanRegexBody(s,r)}break;case"%":this.ch()==="="?(this.adv(),this.tok(o.PERCENTEQ,"%=",s,r)):this.tok(o.PERCENT,"%",s,r);break;case"=":this.ch()==="="&&this.ch(1)==="="?(this.adv(),this.adv(),this.tok(o.EQEQEQ,"===",s,r)):this.ch()==="="?(this.adv(),this.tok(o.EQEQ,"==",s,r)):this.ch()===">"?(this.adv(),this.tok(o.FATARROW,"=>",s,r)):this.tok(o.EQ,"=",s,r);break;case"!":this.ch()==="="&&this.ch(1)==="="?(this.adv(),this.adv(),this.tok(o.NEQEQ,"!==",s,r)):this.ch()==="="?(this.adv(),this.tok(o.NEQ,"!=",s,r)):this.tok(o.BANG,"!",s,r);break;case"<":this.ch()==="<"?(this.adv(),this.tok(o.LSHIFT,"<<",s,r)):this.ch()==="="?(this.adv(),this.tok(o.LTE,"<=",s,r)):this.tok(o.LT,"<",s,r);break;case">":this.ch()===">"?(this.adv(),this.tok(o.RSHIFT,">>",s,r)):this.ch()==="="?(this.adv(),this.tok(o.GTE,">=",s,r)):this.tok(o.GT,">",s,r);break;case".":this.ch()==="."&&this.ch(1)==="."?(this.adv(),this.adv(),this.tok(o.DOTDOTDOT,"...",s,r)):this.ch()==="."?(this.adv(),this.tok(o.DOTDOT,"..",s,r)):this.tok(o.DOT,".",s,r);break;case"?":this.ch()==="."?(this.adv(),this.tok(o.QUESTIONDOT,"?.",s,r)):this.ch()==="?"?(this.adv(),this.tok(o.NULLISH,"??",s,r)):this.tok(o.QUESTION,"?",s,r);break;case"|":this.ch()===">"?(this.adv(),this.tok(o.PIPE,"|>",s,r)):this.ch()==="|"?(this.adv(),this.tok(o.OROR,"||",s,r)):this.tok(o.PIPEB,"|",s,r);break;case"&":this.ch()==="&"?(this.adv(),this.tok(o.ANDAND,"&&",s,r)):this.tok(o.AMPERSAND,"&",s,r);break;case"^":this.tok(o.CARET,"^",s,r);break;case"~":this.tok(o.TILDE,"~",s,r);break;case"@":this.tok(o.AT,"@",s,r);break;case";":break;case"(":this.nestDepth++,this.tok(o.LPAREN,"(",s,r);break;case")":this.nestDepth--,this.tok(o.RPAREN,")",s,r);break;case"[":this.nestDepth++,this.tok(o.LBRACKET,"[",s,r);break;case"]":this.nestDepth--,this.tok(o.RBRACKET,"]",s,r);break;case"{":this.nestDepth++,this.tok(o.LBRACE,"{",s,r);break;case"}":this.nestDepth--,this.tok(o.RBRACE,"}",s,r);break;case",":this.tok(o.COMMA,",",s,r);break;case":":this.tok(o.COLON,":",s,r);break;default:this.err(`Unknown character: '${a}'`)}}for(;this.indentStack.length>1;)this.indentStack.pop(),this.tok(o.DEDENT,null,this.line,1);let e=this.tokens[this.tokens.length-1];return e&&e.type!==o.NEWLINE&&e.type!==o.DEDENT&&this.tok(o.NEWLINE,null,this.line,this.col),this.tok(o.EOF,null,this.line,this.col),this.tokens}};Ct.exports={Lexer:Et,T:o,TokenType:o}});var et=_((bs,jt)=>{"use strict";var{T:i}=J(),Ft={COLON:'":"',COMMA:'","',DOT:'"."',LPAREN:'"("',RPAREN:'")"',LBRACKET:'"["',RBRACKET:'"]"',LBRACE:'"{"',RBRACE:'"}"',ARROW:'"->"',FATARROW:'"=>"',EQ:'"="',EQEQ:'"=="',NEQ:'"!="',PLUS:'"+"',MINUS:'"-"',STAR:'"*"',SLASH:'"/"',PERCENT:'"%"',STARSTAR:'"**"',LT:'"<"',GT:'">"',LTE:'"<="',GTE:'">="',PIPE:'"|>"',PIPEB:'"|"',DOTDOT:'".."',DOTDOTDOT:'"..."',QUESTION:'"?"',BANG:'"!"',NEWLINE:"end of line",INDENT:"indented block",DEDENT:"end of block",EOF:"end of file",IDENT:"identifier",NUMBER:"number",STRING:"string",BOOL:"true/false",NULL:"null",FN:'"fn"',VAL:'"val"',VAR:'"var"',IF:'"if"',ELSE:'"else"',FOR:'"for"',WHILE:'"while"',IN:'"in"',RETURN:'"return"',CLASS:'"class"',NEW:'"new"',SELF:'"self"',IMPORT:'"import"',FROM:'"from"',EXPORT:'"export"',MATCH:'"match"',WHEN:'"when"',AND:'"and"',OR:'"or"',NOT:'"not"',ASYNC:'"async"',AWAIT:'"await"',TRY:'"try"',CATCH:'"catch"',FINALLY:'"finally"',THROW:'"throw"'};function Bt(n,t){return Ft[n]?Ft[n]:t!=null&&t!==n?`"${t}"`:`"${n.toLowerCase()}"`}var z=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.tok=e,this.line=e?e.line:null,this.col=e?e.col:null}},Ne=["val","var","fn","return","if","else","for","in","while","do","break","continue","match","when","class","extends","self","new","interface","implements","import","export","from","as","default","and","or","not","async","await","try","catch","finally","throw","type","enum","static","abstract","override","readonly","private","public","protected","true","false","null"],Pt={function:{fix:"fn",note:'Flux uses "fn" instead of "function"'},func:{fix:"fn",note:'Flux uses "fn" for functions'},def:{fix:"fn",note:'Flux uses "fn" for functions (not "def" like Python)'},const:{fix:"val",note:'Flux uses "val" for immutable bindings (not "const")'},let:{fix:"var",note:'Flux uses "var" for mutable bindings (not "let")'},elif:{fix:"else if",note:'Flux uses "else if" (not "elif" like Python)'},elsif:{fix:"else if",note:'Flux uses "else if" (not "elsif")'},elseif:{fix:"else if",note:'Flux uses "else if" as two separate keywords'},switch:{fix:"match",note:'Flux uses "match/when" instead of "switch/case"'},case:{fix:"when",note:'Flux uses "when" inside a "match" block'},foreach:{fix:"for ... in",note:'Flux uses "for item in collection:" syntax'},forEach:{fix:"for ... in",note:'Flux uses "for item in collection:" syntax'},lambda:{fix:"fn",note:'Flux uses "fn" or the "->" arrow for inline functions'},struct:{fix:"class",note:'Flux uses "class" for data types (no structs)'},interface:null,print:null,Fn:{fix:"fn",note:"Flux keywords are lowercase"},FN:{fix:"fn",note:"Flux keywords are lowercase"},Val:{fix:"val",note:"Flux keywords are lowercase"},Var:{fix:"var",note:"Flux keywords are lowercase"},If:{fix:"if",note:"Flux keywords are lowercase"},Else:{fix:"else",note:"Flux keywords are lowercase"},For:{fix:"for",note:"Flux keywords are lowercase"},While:{fix:"while",note:"Flux keywords are lowercase"},Return:{fix:"return",note:"Flux keywords are lowercase"},Class:{fix:"class",note:"Flux keywords are lowercase"},Import:{fix:"import",note:"Flux keywords are lowercase"},Export:{fix:"export",note:"Flux keywords are lowercase"},New:{fix:"new",note:"Flux keywords are lowercase"},True:{fix:"true",note:"Flux keywords are lowercase"},False:{fix:"false",note:"Flux keywords are lowercase"},Null:{fix:"null",note:"Flux keywords are lowercase"},Async:{fix:"async",note:"Flux keywords are lowercase"},Await:{fix:"await",note:"Flux keywords are lowercase"},Match:{fix:"match",note:"Flux keywords are lowercase"},Try:{fix:"try",note:"Flux keywords are lowercase"},Catch:{fix:"catch",note:"Flux keywords are lowercase"}};function we(n,t,e=2){if(Math.abs(n.length-t.length)>e)return e+1;let s=n.length,r=t.length,a=new Uint8Array(r+1),c=new Uint8Array(r+1);for(let h=0;h<=r;h++)a[h]=h;for(let h=1;h<=s;h++){c[0]=h;let l=h;for(let p=1;p<=r;p++){let m=n[h-1]===t[p-1]?0:1;c[p]=Math.min(c[p-1]+1,a[p]+1,a[p-1]+m),c[p]<l&&(l=c[p])}if(l>e)return e+1;c.copyWithin(0,0,r+1),a.set(c)}return a[r]}function Mt(n){if(!n||n.length<2)return null;if(Object.prototype.hasOwnProperty.call(Pt,n)){let s=Pt[n];return s?`Did you mean "${s.fix}"? ${s.note}`:null}let t=3,e=null;for(let s of Ne){if(Math.abs(n.length-s.length)>2)continue;let r=we(n.toLowerCase(),s,2);r<t&&(t=r,e=s)}return e&&t<=2&&n!==e?`Did you mean "${e}"?`:null}var dt=class{constructor(t){this.tokens=t,this.pos=0}peek(t=0){return this.tokens[this.pos+t]||{type:i.EOF,value:null,line:0,col:0}}check(t){return this.peek().type===t}at(...t){return t.includes(this.peek().type)}eat(t){let e=this.peek();if(e.type!==t){let s=Bt(t,null),r=Bt(e.type,e.value),a=new z(`Expected ${s} but got ${r}`,e);if(e.type===i.IDENT){let c=Mt(e.value);c&&(a.hint=c)}throw a}return this.pos++,e}maybe(t){return this.check(t)?(this.pos++,!0):!1}skip(){return this.tokens[this.pos++]}skipNewlines(){for(;this.check(i.NEWLINE);)this.pos++}err(t){throw new z(t,this.peek())}parseBlock(){if(this.eat(i.COLON),this.check(i.NEWLINE)){this.pos++,this.eat(i.INDENT);let e=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),e}return[this.parseOneStmt()]}parseIndentedBlock(){this.eat(i.NEWLINE),this.eat(i.INDENT);let t=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),t}parse(){return this.skipNewlines(),{type:"Program",body:this.parseStmtList(()=>this.check(i.EOF))}}parseStmtList(t){let e=[];for(;!t()&&(this.skipNewlines(),!t());)e.push(this.parseOneStmt());return e}parseDecorators(){let t=[];for(;this.check(i.AT);){let e=this.skip(),s=this.eat(i.IDENT).value,r=[];if(this.check(i.LPAREN)){for(this.pos++;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(r.push(this.parseExpr()),!!this.maybe(i.COMMA)););this.eat(i.RPAREN)}t.push({name:s,args:r,loc:e}),this.skipNewlines()}return t}parseOneStmt(){let t=this.check(i.AT)?this.parseDecorators():[],e=this.peek();switch(e.type){case i.VAR:case i.VAL:return this.parseVarDecl();case i.FN:{let s=this.parseFnDecl();return t.length&&(s.decorators=t),s}case i.ASYNC:{let s=this.parseAsyncFn();return t.length&&(s.decorators=t),s}case i.CLASS:{let s=this.parseClassDecl();return t.length&&(s.decorators=t),s}case i.IF:return this.parseIf();case i.FOR:return this.parseFor();case i.WHILE:return this.parseWhile();case i.DO:return this.parseDoWhile();case i.MATCH:return this.parseMatch();case i.RETURN:return this.parseReturn();case i.BREAK:{this.skip();let s=!this.check(i.NEWLINE)&&!this.check(i.EOF)&&this.check(i.IDENT)?this.skip().value:null;return this.skipNewlines(),{type:"BreakStmt",label:s,loc:e}}case i.CONTINUE:{this.skip();let s=!this.check(i.NEWLINE)&&!this.check(i.EOF)&&this.check(i.IDENT)?this.skip().value:null;return this.skipNewlines(),{type:"ContinueStmt",label:s,loc:e}}case i.IMPORT:return this.parseImport();case i.EXPORT:return this.parseExport();case i.TRY:return this.parseTryCatch();case i.THROW:return this.parseThrow();case i.TYPE:return this.parseTypeDecl();case i.INTERFACE:return this.parseInterfaceDecl();case i.ENUM:return this.parseEnumDecl();default:{let s={[i.CONST]:{msg:'"const" is not a Flux keyword',hint:'Did you mean "val"? Flux uses "val" for immutable bindings (not "const")'},[i.TYPEOF]:{msg:'"typeof" is an expression, not a statement'},[i.INSTANCEOF]:{msg:'"instanceof" is an expression, not a statement'},[i.SATISFIES]:{msg:'"satisfies" is a type expression, not a statement'}};if(Object.prototype.hasOwnProperty.call(s,e.type)){let r=s[e.type],a=new z(r.msg,e);throw r.hint&&(a.hint=r.hint),a}if(e.type===i.IDENT&&this.peek(1).type===i.COLON){let r=this.peek(2).type;if(r===i.FOR||r===i.WHILE){let a=this.skip().value;this.pos++;let c=this.parseOneStmt();return{type:"LabeledStmt",label:a,body:c,loc:e}}}if(e.type===i.IDENT){let r=this.peek(1).type;if(!(r===i.DOT||r===i.LPAREN||r===i.LBRACKET||r===i.EQ||r===i.PLUSEQ||r===i.MINUSEQ||r===i.STAREQ||r===i.SLASHEQ||r===i.PERCENTEQ||r===i.ARROW||r===i.FATARROW||r===i.QUESTION||r===i.EQEQ||r===i.NEQ||r===i.AND||r===i.OR||r===i.PIPE)){let c=Mt(e.value);if(c){let h=new z(`Unexpected identifier "${e.value}"`,e);throw h.hint=c,h}}}return this.parseExprStmt()}}}parseVarDecl(){let t=this.peek().type===i.VAR?"var":"val",e=this.skip();if(this.check(i.LBRACE)){let c=this.parseObjectDestructurePattern();this.eat(i.EQ);let h=this.parseExpr();return this.skipNewlines(),{type:"DestructureDecl",kind:t,patternType:"object",pattern:c,init:h,loc:e}}if(this.check(i.LBRACKET)){let c=this.parseArrayDestructurePattern();this.eat(i.EQ);let h=this.parseExpr();return this.skipNewlines(),{type:"DestructureDecl",kind:t,patternType:"array",pattern:c,init:h,loc:e}}let s=this.eat(i.IDENT).value,r=null;this.maybe(i.COLON)&&(r=this.parseTypeAnn());let a=null;return this.maybe(i.EQ)&&(a=this.parseExpr()),this.skipNewlines(),{type:"VarDecl",kind:t,name:s,typeAnn:r,init:a,loc:e}}parseObjectDestructurePattern(){this.eat(i.LBRACE);let t=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value;if(e){t.push({key:s,alias:s,rest:!0});break}let r=s;this.maybe(i.COLON)&&(r=this.eat(i.IDENT).value);let a=null;if(this.maybe(i.EQ)&&(a=this.parseExpr()),t.push({key:s,alias:r,defaultVal:a,rest:!1}),!this.maybe(i.COMMA))break}return this.eat(i.RBRACE),t}parseArrayDestructurePattern(){this.eat(i.LBRACKET);let t=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF);){if(this.check(i.COMMA)){t.push(null),this.pos++;continue}let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value,r=null;if(this.maybe(i.EQ)&&(r=this.parseExpr()),t.push({name:s,defaultVal:r,rest:e}),e||!this.maybe(i.COMMA))break}return this.eat(i.RBRACKET),t}parseTypeAnn(){let t=this._parseIntersectionType();for(;this.check(i.PIPEB);)this.pos++,t+=" | "+this._parseIntersectionType();return t}_parseIntersectionType(){let t=this._parseSingleType();for(;this.check(i.AMPERSAND);)this.pos++,t+=" & "+this._parseSingleType();return t}_parseSingleType(){let t=this.peek();if(t.type===i.LBRACKET){this.pos++;let s=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF)&&(s.push(this.parseTypeAnn()),!!this.maybe(i.COMMA)););return this.eat(i.RBRACKET),"["+s.join(", ")+"]"}if(t.type===i.LBRACE){this.pos++;let s=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let r=!1;if(this.check(i.READONLY)&&(this.pos++,r=!0),this.check(i.LBRACKET)){this.pos++;let a=this.eat(i.IDENT).value;this.eat(i.COLON);let c=this.parseTypeAnn();this.eat(i.RBRACKET),this.eat(i.COLON);let h=this.parseTypeAnn();s.push(`[${a}: ${c}]: ${h}`)}else{let a=this.at(i.IDENT,i.STRING)?this.skip().value:this.eat(i.IDENT).value,c=!1;this.check(i.QUESTION)&&(this.pos++,c=!0),this.eat(i.COLON);let h=this.parseTypeAnn(),l=r?"readonly ":"";s.push(`${l}${a}${c?"?":""}: ${h}`)}this.maybe(i.COMMA)}return this.eat(i.RBRACE),"{ "+s.join(", ")+" }"}if(t.type===i.LPAREN){this.pos++;let s=this.parseTypeAnn();return this.eat(i.RPAREN),"("+s+")"}if(t.type===i.IDENT&&t.value==="keyof")return this.pos++,"keyof "+this._parseSingleType();if(t.type===i.TYPEOF)return this.pos++,"typeof "+this.eat(i.IDENT).value;if(t.type===i.READONLY)return this.pos++,"readonly "+this._parseSingleType();if(t.type===i.IDENT&&t.value==="infer")return this.pos++,"infer "+this.eat(i.IDENT).value;if(t.type===i.FN){this.pos++;let s=[];if(this.check(i.LPAREN)){for(this.pos++;!this.check(i.RPAREN)&&!this.check(i.EOF);){let a;if(this.check(i.IDENT)&&this.peek(1).type===i.COLON?(this.pos+=2,a=this.parseTypeAnn()):a=this.parseTypeAnn(),s.push(a),!this.maybe(i.COMMA))break}this.eat(i.RPAREN)}let r="Void";return this.check(i.ARROW)&&(this.pos++,r=this.parseTypeAnn()),`fn(${s.join(", ")}) -> ${r}`}let e;if(t.type===i.IDENT||t.type===i.CONST||t.type===i.TYPE?e=this.skip().value:e=this.eat(i.IDENT).value,this.check(i.EXTENDS)){this.pos++;let s=this._parseSingleType();this.eat(i.QUESTION);let r=this.parseTypeAnn();this.eat(i.COLON);let a=this.parseTypeAnn();return`${e} extends ${s} ? ${r} : ${a}`}if(this.check(i.LT)){this.pos++;let s=[this._parseGenericArg()];for(;this.maybe(i.COMMA);)s.push(this._parseGenericArg());this.eat(i.GT),e+="<"+s.join(", ")+">"}for(;this.check(i.LBRACKET)&&this.peek(1).type===i.RBRACKET;)this.pos+=2,e+="[]";return this.check(i.QUESTION)&&this.peek(1).type!==i.DOT&&(this.pos++,e+="?"),e}_parseGenericArg(){return this.parseTypeAnn()}_isTypeAnnBeforeColon(){let t=s=>this.tokens[this.pos+s]||{type:i.EOF},e=0;if(t(e).type===i.LBRACKET||t(e).type===i.LBRACE||t(e).type===i.LPAREN){let s=0,r=new Set([i.LBRACKET,i.LBRACE,i.LPAREN,i.LT]),a=new Set([i.RBRACKET,i.RBRACE,i.RPAREN,i.GT]);for(;t(e).type!==i.EOF&&(r.has(t(e).type)&&s++,a.has(t(e).type)&&s--,e++,s!==0););for(t(e).type===i.QUESTION&&e++;t(e).type===i.PIPEB||t(e).type===i.AMPERSAND;){if(e++,t(e).type!==i.IDENT)return!1;e++}return t(e).type===i.COLON}if((t(e).type===i.TYPEOF||t(e).type===i.READONLY||t(e).type===i.IDENT&&(t(e).value==="keyof"||t(e).value==="readonly"))&&e++,t(e).type!==i.IDENT)return!1;if(e++,t(e).type===i.LT){e++;let s=1;for(;t(e).type!==i.EOF&&s>0;)t(e).type===i.LT&&s++,t(e).type===i.GT&&s--,e++}for(;t(e).type===i.LBRACKET&&t(e+1).type===i.RBRACKET;)e+=2;for(t(e).type===i.QUESTION&&e++;t(e).type===i.PIPEB;){if(e++,t(e).type!==i.IDENT)return!1;if(e++,t(e).type===i.LT){e++;let s=1;for(;t(e).type!==i.EOF&&s>0;)t(e).type===i.LT&&s++,t(e).type===i.GT&&s--,e++}for(;t(e).type===i.LBRACKET&&t(e+1).type===i.RBRACKET;)e+=2;t(e).type===i.QUESTION&&e++}return t(e).type===i.COLON}parseTypeDecl(){let t=this.eat(i.TYPE),e=this.eat(i.IDENT).value,s=[];if(this.check(i.LT)){for(this.pos++;!this.check(i.GT)&&!this.check(i.EOF)&&(s.push(this.eat(i.IDENT).value),!!this.maybe(i.COMMA)););this.eat(i.GT)}this.eat(i.EQ);let r=[];for(;;){let a=this.eat(i.IDENT).value,c=[],h={};if(this.check(i.LPAREN)){for(this.eat(i.LPAREN);!this.check(i.RPAREN)&&!this.check(i.EOF);){let l=this.peek(),p;if(l.type===i.IDENT||l.type in i?p=this.skip().value:this.err(`Expected field name, got '${l.type}'`),this.maybe(i.COLON)&&(h[p]=this.parseTypeAnn()),c.push(p),!this.maybe(i.COMMA))break}this.eat(i.RPAREN)}if(r.push({name:a,fields:c,fieldTypes:h}),!this.check(i.PIPEB))break;this.pos++}return this.skipNewlines(),{type:"TypeDecl",name:e,variants:r,loc:t}}_isColonReturnType(){let t=this.pos;try{return this.pos++,this.at(i.IDENT,i.LBRACKET,i.LBRACE,i.LPAREN,i.FN,i.READONLY,i.TYPEOF)?(this.parseTypeAnn(),this.check(i.NEWLINE)||this.check(i.EOF)):!1}catch{return!1}finally{this.pos=t}}parseFnDecl(t=!1){let e=this.eat(i.FN),s=new Set([i.NEW,i.DELETE,i.FROM,i.AS,i.DEFAULT,i.IS,i.IN,i.TYPE]),r=this.check(i.IDENT)||s.has(this.peek().type)?this.skip().value:null,a=this.parseParamList(),c=null;if(this.check(i.ARROW))if(this.pos++,this._isTypeAnnBeforeColon()){c=this.parseTypeAnn();let h=this.parseBlock();return{type:"FnDecl",name:r,params:a,retType:c,body:h,inline:!1,async:t,loc:e}}else{let h=this.parseExpr();return this.skipNewlines(),{type:"FnDecl",name:r,params:a,retType:null,body:h,inline:!0,async:t,loc:e}}if(this.check(i.COLON)){if(this._isColonReturnType()){if(this.pos++,c=this.parseTypeAnn(),this.check(i.NEWLINE)&&this.pos++,this.check(i.INDENT)){this.pos++;let p=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),{type:"FnDecl",name:r,params:a,retType:c,body:p,inline:!1,async:t,loc:e}}let l=this.parseOneStmt();return{type:"FnDecl",name:r,params:a,retType:c,body:[l],inline:!1,async:t,loc:e}}let h=this.parseBlock();return{type:"FnDecl",name:r,params:a,retType:null,body:h,inline:!1,async:t,loc:e}}this.err("Expected -> or : after function signature")}parseAsyncFn(){return this.eat(i.ASYNC),this.check(i.FN)||this.err("Expected fn after async"),this.parseFnDecl(!0)}parseParamList(){this.eat(i.LPAREN);let t=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF);){let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value,r=!1,a=null;!e&&this.check(i.QUESTION)&&(this.pos++,r=!0),!e&&this.maybe(i.COLON)&&(a=this.parseTypeAnn());let c=null;if(!e&&this.maybe(i.EQ)&&(c=this.parseExpr()),t.push({name:s,typeAnn:a,optional:r,defaultVal:c,rest:e}),e||!this.maybe(i.COMMA))break}return this.eat(i.RPAREN),t}parseAccessModifiers(){let t=new Set,e=new Set([i.PRIVATE,i.PUBLIC,i.PROTECTED,i.READONLY,i.STATIC,i.ABSTRACT,i.OVERRIDE]);for(;e.has(this.peek().type);)t.add(this.skip().value);return t}parseClassDecl(){let t=this.eat(i.CLASS),e=this.eat(i.IDENT).value,s=null,r=[],a=[];if(this.check(i.LT)){for(this.pos++,a.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)a.push(this.eat(i.IDENT).value);this.eat(i.GT)}if(this.maybe(i.EXTENDS)&&(s=this.eat(i.IDENT).value),this.maybe(i.IMPLEMENTS))for(r.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)r.push(this.eat(i.IDENT).value);this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let c=[],h=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let l=this.parseAccessModifiers(),p=this.check(i.IDENT)&&(this.peek().value==="get"||this.peek().value==="set")&&(this.peek(1).type===i.IDENT||this.peek(1).type===i.FN),m=this.check(i.FN)&&this.peek(1).type===i.IDENT&&(this.peek(1).value==="get"||this.peek(1).value==="set")&&this.peek(2).type===i.IDENT;if(p&&this.peek(1).type!==i.FN){let y=this.peek(),u=this.skip().value,d=this.eat(i.IDENT).value,g=this.parseParamList(),f=null;this.check(i.ARROW)?(this.pos++,this._isTypeAnnBeforeColon()&&(f=this.parseTypeAnn())):this.check(i.COLON)&&this._isColonReturnType()&&(this.pos++,f=this.parseTypeAnn());let T=this.parseBlock(),x={type:"FnDecl",name:d,params:g,retType:f,body:T,inline:!1,async:!1,modifiers:l,getset:u,loc:y};h.push(x)}else if(this.check(i.FN)){let y=this.parseFnDecl();y.modifiers=l,h.push(y)}else if(this.check(i.ASYNC)){let y=this.parseAsyncFn();y.modifiers=l,h.push(y)}else if(this.check(i.STATIC)&&(this.peek(1).type===i.FN||this.peek(1).type===i.ASYNC)){this.skip();let y=this.check(i.ASYNC)?this.parseAsyncFn():this.parseFnDecl();y.modifiers=l,y.modifiers.add("static"),h.push(y)}else if(this.check(i.VAR)||this.check(i.VAL)){let y=this.skip().type===i.VAR?"var":"val",u=this.eat(i.IDENT).value,d=!1,g=null;this.check(i.QUESTION)&&(this.pos++,d=!0),this.check(i.COLON)&&(this.pos++,g=this.parseTypeAnn());let f=null;this.check(i.EQ)&&(this.pos++,f=this.parseExpr()),this.skipNewlines(),c.push({name:u,typeAnn:g,optional:d,modifiers:l,init:f,fieldKind:y})}else if(this.check(i.IDENT)){let y=this.eat(i.IDENT).value,u=!1;this.check(i.QUESTION)&&(this.pos++,u=!0),this.eat(i.COLON);let d=this.parseTypeAnn();this.skipNewlines(),c.push({name:y,typeAnn:d,optional:u,modifiers:l,init:null})}else this.skip()}return this.maybe(i.DEDENT),{type:"ClassDecl",name:e,typeParams:a,superClass:s,interfaces:r,fields:c,methods:h,loc:t}}parseInterfaceDecl(){let t=this.eat(i.INTERFACE),e=this.eat(i.IDENT).value,s=[];if(this.check(i.LT)){for(this.pos++,s.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)s.push(this.eat(i.IDENT).value);this.eat(i.GT)}let r=[];if(this.maybe(i.EXTENDS))for(r.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)r.push(this.eat(i.IDENT).value);this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let a=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let c=this.parseAccessModifiers();if(this.check(i.ASYNC)){this.pos++,this.eat(i.FN);let h=this.eat(i.IDENT).value,l=this.parseParamList(),p=null;this.maybe(i.ARROW)&&(p=this.parseTypeAnn()),this.skipNewlines(),a.push({kind:"method",name:h,params:l,retType:p,modifiers:c,isAsync:!0})}else if(this.check(i.FN)){this.eat(i.FN);let h=this.eat(i.IDENT).value,l=this.parseParamList(),p=null;this.maybe(i.ARROW)&&(p=this.parseTypeAnn()),this.skipNewlines(),a.push({kind:"method",name:h,params:l,retType:p,modifiers:c,isAsync:!1})}else if(this.check(i.IDENT)){let h=this.eat(i.IDENT).value,l=!1;this.check(i.QUESTION)&&(this.pos++,l=!0),this.eat(i.COLON);let p=this.parseTypeAnn();this.skipNewlines(),a.push({kind:"field",name:h,typeAnn:p,optional:l,modifiers:c})}else this.skip()}return this.maybe(i.DEDENT),{type:"InterfaceDecl",name:e,typeParams:s,superInterfaces:r,members:a,loc:t}}parseEnumDecl(){let t=this.eat(i.ENUM),e=this.eat(i.IDENT).value;this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let s=[],r=0;for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let a=this.eat(i.IDENT).value,c=null;this.maybe(i.EQ)?(c=this.parseExpr(),c.type==="NumberLit"&&(r=c.value)):c={type:"NumberLit",value:r},r++,this.skipNewlines(),s.push({name:a,value:c})}return this.maybe(i.DEDENT),{type:"EnumDecl",name:e,members:s,loc:t}}parseIf(){let t=this.eat(i.IF),e=this.parseExpr(),s=this.parseBlock(),r=[],a=null;for(this.skipNewlines();this.check(i.ELSE);)if(this.pos++,this.check(i.IF)){this.pos++;let c=this.parseExpr(),h=this.parseBlock();r.push({cond:c,body:h}),this.skipNewlines()}else{a=this.parseBlock();break}return{type:"IfStmt",cond:e,then:s,elseifs:r,else_:a,loc:t}}parseFor(){let t=this.eat(i.FOR),e=!1;this.check(i.AWAIT)&&(this.pos++,e=!0);let s,r=null;if(this.check(i.LBRACKET)){this.pos++;let h=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF);){if(this.check(i.DOTDOTDOT)){this.pos++,h.push({rest:!0,name:this.eat(i.IDENT).value});break}if(h.push({name:this.eat(i.IDENT).value}),!this.maybe(i.COMMA))break}this.eat(i.RBRACKET),s="__item__",r={type:"array",names:h}}else s=this.eat(i.IDENT).value;this.check(i.IN)?this.pos++:this.check(i.IDENT)&&this.peek().value==="of"?(this.pos++,e=e):this.eat(i.IN);let a=this.parseExpr(),c=this.parseBlock();return{type:"ForInStmt",var:s,varPattern:r,iter:a,body:c,isAwait:e,loc:t}}parseWhile(){let t=this.eat(i.WHILE),e=this.parseExpr(),s=this.parseBlock();return{type:"WhileStmt",cond:e,body:s,loc:t}}parseDoWhile(){let t=this.eat(i.DO),e=this.parseBlock();this.skipNewlines(),this.eat(i.WHILE);let s=this.parseExpr();return this.skipNewlines(),{type:"DoWhileStmt",body:e,cond:s,loc:t}}parseMatch(){let t=this.eat(i.MATCH),e=this.parseExpr();this.eat(i.COLON),this.check(i.NEWLINE)&&this.pos++,this.eat(i.INDENT);let s=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){this.eat(i.WHEN);let r=this.parsePattern(),a=null;if(this.check(i.IF)&&(this.pos++,a=this.parseExpr()),this.check(i.ARROW)){this.pos++;let c=this.parseExpr();this.skipNewlines(),s.push({pattern:r,guard:a,body:[{type:"ExprStmt",expr:c}],inline:!0})}else if(this.check(i.COLON)){let c=this.peek(1).type!==i.NEWLINE,h=this.parseBlock();s.push({pattern:r,guard:a,body:h,inline:c&&h.length===1&&h[0].type==="ExprStmt"})}}return this.maybe(i.DEDENT),{type:"MatchStmt",subject:e,arms:s,loc:t}}parsePattern(){if(this.check(i.WILDCARD))return this.skip(),{type:"WildcardPat"};if(this.check(i.IDENT)&&this.peek(1).type===i.LPAREN){let e=this.eat(i.IDENT).value;this.eat(i.LPAREN);let s=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(this.check(i.WILDCARD)?(s.push("_"),this.pos++):s.push(this.eat(i.IDENT).value),!!this.maybe(i.COMMA)););return this.eat(i.RPAREN),{type:"VariantPat",variant:e,bindings:s}}let t=this.parsePrimary();for(;this.check(i.DOT);){this.pos++;let e=this.skip().value;t={type:"MemberExpr",obj:t,prop:e}}if(this.check(i.DOTDOT)){this.pos++;let e=this.parsePrimary();return{type:"RangePat",start:t,end:e}}return{type:"LiteralPat",value:t}}parseReturn(){let t=this.eat(i.RETURN),e=null;return this.at(i.NEWLINE,i.EOF,i.DEDENT)||(e=this.parseExpr()),this.skipNewlines(),{type:"ReturnStmt",value:e,loc:t}}parseTryCatch(){let t=this.eat(i.TRY),e=this.parseBlock(),s=null,r=null,a=null;return this.skipNewlines(),this.check(i.CATCH)&&(this.pos++,this.check(i.LPAREN)&&(this.pos++,s=this.eat(i.IDENT).value,this.maybe(i.COLON)&&this.parseTypeAnn(),this.eat(i.RPAREN)),r=this.parseBlock(),this.skipNewlines()),this.check(i.FINALLY)&&(this.pos++,a=this.parseBlock()),{type:"TryCatchStmt",tryBody:e,catchParam:s,catchBody:r,finallyBody:a,loc:t}}parseThrow(){let t=this.eat(i.THROW),e=this.parseExpr();return this.skipNewlines(),{type:"ThrowStmt",value:e,loc:t}}parseImport(){if(this.eat(i.IMPORT),this.check(i.STAR)){this.pos++,this.eat(i.AS);let s=this.eat(i.IDENT).value;this.eat(i.FROM);let r=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:[],defaultName:null,namespaceName:s,source:r}}if(this.check(i.IDENT)){let s=this.eat(i.IDENT).value;this.eat(i.FROM);let r=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:[],defaultName:s,source:r}}let t=[];if(this.maybe(i.LBRACE)){for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let s=this.eat(i.IDENT).value,r=s;if(this.check(i.AS)&&(this.pos++,r=this.eat(i.IDENT).value),t.push({name:s,alias:r}),!this.maybe(i.COMMA))break}this.eat(i.RBRACE)}this.eat(i.FROM);let e=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:t,defaultName:null,source:e}}parseExport(){if(this.eat(i.EXPORT),this.check(i.DEFAULT)&&(this.peek(1).type===i.FN||this.peek(1).type===i.ASYNC))return this.pos++,{type:"ExportDecl",isDefault:!0,decl:this.check(i.ASYNC)?(this.pos++,this.parseFnDecl(!0)):this.parseFnDecl()};if(this.check(i.DEFAULT)){this.pos++;let e=this.parseExpr();return this.skipNewlines(),{type:"ExportDecl",isDefault:!0,decl:e}}return this.check(i.ASYNC)?(this.pos++,this.check(i.FN)||this.err("Expected fn after async"),{type:"ExportDecl",isDefault:!1,decl:this.parseFnDecl(!0)}):{type:"ExportDecl",isDefault:!1,decl:this.parseOneStmt()}}parseExprStmt(){let t=this.parseExpr();return this.skipNewlines(),{type:"ExprStmt",expr:t}}parseExpr(){return this.parsePipe()}parsePipe(){let t=this.parseAssign();for(;;)if(this.check(i.PIPE)){this.pos++;let e=this.parseAssign();t={type:"PipeExpr",left:t,right:e}}else if(this.check(i.NEWLINE)){let e=1;for(;this.peek(e).type===i.NEWLINE;)e++;if(this.peek(e).type===i.PIPE){for(;this.check(i.NEWLINE);)this.pos++;this.pos++;let s=this.parseAssign();t={type:"PipeExpr",left:t,right:s}}else break}else break;return t}parseAssign(){let t=this.parseTernary(),s={[i.EQ]:"=",[i.PLUSEQ]:"+=",[i.MINUSEQ]:"-=",[i.STAREQ]:"*=",[i.SLASHEQ]:"/=",[i.PERCENTEQ]:"%="}[this.peek().type];return s?(this.pos++,{type:"AssignExpr",target:t,op:s,value:this.parseAssign()}):t}parseTernary(){let t=this.parseNullish();if(this.maybe(i.QUESTION)){let e=this.parseNullish();this.eat(i.COLON);let s=this.parseTernary();return{type:"TernaryExpr",cond:t,then:e,else_:s}}return t}parseNullish(){let t=this.parseOr();for(;this.check(i.NULLISH);){this.pos++;let e=this.parseOr();t={type:"BinaryExpr",op:"??",left:t,right:e}}return t}parseOr(){let t=this.parseAnd();for(;this.check(i.OR)||this.check(i.OROR);){this.pos++;let e=this.parseAnd();t={type:"BinaryExpr",op:"||",left:t,right:e}}return t}parseAnd(){let t=this.parseBitOr();for(;this.check(i.AND)||this.check(i.ANDAND);){this.pos++;let e=this.parseBitOr();t={type:"BinaryExpr",op:"&&",left:t,right:e}}return t}parseBitOr(){let t=this.parseBitXor();for(;this.check(i.PIPEB);){this.pos++;let e=this.parseBitXor();t={type:"BinaryExpr",op:"|",left:t,right:e}}return t}parseBitXor(){let t=this.parseBitAnd();for(;this.check(i.CARET);){this.pos++;let e=this.parseBitAnd();t={type:"BinaryExpr",op:"^",left:t,right:e}}return t}parseBitAnd(){let t=this.parseEq();for(;this.check(i.AMPERSAND);){this.pos++;let e=this.parseEq();t={type:"BinaryExpr",op:"&",left:t,right:e}}return t}parseEq(){let t=this.parseRel();for(;this.at(i.EQEQ,i.NEQ,i.EQEQEQ,i.NEQEQ);){let e=this.skip().value,s=this.parseRel();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseRel(){let t=this.parseShift();for(;this.at(i.LT,i.LTE,i.GT,i.GTE)||this.check(i.IN);){let e=this.skip().value,s=this.parseShift();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseShift(){let t=this.parseRange();for(;this.at(i.LSHIFT,i.RSHIFT);){let e=this.skip().value,s=this.parseRange();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseRange(){let t=this.parseAdd();if(this.check(i.DOTDOT)){this.pos++;let e=this.parseAdd();return{type:"RangeExpr",start:t,end:e}}return t}parseAdd(){let t=this.parseMul();for(;this.at(i.PLUS,i.MINUS);){let e=this.skip().value,s=this.parseMul();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseMul(){let t=this.parsePow();for(;this.at(i.STAR,i.SLASH,i.PERCENT);){let e=this.skip().value,s=this.parsePow();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parsePow(){let t=this.parseUnary();return this.check(i.STARSTAR)?(this.pos++,{type:"BinaryExpr",op:"**",left:t,right:this.parsePow()}):t}parseUnary(){return this.check(i.MINUS)?(this.pos++,{type:"UnaryExpr",op:"-",operand:this.parseUnary()}):this.check(i.NOT)?(this.pos++,{type:"UnaryExpr",op:"!",operand:this.parseUnary()}):this.check(i.BANG)?(this.pos++,{type:"UnaryExpr",op:"!",operand:this.parseUnary()}):this.check(i.TILDE)?(this.pos++,{type:"UnaryExpr",op:"~",operand:this.parseUnary()}):this.check(i.PLUSPLUS)?(this.pos++,{type:"UpdateExpr",op:"++",prefix:!0,operand:this.parseUnary()}):this.check(i.MINUSMINUS)?(this.pos++,{type:"UpdateExpr",op:"--",prefix:!0,operand:this.parseUnary()}):this.check(i.AWAIT)?(this.pos++,{type:"AwaitExpr",operand:this.parseUnary()}):this.check(i.TYPEOF)?(this.pos++,{type:"TypeofExpr",operand:this.parseUnary()}):this.check(i.IDENT)&&this.tokens[this.pos].value==="delete"?(this.pos++,{type:"UnaryExpr",op:"delete ",operand:this.parseUnary()}):this.parseLambdaOrPostfix()}parseLambdaOrPostfix(){let t=this.pos;if(this.check(i.IDENT)||this.check(i.WILDCARD)){let e=this.skip().value??"_";if(this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let r=this.parseIndentedBlock();return{type:"LambdaExpr",params:[{name:e}],body:r,block:!0}}let s=this.parseExpr();return{type:"LambdaExpr",params:[{name:e}],body:s}}this.pos=t}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();t:for(;;)if(this.check(i.PLUSPLUS))this.pos++,t={type:"UpdateExpr",op:"++",prefix:!1,operand:t};else if(this.check(i.MINUSMINUS))this.pos++,t={type:"UpdateExpr",op:"--",prefix:!1,operand:t};else if(this.check(i.DOT)){this.pos++;let e=this.peek();e.type!==i.IDENT&&!(e.type in i)&&this.err(`Expected property name, got '${e.type}'`);let s=this.skip().value;t={type:"MemberExpr",obj:t,prop:s}}else if(this.check(i.QUESTIONDOT))if(this.pos++,this.check(i.LPAREN)){let e=this.parseArgList();t={type:"OptCallExpr",callee:t,args:e}}else if(this.check(i.LBRACKET)){this.pos++;let e=this.parseExpr();this.eat(i.RBRACKET),t={type:"OptIndexExpr",obj:t,idx:e}}else{let e=this.peek();e.type!==i.IDENT&&!(e.type in i)&&this.err(`Expected property name, got '${e.type}'`);let s=this.skip().value;t={type:"OptMemberExpr",obj:t,prop:s}}else if(this.check(i.INSTANCEOF)){this.pos++;let e=this.eat(i.IDENT).value;t={type:"BinaryExpr",op:"instanceof",left:t,right:{type:"Identifier",name:e}}}else if(this.check(i.AS))if(this.pos++,this.check(i.CONST))this.pos++,t={type:"AsConstExpr",expr:t};else{let e=this.parseTypeAnn();t={type:"CastExpr",expr:t,castType:e}}else if(this.check(i.SATISFIES)){this.pos++;let e=this.parseTypeAnn();t={type:"SatisfiesExpr",expr:t,satType:e}}else if(this.check(i.IS)){this.pos++;let e=this.parseTypeAnn();t={type:"IsExpr",expr:t,isType:e}}else if(this.check(i.BANG))this.pos++,t={type:"NonNullExpr",expr:t};else if(this.check(i.LBRACKET)){this.pos++;let e=this.parseExpr();this.eat(i.RBRACKET),t={type:"IndexExpr",obj:t,idx:e}}else if(this.check(i.LPAREN)){let e=this.parseArgList();if(this.check(i.ARROW)){this.pos++;let s=this.parseExpr();return{type:"LambdaExpr",params:e.map(a=>({name:a.type==="Identifier"?a.name:"_"})),body:s}}t={type:"CallExpr",callee:t,args:e}}else break t;return t}parseArgList(){this.eat(i.LPAREN);let t=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(this.check(i.DOTDOTDOT)?(this.pos++,t.push({type:"SpreadExpr",expr:this.parseExpr()})):t.push(this.parseExpr()),!!this.maybe(i.COMMA)););return this.eat(i.RPAREN),t}parsePrimary(){let t=this.peek();switch(t.type){case i.NUMBER:return this.pos++,{type:"NumberLit",value:t.value,loc:t};case i.BOOL:return this.pos++,{type:"BoolLit",value:t.value,loc:t};case i.NULL:return this.pos++,{type:"NullLit",loc:t};case i.SELF:return this.pos++,{type:"SelfExpr",loc:t};case i.WILDCARD:return this.pos++,{type:"Identifier",name:"_",loc:t};case i.IDENT:return this.pos++,{type:"Identifier",name:t.value,loc:t};case i.STRING:return this.pos++,t.value&&t.value.template?{type:"TemplateLit",parts:t.value.parts,loc:t}:{type:"StringLit",value:t.value,loc:t};case i.REGEX:return this.pos++,{type:"RegexLit",value:t.value,loc:t};case i.NEW:{this.pos++;let e=this.eat(i.IDENT).value,s=this.parseArgList();return{type:"NewExpr",callee:e,args:s}}case i.FN:{this.pos++;let e=this.parseParamList();if(this.check(i.ARROW)){if(this.pos++,this._isTypeAnnBeforeColon()){let r=this.parseTypeAnn(),a=this.parseBlock();return{type:"FnDecl",name:null,params:e,retType:r,body:a,inline:!1,async:!1,loc:t}}let s=this.parseExpr();return{type:"FnDecl",name:null,params:e,retType:null,body:s,inline:!0,async:!1,loc:t}}if(this.check(i.COLON)){let s=this.parseBlock();return{type:"FnDecl",name:null,params:e,retType:null,body:s,inline:!1,async:!1,loc:t}}this.err("Expected -> or : after anonymous fn")}case i.MATCH:return this.parseMatch();case i.LPAREN:{if(this.pos++,this.check(i.RPAREN)){if(this.pos++,this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let a=this.parseIndentedBlock();return{type:"LambdaExpr",params:[],body:a,block:!0}}let r=this.parseExpr();return{type:"LambdaExpr",params:[],body:r}}return{type:"NullLit"}}let e=this.parseExpr();if(this.check(i.RPAREN)){if(this.pos++,this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let c=this.parseIndentedBlock();return{type:"LambdaExpr",params:[{name:e.type==="Identifier"?e.name:"_"}],body:c,block:!0}}let r=this.parseExpr();return{type:"LambdaExpr",params:[{name:e.type==="Identifier"?e.name:"_"}],body:r}}return e}let s=[e];for(;this.maybe(i.COMMA);)s.push(this.parseExpr());if(this.eat(i.RPAREN),this.check(i.ARROW)){this.pos++;let r=s.map(c=>({name:c.type==="Identifier"?c.name:"_"}));if(this.check(i.NEWLINE)){let c=this.parseIndentedBlock();return{type:"LambdaExpr",params:r,body:c,block:!0}}let a=this.parseExpr();return{type:"LambdaExpr",params:r,body:a}}return s.length>1&&this.err(`Unexpected comma in expression \u2014 did you mean a lambda? Write (${s.map((r,a)=>"p"+a).join(", ")}) -> expr`),s[0]}case i.LBRACKET:{this.pos++;let e=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF)&&(this.check(i.DOTDOTDOT)?(this.pos++,e.push({type:"SpreadExpr",expr:this.parseExpr()})):e.push(this.parseExpr()),!!this.maybe(i.COMMA)););return this.eat(i.RBRACKET),{type:"ArrayExpr",items:e}}case i.LBRACE:{this.pos++;let e=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){if(this.check(i.DOTDOTDOT)){if(this.pos++,e.push({spread:!0,value:this.parseExpr()}),!this.maybe(i.COMMA))break;continue}if(this.check(i.LBRACKET)){this.pos++;let r=this.parseExpr();this.eat(i.RBRACKET),this.eat(i.COLON);let a=this.parseExpr();if(e.push({computed:!0,keyExpr:r,value:a}),!this.maybe(i.COMMA))break;continue}let s=this.check(i.STRING)?this.eat(i.STRING).value:this.check(i.IDENT)?this.eat(i.IDENT).value:this.skip().value;if(!this.check(i.COLON))e.push({key:s,value:{type:"Identifier",name:s}});else{this.eat(i.COLON);let r=this.parseExpr();e.push({key:s,value:r})}if(!this.maybe(i.COMMA))break}return this.eat(i.RBRACE),{type:"ObjectExpr",pairs:e}}default:this.err(`Unexpected token: ${t.type} (${JSON.stringify(t.value)})`)}}};jt.exports={Parser:dt,ParseError:z}});var xt=_((Ns,Ut)=>{"use strict";function Se(n){let t=n.lastIndexOf(":");if(t<1)return null;let e=n.slice(t+1).trim();return e.length>0&&/[.<>^,dbeEfFgGoOxXs%bcn]/.test(e)&&/^([.<>^0\-+ #,]*[0-9]*\.?[0-9]*[dbeEfFgGoOxXs%bcn]?[,]?)$/.test(e)?{expr:n.slice(0,t).trim(),fmt:e}:null}var Ae=`
|
|
22
|
+
`,t:" ",r:"\r","'":"'","\\":"\\"}[h]||"\\"+h}else c+=this.adv();this.ch()!=="'"&&this.err("Unterminated string"),this.adv(),this.tok(o.STRING,c,s,r);continue}if(a>="a"&&a<="z"||a>="A"&&a<="Z"||a==="_"){let c="";for(;/[a-zA-Z0-9_]/.test(this.ch());)c+=this.adv();if(c==="_"&&!/[a-zA-Z0-9_]/.test(this.ch())){this.tok(o.WILDCARD,"_",s,r);continue}let h=Object.prototype.hasOwnProperty.call(Lt,c)?Lt[c]:void 0;h==="__TRUE__"?this.tok(o.BOOL,!0,s,r):h==="__FALSE__"?this.tok(o.BOOL,!1,s,r):h==="__NULL__"?this.tok(o.NULL,null,s,r):h?this.tok(h,c,s,r):this.tok(o.IDENT,c,s,r);continue}switch(this.adv(),a){case"+":this.ch()==="+"?(this.adv(),this.tok(o.PLUSPLUS,"++",s,r)):this.ch()==="="?(this.adv(),this.tok(o.PLUSEQ,"+=",s,r)):this.tok(o.PLUS,"+",s,r);break;case"-":this.ch()==="-"?(this.adv(),this.tok(o.MINUSMINUS,"--",s,r)):this.ch()===">"?(this.adv(),this.tok(o.ARROW,"->",s,r)):this.ch()==="="?(this.adv(),this.tok(o.MINUSEQ,"-=",s,r)):this.tok(o.MINUS,"-",s,r);break;case"*":this.ch()==="*"?(this.adv(),this.tok(o.STARSTAR,"**",s,r)):this.ch()==="="?(this.adv(),this.tok(o.STAREQ,"*=",s,r)):this.tok(o.STAR,"*",s,r);break;case"/":if(this.ch()==="=")this.adv(),this.tok(o.SLASHEQ,"/=",s,r);else{let c=this.tokens[this.tokens.length-1];c&&(c.type===o.IDENT||c.type===o.NUMBER||c.type===o.STRING||c.type===o.BOOL||c.type===o.NULL||c.type===o.REGEX||c.type===o.RPAREN||c.type===o.RBRACKET||c.type===o.PLUSPLUS||c.type===o.MINUSMINUS||c.type===o.BANG)?this.tok(o.SLASH,"/",s,r):this.scanRegexBody(s,r)}break;case"%":this.ch()==="="?(this.adv(),this.tok(o.PERCENTEQ,"%=",s,r)):this.tok(o.PERCENT,"%",s,r);break;case"=":this.ch()==="="&&this.ch(1)==="="?(this.adv(),this.adv(),this.tok(o.EQEQEQ,"===",s,r)):this.ch()==="="?(this.adv(),this.tok(o.EQEQ,"==",s,r)):this.ch()===">"?(this.adv(),this.tok(o.FATARROW,"=>",s,r)):this.tok(o.EQ,"=",s,r);break;case"!":this.ch()==="="&&this.ch(1)==="="?(this.adv(),this.adv(),this.tok(o.NEQEQ,"!==",s,r)):this.ch()==="="?(this.adv(),this.tok(o.NEQ,"!=",s,r)):this.tok(o.BANG,"!",s,r);break;case"<":this.ch()==="<"?(this.adv(),this.tok(o.LSHIFT,"<<",s,r)):this.ch()==="="?(this.adv(),this.tok(o.LTE,"<=",s,r)):this.tok(o.LT,"<",s,r);break;case">":this.ch()===">"?(this.adv(),this.tok(o.RSHIFT,">>",s,r)):this.ch()==="="?(this.adv(),this.tok(o.GTE,">=",s,r)):this.tok(o.GT,">",s,r);break;case".":this.ch()==="."&&this.ch(1)==="."?(this.adv(),this.adv(),this.tok(o.DOTDOTDOT,"...",s,r)):this.ch()==="."?(this.adv(),this.tok(o.DOTDOT,"..",s,r)):this.tok(o.DOT,".",s,r);break;case"?":this.ch()==="."?(this.adv(),this.tok(o.QUESTIONDOT,"?.",s,r)):this.ch()==="?"?(this.adv(),this.tok(o.NULLISH,"??",s,r)):this.tok(o.QUESTION,"?",s,r);break;case"|":this.ch()===">"?(this.adv(),this.tok(o.PIPE,"|>",s,r)):this.ch()==="|"?(this.adv(),this.tok(o.OROR,"||",s,r)):this.tok(o.PIPEB,"|",s,r);break;case"&":this.ch()==="&"?(this.adv(),this.tok(o.ANDAND,"&&",s,r)):this.tok(o.AMPERSAND,"&",s,r);break;case"^":this.tok(o.CARET,"^",s,r);break;case"~":this.tok(o.TILDE,"~",s,r);break;case"@":this.tok(o.AT,"@",s,r);break;case";":break;case"(":this.nestDepth++,this.tok(o.LPAREN,"(",s,r);break;case")":this.nestDepth--,this.tok(o.RPAREN,")",s,r);break;case"[":this.nestDepth++,this.tok(o.LBRACKET,"[",s,r);break;case"]":this.nestDepth--,this.tok(o.RBRACKET,"]",s,r);break;case"{":this.nestDepth++,this.tok(o.LBRACE,"{",s,r);break;case"}":this.nestDepth--,this.tok(o.RBRACE,"}",s,r);break;case",":this.tok(o.COMMA,",",s,r);break;case":":this.tok(o.COLON,":",s,r);break;default:this.err(`Unknown character: '${a}'`)}}for(;this.indentStack.length>1;)this.indentStack.pop(),this.tok(o.DEDENT,null,this.line,1);let e=this.tokens[this.tokens.length-1];return e&&e.type!==o.NEWLINE&&e.type!==o.DEDENT&&this.tok(o.NEWLINE,null,this.line,this.col),this.tok(o.EOF,null,this.line,this.col),this.tokens}};Ct.exports={Lexer:Et,T:o,TokenType:o}});var et=_((bs,jt)=>{"use strict";var{T:i}=J(),Ft={COLON:'":"',COMMA:'","',DOT:'"."',LPAREN:'"("',RPAREN:'")"',LBRACKET:'"["',RBRACKET:'"]"',LBRACE:'"{"',RBRACE:'"}"',ARROW:'"->"',FATARROW:'"=>"',EQ:'"="',EQEQ:'"=="',NEQ:'"!="',PLUS:'"+"',MINUS:'"-"',STAR:'"*"',SLASH:'"/"',PERCENT:'"%"',STARSTAR:'"**"',LT:'"<"',GT:'">"',LTE:'"<="',GTE:'">="',PIPE:'"|>"',PIPEB:'"|"',DOTDOT:'".."',DOTDOTDOT:'"..."',QUESTION:'"?"',BANG:'"!"',NEWLINE:"end of line",INDENT:"indented block",DEDENT:"end of block",EOF:"end of file",IDENT:"identifier",NUMBER:"number",STRING:"string",BOOL:"true/false",NULL:"null",FN:'"fn"',VAL:'"val"',VAR:'"var"',IF:'"if"',ELSE:'"else"',FOR:'"for"',WHILE:'"while"',IN:'"in"',RETURN:'"return"',CLASS:'"class"',NEW:'"new"',SELF:'"self"',IMPORT:'"import"',FROM:'"from"',EXPORT:'"export"',MATCH:'"match"',WHEN:'"when"',AND:'"and"',OR:'"or"',NOT:'"not"',ASYNC:'"async"',AWAIT:'"await"',TRY:'"try"',CATCH:'"catch"',FINALLY:'"finally"',THROW:'"throw"'};function Bt(n,t){return Ft[n]?Ft[n]:t!=null&&t!==n?`"${t}"`:`"${n.toLowerCase()}"`}var z=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.tok=e,this.line=e?e.line:null,this.col=e?e.col:null}},Ne=["val","var","fn","return","if","else","for","in","while","do","break","continue","match","when","class","extends","self","new","interface","implements","import","export","from","as","default","and","or","not","async","await","try","catch","finally","throw","type","enum","static","abstract","override","readonly","private","public","protected","true","false","null"],Pt={function:{fix:"fn",note:'Flux uses "fn" instead of "function"'},func:{fix:"fn",note:'Flux uses "fn" for functions'},def:{fix:"fn",note:'Flux uses "fn" for functions (not "def" like Python)'},const:{fix:"val",note:'Flux uses "val" for immutable bindings (not "const")'},let:{fix:"var",note:'Flux uses "var" for mutable bindings (not "let")'},elif:{fix:"else if",note:'Flux uses "else if" (not "elif" like Python)'},elsif:{fix:"else if",note:'Flux uses "else if" (not "elsif")'},elseif:{fix:"else if",note:'Flux uses "else if" as two separate keywords'},switch:{fix:"match",note:'Flux uses "match/when" instead of "switch/case"'},case:{fix:"when",note:'Flux uses "when" inside a "match" block'},foreach:{fix:"for ... in",note:'Flux uses "for item in collection:" syntax'},forEach:{fix:"for ... in",note:'Flux uses "for item in collection:" syntax'},lambda:{fix:"fn",note:'Flux uses "fn" or the "->" arrow for inline functions'},struct:{fix:"class",note:'Flux uses "class" for data types (no structs)'},interface:null,print:null,Fn:{fix:"fn",note:"Flux keywords are lowercase"},FN:{fix:"fn",note:"Flux keywords are lowercase"},Val:{fix:"val",note:"Flux keywords are lowercase"},Var:{fix:"var",note:"Flux keywords are lowercase"},If:{fix:"if",note:"Flux keywords are lowercase"},Else:{fix:"else",note:"Flux keywords are lowercase"},For:{fix:"for",note:"Flux keywords are lowercase"},While:{fix:"while",note:"Flux keywords are lowercase"},Return:{fix:"return",note:"Flux keywords are lowercase"},Class:{fix:"class",note:"Flux keywords are lowercase"},Import:{fix:"import",note:"Flux keywords are lowercase"},Export:{fix:"export",note:"Flux keywords are lowercase"},New:{fix:"new",note:"Flux keywords are lowercase"},True:{fix:"true",note:"Flux keywords are lowercase"},False:{fix:"false",note:"Flux keywords are lowercase"},Null:{fix:"null",note:"Flux keywords are lowercase"},Async:{fix:"async",note:"Flux keywords are lowercase"},Await:{fix:"await",note:"Flux keywords are lowercase"},Match:{fix:"match",note:"Flux keywords are lowercase"},Try:{fix:"try",note:"Flux keywords are lowercase"},Catch:{fix:"catch",note:"Flux keywords are lowercase"}};function we(n,t,e=2){if(Math.abs(n.length-t.length)>e)return e+1;let s=n.length,r=t.length,a=new Uint8Array(r+1),c=new Uint8Array(r+1);for(let h=0;h<=r;h++)a[h]=h;for(let h=1;h<=s;h++){c[0]=h;let l=h;for(let p=1;p<=r;p++){let m=n[h-1]===t[p-1]?0:1;c[p]=Math.min(c[p-1]+1,a[p]+1,a[p-1]+m),c[p]<l&&(l=c[p])}if(l>e)return e+1;c.copyWithin(0,0,r+1),a.set(c)}return a[r]}function Mt(n){if(!n||n.length<2)return null;if(Object.prototype.hasOwnProperty.call(Pt,n)){let s=Pt[n];return s?`Did you mean "${s.fix}"? ${s.note}`:null}let t=3,e=null;for(let s of Ne){if(Math.abs(n.length-s.length)>2)continue;let r=we(n.toLowerCase(),s,2);r<t&&(t=r,e=s)}return e&&t<=2&&n!==e?`Did you mean "${e}"?`:null}var dt=class{constructor(t){this.tokens=t,this.pos=0}peek(t=0){return this.tokens[this.pos+t]||{type:i.EOF,value:null,line:0,col:0}}check(t){return this.peek().type===t}at(...t){return t.includes(this.peek().type)}eat(t){let e=this.peek();if(e.type!==t){let s=Bt(t,null),r=Bt(e.type,e.value),a=new z(`Expected ${s} but got ${r}`,e);if(e.type===i.IDENT){let c=Mt(e.value);c&&(a.hint=c)}throw a}return this.pos++,e}maybe(t){return this.check(t)?(this.pos++,!0):!1}skip(){return this.tokens[this.pos++]}skipNewlines(){for(;this.check(i.NEWLINE);)this.pos++}err(t){throw new z(t,this.peek())}parseBlock(){if(this.eat(i.COLON),this.check(i.NEWLINE)){this.pos++,this.eat(i.INDENT);let e=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),e}return[this.parseOneStmt()]}parseIndentedBlock(){this.eat(i.NEWLINE),this.eat(i.INDENT);let t=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),t}parse(){return this.skipNewlines(),{type:"Program",body:this.parseStmtList(()=>this.check(i.EOF))}}parseStmtList(t){let e=[];for(;!t()&&(this.skipNewlines(),!t());)e.push(this.parseOneStmt());return e}parseDecorators(){let t=[];for(;this.check(i.AT);){let e=this.skip(),s=this.eat(i.IDENT).value,r=[];if(this.check(i.LPAREN)){for(this.pos++;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(r.push(this.parseExpr()),!!this.maybe(i.COMMA)););this.eat(i.RPAREN)}t.push({name:s,args:r,loc:e}),this.skipNewlines()}return t}parseOneStmt(){let t=this.check(i.AT)?this.parseDecorators():[],e=this.peek();switch(e.type){case i.VAR:case i.VAL:return this.parseVarDecl();case i.FN:{let s=this.parseFnDecl();return t.length&&(s.decorators=t),s}case i.ASYNC:{let s=this.parseAsyncFn();return t.length&&(s.decorators=t),s}case i.CLASS:{let s=this.parseClassDecl();return t.length&&(s.decorators=t),s}case i.DECLARE:return this.parseDeclareDecl();case i.IF:return this.parseIf();case i.FOR:return this.parseFor();case i.WHILE:return this.parseWhile();case i.DO:return this.parseDoWhile();case i.MATCH:return this.parseMatch();case i.RETURN:return this.parseReturn();case i.BREAK:{this.skip();let s=!this.check(i.NEWLINE)&&!this.check(i.EOF)&&this.check(i.IDENT)?this.skip().value:null;return this.skipNewlines(),{type:"BreakStmt",label:s,loc:e}}case i.CONTINUE:{this.skip();let s=!this.check(i.NEWLINE)&&!this.check(i.EOF)&&this.check(i.IDENT)?this.skip().value:null;return this.skipNewlines(),{type:"ContinueStmt",label:s,loc:e}}case i.IMPORT:return this.parseImport();case i.EXPORT:return this.parseExport();case i.TRY:return this.parseTryCatch();case i.THROW:return this.parseThrow();case i.TYPE:return this.parseTypeDecl();case i.INTERFACE:return this.parseInterfaceDecl();case i.ENUM:return this.parseEnumDecl();default:{let s={[i.CONST]:{msg:'"const" is not a Flux keyword',hint:'Did you mean "val"? Flux uses "val" for immutable bindings (not "const")'},[i.TYPEOF]:{msg:'"typeof" is an expression, not a statement'},[i.INSTANCEOF]:{msg:'"instanceof" is an expression, not a statement'},[i.SATISFIES]:{msg:'"satisfies" is a type expression, not a statement'}};if(Object.prototype.hasOwnProperty.call(s,e.type)){let r=s[e.type],a=new z(r.msg,e);throw r.hint&&(a.hint=r.hint),a}if(e.type===i.IDENT&&this.peek(1).type===i.COLON){let r=this.peek(2).type;if(r===i.FOR||r===i.WHILE){let a=this.skip().value;this.pos++;let c=this.parseOneStmt();return{type:"LabeledStmt",label:a,body:c,loc:e}}}if(e.type===i.IDENT){let r=this.peek(1).type;if(!(r===i.DOT||r===i.LPAREN||r===i.LBRACKET||r===i.EQ||r===i.PLUSEQ||r===i.MINUSEQ||r===i.STAREQ||r===i.SLASHEQ||r===i.PERCENTEQ||r===i.ARROW||r===i.FATARROW||r===i.QUESTION||r===i.EQEQ||r===i.NEQ||r===i.AND||r===i.OR||r===i.PIPE)){let c=Mt(e.value);if(c){let h=new z(`Unexpected identifier "${e.value}"`,e);throw h.hint=c,h}}}return this.parseExprStmt()}}}parseVarDecl(){let t=this.peek().type===i.VAR?"var":"val",e=this.skip();if(this.check(i.LBRACE)){let c=this.parseObjectDestructurePattern();this.eat(i.EQ);let h=this.parseExpr();return this.skipNewlines(),{type:"DestructureDecl",kind:t,patternType:"object",pattern:c,init:h,loc:e}}if(this.check(i.LBRACKET)){let c=this.parseArrayDestructurePattern();this.eat(i.EQ);let h=this.parseExpr();return this.skipNewlines(),{type:"DestructureDecl",kind:t,patternType:"array",pattern:c,init:h,loc:e}}let s=this.eat(i.IDENT).value,r=null;this.maybe(i.COLON)&&(r=this.parseTypeAnn());let a=null;return this.maybe(i.EQ)&&(a=this.parseExpr()),this.skipNewlines(),{type:"VarDecl",kind:t,name:s,typeAnn:r,init:a,loc:e}}parseObjectDestructurePattern(){this.eat(i.LBRACE);let t=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value;if(e){t.push({key:s,alias:s,rest:!0});break}let r=s;this.maybe(i.COLON)&&(r=this.eat(i.IDENT).value);let a=null;if(this.maybe(i.EQ)&&(a=this.parseExpr()),t.push({key:s,alias:r,defaultVal:a,rest:!1}),!this.maybe(i.COMMA))break}return this.eat(i.RBRACE),t}parseArrayDestructurePattern(){this.eat(i.LBRACKET);let t=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF);){if(this.check(i.COMMA)){t.push(null),this.pos++;continue}let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value,r=null;if(this.maybe(i.EQ)&&(r=this.parseExpr()),t.push({name:s,defaultVal:r,rest:e}),e||!this.maybe(i.COMMA))break}return this.eat(i.RBRACKET),t}parseTypeAnn(){let t=this._parseIntersectionType();for(;this.check(i.PIPEB);)this.pos++,t+=" | "+this._parseIntersectionType();return t}_parseIntersectionType(){let t=this._parseSingleType();for(;this.check(i.AMPERSAND);)this.pos++,t+=" & "+this._parseSingleType();return t}_parseSingleType(){let t=this.peek();if(t.type===i.LBRACKET){this.pos++;let s=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF)&&(s.push(this.parseTypeAnn()),!!this.maybe(i.COMMA)););return this.eat(i.RBRACKET),"["+s.join(", ")+"]"}if(t.type===i.LBRACE){this.pos++;let s=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let r=!1;if(this.check(i.READONLY)&&(this.pos++,r=!0),this.check(i.LBRACKET)){this.pos++;let a=this.eat(i.IDENT).value;this.eat(i.COLON);let c=this.parseTypeAnn();this.eat(i.RBRACKET),this.eat(i.COLON);let h=this.parseTypeAnn();s.push(`[${a}: ${c}]: ${h}`)}else{let a=this.at(i.IDENT,i.STRING)?this.skip().value:this.eat(i.IDENT).value,c=!1;this.check(i.QUESTION)&&(this.pos++,c=!0),this.eat(i.COLON);let h=this.parseTypeAnn(),l=r?"readonly ":"";s.push(`${l}${a}${c?"?":""}: ${h}`)}this.maybe(i.COMMA)}return this.eat(i.RBRACE),"{ "+s.join(", ")+" }"}if(t.type===i.LPAREN){this.pos++;let s=this.parseTypeAnn();return this.eat(i.RPAREN),"("+s+")"}if(t.type===i.IDENT&&t.value==="keyof")return this.pos++,"keyof "+this._parseSingleType();if(t.type===i.TYPEOF)return this.pos++,"typeof "+this.eat(i.IDENT).value;if(t.type===i.READONLY)return this.pos++,"readonly "+this._parseSingleType();if(t.type===i.IDENT&&t.value==="infer")return this.pos++,"infer "+this.eat(i.IDENT).value;if(t.type===i.FN){this.pos++;let s=[];if(this.check(i.LPAREN)){for(this.pos++;!this.check(i.RPAREN)&&!this.check(i.EOF);){let a;if(this.check(i.IDENT)&&this.peek(1).type===i.COLON?(this.pos+=2,a=this.parseTypeAnn()):a=this.parseTypeAnn(),s.push(a),!this.maybe(i.COMMA))break}this.eat(i.RPAREN)}let r="Void";return this.check(i.ARROW)&&(this.pos++,r=this.parseTypeAnn()),`fn(${s.join(", ")}) -> ${r}`}let e;if(t.type===i.IDENT||t.type===i.CONST||t.type===i.TYPE?e=this.skip().value:e=this.eat(i.IDENT).value,this.check(i.EXTENDS)){this.pos++;let s=this._parseSingleType();this.eat(i.QUESTION);let r=this.parseTypeAnn();this.eat(i.COLON);let a=this.parseTypeAnn();return`${e} extends ${s} ? ${r} : ${a}`}if(this.check(i.LT)){this.pos++;let s=[this._parseGenericArg()];for(;this.maybe(i.COMMA);)s.push(this._parseGenericArg());this.eat(i.GT),e+="<"+s.join(", ")+">"}for(;this.check(i.LBRACKET)&&this.peek(1).type===i.RBRACKET;)this.pos+=2,e+="[]";return this.check(i.QUESTION)&&this.peek(1).type!==i.DOT&&(this.pos++,e+="?"),e}_parseGenericArg(){return this.parseTypeAnn()}_isTypeAnnBeforeColon(){let t=s=>this.tokens[this.pos+s]||{type:i.EOF},e=0;if(t(e).type===i.LBRACKET||t(e).type===i.LBRACE||t(e).type===i.LPAREN){let s=0,r=new Set([i.LBRACKET,i.LBRACE,i.LPAREN,i.LT]),a=new Set([i.RBRACKET,i.RBRACE,i.RPAREN,i.GT]);for(;t(e).type!==i.EOF&&(r.has(t(e).type)&&s++,a.has(t(e).type)&&s--,e++,s!==0););for(t(e).type===i.QUESTION&&e++;t(e).type===i.PIPEB||t(e).type===i.AMPERSAND;){if(e++,t(e).type!==i.IDENT)return!1;e++}return t(e).type===i.COLON}if((t(e).type===i.TYPEOF||t(e).type===i.READONLY||t(e).type===i.IDENT&&(t(e).value==="keyof"||t(e).value==="readonly"))&&e++,t(e).type!==i.IDENT)return!1;if(e++,t(e).type===i.LT){e++;let s=1;for(;t(e).type!==i.EOF&&s>0;)t(e).type===i.LT&&s++,t(e).type===i.GT&&s--,e++}for(;t(e).type===i.LBRACKET&&t(e+1).type===i.RBRACKET;)e+=2;for(t(e).type===i.QUESTION&&e++;t(e).type===i.PIPEB;){if(e++,t(e).type!==i.IDENT)return!1;if(e++,t(e).type===i.LT){e++;let s=1;for(;t(e).type!==i.EOF&&s>0;)t(e).type===i.LT&&s++,t(e).type===i.GT&&s--,e++}for(;t(e).type===i.LBRACKET&&t(e+1).type===i.RBRACKET;)e+=2;t(e).type===i.QUESTION&&e++}return t(e).type===i.COLON}parseTypeDecl(){let t=this.eat(i.TYPE),e=this.eat(i.IDENT).value,s=[];if(this.check(i.LT)){for(this.pos++;!this.check(i.GT)&&!this.check(i.EOF)&&(s.push(this.eat(i.IDENT).value),!!this.maybe(i.COMMA)););this.eat(i.GT)}this.eat(i.EQ);let r=[];for(;;){let a=this.eat(i.IDENT).value,c=[],h={};if(this.check(i.LPAREN)){for(this.eat(i.LPAREN);!this.check(i.RPAREN)&&!this.check(i.EOF);){let l=this.peek(),p;if(l.type===i.IDENT||l.type in i?p=this.skip().value:this.err(`Expected field name, got '${l.type}'`),this.maybe(i.COLON)&&(h[p]=this.parseTypeAnn()),c.push(p),!this.maybe(i.COMMA))break}this.eat(i.RPAREN)}if(r.push({name:a,fields:c,fieldTypes:h}),!this.check(i.PIPEB))break;this.pos++}return this.skipNewlines(),{type:"TypeDecl",name:e,variants:r,loc:t}}_isColonReturnType(){let t=this.pos;try{return this.pos++,this.at(i.IDENT,i.LBRACKET,i.LBRACE,i.LPAREN,i.FN,i.READONLY,i.TYPEOF)?(this.parseTypeAnn(),this.check(i.NEWLINE)||this.check(i.EOF)):!1}catch{return!1}finally{this.pos=t}}parseFnDecl(t=!1){let e=this.eat(i.FN),s=new Set([i.NEW,i.DELETE,i.FROM,i.AS,i.DEFAULT,i.IS,i.IN,i.TYPE]),r=this.check(i.IDENT)||s.has(this.peek().type)?this.skip().value:null,a=this.parseParamList(),c=null;if(this.check(i.ARROW))if(this.pos++,this._isTypeAnnBeforeColon()){c=this.parseTypeAnn();let h=this.parseBlock();return{type:"FnDecl",name:r,params:a,retType:c,body:h,inline:!1,async:t,loc:e}}else{let h=this.parseExpr();return this.skipNewlines(),{type:"FnDecl",name:r,params:a,retType:null,body:h,inline:!0,async:t,loc:e}}if(this.check(i.COLON)){if(this._isColonReturnType()){if(this.pos++,c=this.parseTypeAnn(),this.check(i.NEWLINE)&&this.pos++,this.check(i.INDENT)){this.pos++;let p=this.parseStmtList(()=>this.check(i.DEDENT)||this.check(i.EOF));return this.maybe(i.DEDENT),{type:"FnDecl",name:r,params:a,retType:c,body:p,inline:!1,async:t,loc:e}}let l=this.parseOneStmt();return{type:"FnDecl",name:r,params:a,retType:c,body:[l],inline:!1,async:t,loc:e}}let h=this.parseBlock();return{type:"FnDecl",name:r,params:a,retType:null,body:h,inline:!1,async:t,loc:e}}this.err("Expected -> or : after function signature")}parseDeclareDecl(){let t=this.eat(i.DECLARE),e=this.peek();if(e.type===i.FN||e.type===i.ASYNC){let s=e.type===i.ASYNC;this.skip(),s&&this.eat(i.FN);let r=new Set([i.NEW,i.DELETE,i.FROM,i.AS,i.DEFAULT,i.IS,i.IN,i.TYPE]),a=this.check(i.IDENT)||r.has(this.peek().type)?this.skip().value:null,c=this.parseParamList(),h=null;return this.check(i.ARROW)?(this.pos++,h=this.parseTypeAnn()):this.check(i.COLON)&&(this.pos++,h=this.parseTypeAnn()),this.skipNewlines(),{type:"DeclareDecl",decl:{type:"FnDecl",name:a,params:c,retType:h,body:[],inline:!1,async:s,loc:e},loc:t}}if(e.type===i.VAL||e.type===i.VAR){let s=e.type===i.VAR?"var":"val";this.skip();let r=this.eat(i.IDENT).value,a=null;return this.maybe(i.COLON)&&(a=this.parseTypeAnn()),this.skipNewlines(),{type:"DeclareDecl",decl:{type:"VarDecl",kind:s,name:r,typeAnn:a,init:null,loc:e},loc:t}}if(e.type===i.CLASS){this.skip();let s=this.eat(i.IDENT).value;return this.skipNewlines(),{type:"DeclareDecl",decl:{type:"ClassDecl",name:s,fields:[],methods:[],loc:e},loc:t}}this.err("Expected fn, async fn, val, var, or class after declare")}parseAsyncFn(){return this.eat(i.ASYNC),this.check(i.FN)||this.err("Expected fn after async"),this.parseFnDecl(!0)}parseParamList(){this.eat(i.LPAREN);let t=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF);){let e=!1;this.check(i.DOTDOTDOT)&&(this.pos++,e=!0);let s=this.eat(i.IDENT).value,r=!1,a=null;!e&&this.check(i.QUESTION)&&(this.pos++,r=!0),!e&&this.maybe(i.COLON)&&(a=this.parseTypeAnn());let c=null;if(!e&&this.maybe(i.EQ)&&(c=this.parseExpr()),t.push({name:s,typeAnn:a,optional:r,defaultVal:c,rest:e}),e||!this.maybe(i.COMMA))break}return this.eat(i.RPAREN),t}parseAccessModifiers(){let t=new Set,e=new Set([i.PRIVATE,i.PUBLIC,i.PROTECTED,i.READONLY,i.STATIC,i.ABSTRACT,i.OVERRIDE]);for(;e.has(this.peek().type);)t.add(this.skip().value);return t}parseClassDecl(){let t=this.eat(i.CLASS),e=this.eat(i.IDENT).value,s=null,r=[],a=[];if(this.check(i.LT)){for(this.pos++,a.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)a.push(this.eat(i.IDENT).value);this.eat(i.GT)}if(this.maybe(i.EXTENDS)&&(s=this.eat(i.IDENT).value),this.maybe(i.IMPLEMENTS))for(r.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)r.push(this.eat(i.IDENT).value);this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let c=[],h=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let l=this.parseAccessModifiers(),p=this.check(i.IDENT)&&(this.peek().value==="get"||this.peek().value==="set")&&(this.peek(1).type===i.IDENT||this.peek(1).type===i.FN),m=this.check(i.FN)&&this.peek(1).type===i.IDENT&&(this.peek(1).value==="get"||this.peek(1).value==="set")&&this.peek(2).type===i.IDENT;if(p&&this.peek(1).type!==i.FN){let y=this.peek(),u=this.skip().value,d=this.eat(i.IDENT).value,g=this.parseParamList(),f=null;this.check(i.ARROW)?(this.pos++,this._isTypeAnnBeforeColon()&&(f=this.parseTypeAnn())):this.check(i.COLON)&&this._isColonReturnType()&&(this.pos++,f=this.parseTypeAnn());let T=this.parseBlock(),b={type:"FnDecl",name:d,params:g,retType:f,body:T,inline:!1,async:!1,modifiers:l,getset:u,loc:y};h.push(b)}else if(this.check(i.FN)){let y=this.parseFnDecl();y.modifiers=l,h.push(y)}else if(this.check(i.ASYNC)){let y=this.parseAsyncFn();y.modifiers=l,h.push(y)}else if(this.check(i.STATIC)&&(this.peek(1).type===i.FN||this.peek(1).type===i.ASYNC)){this.skip();let y=this.check(i.ASYNC)?this.parseAsyncFn():this.parseFnDecl();y.modifiers=l,y.modifiers.add("static"),h.push(y)}else if(this.check(i.VAR)||this.check(i.VAL)){let y=this.skip().type===i.VAR?"var":"val",u=this.eat(i.IDENT).value,d=!1,g=null;this.check(i.QUESTION)&&(this.pos++,d=!0),this.check(i.COLON)&&(this.pos++,g=this.parseTypeAnn());let f=null;this.check(i.EQ)&&(this.pos++,f=this.parseExpr()),this.skipNewlines(),c.push({name:u,typeAnn:g,optional:d,modifiers:l,init:f,fieldKind:y})}else if(this.check(i.IDENT)){let y=this.eat(i.IDENT).value,u=!1;this.check(i.QUESTION)&&(this.pos++,u=!0),this.eat(i.COLON);let d=this.parseTypeAnn();this.skipNewlines(),c.push({name:y,typeAnn:d,optional:u,modifiers:l,init:null})}else this.skip()}return this.maybe(i.DEDENT),{type:"ClassDecl",name:e,typeParams:a,superClass:s,interfaces:r,fields:c,methods:h,loc:t}}parseInterfaceDecl(){let t=this.eat(i.INTERFACE),e=this.eat(i.IDENT).value,s=[];if(this.check(i.LT)){for(this.pos++,s.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)s.push(this.eat(i.IDENT).value);this.eat(i.GT)}let r=[];if(this.maybe(i.EXTENDS))for(r.push(this.eat(i.IDENT).value);this.maybe(i.COMMA);)r.push(this.eat(i.IDENT).value);this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let a=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let c=this.parseAccessModifiers();if(this.check(i.ASYNC)){this.pos++,this.eat(i.FN);let h=this.eat(i.IDENT).value,l=this.parseParamList(),p=null;this.maybe(i.ARROW)&&(p=this.parseTypeAnn()),this.skipNewlines(),a.push({kind:"method",name:h,params:l,retType:p,modifiers:c,isAsync:!0})}else if(this.check(i.FN)){this.eat(i.FN);let h=this.eat(i.IDENT).value,l=this.parseParamList(),p=null;this.maybe(i.ARROW)&&(p=this.parseTypeAnn()),this.skipNewlines(),a.push({kind:"method",name:h,params:l,retType:p,modifiers:c,isAsync:!1})}else if(this.check(i.IDENT)){let h=this.eat(i.IDENT).value,l=!1;this.check(i.QUESTION)&&(this.pos++,l=!0),this.eat(i.COLON);let p=this.parseTypeAnn();this.skipNewlines(),a.push({kind:"field",name:h,typeAnn:p,optional:l,modifiers:c})}else this.skip()}return this.maybe(i.DEDENT),{type:"InterfaceDecl",name:e,typeParams:s,superInterfaces:r,members:a,loc:t}}parseEnumDecl(){let t=this.eat(i.ENUM),e=this.eat(i.IDENT).value;this.eat(i.COLON),this.check(i.NEWLINE)&&(this.pos++,this.eat(i.INDENT));let s=[],r=0;for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){let a=this.eat(i.IDENT).value,c=null;this.maybe(i.EQ)?(c=this.parseExpr(),c.type==="NumberLit"&&(r=c.value)):c={type:"NumberLit",value:r},r++,this.skipNewlines(),s.push({name:a,value:c})}return this.maybe(i.DEDENT),{type:"EnumDecl",name:e,members:s,loc:t}}parseIf(){let t=this.eat(i.IF),e=this.parseExpr(),s=this.parseBlock(),r=[],a=null;for(this.skipNewlines();this.check(i.ELSE);)if(this.pos++,this.check(i.IF)){this.pos++;let c=this.parseExpr(),h=this.parseBlock();r.push({cond:c,body:h}),this.skipNewlines()}else{a=this.parseBlock();break}return{type:"IfStmt",cond:e,then:s,elseifs:r,else_:a,loc:t}}parseFor(){let t=this.eat(i.FOR),e=!1;this.check(i.AWAIT)&&(this.pos++,e=!0);let s,r=null;if(this.check(i.LBRACKET)){this.pos++;let h=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF);){if(this.check(i.DOTDOTDOT)){this.pos++,h.push({rest:!0,name:this.eat(i.IDENT).value});break}if(h.push({name:this.eat(i.IDENT).value}),!this.maybe(i.COMMA))break}this.eat(i.RBRACKET),s="__item__",r={type:"array",names:h}}else s=this.eat(i.IDENT).value;this.check(i.IN)?this.pos++:this.check(i.IDENT)&&this.peek().value==="of"?(this.pos++,e=e):this.eat(i.IN);let a=this.parseExpr(),c=this.parseBlock();return{type:"ForInStmt",var:s,varPattern:r,iter:a,body:c,isAwait:e,loc:t}}parseWhile(){let t=this.eat(i.WHILE),e=this.parseExpr(),s=this.parseBlock();return{type:"WhileStmt",cond:e,body:s,loc:t}}parseDoWhile(){let t=this.eat(i.DO),e=this.parseBlock();this.skipNewlines(),this.eat(i.WHILE);let s=this.parseExpr();return this.skipNewlines(),{type:"DoWhileStmt",body:e,cond:s,loc:t}}parseMatch(){let t=this.eat(i.MATCH),e=this.parseExpr();this.eat(i.COLON),this.check(i.NEWLINE)&&this.pos++,this.eat(i.INDENT);let s=[];for(;!this.check(i.DEDENT)&&!this.check(i.EOF)&&(this.skipNewlines(),!(this.check(i.DEDENT)||this.check(i.EOF)));){this.eat(i.WHEN);let r=this.parsePattern(),a=null;if(this.check(i.IF)&&(this.pos++,a=this.parseExpr()),this.check(i.ARROW)){this.pos++;let c=this.parseExpr();this.skipNewlines(),s.push({pattern:r,guard:a,body:[{type:"ExprStmt",expr:c}],inline:!0})}else if(this.check(i.COLON)){let c=this.peek(1).type!==i.NEWLINE,h=this.parseBlock();s.push({pattern:r,guard:a,body:h,inline:c&&h.length===1&&h[0].type==="ExprStmt"})}}return this.maybe(i.DEDENT),{type:"MatchStmt",subject:e,arms:s,loc:t}}parsePattern(){if(this.check(i.WILDCARD))return this.skip(),{type:"WildcardPat"};if(this.check(i.IDENT)&&this.peek(1).type===i.LPAREN){let e=this.eat(i.IDENT).value;this.eat(i.LPAREN);let s=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(this.check(i.WILDCARD)?(s.push("_"),this.pos++):s.push(this.eat(i.IDENT).value),!!this.maybe(i.COMMA)););return this.eat(i.RPAREN),{type:"VariantPat",variant:e,bindings:s}}let t=this.parsePrimary();for(;this.check(i.DOT);){this.pos++;let e=this.skip().value;t={type:"MemberExpr",obj:t,prop:e}}if(this.check(i.DOTDOT)){this.pos++;let e=this.parsePrimary();return{type:"RangePat",start:t,end:e}}return{type:"LiteralPat",value:t}}parseReturn(){let t=this.eat(i.RETURN),e=null;return this.at(i.NEWLINE,i.EOF,i.DEDENT)||(e=this.parseExpr()),this.skipNewlines(),{type:"ReturnStmt",value:e,loc:t}}parseTryCatch(){let t=this.eat(i.TRY),e=this.parseBlock(),s=null,r=null,a=null;return this.skipNewlines(),this.check(i.CATCH)&&(this.pos++,this.check(i.LPAREN)&&(this.pos++,s=this.eat(i.IDENT).value,this.maybe(i.COLON)&&this.parseTypeAnn(),this.eat(i.RPAREN)),r=this.parseBlock(),this.skipNewlines()),this.check(i.FINALLY)&&(this.pos++,a=this.parseBlock()),{type:"TryCatchStmt",tryBody:e,catchParam:s,catchBody:r,finallyBody:a,loc:t}}parseThrow(){let t=this.eat(i.THROW),e=this.parseExpr();return this.skipNewlines(),{type:"ThrowStmt",value:e,loc:t}}parseImport(){if(this.eat(i.IMPORT),this.check(i.STAR)){this.pos++,this.eat(i.AS);let s=this.eat(i.IDENT).value;this.eat(i.FROM);let r=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:[],defaultName:null,namespaceName:s,source:r}}if(this.check(i.IDENT)){let s=this.eat(i.IDENT).value;this.eat(i.FROM);let r=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:[],defaultName:s,source:r}}let t=[];if(this.maybe(i.LBRACE)){for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){let s=this.eat(i.IDENT).value,r=s;if(this.check(i.AS)&&(this.pos++,r=this.eat(i.IDENT).value),t.push({name:s,alias:r}),!this.maybe(i.COMMA))break}this.eat(i.RBRACE)}this.eat(i.FROM);let e=this.eat(i.STRING).value;return this.skipNewlines(),{type:"ImportDecl",names:t,defaultName:null,source:e}}parseExport(){if(this.eat(i.EXPORT),this.check(i.DEFAULT)&&(this.peek(1).type===i.FN||this.peek(1).type===i.ASYNC))return this.pos++,{type:"ExportDecl",isDefault:!0,decl:this.check(i.ASYNC)?(this.pos++,this.parseFnDecl(!0)):this.parseFnDecl()};if(this.check(i.DEFAULT)){this.pos++;let e=this.parseExpr();return this.skipNewlines(),{type:"ExportDecl",isDefault:!0,decl:e}}return this.check(i.ASYNC)?(this.pos++,this.check(i.FN)||this.err("Expected fn after async"),{type:"ExportDecl",isDefault:!1,decl:this.parseFnDecl(!0)}):{type:"ExportDecl",isDefault:!1,decl:this.parseOneStmt()}}parseExprStmt(){let t=this.parseExpr();return this.skipNewlines(),{type:"ExprStmt",expr:t}}parseExpr(){return this.parsePipe()}parsePipe(){let t=this.parseAssign();for(;;)if(this.check(i.PIPE)){this.pos++;let e=this.parseAssign();t={type:"PipeExpr",left:t,right:e}}else if(this.check(i.NEWLINE)){let e=1;for(;this.peek(e).type===i.NEWLINE;)e++;if(this.peek(e).type===i.PIPE){for(;this.check(i.NEWLINE);)this.pos++;this.pos++;let s=this.parseAssign();t={type:"PipeExpr",left:t,right:s}}else break}else break;return t}parseAssign(){let t=this.parseTernary(),s={[i.EQ]:"=",[i.PLUSEQ]:"+=",[i.MINUSEQ]:"-=",[i.STAREQ]:"*=",[i.SLASHEQ]:"/=",[i.PERCENTEQ]:"%="}[this.peek().type];return s?(this.pos++,{type:"AssignExpr",target:t,op:s,value:this.parseAssign()}):t}parseTernary(){let t=this.parseNullish();if(this.maybe(i.QUESTION)){let e=this.parseNullish();this.eat(i.COLON);let s=this.parseTernary();return{type:"TernaryExpr",cond:t,then:e,else_:s}}return t}parseNullish(){let t=this.parseOr();for(;this.check(i.NULLISH);){this.pos++;let e=this.parseOr();t={type:"BinaryExpr",op:"??",left:t,right:e}}return t}parseOr(){let t=this.parseAnd();for(;this.check(i.OR)||this.check(i.OROR);){this.pos++;let e=this.parseAnd();t={type:"BinaryExpr",op:"||",left:t,right:e}}return t}parseAnd(){let t=this.parseBitOr();for(;this.check(i.AND)||this.check(i.ANDAND);){this.pos++;let e=this.parseBitOr();t={type:"BinaryExpr",op:"&&",left:t,right:e}}return t}parseBitOr(){let t=this.parseBitXor();for(;this.check(i.PIPEB);){this.pos++;let e=this.parseBitXor();t={type:"BinaryExpr",op:"|",left:t,right:e}}return t}parseBitXor(){let t=this.parseBitAnd();for(;this.check(i.CARET);){this.pos++;let e=this.parseBitAnd();t={type:"BinaryExpr",op:"^",left:t,right:e}}return t}parseBitAnd(){let t=this.parseEq();for(;this.check(i.AMPERSAND);){this.pos++;let e=this.parseEq();t={type:"BinaryExpr",op:"&",left:t,right:e}}return t}parseEq(){let t=this.parseRel();for(;this.at(i.EQEQ,i.NEQ,i.EQEQEQ,i.NEQEQ);){let e=this.skip().value,s=this.parseRel();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseRel(){let t=this.parseShift();for(;this.at(i.LT,i.LTE,i.GT,i.GTE)||this.check(i.IN);){let e=this.skip().value,s=this.parseShift();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseShift(){let t=this.parseRange();for(;this.at(i.LSHIFT,i.RSHIFT);){let e=this.skip().value,s=this.parseRange();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseRange(){let t=this.parseAdd();if(this.check(i.DOTDOT)){this.pos++;let e=this.parseAdd();return{type:"RangeExpr",start:t,end:e}}return t}parseAdd(){let t=this.parseMul();for(;this.at(i.PLUS,i.MINUS);){let e=this.skip().value,s=this.parseMul();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parseMul(){let t=this.parsePow();for(;this.at(i.STAR,i.SLASH,i.PERCENT);){let e=this.skip().value,s=this.parsePow();t={type:"BinaryExpr",op:e,left:t,right:s}}return t}parsePow(){let t=this.parseUnary();return this.check(i.STARSTAR)?(this.pos++,{type:"BinaryExpr",op:"**",left:t,right:this.parsePow()}):t}parseUnary(){return this.check(i.MINUS)?(this.pos++,{type:"UnaryExpr",op:"-",operand:this.parseUnary()}):this.check(i.NOT)?(this.pos++,{type:"UnaryExpr",op:"!",operand:this.parseUnary()}):this.check(i.BANG)?(this.pos++,{type:"UnaryExpr",op:"!",operand:this.parseUnary()}):this.check(i.TILDE)?(this.pos++,{type:"UnaryExpr",op:"~",operand:this.parseUnary()}):this.check(i.PLUSPLUS)?(this.pos++,{type:"UpdateExpr",op:"++",prefix:!0,operand:this.parseUnary()}):this.check(i.MINUSMINUS)?(this.pos++,{type:"UpdateExpr",op:"--",prefix:!0,operand:this.parseUnary()}):this.check(i.AWAIT)?(this.pos++,{type:"AwaitExpr",operand:this.parseUnary()}):this.check(i.TYPEOF)?(this.pos++,{type:"TypeofExpr",operand:this.parseUnary()}):this.check(i.IDENT)&&this.tokens[this.pos].value==="delete"?(this.pos++,{type:"UnaryExpr",op:"delete ",operand:this.parseUnary()}):this.parseLambdaOrPostfix()}parseLambdaOrPostfix(){let t=this.pos;if(this.check(i.IDENT)||this.check(i.WILDCARD)){let e=this.skip().value??"_";if(this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let r=this.parseIndentedBlock();return{type:"LambdaExpr",params:[{name:e}],body:r,block:!0}}let s=this.parseExpr();return{type:"LambdaExpr",params:[{name:e}],body:s}}this.pos=t}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();t:for(;;)if(this.check(i.PLUSPLUS))this.pos++,t={type:"UpdateExpr",op:"++",prefix:!1,operand:t};else if(this.check(i.MINUSMINUS))this.pos++,t={type:"UpdateExpr",op:"--",prefix:!1,operand:t};else if(this.check(i.DOT)){this.pos++;let e=this.peek();e.type!==i.IDENT&&!(e.type in i)&&this.err(`Expected property name, got '${e.type}'`);let s=this.skip().value;t={type:"MemberExpr",obj:t,prop:s}}else if(this.check(i.QUESTIONDOT))if(this.pos++,this.check(i.LPAREN)){let e=this.parseArgList();t={type:"OptCallExpr",callee:t,args:e}}else if(this.check(i.LBRACKET)){this.pos++;let e=this.parseExpr();this.eat(i.RBRACKET),t={type:"OptIndexExpr",obj:t,idx:e}}else{let e=this.peek();e.type!==i.IDENT&&!(e.type in i)&&this.err(`Expected property name, got '${e.type}'`);let s=this.skip().value;t={type:"OptMemberExpr",obj:t,prop:s}}else if(this.check(i.INSTANCEOF)){this.pos++;let e=this.eat(i.IDENT).value;t={type:"BinaryExpr",op:"instanceof",left:t,right:{type:"Identifier",name:e}}}else if(this.check(i.AS))if(this.pos++,this.check(i.CONST))this.pos++,t={type:"AsConstExpr",expr:t};else{let e=this.parseTypeAnn();t={type:"CastExpr",expr:t,castType:e}}else if(this.check(i.SATISFIES)){this.pos++;let e=this.parseTypeAnn();t={type:"SatisfiesExpr",expr:t,satType:e}}else if(this.check(i.IS)){this.pos++;let e=this.parseTypeAnn();t={type:"IsExpr",expr:t,isType:e}}else if(this.check(i.BANG))this.pos++,t={type:"NonNullExpr",expr:t};else if(this.check(i.LBRACKET)){this.pos++;let e=this.parseExpr();this.eat(i.RBRACKET),t={type:"IndexExpr",obj:t,idx:e}}else if(this.check(i.LPAREN)){let e=this.parseArgList();if(this.check(i.ARROW)){this.pos++;let s=this.parseExpr();return{type:"LambdaExpr",params:e.map(a=>({name:a.type==="Identifier"?a.name:"_"})),body:s}}t={type:"CallExpr",callee:t,args:e}}else break t;return t}parseArgList(){this.eat(i.LPAREN);let t=[];for(;!this.check(i.RPAREN)&&!this.check(i.EOF)&&(this.check(i.DOTDOTDOT)?(this.pos++,t.push({type:"SpreadExpr",expr:this.parseExpr()})):t.push(this.parseExpr()),!!this.maybe(i.COMMA)););return this.eat(i.RPAREN),t}parsePrimary(){let t=this.peek();switch(t.type){case i.NUMBER:return this.pos++,{type:"NumberLit",value:t.value,loc:t};case i.BOOL:return this.pos++,{type:"BoolLit",value:t.value,loc:t};case i.NULL:return this.pos++,{type:"NullLit",loc:t};case i.SELF:return this.pos++,{type:"SelfExpr",loc:t};case i.WILDCARD:return this.pos++,{type:"Identifier",name:"_",loc:t};case i.IDENT:return this.pos++,{type:"Identifier",name:t.value,loc:t};case i.STRING:return this.pos++,t.value&&t.value.template?{type:"TemplateLit",parts:t.value.parts,loc:t}:{type:"StringLit",value:t.value,loc:t};case i.REGEX:return this.pos++,{type:"RegexLit",value:t.value,loc:t};case i.NEW:{this.pos++;let e=this.eat(i.IDENT).value,s=this.parseArgList();return{type:"NewExpr",callee:e,args:s}}case i.FN:{this.pos++;let e=this.parseParamList();if(this.check(i.ARROW)){if(this.pos++,this._isTypeAnnBeforeColon()){let r=this.parseTypeAnn(),a=this.parseBlock();return{type:"FnDecl",name:null,params:e,retType:r,body:a,inline:!1,async:!1,loc:t}}let s=this.parseExpr();return{type:"FnDecl",name:null,params:e,retType:null,body:s,inline:!0,async:!1,loc:t}}if(this.check(i.COLON)){let s=this.parseBlock();return{type:"FnDecl",name:null,params:e,retType:null,body:s,inline:!1,async:!1,loc:t}}this.err("Expected -> or : after anonymous fn")}case i.MATCH:return this.parseMatch();case i.LPAREN:{if(this.pos++,this.check(i.RPAREN)){if(this.pos++,this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let a=this.parseIndentedBlock();return{type:"LambdaExpr",params:[],body:a,block:!0}}let r=this.parseExpr();return{type:"LambdaExpr",params:[],body:r}}return{type:"NullLit"}}let e=this.parseExpr();if(this.check(i.RPAREN)){if(this.pos++,this.check(i.ARROW)){if(this.pos++,this.check(i.NEWLINE)){let c=this.parseIndentedBlock();return{type:"LambdaExpr",params:[{name:e.type==="Identifier"?e.name:"_"}],body:c,block:!0}}let r=this.parseExpr();return{type:"LambdaExpr",params:[{name:e.type==="Identifier"?e.name:"_"}],body:r}}return e}let s=[e];for(;this.maybe(i.COMMA);)s.push(this.parseExpr());if(this.eat(i.RPAREN),this.check(i.ARROW)){this.pos++;let r=s.map(c=>({name:c.type==="Identifier"?c.name:"_"}));if(this.check(i.NEWLINE)){let c=this.parseIndentedBlock();return{type:"LambdaExpr",params:r,body:c,block:!0}}let a=this.parseExpr();return{type:"LambdaExpr",params:r,body:a}}return s.length>1&&this.err(`Unexpected comma in expression \u2014 did you mean a lambda? Write (${s.map((r,a)=>"p"+a).join(", ")}) -> expr`),s[0]}case i.LBRACKET:{this.pos++;let e=[];for(;!this.check(i.RBRACKET)&&!this.check(i.EOF)&&(this.check(i.DOTDOTDOT)?(this.pos++,e.push({type:"SpreadExpr",expr:this.parseExpr()})):e.push(this.parseExpr()),!!this.maybe(i.COMMA)););return this.eat(i.RBRACKET),{type:"ArrayExpr",items:e}}case i.LBRACE:{this.pos++;let e=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);){if(this.check(i.DOTDOTDOT)){if(this.pos++,e.push({spread:!0,value:this.parseExpr()}),!this.maybe(i.COMMA))break;continue}if(this.check(i.LBRACKET)){this.pos++;let r=this.parseExpr();this.eat(i.RBRACKET),this.eat(i.COLON);let a=this.parseExpr();if(e.push({computed:!0,keyExpr:r,value:a}),!this.maybe(i.COMMA))break;continue}let s=this.check(i.STRING)?this.eat(i.STRING).value:this.check(i.IDENT)?this.eat(i.IDENT).value:this.skip().value;if(!this.check(i.COLON))e.push({key:s,value:{type:"Identifier",name:s}});else{this.eat(i.COLON);let r=this.parseExpr();e.push({key:s,value:r})}if(!this.maybe(i.COMMA))break}return this.eat(i.RBRACE),{type:"ObjectExpr",pairs:e}}default:this.err(`Unexpected token: ${t.type} (${JSON.stringify(t.value)})`)}}};jt.exports={Parser:dt,ParseError:z}});var xt=_((Ns,Wt)=>{"use strict";function Se(n){let t=n.lastIndexOf(":");if(t<1)return null;let e=n.slice(t+1).trim();return e.length>0&&/[.<>^,dbeEfFgGoOxXs%bcn]/.test(e)&&/^([.<>^0\-+ #,]*[0-9]*\.?[0-9]*[dbeEfFgGoOxXs%bcn]?[,]?)$/.test(e)?{expr:n.slice(0,t).trim(),fmt:e}:null}var Ae=`
|
|
23
23
|
function _fmt(v, s) {
|
|
24
24
|
if (s === ',') return (+v).toLocaleString();
|
|
25
25
|
if (s === '%') return ((+v)*100).toFixed(0)+'%';
|
|
@@ -35,7 +35,7 @@ function _fmt(v, s) {
|
|
|
35
35
|
var m2 = s.match(/^([0-9]*)d$/); if (m2) return Math.round(+v).toString();
|
|
36
36
|
return String(v);
|
|
37
37
|
}`,st=class extends Error{constructor(t,e){super(`${t}${e?` [${e.type}]`:""}`),this.name="CodeGenError"}};function ve(n){let t={};for(let e of n.body){let s=e.type==="ExportDecl"?e.decl:e;s.type==="ClassDecl"&&(t[s.name]={fields:s.fields,superClass:s.superClass})}return t}function gt(n,t,e=new Set){return!n||!t[n]||e.has(n)?[]:(e.add(n),[...gt(t[n].superClass,t,e),...t[n].fields])}var Tt=class{constructor(t={}){this.ind=t.indent||" ",this.level=0,this.lines=[],this.clsReg={},this.smBuilder=t.smBuilder||null,this._needsFmt=!1,this._loopDepth=0}i(){return this.ind.repeat(this.level)}emit(t){this.lines.push(this.i()+t)}emitRaw(t){this.lines.push(t)}blank(){this.lines.push("")}in(){this.level++}out(){this.level=Math.max(0,this.level-1)}_map(t){if(!this.smBuilder||!t)return;let e=this.lines.length,s=this.ind.repeat(this.level).length,r=(t.line||1)-1,a=(t.col||1)-1;this.smBuilder.addMapping(e,s,r,a)}generate(t){this.clsReg=ve(t),this.lines=[],this.level=0,this._needsFmt=!1,this.emit("// Generated by Flux Transpiler v3.2.0"),this.emit('"use strict";'),this.blank();for(let e of t.body)this.genStmt(e);return this._needsFmt&&this.lines.splice(2,0,Ae),{code:this.lines.join(`
|
|
38
|
-
`),smBuilder:this.smBuilder}}genStmt(t){switch(this._map(t.loc),t.type){case"VarDecl":return this.genVar(t);case"DestructureDecl":return this.genDestructure(t);case"FnDecl":return this.genFn(t);case"ClassDecl":return this.genClass(t);case"IfStmt":return this.genIf(t);case"ForInStmt":return this.genFor(t);case"WhileStmt":return this.genWhile(t);case"MatchStmt":return this.genMatch(t);case"ReturnStmt":return this.genReturn(t);case"TryCatchStmt":return this.genTryCatch(t);case"ThrowStmt":return this.genThrow(t);case"DoWhileStmt":return this.genDoWhile(t);case"BreakStmt":return this.emit(t.label?`break ${t.label};`:"break;");case"ContinueStmt":return this.emit(t.label?`continue ${t.label};`:"continue;");case"LabeledStmt":return this.genLabeled(t);case"ImportDecl":return this.genImport(t);case"ExportDecl":return this.genExport(t);case"TypeDecl":return this.genTypeDecl(t);case"InterfaceDecl":return this.genInterfaceDecl(t);case"EnumDecl":return this.genEnumDecl(t);case"ExprStmt":return this.emit(this.genExpr(t.expr)+";");default:throw new st(`Unknown statement: ${t.type}`,t)}}genVar(t){let e=t.kind==="val"?"const":"let",s=t.init?` = ${this.genExpr(t.init)}`:"";this.emit(`${e} ${t.name}${s};`)}genDestructure(t){let e=t.kind==="val"?"const":"let",s=this.genExpr(t.init);if(t.patternType==="object"){let r=t.pattern.map(a=>{if(a.rest)return`...${a.key}`;let c=a.alias!==a.key?`${a.key}: ${a.alias}`:a.key;return a.defaultVal&&(c+=` = ${this.genExpr(a.defaultVal)}`),c}).join(", ");this.emit(`${e} { ${r} } = ${s};`)}else{let r=t.pattern.map(a=>{if(!a)return"";if(a.rest)return`...${a.name}`;let c=a.name;return a.defaultVal&&(c+=` = ${this.genExpr(a.defaultVal)}`),c}).join(", ");this.emit(`${e} [${r}] = ${s};`)}}genFn(t,e=""){let s=t.async?"async ":"",r=t.name||"",a=t.params.map(c=>c.rest?`...${c.name}`:c.defaultVal?`${c.name} = ${this.genExpr(c.defaultVal)}`:c.name).join(", ");if(t.inline)this.emit(`${e}${s}function ${r}(${a}) { return ${this.genExpr(t.body)}; }`);else{this.emit(`${e}${s}function ${r}(${a}) {`),this.in();for(let c of t.body)this.genStmt(c);this.out(),this.emit("}")}if(t.name&&t.decorators&&t.decorators.length>0)for(let c=t.decorators.length-1;c>=0;c--){let h=t.decorators[c],l=h.args.length>0?`(${h.args.map(p=>this.genExpr(p)).join(", ")})(${t.name})`:`(${t.name})`;this.emit(`${t.name} = ${h.name}${l};`)}}genClass(t){let e=t.superClass?` extends ${t.superClass}`:"";this.emit(`class ${t.name}${e} {`),this.in();let s=u=>u.modifiers&&u.modifiers.has("private"),r=u=>s(u)?`#${u.name}`:u.name,a=u=>s(u)?`this.#${u.name}`:`this.${u.name}`,c=t.fields.filter(s);for(let u of c)this.emit(`#${u.name};`);c.length>0&&this.blank();let h=gt(t.name,this.clsReg),l=h.filter(u=>u.init==null&&!s(u)),p=h.filter(u=>u.init!=null),m=t.fields.filter(u=>u.init!=null);if(l.length>0||p.length>0||c.length>0){let u=l.map(d=>d.name).join(", ");if(this.emit(`constructor(${u}) {`),this.in(),t.superClass&&this.clsReg[t.superClass]){let g=gt(t.superClass,this.clsReg).filter(f=>f.init==null);g.length>0&&this.emit(`super(${g.map(f=>f.name).join(", ")});`)}for(let d of t.fields.filter(g=>g.init==null&&!s(g)))this.emit(`${a(d)} = ${d.name};`);for(let d of m)this.emit(`${a(d)} = ${this.genExpr(d.init)};`);this.out(),this.emit("}"),this.blank()}for(let u of t.methods){let d=u.async?"async ":"",g=u.modifiers&&u.modifiers.has("static")?"static ":"",f=u.getset?`${u.getset} `:"",T=u.params.map(x=>x.rest?`...${x.name}`:x.defaultVal?`${x.name} = ${this.genExpr(x.defaultVal)}`:x.name).join(", ");if(u.inline)this.emit(`${g}${d}${f}${u.name}(${T}) { return ${this.genExpr(u.body)}; }`);else{this.emit(`${g}${d}${f}${u.name}(${T}) {`),this.in();for(let x of u.body)this.genStmt(x);this.out(),this.emit("}")}this.blank()}if(this.out(),this.emit("}"),t.decorators&&t.decorators.length>0)for(let u=t.decorators.length-1;u>=0;u--){let d=t.decorators[u],g=d.args.length>0?`(${d.args.map(f=>this.genExpr(f)).join(", ")})(${t.name})`:`(${t.name})`;this.emit(`${t.name} = ${d.name}${g};`)}this.blank()}genIf(t){this.emit(`if (${this.genExpr(t.cond)}) {`),this.in(),t.then.forEach(e=>this.genStmt(e)),this.out(),this.emit("}");for(let e of t.elseifs)this.emitRaw(this.i()+`else if (${this.genExpr(e.cond)}) {`),this.in(),e.body.forEach(s=>this.genStmt(s)),this.out(),this.emit("}");t.else_&&(this.emitRaw(this.i()+"else {"),this.in(),t.else_.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"))}genFor(t){let e=t.iter,s=t.label?`${t.label}: `:"";if(e.type==="RangeExpr"){let r=this.genExpr(e.start),a=this.genExpr(e.end);this.emit(`${s}for (let ${t.var} = ${r}; ${t.var} < ${a}; ${t.var}++) {`)}else t.isAwait?this.emit(`${s}for await (const ${t.var} of ${this.genExpr(e)}) {`):this.emit(`${s}for (const ${t.var} of ${this.genExpr(e)}) {`);if(this._loopDepth++,this.in(),t.varPattern){let r=t.varPattern;if(r.type==="array"){let a=r.names.map(c=>c.rest?`...${c.name}`:c.name).join(", ");this.emit(`const [${a}] = ${t.var};`)}}t.body.forEach(r=>this.genStmt(r)),this.out(),this._loopDepth--,this.emit("}")}genLabeled(t){t.body.label=t.label,this.genStmt(t.body)}genWhile(t){let e=t.label?`${t.label}: `:"";this.emit(`${e}while (${this.genExpr(t.cond)}) {`),this._loopDepth++,this.in(),t.body.forEach(s=>this.genStmt(s)),this.out(),this._loopDepth--,this.emit("}")}genMatch(t){let e=this.genExpr(t.subject),s=t.arms,r=!1;s.forEach((a,c)=>{let h=a.pattern,l=null,p=[];if(h.type==="WildcardPat")l=null;else if(h.type==="RangePat"){let m=this.genExpr(h.start),y=this.genExpr(h.end);l=`${e} >= ${m} && ${e} <= ${y}`}else if(h.type==="VariantPat")l=`${e}?.__type === "${h.variant}"`,p=h.bindings.map((m,y)=>`const ${m} = ${e}.__args[${y}];`);else{let m=this.genExpr(h.value);h.value.type==="Identifier"&&/^[A-Z]/.test(h.value.name)?l=`(${e} === ${m} || ${e}?.__type === "${h.value.name}")`:l=`${e} === ${m}`}if(a.guard){let m=this.genExpr(a.guard);if(p.length>0){let y=`(function(){ ${p.map(u=>u.replace("const ","var ")).join(" ")} return (${m}); }())`;l=l?`(${l}) && ${y}`:y}else l=l?`(${l}) && (${m})`:m}!r&&l?(this.emit(`if (${l}) {`),r=!0):!r&&!l?(this.emit("if (true) {"),r=!0):r&&l?this.emitRaw(this.i()+`else if (${l}) {`):this.emitRaw(this.i()+"else {"),this.in();for(let m of p)this.emit(m);if(a.inline){let m=this.genExpr(a.body[0].expr);this._loopDepth>0?this.emit(`${m};`):this.emit(`return ${m};`)}else a.body.forEach(m=>this.genStmt(m));this.out(),this.emit("}")})}genInterfaceDecl(t){this.blank(),this.emit(`// interface ${t.name}`),this.blank()}genEnumDecl(t){this.blank();let e=t.members.map(s=>{let r=this.genExpr(s.value);return`${s.name}: ${r}`}).join(", ");this.emit(`const ${t.name} = Object.freeze({ ${e} });`),this.blank()}genTypeDecl(t){this.blank(),this.emit(`// ADT type: ${t.name}`);for(let e of t.variants)if(e.fields.length===0)this.emit(`const ${e.name} = Object.freeze({ __type: "${e.name}", __args: [] });`);else{let s=e.fields.join(", "),r=`[${e.fields.join(", ")}]`,a=e.fields.map(c=>`${c}: ${c}`).join(", ");this.emit(`function ${e.name}(${s}) { return Object.freeze({ __type: "${e.name}", __args: ${r}, ${a} }); }`)}this.blank()}genReturn(t){t.value?this.emit(`return ${this.genExpr(t.value)};`):this.emit("return;")}genTryCatch(t){if(this.emit("try {"),this.in(),t.tryBody.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"),t.catchBody){let e=t.catchParam?`(${t.catchParam})`:"(_err)";this.emitRaw(this.i()+`catch ${e} {`),this.in(),t.catchBody.forEach(s=>this.genStmt(s)),this.out(),this.emit("}")}t.finallyBody&&(this.emitRaw(this.i()+"finally {"),this.in(),t.finallyBody.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"))}genThrow(t){this.emit(`throw ${this.genExpr(t.value)};`)}genDoWhile(t){this.emit("do {"),this.in();for(let e of t.body)this.genStmt(e);this.out(),this.emit(`} while (${this.genExpr(t.cond)});`)}genImport(t){let e=typeof t.source=="string"?t.source:String(t.source);if(t.namespaceName)this.emit(`const ${t.namespaceName} = require("${e}");`);else if(t.defaultName)this.emit(`const ${t.defaultName} = require("${e}");`);else if(t.names.length){let s=t.names.map(r=>typeof r=="string"?r:r.name!==r.alias?`${r.name}: ${r.alias}`:r.name).join(", ");this.emit(`const { ${s} } = require("${e}");`)}}genExport(t){if(t.isDefault){this.emit(`module.exports = ${this.genExpr(t.decl)};`);return}let e=t.decl;switch(e.type){case"FnDecl":{let s=e.async?"async ":"",r=e.params.map(a=>a.rest?`...${a.name}`:a.defaultVal?`${a.name} = ${this.genExpr(a.defaultVal)}`:a.name).join(", ");e.inline?this.emit(`${s}function ${e.name}(${r}) { return ${this.genExpr(e.body)}; }`):(this.emit(`${s}function ${e.name}(${r}) {`),this.in(),e.body.forEach(a=>this.genStmt(a)),this.out(),this.emit("}")),this.emit(`module.exports.${e.name} = ${e.name};`);break}case"ClassDecl":this.genClass(e),this.emit(`module.exports.${e.name} = ${e.name};`);break;case"TypeDecl":this.genTypeDecl(e);for(let s of e.variants)this.emit(`module.exports.${s.name} = ${s.name};`);break;case"InterfaceDecl":this.genInterfaceDecl(e);break;case"EnumDecl":this.genEnumDecl(e),this.emit(`module.exports.${e.name} = ${e.name};`);break;case"VarDecl":{let s=e.kind==="val"?"const":"let";this.emit(`${s} ${e.name} = ${this.genExpr(e.init)};`),this.emit(`module.exports.${e.name} = ${e.name};`);break}default:this.genStmt(e)}}genExpr(t){if(!t)return"undefined";switch(t.type){case"NumberLit":return String(t.value);case"BoolLit":return String(t.value);case"NullLit":return"null";case"SelfExpr":return"this";case"Identifier":return t.name==="print"?"console.log":t.name;case"StringLit":return JSON.stringify(t.value);case"RegexLit":return`/${t.value.pattern}/${t.value.flags}`;case"TemplateLit":return this.genTemplate(t.parts);case"BinaryExpr":return`(${this.genExpr(t.left)} ${t.op} ${this.genExpr(t.right)})`;case"UnaryExpr":return`${t.op}${this.genExpr(t.operand)}`;case"UpdateExpr":return t.prefix?`${t.op}${this.genExpr(t.operand)}`:`${this.genExpr(t.operand)}${t.op}`;case"TernaryExpr":return`(${this.genExpr(t.cond)} ? ${this.genExpr(t.then)} : ${this.genExpr(t.else_)})`;case"AssignExpr":return`${this.genExpr(t.target)} ${t.op} ${this.genExpr(t.value)}`;case"AwaitExpr":return`await ${this.genExpr(t.operand)}`;case"TypeofExpr":return`typeof ${this.genExpr(t.operand)}`;case"SpreadExpr":return`...${this.genExpr(t.expr)}`;case"CallExpr":{let e=this.genExpr(t.callee),s=t.args.map(r=>this.genExpr(r)).join(", ");return`${e}(${s})`}case"MemberExpr":{let e=this.genExpr(t.obj);return`${t.obj.type==="NumberLit"?`(${e})`:e}.${t.prop}`}case"OptMemberExpr":return`${this.genExpr(t.obj)}?.${t.prop}`;case"OptIndexExpr":return`${this.genExpr(t.obj)}?.[${this.genExpr(t.idx)}]`;case"OptCallExpr":{let e=t.args.map(s=>this.genExpr(s)).join(", ");return`${this.genExpr(t.callee)}?.(${e})`}case"IndexExpr":return`${this.genExpr(t.obj)}[${this.genExpr(t.idx)}]`;case"NewExpr":{let e=t.args.map(s=>this.genExpr(s)).join(", ");return`new ${t.callee}(${e})`}case"LambdaExpr":{let e=t.params.map(s=>s.rest?`...${s.name}`:s.name).join(", ");if(t.block){let s=this.lines.length,r=this.level;this.emit(`(${e}) => {`),this.in();for(let c of t.body)this.genStmt(c);this.out(),this.emit("}");let a=this.lines.splice(s).map(c=>c.trimStart()).join(" ");return this.level=r,a}return`(${e}) => ${this.genExpr(t.body)}`}case"FnDecl":{let e=t.async?"async ":"",s=t.params.map(r=>r.rest?`...${r.name}`:r.defaultVal?`${r.name} = ${this.genExpr(r.defaultVal)}`:r.name).join(", ");if(t.inline)return`${e}function(${s}) { return ${this.genExpr(t.body)}; }`;{let r=this.lines.length,a=this.level;this.emit(`${e}function(${s}) {`),this.in();for(let h of t.body)this.genStmt(h);this.out(),this.emit("}");let c=this.lines.splice(r).map(h=>h.trimStart()).join(" ");return this.level=a,c}}case"MatchStmt":{let e=this.lines.length,s=this.level,r=this._loopDepth;this._loopDepth=0,this.emit("(() => {"),this.in(),this.genMatch(t),this.out(),this.emit("})()"),this._loopDepth=r;let a=this.lines.splice(e).map(c=>c.trimStart()).join(" ");return this.level=s,a}case"ArrayExpr":return`[${t.items.map(e=>this.genExpr(e)).join(", ")}]`;case"ObjectExpr":return`{ ${t.pairs.map(s=>{if(s.spread)return`...${this.genExpr(s.value)}`;if(s.computed)return`[${this.genExpr(s.keyExpr)}]: ${this.genExpr(s.value)}`;let r=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s.key),a=r?s.key:`"${s.key}"`;return r&&s.value&&s.value.type==="Identifier"&&s.value.name===s.key?s.key:`${a}: ${this.genExpr(s.value)}`}).join(", ")} }`;case"RangeExpr":return`Array.from({ length: ${this.genExpr(t.end)} - ${this.genExpr(t.start)} }, (_, i) => i + ${this.genExpr(t.start)})`;case"PipeExpr":return this.genPipe(t);case"CastExpr":return this.genExpr(t.expr);case"AsConstExpr":return`Object.freeze(${this.genExpr(t.expr)})`;case"SatisfiesExpr":return this.genExpr(t.expr);case"IsExpr":return this.genExpr(t.expr);case"NonNullExpr":return this.genExpr(t.expr);default:throw new st(`Unknown expression: ${t.type}`,t)}}genTemplate(t){let{Lexer:e}=J(),{Parser:s}=et(),r="`";for(let a of t)if(a.type==="text")r+=a.value.replace(/`/g,"\\`").replace(/\$/g,"\\$");else{let c=Se(a.value),h=c?c.expr:a.value,l=c?c.fmt:null;try{let p=new e(h).tokenize(),m=new s(p).parseExpr(),y=this.genExpr(m);l?(this._needsFmt=!0,r+=`\${_fmt(${y}, ${JSON.stringify(l)})}`):r+=`\${${y}}`}catch{r+=`\${${a.value}}`}}return r+="`",r}genPipe(t){let e=this.genExpr(t.left),s=t.right;if(s.type==="Identifier")return`${this.genExpr(s)}(${e})`;if(s.type==="CallExpr"){let r=this.genExpr(s.callee),a=s.args.map(c=>this.genExpr(c)).join(", ");return a?`${r}(${e}, ${a})`:`${r}(${e})`}return`(${this.genExpr(s)})(${e})`}};Ut.exports={CodeGenerator:Tt,CodeGenError:st}});var Qt=_((ws,Wt)=>{"use strict";var Re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function it(n){let t=n<0?-n<<1|1:n<<1,e="";do{let s=t&31;t>>>=5,t>0&&(s|=32),e+=Re[s]}while(t>0);return e}var bt=class{constructor(t,e){this.sourceFile=t,this.sourceContent=e,this.mappings=[]}addMapping(t,e,s,r){for(;this.mappings.length<=t;)this.mappings.push([]);this.mappings[t].push({genCol:e,srcLine:s,srcCol:r})}encodeMappings(){let t=0,e=0;return this.mappings.map(s=>{let r=0;return s.map(a=>{let c=[it(a.genCol-r),it(0),it(a.srcLine-t),it(a.srcCol-e)].join("");return r=a.genCol,t=a.srcLine,e=a.srcCol,c}).join(",")}).join(";")}toJSON(t=""){return{version:3,file:t,sourceRoot:"",sources:[this.sourceFile],sourcesContent:[this.sourceContent],names:[],mappings:this.encodeMappings()}}toString(t=""){return JSON.stringify(this.toJSON(t))}};Wt.exports={SourceMapBuilder:bt,encodeVLQ:it}});var qt=_((As,Kt)=>{"use strict";var Nt={bg:n=>`background:${n}`,fg:n=>`color:${n}`,color:n=>`color:${n}`,p:n=>`padding:${n}`,px:n=>`paddingLeft:${n},paddingRight:${n}`,py:n=>`paddingTop:${n},paddingBottom:${n}`,pt:n=>`paddingTop:${n}`,pb:n=>`paddingBottom:${n}`,pl:n=>`paddingLeft:${n}`,pr:n=>`paddingRight:${n}`,m:n=>`margin:${n}`,mx:n=>`marginLeft:${n},marginRight:${n}`,my:n=>`marginTop:${n},marginBottom:${n}`,mt:n=>`marginTop:${n}`,mb:n=>`marginBottom:${n}`,ml:n=>`marginLeft:${n}`,mr:n=>`marginRight:${n}`,radius:n=>`borderRadius:${n}`,w:n=>`width:${n}`,h:n=>`height:${n}`,"min-w":n=>`minWidth:${n}`,"max-w":n=>`maxWidth:${n}`,"min-h":n=>`minHeight:${n}`,"max-h":n=>`maxHeight:${n}`,gap:n=>`gap:${n}`,"col-gap":n=>`columnGap:${n}`,"row-gap":n=>`rowGap:${n}`,text:n=>`fontSize:${n}`,font:n=>`fontFamily:${n}`,weight:n=>`fontWeight:${n}`,tracking:n=>`letterSpacing:${n}`,leading:n=>`lineHeight:${n}`,shadow:n=>`boxShadow:${n}`,opacity:n=>`opacity:${n}`,border:n=>`border:${n}`,outline:n=>`outline:${n}`,transition:n=>`transition:${n}`,cursor:n=>`cursor:${n}`,overflow:n=>`overflow:${n}`,z:n=>`zIndex:${n}`,transform:n=>`transform:${n}`,direction:n=>`flexDirection:${n}`,align:n=>`alignItems:${n}`,justify:n=>`justifyContent:${n}`,"align-self":n=>`alignSelf:${n}`,"place-items":n=>`placeItems:${n}`,grow:n=>`flexGrow:${n}`,shrink:n=>`flexShrink:${n}`,basis:n=>`flexBasis:${n}`,cols:n=>`gridTemplateColumns:${n}`,rows:n=>`gridTemplateRows:${n}`,inset:n=>`inset:${n}`,top:n=>`top:${n}`,right:n=>`right:${n}`,bottom:n=>`bottom:${n}`,left:n=>`left:${n}`,"object-fit":n=>`objectFit:${n}`,"line-height":n=>`lineHeight:${n}`,"text-align":n=>`textAlign:${n}`,decoration:n=>`textDecoration:${n}`,clip:n=>`clipPath:${n}`,filter:n=>`filter:${n}`,backdrop:n=>`backdropFilter:${n}`,animation:n=>`animation:${n}`},rt={flex:'display:"flex"',grid:'display:"grid"',block:'display:"block"',"inline-flex":'display:"inline-flex"',"inline-block":'display:"inline-block"',bold:"fontWeight:700",italic:'fontStyle:"italic"',underline:'textDecoration:"underline"',pointer:'cursor:"pointer"',hidden:'display:"none"',relative:'position:"relative"',absolute:'position:"absolute"',fixed:'position:"fixed"',sticky:'position:"sticky"',"flex-col":'flexDirection:"column"',"flex-row":'flexDirection:"row"',"flex-wrap":'flexWrap:"wrap"',"flex-1":"flex:1","w-full":'width:"100%"',"h-full":'height:"100%"',center:'textAlign:"center"',truncate:'overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"',"select-none":'userSelect:"none"',"no-wrap":'whiteSpace:"nowrap"',"no-list":'listStyle:"none"',"no-outline":'outline:"none"',"no-border":'border:"none"',"box-border":'boxSizing:"border-box"'},Ss=new Set([...Object.keys(Nt),...Object.keys(rt)]),ht=class{constructor(t){this.src=t,this.pos=0,this.out=""}transform(){for(;this.pos<this.src.length;)this.scanTop();return this.hasJsx=this.out!==this.src,this.out}scanTop(){let t=this.src[this.pos];if(t==="/"&&this.src[this.pos+1]==="/"){let e=this.src.indexOf(`
|
|
38
|
+
`),smBuilder:this.smBuilder}}genStmt(t){switch(this._map(t.loc),t.type){case"VarDecl":return this.genVar(t);case"DestructureDecl":return this.genDestructure(t);case"FnDecl":return this.genFn(t);case"ClassDecl":return this.genClass(t);case"IfStmt":return this.genIf(t);case"ForInStmt":return this.genFor(t);case"WhileStmt":return this.genWhile(t);case"MatchStmt":return this.genMatch(t);case"ReturnStmt":return this.genReturn(t);case"TryCatchStmt":return this.genTryCatch(t);case"ThrowStmt":return this.genThrow(t);case"DoWhileStmt":return this.genDoWhile(t);case"BreakStmt":return this.emit(t.label?`break ${t.label};`:"break;");case"ContinueStmt":return this.emit(t.label?`continue ${t.label};`:"continue;");case"LabeledStmt":return this.genLabeled(t);case"ImportDecl":return this.genImport(t);case"ExportDecl":return this.genExport(t);case"TypeDecl":return this.genTypeDecl(t);case"InterfaceDecl":return this.genInterfaceDecl(t);case"EnumDecl":return this.genEnumDecl(t);case"DeclareDecl":return;case"ExprStmt":return this.emit(this.genExpr(t.expr)+";");default:throw new st(`Unknown statement: ${t.type}`,t)}}genVar(t){let e=t.kind==="val"?"const":"let",s=t.init?` = ${this.genExpr(t.init)}`:"";this.emit(`${e} ${t.name}${s};`)}genDestructure(t){let e=t.kind==="val"?"const":"let",s=this.genExpr(t.init);if(t.patternType==="object"){let r=t.pattern.map(a=>{if(a.rest)return`...${a.key}`;let c=a.alias!==a.key?`${a.key}: ${a.alias}`:a.key;return a.defaultVal&&(c+=` = ${this.genExpr(a.defaultVal)}`),c}).join(", ");this.emit(`${e} { ${r} } = ${s};`)}else{let r=t.pattern.map(a=>{if(!a)return"";if(a.rest)return`...${a.name}`;let c=a.name;return a.defaultVal&&(c+=` = ${this.genExpr(a.defaultVal)}`),c}).join(", ");this.emit(`${e} [${r}] = ${s};`)}}genFn(t,e=""){let s=t.async?"async ":"",r=t.name||"",a=t.params.map(c=>c.rest?`...${c.name}`:c.defaultVal?`${c.name} = ${this.genExpr(c.defaultVal)}`:c.name).join(", ");if(t.inline)this.emit(`${e}${s}function ${r}(${a}) { return ${this.genExpr(t.body)}; }`);else{this.emit(`${e}${s}function ${r}(${a}) {`),this.in();for(let c of t.body)this.genStmt(c);this.out(),this.emit("}")}if(t.name&&t.decorators&&t.decorators.length>0)for(let c=t.decorators.length-1;c>=0;c--){let h=t.decorators[c],l=h.args.length>0?`(${h.args.map(p=>this.genExpr(p)).join(", ")})(${t.name})`:`(${t.name})`;this.emit(`${t.name} = ${h.name}${l};`)}}genClass(t){let e=t.superClass?` extends ${t.superClass}`:"";this.emit(`class ${t.name}${e} {`),this.in();let s=u=>u.modifiers&&u.modifiers.has("private"),r=u=>s(u)?`#${u.name}`:u.name,a=u=>s(u)?`this.#${u.name}`:`this.${u.name}`,c=t.fields.filter(s);for(let u of c)this.emit(`#${u.name};`);c.length>0&&this.blank();let h=gt(t.name,this.clsReg),l=h.filter(u=>u.init==null&&!s(u)),p=h.filter(u=>u.init!=null),m=t.fields.filter(u=>u.init!=null);if(l.length>0||p.length>0||c.length>0){let u=l.map(d=>d.name).join(", ");if(this.emit(`constructor(${u}) {`),this.in(),t.superClass&&this.clsReg[t.superClass]){let g=gt(t.superClass,this.clsReg).filter(f=>f.init==null);g.length>0&&this.emit(`super(${g.map(f=>f.name).join(", ")});`)}for(let d of t.fields.filter(g=>g.init==null&&!s(g)))this.emit(`${a(d)} = ${d.name};`);for(let d of m)this.emit(`${a(d)} = ${this.genExpr(d.init)};`);this.out(),this.emit("}"),this.blank()}for(let u of t.methods){let d=u.async?"async ":"",g=u.modifiers&&u.modifiers.has("static")?"static ":"",f=u.getset?`${u.getset} `:"",T=u.params.map(b=>b.rest?`...${b.name}`:b.defaultVal?`${b.name} = ${this.genExpr(b.defaultVal)}`:b.name).join(", ");if(u.inline)this.emit(`${g}${d}${f}${u.name}(${T}) { return ${this.genExpr(u.body)}; }`);else{this.emit(`${g}${d}${f}${u.name}(${T}) {`),this.in();for(let b of u.body)this.genStmt(b);this.out(),this.emit("}")}this.blank()}if(this.out(),this.emit("}"),t.decorators&&t.decorators.length>0)for(let u=t.decorators.length-1;u>=0;u--){let d=t.decorators[u],g=d.args.length>0?`(${d.args.map(f=>this.genExpr(f)).join(", ")})(${t.name})`:`(${t.name})`;this.emit(`${t.name} = ${d.name}${g};`)}this.blank()}genIf(t){this.emit(`if (${this.genExpr(t.cond)}) {`),this.in(),t.then.forEach(e=>this.genStmt(e)),this.out(),this.emit("}");for(let e of t.elseifs)this.emitRaw(this.i()+`else if (${this.genExpr(e.cond)}) {`),this.in(),e.body.forEach(s=>this.genStmt(s)),this.out(),this.emit("}");t.else_&&(this.emitRaw(this.i()+"else {"),this.in(),t.else_.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"))}genFor(t){let e=t.iter,s=t.label?`${t.label}: `:"";if(e.type==="RangeExpr"){let r=this.genExpr(e.start),a=this.genExpr(e.end);this.emit(`${s}for (let ${t.var} = ${r}; ${t.var} < ${a}; ${t.var}++) {`)}else t.isAwait?this.emit(`${s}for await (const ${t.var} of ${this.genExpr(e)}) {`):this.emit(`${s}for (const ${t.var} of ${this.genExpr(e)}) {`);if(this._loopDepth++,this.in(),t.varPattern){let r=t.varPattern;if(r.type==="array"){let a=r.names.map(c=>c.rest?`...${c.name}`:c.name).join(", ");this.emit(`const [${a}] = ${t.var};`)}}t.body.forEach(r=>this.genStmt(r)),this.out(),this._loopDepth--,this.emit("}")}genLabeled(t){t.body.label=t.label,this.genStmt(t.body)}genWhile(t){let e=t.label?`${t.label}: `:"";this.emit(`${e}while (${this.genExpr(t.cond)}) {`),this._loopDepth++,this.in(),t.body.forEach(s=>this.genStmt(s)),this.out(),this._loopDepth--,this.emit("}")}genMatch(t){let e=this.genExpr(t.subject),s=t.arms,r=!1;s.forEach((a,c)=>{let h=a.pattern,l=null,p=[];if(h.type==="WildcardPat")l=null;else if(h.type==="RangePat"){let m=this.genExpr(h.start),y=this.genExpr(h.end);l=`${e} >= ${m} && ${e} <= ${y}`}else if(h.type==="VariantPat")l=`${e}?.__type === "${h.variant}"`,p=h.bindings.map((m,y)=>`const ${m} = ${e}.__args[${y}];`);else{let m=this.genExpr(h.value);h.value.type==="Identifier"&&/^[A-Z]/.test(h.value.name)?l=`(${e} === ${m} || ${e}?.__type === "${h.value.name}")`:l=`${e} === ${m}`}if(a.guard){let m=this.genExpr(a.guard);if(p.length>0){let y=`(function(){ ${p.map(u=>u.replace("const ","var ")).join(" ")} return (${m}); }())`;l=l?`(${l}) && ${y}`:y}else l=l?`(${l}) && (${m})`:m}!r&&l?(this.emit(`if (${l}) {`),r=!0):!r&&!l?(this.emit("if (true) {"),r=!0):r&&l?this.emitRaw(this.i()+`else if (${l}) {`):this.emitRaw(this.i()+"else {"),this.in();for(let m of p)this.emit(m);if(a.inline){let m=this.genExpr(a.body[0].expr);this._loopDepth>0?this.emit(`${m};`):this.emit(`return ${m};`)}else a.body.forEach(m=>this.genStmt(m));this.out(),this.emit("}")})}genInterfaceDecl(t){this.blank(),this.emit(`// interface ${t.name}`),this.blank()}genEnumDecl(t){this.blank();let e=t.members.map(s=>{let r=this.genExpr(s.value);return`${s.name}: ${r}`}).join(", ");this.emit(`const ${t.name} = Object.freeze({ ${e} });`),this.blank()}genTypeDecl(t){this.blank(),this.emit(`// ADT type: ${t.name}`);for(let e of t.variants)if(e.fields.length===0)this.emit(`const ${e.name} = Object.freeze({ __type: "${e.name}", __args: [] });`);else{let s=e.fields.join(", "),r=`[${e.fields.join(", ")}]`,a=e.fields.map(c=>`${c}: ${c}`).join(", ");this.emit(`function ${e.name}(${s}) { return Object.freeze({ __type: "${e.name}", __args: ${r}, ${a} }); }`)}this.blank()}genReturn(t){t.value?this.emit(`return ${this.genExpr(t.value)};`):this.emit("return;")}genTryCatch(t){if(this.emit("try {"),this.in(),t.tryBody.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"),t.catchBody){let e=t.catchParam?`(${t.catchParam})`:"(_err)";this.emitRaw(this.i()+`catch ${e} {`),this.in(),t.catchBody.forEach(s=>this.genStmt(s)),this.out(),this.emit("}")}t.finallyBody&&(this.emitRaw(this.i()+"finally {"),this.in(),t.finallyBody.forEach(e=>this.genStmt(e)),this.out(),this.emit("}"))}genThrow(t){this.emit(`throw ${this.genExpr(t.value)};`)}genDoWhile(t){this.emit("do {"),this.in();for(let e of t.body)this.genStmt(e);this.out(),this.emit(`} while (${this.genExpr(t.cond)});`)}genImport(t){let e=typeof t.source=="string"?t.source:String(t.source);if(t.namespaceName)this.emit(`const ${t.namespaceName} = require("${e}");`);else if(t.defaultName)this.emit(`const ${t.defaultName} = require("${e}");`);else if(t.names.length){let s=t.names.map(r=>typeof r=="string"?r:r.name!==r.alias?`${r.name}: ${r.alias}`:r.name).join(", ");this.emit(`const { ${s} } = require("${e}");`)}}genExport(t){if(t.isDefault){this.emit(`module.exports = ${this.genExpr(t.decl)};`);return}let e=t.decl;switch(e.type){case"FnDecl":{let s=e.async?"async ":"",r=e.params.map(a=>a.rest?`...${a.name}`:a.defaultVal?`${a.name} = ${this.genExpr(a.defaultVal)}`:a.name).join(", ");e.inline?this.emit(`${s}function ${e.name}(${r}) { return ${this.genExpr(e.body)}; }`):(this.emit(`${s}function ${e.name}(${r}) {`),this.in(),e.body.forEach(a=>this.genStmt(a)),this.out(),this.emit("}")),this.emit(`module.exports.${e.name} = ${e.name};`);break}case"ClassDecl":this.genClass(e),this.emit(`module.exports.${e.name} = ${e.name};`);break;case"TypeDecl":this.genTypeDecl(e);for(let s of e.variants)this.emit(`module.exports.${s.name} = ${s.name};`);break;case"InterfaceDecl":this.genInterfaceDecl(e);break;case"EnumDecl":this.genEnumDecl(e),this.emit(`module.exports.${e.name} = ${e.name};`);break;case"VarDecl":{let s=e.kind==="val"?"const":"let";this.emit(`${s} ${e.name} = ${this.genExpr(e.init)};`),this.emit(`module.exports.${e.name} = ${e.name};`);break}default:this.genStmt(e)}}genExpr(t){if(!t)return"undefined";switch(t.type){case"NumberLit":return String(t.value);case"BoolLit":return String(t.value);case"NullLit":return"null";case"SelfExpr":return"this";case"Identifier":return t.name==="print"?"console.log":t.name;case"StringLit":return JSON.stringify(t.value);case"RegexLit":return`/${t.value.pattern}/${t.value.flags}`;case"TemplateLit":return this.genTemplate(t.parts);case"BinaryExpr":return`(${this.genExpr(t.left)} ${t.op} ${this.genExpr(t.right)})`;case"UnaryExpr":return`${t.op}${this.genExpr(t.operand)}`;case"UpdateExpr":return t.prefix?`${t.op}${this.genExpr(t.operand)}`:`${this.genExpr(t.operand)}${t.op}`;case"TernaryExpr":return`(${this.genExpr(t.cond)} ? ${this.genExpr(t.then)} : ${this.genExpr(t.else_)})`;case"AssignExpr":return`${this.genExpr(t.target)} ${t.op} ${this.genExpr(t.value)}`;case"AwaitExpr":return`await ${this.genExpr(t.operand)}`;case"TypeofExpr":return`typeof ${this.genExpr(t.operand)}`;case"SpreadExpr":return`...${this.genExpr(t.expr)}`;case"CallExpr":{let e=this.genExpr(t.callee),s=t.args.map(r=>this.genExpr(r)).join(", ");return`${e}(${s})`}case"MemberExpr":{let e=this.genExpr(t.obj);return`${t.obj.type==="NumberLit"?`(${e})`:e}.${t.prop}`}case"OptMemberExpr":return`${this.genExpr(t.obj)}?.${t.prop}`;case"OptIndexExpr":return`${this.genExpr(t.obj)}?.[${this.genExpr(t.idx)}]`;case"OptCallExpr":{let e=t.args.map(s=>this.genExpr(s)).join(", ");return`${this.genExpr(t.callee)}?.(${e})`}case"IndexExpr":return`${this.genExpr(t.obj)}[${this.genExpr(t.idx)}]`;case"NewExpr":{let e=t.args.map(s=>this.genExpr(s)).join(", ");return`new ${t.callee}(${e})`}case"LambdaExpr":{let e=t.params.map(s=>s.rest?`...${s.name}`:s.name).join(", ");if(t.block){let s=this.lines.length,r=this.level;this.emit(`(${e}) => {`),this.in();for(let c of t.body)this.genStmt(c);this.out(),this.emit("}");let a=this.lines.splice(s).map(c=>c.trimStart()).join(" ");return this.level=r,a}return`(${e}) => ${this.genExpr(t.body)}`}case"FnDecl":{let e=t.async?"async ":"",s=t.params.map(r=>r.rest?`...${r.name}`:r.defaultVal?`${r.name} = ${this.genExpr(r.defaultVal)}`:r.name).join(", ");if(t.inline)return`${e}function(${s}) { return ${this.genExpr(t.body)}; }`;{let r=this.lines.length,a=this.level;this.emit(`${e}function(${s}) {`),this.in();for(let h of t.body)this.genStmt(h);this.out(),this.emit("}");let c=this.lines.splice(r).map(h=>h.trimStart()).join(" ");return this.level=a,c}}case"MatchStmt":{let e=this.lines.length,s=this.level,r=this._loopDepth;this._loopDepth=0,this.emit("(() => {"),this.in(),this.genMatch(t),this.out(),this.emit("})()"),this._loopDepth=r;let a=this.lines.splice(e).map(c=>c.trimStart()).join(" ");return this.level=s,a}case"ArrayExpr":return`[${t.items.map(e=>this.genExpr(e)).join(", ")}]`;case"ObjectExpr":return`{ ${t.pairs.map(s=>{if(s.spread)return`...${this.genExpr(s.value)}`;if(s.computed)return`[${this.genExpr(s.keyExpr)}]: ${this.genExpr(s.value)}`;let r=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s.key),a=r?s.key:`"${s.key}"`;return r&&s.value&&s.value.type==="Identifier"&&s.value.name===s.key?s.key:`${a}: ${this.genExpr(s.value)}`}).join(", ")} }`;case"RangeExpr":return`Array.from({ length: ${this.genExpr(t.end)} - ${this.genExpr(t.start)} }, (_, i) => i + ${this.genExpr(t.start)})`;case"PipeExpr":return this.genPipe(t);case"CastExpr":return this.genExpr(t.expr);case"AsConstExpr":return`Object.freeze(${this.genExpr(t.expr)})`;case"SatisfiesExpr":return this.genExpr(t.expr);case"IsExpr":return this.genExpr(t.expr);case"NonNullExpr":return this.genExpr(t.expr);default:throw new st(`Unknown expression: ${t.type}`,t)}}genTemplate(t){let{Lexer:e}=J(),{Parser:s}=et(),r="`";for(let a of t)if(a.type==="text")r+=a.value.replace(/`/g,"\\`").replace(/\$/g,"\\$");else{let c=Se(a.value),h=c?c.expr:a.value,l=c?c.fmt:null;try{let p=new e(h).tokenize(),m=new s(p).parseExpr(),y=this.genExpr(m);l?(this._needsFmt=!0,r+=`\${_fmt(${y}, ${JSON.stringify(l)})}`):r+=`\${${y}}`}catch{r+=`\${${a.value}}`}}return r+="`",r}genPipe(t){let e=this.genExpr(t.left),s=t.right;if(s.type==="Identifier")return`${this.genExpr(s)}(${e})`;if(s.type==="CallExpr"){let r=this.genExpr(s.callee),a=s.args.map(c=>this.genExpr(c)).join(", ");return a?`${r}(${e}, ${a})`:`${r}(${e})`}return`(${this.genExpr(s)})(${e})`}};Wt.exports={CodeGenerator:Tt,CodeGenError:st}});var Qt=_((ws,Ut)=>{"use strict";var Re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function it(n){let t=n<0?-n<<1|1:n<<1,e="";do{let s=t&31;t>>>=5,t>0&&(s|=32),e+=Re[s]}while(t>0);return e}var bt=class{constructor(t,e){this.sourceFile=t,this.sourceContent=e,this.mappings=[]}addMapping(t,e,s,r){for(;this.mappings.length<=t;)this.mappings.push([]);this.mappings[t].push({genCol:e,srcLine:s,srcCol:r})}encodeMappings(){let t=0,e=0;return this.mappings.map(s=>{let r=0;return s.map(a=>{let c=[it(a.genCol-r),it(0),it(a.srcLine-t),it(a.srcCol-e)].join("");return r=a.genCol,t=a.srcLine,e=a.srcCol,c}).join(",")}).join(";")}toJSON(t=""){return{version:3,file:t,sourceRoot:"",sources:[this.sourceFile],sourcesContent:[this.sourceContent],names:[],mappings:this.encodeMappings()}}toString(t=""){return JSON.stringify(this.toJSON(t))}};Ut.exports={SourceMapBuilder:bt,encodeVLQ:it}});var Yt=_((As,Gt)=>{"use strict";var Nt={bg:n=>`background:${n}`,fg:n=>`color:${n}`,color:n=>`color:${n}`,p:n=>`padding:${n}`,px:n=>`paddingLeft:${n},paddingRight:${n}`,py:n=>`paddingTop:${n},paddingBottom:${n}`,pt:n=>`paddingTop:${n}`,pb:n=>`paddingBottom:${n}`,pl:n=>`paddingLeft:${n}`,pr:n=>`paddingRight:${n}`,m:n=>`margin:${n}`,mx:n=>`marginLeft:${n},marginRight:${n}`,my:n=>`marginTop:${n},marginBottom:${n}`,mt:n=>`marginTop:${n}`,mb:n=>`marginBottom:${n}`,ml:n=>`marginLeft:${n}`,mr:n=>`marginRight:${n}`,radius:n=>`borderRadius:${n}`,w:n=>`width:${n}`,h:n=>`height:${n}`,"min-w":n=>`minWidth:${n}`,"max-w":n=>`maxWidth:${n}`,"min-h":n=>`minHeight:${n}`,"max-h":n=>`maxHeight:${n}`,gap:n=>`gap:${n}`,"col-gap":n=>`columnGap:${n}`,"row-gap":n=>`rowGap:${n}`,text:n=>`fontSize:${n}`,font:n=>`fontFamily:${n}`,weight:n=>`fontWeight:${n}`,tracking:n=>`letterSpacing:${n}`,leading:n=>`lineHeight:${n}`,shadow:n=>`boxShadow:${n}`,opacity:n=>`opacity:${n}`,border:n=>`border:${n}`,outline:n=>`outline:${n}`,transition:n=>`transition:${n}`,cursor:n=>`cursor:${n}`,overflow:n=>`overflow:${n}`,z:n=>`zIndex:${n}`,transform:n=>`transform:${n}`,direction:n=>`flexDirection:${n}`,align:n=>`alignItems:${n}`,justify:n=>`justifyContent:${n}`,"align-self":n=>`alignSelf:${n}`,"place-items":n=>`placeItems:${n}`,grow:n=>`flexGrow:${n}`,shrink:n=>`flexShrink:${n}`,basis:n=>`flexBasis:${n}`,cols:n=>`gridTemplateColumns:${n}`,rows:n=>`gridTemplateRows:${n}`,inset:n=>`inset:${n}`,top:n=>`top:${n}`,right:n=>`right:${n}`,bottom:n=>`bottom:${n}`,left:n=>`left:${n}`,"object-fit":n=>`objectFit:${n}`,"line-height":n=>`lineHeight:${n}`,"text-align":n=>`textAlign:${n}`,decoration:n=>`textDecoration:${n}`,clip:n=>`clipPath:${n}`,filter:n=>`filter:${n}`,backdrop:n=>`backdropFilter:${n}`,animation:n=>`animation:${n}`},rt={flex:'display:"flex"',grid:'display:"grid"',block:'display:"block"',"inline-flex":'display:"inline-flex"',"inline-block":'display:"inline-block"',bold:"fontWeight:700",italic:'fontStyle:"italic"',underline:'textDecoration:"underline"',pointer:'cursor:"pointer"',hidden:'display:"none"',relative:'position:"relative"',absolute:'position:"absolute"',fixed:'position:"fixed"',sticky:'position:"sticky"',"flex-col":'flexDirection:"column"',"flex-row":'flexDirection:"row"',"flex-wrap":'flexWrap:"wrap"',"flex-1":"flex:1","w-full":'width:"100%"',"h-full":'height:"100%"',center:'textAlign:"center"',truncate:'overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"',"select-none":'userSelect:"none"',"no-wrap":'whiteSpace:"nowrap"',"no-list":'listStyle:"none"',"no-outline":'outline:"none"',"no-border":'border:"none"',"box-border":'boxSizing:"border-box"'},Ss=new Set([...Object.keys(Nt),...Object.keys(rt)]),ht=class{constructor(t){this.src=t,this.pos=0,this.out=""}transform(){for(;this.pos<this.src.length;)this.scanTop();return this.hasJsx=this.out!==this.src,this.out}scanTop(){let t=this.src[this.pos];if(t==="/"&&this.src[this.pos+1]==="/"){let e=this.src.indexOf(`
|
|
39
39
|
`,this.pos);e===-1?(this.out+=this.src.slice(this.pos),this.pos=this.src.length):(this.out+=this.src.slice(this.pos,e+1),this.pos=e+1);return}if(t==="/"&&this.src[this.pos+1]==="*"){let e=this.src.indexOf("*/",this.pos+2);e===-1?(this.out+=this.src.slice(this.pos),this.pos=this.src.length):(this.out+=this.src.slice(this.pos,e+2),this.pos=e+2);return}if(t==='"'){this.passString('"');return}if(t==="'"){this.passString("'");return}if(t==="`"){this.passTemplateLit();return}if(t==="<"&&this.isJsxStart()){let e=this.parseJsxElement();this.out+=e;return}this.out+=t,this.pos++}isJsxStart(){let t=this.src[this.pos+1]||"";if(!(t===">"||t>="a"&&t<="z"||t>="A"&&t<="Z"))return!1;let e=this.pos-1;for(;e>=0&&(this.src[e]===" "||this.src[e]===" ");)e--;if(e<0)return!0;let s=this.src[e];if(`=([{,:>
|
|
40
40
|
?`.includes(s))return!0;if(/[a-z]/.test(s)){let r=e;for(;r>=0&&/[a-z]/.test(this.src[r]);)r--;let a=this.src.slice(r+1,e+1);if(new Set(["return","not","and","or","val","var","await","yield","else","in","throw"]).has(a))return!0}return!1}passString(t){for(this.out+=t,this.pos++;this.pos<this.src.length;){let e=this.src[this.pos];if(e==="\\"){this.out+=e+(this.src[this.pos+1]||""),this.pos+=2;continue}if(e===t){this.out+=e,this.pos++;return}this.out+=e,this.pos++}}passTemplateLit(){for(this.out+="`",this.pos++;this.pos<this.src.length;){let t=this.src[this.pos];if(t==="\\"){this.out+=t+(this.src[this.pos+1]||""),this.pos+=2;continue}if(t==="`"){this.out+=t,this.pos++;return}this.out+=t,this.pos++}}parseJsxElement(){if(this.pos++,this.src[this.pos]===">"){this.pos++;let s=this.parseJsxChildren("");return this.expectClose(""),`_fluxH("",null${s.length?","+s.join(","):""})`}let t=this.readTagName(),e=this.parseJsxAttrs();if(this.src[this.pos]==="/"&&this.src[this.pos+1]===">")return this.pos+=2,`_fluxH("${t}",${e})`;if(this.src[this.pos]===">"){this.pos++;let s=this.parseJsxChildren(t);this.expectClose(t);let r=s.length?","+s.join(","):"";return`_fluxH("${t}",${e}${r})`}return`<${t}`}readTagName(){let t="";for(;this.pos<this.src.length;){let e=this.src[this.pos];if(/[a-zA-Z0-9\-_\.]/.test(e))t+=e,this.pos++;else break}return t}parseJsxAttrs(){this.skipWs();let t=[],e=[],s=null;for(;this.pos<this.src.length;){let r=this.src[this.pos];if(r===">"||r==="/"&&this.src[this.pos+1]===">"||(this.skipWs(),!/[a-zA-Z_\-]/.test(this.src[this.pos])))break;let a="";for(;this.pos<this.src.length&&/[a-zA-Z0-9\-_:]/.test(this.src[this.pos]);)a+=this.src[this.pos++];if(this.skipWs(),this.src[this.pos]!=="="){rt[a]!==void 0?e.push(rt[a]):t.push(`"${a}":true`);continue}this.pos++,this.skipWs();let c=this.src[this.pos],h=null,l=null;if(c==='"'||c==="'"){let p=c;this.pos++;let m="";for(;this.pos<this.src.length&&this.src[this.pos]!==p;)this.src[this.pos]==="\\"?(m+=this.src[this.pos]+this.src[this.pos+1],this.pos+=2):m+=this.src[this.pos++];this.pos++,h=m}else if(c==="{")l=this.readBraced();else{rt[a]!==void 0?e.push(rt[a]):t.push(`"${a}":true`),this.skipWs();continue}if(h!==null&&Nt[a]){let p=Nt[a](JSON.stringify(h));e.push(p)}else l!==null&&a==="style"?s=l:h!==null?t.push(`"${a}":${JSON.stringify(h)}`):t.push(`"${a}":${l}`);this.skipWs()}if(e.length>0||s!==null){let r=e.length>0?`{${e.join(",")}}`:null;s!==null&&r!==null?t.push(`"style":Object.assign(${s},${r})`):s!==null?t.push(`"style":${s}`):t.push(`"style":{${e.join(",")}}`)}return t.length?`{${t.join(",")}}`:"null"}readBraced(){this.pos++;let t=1,e="";for(;this.pos<this.src.length&&t>0;){let s=this.src[this.pos];if(s==="{"&&t++,s==="}"&&(t--,t===0)){this.pos++;break}e+=s,this.pos++}return e.trim()}parseJsxChildren(t){let e=[];for(;this.pos<this.src.length&&!(this.src[this.pos]==="<"&&this.src[this.pos+1]==="/");){if(this.src[this.pos]==="<"){let a=this.src[this.pos+1]||"";if(a>="a"&&a<="z"||a>="A"&&a<="Z"||a===">"){e.push(this.parseJsxElement());continue}}if(this.src[this.pos]==="{"){let a=this.readBraced();a.trim()&&e.push(a);continue}let s="";for(;this.pos<this.src.length;){let a=this.src[this.pos];if(a==="<"||a==="{")break;s+=a,this.pos++}let r=s.replace(/\s+/g," ").trim();r&&e.push(JSON.stringify(r))}return e}expectClose(t){if(this.src[this.pos]==="<"&&this.src[this.pos+1]==="/"){for(this.pos+=2;this.pos<this.src.length&&this.src[this.pos]!==">";)this.pos++;this.src[this.pos]===">"&&this.pos++}}skipWs(){for(;this.pos<this.src.length&&(this.src[this.pos]===" "||this.src[this.pos]===" ");)this.pos++}},Vt=`
|
|
41
41
|
function _fluxH(tag,props,...children){
|
|
@@ -45,23 +45,23 @@ function _fluxH(tag,props,...children){
|
|
|
45
45
|
children.flat(Infinity).forEach(c=>{if(c==null)return;el.appendChild(c instanceof Node?c:document.createTextNode(String(c)));});
|
|
46
46
|
return el;
|
|
47
47
|
}`,Ht='\nfunction _fluxH(tag,props,...children){\n const VOID=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);\n if(tag==="")return children.flat(Infinity).map(c=>c==null?"":String(c)).join("");\n let attrs="";\n if(props){for(const[k,v]of Object.entries(props)){if(k==="class"||k==="className")attrs+=` class="${v}"`;else if(k==="style"&&typeof v==="object")attrs+=` style="${Object.entries(v).map(([p,val])=>p.replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+":"+val).join(";")}"`;else if(typeof v!=="function"&&typeof v!=="boolean")attrs+=` ${k}="${String(v).replace(/"/g,""")}"`;else if(v===true)attrs+=` ${k}`;}}\n const inner=children.flat(Infinity).map(c=>c==null?"":String(c)).join("");\n if(VOID.has(tag))return`<${tag}${attrs}>`;\n return`<${tag}${attrs}>${inner}</${tag}>`;\n}',zt=`
|
|
48
|
-
function _fluxCSS(css){const s=document.createElement("style");s.textContent=css;document.head.appendChild(s);return css;}`,
|
|
49
|
-
function _fluxCSS(css){return css;}`;function Ie(n,t={}){let e=t.target||"browser",s=new ht(n),r=s.transform(),a=s.hasJsx||n.includes("_fluxH")||n.includes("_fluxCSS");return{source:r,hasJsx:a,runtimeHelpers:(e==="browser"?Vt:Ht)+(e==="browser"?zt:Gt)}}Kt.exports={transformJsx:Ie,JsxPreprocessor:ht,FLUX_H_BROWSER:Vt,FLUX_H_SERVER:Ht,FLUX_CSS_BROWSER:zt,FLUX_CSS_SERVER:Gt}});var Jt=_((vs,Yt)=>{"use strict";var nt=new Set(["undefined","null","true","false","NaN","Infinity","arguments","this","super","console","document","window","navigator","location","history","screen","Math","JSON","Array","Object","String","Number","Boolean","Symbol","BigInt","Promise","Proxy","Reflect","WeakMap","WeakSet","WeakRef","Map","Set","Date","RegExp","Error","TypeError","RangeError","SyntaxError","URIError","EvalError","ReferenceError","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","atob","btoa","structuredClone","queueMicrotask","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","fetch","XMLHttpRequest","WebSocket","EventSource","FormData","Headers","Request","Response","URL","URLSearchParams","Blob","File","FileReader","alert","confirm","prompt","Event","CustomEvent","Node","Element","HTMLElement","DocumentFragment","MutationObserver","IntersectionObserver","ResizeObserver","process","Buffer","require","module","exports","__dirname","__filename","global","globalThis","setImmediate","clearImmediate","queueMicrotask","TextEncoder","TextDecoder","AbortController","AbortSignal","performance","Http","Fs","Path","Url","Crypto","Os","Net","Stream","Events","Util","http","fs","path","url","crypto","os","net","stream","events","util","_fluxH","_fluxCSS","print"]);function lt(n){let t="abcdefghijklmnopqrstuvwxyz",e="";for(n++;n>0;)e=t[(n-1)%26]+e,n=Math.floor((n-1)/26);return"_"+e}var wt=class{constructor(){this.map=new Map,this.counter=0,this.exported=new Set,this.imported=new Set}mangle(t){return this._collectExportedAndImported(t),this._collectDeclarations(t),this._walkProgram(t)}getMap(){return Object.fromEntries(this.map)}_collectExportedAndImported(t){for(let e of t.body){if(e.type==="ExportDecl"){let s=e.decl;s&&s.name&&this.exported.add(s.name),s&&s.type==="DestructureDecl"&&(s.pattern||[]).forEach(r=>r&&this.exported.add(r.alias||r.name||r.key))}e.type==="ImportDecl"&&(e.defaultName&&this.imported.add(e.defaultName),(e.names||[]).forEach(s=>this.imported.add(s)))}}_collectDeclarations(t){this._walkStmts(t.body,{toplevel:!0,collect:!0})}_walkProgram(t){let e=this._walkStmts(t.body,{toplevel:!0});return{...t,body:e}}_walkStmts(t,e={}){return t.map(s=>this._walkStmt(s,e))}_walkStmt(t,e={}){if(!t)return t;switch(t.type){case"VarDecl":return this._walkVarDecl(t,e);case"DestructureDecl":return this._walkDestructure(t,e);case"FnDecl":return this._walkFnDecl(t,e);case"ClassDecl":return this._walkClassDecl(t,e);case"IfStmt":return{...t,cond:this._walkExpr(t.cond),then:this._walkStmts(t.then),elseifs:t.elseifs.map(s=>({cond:this._walkExpr(s.cond),body:this._walkStmts(s.body)})),else_:t.else_?this._walkStmts(t.else_):null};case"ForInStmt":return{...t,var:this._mangleLocal(t.var),iter:this._walkExpr(t.iter),body:this._walkStmts(t.body)};case"WhileStmt":return{...t,cond:this._walkExpr(t.cond),body:this._walkStmts(t.body)};case"DoWhileStmt":return{...t,cond:this._walkExpr(t.cond),body:this._walkStmts(t.body)};case"MatchStmt":return{...t,subject:this._walkExpr(t.subject),arms:t.arms.map(s=>({...s,body:this._walkStmts(s.body)}))};case"ReturnStmt":return{...t,value:this._walkExpr(t.value)};case"ThrowStmt":return{...t,value:this._walkExpr(t.value)};case"TryCatchStmt":return{...t,tryBody:this._walkStmts(t.tryBody),catchParam:t.catchParam?this._mangleLocal(t.catchParam):null,catchBody:t.catchBody?this._walkStmts(t.catchBody):null,finallyBody:t.finallyBody?this._walkStmts(t.finallyBody):null};case"ExportDecl":{let s=t.decl;return{...t,decl:this._walkStmt(s,e)}}case"ImportDecl":return t;case"TypeDecl":return t;case"ExprStmt":return{...t,expr:this._walkExpr(t.expr)};case"BreakStmt":case"ContinueStmt":return t;default:return t}}_walkVarDecl(t,e){return e.collect?(this._registerName(t.name),t):{...t,name:this._mangleName(t.name),init:t.init?this._walkExpr(t.init):null}}_walkDestructure(t,e){if(e.collect)return(t.pattern||[]).forEach(s=>{s&&this._registerName(s.alias||s.name||s.key)}),t;if(t.patternType==="array"){let s=t.pattern.map(r=>r&&(r.rest?{...r,name:this._mangleName(r.name)}:{...r,name:this._mangleName(r.name),defaultVal:r.defaultVal?this._walkExpr(r.defaultVal):null}));return{...t,pattern:s,init:this._walkExpr(t.init)}}else{let s=t.pattern.map(r=>r&&(r.rest?{...r,key:r.key,alias:this._mangleName(r.alias||r.key)}:{...r,alias:this._mangleName(r.alias||r.key),defaultVal:r.defaultVal?this._walkExpr(r.defaultVal):null}));return{...t,pattern:s,init:this._walkExpr(t.init)}}}_walkFnDecl(t,e){if(e.collect&&t.name)return this._registerName(t.name),t;let s=t.name?this._mangleName(t.name):null,r=t.params.map(c=>({...c,name:this._mangleParam(c.name),defaultVal:c.defaultVal?this._walkExpr(c.defaultVal):null})),a=t.inline?this._walkExpr(t.body):this._walkStmts(t.body);return{...t,name:s,params:r,body:a}}_walkClassDecl(t,e){if(e.collect&&t.name)return this._registerName(t.name),t;let s=this._mangleName(t.name),r=t.methods.map(c=>{let h=c.params.map(p=>({...p,name:this._mangleParam(p.name),defaultVal:p.defaultVal?this._walkExpr(p.defaultVal):null})),l=c.inline?this._walkExpr(c.body):this._walkStmts(c.body);return{...c,params:h,body:l}}),a=t.superClass?this._mangleName(t.superClass):null;return{...t,name:s,superClass:a,methods:r}}_walkExpr(t){if(!t)return t;switch(t.type){case"Identifier":return{...t,name:this._mangleName(t.name)};case"NumberLit":case"BoolLit":case"NullLit":case"StringLit":case"SelfExpr":return t;case"TemplateLit":return{...t,parts:t.parts.map(e=>{if(e.type!=="expr")return e;let s=e.value;for(let[r,a]of this.map)s=s.replace(new RegExp(`(?<![\\w$])${r}(?![\\w$])`,"g"),a);return{...e,value:s}})};case"BinaryExpr":return{...t,left:this._walkExpr(t.left),right:this._walkExpr(t.right)};case"UnaryExpr":return{...t,operand:this._walkExpr(t.operand)};case"UpdateExpr":return{...t,operand:this._walkExpr(t.operand)};case"AwaitExpr":return{...t,operand:this._walkExpr(t.operand)};case"TypeofExpr":return{...t,operand:this._walkExpr(t.operand)};case"TernaryExpr":return{...t,cond:this._walkExpr(t.cond),then:this._walkExpr(t.then),else_:this._walkExpr(t.else_)};case"AssignExpr":return{...t,target:this._walkExpr(t.target),value:this._walkExpr(t.value)};case"SpreadExpr":return{...t,expr:this._walkExpr(t.expr)};case"PipeExpr":return{...t,left:this._walkExpr(t.left),right:this._walkExpr(t.right)};case"MemberExpr":return{...t,obj:this._walkExpr(t.obj)};case"OptMemberExpr":return{...t,obj:this._walkExpr(t.obj)};case"IndexExpr":return{...t,obj:this._walkExpr(t.obj),idx:this._walkExpr(t.idx)};case"OptIndexExpr":return{...t,obj:this._walkExpr(t.obj),idx:this._walkExpr(t.idx)};case"CallExpr":return{...t,callee:this._walkExpr(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"OptCallExpr":return{...t,callee:this._walkExpr(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"NewExpr":return{...t,callee:this._mangleName(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"LambdaExpr":return{...t,params:t.params.map(e=>({...e,name:this._mangleParam(e.name)})),body:this._walkExpr(t.body)};case"FnDecl":return this._walkFnDecl(t,{});case"ArrayExpr":return{...t,items:t.items.map(e=>this._walkExpr(e))};case"ObjectExpr":return{...t,pairs:t.pairs.map(e=>({...e,value:this._walkExpr(e.value)}))};case"RangeExpr":return{...t,start:this._walkExpr(t.start),end:this._walkExpr(t.end)};default:return t}}_registerName(t){!t||nt.has(t)||this.exported.has(t)||this.imported.has(t)||this.map.has(t)||this.map.set(t,lt(this.counter++))}_mangleName(t){return!t||nt.has(t)||this.exported.has(t)||this.imported.has(t)?t:this.map.has(t)?this.map.get(t):t}_mangleLocal(t){return!t||nt.has(t)?t:(this.map.has(t)||this.map.set(t,lt(this.counter++)),this.map.get(t))}_mangleParam(t){return!t||nt.has(t)?t:(this.map.has(t)||this.map.set(t,lt(this.counter++)),this.map.get(t))}};Yt.exports={Mangler:wt,SAFE:nt,makeName:lt}});var se=_((Rs,ee)=>{"use strict";var te={bg:"background",fg:"color",p:"padding",px:"padding-inline",py:"padding-block",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",m:"margin",mx:"margin-inline",my:"margin-block",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",radius:"border-radius",w:"width",h:"height","min-w":"min-width","max-w":"max-width","min-h":"min-height","max-h":"max-height",gap:"gap","col-gap":"column-gap","row-gap":"row-gap",text:"font-size",font:"font-family",weight:"font-weight",tracking:"letter-spacing",leading:"line-height",shadow:"box-shadow",opacity:"opacity",border:"border",outline:"outline",transition:"transition",cursor:"cursor",overflow:"overflow","overflow-x":"overflow-x","overflow-y":"overflow-y",z:"z-index",transform:"transform",content:"content",resize:"resize",appearance:"appearance","accent-color":"accent-color","object-fit":"object-fit",direction:"flex-direction",wrap:"flex-wrap",align:"align-items",justify:"justify-content","align-self":"align-self","justify-self":"justify-self",grow:"flex-grow",shrink:"flex-shrink",basis:"flex-basis",order:"order",cols:"grid-template-columns",rows:"grid-template-rows","col-span":"grid-column","row-span":"grid-row","place-items":"place-items","place-content":"place-content","list-style":"list-style","text-align":"text-align",decoration:"text-decoration","text-transform":"text-transform","white-space":"white-space","word-break":"word-break","user-select":"user-select","pointer-events":"pointer-events","vertical-align":"vertical-align",backdrop:"backdrop-filter",filter:"filter",clip:"clip-path",animation:"animation",position:"position",top:"top",right:"right",bottom:"bottom",left:"left",inset:"inset",color:"color",background:"background"},at={flex:"display: flex",grid:"display: grid",block:"display: block",inline:"display: inline","inline-flex":"display: inline-flex","inline-block":"display: inline-block","inline-grid":"display: inline-grid",bold:"font-weight: 700",italic:"font-style: italic",relative:"position: relative",absolute:"position: absolute",fixed:"position: fixed",sticky:"position: sticky",hidden:"display: none",pointer:"cursor: pointer",underline:"text-decoration: underline","line-through":"text-decoration: line-through",capitalize:"text-transform: capitalize",uppercase:"text-transform: uppercase",lowercase:"text-transform: lowercase",truncate:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap","select-none":"user-select: none","no-wrap":"white-space: nowrap","no-list":"list-style: none","no-outline":"outline: none","no-border":"border: none","no-bg":"background: transparent","no-padding":"padding: 0","no-margin":"margin: 0","no-resize":"resize: none",center:"text-align: center","items-center":"align-items: center","justify-center":"justify-content: center","place-center":"place-items: center","flex-col":"flex-direction: column","flex-row":"flex-direction: row","flex-wrap":"flex-wrap: wrap","flex-1":"flex: 1","w-full":"width: 100%","h-full":"height: 100%","w-screen":"width: 100vw","h-screen":"height: 100vh","box-border":"box-sizing: border-box"};function St(n){let t=n.trim();return te[t]||t}function At(n){let t=n.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function Xt(n,t){return n=n.trim(),!t||n.startsWith("@")||t.startsWith("@keyframes")||t.startsWith("@font-face")?n:n.includes("&")?n.replace(/&/g,t):t+" "+n}function Zt(n){let t=[];return n.split(";").forEach(e=>{let s=e.trim();if(!s||s.startsWith("//"))return;if(at[s]){at[s].split(";").forEach(a=>{let c=a.trim();c&&t.push(c)});return}let r=s.indexOf(":");if(r!==-1){let a=St(s.slice(0,r)),c=At(s.slice(r+1));c!==""&&t.push(a+": "+c)}}),t}function Rt(n,t){let e=" ".repeat(t||0),s=e+" ",r=n.split(`
|
|
50
|
-
`),a=new Map,c=[],h=[];function l(){return h.length?h[h.length-1]:null}function p(g,f){a.has(g)||a.set(g,[]),a.get(g).push(f)}function m(g,f){if(g.includes(";")){g.split(";").forEach(
|
|
48
|
+
function _fluxCSS(css){const s=document.createElement("style");s.textContent=css;document.head.appendChild(s);return css;}`,Kt=`
|
|
49
|
+
function _fluxCSS(css){return css;}`;function De(n,t={}){let e=t.target||"browser",s=new ht(n),r=s.transform(),a=s.hasJsx||n.includes("_fluxH")||n.includes("_fluxCSS");return{source:r,hasJsx:a,runtimeHelpers:(e==="browser"?Vt:Ht)+(e==="browser"?zt:Kt)}}Gt.exports={transformJsx:De,JsxPreprocessor:ht,FLUX_H_BROWSER:Vt,FLUX_H_SERVER:Ht,FLUX_CSS_BROWSER:zt,FLUX_CSS_SERVER:Kt}});var Jt=_((vs,qt)=>{"use strict";var nt=new Set(["undefined","null","true","false","NaN","Infinity","arguments","this","super","console","document","window","navigator","location","history","screen","Math","JSON","Array","Object","String","Number","Boolean","Symbol","BigInt","Promise","Proxy","Reflect","WeakMap","WeakSet","WeakRef","Map","Set","Date","RegExp","Error","TypeError","RangeError","SyntaxError","URIError","EvalError","ReferenceError","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","atob","btoa","structuredClone","queueMicrotask","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","fetch","XMLHttpRequest","WebSocket","EventSource","FormData","Headers","Request","Response","URL","URLSearchParams","Blob","File","FileReader","alert","confirm","prompt","Event","CustomEvent","Node","Element","HTMLElement","DocumentFragment","MutationObserver","IntersectionObserver","ResizeObserver","process","Buffer","require","module","exports","__dirname","__filename","global","globalThis","setImmediate","clearImmediate","queueMicrotask","TextEncoder","TextDecoder","AbortController","AbortSignal","performance","Http","Fs","Path","Url","Crypto","Os","Net","Stream","Events","Util","http","fs","path","url","crypto","os","net","stream","events","util","_fluxH","_fluxCSS","print"]);function lt(n){let t="abcdefghijklmnopqrstuvwxyz",e="";for(n++;n>0;)e=t[(n-1)%26]+e,n=Math.floor((n-1)/26);return"_"+e}var wt=class{constructor(){this.map=new Map,this.counter=0,this.exported=new Set,this.imported=new Set}mangle(t){return this._collectExportedAndImported(t),this._collectDeclarations(t),this._walkProgram(t)}getMap(){return Object.fromEntries(this.map)}_collectExportedAndImported(t){for(let e of t.body){if(e.type==="ExportDecl"){let s=e.decl;s&&s.name&&this.exported.add(s.name),s&&s.type==="DestructureDecl"&&(s.pattern||[]).forEach(r=>r&&this.exported.add(r.alias||r.name||r.key))}e.type==="ImportDecl"&&(e.defaultName&&this.imported.add(e.defaultName),(e.names||[]).forEach(s=>this.imported.add(s)))}}_collectDeclarations(t){this._walkStmts(t.body,{toplevel:!0,collect:!0})}_walkProgram(t){let e=this._walkStmts(t.body,{toplevel:!0});return{...t,body:e}}_walkStmts(t,e={}){return t.map(s=>this._walkStmt(s,e))}_walkStmt(t,e={}){if(!t)return t;switch(t.type){case"VarDecl":return this._walkVarDecl(t,e);case"DestructureDecl":return this._walkDestructure(t,e);case"FnDecl":return this._walkFnDecl(t,e);case"ClassDecl":return this._walkClassDecl(t,e);case"IfStmt":return{...t,cond:this._walkExpr(t.cond),then:this._walkStmts(t.then),elseifs:t.elseifs.map(s=>({cond:this._walkExpr(s.cond),body:this._walkStmts(s.body)})),else_:t.else_?this._walkStmts(t.else_):null};case"ForInStmt":return{...t,var:this._mangleLocal(t.var),iter:this._walkExpr(t.iter),body:this._walkStmts(t.body)};case"WhileStmt":return{...t,cond:this._walkExpr(t.cond),body:this._walkStmts(t.body)};case"DoWhileStmt":return{...t,cond:this._walkExpr(t.cond),body:this._walkStmts(t.body)};case"MatchStmt":return{...t,subject:this._walkExpr(t.subject),arms:t.arms.map(s=>({...s,body:this._walkStmts(s.body)}))};case"ReturnStmt":return{...t,value:this._walkExpr(t.value)};case"ThrowStmt":return{...t,value:this._walkExpr(t.value)};case"TryCatchStmt":return{...t,tryBody:this._walkStmts(t.tryBody),catchParam:t.catchParam?this._mangleLocal(t.catchParam):null,catchBody:t.catchBody?this._walkStmts(t.catchBody):null,finallyBody:t.finallyBody?this._walkStmts(t.finallyBody):null};case"ExportDecl":{let s=t.decl;return{...t,decl:this._walkStmt(s,e)}}case"ImportDecl":return t;case"TypeDecl":return t;case"ExprStmt":return{...t,expr:this._walkExpr(t.expr)};case"BreakStmt":case"ContinueStmt":return t;default:return t}}_walkVarDecl(t,e){return e.collect?(this._registerName(t.name),t):{...t,name:this._mangleName(t.name),init:t.init?this._walkExpr(t.init):null}}_walkDestructure(t,e){if(e.collect)return(t.pattern||[]).forEach(s=>{s&&this._registerName(s.alias||s.name||s.key)}),t;if(t.patternType==="array"){let s=t.pattern.map(r=>r&&(r.rest?{...r,name:this._mangleName(r.name)}:{...r,name:this._mangleName(r.name),defaultVal:r.defaultVal?this._walkExpr(r.defaultVal):null}));return{...t,pattern:s,init:this._walkExpr(t.init)}}else{let s=t.pattern.map(r=>r&&(r.rest?{...r,key:r.key,alias:this._mangleName(r.alias||r.key)}:{...r,alias:this._mangleName(r.alias||r.key),defaultVal:r.defaultVal?this._walkExpr(r.defaultVal):null}));return{...t,pattern:s,init:this._walkExpr(t.init)}}}_walkFnDecl(t,e){if(e.collect&&t.name)return this._registerName(t.name),t;let s=t.name?this._mangleName(t.name):null,r=t.params.map(c=>({...c,name:this._mangleParam(c.name),defaultVal:c.defaultVal?this._walkExpr(c.defaultVal):null})),a=t.inline?this._walkExpr(t.body):this._walkStmts(t.body);return{...t,name:s,params:r,body:a}}_walkClassDecl(t,e){if(e.collect&&t.name)return this._registerName(t.name),t;let s=this._mangleName(t.name),r=t.methods.map(c=>{let h=c.params.map(p=>({...p,name:this._mangleParam(p.name),defaultVal:p.defaultVal?this._walkExpr(p.defaultVal):null})),l=c.inline?this._walkExpr(c.body):this._walkStmts(c.body);return{...c,params:h,body:l}}),a=t.superClass?this._mangleName(t.superClass):null;return{...t,name:s,superClass:a,methods:r}}_walkExpr(t){if(!t)return t;switch(t.type){case"Identifier":return{...t,name:this._mangleName(t.name)};case"NumberLit":case"BoolLit":case"NullLit":case"StringLit":case"SelfExpr":return t;case"TemplateLit":return{...t,parts:t.parts.map(e=>{if(e.type!=="expr")return e;let s=e.value;for(let[r,a]of this.map)s=s.replace(new RegExp(`(?<![\\w$])${r}(?![\\w$])`,"g"),a);return{...e,value:s}})};case"BinaryExpr":return{...t,left:this._walkExpr(t.left),right:this._walkExpr(t.right)};case"UnaryExpr":return{...t,operand:this._walkExpr(t.operand)};case"UpdateExpr":return{...t,operand:this._walkExpr(t.operand)};case"AwaitExpr":return{...t,operand:this._walkExpr(t.operand)};case"TypeofExpr":return{...t,operand:this._walkExpr(t.operand)};case"TernaryExpr":return{...t,cond:this._walkExpr(t.cond),then:this._walkExpr(t.then),else_:this._walkExpr(t.else_)};case"AssignExpr":return{...t,target:this._walkExpr(t.target),value:this._walkExpr(t.value)};case"SpreadExpr":return{...t,expr:this._walkExpr(t.expr)};case"PipeExpr":return{...t,left:this._walkExpr(t.left),right:this._walkExpr(t.right)};case"MemberExpr":return{...t,obj:this._walkExpr(t.obj)};case"OptMemberExpr":return{...t,obj:this._walkExpr(t.obj)};case"IndexExpr":return{...t,obj:this._walkExpr(t.obj),idx:this._walkExpr(t.idx)};case"OptIndexExpr":return{...t,obj:this._walkExpr(t.obj),idx:this._walkExpr(t.idx)};case"CallExpr":return{...t,callee:this._walkExpr(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"OptCallExpr":return{...t,callee:this._walkExpr(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"NewExpr":return{...t,callee:this._mangleName(t.callee),args:t.args.map(e=>this._walkExpr(e))};case"LambdaExpr":return{...t,params:t.params.map(e=>({...e,name:this._mangleParam(e.name)})),body:this._walkExpr(t.body)};case"FnDecl":return this._walkFnDecl(t,{});case"ArrayExpr":return{...t,items:t.items.map(e=>this._walkExpr(e))};case"ObjectExpr":return{...t,pairs:t.pairs.map(e=>({...e,value:this._walkExpr(e.value)}))};case"RangeExpr":return{...t,start:this._walkExpr(t.start),end:this._walkExpr(t.end)};default:return t}}_registerName(t){!t||nt.has(t)||this.exported.has(t)||this.imported.has(t)||this.map.has(t)||this.map.set(t,lt(this.counter++))}_mangleName(t){return!t||nt.has(t)||this.exported.has(t)||this.imported.has(t)?t:this.map.has(t)?this.map.get(t):t}_mangleLocal(t){return!t||nt.has(t)?t:(this.map.has(t)||this.map.set(t,lt(this.counter++)),this.map.get(t))}_mangleParam(t){return!t||nt.has(t)?t:(this.map.has(t)||this.map.set(t,lt(this.counter++)),this.map.get(t))}};qt.exports={Mangler:wt,SAFE:nt,makeName:lt}});var se=_((Rs,ee)=>{"use strict";var te={bg:"background",fg:"color",p:"padding",px:"padding-inline",py:"padding-block",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",m:"margin",mx:"margin-inline",my:"margin-block",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",radius:"border-radius",w:"width",h:"height","min-w":"min-width","max-w":"max-width","min-h":"min-height","max-h":"max-height",gap:"gap","col-gap":"column-gap","row-gap":"row-gap",text:"font-size",font:"font-family",weight:"font-weight",tracking:"letter-spacing",leading:"line-height",shadow:"box-shadow",opacity:"opacity",border:"border",outline:"outline",transition:"transition",cursor:"cursor",overflow:"overflow","overflow-x":"overflow-x","overflow-y":"overflow-y",z:"z-index",transform:"transform",content:"content",resize:"resize",appearance:"appearance","accent-color":"accent-color","object-fit":"object-fit",direction:"flex-direction",wrap:"flex-wrap",align:"align-items",justify:"justify-content","align-self":"align-self","justify-self":"justify-self",grow:"flex-grow",shrink:"flex-shrink",basis:"flex-basis",order:"order",cols:"grid-template-columns",rows:"grid-template-rows","col-span":"grid-column","row-span":"grid-row","place-items":"place-items","place-content":"place-content","list-style":"list-style","text-align":"text-align",decoration:"text-decoration","text-transform":"text-transform","white-space":"white-space","word-break":"word-break","user-select":"user-select","pointer-events":"pointer-events","vertical-align":"vertical-align",backdrop:"backdrop-filter",filter:"filter",clip:"clip-path",animation:"animation",position:"position",top:"top",right:"right",bottom:"bottom",left:"left",inset:"inset",color:"color",background:"background"},at={flex:"display: flex",grid:"display: grid",block:"display: block",inline:"display: inline","inline-flex":"display: inline-flex","inline-block":"display: inline-block","inline-grid":"display: inline-grid",bold:"font-weight: 700",italic:"font-style: italic",relative:"position: relative",absolute:"position: absolute",fixed:"position: fixed",sticky:"position: sticky",hidden:"display: none",pointer:"cursor: pointer",underline:"text-decoration: underline","line-through":"text-decoration: line-through",capitalize:"text-transform: capitalize",uppercase:"text-transform: uppercase",lowercase:"text-transform: lowercase",truncate:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap","select-none":"user-select: none","no-wrap":"white-space: nowrap","no-list":"list-style: none","no-outline":"outline: none","no-border":"border: none","no-bg":"background: transparent","no-padding":"padding: 0","no-margin":"margin: 0","no-resize":"resize: none",center:"text-align: center","items-center":"align-items: center","justify-center":"justify-content: center","place-center":"place-items: center","flex-col":"flex-direction: column","flex-row":"flex-direction: row","flex-wrap":"flex-wrap: wrap","flex-1":"flex: 1","w-full":"width: 100%","h-full":"height: 100%","w-screen":"width: 100vw","h-screen":"height: 100vh","box-border":"box-sizing: border-box"};function St(n){let t=n.trim();return te[t]||t}function At(n){let t=n.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function Xt(n,t){return n=n.trim(),!t||n.startsWith("@")||t.startsWith("@keyframes")||t.startsWith("@font-face")?n:n.includes("&")?n.replace(/&/g,t):t+" "+n}function Zt(n){let t=[];return n.split(";").forEach(e=>{let s=e.trim();if(!s||s.startsWith("//"))return;if(at[s]){at[s].split(";").forEach(a=>{let c=a.trim();c&&t.push(c)});return}let r=s.indexOf(":");if(r!==-1){let a=St(s.slice(0,r)),c=At(s.slice(r+1));c!==""&&t.push(a+": "+c)}}),t}function Rt(n,t){let e=" ".repeat(t||0),s=e+" ",r=n.split(`
|
|
50
|
+
`),a=new Map,c=[],h=[];function l(){return h.length?h[h.length-1]:null}function p(g,f){a.has(g)||a.set(g,[]),a.get(g).push(f)}function m(g,f){if(g.includes(";")){g.split(";").forEach(b=>{let w=b.trim();w&&m(w,f)});return}if(at[g]){at[g].split(";").forEach(b=>{let w=b.trim();w&&p(f,w)});return}let T=g.indexOf(":");if(T!==-1){let b=St(g.slice(0,T)),w=At(g.slice(T+1));w!==""&&p(f,b+": "+w)}}function y(g){let f=1,T="",b=g;for(;b<r.length&&f>0;){let w=r[b++];for(let S of w)S==="{"?f++:S==="}"&&f--;if(f>0)T+=w+`
|
|
51
51
|
`;else{let S=w.lastIndexOf("}");S>0&&(T+=w.slice(0,S)+`
|
|
52
|
-
`)}}return{inner:T,nextI:
|
|
53
|
-
`).map(v=>{let B=v.trim();if(!B||B==="{"||B==="}")return v;let $=B.indexOf(":");if($!==-1&&!B.slice(0,$).includes("{")){let P=St(B.slice(0,$)),
|
|
52
|
+
`)}}return{inner:T,nextI:b}}let u=0;for(;u<r.length;){let f=r[u++].trim();if(!f||f.startsWith("//"))continue;let T=f.indexOf("{"),b=f.lastIndexOf("}");if(f.startsWith("@keyframes")||f.startsWith("@font-face")){let w=T!==-1?f.slice(0,T).trim():f.trim(),S="";if(T!==-1&&b!==-1&&b>T)S=f.slice(T+1,b);else if(T!==-1){let v=y(u);u=v.nextI,S=v.inner}let A=S.split(`
|
|
53
|
+
`).map(v=>{let B=v.trim();if(!B||B==="{"||B==="}")return v;let $=B.indexOf(":");if($!==-1&&!B.slice(0,$).includes("{")){let P=St(B.slice(0,$)),U=At(B.slice($+1));return v.replace(B,P+": "+U)}return v}).join(`
|
|
54
54
|
`);c.push(`${e}${w} {
|
|
55
55
|
${A}${e}}
|
|
56
|
-
`);continue}if(f.startsWith("@media")||f.startsWith("@supports")||f.startsWith("@layer")){let w=T!==-1?f.slice(0,T).trim():f.trim(),S="";if(T!==-1&&
|
|
56
|
+
`);continue}if(f.startsWith("@media")||f.startsWith("@supports")||f.startsWith("@layer")){let w=T!==-1?f.slice(0,T).trim():f.trim(),S="";if(T!==-1&&b!==-1&&b>T)S=f.slice(T+1,b);else if(T!==-1){let v=y(u);u=v.nextI,S=v.inner}let A=Rt(S,(t||0)+1);c.push(`${e}${w} {
|
|
57
57
|
${A}${e}}
|
|
58
|
-
`);continue}if(T!==-1&&
|
|
58
|
+
`);continue}if(T!==-1&&b!==-1&&b>T){let w=f.slice(0,T).trim(),S=f.slice(T+1,b).trim(),A=Xt(w,l());a.has(A)||a.set(A,[]),S&&Zt(S).forEach(v=>p(A,v));continue}if(T!==-1){let w=f.slice(0,T).trim(),S=Xt(w,l());h.push(S),a.has(S)||a.set(S,[]);let A=f.slice(T+1).trim();A&&Zt(A).forEach(v=>p(S,v));continue}if(f==="}"||f==="};"){h.pop();continue}h.length>0&&m(f,l())}let d="";for(let[g,f]of a)if(f.length!==0){d+=`${e}${g} {
|
|
59
59
|
`;for(let T of f)d+=`${s}${T};
|
|
60
60
|
`;d+=`${e}}
|
|
61
61
|
`}for(let g of c)d+=g;return d}var vt=class{constructor(t){this.src=t,this.pos=0,this.out=""}transform(){for(;this.pos<this.src.length;)this.scan();return this.out}scan(){let t=this.src[this.pos];if(t==="/"&&this.src[this.pos+1]==="/"){let e=this.src.indexOf(`
|
|
62
62
|
`,this.pos);e===-1?(this.out+=this.src.slice(this.pos),this.pos=this.src.length):(this.out+=this.src.slice(this.pos,e+1),this.pos=e+1);return}if(t==="/"&&this.src[this.pos+1]==="*"){let e=this.src.indexOf("*/",this.pos+2);e===-1?(this.out+=this.src.slice(this.pos),this.pos=this.src.length):(this.out+=this.src.slice(this.pos,e+2),this.pos=e+2);return}if(t==='"'||t==="'"||t==="`"){this.passString(t);return}if(t==="c"&&this.src.slice(this.pos,this.pos+3)==="css"){let e=this.pos>0?this.src[this.pos-1]:`
|
|
63
63
|
`,s=this.src[this.pos+3]||"";if(!/[a-zA-Z0-9_]/.test(e)&&!/[a-zA-Z0-9_]/.test(s)){let r=this.pos+3;for(;r<this.src.length&&(this.src[r]===" "||this.src[r]===" "||this.src[r]===`
|
|
64
|
-
`||this.src[r]==="\r");)r++;if(this.src[r]==="{"){r++;let a=1,c=r;for(;r<this.src.length&&a>0;){let p=this.src[r];if(p==='"'||p==="'"||p==="`"){let m=p;for(r++;r<this.src.length&&this.src[r]!==m;)this.src[r]==="\\"&&r++,r++;r++}else p==="{"?(a++,r++):(p==="}"&&a--,r++)}let h=this.src.slice(c,r-1),l=Rt(h);this.out+="`"+l.replace(/\\/g,"\\\\").replace(/`/g,"\\`")+"`",this.pos=r;return}}}this.out+=t,this.pos++}passString(t){for(this.out+=t,this.pos++;this.pos<this.src.length;){let e=this.src[this.pos];if(e==="\\"){this.out+=e+(this.src[this.pos+1]||""),this.pos+=2;continue}if(e===t){this.out+=e,this.pos++;return}this.out+=e,this.pos++}}};function Oe(n){return new vt(n).transform()}ee.exports={transformCss:Oe,parseCssBlockContent:Rt,CSS_PROP_MAP:te,CSS_BOOL_MAP:at}});var re=_((Is,ie)=>{"use strict";var ot=class{constructor(t,e,s=null){this.message=t,this.loc=e,this.hint=s,this.name="CheckError",e&&(this.line=e.line,this.col=e.col)}},I=class{constructor(t=null){this.parent=t,this.vars=new Map}define(t,e,s){this.vars.set(t,{kind:e,loc:s})}lookup(t){let e=this;for(;e;){if(e.vars.has(t))return e.vars.get(t);e=e.parent}return null}isVal(t){let e=this.lookup(t);return e&&e.kind==="val"}},It=class{constructor(){this.errors=[],this.warnings=[]}check(t){this.errors=[],this.warnings=[];let e=new I;return this.walkStmts(t.body,e),{errors:this.errors,warnings:this.warnings}}error(t,e,s=null){this.errors.push(new ot(t,e,s))}warn(t,e,s=null){this.warnings.push(new ot(t,e,s))}walkStmts(t,e){for(let s of t)this.walkStmt(s,e)}walkStmt(t,e){if(t)switch(t.type){case"VarDecl":t.init&&this.walkExpr(t.init,e),e.define(t.name,t.kind,t.loc);break;case"DestructureDecl":if(t.init&&this.walkExpr(t.init,e),t.patternType==="object")for(let s of t.pattern)e.define(s.alias,t.kind,t.loc);else for(let s of t.pattern)s&&e.define(s.name,t.kind,t.loc);break;case"FnDecl":{let s=new I(e);for(let r of t.params)s.define(r.name,"val",t.loc);t.name&&e.define(t.name,"val",t.loc),t.inline?this.walkExpr(t.body,s):this.walkStmts(t.body,s);break}case"ClassDecl":{e.define(t.name,"val",t.loc);let s=new I(e);for(let r of t.fields)s.define(r.name,"var",t.loc);for(let r of t.methods)this.walkStmt(r,s);break}case"TypeDecl":for(let s of t.variants)e.define(s.name,"val",t.loc);break;case"InterfaceDecl":e.define(t.name,"val",t.loc);break;case"EnumDecl":e.define(t.name,"val",t.loc);break;case"IfStmt":this.walkExpr(t.cond,e),this.walkStmts(t.then,new I(e));for(let s of t.elseifs)this.walkExpr(s.cond,e),this.walkStmts(s.body,new I(e));t.else_&&this.walkStmts(t.else_,new I(e));break;case"ForInStmt":{this.walkExpr(t.iter,e);let s=new I(e);s.define(t.var,"val",t.loc),this.walkStmts(t.body,s);break}case"WhileStmt":this.walkExpr(t.cond,e),this.walkStmts(t.body,new I(e));break;case"DoWhileStmt":this.walkStmts(t.body,new I(e)),this.walkExpr(t.cond,e);break;case"MatchStmt":this.walkExpr(t.subject,e);for(let s of t.arms){let r=new I(e);if(s.pattern.type==="VariantPat")for(let a of s.pattern.bindings)r.define(a,"val",t.loc);s.guard&&this.walkExpr(s.guard,r),this.walkStmts(s.body,r)}break;case"ReturnStmt":t.value&&this.walkExpr(t.value,e);break;case"ThrowStmt":this.walkExpr(t.value,e);break;case"TryCatchStmt":{if(this.walkStmts(t.tryBody,new I(e)),t.catchBody){let s=new I(e);t.catchParam&&s.define(t.catchParam,"val",t.loc),this.walkStmts(t.catchBody,s)}t.finallyBody&&this.walkStmts(t.finallyBody,new I(e));break}case"ImportDecl":t.defaultName&&e.define(t.defaultName,"val",t.loc),t.namespaceName&&e.define(t.namespaceName,"val",t.loc);for(let s of t.names)e.define(typeof s=="string"?s:s.alias,"val",t.loc);break;case"ExportDecl":this.walkStmt(t.isDefault?{type:"ExprStmt",expr:t.decl}:t.decl,e);break;case"ExprStmt":this.walkExpr(t.expr,e);break;case"BreakStmt":case"ContinueStmt":break;default:}}walkExpr(t,e){if(t)switch(t.type){case"AssignExpr":{let s=t.target;s.type==="Identifier"&&e.isVal(s.name)&&this.error(`Cannot reassign 'val ${s.name}' \u2014 val is immutable`,s.loc,`Use 'var ${s.name}' if you need a mutable variable`),this.walkExpr(t.target,e),this.walkExpr(t.value,e);break}case"UpdateExpr":t.operand.type==="Identifier"&&e.isVal(t.operand.name)&&this.error(`Cannot apply '${t.op}' to 'val ${t.operand.name}' \u2014 val is immutable`,t.operand.loc,`Use 'var ${t.operand.name}' if you need a mutable variable`),this.walkExpr(t.operand,e);break;case"BinaryExpr":case"PipeExpr":this.walkExpr(t.left,e),this.walkExpr(t.right,e);break;case"UnaryExpr":case"AwaitExpr":case"TypeofExpr":this.walkExpr(t.operand,e);break;case"TernaryExpr":this.walkExpr(t.cond,e),this.walkExpr(t.then,e),this.walkExpr(t.else_,e);break;case"CallExpr":case"OptCallExpr":this.walkExpr(t.callee,e);for(let s of t.args)this.walkExpr(s,e);break;case"MemberExpr":case"OptMemberExpr":this.walkExpr(t.obj,e);break;case"IndexExpr":case"OptIndexExpr":this.walkExpr(t.obj,e),this.walkExpr(t.idx,e);break;case"NewExpr":for(let s of t.args)this.walkExpr(s,e);break;case"ArrayExpr":for(let s of t.items)s&&this.walkExpr(s,e);break;case"ObjectExpr":for(let s of t.pairs)s.value&&this.walkExpr(s.value,e);break;case"SpreadExpr":this.walkExpr(t.expr,e);break;case"LambdaExpr":{let s=new I(e);for(let r of t.params)s.define(r.name,"val",null);this.walkExpr(t.body,s);break}case"FnDecl":{let s=new I(e);for(let r of t.params)s.define(r.name,"val",null);t.inline?this.walkExpr(t.body,s):this.walkStmts(t.body,s);break}case"TemplateLit":break;case"CastExpr":case"AsConstExpr":case"SatisfiesExpr":case"IsExpr":case"NonNullExpr":this.walkExpr(t.expr,e);break;case"RangeExpr":this.walkExpr(t.start,e),this.walkExpr(t.end,e);break;case"Identifier":case"NumberLit":case"BoolLit":case"NullLit":case"StringLit":case"SelfExpr":break;default:}}};ie.exports={Checker:It}});var oe=_((Os,le)=>{"use strict";var O=Object.freeze({kind:"any"}),E=Object.freeze({kind:"unknown"}),ct=Object.freeze({kind:"never"}),D=Object.freeze({kind:"void"}),V=Object.freeze({kind:"null"}),C=Object.freeze({kind:"primitive",name:"String"}),U=Object.freeze({kind:"primitive",name:"Int"}),K=Object.freeze({kind:"primitive",name:"Float"}),L=Object.freeze({kind:"primitive",name:"Number"}),j=Object.freeze({kind:"primitive",name:"Bool"});function F(...n){let t=[];for(let r of n)r&&r.kind==="union"?t.push(...r.members):r&&t.push(r);let e=new Set,s=t.filter(r=>{let a=b(r);return e.has(a)?!1:(e.add(a),!0)});return s.length===0?ct:s.length===1?s[0]:{kind:"union",members:s}}function ae(...n){let t=[];for(let e of n)e&&e.kind==="intersection"?t.push(...e.members):e&&t.push(e);return t.length===1?t[0]:{kind:"intersection",members:t}}function X(n){return{kind:"generic",name:"Array",args:[n||E]}}function Ot(n){return{kind:"tuple",types:n||[]}}function ce(n){return F(n,V)}function k(n){return{kind:"named",name:n}}function R(n,t){return{kind:"fn",params:n||[],ret:t||D}}function ut(n){return{kind:"object",shape:n||new Map}}function he(n,t){return{kind:"record",key:n||C,val:t||E}}function De(n,t){return{kind:"literal",value:n,prim:t}}function b(n){if(!n)return"unknown";switch(n.kind){case"any":return"Any";case"unknown":return"Unknown";case"never":return"Never";case"void":return"Void";case"null":return"Null";case"primitive":return n.name;case"literal":return JSON.stringify(n.value);case"union":return n.members.map(b).join(" | ");case"intersection":return n.members.map(b).join(" & ");case"tuple":return"["+n.types.map(b).join(", ")+"]";case"object":return"{"+[...(n.shape||new Map).entries()].map(([t,e])=>`${t}: ${b(e)}`).join(", ")+"}";case"record":return`Record<${b(n.key)}, ${b(n.val)}>`;case"generic":return n.name+(n.args&&n.args.length?"<"+n.args.map(b).join(", ")+">":"");case"named":return n.name;case"fn":return`(${(n.params||[]).map(b).join(", ")}) -> ${b(n.ret)}`;case"keyof":return`keyof ${b(n.inner)}`;case"conditional":return`${b(n.check)} extends ${b(n.extends)} ? ${b(n.then)} : ${b(n.else)}`;default:return"unknown"}}function G(n,t){let e=[],s=0,r=0;for(let a=0;a<n.length;a++){let c=n[a];"<([{".includes(c)?s++:">)]}".includes(c)?s--:s===0&&n.slice(a,a+t.length)===t&&(e.push(n.slice(r,a)),r=a+t.length,a+=t.length-1)}return e.push(n.slice(r)),e.filter(a=>a.trim().length>0)}var ne={String:C,string:C,Int:U,int:U,Float:K,float:K,Number:L,number:L,Bool:j,boolean:j,Boolean:j,bool:j,Void:D,void:D,Never:ct,never:ct,Any:O,any:O,Unknown:E,unknown:E,Null:V,null:V,undefined:D,Object:k("Object"),object:k("Object"),Symbol:k("Symbol"),symbol:k("Symbol"),BigInt:k("BigInt"),bigint:k("BigInt")};function N(n){if(!n)return null;n=n.trim(),n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim());let t=G(n," | ");if(t.length>1)return F(...t.map(N));let e=G(n," & ");if(e.length>1)return ae(...e.map(N));let s=n.match(/^(\w+)\s+extends\s+(.+?)\s*\?\s*(.+?)\s*:\s*(.+)$/);if(s)return{kind:"conditional",check:N(s[1]),extends:N(s[2]),then:N(s[3]),else:N(s[4])};if(n.startsWith("keyof "))return{kind:"keyof",inner:N(n.slice(6))};if(n.startsWith("typeof "))return{kind:"typeof",name:n.slice(7)};if(n.startsWith("readonly "))return N(n.slice(9));if(n.startsWith("infer "))return O;let r=n.match(/^fn\(([^)]*)\)\s*->\s*(.+)$/)||n.match(/^\(([^)]*)\)\s*->\s*(.+)$/);if(r){let c=r[1].trim(),h=r[2].trim(),l=c?G(c,", ").map(p=>{let m=p.indexOf(":");return N(m>=0?p.slice(m+1).trim():p.trim())}):[];return R(l,N(h))}if(n.endsWith("?"))return ce(N(n.slice(0,-1)));if(n.endsWith("[]"))return X(N(n.slice(0,-2)));if(n.startsWith("[")&&n.endsWith("]")){let c=n.slice(1,-1);if(!c.trim())return Ot([]);let h=G(c,", ");return Ot(h.map(l=>N(l.replace(/^\.\.\./,"").trim())))}if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).trim(),h=new Map;if(c){let l=G(c,", ");for(let p of l){let m=p.match(/^\[(\w+):\s*\w+\]:\s*(.+)$/);if(m){h.set("[index]",N(m[2]));continue}let y=p.indexOf(":");if(y>=0){let u=p.slice(0,y).trim().replace(/^readonly\s+/,""),d=u.replace(/\?$/,""),g=u.endsWith("?"),f=N(p.slice(y+1).trim());h.set(d,g?F(f,D):f)}}}return ut(h)}let a=n.match(/^(\w+)<(.+)>$/s);if(a){let c=a[1],l=G(a[2],", ").map(p=>N(p.trim()));switch(c){case"Array":case"List":case"ReadonlyArray":return X(l[0]||E);case"NonNullable":return $e(l[0]);case"Partial":return{kind:"utility",util:"Partial",inner:l[0]};case"Required":return{kind:"utility",util:"Required",inner:l[0]};case"Readonly":return l[0];case"Record":return he(l[0]||C,l[1]||E);case"Pick":return{kind:"utility",util:"Pick",inner:l[0],keys:l[1]};case"Omit":return{kind:"utility",util:"Omit",inner:l[0],keys:l[1]};case"Exclude":return{kind:"utility",util:"Exclude",inner:l[0],keys:l[1]};case"Extract":return{kind:"utility",util:"Extract",inner:l[0],keys:l[1]};case"ReturnType":return{kind:"utility",util:"ReturnType",inner:l[0]};case"InstanceType":return{kind:"utility",util:"InstanceType",inner:l[0]};case"Parameters":return{kind:"utility",util:"Parameters",inner:l[0]};case"Awaited":return{kind:"utility",util:"Awaited",inner:l[0]};case"Promise":return{kind:"generic",name:"Promise",args:l};case"Map":return{kind:"generic",name:"Map",args:l};case"Set":return{kind:"generic",name:"Set",args:l};case"WeakMap":return{kind:"generic",name:"WeakMap",args:l};default:return{kind:"generic",name:c,args:l}}}return ne[n]?ne[n]:k(n)}function $e(n){return n?n.kind==="union"?F(...n.members.filter(t=>t.kind!=="null"&&t.kind!=="void")):n.kind==="null"||n.kind==="void"?ct:n:E}function _e(n,t){return M(n,t)}function M(n,t){if(!n||!t||t.kind==="any"||n.kind==="any"||n.kind==="never"||t.kind==="unknown"||n.kind==="void"&&t.kind==="void"||n.kind==="null"&&t.kind==="null"||n.kind==="never"&&t.kind==="never")return!0;if(n.kind==="null"&&t.kind==="union")return t.members.some(e=>e.kind==="null"||e.kind==="any"||e.kind==="void");if(n.kind==="union")return n.members.every(e=>M(e,t));if(t.kind==="union")return t.members.some(e=>M(n,e));if(n.kind==="intersection")return n.members.some(e=>M(e,t));if(t.kind==="intersection")return t.members.every(e=>M(n,e));if(n.kind==="primitive"&&t.kind==="primitive")return!!(n.name===t.name||t.name==="Number"&&["Int","Float","Number"].includes(n.name)||t.name==="Float"&&n.name==="Int"||n.name==="Bool"&&t.name==="Boolean"||n.name==="Boolean"&&t.name==="Bool");if(n.kind==="literal"&&t.kind==="primitive")return{string:"String",number:"Number",boolean:"Bool"}[n.prim]===t.name||n.prim==="number"&&["Int","Float","Number"].includes(t.name);if(n.kind==="named"&&t.kind==="named")return n.name===t.name||t.name==="Object";if(n.kind==="generic"&&t.kind==="generic"){let e=new Set(["Array","List","ReadonlyArray"]);return n.name!==t.name&&!(e.has(n.name)&&e.has(t.name))||n.args.length!==t.args.length?!1:n.args.every((s,r)=>M(s,t.args[r]))}if(n.kind==="tuple"&&t.kind==="tuple")return n.types.length!==t.types.length?!1:n.types.every((e,s)=>M(e,t.types[s]));if(n.kind==="generic"&&n.name==="Array"&&t.kind==="tuple"){let e=n.args[0]||E;return e.kind==="unknown"?!0:t.types.every(s=>M(e,s))}if(n.kind==="object"&&t.kind==="object"){for(let[e,s]of t.shape)if(!n.shape.has(e)||!M(n.shape.get(e),s))return!1;return!0}return n.kind==="object"&&t.kind==="named"?!0:n.kind==="fn"&&t.kind==="fn"?t.ret&&n.ret?M(n.ret,t.ret):!0:(n.kind==="fn"||t.kind==="fn")&&(n.kind==="fn"||t.kind==="fn")?!0:n.kind==="record"&&t.kind==="record"?M(n.val,t.val):n.kind==="generic"&&t.kind==="generic"||t.kind==="utility"||n.kind==="utility"}function pt(n,t){return!n||n.kind==="unknown"?t||E:!t||t.kind==="unknown"||b(n)===b(t)?n:n.kind==="any"||t.kind==="any"?O:F(n,t)}var Dt=class n{constructor(t=null){this.parent=t,this.vars=new Map,this.retType=t?t.retType:null,this.isAsync=t?t.isAsync:!1}set(t,e){this.vars.set(t,e)}has(t){let e=this;for(;e;){if(e.vars.has(t))return!0;e=e.parent}return!1}get(t){let e=this;for(;e;){if(e.vars.has(t))return e.vars.get(t);e=e.parent}return null}child(){return new n(this)}childFn(t,e=!1){let s=new n(this);return s.retType=t,s.isAsync=e,s}narrow(t,e){let s=new n(this);return t&&e&&s.vars.set(t,e),s}},ft=class{constructor(t,e,s=null){this.message=t,this.name="TypeError",this.hint=s,e&&(this.line=e.line,this.col=e.col)}},$t=class{constructor(){this.errors=[],this.warnings=[],this.interfaces=new Map,this.types=new Map,this.classes=new Map,this.enums=new Map,this.typeAliases=new Map}check(t){this.errors=[],this.warnings=[],this.interfaces.clear(),this.types.clear(),this.classes.clear(),this.enums.clear(),this.typeAliases.clear(),this._collectDeclarations(t.body),this._validateImplementations();let e=new Dt;return this._registerBuiltins(e),this._checkStmts(t.body,e),{errors:this.errors,warnings:this.warnings}}_err(t,e,s=null){this.errors.push(new ft(t,e,s))}_warn(t,e,s=null){this.warnings.push(new ft(t,e,s))}_collectDeclarations(t){for(let e of t){let s=e.type==="ExportDecl"?e.decl:e;if(s)switch(s.type){case"InterfaceDecl":this.interfaces.set(s.name,s);break;case"TypeDecl":this.types.set(s.name,s);break;case"ClassDecl":this.classes.set(s.name,s);break;case"EnumDecl":this.enums.set(s.name,s);break}}}_validateImplementations(){for(let[,t]of this.classes)for(let e of t.interfaces||[])this._checkInterfaceImpl(t,e)}_checkInterfaceImpl(t,e){let s=this.interfaces.get(e);if(!s){this._warn(`Class '${t.name}' implements unknown interface '${e}'`,t.loc,`Define 'interface ${e}' before use`);return}for(let r of s.members)if(r.kind==="method")t.methods.find(c=>c.name===r.name)||this._err(`Class '${t.name}' does not implement method '${r.name}()' required by interface '${e}'`,t.loc,`Add 'fn ${r.name}(${r.params.map(c=>c.name+(c.typeAnn?": "+c.typeAnn:"")).join(", ")})' to the class`);else if(r.kind==="field"&&!r.optional){let a=t.fields.find(h=>h.name===r.name),c=t.methods.find(h=>h.name===r.name);!a&&!c&&this._err(`Class '${t.name}' is missing field '${r.name}' required by interface '${e}'`,t.loc,`Add '${r.name}: ${r.typeAnn}' to the class`)}for(let r of s.superInterfaces||[])this._checkInterfaceImpl(t,r)}_isStructurallyCompatible(t,e){let s=this.interfaces.get(e);if(!s){let r=this.classes.get(e);if(!r)return!1;for(let a of r.fields){if(!t.has(a.name)&&!a.optional)return!1;if(a.typeAnn&&t.has(a.name)){let c=N(a.typeAnn),h=t.get(a.name);if(!this._isAssignable(h,c))return!1}}return!0}for(let r of s.members)if(r.kind==="field"&&!r.optional){if(!t.has(r.name))return!1;if(r.typeAnn){let a=N(r.typeAnn),c=t.get(r.name);if(!this._isAssignable(c,a))return!1}}return!0}_isAssignable(t,e){if(!t||!e||e.kind==="any"||t.kind==="any"||t.kind==="never"||e.kind==="unknown")return!0;if(t.kind==="unknown")return!1;if(t.kind==="object"&&e.kind==="named")return this._isStructurallyCompatible(t.shape,e.name);if(t.kind==="object"&&e.kind==="object"){for(let[s,r]of e.shape)if(!t.shape.has(s)||!this._isAssignable(t.shape.get(s),r))return!1;return!0}if(t.kind==="named"&&e.kind==="named"){if(t.name===e.name||e.name==="Object")return!0;let s=this.classes.get(t.name);if(s&&(s.interfaces||[]).includes(e.name)||s&&s.superClass===e.name)return!0;let r=this.interfaces.get(t.name);return!!(r&&(r.superInterfaces||[]).includes(e.name))}if(e.kind==="utility")switch(e.util){case"Partial":return!0;case"Required":return this._isAssignable(t,e.inner);case"NonNullable":return t.kind!=="null"&&t.kind!=="void";default:return!0}return t.kind==="utility"?!0:M(t,e)}_analyzeNarrowingCondition(t,e){if(!t)return null;if(t.type==="BinaryExpr"&&(t.op==="!="||t.op==="!==")&&t.left.type==="Identifier"&&(t.right.type==="NullLit"||t.right.type==="Identifier"&&t.right.name==="undefined")){let s=t.left.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:a,falseType:F(V,D)}}}if(t.type==="BinaryExpr"&&(t.op==="=="||t.op==="===")&&t.left.type==="Identifier"&&t.right.type==="NullLit"){let s=t.left.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:V,falseType:a}}}if(t.type==="BinaryExpr"&&(t.op==="==="||t.op==="==")&&t.left.type==="TypeofExpr"&&t.left.operand.type==="Identifier"&&t.right.type==="StringLit"){let s=t.left.operand.name,r=t.right.value,c={string:C,number:L,boolean:j,object:k("Object"),function:R([],O),undefined:D,bigint:k("BigInt"),symbol:k("Symbol")}[r]||E;return{varName:s,trueType:c,falseType:e.get(s)||E}}if(t.type==="BinaryExpr"&&t.op==="instanceof"&&t.left.type==="Identifier"){let s=t.left.name,r=t.right.type==="Identifier"?t.right.name:null;if(r)return{varName:s,trueType:k(r),falseType:e.get(s)||E}}if(t.type==="Identifier"){let s=t.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:a,falseType:F(V,D)}}}return null}_registerBuiltins(t){t.set("console",k("Console")),t.set("process",k("Process")),t.set("Math",k("Math")),t.set("JSON",k("JSON")),t.set("Date",k("Date")),t.set("Promise",k("Promise")),t.set("Error",k("Error")),t.set("Buffer",k("Buffer")),t.set("RegExp",k("RegExp")),t.set("Map",k("Map")),t.set("Set",k("Set")),t.set("WeakMap",k("WeakMap")),t.set("WeakSet",k("WeakSet")),t.set("Symbol",k("Symbol")),t.set("Proxy",k("Proxy")),t.set("Reflect",k("Reflect")),t.set("setTimeout",R([R([],D),L],D)),t.set("setInterval",R([R([],D),L],D)),t.set("clearTimeout",O),t.set("clearInterval",O),t.set("parseInt",R([C,U],U)),t.set("parseFloat",R([C],K)),t.set("isNaN",R([L],j)),t.set("isFinite",R([L],j)),t.set("require",R([C],O)),t.set("fetch",R([C],O)),t.set("print",R([],D)),t.set("undefined",D),t.set("Infinity",L),t.set("NaN",L),t.set("globalThis",k("Object")),t.set("Object",k("Object")),t.set("Array",k("Array")),t.set("String",k("String")),t.set("Number",k("Number")),t.set("Boolean",k("Boolean")),t.set("Function",k("Function"))}_checkStmts(t,e){for(let s of t)this._checkStmt(s,e)}_checkStmt(t,e){if(t)switch(t.type){case"VarDecl":{let s=t.typeAnn?N(t.typeAnn):null,r=null;t.init&&(r=this._inferType(t.init,e)),s&&r&&r.kind!=="unknown"&&(this._isAssignable(r,s)||this._err(`Type '${b(r)}' is not assignable to '${t.name}: ${b(s)}'`,t.loc,`Change the value to match '${b(s)}' or update the annotation`)),e.set(t.name,s||r||E);break}case"DestructureDecl":{let s=t.init?this._inferType(t.init,e):E;if(t.patternType==="object")for(let r of t.pattern){let a=E;s.kind==="object"&&s.shape.has(r.key)&&(a=s.shape.get(r.key)),e.set(r.alias,a)}else for(let r=0;r<t.pattern.length;r++){let a=t.pattern[r];if(!a)continue;let c=E;s.kind==="tuple"&&s.types[r]?c=s.types[r]:s.kind==="generic"&&s.name==="Array"&&(c=s.args[0]||E),e.set(a.name,c)}break}case"FnDecl":{let s=t.retType?N(t.retType):null,r=t.params.map(c=>c.typeAnn?N(c.typeAnn):E);t.name&&e.set(t.name,R(r,s||E));let a=e.childFn(s,t.async);for(let c=0;c<t.params.length;c++)a.set(t.params[c].name,r[c]);if(t.inline){let c=this._inferType(t.body,a);s&&c&&c.kind!=="unknown"&&(this._isAssignable(c,s)||this._err(`Function '${t.name||"(anon)"}' returns '${b(c)}' but declared '${b(s)}'`,t.loc,"Fix return type or update the annotation"))}else this._checkStmts(t.body,a);break}case"ClassDecl":{e.set(t.name,k(t.name));let s=e.child(),r=new Map;for(let a of t.fields){let c=a.typeAnn?N(a.typeAnn):E;s.set(a.name,c),r.set(a.name,c)}s.set("self",ut(r));for(let a of t.methods)this._checkStmt(a,s);break}case"TypeDecl":for(let s of t.variants)s.fields.length===0?e.set(s.name,k(t.name)):e.set(s.name,R(s.fields.map(()=>O),k(t.name)));break;case"InterfaceDecl":e.set(t.name,k(t.name));break;case"EnumDecl":e.set(t.name,k(t.name));break;case"IfStmt":{this._inferType(t.cond,e);let s=this._analyzeNarrowingCondition(t.cond,e),r=s?e.narrow(s.varName,s.trueType):e.child(),a=s?e.narrow(s.varName,s.falseType):e.child();this._checkStmts(t.then,r);for(let c of t.elseifs)this._inferType(c.cond,e),this._checkStmts(c.body,e.child());t.else_&&this._checkStmts(t.else_,a);break}case"ForInStmt":{let s=this._inferType(t.iter,e),r=e.child();s.kind==="generic"&&s.args.length>0?r.set(t.var,s.args[0]):s.kind==="tuple"&&s.types.length>0?r.set(t.var,F(...s.types)):r.set(t.var,E),this._checkStmts(t.body,r);break}case"WhileStmt":this._inferType(t.cond,e),this._checkStmts(t.body,e.child());break;case"DoWhileStmt":this._checkStmts(t.body,e.child()),this._inferType(t.cond,e);break;case"MatchStmt":this._inferType(t.subject,e);for(let s of t.arms){let r=e.child();if(s.pattern.type==="VariantPat")for(let a of s.pattern.bindings)r.set(a,E);s.guard&&this._inferType(s.guard,r),this._checkStmts(s.body,r)}break;case"ReturnStmt":{let s=e.retType;if(t.value){let r=this._inferType(t.value,e);if(s&&r&&r.kind!=="unknown"&&s.kind!=="unknown"){let a=e.isAsync&&s.kind==="generic"&&s.name==="Promise"?s.args[0]:s;this._isAssignable(r,a)||this._err(`Return type '${b(r)}' is not assignable to declared '${b(a)}'`,t.loc,"Fix return expression or update return type annotation")}}else s&&s.kind!=="void"&&s.kind!=="any"&&s.kind!=="unknown"&&this._warn(`Missing return value \u2014 function declares return type '${b(s)}'`,t.loc);break}case"ThrowStmt":this._inferType(t.value,e);break;case"TryCatchStmt":{if(this._checkStmts(t.tryBody,e.child()),t.catchBody){let s=e.child();t.catchParam&&s.set(t.catchParam,F(k("Error"),E)),this._checkStmts(t.catchBody,s)}t.finallyBody&&this._checkStmts(t.finallyBody,e.child());break}case"ImportDecl":t.defaultName&&e.set(t.defaultName,O),t.namespaceName&&e.set(t.namespaceName,O);for(let s of t.names)e.set(typeof s=="string"?s:s.alias,O);break;case"ExportDecl":this._checkStmt(t.decl,e);break;case"ExprStmt":this._inferType(t.expr,e);break;case"BreakStmt":case"ContinueStmt":break}}_inferType(t,e){if(!t)return D;switch(t.type){case"NumberLit":return Number.isInteger(t.value)?U:K;case"StringLit":case"TemplateLit":return C;case"BoolLit":return j;case"NullLit":return V;case"RegexLit":return O;case"SelfExpr":return e.get("self")||E;case"Identifier":{let s=e.get(t.name);return s||(this.classes.has(t.name)||this.enums.has(t.name)||this.interfaces.has(t.name)?k(t.name):E)}case"ArrayExpr":{if(!t.items||t.items.length===0)return X(E);let s=t.items.filter(r=>r&&r.type!=="SpreadExpr").map(r=>this._inferType(r,e));return X(s.reduce(pt,E))}case"ObjectExpr":{let s=new Map;for(let r of t.pairs||[])r.spread||s.set(String(r.key),this._inferType(r.value,e));return ut(s)}case"NewExpr":for(let s of t.args)this._inferType(s,e);return k(t.callee);case"CallExpr":{let s=this._inferType(t.callee,e);for(let r of t.args)this._inferType(r,e);return s&&s.kind==="fn"?(this._checkCallArgs(t,s,e),s.ret||E):E}case"OptCallExpr":this._inferType(t.callee,e);for(let s of t.args)this._inferType(s,e);return E;case"MemberExpr":case"OptMemberExpr":{let s=this._inferType(t.obj,e);return s.kind==="object"&&s.shape.has(t.prop)?s.shape.get(t.prop):E}case"IndexExpr":case"OptIndexExpr":{let s=this._inferType(t.obj,e);return this._inferType(t.idx,e),s.kind==="generic"&&s.args.length>0?s.args[0]:s.kind==="tuple"?F(...s.types):s.kind==="record"?s.val:E}case"BinaryExpr":{let s=this._inferType(t.left,e),r=this._inferType(t.right,e),a=t.op;if(["+","-","*","/","%","**"].includes(a)){if(s.kind==="primitive"&&s.name==="String"||r.kind==="primitive"&&r.name==="String")return C;if(s.kind==="unknown"||r.kind==="unknown")return E;if(s.kind==="any"||r.kind==="any")return L;if(s.kind==="primitive"&&r.kind==="primitive"){let c=s.name,h=r.name;if(c==="Int"&&h==="Int")return U;if(["Float","Int"].includes(c)&&["Float","Int"].includes(h))return K}return L}return["===","!==","==","!=","<","<=",">",">=","&&","||","instanceof","in"].includes(a)?j:a==="??"?pt(s,r):["&","|","^","<<",">>"].includes(a)?U:E}case"UnaryExpr":{let s=this._inferType(t.operand,e);return t.op==="!"||t.op==="not"?j:t.op==="-"?s.kind==="primitive"&&s.name==="Int"?U:s.kind==="primitive"&&s.name==="Float"?K:L:t.op==="~"?U:s}case"UpdateExpr":return this._inferType(t.operand,e),L;case"TernaryExpr":{let s=this._analyzeNarrowingCondition(t.cond,e),r=s?e.narrow(s.varName,s.trueType):e,a=s?e.narrow(s.varName,s.falseType):e;this._inferType(t.cond,e);let c=this._inferType(t.then,r),h=this._inferType(t.else_,a);return pt(c,h)}case"AssignExpr":{let s=this._inferType(t.value,e),r=this._inferType(t.target,e);return r&&r.kind!=="unknown"&&s&&s.kind!=="unknown"&&(this._isAssignable(s,r)||this._err(`Cannot assign '${b(s)}' to type '${b(r)}'`,t.target.loc||t.loc,"Ensure the value matches the declared type")),s}case"AwaitExpr":{let s=this._inferType(t.operand,e);return s.kind==="generic"&&s.name==="Promise"&&s.args[0]||E}case"TypeofExpr":return this._inferType(t.operand,e),C;case"PipeExpr":return this._inferType(t.left,e),this._inferType(t.right,e);case"SpreadExpr":return this._inferType(t.expr,e),E;case"RangeExpr":return this._inferType(t.start,e),this._inferType(t.end,e),X(U);case"LambdaExpr":{let s=e.child();for(let c of t.params)s.set(c.name,c.typeAnn?N(c.typeAnn):E);let r=this._inferType(t.body,s),a=t.params.map(c=>c.typeAnn?N(c.typeAnn):E);return R(a,r)}case"FnDecl":{let s=t.retType?N(t.retType):null,r=e.childFn(s,t.async);for(let c of t.params||[])r.set(c.name,c.typeAnn?N(c.typeAnn):E);let a=(t.params||[]).map(c=>c.typeAnn?N(c.typeAnn):E);if(t.inline){let c=this._inferType(t.body,r);return R(a,s||c)}return this._checkStmts(t.body,r),R(a,s||E)}case"CastExpr":return this._inferType(t.expr,e),t.castType?N(t.castType):O;case"SatisfiesExpr":case"NonNullExpr":case"AsConstExpr":{let s=this._inferType(t.expr,e);if(t.type==="SatisfiesExpr"&&t.satType){let r=N(t.satType);this._isAssignable(s,r)||this._err(`Type '${b(s)}' does not satisfy '${b(r)}'`,t.loc)}return s}case"IsExpr":return this._inferType(t.expr,e),j;default:return E}}_checkCallArgs(t,e,s){let r=t.args||[],a=e.params||[];for(let c=0;c<r.length;c++){let h=this._inferType(r[c],s),l=a[c]||O;l.kind!=="any"&&h&&h.kind!=="unknown"&&(this._isAssignable(h,l)||this._err(`Argument ${c+1}: '${b(h)}' is not assignable to '${b(l)}'`,t.loc,"Check function signature"))}}};le.exports={FluxTypeChecker:$t,parseAnnotation:N,typeStr:b,isAssignable:_e,mergeTypes:pt,splitAtTopLevel:G,T_ANY:O,T_UNKNOWN:E,T_NEVER:ct,T_VOID:D,T_NULL:V,T_STRING:C,T_INT:U,T_FLOAT:K,T_NUMBER:L,T_BOOL:j,T_UNION:F,T_INTERSECTION:ae,T_ARRAY:X,T_TUPLE:Ot,T_NULLABLE:ce,T_NAMED:k,T_FN:R,T_OBJECT:ut,T_RECORD:he,T_LITERAL:De}});var _t=_((Ds,pe)=>{"use strict";var mt=["range","zip","enumerate","flatten","chunk","unique","groupBy","sortBy","map","filter","reduce","forEach","find","findIndex","some","every","join","sort","flat","flatMap","includes","first","last","take","drop","takeWhile","dropWhile","compact","intersection","difference","arrayUnion","unzip","countBy","minBy","maxBy","toPairs","partition","count","head","tail","nth","rotate","sliding","clamp","sum","product","min","max","abs","floor","ceil","round","mean","median","stdDev","lerp","randInt","sample","shuffle","pick","omit","deepEqual","deepClone","mapValues","filterValues","fromEntries","keys","values","entries","merge","invert","defaults","capitalize","camelCase","snakeCase","kebabCase","truncate","pad","padStart","padEnd","trim","trimStart","trimEnd","words","lines","startsWith","endsWith","repeat","replaceAll","reverseStr","isNil","isString","isNumber","isArray","isObject","isFunction","isBool","sleep","retry","memoize","timeout","debounce","throttle","allSettled","pipe","compose","partial","curry","identity","noop","once","flip","complement"];function Le(n){let t=n?new Set(n.filter(s=>mt.includes(s))):new Set(mt);if(t.size===0)return"";let e=["// \u2500\u2500 Flux stdlib \u2500\u2500"];return t.has("map")&&e.push(`
|
|
64
|
+
`||this.src[r]==="\r");)r++;if(this.src[r]==="{"){r++;let a=1,c=r;for(;r<this.src.length&&a>0;){let p=this.src[r];if(p==='"'||p==="'"||p==="`"){let m=p;for(r++;r<this.src.length&&this.src[r]!==m;)this.src[r]==="\\"&&r++,r++;r++}else p==="{"?(a++,r++):(p==="}"&&a--,r++)}let h=this.src.slice(c,r-1),l=Rt(h);this.out+="`"+l.replace(/\\/g,"\\\\").replace(/`/g,"\\`")+"`",this.pos=r;return}}}this.out+=t,this.pos++}passString(t){for(this.out+=t,this.pos++;this.pos<this.src.length;){let e=this.src[this.pos];if(e==="\\"){this.out+=e+(this.src[this.pos+1]||""),this.pos+=2;continue}if(e===t){this.out+=e,this.pos++;return}this.out+=e,this.pos++}}};function Ie(n){return new vt(n).transform()}ee.exports={transformCss:Ie,parseCssBlockContent:Rt,CSS_PROP_MAP:te,CSS_BOOL_MAP:at}});var re=_((Ds,ie)=>{"use strict";var ot=class{constructor(t,e,s=null){this.message=t,this.loc=e,this.hint=s,this.name="CheckError",e&&(this.line=e.line,this.col=e.col)}},D=class{constructor(t=null){this.parent=t,this.vars=new Map}define(t,e,s){this.vars.set(t,{kind:e,loc:s})}lookup(t){let e=this;for(;e;){if(e.vars.has(t))return e.vars.get(t);e=e.parent}return null}isVal(t){let e=this.lookup(t);return e&&e.kind==="val"}},Dt=class{constructor(){this.errors=[],this.warnings=[]}check(t){this.errors=[],this.warnings=[];let e=new D;return this.walkStmts(t.body,e),{errors:this.errors,warnings:this.warnings}}error(t,e,s=null){this.errors.push(new ot(t,e,s))}warn(t,e,s=null){this.warnings.push(new ot(t,e,s))}walkStmts(t,e){for(let s of t)this.walkStmt(s,e)}walkStmt(t,e){if(t)switch(t.type){case"VarDecl":t.init&&this.walkExpr(t.init,e),e.define(t.name,t.kind,t.loc);break;case"DestructureDecl":if(t.init&&this.walkExpr(t.init,e),t.patternType==="object")for(let s of t.pattern)e.define(s.alias,t.kind,t.loc);else for(let s of t.pattern)s&&e.define(s.name,t.kind,t.loc);break;case"FnDecl":{let s=new D(e);for(let r of t.params)s.define(r.name,"val",t.loc);t.name&&e.define(t.name,"val",t.loc),t.inline?this.walkExpr(t.body,s):this.walkStmts(t.body,s);break}case"ClassDecl":{e.define(t.name,"val",t.loc);let s=new D(e);for(let r of t.fields)s.define(r.name,"var",t.loc);for(let r of t.methods)this.walkStmt(r,s);break}case"TypeDecl":for(let s of t.variants)e.define(s.name,"val",t.loc);break;case"InterfaceDecl":e.define(t.name,"val",t.loc);break;case"EnumDecl":e.define(t.name,"val",t.loc);break;case"IfStmt":this.walkExpr(t.cond,e),this.walkStmts(t.then,new D(e));for(let s of t.elseifs)this.walkExpr(s.cond,e),this.walkStmts(s.body,new D(e));t.else_&&this.walkStmts(t.else_,new D(e));break;case"ForInStmt":{this.walkExpr(t.iter,e);let s=new D(e);s.define(t.var,"val",t.loc),this.walkStmts(t.body,s);break}case"WhileStmt":this.walkExpr(t.cond,e),this.walkStmts(t.body,new D(e));break;case"DoWhileStmt":this.walkStmts(t.body,new D(e)),this.walkExpr(t.cond,e);break;case"MatchStmt":this.walkExpr(t.subject,e);for(let s of t.arms){let r=new D(e);if(s.pattern.type==="VariantPat")for(let a of s.pattern.bindings)r.define(a,"val",t.loc);s.guard&&this.walkExpr(s.guard,r),this.walkStmts(s.body,r)}break;case"ReturnStmt":t.value&&this.walkExpr(t.value,e);break;case"ThrowStmt":this.walkExpr(t.value,e);break;case"TryCatchStmt":{if(this.walkStmts(t.tryBody,new D(e)),t.catchBody){let s=new D(e);t.catchParam&&s.define(t.catchParam,"val",t.loc),this.walkStmts(t.catchBody,s)}t.finallyBody&&this.walkStmts(t.finallyBody,new D(e));break}case"ImportDecl":t.defaultName&&e.define(t.defaultName,"val",t.loc),t.namespaceName&&e.define(t.namespaceName,"val",t.loc);for(let s of t.names)e.define(typeof s=="string"?s:s.alias,"val",t.loc);break;case"ExportDecl":this.walkStmt(t.isDefault?{type:"ExprStmt",expr:t.decl}:t.decl,e);break;case"ExprStmt":this.walkExpr(t.expr,e);break;case"BreakStmt":case"ContinueStmt":break;default:}}walkExpr(t,e){if(t)switch(t.type){case"AssignExpr":{let s=t.target;s.type==="Identifier"&&e.isVal(s.name)&&this.error(`Cannot reassign 'val ${s.name}' \u2014 val is immutable`,s.loc,`Use 'var ${s.name}' if you need a mutable variable`),this.walkExpr(t.target,e),this.walkExpr(t.value,e);break}case"UpdateExpr":t.operand.type==="Identifier"&&e.isVal(t.operand.name)&&this.error(`Cannot apply '${t.op}' to 'val ${t.operand.name}' \u2014 val is immutable`,t.operand.loc,`Use 'var ${t.operand.name}' if you need a mutable variable`),this.walkExpr(t.operand,e);break;case"BinaryExpr":case"PipeExpr":this.walkExpr(t.left,e),this.walkExpr(t.right,e);break;case"UnaryExpr":case"AwaitExpr":case"TypeofExpr":this.walkExpr(t.operand,e);break;case"TernaryExpr":this.walkExpr(t.cond,e),this.walkExpr(t.then,e),this.walkExpr(t.else_,e);break;case"CallExpr":case"OptCallExpr":this.walkExpr(t.callee,e);for(let s of t.args)this.walkExpr(s,e);break;case"MemberExpr":case"OptMemberExpr":this.walkExpr(t.obj,e);break;case"IndexExpr":case"OptIndexExpr":this.walkExpr(t.obj,e),this.walkExpr(t.idx,e);break;case"NewExpr":for(let s of t.args)this.walkExpr(s,e);break;case"ArrayExpr":for(let s of t.items)s&&this.walkExpr(s,e);break;case"ObjectExpr":for(let s of t.pairs)s.value&&this.walkExpr(s.value,e);break;case"SpreadExpr":this.walkExpr(t.expr,e);break;case"LambdaExpr":{let s=new D(e);for(let r of t.params)s.define(r.name,"val",null);this.walkExpr(t.body,s);break}case"FnDecl":{let s=new D(e);for(let r of t.params)s.define(r.name,"val",null);t.inline?this.walkExpr(t.body,s):this.walkStmts(t.body,s);break}case"TemplateLit":break;case"CastExpr":case"AsConstExpr":case"SatisfiesExpr":case"IsExpr":case"NonNullExpr":this.walkExpr(t.expr,e);break;case"RangeExpr":this.walkExpr(t.start,e),this.walkExpr(t.end,e);break;case"Identifier":case"NumberLit":case"BoolLit":case"NullLit":case"StringLit":case"SelfExpr":break;default:}}};ie.exports={Checker:Dt}});var oe=_((Is,le)=>{"use strict";var I=Object.freeze({kind:"any"}),k=Object.freeze({kind:"unknown"}),ct=Object.freeze({kind:"never"}),O=Object.freeze({kind:"void"}),V=Object.freeze({kind:"null"}),C=Object.freeze({kind:"primitive",name:"String"}),W=Object.freeze({kind:"primitive",name:"Int"}),G=Object.freeze({kind:"primitive",name:"Float"}),L=Object.freeze({kind:"primitive",name:"Number"}),j=Object.freeze({kind:"primitive",name:"Bool"});function F(...n){let t=[];for(let r of n)r&&r.kind==="union"?t.push(...r.members):r&&t.push(r);let e=new Set,s=t.filter(r=>{let a=N(r);return e.has(a)?!1:(e.add(a),!0)});return s.length===0?ct:s.length===1?s[0]:{kind:"union",members:s}}function ae(...n){let t=[];for(let e of n)e&&e.kind==="intersection"?t.push(...e.members):e&&t.push(e);return t.length===1?t[0]:{kind:"intersection",members:t}}function X(n){return{kind:"generic",name:"Array",args:[n||k]}}function It(n){return{kind:"tuple",types:n||[]}}function ce(n){return F(n,V)}function E(n){return{kind:"named",name:n}}function R(n,t){return{kind:"fn",params:n||[],ret:t||O}}function ut(n){return{kind:"object",shape:n||new Map}}function he(n,t){return{kind:"record",key:n||C,val:t||k}}function Oe(n,t){return{kind:"literal",value:n,prim:t}}function N(n){if(!n)return"unknown";switch(n.kind){case"any":return"Any";case"unknown":return"Unknown";case"never":return"Never";case"void":return"Void";case"null":return"Null";case"primitive":return n.name;case"literal":return JSON.stringify(n.value);case"union":return n.members.map(N).join(" | ");case"intersection":return n.members.map(N).join(" & ");case"tuple":return"["+n.types.map(N).join(", ")+"]";case"object":return"{"+[...(n.shape||new Map).entries()].map(([t,e])=>`${t}: ${N(e)}`).join(", ")+"}";case"record":return`Record<${N(n.key)}, ${N(n.val)}>`;case"generic":return n.name+(n.args&&n.args.length?"<"+n.args.map(N).join(", ")+">":"");case"named":return n.name;case"fn":return`(${(n.params||[]).map(N).join(", ")}) -> ${N(n.ret)}`;case"keyof":return`keyof ${N(n.inner)}`;case"conditional":return`${N(n.check)} extends ${N(n.extends)} ? ${N(n.then)} : ${N(n.else)}`;default:return"unknown"}}function K(n,t){let e=[],s=0,r=0;for(let a=0;a<n.length;a++){let c=n[a];"<([{".includes(c)?s++:">)]}".includes(c)?s--:s===0&&n.slice(a,a+t.length)===t&&(e.push(n.slice(r,a)),r=a+t.length,a+=t.length-1)}return e.push(n.slice(r)),e.filter(a=>a.trim().length>0)}var ne={String:C,string:C,Int:W,int:W,Float:G,float:G,Number:L,number:L,Bool:j,boolean:j,Boolean:j,bool:j,Void:O,void:O,Never:ct,never:ct,Any:I,any:I,Unknown:k,unknown:k,Null:V,null:V,undefined:O,Object:E("Object"),object:E("Object"),Symbol:E("Symbol"),symbol:E("Symbol"),BigInt:E("BigInt"),bigint:E("BigInt")};function x(n){if(!n)return null;n=n.trim(),n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim());let t=K(n," | ");if(t.length>1)return F(...t.map(x));let e=K(n," & ");if(e.length>1)return ae(...e.map(x));let s=n.match(/^(\w+)\s+extends\s+(.+?)\s*\?\s*(.+?)\s*:\s*(.+)$/);if(s)return{kind:"conditional",check:x(s[1]),extends:x(s[2]),then:x(s[3]),else:x(s[4])};if(n.startsWith("keyof "))return{kind:"keyof",inner:x(n.slice(6))};if(n.startsWith("typeof "))return{kind:"typeof",name:n.slice(7)};if(n.startsWith("readonly "))return x(n.slice(9));if(n.startsWith("infer "))return I;let r=n.match(/^fn\(([^)]*)\)\s*->\s*(.+)$/)||n.match(/^\(([^)]*)\)\s*->\s*(.+)$/);if(r){let c=r[1].trim(),h=r[2].trim(),l=c?K(c,", ").map(p=>{let m=p.indexOf(":");return x(m>=0?p.slice(m+1).trim():p.trim())}):[];return R(l,x(h))}if(n.endsWith("?"))return ce(x(n.slice(0,-1)));if(n.endsWith("[]"))return X(x(n.slice(0,-2)));if(n.startsWith("[")&&n.endsWith("]")){let c=n.slice(1,-1);if(!c.trim())return It([]);let h=K(c,", ");return It(h.map(l=>x(l.replace(/^\.\.\./,"").trim())))}if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).trim(),h=new Map;if(c){let l=K(c,", ");for(let p of l){let m=p.match(/^\[(\w+):\s*\w+\]:\s*(.+)$/);if(m){h.set("[index]",x(m[2]));continue}let y=p.indexOf(":");if(y>=0){let u=p.slice(0,y).trim().replace(/^readonly\s+/,""),d=u.replace(/\?$/,""),g=u.endsWith("?"),f=x(p.slice(y+1).trim());h.set(d,g?F(f,O):f)}}}return ut(h)}let a=n.match(/^(\w+)<(.+)>$/s);if(a){let c=a[1],l=K(a[2],", ").map(p=>x(p.trim()));switch(c){case"Array":case"List":case"ReadonlyArray":return X(l[0]||k);case"NonNullable":return $e(l[0]);case"Partial":return{kind:"utility",util:"Partial",inner:l[0]};case"Required":return{kind:"utility",util:"Required",inner:l[0]};case"Readonly":return l[0];case"Record":return he(l[0]||C,l[1]||k);case"Pick":return{kind:"utility",util:"Pick",inner:l[0],keys:l[1]};case"Omit":return{kind:"utility",util:"Omit",inner:l[0],keys:l[1]};case"Exclude":return{kind:"utility",util:"Exclude",inner:l[0],keys:l[1]};case"Extract":return{kind:"utility",util:"Extract",inner:l[0],keys:l[1]};case"ReturnType":return{kind:"utility",util:"ReturnType",inner:l[0]};case"InstanceType":return{kind:"utility",util:"InstanceType",inner:l[0]};case"Parameters":return{kind:"utility",util:"Parameters",inner:l[0]};case"Awaited":return{kind:"utility",util:"Awaited",inner:l[0]};case"Promise":return{kind:"generic",name:"Promise",args:l};case"Map":return{kind:"generic",name:"Map",args:l};case"Set":return{kind:"generic",name:"Set",args:l};case"WeakMap":return{kind:"generic",name:"WeakMap",args:l};default:return{kind:"generic",name:c,args:l}}}return ne[n]?ne[n]:E(n)}function $e(n){return n?n.kind==="union"?F(...n.members.filter(t=>t.kind!=="null"&&t.kind!=="void")):n.kind==="null"||n.kind==="void"?ct:n:k}function _e(n,t){return M(n,t)}function M(n,t){if(!n||!t||t.kind==="any"||n.kind==="any"||n.kind==="never"||t.kind==="unknown"||n.kind==="void"&&t.kind==="void"||n.kind==="null"&&t.kind==="null"||n.kind==="never"&&t.kind==="never")return!0;if(n.kind==="null"&&t.kind==="union")return t.members.some(e=>e.kind==="null"||e.kind==="any"||e.kind==="void");if(n.kind==="union")return n.members.every(e=>M(e,t));if(t.kind==="union")return t.members.some(e=>M(n,e));if(n.kind==="intersection")return n.members.some(e=>M(e,t));if(t.kind==="intersection")return t.members.every(e=>M(n,e));if(n.kind==="primitive"&&t.kind==="primitive")return!!(n.name===t.name||t.name==="Number"&&["Int","Float","Number"].includes(n.name)||t.name==="Float"&&n.name==="Int"||n.name==="Bool"&&t.name==="Boolean"||n.name==="Boolean"&&t.name==="Bool");if(n.kind==="literal"&&t.kind==="primitive")return{string:"String",number:"Number",boolean:"Bool"}[n.prim]===t.name||n.prim==="number"&&["Int","Float","Number"].includes(t.name);if(n.kind==="named"&&t.kind==="named")return n.name===t.name||t.name==="Object";if(n.kind==="generic"&&t.kind==="generic"){let e=new Set(["Array","List","ReadonlyArray"]);return n.name!==t.name&&!(e.has(n.name)&&e.has(t.name))||n.args.length!==t.args.length?!1:n.args.every((s,r)=>M(s,t.args[r]))}if(n.kind==="tuple"&&t.kind==="tuple")return n.types.length!==t.types.length?!1:n.types.every((e,s)=>M(e,t.types[s]));if(n.kind==="generic"&&n.name==="Array"&&t.kind==="tuple"){let e=n.args[0]||k;return e.kind==="unknown"?!0:t.types.every(s=>M(e,s))}if(n.kind==="object"&&t.kind==="object"){for(let[e,s]of t.shape)if(!n.shape.has(e)||!M(n.shape.get(e),s))return!1;return!0}return n.kind==="object"&&t.kind==="named"?!0:n.kind==="fn"&&t.kind==="fn"?t.ret&&n.ret?M(n.ret,t.ret):!0:(n.kind==="fn"||t.kind==="fn")&&(n.kind==="fn"||t.kind==="fn")?!0:n.kind==="record"&&t.kind==="record"?M(n.val,t.val):n.kind==="generic"&&t.kind==="generic"||t.kind==="utility"||n.kind==="utility"}function pt(n,t){return!n||n.kind==="unknown"?t||k:!t||t.kind==="unknown"||N(n)===N(t)?n:n.kind==="any"||t.kind==="any"?I:F(n,t)}var Ot=class n{constructor(t=null){this.parent=t,this.vars=new Map,this.retType=t?t.retType:null,this.isAsync=t?t.isAsync:!1}set(t,e){this.vars.set(t,e)}has(t){let e=this;for(;e;){if(e.vars.has(t))return!0;e=e.parent}return!1}get(t){let e=this;for(;e;){if(e.vars.has(t))return e.vars.get(t);e=e.parent}return null}child(){return new n(this)}childFn(t,e=!1){let s=new n(this);return s.retType=t,s.isAsync=e,s}narrow(t,e){let s=new n(this);return t&&e&&s.vars.set(t,e),s}},ft=class{constructor(t,e,s=null){this.message=t,this.name="TypeError",this.hint=s,e&&(this.line=e.line,this.col=e.col)}},$t=class{constructor(){this.errors=[],this.warnings=[],this.interfaces=new Map,this.types=new Map,this.classes=new Map,this.enums=new Map,this.typeAliases=new Map}check(t){this.errors=[],this.warnings=[],this.interfaces.clear(),this.types.clear(),this.classes.clear(),this.enums.clear(),this.typeAliases.clear(),this._collectDeclarations(t.body),this._validateImplementations();let e=new Ot;return this._registerBuiltins(e),this._checkStmts(t.body,e),{errors:this.errors,warnings:this.warnings}}_err(t,e,s=null){this.errors.push(new ft(t,e,s))}_warn(t,e,s=null){this.warnings.push(new ft(t,e,s))}_collectDeclarations(t){for(let e of t){let s=e.type==="ExportDecl"?e.decl:e;if(s)switch(s.type){case"InterfaceDecl":this.interfaces.set(s.name,s);break;case"TypeDecl":this.types.set(s.name,s);break;case"ClassDecl":this.classes.set(s.name,s);break;case"EnumDecl":this.enums.set(s.name,s);break}}}_validateImplementations(){for(let[,t]of this.classes)for(let e of t.interfaces||[])this._checkInterfaceImpl(t,e)}_checkInterfaceImpl(t,e){let s=this.interfaces.get(e);if(!s){this._warn(`Class '${t.name}' implements unknown interface '${e}'`,t.loc,`Define 'interface ${e}' before use`);return}for(let r of s.members)if(r.kind==="method")t.methods.find(c=>c.name===r.name)||this._err(`Class '${t.name}' does not implement method '${r.name}()' required by interface '${e}'`,t.loc,`Add 'fn ${r.name}(${r.params.map(c=>c.name+(c.typeAnn?": "+c.typeAnn:"")).join(", ")})' to the class`);else if(r.kind==="field"&&!r.optional){let a=t.fields.find(h=>h.name===r.name),c=t.methods.find(h=>h.name===r.name);!a&&!c&&this._err(`Class '${t.name}' is missing field '${r.name}' required by interface '${e}'`,t.loc,`Add '${r.name}: ${r.typeAnn}' to the class`)}for(let r of s.superInterfaces||[])this._checkInterfaceImpl(t,r)}_isStructurallyCompatible(t,e){let s=this.interfaces.get(e);if(!s){let r=this.classes.get(e);if(!r)return!1;for(let a of r.fields){if(!t.has(a.name)&&!a.optional)return!1;if(a.typeAnn&&t.has(a.name)){let c=x(a.typeAnn),h=t.get(a.name);if(!this._isAssignable(h,c))return!1}}return!0}for(let r of s.members)if(r.kind==="field"&&!r.optional){if(!t.has(r.name))return!1;if(r.typeAnn){let a=x(r.typeAnn),c=t.get(r.name);if(!this._isAssignable(c,a))return!1}}return!0}_isAssignable(t,e){if(!t||!e||e.kind==="any"||t.kind==="any"||t.kind==="never"||e.kind==="unknown")return!0;if(t.kind==="unknown")return!1;if(t.kind==="object"&&e.kind==="named")return this._isStructurallyCompatible(t.shape,e.name);if(t.kind==="object"&&e.kind==="object"){for(let[s,r]of e.shape)if(!t.shape.has(s)||!this._isAssignable(t.shape.get(s),r))return!1;return!0}if(t.kind==="named"&&e.kind==="named"){if(t.name===e.name||e.name==="Object")return!0;let s=this.classes.get(t.name);if(s&&(s.interfaces||[]).includes(e.name)||s&&s.superClass===e.name)return!0;let r=this.interfaces.get(t.name);return!!(r&&(r.superInterfaces||[]).includes(e.name))}if(e.kind==="utility")switch(e.util){case"Partial":return!0;case"Required":return this._isAssignable(t,e.inner);case"NonNullable":return t.kind!=="null"&&t.kind!=="void";default:return!0}return t.kind==="utility"?!0:M(t,e)}_analyzeNarrowingCondition(t,e){if(!t)return null;if(t.type==="BinaryExpr"&&(t.op==="!="||t.op==="!==")&&t.left.type==="Identifier"&&(t.right.type==="NullLit"||t.right.type==="Identifier"&&t.right.name==="undefined")){let s=t.left.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:a,falseType:F(V,O)}}}if(t.type==="BinaryExpr"&&(t.op==="=="||t.op==="===")&&t.left.type==="Identifier"&&t.right.type==="NullLit"){let s=t.left.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:V,falseType:a}}}if(t.type==="BinaryExpr"&&(t.op==="==="||t.op==="==")&&t.left.type==="TypeofExpr"&&t.left.operand.type==="Identifier"&&t.right.type==="StringLit"){let s=t.left.operand.name,r=t.right.value,c={string:C,number:L,boolean:j,object:E("Object"),function:R([],I),undefined:O,bigint:E("BigInt"),symbol:E("Symbol")}[r]||k;return{varName:s,trueType:c,falseType:e.get(s)||k}}if(t.type==="BinaryExpr"&&t.op==="instanceof"&&t.left.type==="Identifier"){let s=t.left.name,r=t.right.type==="Identifier"?t.right.name:null;if(r)return{varName:s,trueType:E(r),falseType:e.get(s)||k}}if(t.type==="Identifier"){let s=t.name,r=e.get(s);if(r&&r.kind==="union"){let a=F(...r.members.filter(c=>c.kind!=="null"&&c.kind!=="void"));return{varName:s,trueType:a,falseType:F(V,O)}}}return null}_registerBuiltins(t){t.set("console",E("Console")),t.set("process",E("Process")),t.set("Math",E("Math")),t.set("JSON",E("JSON")),t.set("Date",E("Date")),t.set("Promise",E("Promise")),t.set("Error",E("Error")),t.set("Buffer",E("Buffer")),t.set("RegExp",E("RegExp")),t.set("Map",E("Map")),t.set("Set",E("Set")),t.set("WeakMap",E("WeakMap")),t.set("WeakSet",E("WeakSet")),t.set("Symbol",E("Symbol")),t.set("Proxy",E("Proxy")),t.set("Reflect",E("Reflect")),t.set("setTimeout",R([R([],O),L],O)),t.set("setInterval",R([R([],O),L],O)),t.set("clearTimeout",I),t.set("clearInterval",I),t.set("parseInt",R([C,W],W)),t.set("parseFloat",R([C],G)),t.set("isNaN",R([L],j)),t.set("isFinite",R([L],j)),t.set("require",R([C],I)),t.set("fetch",R([C],I)),t.set("print",R([],O)),t.set("undefined",O),t.set("Infinity",L),t.set("NaN",L),t.set("globalThis",E("Object")),t.set("Object",E("Object")),t.set("Array",E("Array")),t.set("String",E("String")),t.set("Number",E("Number")),t.set("Boolean",E("Boolean")),t.set("Function",E("Function"))}_checkStmts(t,e){for(let s of t)this._checkStmt(s,e)}_checkStmt(t,e){if(t)switch(t.type){case"VarDecl":{let s=t.typeAnn?x(t.typeAnn):null,r=null;t.init&&(r=this._inferType(t.init,e)),s&&r&&r.kind!=="unknown"&&(this._isAssignable(r,s)||this._err(`Type '${N(r)}' is not assignable to '${t.name}: ${N(s)}'`,t.loc,`Change the value to match '${N(s)}' or update the annotation`)),e.set(t.name,s||r||k);break}case"DestructureDecl":{let s=t.init?this._inferType(t.init,e):k;if(t.patternType==="object")for(let r of t.pattern){let a=k;s.kind==="object"&&s.shape.has(r.key)&&(a=s.shape.get(r.key)),e.set(r.alias,a)}else for(let r=0;r<t.pattern.length;r++){let a=t.pattern[r];if(!a)continue;let c=k;s.kind==="tuple"&&s.types[r]?c=s.types[r]:s.kind==="generic"&&s.name==="Array"&&(c=s.args[0]||k),e.set(a.name,c)}break}case"FnDecl":{let s=t.retType?x(t.retType):null,r=t.params.map(c=>c.typeAnn?x(c.typeAnn):k);t.name&&e.set(t.name,R(r,s||k));let a=e.childFn(s,t.async);for(let c=0;c<t.params.length;c++)a.set(t.params[c].name,r[c]);if(t.inline){let c=this._inferType(t.body,a);s&&c&&c.kind!=="unknown"&&(this._isAssignable(c,s)||this._err(`Function '${t.name||"(anon)"}' returns '${N(c)}' but declared '${N(s)}'`,t.loc,"Fix return type or update the annotation"))}else this._checkStmts(t.body,a);break}case"ClassDecl":{e.set(t.name,E(t.name));let s=e.child(),r=new Map;for(let a of t.fields){let c=a.typeAnn?x(a.typeAnn):k;s.set(a.name,c),r.set(a.name,c)}s.set("self",ut(r));for(let a of t.methods)this._checkStmt(a,s);break}case"DeclareDecl":{let s=t.decl;if(s.type==="FnDecl"){let r=s.retType?x(s.retType):null,a=s.params.map(c=>c.typeAnn?x(c.typeAnn):k);s.name&&e.set(s.name,R(a,r||k))}else if(s.type==="VarDecl"){let r=s.typeAnn?x(s.typeAnn):k;e.set(s.name,r)}else s.type==="ClassDecl"&&e.set(s.name,E(s.name));break}case"TypeDecl":for(let s of t.variants)s.fields.length===0?e.set(s.name,E(t.name)):e.set(s.name,R(s.fields.map(()=>I),E(t.name)));break;case"InterfaceDecl":e.set(t.name,E(t.name));break;case"EnumDecl":e.set(t.name,E(t.name));break;case"IfStmt":{this._inferType(t.cond,e);let s=this._analyzeNarrowingCondition(t.cond,e),r=s?e.narrow(s.varName,s.trueType):e.child(),a=s?e.narrow(s.varName,s.falseType):e.child();this._checkStmts(t.then,r);for(let c of t.elseifs)this._inferType(c.cond,e),this._checkStmts(c.body,e.child());t.else_&&this._checkStmts(t.else_,a);break}case"ForInStmt":{let s=this._inferType(t.iter,e),r=e.child();s.kind==="generic"&&s.args.length>0?r.set(t.var,s.args[0]):s.kind==="tuple"&&s.types.length>0?r.set(t.var,F(...s.types)):r.set(t.var,k),this._checkStmts(t.body,r);break}case"WhileStmt":this._inferType(t.cond,e),this._checkStmts(t.body,e.child());break;case"DoWhileStmt":this._checkStmts(t.body,e.child()),this._inferType(t.cond,e);break;case"MatchStmt":this._inferType(t.subject,e);for(let s of t.arms){let r=e.child();if(s.pattern.type==="VariantPat")for(let a of s.pattern.bindings)r.set(a,k);s.guard&&this._inferType(s.guard,r),this._checkStmts(s.body,r)}break;case"ReturnStmt":{let s=e.retType;if(t.value){let r=this._inferType(t.value,e);if(s&&r&&r.kind!=="unknown"&&s.kind!=="unknown"){let a=e.isAsync&&s.kind==="generic"&&s.name==="Promise"?s.args[0]:s;this._isAssignable(r,a)||this._err(`Return type '${N(r)}' is not assignable to declared '${N(a)}'`,t.loc,"Fix return expression or update return type annotation")}}else s&&s.kind!=="void"&&s.kind!=="any"&&s.kind!=="unknown"&&this._warn(`Missing return value \u2014 function declares return type '${N(s)}'`,t.loc);break}case"ThrowStmt":this._inferType(t.value,e);break;case"TryCatchStmt":{if(this._checkStmts(t.tryBody,e.child()),t.catchBody){let s=e.child();t.catchParam&&s.set(t.catchParam,F(E("Error"),k)),this._checkStmts(t.catchBody,s)}t.finallyBody&&this._checkStmts(t.finallyBody,e.child());break}case"ImportDecl":t.defaultName&&e.set(t.defaultName,I),t.namespaceName&&e.set(t.namespaceName,I);for(let s of t.names)e.set(typeof s=="string"?s:s.alias,I);break;case"ExportDecl":this._checkStmt(t.decl,e);break;case"ExprStmt":this._inferType(t.expr,e);break;case"BreakStmt":case"ContinueStmt":break}}_inferType(t,e){if(!t)return O;switch(t.type){case"NumberLit":return Number.isInteger(t.value)?W:G;case"StringLit":case"TemplateLit":return C;case"BoolLit":return j;case"NullLit":return V;case"RegexLit":return I;case"SelfExpr":return e.get("self")||k;case"Identifier":{let s=e.get(t.name);return s||(this.classes.has(t.name)||this.enums.has(t.name)||this.interfaces.has(t.name)?E(t.name):k)}case"ArrayExpr":{if(!t.items||t.items.length===0)return X(k);let s=t.items.filter(r=>r&&r.type!=="SpreadExpr").map(r=>this._inferType(r,e));return X(s.reduce(pt,k))}case"ObjectExpr":{let s=new Map;for(let r of t.pairs||[])r.spread||s.set(String(r.key),this._inferType(r.value,e));return ut(s)}case"NewExpr":for(let s of t.args)this._inferType(s,e);return E(t.callee);case"CallExpr":{let s=this._inferType(t.callee,e);for(let r of t.args)this._inferType(r,e);return s&&s.kind==="fn"?(this._checkCallArgs(t,s,e),s.ret||k):k}case"OptCallExpr":this._inferType(t.callee,e);for(let s of t.args)this._inferType(s,e);return k;case"MemberExpr":case"OptMemberExpr":{let s=this._inferType(t.obj,e);return s.kind==="object"&&s.shape.has(t.prop)?s.shape.get(t.prop):k}case"IndexExpr":case"OptIndexExpr":{let s=this._inferType(t.obj,e);return this._inferType(t.idx,e),s.kind==="generic"&&s.args.length>0?s.args[0]:s.kind==="tuple"?F(...s.types):s.kind==="record"?s.val:k}case"BinaryExpr":{let s=this._inferType(t.left,e),r=this._inferType(t.right,e),a=t.op;if(["+","-","*","/","%","**"].includes(a)){if(s.kind==="primitive"&&s.name==="String"||r.kind==="primitive"&&r.name==="String")return C;if(s.kind==="unknown"||r.kind==="unknown")return k;if(s.kind==="any"||r.kind==="any")return L;if(s.kind==="primitive"&&r.kind==="primitive"){let c=s.name,h=r.name;if(c==="Int"&&h==="Int")return W;if(["Float","Int"].includes(c)&&["Float","Int"].includes(h))return G}return L}return["===","!==","==","!=","<","<=",">",">=","&&","||","instanceof","in"].includes(a)?j:a==="??"?pt(s,r):["&","|","^","<<",">>"].includes(a)?W:k}case"UnaryExpr":{let s=this._inferType(t.operand,e);return t.op==="!"||t.op==="not"?j:t.op==="-"?s.kind==="primitive"&&s.name==="Int"?W:s.kind==="primitive"&&s.name==="Float"?G:L:t.op==="~"?W:s}case"UpdateExpr":return this._inferType(t.operand,e),L;case"TernaryExpr":{let s=this._analyzeNarrowingCondition(t.cond,e),r=s?e.narrow(s.varName,s.trueType):e,a=s?e.narrow(s.varName,s.falseType):e;this._inferType(t.cond,e);let c=this._inferType(t.then,r),h=this._inferType(t.else_,a);return pt(c,h)}case"AssignExpr":{let s=this._inferType(t.value,e),r=this._inferType(t.target,e);return r&&r.kind!=="unknown"&&s&&s.kind!=="unknown"&&(this._isAssignable(s,r)||this._err(`Cannot assign '${N(s)}' to type '${N(r)}'`,t.target.loc||t.loc,"Ensure the value matches the declared type")),s}case"AwaitExpr":{let s=this._inferType(t.operand,e);return s.kind==="generic"&&s.name==="Promise"&&s.args[0]||k}case"TypeofExpr":return this._inferType(t.operand,e),C;case"PipeExpr":return this._inferType(t.left,e),this._inferType(t.right,e);case"SpreadExpr":return this._inferType(t.expr,e),k;case"RangeExpr":return this._inferType(t.start,e),this._inferType(t.end,e),X(W);case"LambdaExpr":{let s=e.child();for(let c of t.params)s.set(c.name,c.typeAnn?x(c.typeAnn):k);let r=this._inferType(t.body,s),a=t.params.map(c=>c.typeAnn?x(c.typeAnn):k);return R(a,r)}case"FnDecl":{let s=t.retType?x(t.retType):null,r=e.childFn(s,t.async);for(let c of t.params||[])r.set(c.name,c.typeAnn?x(c.typeAnn):k);let a=(t.params||[]).map(c=>c.typeAnn?x(c.typeAnn):k);if(t.inline){let c=this._inferType(t.body,r);return R(a,s||c)}return this._checkStmts(t.body,r),R(a,s||k)}case"CastExpr":return this._inferType(t.expr,e),t.castType?x(t.castType):I;case"SatisfiesExpr":case"NonNullExpr":case"AsConstExpr":{let s=this._inferType(t.expr,e);if(t.type==="SatisfiesExpr"&&t.satType){let r=x(t.satType);this._isAssignable(s,r)||this._err(`Type '${N(s)}' does not satisfy '${N(r)}'`,t.loc)}return s}case"IsExpr":return this._inferType(t.expr,e),j;default:return k}}_checkCallArgs(t,e,s){let r=t.args||[],a=e.params||[];for(let c=0;c<r.length;c++){let h=this._inferType(r[c],s),l=a[c]||I;l.kind!=="any"&&h&&h.kind!=="unknown"&&(this._isAssignable(h,l)||this._err(`Argument ${c+1}: '${N(h)}' is not assignable to '${N(l)}'`,t.loc,"Check function signature"))}}};le.exports={FluxTypeChecker:$t,parseAnnotation:x,typeStr:N,isAssignable:_e,mergeTypes:pt,splitAtTopLevel:K,T_ANY:I,T_UNKNOWN:k,T_NEVER:ct,T_VOID:O,T_NULL:V,T_STRING:C,T_INT:W,T_FLOAT:G,T_NUMBER:L,T_BOOL:j,T_UNION:F,T_INTERSECTION:ae,T_ARRAY:X,T_TUPLE:It,T_NULLABLE:ce,T_NAMED:E,T_FN:R,T_OBJECT:ut,T_RECORD:he,T_LITERAL:Oe}});var _t=_((Os,pe)=>{"use strict";var mt=["range","zip","enumerate","flatten","chunk","unique","groupBy","sortBy","map","filter","reduce","forEach","find","findIndex","some","every","join","sort","flat","flatMap","includes","first","last","take","drop","takeWhile","dropWhile","compact","intersection","difference","arrayUnion","unzip","countBy","minBy","maxBy","toPairs","partition","count","head","tail","nth","rotate","sliding","clamp","sum","product","min","max","abs","floor","ceil","round","mean","median","stdDev","lerp","randInt","sample","shuffle","pick","omit","deepEqual","deepClone","mapValues","filterValues","fromEntries","keys","values","entries","merge","invert","defaults","capitalize","camelCase","snakeCase","kebabCase","truncate","pad","padStart","padEnd","trim","trimStart","trimEnd","words","lines","startsWith","endsWith","repeat","replaceAll","reverseStr","isNil","isString","isNumber","isArray","isObject","isFunction","isBool","sleep","retry","memoize","timeout","debounce","throttle","allSettled","pipe","compose","partial","curry","identity","noop","once","flip","complement"];function Le(n){let t=n?new Set(n.filter(s=>mt.includes(s))):new Set(mt);if(t.size===0)return"";let e=["// \u2500\u2500 Flux stdlib \u2500\u2500"];return t.has("map")&&e.push(`
|
|
65
65
|
function map(arr, fn) { return arr.map(fn); }`),t.has("filter")&&e.push(`
|
|
66
66
|
function filter(arr, fn) { return arr.filter(fn); }`),t.has("reduce")&&e.push(`
|
|
67
67
|
function reduce(arr, fn, init) { return arguments.length >= 3 ? arr.reduce(fn, init) : arr.reduce(fn); }`),t.has("forEach")&&e.push(`
|
|
@@ -443,22 +443,22 @@ function complement(fn) {
|
|
|
443
443
|
return function() { return !fn.apply(this, arguments); };
|
|
444
444
|
}`),e.push(`// \u2500\u2500 end stdlib \u2500\u2500
|
|
445
445
|
`),e.join(`
|
|
446
|
-
`)}function Ce(n){return mt.filter(t=>new RegExp(`\\b${t}\\s*\\(`,"g").test(n))}pe.exports={buildStdlib:Le,detectUsedSymbols:Ce,STDLIB_SYMBOLS:mt}});var me=_(($s,fe)=>{"use strict";var{Lexer:Fe}=J(),{Parser:Be}=et(),{CodeGenerator:Pe}=xt(),{SourceMapBuilder:ue}=Qt(),{transformJsx:Me}=
|
|
446
|
+
`)}function Ce(n){return mt.filter(t=>new RegExp(`\\b${t}\\s*\\(`,"g").test(n))}pe.exports={buildStdlib:Le,detectUsedSymbols:Ce,STDLIB_SYMBOLS:mt}});var me=_(($s,fe)=>{"use strict";var{Lexer:Fe}=J(),{Parser:Be}=et(),{CodeGenerator:Pe}=xt(),{SourceMapBuilder:ue}=Qt(),{transformJsx:Me}=Yt(),{Mangler:je}=Jt(),{transformCss:We}=se(),{Checker:Ue}=re(),{FluxTypeChecker:Qe}=oe(),{buildStdlib:Ve,detectUsedSymbols:He}=_t();function ze(n,t={}){let e={success:!1,output:"",sourceMap:null,ast:null,tokens:null,errors:[],typeErrors:[],typeWarnings:[],stage:null,nameMap:null};try{e.stage="css";let s=We(n);e.stage="jsx";let r=t.jsxTarget||"browser",a=t.jsx!==!1,c=s,h="";if(a){let A=Me(s,{target:r});c=A.source,h=A.hasJsx?A.runtimeHelpers:""}e.stage="lexer";let l=new Fe(c).tokenize();e.tokens=l,e.stage="parser";let p=new Be(l).parse();if(e.ast=p,t.check){e.stage="checker";let v=new Ue().check(p);if(v.errors.length>0)return e.errors=v.errors,e.stage=null,e;e.typeWarnings=[...e.typeWarnings||[],...v.warnings]}if(t.typecheck!==!1){e.stage="typecheck";let v=new Qe().check(p);e.typeErrors=v.errors,e.typeWarnings=[...e.typeWarnings||[],...v.warnings]}let m=p;if(t.mangle){e.stage="mangler";let A=new je;m=A.mangle(p),e.nameMap=A.getMap()}e.stage="codegen";let y={indent:t.mangle?"":" "};t.sourcemap&&(y.smBuilder=new ue(t.sourceFile||"source.flux",n));let{code:u,smBuilder:d}=new Pe(y).generate(m),g=t.stdlib!==!1,f="";if(g){let A=He(u);A.length>0&&(f=Ve(A)+`
|
|
447
447
|
`)}let T=h?`// Flux JSX Runtime
|
|
448
448
|
"use strict";
|
|
449
449
|
${h}
|
|
450
|
-
`:"",
|
|
450
|
+
`:"",b=h?u.replace(/^\/\/ Generated.*\n"use strict";\n/,""):u,w=T+f+b,S=d||null;if(t.mangle){let A=(T+f).split(`
|
|
451
451
|
`).length-1,v=w.split(`
|
|
452
|
-
`),B=[];for(let $=0;$<v.length;$++){let P=v[$].trim();if(!P||P.startsWith("//"))continue;let
|
|
453
|
-
//# sourceMappingURL=${v}`}e.output=w,e.success=!0,e.stage=null}catch(s){e.errors.push({message:s.message,name:s.name,stage:e.stage,line:s.tok?s.tok.line:s.line||null,col:s.tok?s.tok.col:s.col||null,len:s.tok&&s.tok.value?String(s.tok.value).length:1,hint:s.hint||null})}return e}fe.exports={transpile:ze}});var ke=_((_s,ye)=>{"use strict";function
|
|
452
|
+
`),B=[];for(let $=0;$<v.length;$++){let P=v[$].trim();if(!P||P.startsWith("//"))continue;let U=null,tt=!1,q=P;for(let Q=0;Q<P.length-1;Q++){let H=P[Q];if(tt){tt=!1;continue}if(H==="\\"){tt=!0;continue}if(!U&&(H==='"'||H==="'"||H==="`")){U=H;continue}if(U&&H===U){U=null;continue}if(!U&&H==="/"&&P[Q+1]==="/"){q=P.slice(0,Q).trimEnd();break}}q&&B.push({origIdx:$,content:q})}if(w=B.map($=>$.content).join(" "),S){let $=new ue(t.sourceFile||"source.flux",n),P=0;for(let{origIdx:U,content:tt}of B){let q=U-A;if(q>=0)for(let Q of S.mappings[q]||[])$.addMapping(0,P+Q.genCol,Q.srcLine,Q.srcCol);P+=tt.length+1}S=$}}if(S){let A=t.outputFile||"output.js",v=A+".map";e.sourceMap=S.toString(A),w=w+`
|
|
453
|
+
//# sourceMappingURL=${v}`}e.output=w,e.success=!0,e.stage=null}catch(s){e.errors.push({message:s.message,name:s.name,stage:e.stage,line:s.tok?s.tok.line:s.line||null,col:s.tok?s.tok.col:s.col||null,len:s.tok&&s.tok.value?String(s.tok.value).length:1,hint:s.hint||null})}return e}fe.exports={transpile:ze}});var ke=_((_s,ye)=>{"use strict";function Ke(n){let t=n.replace(/\r\n/g,`
|
|
454
454
|
`).replace(/\r/g,`
|
|
455
455
|
`).split(`
|
|
456
|
-
`),e=4;for(let l of t){let p=l.match(/^( +)\S/);if(p){let m=p[1].length;m>0&&m<e&&(e=m);break}}e<1&&(e=4);let s=t.map(l=>{let p=l.trimEnd();if(!p)return"";let m=p.match(/^( *)/),y=m?m[1].length:0,u=Math.round(y/e),d=p.trimStart(),g=d.startsWith("//")||d.startsWith("*")?d:
|
|
457
|
-
`)}function
|
|
456
|
+
`),e=4;for(let l of t){let p=l.match(/^( +)\S/);if(p){let m=p[1].length;m>0&&m<e&&(e=m);break}}e<1&&(e=4);let s=t.map(l=>{let p=l.trimEnd();if(!p)return"";let m=p.match(/^( *)/),y=m?m[1].length:0,u=Math.round(y/e),d=p.trimStart(),g=d.startsWith("//")||d.startsWith("*")?d:Ge(d);return" ".repeat(u)+g}),r=[],a=0;for(let l of s)l===""?(a++,a<=1&&r.push("")):(a=0,r.push(l));let c=[];for(let l=0;l<r.length;l++){c.push(r[l]);let p=r[l].trimStart(),m=(r[l+1]||"").trimStart(),y=r[l].match(/^( *)/)[1].length;y<=4&&/^(fn |async fn |class |type )/.test(p)&&m!==""&&/^(fn |async fn |class |type )/.test(m),l>0&&r[l-1].match(/^( *)/)[1].length>=4&&y===0&&p!==""&&c[c.length-2]!==""&&c.splice(c.length-1,0,"")}let h=c;for(;h.length>0&&h[0]==="";)h.shift();for(;h.length>0&&h[h.length-1]==="";)h.pop();return h.push(""),h.join(`
|
|
457
|
+
`)}function Ge(n){if((n.match(/:/g)||[]).length>2)return n;let t=n;return t=t.replace(/([^=!<>+\-*/%])=(?!=|>)/g,"$1 = "),t=t.replace(/\s{2,}=/g," ="),t=t.replace(/([^\s]) +/g,"$1 "),t=t.replace(/,(?!\s)/g,", "),t=t.replace(/\s*->\s*/g," -> "),t=t.replace(/\s*=>\s*/g," => "),t=t.trimEnd(),t}function Ye(n,t){let e=n.split(`
|
|
458
458
|
`),s=t.split(`
|
|
459
|
-
`),r=[],a=Math.max(e.length,s.length);for(let c=0;c<a;c++){let h=e[c],l=s[c];h!==l&&r.push({line:c+1,original:h,formatted:l})}return r}ye.exports={format:
|
|
459
|
+
`),r=[],a=Math.max(e.length,s.length);for(let c=0;c<a;c++){let h=e[c],l=s[c];h!==l&&r.push({line:c+1,original:h,formatted:l})}return r}ye.exports={format:Ke,diff:Ye}});var Te=_((Ls,ge)=>{"use strict";var Ee=require("fs"),Y=require("path"),{Lexer:qe}=J(),{Parser:Je}=et(),{CodeGenerator:Xe}=xt(),Z=class extends Error{constructor(t,e){super(e?`[${Y.basename(e)}] ${t}`:t),this.name="BundleError",this.file=e}};function Ze(n,t){let e=[],s=[],r=[],a=Y.dirname(t);for(let c of n.body)if(c.type==="ImportDecl"){let h=c.source;h.endsWith(".flux")||(h+=".flux");let l=Y.resolve(a,h);e.push({names:c.names,source:c.source,absPath:l})}else if(c.type==="ExportDecl"){let h=c.decl;h.type==="FnDecl"&&s.push(h.name),h.type==="ClassDecl"&&s.push(h.name),h.type==="VarDecl"&&s.push(h.name),r.push(h)}else r.push(c);return{cleanAst:{type:"Program",body:r},imports:e,exports:s}}function ts(n){let{code:t}=new Xe({indent:" "}).generate(n),e=t.split(`
|
|
460
460
|
`),s=e.findIndex(r=>r.trim()!==""&&!r.includes("Dihasilkan")&&!r.includes('"use strict"'));return e.slice(s).join(`
|
|
461
|
-
`)}function de(n){return"_flux_"+
|
|
461
|
+
`)}function de(n){return"_flux_"+Y.basename(n,".flux").replace(/[^a-zA-Z0-9]/g,"_")}var yt=class{constructor(t,e={}){this.entryFile=Y.resolve(t),this.options=e,this.modules=new Map,this.order=[],this.visited=new Set,this.inStack=new Set}bundle(){return this.collect(this.entryFile),this.link()}collect(t){if(this.visited.has(t))return;if(this.inStack.has(t))throw new Z(`Dependensi sirkular terdeteksi: ${t}`,t);if(!Ee.existsSync(t))throw new Z(`File tidak ditemukan: ${t}`,t);this.inStack.add(t);let e=Ee.readFileSync(t,"utf8"),s;try{let h=new qe(e).tokenize();s=new Je(h).parse()}catch(h){throw new Z(`Error saat parsing: ${h.message}`,t)}let{cleanAst:r,imports:a,exports:c}=Ze(s,t);this.modules.set(t,{cleanAst:r,imports:a,exports:c,source:e,absPath:t});for(let h of a)this.collect(h.absPath);this.inStack.delete(t),this.visited.add(t),this.order.push(t)}link(){let t=[];this.options.banner!==!1&&(t.push("// Dihasilkan oleh Flux Bundler"),t.push(`// Entry: ${Y.basename(this.entryFile)}`),t.push(`// Modul: ${this.order.length}`),t.push('"use strict";'),t.push("")),t.push("// flux_modules resolver"),t.push("(function(){var _p=require('path'),_fs=require('fs'),_M=require('module'),_d=_p.join(process.cwd(),'flux_modules','node_modules');if(_fs.existsSync(_d)){var _o=_M._resolveFilename.bind(_M);_M._resolveFilename=function(r,p,m,op){if(!r.startsWith('.')&&!r.startsWith('/')&&!r.startsWith('node:')){var _fp=_p.join(_d,r.split('/')[0]);if(_fs.existsSync(_fp)){try{return _o(_p.join(_d,r),p,m,op);}catch(_e){}}}return _o(r,p,m,op);};}})();"),t.push(""),t.push("(function() {"),t.push("");for(let s of this.order){let{cleanAst:r,imports:a,exports:c}=this.modules.get(s),h=s===this.entryFile,l=de(s),p=Y.relative(process.cwd(),s);t.push(` // ${"\u2500".repeat(60)}`),t.push(` // Modul: ${p}`),t.push(` // ${"\u2500".repeat(60)}`),h||(t.push(` var ${l} = (function() {`),t.push(" var _exports = {};"),t.push(""));for(let y of a){let u=de(y.absPath);if(y.names.length===1)t.push(` var ${y.names[0]} = ${u};`);else for(let d of y.names)t.push(` var ${d} = ${u}._exports ? ${u}._exports.${d} : ${u}.${d};`)}a.length>0&&t.push("");let m=ts(r);if(t.push(m),!h){if(c.length>0){t.push("");for(let y of c)t.push(` _exports.${y} = ${y};`)}t.push(""),t.push(" return _exports;"),t.push(" })()"),t.push(` ${l}._exports = ${l};`)}t.push("")}return t.push("})();"),{code:t.join(`
|
|
462
462
|
`),modules:this.order.length}}};function es(n,t={}){let e={success:!1,code:"",modules:0,errors:[]};try{let s=new yt(n,t),{code:r,modules:a}=s.bundle();e.code=r,e.modules=a,e.success=!0}catch(s){e.errors.push({message:s.message,name:s.name,file:s.file||null})}return e}ge.exports={bundle:es,Bundler:yt,BundleError:Z}});var be=_((Cs,xe)=>{"use strict";var ss=require("fs"),is=require("path"),rs=["flux.config.js","flux.config.cjs",".fluxrc.js"];function ns(n){let t=n||process.cwd();for(let e of rs){let s=is.join(t,e);if(ss.existsSync(s)){delete require.cache[require.resolve(s)];try{let r=require(s),a=r&&r.default?r.default:r;return typeof a!="object"||a===null?(process.stderr.write(`[flux] warning: ${e} must export a plain object \u2014 ignoring
|
|
463
463
|
`),{}):a}catch(r){return process.stderr.write(`[flux] error loading ${e}: ${r.message}
|
|
464
464
|
`),{}}}}return{}}function as(n,t){let e=n||{},s=t||{};return{jsxTarget:s.jsxTarget!==void 0?s.jsxTarget:e.jsxTarget||"browser",outDir:s.outDir!==void 0?s.outDir:e.outDir||null,sourcemap:s.sourcemap!==void 0?s.sourcemap:e.sourcemap||!1,mangle:s.mangle!==void 0?s.mangle:e.mangle!==void 0?e.mangle:!0,ignore:s.ignore!==void 0?s.ignore:e.ignore||[],entry:s.entry!==void 0?s.entry:e.entry||null}}function cs(n){return n}function hs(n,t){if(!t||t.length===0)return!1;let e=r=>r.replace(/\\/g,"/"),s=e(n);for(let r of t){let a=e(r).replace(/\*\*/g,"\0DS\0");if(a=a.replace(/[.+^${}()|[\]\\]/g,"\\$&"),a=a.replace(/\*/g,"[^/]*"),a=a.replace(/\x00DS\x00\//g,"(.+/)?").replace(/\x00DS\x00/g,".*"),new RegExp("(^|/)"+a+"$").test(s))return!0}return!1}xe.exports={loadConfig:ns,mergeConfig:as,defineConfig:cs,matchIgnore:hs}});var{transpile:ls}=me(),{format:os}=ke(),{buildStdlib:ps,detectUsedSymbols:us,STDLIB_SYMBOLS:fs}=_t(),{Lexer:ms}=J(),{Parser:ys}=et(),{bundle:ks}=Te(),{loadConfig:Es,mergeConfig:ds,defineConfig:gs}=be();module.exports={transpile:ls,format:os,buildStdlib:ps,detectUsedSymbols:us,STDLIB_SYMBOLS:fs,Lexer:ms,Parser:ys,bundle:ks,loadConfig:Es,mergeConfig:ds,defineConfig:gs};
|