code-playpad 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -9
- package/dist/{boot-DcnEI4qy.js → boot-BPyX_lVu.js} +1 -1
- package/dist/cdn.js +2 -2
- package/dist/{cpp-CBVxd2dw.js → cpp-C9kekic8.js} +1 -1
- package/dist/{csharp-JjARABhc.js → csharp-BoD8d8x4.js} +1 -1
- package/dist/editor.d.ts +2 -0
- package/dist/element-Bzd1Vk4K.js +727 -0
- package/dist/element.d.ts +14 -0
- package/dist/element.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{java-CUKw78Eb.js → java-B2RmbH1B.js} +1 -1
- package/dist/{javascript-CCMT-hV6.js → javascript-CcekVHtC.js} +1 -1
- package/dist/{next-B-N7qTIW.js → next-CdrJeX7n.js} +1 -1
- package/dist/progress.d.ts +2 -0
- package/dist/{pyodide-BUWhkmBH.js → pyodide-BVBDl-OE.js} +1 -1
- package/dist/{react-BUyOuVQm.js → react-BPyvHY9v.js} +1 -1
- package/dist/react.d.ts +5 -1
- package/dist/react.js +1 -1
- package/dist/standalone.js +120 -13
- package/dist/{worker-runtime-BptYo0uF.js → worker-runtime-VpuXbObm.js} +1 -1
- package/package.json +1 -10
- package/dist/element-BpSZy4LD.js +0 -620
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./worker-runtime-BptYo0uF.js";var t='"use strict";(()=>{function sr(i,t){let e=[0];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);s===13?(t.charCodeAt(n+1)===10&&n++,e.push(n+1)):s===10&&e.push(n+1)}return{name:i,text:t,lineStarts:e}}function ps(i,t){let e=i.lineStarts,n=0,s=e.length-1;for(;n<s;){let r=n+s+1>>1;e[r]<=t?n=r:s=r-1}return{line:n+1,column:t-e[n]+1}}function yi(i,t){let e=i.lineStarts[t-1];if(e===void 0)return"";let n=i.lineStarts[t],s=n===void 0?i.text.length:n;for(;s>e&&(i.text.charCodeAt(s-1)===10||i.text.charCodeAt(s-1)===13);)s--;return i.text.slice(e,s)}var w={syntax:"syntax",unsupported:"unsupported",limit:"limit",cantResolve:"cant-resolve",incompatibleTypes:"incompatible-types",badOperands:"bad-operands",alreadyDefined:"already-defined",uninitialized:"var-might-not-have-been-initialized",unreported:"unreported-exception",notEffectivelyFinal:"not-effectively-final",unreachable:"unreachable",missingReturn:"missing-return",finalAssign:"final-assign",notStatement:"not-a-statement",numberTooLarge:"int-number-too-large",noMain:"no-main",unchecked:"unchecked",deprecation:"deprecation"},mn=class{items=[];error(t,e,n,s,r,a){let{line:o,column:c}=ps(t,e),u={code:s,phase:n,severity:"error",file:t.name,line:o,column:c,message:r,offset:e};return a&&a.length&&(u.details=a),this.items.push(u),u}warning(t,e,n,s,r){let a=this.error(t,e,"type",n,s,r);return a.severity="warning",a}launchError(t,e,n){let s={code:e,phase:"launch",severity:"error",file:t,line:0,column:0,message:n};return this.items.push(s),s}get hasErrors(){return this.items.some(t=>t.severity==="error")}};function rr(i,t){let e=i.filter(h=>h.phase!=="launch"),n=i.filter(h=>h.phase==="launch"),s=[],r=100,a=0,o=0,c=new Set;for(let h of e){if(h.severity==="error"?++a>r:++o>r){h.severity==="warning"&&h.message.startsWith("[unchecked]")&&c.add(h.file);continue}s.push(`${h.file}:${h.line}: ${h.severity}: ${h.message}`);let m=t.get(h.file);if(m&&h.line>0&&!(h.line>m.lineStarts.length-1&&m.lineStarts[h.line-1]===m.text.length&&m.text.length>0)){let p=yi(m,h.line);s.push(p);let k="";for(let g=0;g<h.column-1;g++)k+=p[g]===" "?" ":" ";s.push(k+"^")}for(let p of h.details??[])s.push(p)}let u=e.filter(h=>h.severity==="error").length,d=e.filter(h=>h.severity==="warning").length;for(let h of c)s.push(`Note: ${h} has additional unchecked or unsafe operations.`);u&&s.push(u===1?"1 error":`${Math.min(u,r)} errors`),u>r&&s.push(`only showing the first ${r} errors, of ${u} total; use -Xmaxerrs if you would like to see more`),d&&s.push(d===1?"1 warning":`${Math.min(d,r)} warnings`),u&&s.push("error: compilation failed");for(let h of n)s.push(h.text??`error: ${h.message}`);return s.join(`\n`)+`\n`}function Oo(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function gi(i){if(i.indexOf("\\\\u")===-1){let a=new Int32Array(i.length+1);for(let o=0;o<=i.length;o++)a[o]=o;return{text:i,offsets:a,errors:[]}}let t=[],e=[],n=[],s=0,r=0;for(;r<i.length;){let a=i.charCodeAt(r);if(a===92&&s%2===0&&i.charCodeAt(r+1)===117){let o=r+1;for(;i.charCodeAt(o)===117;)o++;let c=0,u=-1;for(let d=0;d<4;d++){let h=Oo(i.charCodeAt(o+d));if(h<0){u=o+d;break}c=c*16+h}if(u>=0){n.push({offset:u,message:"illegal unicode escape"}),t.push("\\\\"),e.push(r),s=1,r++;continue}t.push(String.fromCharCode(c)),e.push(r),s=0,r=o+4;continue}s=a===92?s+1:0,t.push(i[r]),e.push(r),r++}return e.push(i.length),{text:t.join(""),offsets:Int32Array.from(e),errors:n}}var Lo=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","_","true","false","null"]),No=[">>>=","<<=",">>=",">>>","...","->","::","++","--","&&","||","==","!=","<=",">=","+=","-=","*=","/=","&=","|=","^=","%=","<<",">>","(",")","{","}","[","]",";",",",".","@","=",">","<","!","~","?",":","+","-","*","/","&","|","^","%"];function Si(i){return i>=65&&i<=90||i>=97&&i<=122||i===95||i===36}function bi(i){return Si(i)||i>=48&&i<=57}function he(i){return i>=48&&i<=57}function $o(i){let t=i.charCodeAt(0);return t>=32&&t<127?`\'${i}\'`:`\'\\\\u${t.toString(16).padStart(4,"0")}\'`}function Ti(i){let t=gi(i),e=t.text,n=t.offsets,s=[],r=t.errors.map(T=>({offset:T.offset,code:"syntax",message:T.message}));if(r.length)return{tokens:[{kind:"eof",text:"",start:i.length,end:i.length}],errors:r};let a=(T,x,v="syntax")=>{r.push({offset:n[T],code:v,message:x,token:s.length})},o=(T,x)=>c("error",T,Math.max(x,T+1)),c=(T,x,v,R)=>{s.push({kind:T,text:e.slice(x,v),start:n[x],end:n[v],...R})},u=e.length;u>0&&e.charCodeAt(u-1)===26&&u--;let d=0;for(;d<u;){let T=e.charCodeAt(d);if(T===32||T===9||T===12||T===10||T===13){d++;continue}if(T===47&&e.charCodeAt(d+1)===47){for(;d<u&&e.charCodeAt(d)!==10&&e.charCodeAt(d)!==13;)d++;continue}if(T===47&&e.charCodeAt(d+1)===42){let v=e.indexOf("*/",d+2);if(v===-1||v+2>u){a(d,"unclosed comment"),d=u;break}d=v+2;continue}if(Si(T)){let v=d;for(;d<u&&bi(e.charCodeAt(d));)d++;if(d<u&&e.charCodeAt(d)>127&&/[\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Sc}]/u.test(e[d]))for(a(d,"identifiers containing non-ASCII characters are not supported in this version","unsupported");d<u&&(bi(e.charCodeAt(d))||e.charCodeAt(d)>127);)d++;let R=e.slice(v,d);c(Lo.has(R)?"keyword":"identifier",v,d);continue}if(he(T)||T===46&&he(e.charCodeAt(d+1))){d=h(d);continue}if(T===39){d=p(d);continue}if(T===34){e.startsWith(\'"""\',d)?d=g(d):d=k(d);continue}let x=No.find(v=>e.startsWith(v,d));if(x){c("operator",d,d+x.length),d+=x.length;continue}T>127&&/[\\p{L}\\p{Nl}\\p{Sc}\\p{Pc}]/u.test(e[d])?a(d,"identifiers containing non-ASCII characters are not supported in this version","unsupported"):(a(d,`illegal character: ${$o(e[d])}`),o(d,d+1)),d++}return s.push({kind:"eof",text:"",start:n[u],end:n[u]}),{tokens:s,errors:r};function h(T){let x=N=>N<u?e.charCodeAt(N):-1,v=N=>x(N)|32,R=N=>he(N)||(N|32)>=97&&(N|32)<=102,L=(N,F)=>{let q=N;for(;q<u&&(F(x(q))||x(q)===95);)q++;return q>N&&x(q-1)===95&&a(q-1,"illegal underscore"),q},C=(N,F="int-literal")=>(c(F,T,N,F==="int-literal"?{integer:{value:0n,radix:10}}:{}),N),M=(N,F,q)=>{let Z=e.slice(q,N).replace(/_/g,""),cn=BigInt((F===16?"0x":F===8?"0o":F===2?"0b":"")+(Z||"0"));return(x(N)|32)===108?(c("long-literal",T,N+1,{integer:{value:cn,radix:F}}),N+1):(c("int-literal",T,N,{integer:{value:cn,radix:F}}),N)},_=(N,F)=>{if(v(N)!==F)return N;let q=N+1;return(x(q)===43||x(q)===45)&&q++,he(x(q))?L(q,he):(a(T,"malformed floating-point literal"),q)},j=N=>{let F=v(N);return F===102?(c("float-literal",T,N+1),N+1):F===100?(c("double-literal",T,N+1),N+1):(c("double-literal",T,N),N)};if(x(T)===48&&v(T+1)===120){let N=T+2;if(x(N)===95)return a(N,"illegal underscore"),C(N+1);let F=L(N,R),q=F>N;if(x(F)===46||v(F)===112){if(x(F)===46){let Z=L(F+1,R);if(!q&&Z===F+1)return a(T,"hexadecimal numbers must contain at least one hexadecimal digit"),C(Z,"double-literal");F=Z}return v(F)!==112?(a(T,"malformed floating-point literal"),C(F,"double-literal")):j(_(F,112))}return q?M(F,16,N):(a(T,"hexadecimal numbers must contain at least one hexadecimal digit"),C(F))}if(x(T)===48&&v(T+1)===98){let N=T+2;if(x(N)===95)return a(N,"illegal underscore"),C(N+1);let F=L(N,he);return F===N?(a(T,"binary numbers must contain at least one binary digit"),C(F)):/[2-9]/.test(e.slice(N,F))?(a(T,"illegal digit in a binary literal"),C(F)):M(F,2,N)}let P=T;if(he(x(T))&&(P=L(T,he)),x(P)===46&&(P>T||he(x(P+1)))||v(P)===101||v(P)===102||v(P)===100)return x(P)===46&&(P=he(x(P+1))?L(P+1,he):P+1),j(_(P,101));if(x(T)===48&&P>T+1){for(let N=T+1;N<P;N++)if(x(N)===56||x(N)===57)return a(N,"illegal digit in an octal literal"),C(P);return M(P,8,T+1)}return M(P,10,T)}function m(T){let x=e[T+1];switch(x){case"b":return["\\b",T+2];case"s":return[" ",T+2];case"t":return[" ",T+2];case"n":return[`\n`,T+2];case"f":return["\\f",T+2];case"r":return["\\r",T+2];case\'"\':return[\'"\',T+2];case"\'":return["\'",T+2];case"\\\\":return["\\\\",T+2]}if(x!==void 0&&x>="0"&&x<="7"){let v=x<="3"?3:2,R=T+1,L="";for(;L.length<v&&R<u&&e[R]>="0"&&e[R]<="7";)L+=e[R++];return[String.fromCharCode(parseInt(L,8)),R]}return null}function p(T){let x=T+1,v=x<u?e.charCodeAt(x):-1;if(v===39)return a(T,"empty character literal"),o(T,x+1),x+1;if(v===-1||v===10||v===13)return a(T,"unclosed character literal"),o(T,x),x;let R;if(v===92){let L=m(x);if(!L){a(x+1,"illegal escape character");let C=O(x);return o(T,C),C}R=L[0],x=L[1]}else R=e[x],x++;return x>=u||e.charCodeAt(x)!==39?(a(T,"unclosed character literal"),o(T,x),x):(c("char-literal",T,x+1,{stringValue:R}),x+1)}function k(T){let x=T+1,v="";for(;x<u;){let R=e.charCodeAt(x);if(R===34)return c("string-literal",T,x+1,{stringValue:v}),x+1;if(R===10||R===13)break;if(R===92){let L=m(x);if(!L){a(x+1,"illegal escape character");let C=O(x);return o(T,C),C}v+=L[0],x=L[1];continue}v+=e[x],x++}return a(T,"unclosed string literal"),o(T,x),x}function g(T){let x=T+3;for(;x<u&&(e[x]===" "||e[x]===" "||e[x]==="\\f");)x++;if(x<u&&e[x]!==`\n`&&e[x]!=="\\r")return a(x,"illegal text block open delimiter sequence, missing line terminator"),o(T,x),x;if(x>=u)return a(T,"unclosed text block"),o(T,u),u;x+=e[x]==="\\r"&&e[x+1]===`\n`?2:1;let v=x;for(;x<u;){if(e.charCodeAt(x)===92){let L=e[x+1];if(L===`\n`||L==="\\r"){x+=L==="\\r"&&e[x+2]===`\n`?3:2;continue}let C=m(x);if(!C){a(x+1,"illegal escape character"),x+=2;continue}x=C[1];continue}if(e.startsWith(\'"""\',x))return c("text-block",T,x+3,{stringValue:Po(e.slice(v,x))}),x+3;x++}return a(T,"unclosed text block"),o(T,u),u}function O(T){for(;T<u&&e.charCodeAt(T)!==10&&e.charCodeAt(T)!==13;)T++;return T}}var ir=/[\\t\\x0b\\f\\x1c-\\x20\\u1680\\u2000-\\u2006\\u2008-\\u200a\\u2028\\u2029\\u205f\\u3000]/;function Po(i){let t=i.replace(/\\r\\n?/g,`\n`).split(`\n`),e=a=>[...a].every(o=>ir.test(o)),n=a=>{let o=0;for(;o<a.length&&ir.test(a[o]);)o++;return o},s=1/0;t.forEach((a,o)=>{(!e(a)||o===t.length-1)&&(s=Math.min(s,n(a)))});let r=t.map(a=>{if(e(a))return"";let o=a.length;for(;o>0&&ir.test(a[o-1]);)o--;return a.slice(s,o)});return Mo(r.join(`\n`))}function Mo(i){if(!i.includes("\\\\"))return i;let t="";for(let e=0;e<i.length;e++){let n=i[e];if(n!=="\\\\"){t+=n;continue}let s=i[++e];switch(s){case`\n`:continue;case"b":t+="\\b";continue;case"s":t+=" ";continue;case"t":t+=" ";continue;case"n":t+=`\n`;continue;case"f":t+="\\f";continue;case"r":t+="\\r";continue}if(s>="0"&&s<="7"){let r=s<="3"?3:2,a="";for(;a.length<r&&e<i.length&&i[e]>="0"&&i[e]<="7";)a+=i[e++];e--,t+=String.fromCharCode(parseInt(a,8));continue}t+=s}return t}var fn=Number.MAX_SAFE_INTEGER,or=9223372036854775807n,lr=-9223372036854775808n,xi=9223372036854776e3;function At(i){let t=BigInt.asIntN(64,i);return t>=-9007199254740991n&&t<=9007199254740991n?Number(t):t}var Pt=i=>typeof i=="bigint"?i:BigInt(i),pn=i=>i===0?0:i;function vi(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i+t;if(e<=fn&&e>=-fn)return e}return At(Pt(i)+Pt(t))}function wi(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i-t;if(e<=fn&&e>=-fn)return e}return At(Pt(i)-Pt(t))}function ki(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i*t;if(e<=fn&&e>=-fn)return pn(e)}return At(Pt(i)*Pt(t))}function Ci(i,t){return typeof i=="number"&&typeof t=="number"?pn(Math.trunc(i/t)):At(Pt(i)/Pt(t))}function Ei(i,t){return typeof i=="number"&&typeof t=="number"?pn(i%t):At(Pt(i)%Pt(t))}function cr(i){return typeof i=="number"?pn(-i):At(-i)}function Ai(i,t){return At(Pt(i)<<BigInt(t&63))}function Ii(i,t){return At(Pt(i)>>BigInt(t&63))}function Oi(i,t){return At(BigInt.asUintN(64,Pt(i))>>BigInt(t&63))}function Li(i,t){return At(Pt(i)&Pt(t))}function Ni(i,t){return At(Pt(i)|Pt(t))}function $i(i,t){return At(Pt(i)^Pt(t))}function bs(i){return typeof i=="number"?i|0:Number(BigInt.asIntN(32,i))}function Ss(i){return Number(i)}function yn(i){if(typeof i=="number")return Math.fround(i);let t=i<0n,e=t?-i:i,n=e.toString(2).length;if(n>26){let s=BigInt(n-26),r=(e&(1n<<s)-1n)!==0n?1n:0n;e=e>>s<<1n|r;let a=Math.fround(Number(e)*2**(n-27));return t?-a:a}return Math.fround(Number(i))}function Dn(i){if(Number.isNaN(i))return 0;if(i>=xi)return or;if(i<=-xi)return lr;let t=Math.trunc(i);return Number.isSafeInteger(t)?pn(t):BigInt(t)}function Fn(i){return Number.isNaN(i)?0:i>=2147483647?2147483647:i<=-2147483648?-2147483648:pn(Math.trunc(i))}function Pi(i){return Number.isNaN(i)?0:Fn(Math.abs(i)>=8388608?i:Math.floor(i+.5))}function Mi(i){return Dn(Math.round(i))}function Ro(i,t,e,n){if(n){if(t=t.replace(/0+$/,"")||"0",e>=0){let s=t.slice(0,e+1).padEnd(e+1,"0"),r=t.slice(e+1)||"0";return`${i}${s}.${r}`}return`${i}0.${"0".repeat(-e-1)}${t}`}return`${i}${t[0]}.${t.slice(1).replace(/0+$/,"")||"0"}E${e}`}var ys=new DataView(new ArrayBuffer(4));function Ri(i){return ys.setFloat32(0,i),ys.getInt32(0)}function Ts(i){return Number.isNaN(i)?2143289344:Ri(i)}function Ji(i){return ys.setInt32(0,i),ys.getFloat32(0)}var gs=i=>10n**BigInt(i);function Fe(i){if(Number.isNaN(i))return"NaN";if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(i===0)return Object.is(i,-0)?"-0.0":"0.0";let t=Ri(i),e=t>>>23&255,n=t&8388607,s=BigInt(e===0?n:n|8388608),r=e===0?-149:e-150,a=Math.max(0,2-r),o=(L,C)=>C>=0?L<<BigInt(C):L>>BigInt(-C),c=o(s,r+a),u=o(2n*s+1n,r-1+a),d=n===0&&e>1?o(4n*s-1n,r-2+a):o(2n*s-1n,r-1+a),h=(s&1n)===0n,m=1n<<BigInt(a),p=L=>L<0?{A:gs(-L),B:m}:{A:1n,B:gs(L)*m},k=L=>{let{A:C,B:M}=p(L),_=d*C,j=u*C,P=(_+M-1n)/M;!h&&P*M===_&&P++;let B=j/M;return!h&&B*M===j&&B--,{dLo:P,dHi:B,A:C,B:M}},g=L=>{let{dLo:C,dHi:M,A:_,B:j}=k(L);if(C>M)return null;let P=c*_,B=P/j,N=2n*P,F=(2n*B+1n)*j;return(N>F||N===F&&(B&1n)===1n)&&B++,B<C&&(B=C),B>M&&(B=M),B},O=Math.floor(Math.log10(Math.abs(i)))+2,T=g(O);for(;T===null;)T=g(--O);T<10n&&(O--,T=g(O));let x=T.toString(),v=O+x.length-1,R=Math.abs(i);return Ro(i<0?"-":"",x,v,R>=.001&&R<1e7)}function Jo(i,t,e){let n=o=>e?-o:o;if(i===0n)return n(0);let s=i.toString().length;if(s+t<-46)return n(0);if(s+t-1>39)return n(1/0);let r=t>=0?i*gs(t):i,a=t>=0?1n:gs(-t);return n(ar(r,a))}function ar(i,t){let e=s=>s.toString(2).length,n=e(i)-e(t)-24;for(;;){n<-149&&(n=-149);let s=n>=0?i:i<<BigInt(-n),r=n>=0?t<<BigInt(n):t,a=s/r;if(a>=1n<<24n){n++;continue}if(a<1n<<23n&&n>-149){n--;continue}let o=s-a*r;return(2n*o>r||2n*o===r&&(a&1n)===1n)&&a++,a===1n<<24n&&(a=1n<<23n,n++),n>104?1/0:Number(a)*2**n}}function ji(i,t){return i===0n?0:t>=0?ar(i<<BigInt(t),1n):ar(i,1n<<BigInt(-t))}function Di(i){let t=i.replace(/_/g,"").replace(/[fF]$/,""),e,n;if(/^0[xX]/.test(t)){let s=/^0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)$/.exec(t),r=s[1]??"",a=s[2]??"",o=BigInt("0x"+(r+a||"0"));n=o!==0n,e=ji(o,Number(s[3])-4*a.length)}else e=ur(t),n=/[1-9]/.test(t.replace(/[eE].*$/,""));return e===1/0?{error:"too-large"}:e===0&&n?{error:"too-small"}:{value:e}}function Fi(i,t){let e=/^([+-]?)0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)[fFdD]?$/.exec(i);if(!e||!(e[2]||e[3]))return NaN;let n=e[3]??"",s=BigInt("0x"+((e[2]??"")+n||"0")),r=Math.max(-1e5,Math.min(1e5,Number(e[4])))-4*n.length,a=t?ji(s,r):Ui(s,r);return e[1]==="-"?-a:a}function ur(i){let t=/^([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?$/.exec(i);if(!t)return NaN;let e=t[2]??"",n=t[3]??"",s=BigInt((e+n).replace(/^0+(?=\\d)/,"")||"0"),r=Math.max(-1e5,Math.min(1e5,Number(t[4]??"0")))-n.length;return Jo(s,r,t[1]==="-")}function de(i){if(Number.isNaN(i))return"NaN";if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(i===0)return Object.is(i,-0)?"-0.0":"0.0";let t=i<0?"-":"",e=Math.abs(i),[n,s]=e.toExponential().split("e");n.includes(".")||([n,s]=e.toExponential(1).split("e"));let r=n.replace(".",""),a=Number(s);if(e>=.001&&e<1e7){if(r=r.replace(/0+$/,"")||"0",a>=0){let o=r.slice(0,a+1).padEnd(a+1,"0"),c=r.slice(a+1)||"0";return`${t}${o}.${c}`}return`${t}0.${"0".repeat(-a-1)}${r}`}return`${t}${r[0]}.${r.slice(1)||"0"}E${a}`}function _i(i){let t=i.replace(/_/g,"").replace(/[dD]$/,""),e,n;if(/^0[xX]/.test(t)){let s=/^0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)$/.exec(t),r=s[1]??"",a=s[2]??"",o=BigInt("0x"+(r+a||"0"));n=o!==0n,e=Ui(o,Number(s[3])-4*a.length)}else e=Number(t),n=/[1-9]/.test(t.replace(/[eE].*$/,""));return e===1/0?{error:"too-large"}:e===0&&n?{error:"too-small"}:{value:e}}function Ui(i,t){if(i===0n)return 0;let e=i.toString(2).length,n=i,s=t;if(e>64){let r=BigInt(e-64),a=(n&(1n<<r)-1n)!==0n?1n:0n;n=n>>r|a,s+=e-64}return Number(n)*2**s}function hr(i){return i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="MethodCall"||i.kind==="NewObject"}var Vt=class extends Error{info;constructor(t){super(t.message),this.info=t}},xs=class extends Error{},Oe=new Set(["int","boolean","byte","short","long","char","float","double"]),Bi=new Set(["public","protected","private","static","final","abstract","native","synchronized","transient","volatile","strictfp","default"]),jo={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"<":7,">":7,"<=":7,">=":7,instanceof:7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Vi=new Set(["=","+=","-=","*=","/=","%=","&=","|=","^=","<<=",">>=",">>>="]),Do={synchronized:"\'synchronized\' statements"},Fo=new Set(["}","{","if","for","while","do","try","switch","return","throw","break","continue","else","final","class","int","long","double","boolean","char","byte","short","float","case","default","yield","assert","synchronized"]),Hi=new Set(["}","public","protected","private","static","final","abstract","class","interface","enum","void","int","long","double","boolean","char","byte","short","float","@","<"]),_o=new Set(["(","!","~","this","super","new","true","false","null","switch"]);function zi(i,t,e,n=[]){let s=new dr(i,t,e,n);try{let r=s.compilationUnit();return s.errors.length?{unit:null,errors:s.errors}:{unit:r,errors:[]}}catch(r){if(r instanceof xs)return{unit:null,errors:s.errors};if(!(r instanceof Vt))throw r;return s.errors.length?(r.info.code==="syntax"&&s.report(r.info),{unit:null,errors:s.errors}):{unit:null,errors:[r.info]}}}var dr=class{#d;#z;#It=[];#rt;#G=0;errors=[];#Ot=-1;#O=-1;#R;#bt=-1;#m=0;#C=!1;#W=0;#V=new Map;#ut=new Map;constructor(t,e,n,s){this.#d=t,this.#z=[...e],this.#rt=n,this.#R=s.some(r=>r.message==="unclosed comment");for(let r of s){let a=e[Math.min(r.token??e.length-1,e.length-1)];this.#V.set(a,[...this.#V.get(a)??[],r]),this.#ut.set(a,Math.max(this.#ut.get(a)??-1,r.offset))}this.#X()}#X(){let t=this.#ut.get(this.#r());t!==void 0&&(this.#bt=Math.max(this.#bt,t));for(let e of[this.#r(),this.#r(1)]){let n=this.#V.get(e);if(n){this.#V.delete(e);for(let s of n)this.errors.push({offset:s.offset,code:"syntax",message:s.message}),s.message.startsWith("illegal text block open delimiter")&&(this.#Ot=Math.max(this.#Ot,s.offset))}}}#r(t=0){return this.#z[Math.min(this.#G+t,this.#z.length-1)]}#p(){return this.#z[Math.max(this.#G-1,0)]}#s(){let t=this.#r();return this.#G<this.#z.length-1&&this.#G++,this.#ut.size&&this.#X(),t}#n(t,e=0){let n=this.#r(e);return(n.kind==="operator"||n.kind==="keyword")&&n.text===t}#S(t=0,e){let n=this.#r(t);return n.kind==="identifier"&&(e===void 0||n.text===e)}#l(t){return this.#n(t)?(this.#s(),!0):!1}#i(t,e=`\'${t}\' expected`){if(this.#n(t))return this.#s();if(this.#m)throw this.#r().kind==="eof"&&t==="}"&&this.#Q(),this.#u(this.#p().end,e);let n=this.#p().end;return this.#O=Math.max(this.#O,this.#r().start),this.report({offset:n,code:"syntax",message:e}),{kind:"operator",text:t,start:n,end:n}}report(t){let e=this.#r().kind==="eof",n=e&&this.#R,s=e&&t.code==="syntax"?{...t,offset:n?this.#r().start:this.#p().end,message:"reached end of file while parsing"}:t,r=this.#r().kind==="error"&&s.offset>=this.#p().end||e&&this.#p().kind==="error";if(s.offset>this.#Ot&&!r&&this.errors.push(s),this.#Ot=Math.max(this.#Ot,s.offset),e)throw new xs}#D(t,e,n){let s={offset:t,code:"syntax",message:e,...n?{details:n}:{}};if(this.#m)throw new Vt(s);this.report(s)}#kt(t){this.#m++;try{return t()}finally{this.#m--}}#E(t,e){if(!(t instanceof Vt)||t.info.code!=="syntax"||this.#m)throw t;this.#O=Math.max(this.#O,t.info.offset,this.#r().start),this.report(t.info),this.#Y(e)}#Y(t){for(;this.#r().start<=this.#bt&&this.#r().kind!=="eof"&&!this.#n("}");){if(this.#n(";")){this.#s();return}this.#s()}if(!(this.#r().start>this.#O))for(;;){let e=this.#r();if(e.kind==="eof")return;if(this.#n(";")){this.#s();return}if(t(e))return;this.#s()}}#A(){let t=this.#r();if(t.kind==="identifier")return this.#s();if(t.kind==="keyword"&&t.text==="_")throw this.#x(t.start,"the unnamed variable \'_\'",!0);t.kind==="eof"&&this.#Q();let e=t.kind==="keyword"?t.start:this.#p().end;if(this.#m)throw this.#u(e,"<identifier> expected");return this.#O=Math.max(this.#O,t.start),this.report({offset:e,code:"syntax",message:"<identifier> expected"}),{kind:"identifier",text:"<error>",start:e,end:e}}#Q(){throw this.#m||this.report({offset:this.#p().end,code:"syntax",message:"reached end of file while parsing"}),this.#u(this.#p().end,"reached end of file while parsing")}#u(t,e){return new Vt({offset:t,code:"syntax",message:e})}#x(t,e,n=!1){return new Vt({offset:t,code:"unsupported",message:`${e} ${n?"is":"are"} not supported in this version`})}#I(){return{i:this.#G,splits:this.#It.length}}#Ct(t){for(;this.#It.length>t.splits;){let e=this.#It.pop();this.#z.splice(e.index,2,e.token)}this.#G=t.i}#me(){let t=this.#r();if(t.kind==="operator"&&t.text===">"){this.#s();return}if(t.kind==="operator"&&(t.text===">>"||t.text===">>>"||t.text===">="||t.text===">>=")){let e={...t,text:">",end:t.start+1},n={...t,text:t.text.slice(1),start:t.start+1};this.#It.push({index:this.#G,token:t}),this.#z.splice(this.#G,1,e,n),this.#s();return}if(t.kind==="eof"&&this.#Q(),this.#m)throw this.#u(t.start,"\'>\' expected");this.#O=Math.max(this.#O,t.start),this.report({offset:this.#p().end,code:"syntax",message:"> expected"})}#o(){this.#i("<");let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#x(e.start,"annotations");let n=this.#A(),s=[];if(this.#l("extends"))do s.push(this.#N());while(this.#l("&"));t.push({name:n.text,pos:n.start,bounds:s})}while(this.#l(","));return this.#me(),t}#b(){if(this.#i("<"),this.#l(">"))return"diamond";let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#x(e.start,"annotations");if(this.#l("?")){let n=null,s=!1;this.#l("extends")?n=this.#N():this.#l("super")&&(s=!0,n=this.#N()),t.push({kind:"WildcardType",bound:n,isSuper:s,pos:e.start,start:e.start,end:this.#p().end})}else t.push(this.#N())}while(this.#l(","));return this.#me(),t}#it(){if(++this.#W>this.#rt.maxNestingDepth)throw new Vt({offset:this.#r().start,code:"limit",message:`code is nested too deeply for this engine (limit ${this.#rt.maxNestingDepth})`})}#St(){this.#W--}#$(t,...e){let n=0;for(let s of e)n=Math.max(n,s.depth);if(t.depth=n+1,t.depth>this.#rt.maxExpressionDepth)throw new Vt({offset:t.start,code:"limit",message:`expression is nested too deeply for this engine (limit ${this.#rt.maxExpressionDepth})`});return t}compilationUnit(){let t={file:this.#d,imports:[],types:[]},e=[];if(this.#n("package")){let n=this.#s().start,s=[this.#A().text],r=[];for(;this.#n(".");)r.push(this.#s().start),s.push(this.#A().text);this.#i(";"),t.package={names:s,start:n,dots:r}}for(;this.#n("import");)t.imports.push(this.#t());for(;this.#r().kind!=="eof";){if(this.#l(";"))continue;let n=this.#r().start;if(this.#n("import"))throw this.#f(t,e);let s=this.#y();if(this.#n("class")||this.#n("interface")){t.types.push(this.#Tt(s,n));continue}if(this.#n("enum")){t.types.push(this.#Lt(s,n));continue}if(this.#n("@")&&this.#n("interface",1))throw this.#x(this.#r().start,"annotation interface declarations");if(this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2))){t.types.push(this.#gt(s,n));continue}if(this.#c()){e.push(this.#j(s,n,null));continue}let r=this.#f(t,e);if(r.info.code!=="syntax"||this.#m)throw r;for(this.report(r.info),this.#s();this.#r().kind!=="eof"&&!this.#n("class")&&!this.#n("interface")&&!this.#n("enum")&&!(this.#s().text===";"&&this.#p().kind==="operator"););}if(e.length){let n=[...e,...t.types].sort((a,o)=>a.start-o.start),s=n[0],r=this.#d.replace(/^.*[\\\\/]/,"").replace(/\\.java$/,"");t.types=[{kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:r,namePos:s.start,keywordPos:s.start,members:n,implicit:!0,pos:s.start,start:s.start,end:n[n.length-1].end}]}return t}#t(){let t=this.#i("import"),e=this.#n("static");e&&this.#s();let n=[this.#A().text],s=t.start,r=[],a=!1,o=this.#p().start,c=o;for(;this.#n(".");){if(s=this.#s().start,r.push(s),this.#n("*")){o=this.#s().start,a=!0;break}let d=this.#A();n.push(d.text),o=d.start}let u=this.#i(";");return{names:n,onDemand:a,lastDotPos:s,dots:r,firstPos:c,...e?{isStatic:!0}:{},pos:o,start:t.start,end:u.end}}#f(t,e){let n=this.#z.some(s=>s.kind==="keyword"&&(s.text==="class"||s.text==="interface"||s.text==="enum"));return!t.types.length&&!e.length&&!n?new Vt({offset:0,code:"no-class",message:"no class declared in source file"}):this.#u(this.#r().start,"class, interface, annotation type, enum, record, method or field expected")}#c(){let t=this.#I();try{if(this.#n("<"))try{this.#kt(()=>this.#o())}catch{return!1}if(this.#n("void"))this.#s();else if(!this.#Et())return!1;return this.#S()?(this.#s(),this.#n("(")||this.#n("=")||this.#n(";")||this.#n(",")):!1}finally{this.#Ct(t)}}#y(){let t={keywords:[]};for(;;){let e=this.#r();if(e.kind==="operator"&&e.text==="@"){if(this.#n("interface",1))return t;(t.annotations??=[]).push(this.#P());continue}if(e.kind==="keyword"&&Bi.has(e.text)){t.keywords.some(n=>n.name===e.text)&&this.#D(e.start,"repeated modifier"),t.keywords.push({name:e.text,pos:e.start}),this.#s();continue}if(e.kind==="identifier"){let n=a=>this.#n("class",a)||this.#n("interface",a)||this.#S(a,"sealed")||this.#S(a,"non")||this.#n("abstract",a)||this.#r(a).kind==="keyword"&&Bi.has(this.#r(a).text),s=e.text==="sealed"&&n(1),r=e.text==="non"&&this.#n("-",1)&&this.#S(2,"sealed")&&this.#r(1).start===e.end&&this.#r(2).start===this.#r(1).end&&n(3);if(s||r){let a=s?"sealed":"non-sealed";t.keywords.some(o=>o.name===a)&&this.#D(e.start,"repeated modifier"),t.keywords.push({name:a,pos:e.start}),this.#s(),r&&(this.#s(),this.#s());continue}}return t}}#P(){let t=this.#i("@"),e=this.#A(),n=[e.text];for(;this.#n(".")&&this.#S(1);)this.#s(),n.push(this.#s().text);let s={name:n[n.length-1],names:n,pos:t.start,namePos:e.start};if(this.#l("(")){let r=[];for(;!this.#n(")");){let a=this.#r().start,o=null;if(this.#S()&&this.#n("=",1)&&(o=this.#s().text,this.#s()),r.push({name:o,value:this.#g(),pos:a}),!this.#l(","))break}this.#i(")"),s.args=r}return s}#g(){if(this.#n("@"))throw this.#x(this.#r().start,"nested annotations");if(!this.#n("{"))return this.#w();let t=this.#s(),e=[];for(;!this.#n("}")&&(e.push(this.#g()),!!this.#l(",")););return this.#i("}"),{kind:"ElementArray",elements:e,pos:t.start}}#J(t,e){let n=s=>Hi.has(s.text);for(;!this.#n("}")&&(this.#r().kind==="eof"&&this.#Q(),this.#Y(n),!this.#n("}"));){if(this.#r().kind==="eof"&&this.#Q(),this.#l(";"))continue;let s=this.#G;try{t.members.push(this.#ee(t.name,e))}catch(r){this.#E(r,n),this.#G===s&&!this.#n("}")&&this.#s()}}t.end=this.#i("}").end}#ht(){return this.#n("{")||this.#m?(this.#i("{"),!0):(this.#i("{"),this.#Y(t=>Hi.has(t.text)||t.text==="{"),this.#l("{"))}#H(t){if(this.#l("implements"))do t.implementsTypes.push(this.#N());while(this.#l(","))}#Lt(t,e){let n=this.#i("enum"),s=this.#A(),r={kind:"ClassDeclaration",keyword:"enum",extendsTypes:[],implementsTypes:[],enumConstants:[],modifiers:t,name:s.text,namePos:s.start,keywordPos:n.start,members:[],pos:s.start,start:e,end:e};if(this.#n("<"))throw this.#x(this.#r().start,"generic enums");if(this.#n("extends")||this.#H(r),!this.#ht())return r.end=this.#p().end,r;for(;this.#S()||this.#n("@");){if(this.#n("@"))throw this.#x(this.#r().start,"annotations");let a=this.#s(),o=this.#n("(")?this.#Xt():[],c;if(this.#n("{")){let u=this.#s();c={kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:"",namePos:a.start,keywordPos:a.start,members:[],anonymous:!0,pos:a.start,start:u.start,end:u.start},this.#J(c)}if(r.enumConstants.push({name:a.text,args:o,...c?{body:c}:{},pos:a.start,start:a.start,end:this.#p().end}),!this.#l(","))break}if(!this.#n("}")&&!this.#l(";")){if(this.#m)throw this.#u(this.#p().end,"\',\', \'}\', or \';\' expected");this.#i(";","\',\', \'}\', or \';\' expected"),this.#Y(a=>a.text==="}")}return this.#J(r),r}#gt(t,e){let n=this.#s(),s=this.#A(),r=this.#n("<")?this.#o():void 0,a={...r?{typeParams:r}:{},kind:"ClassDeclaration",keyword:"record",extendsTypes:[],implementsTypes:[],components:[],modifiers:t,name:s.text,namePos:s.start,keywordPos:n.start,members:[],pos:s.start,start:e,end:e};if(this.#i("("),!this.#n(")"))do{let o=this.#ne();if(o.varargs)throw this.#x(o.pos,"variable-arity record components");a.components.push(o)}while(this.#l(","));return this.#i(")"),this.#n("extends")||this.#H(a),this.#ht()?(this.#J(a,a.name),a):(a.end=this.#p().end,a)}#Tt(t,e){let n=this.#n("interface"),s=this.#s(),r=this.#A(),a={kind:"ClassDeclaration",keyword:n?"interface":"class",extendsTypes:[],implementsTypes:[],modifiers:t,name:r.text,namePos:r.start,keywordPos:s.start,members:[],pos:r.start,start:e,end:e};if(this.#n("<")&&(a.typeParams=this.#o()),this.#l("extends"))do a.extendsTypes.push(this.#N());while(n&&this.#l(","));if(this.#n("implements")){if(n)throw this.#u(this.#r().start,"\'{\' expected");this.#s();do a.implementsTypes.push(this.#N());while(this.#l(","))}if(this.#S(0,"permits")){this.#s(),a.permits=[];do a.permits.push(this.#N());while(this.#l(","))}return this.#ht()?(this.#J(a),a):(a.end=this.#p().end,a)}#ee(t,e){let n=this.#r().start;if(this.#n("{")||this.#n("static")&&this.#n("{",1)){let r={keywords:[]};this.#n("static")&&r.keywords.push({name:"static",pos:this.#s().start});let a=this.#B();return{kind:"Initializer",modifiers:r,isStatic:r.keywords.length>0,body:a,pos:n,start:n,end:a.end}}let s=this.#y();if(this.#n("class")||this.#n("interface"))return this.#Tt(s,n);if(this.#n("enum"))return this.#Lt(s,n);if(this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2)))return this.#gt(s,n);if(e!==void 0&&this.#S(0,e)&&this.#n("{",1)){let r=this.#s(),a=this.#B();return{kind:"MethodDeclaration",modifiers:s,returnType:{kind:"VoidType",pos:r.start,start:r.start,end:r.start},name:r.text,namePos:r.start,params:[],body:a,closeBracePos:a.end-1,isConstructor:!0,compact:!0,pos:r.start,start:n,end:a.end}}return this.#j(s,n,t)}#j(t,e,n){if(this.#n("<")){let a=this.#o(),o=this.#j(t,e,n);if(o.kind!=="MethodDeclaration")throw this.#u(o.pos,"<identifier> expected");return o.typeParams=a,o}if(n!==null&&this.#S()&&this.#n("(",1)){let a=this.#r();if(a.text!==n){if(this.#m)throw this.#u(a.start,"invalid method declaration; return type required");this.report({offset:a.start,code:"syntax",message:"invalid method declaration; return type required"})}this.#s();let o={kind:"VoidType",pos:a.start,start:a.start,end:a.start},c=this.#L(t,o,a,e);return c.isConstructor=!0,c}let s;if(this.#n("(")&&!this.#m)throw this.#u(this.#r().start,"illegal start of type");if(this.#n("void")){let a=this.#s();s={kind:"VoidType",pos:a.start,start:a.start,end:a.end}}else s=this.#N();if(this.#r().kind==="keyword"&&!this.#m&&this.#r().text!=="_"){let a=this.#r();throw this.#O=Math.max(this.#O,this.#p().end),this.report({offset:this.#p().end,code:"syntax",message:"<identifier> expected"}),s.kind==="VoidType"?this.#u(a.start,"\'(\' expected"):this.#u(this.#p().end,"<identifier> expected")}if(this.#n("(")&&!this.#m){let a=this.#p().end;return this.#O=Math.max(this.#O,this.#r().start),this.report({offset:a,code:"syntax",message:"<identifier> expected"}),this.#L(t,s,{kind:"identifier",text:"<error>",start:a,end:a},e)}let r=this.#A();if(!this.#n("(")){if(s.kind!=="VoidType"&&(this.#n("=")||this.#n(";")||this.#n(",")||this.#n("[")))return this.#st(t,s,r,e);throw this.#u(this.#p().end,"\'(\' expected")}return this.#L(t,s,r,e)}#st(t,e,n,s){let r=[],a=n;for(;;){let c=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),c++;let u=null;if(this.#l("=")&&(u=this.#n("{")?this.#ie():this.#w()),r.push({name:a.text,extraDims:c,init:u,pos:a.start,start:a.start,end:this.#p().end}),!this.#l(","))break;a=this.#A()}let o=this.#i(";");return{kind:"FieldDeclaration",modifiers:t,type:e,declarators:r,pos:n.start,start:s,end:o.end}}#L(t,e,n,s){let r={kind:"MethodDeclaration",modifiers:t,returnType:e,name:n.text,namePos:n.start,params:[],body:null,pos:n.start,start:s,end:s};if(this.#i("("),this.#n(")"))this.#i(")");else{do{let a=r.params[r.params.length-1];a?.varargs&&this.#D(a.pos,"varargs parameter must be the last parameter"),r.params.push(this.#ne())}while(this.#l(","));this.#i(")","\',\', \')\', or \'[\' expected")}if(this.#n("["))throw this.#x(this.#r().start,"array dimensions after a parameter list");if(this.#l("throws")){r.throwsTypes=[];do r.throwsTypes.push(this.#N());while(this.#l(","))}if(this.#l(";"))return r.end=this.#p().end,r;if(this.#n("{"))r.body=this.#B();else{if(this.#m)throw this.#u(this.#p().end,"\'{\' or \';\' expected");let a=this.#p().end;this.#O=Math.max(this.#O,this.#r().start),this.report({offset:a,code:"syntax",message:"\'{\' or \';\' expected"}),r.body=this.#B({kind:"operator",text:"{",start:a,end:a})}return r.end=r.body.end,r.closeBracePos=r.body.end-1,r}#ne(){let t=this.#r().start,e=this.#y(),n=this.#N(),s=!1;this.#l("...")&&(s=!0);let r=this.#A();for(;this.#n("[")&&this.#n("]",1);){let a=this.#s(),o=this.#s();n={kind:"ArrayType",element:n,pos:a.start,start:n.start,end:o.end}}if(s){let a=this.#p().end;n={kind:"ArrayType",element:n,pos:n.pos,start:n.start,end:a}}return{modifiers:e,type:n,name:r.text,varargs:s,pos:r.start,start:t,end:r.end}}#N(){let t=this.#r(),e;if(t.kind==="keyword"&&Oe.has(t.text))this.#s(),e={kind:"PrimitiveType",name:t.text,pos:t.start,start:t.start,end:t.end};else if(t.kind==="identifier"){let n=[this.#s().text],s=!1,r,a,o;for(;;){if(this.#n("<")){let c=this.#r().start;r??=c;let u=this.#b();if(u==="diamond")throw this.#u(this.#p().start,"illegal start of type");a=u,s=!0}if(this.#n(".")&&this.#S(1)){o=this.#s().start,n.push(this.#s().text);continue}break}e={kind:"ClassType",names:n,hasTypeArguments:s,typeArgumentsPos:r,typeArguments:a,lastDotPos:o,pos:t.start,start:t.start,end:this.#p().end}}else if(t.kind==="eof")this.#Q();else throw this.#u(t.start,t.kind==="keyword"?"<identifier> expected":"illegal start of type");for(;this.#n("[")&&this.#n("]",1);){let n=this.#s(),s=this.#s();e={kind:"ArrayType",element:e,pos:n.start,start:e.start,end:s.end}}return e}#Et(){let t=this.#I();try{return this.#kt(()=>this.#N()),!0}catch(e){if(!(e instanceof Vt))throw e;return this.#Ct(t),!1}}#B(t=this.#i("{")){this.#it();let e=this.#dt(()=>this.#n("}")),n=this.#i("}");return this.#St(),{kind:"Block",statements:e,pos:t.start,start:t.start,end:n.end}}#dt(t){let e=[],n=s=>Fo.has(s.text)||s.kind==="identifier";for(;!t()&&(this.#r().kind==="eof"&&this.#Q(),this.#Y(n),!t());){this.#r().kind==="eof"&&this.#Q();let s=this.#G;try{e.push(this.#K())}catch(r){this.#E(r,n)}this.#G===s&&!t()&&this.#s()}return e}#K(){if(this.#At())return this.#F();if(this.#n("static")&&(this.#n("class",1)||this.#n("interface",1)))throw this.#u(this.#r().start,"illegal start of expression");let t=this.#n("class")||this.#n("interface")||this.#n("enum")||(this.#n("abstract")||this.#n("final"))&&this.#n("class",1),e=this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2));if(t||e){let s=this.#r().start,r=this.#y(),a=this.#n("enum")?this.#Lt(r,s):e?this.#gt(r,s):this.#Tt(r,s);return{kind:"LocalClass",declaration:a,pos:a.keywordPos,start:s,end:a.end}}let n=this.#r();return n.kind==="keyword"&&Oe.has(n.text)&&!this.#S(1)&&!this.#n("[",1)&&!this.#n(".",1)&&!this.#m?(this.report({offset:n.start,code:"syntax",message:"not a statement"}),this.#s(),this.#i(";"),{kind:"EmptyStatement",pos:n.start,start:n.start,end:n.end}):this.#M()?this.#Z():this.#F()}#M(){if(this.#n("final")||this.#n("@")&&!this.#n("interface",1))return!0;let t=this.#r();if(t.kind==="keyword"&&Oe.has(t.text))return!this.#n(".",1);if(t.kind!=="identifier")return!1;let e=this.#I();try{if(!this.#Et())return!1;let n=this.#r();return n.kind==="identifier"||n.kind==="keyword"&&n.text==="_"}finally{this.#Ct(e)}}#Z(){let t=this.#r().start,e=this.#y();for(let a of e.keywords)if(a.name!=="final")throw this.#u(a.pos,"illegal start of expression");let n=this.#N();n.kind==="ClassType"&&n.names.length===1&&n.names[0]==="var"&&!n.hasTypeArguments&&(n={kind:"VarType",pos:n.pos,start:n.start,end:n.end});let s=[];do{let a=this.#A(),o=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),o++;let c=null;this.#l("=")&&(c=this.#n("{")?this.#ie():this.#w()),s.push({name:a.text,extraDims:o,init:c,pos:a.start,start:a.start,end:this.#p().end})}while(this.#l(","));let r=this.#i(";");return{kind:"LocalVariableDeclaration",modifiers:e,type:n,declarators:s,pos:t,start:t,end:r.end}}#F(){this.#it();try{let t=this.#r();if(t.kind==="operator"&&t.text==="{")return this.#B();if(t.kind==="operator"&&t.text===";")return this.#s(),{kind:"EmptyStatement",pos:t.start,start:t.start,end:t.end};if(t.kind==="keyword"){if((t.text==="this"||t.text==="super")&&this.#n("(",1))return this.#e();if(t.text==="if")return this.#at();if(t.text==="while")return this.#Kt();if(t.text==="do")return this.#Re();if(t.text==="switch")return this.#se();if(t.text==="for")return this.#et();if(t.text==="return")return this.#fe();if(t.text==="break"||t.text==="continue")return this.#re();if(t.text==="throw")return this.#pe();if(t.text==="try")return this.#ye();if(t.text==="assert")return this.#vt();let e=Do[t.text];if(e)throw this.#x(t.start,e);if(t.text==="else")throw this.#u(t.start,"\'else\' without \'if\'")}if(t.kind==="identifier"){if(this.#n(":",1))return this.#a();if(this.#At())return this.#Jt()}if(this.#M()){let e=this.#Z();return this.#D(e.declarators[0].pos,"variable declaration not allowed here"),e}return this.#ge()}finally{this.#St()}}#e(){let t=this.#s(),e=this.#r().start,n=this.#Xt(),s=this.#i(";");return{kind:"ConstructorCall",keyword:t.text,thisPos:t.start,args:n,pos:e,start:t.start,end:s.end}}#at(){let t=this.#i("if");this.#i("(");let e=this.#w();this.#i(")");let n=this.#F(),s=null;this.#l("else")&&(s=this.#F());let r=(s??n).end;return{kind:"IfStatement",condition:e,then:n,otherwise:s,pos:t.start,start:t.start,end:r}}#At(){if(!this.#S(0,"yield"))return!1;let t=this.#r(1);return t.kind==="eof"?!1:t.kind!=="operator"?!0:Vi.has(t.text)?!1:![".","(","[","++","--",";",":",")",","].includes(t.text)}#Jt(){let t=this.#s(),e=this.#w(),n=this.#i(";");return{kind:"YieldStatement",value:e,pos:t.start,start:t.start,end:n.end}}#a(){let t=this.#s();this.#i(":");let e=this.#F();return{kind:"LabeledStatement",label:t.text,body:e,pos:t.start,start:t.start,end:e.end}}#Re(){let t=this.#i("do"),e=this.#F();this.#i("while"),this.#i("(");let n=this.#w();this.#i(")");let s=this.#i(";");return{kind:"DoStatement",body:e,condition:n,pos:t.start,start:t.start,end:s.end}}#se(){let t=this.#i("switch"),e=this.#r().start,n=this.#xt(),{cases:s,end:r}=this.#Ut(!1);return{kind:"SwitchStatement",selector:n,selectorPos:e,cases:s,pos:t.start,start:t.start,end:r}}#xt(){this.#i("(");let t=this.#w();return this.#i(")"),t}#Ut(t){this.#i("{"),this.#it();let e=[];for(;!this.#n("}");){this.#r().kind==="eof"&&this.#Q();let s=this.#r(),r=[],a=!1,o={};if(this.#l("default"))a=!0;else if(this.#l("case")){let u,d,h=!1;do{if(this.#n("null")&&(this.#n(",",1)||this.#n("->",1)||this.#n(":",1))){this.#s(),h=!0;continue}if(h&&this.#n("default")){this.#s(),a=!0;continue}if(this.#ot()){if(u||r.length)throw this.#x(this.#r().start,"several patterns in one case label");if(u=this.#Bt(!0),this.#S(0,"when")){this.#s(),this.#C=!0;try{d=this.#w()}finally{this.#C=!1}}continue}if(this.#S()&&(this.#n("->",1)||this.#n(",",1)||this.#n(":",1))){let m=this.#s();r.push({kind:"Name",identifier:m.text,depth:1,pos:m.start,start:m.start,end:m.end})}else r.push(this.#be())}while(this.#l(","));if(u&&(r.length||h))throw this.#x(u.pos,"a pattern combined with other case labels");o={...u?{pattern:u}:{},...d?{guard:d}:{},...h?{nullLabel:h}:{}}}else throw this.#u(s.start,"\'case\', \'default\', or \'}\' expected");let c={labels:r,isDefault:a,arrow:!1,statements:[],body:null,...o,pos:s.start,start:s.start,end:s.end};if(this.#l("->"))if(c.arrow=!0,this.#n("{"))c.body=this.#B();else if(this.#n("throw")){let u=this.#pe();c.body={kind:"Block",statements:[u],pos:u.pos,start:u.start,end:u.end}}else{let u=this.#w();!t&&!hr(u)&&this.#qt(u),this.#i(";"),c.body=u}else this.#i(":",": or -> expected"),c.statements.push(...this.#dt(()=>this.#n("case")||this.#n("default")||this.#n("}")));c.end=this.#p().end,e.push(c)}let n=this.#i("}");return this.#St(),{cases:e,end:n.end}}#ot(){let t=this.#I();try{this.#l("final");let e=this.#r();return!(e.kind==="identifier"||e.kind==="keyword"&&Oe.has(e.text))||!this.#Et()?!1:this.#S()||this.#n("(")||this.#n("_")}finally{this.#Ct(t)}}#Bt(t){let e=this.#r().start;if(!t&&this.#n("_")){let a=this.#s();return{kind:"TypePattern",type:null,name:"_",namePos:a.start,isFinal:!1,pos:a.start,start:a.start,end:a.end}}let n=this.#l("final"),s;if(!t&&this.#S(0,"var")&&(this.#S(1)||this.#n("_",1))?(this.#s(),s=null):s=this.#N(),s&&this.#n("(")){if(n)throw this.#u(e,"illegal start of expression");this.#s();let a=[];if(!this.#n(")"))do a.push(this.#Bt(!1));while(this.#l(","));let o=this.#i(")");return{kind:"RecordPattern",type:s,components:a,pos:e,start:e,end:o.end}}let r=this.#r();if(this.#n("_"))return this.#s(),{kind:"TypePattern",type:s,name:"_",namePos:r.start,isFinal:n,pos:e,start:e,end:r.end};if(!this.#S())throw this.#u(this.#p().end,"<identifier> expected");return this.#s(),{kind:"TypePattern",type:s,name:r.text,namePos:r.start,isFinal:n,pos:e,start:e,end:r.end}}#Kt(){let t=this.#i("while");this.#i("(");let e=this.#w();this.#i(")");let n=this.#F();return{kind:"WhileStatement",condition:e,body:n,pos:t.start,start:t.start,end:n.end}}#et(){let t=this.#i("for");if(this.#i("("),this.#Nt())return this.#tt(t);let e=null;this.#M()?e=this.#Z():(this.#n(";")||(e=this.#h()),this.#i(";"));let n=this.#n(";")?null:this.#w();this.#i(";");let s=this.#n(")")?[]:this.#h();this.#i(")");let r=this.#F();return{kind:"ForStatement",init:e,condition:n,update:s,body:r,pos:t.start,start:t.start,end:r.end}}#tt(t){let e=this.#y();for(let o of e.keywords)if(o.name!=="final")throw this.#u(o.pos,"illegal start of expression");let n=this.#N();n.kind==="ClassType"&&n.names.length===1&&n.names[0]==="var"&&!n.hasTypeArguments&&(n={kind:"VarType",pos:n.pos,start:n.start,end:n.end});let s=this.#A();this.#i(":");let r=this.#w();this.#i(")");let a=this.#F();return{kind:"ForEachStatement",modifiers:e,type:n,name:s.text,namePos:s.start,iterable:r,body:a,pos:t.start,start:t.start,end:a.end}}#Nt(){let t=this.#I();try{return this.#kt(()=>this.#y()),!this.#Et()||!this.#S()?!1:(this.#s(),this.#n(":"))}catch(e){if(e instanceof Vt)return!1;throw e}finally{this.#Ct(t)}}#h(){let t=[];do{let e=this.#w();hr(e)||this.#qt(e),t.push(e)}while(this.#l(","));return t}#fe(){let t=this.#i("return"),e=this.#n(";")?null:this.#w(),n=this.#i(";");return{kind:"ReturnStatement",value:e,pos:t.start,start:t.start,end:n.end}}#pe(){let t=this.#i("throw"),e=this.#w(),n=this.#i(";");return{kind:"ThrowStatement",expression:e,pos:t.start,start:t.start,end:n.end}}#vt(){let t=this.#i("assert"),e=this.#w(),n=this.#l(":")?this.#w():null,s=this.#i(";");return{kind:"AssertStatement",condition:e,message:n,pos:t.start,start:t.start,end:s.end}}#ye(){let t=this.#i("try"),e=[];if(this.#l("(")){for(;!this.#n(")");){let o=this.#r().start;if(this.#S()&&(this.#n(";",1)||this.#n(")",1))){let c=this.#s();e.push({kind:"variable",expression:{kind:"Name",identifier:c.text,depth:1,pos:c.start,start:c.start,end:c.end},pos:c.start,start:o,end:c.end})}else{this.#y();let c=this.#N();c.kind==="ClassType"&&c.names.length===1&&c.names[0]==="var"&&!c.hasTypeArguments&&(c={kind:"VarType",pos:c.pos,start:c.start,end:c.end});let u=this.#A();this.#i("=");let d=this.#w();e.push({kind:"declaration",type:c,name:u.text,namePos:u.start,init:d,pos:u.start,start:o,end:d.end})}if(!this.#l(";"))break}this.#i(")")}let n=this.#B(),s=[];for(;this.#n("catch");){let o=this.#s();this.#i("(");let c=this.#y(),u=[this.#N()];for(;this.#l("|");)u.push(this.#N());let d=this.#A();this.#i(")");let h=this.#B();s.push({types:u,name:d.text,namePos:d.start,isFinal:c.keywords.some(m=>m.name==="final"),block:h,pos:o.start,start:o.start,end:h.end})}let r=this.#l("finally")?this.#B():null;!s.length&&!r&&!e.length&&this.#D(t.start,"\'try\' without \'catch\', \'finally\' or resource declarations");let a=(r??s[s.length-1]?.block??n).end;return{kind:"TryStatement",resources:e,block:n,catches:s,finallyBlock:r,pos:t.start,start:t.start,end:a}}#re(){let t=this.#s(),e=this.#S()?this.#s().text:void 0,n=this.#i(";");return{kind:t.text==="break"?"BreakStatement":"ContinueStatement",label:e,pos:t.start,start:t.start,end:n.end}}#ie(){let t=this.#i("{");this.#it();let e=[];for(;!this.#n("}")&&(e.push(this.#n("{")?this.#ie():this.#w()),!!this.#l(",")););let n=this.#i("}");return this.#St(),{kind:"ArrayInitializer",elements:e,pos:t.start,start:t.start,end:n.end}}#ge(){let t=this.#w();hr(t)||this.#qt(t);let e=this.#i(";");return{kind:"ExpressionStatement",expression:t,pos:t.pos,start:t.start,end:e.end}}#qt(t){if(this.#m)throw this.#u(t.pos,"not a statement");this.report({offset:t.pos,code:"syntax",message:"not a statement"})}#w(){this.#it();try{let t=this.#be(),e=this.#r();if(e.kind==="operator"&&Vi.has(e.text)){this.#s();let n=this.#w();return this.#$({kind:"Assignment",operator:e.text,target:t,value:n,depth:0,pos:e.start,start:t.start,end:n.end},t,n)}return t}finally{this.#St()}}#be(){let t=this.#Vt(1);if(!this.#n("?"))return t;let e=this.#s(),n=this.#w();this.#i(":");let s=this.#be();return this.#$({kind:"Conditional",condition:t,whenTrue:n,whenFalse:s,depth:0,pos:e.start,start:t.start,end:s.end},t,n,s)}#Vt(t){let e=this.#jt();for(;;){let n=this.#r();if(n.kind!=="operator"&&!(n.kind==="keyword"&&n.text==="instanceof"))break;let s=jo[n.text];if(s===void 0||s<t)break;if(n.text==="instanceof"){e=this.#mt(e);continue}this.#s();let r=this.#Vt(s+1);e=this.#$({kind:"Binary",operator:n.text,left:e,right:r,depth:0,pos:n.start,start:e.start,end:r.end},e,r)}return e}#mt(t){let e=this.#s(),n=!1;this.#n("final")&&(this.#s(),n=!0);let s=this.#N(),r,a;if(this.#n("(")){this.#s();let c=[];if(!this.#n(")"))do c.push(this.#Bt(!1));while(this.#l(","));let u=this.#i(")");a={kind:"RecordPattern",type:s,components:c,pos:s.pos,start:s.start,end:u.end}}else if(this.#S()){let c=this.#s();r={name:c.text,pos:c.start,isFinal:n}}else if(n)throw this.#u(this.#p().end,"<identifier> expected");let o={kind:"InstanceOf",expression:t,targetType:s,...r?{binding:r}:{},...a?{recordPattern:a}:{},depth:0,pos:e.start,start:t.start,end:this.#p().end};return this.#$(o,t)}#jt(){this.#it();try{let t=this.#r();if(t.kind==="operator")switch(t.text){case"-":case"+":{this.#s();let e=this.#r(),n=t.text==="-"&&e.kind==="int-literal"&&e.integer?.radix===10&&e.integer.value===2147483648n?this.#ve(!0):t.text==="-"&&e.kind==="long-literal"&&e.integer?.radix===10&&e.integer.value===9223372036854775808n?this.#Qe(!0):this.#jt();return this.#$({kind:"Unary",operator:t.text,operand:n,depth:0,pos:t.start,start:t.start,end:n.end},n)}case"!":case"~":{this.#s();let e=this.#jt();return this.#$({kind:"Unary",operator:t.text,operand:e,depth:0,pos:t.start,start:t.start,end:e.end},e)}case"++":case"--":{this.#s();let e=this.#jt();return this.#$({kind:"IncDec",operator:t.text,prefix:!0,operand:e,depth:0,pos:t.start,start:t.start,end:e.end},e)}case"(":if(this.#Se()){this.#s();let e=this.#N();this.#i(")");let n=this.#jt();return this.#$({kind:"Cast",targetType:e,expression:n,depth:0,pos:t.start,start:t.start,end:n.end},n)}break}return this.#Te(this.#Ze())}finally{this.#St()}}#Se(){if(this.#en())return!1;let t=this.#r(1);if(t.kind==="keyword"&&Oe.has(t.text))return this.#n(")",2)||this.#n("[",2)&&this.#n("]",3);if(t.kind!=="identifier")return!1;let e=this.#I();try{if(this.#s(),!this.#Et()||!this.#l(")"))return!1;let n=this.#r();return n.kind==="identifier"||n.kind.endsWith("-literal")||n.kind==="text-block"?!0:(n.kind==="operator"||n.kind==="keyword")&&_o.has(n.text)}finally{this.#Ct(e)}}#Te(t){let e=t;for(;;){let n=this.#r();if(n.kind!=="operator")return e;if(n.text==="."){this.#s();let s;if(this.#n("<")){let o=this.#b();if(o==="diamond")throw this.#u(this.#r().start,"illegal start of type");if(s=o,!this.#S()||!this.#n("(",1))throw this.#u(this.#r().start,"<identifier> expected")}let r=this.#r();if(r.kind==="keyword"&&r.text==="class"){this.#s(),e=this.#$({kind:"ClassLiteral",target:e,depth:0,pos:n.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="this"&&(e.kind==="Name"||e.kind==="FieldAccess")){this.#s();let o=[];for(let c=e;;c=c.target){if(c.kind==="Name"){o.unshift(c.identifier);break}if(c.kind!=="FieldAccess")throw this.#u(r.start,"<identifier> expected");o.unshift(c.name)}e=this.#$({kind:"This",qualifier:o,depth:0,pos:e.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="super"&&(e.kind==="Name"||e.kind==="FieldAccess")&&(this.#n(".",1)||this.#n("::",1))){let o=[];for(let c=e;;){if(c.kind==="Name"){o.unshift(c.identifier);break}if(c.kind!=="FieldAccess")throw this.#u(r.start,"<identifier> expected");o.unshift(c.name),c=c.target}this.#s(),e=this.#$({kind:"Super",qualifier:o,qualifierPos:e.start,dotPos:n.start,depth:0,pos:r.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="new"){let o=this.#we();if(o.kind!=="NewObject"||o.classType.kind!=="ClassType"||o.classType.names.length!==1)throw this.#u(r.start,"\'(\' expected");if(o.body)throw this.#x(r.start,"\'.new\' with an anonymous class body",!0);o.outerExpression=e,o.start=e.start,e=this.#$(o,e);continue}if(r.kind==="keyword"&&["this","super"].includes(r.text))throw this.#x(r.start,`\'.${r.text}\' expressions`);let a=this.#A();if(this.#n("(")){let o=this.#r().start,c=this.#Xt();e=this.#$({kind:"MethodCall",target:e,name:a.text,namePos:a.start,selectPos:n.start,args:c,...s?{typeArguments:s}:{},depth:0,pos:o,start:e.start,end:this.#p().end},e,...c)}else e=this.#$({kind:"FieldAccess",target:e,name:a.text,namePos:a.start,depth:0,pos:n.start,start:e.start,end:a.end},e);continue}if(n.text==="["&&this.#n("]",1)&&this.#xe()){let s=this.#Ye(e);for(;this.#n("[");){this.#s();let r=this.#i("]");s={kind:"ArrayType",element:s,pos:s.pos,start:s.start,end:r.end}}return this.#Wt(null,s,e.start)}if(n.text==="["){this.#s();let s=this.#w(),r=this.#i("]");e=this.#$({kind:"ArrayAccess",array:e,index:s,depth:0,pos:n.start,start:e.start,end:r.end},e,s);continue}if(n.text==="::")return this.#Wt(e,void 0,e.start);if(n.text==="<"&&(e.kind==="Name"||e.kind==="FieldAccess")&&this.#ae())throw this.#x(n.start,"method references on a parameterized type (write a lambda)");if(n.text==="++"||n.text==="--"){this.#s(),e=this.#$({kind:"IncDec",operator:n.text,prefix:!1,operand:e,depth:0,pos:n.start,start:e.start,end:n.end},e);continue}return e}}#ae(){let t=this.#I();try{return this.#kt(()=>this.#b())!=="diamond"&&this.#n("::")}catch(e){if(!(e instanceof Vt))throw e;return!1}finally{this.#Ct(t)}}#xe(){let t=0;for(;this.#n("[",t)&&this.#n("]",t+1);)t+=2;return t>0&&this.#n("::",t)}#Ye(t){let e=[],n=t;for(;n.kind==="FieldAccess";)e.unshift(n.name),n=n.target;if(n.kind!=="Name")throw this.#u(t.pos,"<identifier> expected");return e.unshift(n.identifier),{kind:"ClassType",names:e,hasTypeArguments:!1,pos:t.pos,start:t.start,end:t.end}}#Wt(t,e,n){let s=this.#i("::"),r=this.#r();if(r.kind==="operator"&&r.text==="<")throw this.#x(r.start,"explicit type arguments in method references");if(!(r.kind==="identifier"||r.kind==="keyword"&&r.text==="new"))throw this.#u(r.start,"<identifier> expected");if(this.#s(),e&&r.text!=="new")throw this.#u(r.start,"<identifier> expected");return{kind:"MethodRef",target:t,...e?{arrayType:e}:{},name:r.text,namePos:r.start,depth:(t?.depth??0)+1,pos:s.start,start:n,end:r.end}}#oe(t){let e=this.#C;this.#C=!1;try{return t()}finally{this.#C=e}}#Xt(){this.#i("(");let t=[];if(!this.#n(")")){do t.push(this.#oe(()=>this.#w()));while(this.#l(","));return this.#i(")","\')\' or \',\' expected"),t}return this.#i(")"),t}#ve(t){let e=this.#s(),{value:n,radix:s}=e.integer,r;if(s===10){if(n>2147483648n||n===2147483648n&&!t)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});r=Number(BigInt.asIntN(32,n))}else{if(n>0xffffffffn)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});r=Number(BigInt.asIntN(32,n))}return{kind:"Literal",literalKind:"int",value:r,depth:1,pos:e.start,start:e.start,end:e.end}}#Qe(t){let e=this.#s(),{value:n,radix:s}=e.integer;if(s===10?n>9223372036854775808n||n===9223372036854775808n&&!t:n>0xffffffffffffffffn)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});return{kind:"Literal",literalKind:"long",value:BigInt.asIntN(64,n),depth:1,pos:e.start,start:e.start,end:e.end}}#Ze(){let t=this.#r(),e=(r,a)=>(this.#s(),{kind:"Literal",literalKind:r,value:a,depth:1,pos:t.start,start:t.start,end:t.end});switch(t.kind){case"int-literal":return this.#ve(!1);case"long-literal":return this.#Qe(!1);case"float-literal":case"double-literal":{let r=t.kind==="float-literal",a=r?Di(t.text):_i(t.text);if("error"in a)throw new Vt({offset:t.start,code:"fp-number-out-of-range",message:a.error==="too-large"?"floating-point number too large":"floating-point number too small"});return this.#s(),{kind:"Literal",literalKind:r?"float":"double",value:a.value,depth:1,pos:t.start,start:t.start,end:t.end}}case"char-literal":return e("char",t.stringValue??"");case"string-literal":return e("string",t.stringValue??"");case"text-block":return e("string",t.stringValue??"");case"identifier":{if(this.#n("->",1)&&!this.#C)return this.#s(),this.#le(t.start,[{name:t.text,pos:t.start,type:null}]);if(this.#s(),this.#n("(")){let r=this.#r().start,a=this.#Xt();return this.#$({kind:"MethodCall",target:null,name:t.text,namePos:t.start,selectPos:t.start,args:a,depth:0,pos:r,start:t.start,end:this.#p().end},...a)}return{kind:"Name",identifier:t.text,depth:1,pos:t.start,start:t.start,end:t.end}}case"keyword":switch(t.text){case"true":case"false":return this.#s(),{kind:"Literal",literalKind:"boolean",value:t.text==="true",depth:1,pos:t.start,start:t.start,end:t.end};case"null":return this.#s(),{kind:"Literal",literalKind:"null",value:null,depth:1,pos:t.start,start:t.start,end:t.end};case"this":if(this.#n("(",1))throw this.#x(t.start,"constructor calls with \'this(...)\'");return this.#s(),{kind:"This",depth:1,pos:t.start,start:t.start,end:t.end};case"super":if(!this.#n(".",1)&&!this.#n("::",1))throw this.#x(t.start,"\'super\' other than in super.member or super(...)",!0);return this.#s(),{kind:"Super",depth:1,pos:t.start,start:t.start,end:t.end};case"new":return this.#we();case"switch":{this.#s();let r=this.#r().start,a=this.#xt(),{cases:o,end:c}=this.#Ut(!0);return this.#$({kind:"SwitchExpression",selector:a,selectorPos:r,cases:o,depth:0,pos:t.start,start:t.start,end:c},a)}}if(Oe.has(t.text)&&this.#n("[",1)&&this.#n("]",2)){this.#s();let r={kind:"PrimitiveType",name:t.text,pos:t.start,start:t.start,end:t.end};for(;this.#n("[")&&this.#n("]",1);){this.#s();let a=this.#i("]");r={kind:"ArrayType",element:r,pos:r.pos,start:r.start,end:a.end}}if(this.#n("::"))return this.#Wt(null,r,t.start)}if(Oe.has(t.text)||t.text==="void")throw this.#x(t.start,"class literals");break;case"operator":if(t.text==="("){if(!this.#C&&this.#en())return this.#tn();this.#s();let r=this.#oe(()=>this.#w()),a=this.#i(")");return this.#$({kind:"Parenthesized",expression:r,depth:0,pos:t.start,start:t.start,end:a.end},r)}break;case"eof":this.#Q()}if(this.#m)throw this.#u(t.start,"illegal start of expression");let n=t.kind==="operator"&&t.text==="<",s=n?this.#r(1):t;return n&&s.kind!=="identifier"&&!(s.kind==="keyword"&&Oe.has(s.text))&&this.#s(),this.#O=Math.max(this.#O,s.start),this.report({offset:s.start,code:"syntax",message:n&&this.#G>0&&this.#p()===t?"illegal start of type":"illegal start of expression"}),{kind:"Name",identifier:"<error>",depth:1,pos:s.start,start:s.start,end:s.start}}#we(){let t=this.#i("new"),e=this.#r(),n;if(e.kind==="keyword"&&Oe.has(e.text))this.#s(),n={kind:"PrimitiveType",name:e.text,pos:e.start,start:e.start,end:e.end};else if(e.kind==="identifier"){let a=[this.#s().text],o;for(;this.#n(".")&&this.#S(1);)o=this.#s().start,a.push(this.#s().text);let c,u=!1,d;if(this.#n("<")){d=this.#r().start;let h=this.#b();if(h==="diamond"?u=!0:c=h,!this.#n("(")&&u)throw this.#x(d,"array creation with \'<>\'",!0)}if(n={kind:"ClassType",names:a,hasTypeArguments:u||c!==void 0,typeArgumentsPos:d,typeArguments:c,diamond:u,lastDotPos:o,pos:e.start,start:e.start,end:this.#p().end},this.#n("(")){let h=this.#Xt(),m;if(this.#n("{")){let p=this.#s();m={kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:"",namePos:p.start,keywordPos:p.start,members:[],anonymous:!0,pos:p.start,start:p.start,end:p.start},this.#it(),this.#J(m),this.#St()}return this.#$({kind:"NewObject",classType:n,args:h,...m?{body:m}:{},depth:0,pos:t.start,start:t.start,end:this.#p().end},...h)}}else throw this.#u(e.start,"<identifier> expected");if(!this.#n("["))throw this.#u(this.#p().end,"\'(\' or \'[\' expected");if(this.#n("]",1)){let a=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),a++;if(!this.#n("{"))throw this.#u(this.#p().end,"array dimension missing");let o=this.#ie();return this.#$({kind:"NewArray",elementType:n,dimensions:[],extraDims:a,initializer:o,depth:0,pos:t.start,start:t.start,end:o.end})}let s=[],r=0;for(;this.#n("[");){if(this.#n("]",1)){this.#s(),this.#s(),r++;continue}if(r)throw this.#u(this.#r().start,"\']\' expected");this.#s(),s.push(this.#w()),this.#i("]")}if(this.#n("{"))throw this.#u(this.#r().start,"\';\' expected");return this.#$({kind:"NewArray",elementType:n,dimensions:s,extraDims:r,initializer:null,depth:0,pos:t.start,start:t.start,end:this.#p().end},...s)}#tn(){let t=this.#i("("),e=[];if(!this.#n(")"))do{if(this.#S()&&(this.#n(",",1)||this.#n(")",1))){let d=this.#s();e.push({name:d.text,pos:d.start,type:null});continue}let a=[];for(;this.#n("final");)a.push({name:"final",pos:this.#s().start});let o=a.length?{keywords:a,annotations:[]}:void 0;if(this.#S(0,"var")&&this.#S(1)){this.#s();let d=this.#A();if(this.#n("["))for(this.#D(d.start,"\'var\' is not allowed as an element type of an array");this.#n("[")&&this.#n("]",1);)this.#s(),this.#s();e.push({name:d.text,pos:d.start,type:null,isVar:!0,...o?{modifiers:o}:{}});continue}let c=this.#N(),u=this.#A();e.push({name:u.text,pos:u.start,type:c,...o?{modifiers:o}:{}})}while(this.#l(","));this.#i(")");let n=e.filter(r=>r.isVar).length;if(n&&n<e.length){let r=e.some(a=>a.type);this.#D(t.start,"invalid lambda parameter declaration",[r?" (cannot mix \'var\' and explicitly-typed parameters)":" (cannot mix \'var\' and implicitly-typed parameters)"])}let s=e.filter(r=>r.type).length;return s&&s<e.length-n&&this.#D(t.start,"invalid lambda parameter declaration",[" (cannot mix implicitly-typed and explicitly-typed parameters)"]),this.#le(t.start,e)}#le(t,e){if(this.#i("->"),this.#n("{")){let s=this.#B();return{kind:"Lambda",params:e,body:s,depth:1,pos:t,start:t,end:s.end}}let n=this.#w();return this.#$({kind:"Lambda",params:e,body:n,depth:0,pos:t,start:t,end:n.end},n)}#en(){let t=0;for(let e=0;;e++){let n=this.#r(e);if(n.kind==="eof")return!1;if(n.kind==="operator")if(n.text==="(")t++;else{if(n.text===")"&&--t===0)return this.#n("->",e+1);if(n.text===";"||n.text==="{"||n.text==="}")return!1}}}};var Uo=[{module:"java-library-time",file:"time.ts",exported:"TIME_NATIVES",classes:["LocalDate","LocalTime","LocalDateTime","Instant","ZoneId","ZoneOffset","ZonedDateTime","Duration","DayOfWeek","Month","Period","DateTimeFormatter","ChronoUnit"]},{module:"java-library-math",file:"bigmath.ts",exported:"BIGMATH_NATIVES",classes:["BigInteger","BigDecimal","MathContext","RoundingMode"],natives:["nextBigInteger()","nextBigDecimal()"]},{module:"java-library-regex",file:"matcher.ts",exported:"PATTERN_STATICS",classes:["Pattern","Matcher","MatchResult"]},{module:"java-library-bitset",file:"bitset.ts",exported:"BITSET_NATIVES",classes:["BitSet"]}],mr="javaOnlineCompilerLibrary",Gi="javaOnlineCompilerLibraryParts";function Ki(i){let t=i.indexOf("."),e=i.indexOf("("),n=t>0&&(e<0||t<e)?i.slice(0,t):null;return Uo.find(s=>n!==null&&s.classes.includes(n)||s.natives?.includes(i))}var It={Runnable:"java.lang",Stream:"java.util.stream",IntStream:"java.util.stream",LongStream:"java.util.stream",DoubleStream:"java.util.stream",Collectors:"java.util.stream",Collector:"java.util.stream",Optional:"java.util",OptionalInt:"java.util",OptionalLong:"java.util",OptionalDouble:"java.util",IntSummaryStatistics:"java.util",LongSummaryStatistics:"java.util",DoubleSummaryStatistics:"java.util",LongPredicate:"java.util.function",DoublePredicate:"java.util.function",LongConsumer:"java.util.function",DoubleConsumer:"java.util.function",LongSupplier:"java.util.function",DoubleSupplier:"java.util.function",LongFunction:"java.util.function",DoubleFunction:"java.util.function",IntToLongFunction:"java.util.function",IntToDoubleFunction:"java.util.function",LongToIntFunction:"java.util.function",LongToDoubleFunction:"java.util.function",DoubleToIntFunction:"java.util.function",DoubleToLongFunction:"java.util.function",Function:"java.util.function",BiFunction:"java.util.function",Supplier:"java.util.function",Consumer:"java.util.function",BiConsumer:"java.util.function",Predicate:"java.util.function",BiPredicate:"java.util.function",UnaryOperator:"java.util.function",BinaryOperator:"java.util.function",IntBinaryOperator:"java.util.function",IntUnaryOperator:"java.util.function",IntPredicate:"java.util.function",IntFunction:"java.util.function",IntConsumer:"java.util.function",IntSupplier:"java.util.function",ToIntFunction:"java.util.function",ToLongFunction:"java.util.function",ToDoubleFunction:"java.util.function",ToIntBiFunction:"java.util.function",LongBinaryOperator:"java.util.function",LongUnaryOperator:"java.util.function",DoubleBinaryOperator:"java.util.function",DoubleUnaryOperator:"java.util.function",BooleanSupplier:"java.util.function",ObjIntConsumer:"java.util.function",List:"java.util",ArrayList:"java.util",Map:"java.util",HashMap:"java.util",Set:"java.util",HashSet:"java.util",LinkedHashMap:"java.util",TreeMap:"java.util",TreeSet:"java.util",SortedMap:"java.util",NavigableMap:"java.util",SortedSet:"java.util",NavigableSet:"java.util",LinkedList:"java.util",Stack:"java.util",Vector:"java.util",AbstractList:"java.util",LocalDate:"java.time",LocalTime:"java.time",LocalDateTime:"java.time",OffsetTime:"java.time",OffsetDateTime:"java.time",Instant:"java.time",ZoneId:"java.time",ZoneOffset:"java.time",ZonedDateTime:"java.time",Duration:"java.time",Temporal:"java.time.temporal",TemporalAccessor:"java.time.temporal",TemporalAmount:"java.time.temporal",TemporalUnit:"java.time.temporal",DayOfWeek:"java.time",Month:"java.time",Period:"java.time",DateTimeFormatter:"java.time.format",ChronoUnit:"java.time.temporal",BitSet:"java.util",Pattern:"java.util.regex",Matcher:"java.util.regex",MatchResult:"java.util.regex",Hashtable:"java.util",Dictionary:"java.util",Enumeration:"java.util",LinkedHashSet:"java.util",Entry:"java.util",Deque:"java.util",Queue:"java.util",ArrayDeque:"java.util",PriorityQueue:"java.util",Collection:"java.util",Iterator:"java.util",ListIterator:"java.util",Arrays:"java.util",Comparator:"java.util",Collections:"java.util",Random:"java.util",Scanner:"java.util",Iterable:"java.lang",Comparable:"java.lang",Class:"java.lang",Objects:"java.util",StringBuilder:"java.lang",StringBuffer:"java.lang",StringJoiner:"java.util",Number:"java.lang",Integer:"java.lang",Long:"java.lang",Double:"java.lang",Character:"java.lang",Boolean:"java.lang",Float:"java.lang",BigInteger:"java.math",EnumMap:"java.util",EnumSet:"java.util",BigDecimal:"java.math",RoundingMode:"java.math",MathContext:"java.math",Byte:"java.lang",Short:"java.lang",OutputStream:"java.io",Reader:"java.io",InputStreamReader:"java.io",StringReader:"java.io",BufferedReader:"java.io",Writer:"java.io",OutputStreamWriter:"java.io",BufferedWriter:"java.io",StringWriter:"java.io",PrintWriter:"java.io",StreamTokenizer:"java.io",StringTokenizer:"java.util",CharSequence:"java.lang"},Mt={Entry:"Map"},vs="java-library",gn=class extends Error{module;constructor(t=vs){super(`the Java library chunk ${t} is needed`),this.name="NeedsLibrary",this.module=t}},_e=null,fr=new Set;function qi(i){_e=i,fr.clear()}function Wi(i,t){if(!_e)throw new Error(`the Java library part ${i} was loaded before the library`);Object.assign(_e.natives,t),fr.add(i)}function pr(i){for(let{name:t}of i){let e=Ki(t);if(e&&!fr.has(e.module))return e.module}return null}function bn(){return _e}function Wt(i){if(i in It){if(!_e)throw new gn;return _e.classes.get(i)}}function te(i){if(!_e)throw new gn;return _e.classes.get(i)}var V={tag:"int"},_n={tag:"byte"},xn={tag:"short"},Ce={tag:"char"},gt={tag:"boolean"},Jt={tag:"long"},kt={tag:"float"},ft={tag:"double"},xt={tag:"void"},br={tag:"null"},mt={tag:"string"},G={tag:"object"},Qi={tag:"printstream"},A={tag:"error"};function ee(i){return{tag:"array",element:i}}function tt(i,t){return t?.length?{tag:"class",name:i.displayName,symbol:i,args:t}:{tag:"class",name:i.displayName,symbol:i}}function me(i){return{tag:"typevar",name:i.name,symbol:i}}function fe(i){return tt(i,i.typeParams?.map(me))}function ws(i){return i.symbol?.key??i.name}function gr(i){return i.symbol?.bounds[0]??G}function Kt(i,t){if(!t.size)return i;switch(i.tag){case"typevar":return t.get(ws(i))??i;case"array":return ee(Kt(i.element,t));case"library":return i.args.length?pt(i.symbol,i.args.map(e=>Kt(e,t))):i;case"class":return i.args?.length?tt(i.symbol,i.args.map(e=>Kt(e,t))):i;case"wildcard":return i.bound?{...i,bound:Kt(i.bound,t)}:i;default:return i}}function Un(i){let t=new Map,e=i.symbol.typeParams??[];return i.args?.length===e.length&&e.forEach((n,s)=>t.set(n.key,i.args[s])),t}function Bn(i){return i.tag==="class"&&(i.symbol.typeParams?.length??0)>0&&!i.args?.length}function W(i){switch(i.tag){case"typevar":return i.symbol?W(gr(i)):G;case"wildcard":return G;case"array":return ee(W(i.element));case"library":return i.args.length?pt(i.symbol):i;case"class":return i.args?.length?tt(i.symbol):i;default:return i}}function Vn(i){let t=i.symbol,e=[];if(t.superType?e.push(t.superType):t.superclass?e.push(tt(t.superclass)):t.librarySuperclass&&e.push(t.librarySuperclass),t.interfaceTypes?e.push(...t.interfaceTypes):e.push(...t.interfaces.map(s=>tt(s))),e.push(...t.libraryInterfaces),!t.typeParams?.length)return e;if(!i.args?.length)return e.map(W);let n=Un(i);return e.map(s=>Kt(s,n))}function se(i,t){if(i.tag==="typevar"&&i.symbol){for(let e of i.symbol.bounds){let n=se(e,t);if(n)return n}return null}if(i.tag!=="class")return null;if(i.symbol===t)return i;for(let e of Vn(i)){let n=se(e,t);if(n)return n}return null}function Le(i,t=new Set){if(t.has(i.symbol))return[];t.add(i.symbol);let e=[];for(let n of Vn(i))n.tag==="library"?e.push(n):n.tag==="class"&&e.push(...Le(n,t));return e}function Ne(i,t,e){if(!t.typeParams?.length)return e;let n=se(i,t);return n?n.args?.length?Kt(e,Un(n)):W(e):e}function pt(i,t=[]){return{tag:"library",symbol:i,args:t}}function wt(i,t,e){switch(i.tag){case"typevar":{if(i.symbol)return i;let n=t.indexOf(i.name);return n>=0&&e[n]?e[n]:G}case"array":return ee(wt(i.element,t,e));case"library":return i.args.length?pt(i.symbol,i.args.map(n=>wt(n,t,e))):i;case"wildcard":return i.bound?{...i,bound:wt(i.bound,t,e)}:i;default:return i}}function Xt(i,t,e){switch(i.tag){case"typevar":{if(i.symbol)return i;let n=t.indexOf(i.name);return n>=0&&e[n]?e[n]:i}case"array":return ee(Xt(i.element,t,e));case"library":return i.args.length?pt(i.symbol,i.args.map(n=>Xt(n,t,e))):i;case"wildcard":return i.bound?{...i,bound:Xt(i.bound,t,e)}:i;default:return i}}function Sr(i){return i.symbol.supertypes.map(t=>wt(t,i.symbol.typeParams,i.args))}function Dt(i,t){if(i.tag!=="library")return null;if(i.symbol===t)return i;for(let e of Sr(i)){let n=Dt(e,t);if(n)return n}return null}function qt(i){let t={int:"Integer",long:"Long",double:"Double",char:"Character",boolean:"Boolean",float:"Float",byte:"Byte",short:"Short"}[i.tag],e=t?bn()?.classes.get(t):void 0;return e?pt(e):null}function St(i){return i.tag!=="library"||!i.symbol.box?null:{int:V,long:Jt,double:ft,char:Ce,boolean:gt,float:kt,byte:_n,short:xn}[i.symbol.box]}function $(i){switch(i.tag){case"int":case"byte":case"short":case"char":case"boolean":case"long":case"float":case"double":case"void":return i.tag;case"null":return"<null>";case"string":return"String";case"object":return"Object";case"printstream":return"PrintStream";case"array":return $(i.element)+"[]";case"class":return i.args?.length?`${i.name}<${i.args.map($).join(",")}>`:i.name;case"library":return i.args.length?`${i.symbol.name}<${i.args.map($).join(",")}>`:i.symbol.name;case"diamond":return`${i.symbol.name}<>`;case"typevar":return i.name;case"wildcard":return i.poly&&i.bound?$(i.bound):i.bound?`? ${i.isSuper?"super":"extends"} ${$(i.bound)}`:"?";case"lambda":return i.text;case"error":return"<any>"}}function at(i,t){if(i.tag!==t.tag)return!1;if(i.tag==="array"&&t.tag==="array")return at(i.element,t.element);if(i.tag==="class"&&t.tag==="class"){let e=i.args??[],n=t.args??[];return i.symbol===t.symbol&&e.length===n.length&&e.every((s,r)=>at(s,n[r]))}return i.tag==="wildcard"&&t.tag==="wildcard"?i.isSuper===t.isSuper&&(i.bound===null?t.bound===null:t.bound!==null&&at(i.bound,t.bound)):i.tag==="library"&&t.tag==="library"?i.symbol===t.symbol&&i.args.length===t.args.length&&i.args.every((e,n)=>at(e,t.args[n])):i.tag==="typevar"&&t.tag==="typevar"?i.symbol===t.symbol&&i.name===t.name:i.tag==="diamond"&&t.tag==="diamond"?i.symbol===t.symbol:!0}function nt(i){return i.tag==="string"||i.tag==="null"||i.tag==="object"||i.tag==="printstream"||i.tag==="array"||i.tag==="class"||i.tag==="library"||i.tag==="typevar"||i.tag==="diamond"}function st(i){return["int","byte","short","char","boolean","long","float","double"].includes(i.tag)}function Rt(i){return["int","byte","short","char","long","float","double"].includes(i.tag)}var Xi={byte:0,short:1,char:1,int:2,long:3,float:4,double:5};function Bo(i,t){return!Rt(i)||!Rt(t)||i.tag==="char"||t.tag==="char"&&i.tag==="short"?!1:Xi[t.tag]<Xi[i.tag]}function Sn(i,t){return i===t||i.superclass&&Sn(i.superclass,t)?!0:i.interfaces.some(e=>Sn(e,t))}function Tn(i,t=new Set){if(t.has(i))return[];t.add(i);let e=[...i.libraryInterfaces];i.superclass&&e.push(...Tn(i.superclass,t));for(let n of i.interfaces)e.push(...Tn(n,t));return e}var Hn={tag:"typevar",name:"?open"};function yr(i,t){let e=t.args??[];return!i.args?.length&&e.length?!1:(i.args??[]).every((n,s)=>{let r=e[s];if(n===Hn||!r)return!0;let a=n.tag==="wildcard"&&n.poly&&n.bound?n.bound:n;return a!==n&&r.tag!=="wildcard"?K(a,r):r.tag==="wildcard"?r.bound?a.tag==="wildcard"?r.isSuper?a.isSuper===!0&&a.bound!==null&&K(r.bound,a.bound):a.isSuper?r.bound.tag==="object":K(a.bound??G,r.bound):r.isSuper?K(r.bound,a):K(a,r.bound):!0:at(a,r)})}function K(i,t){if(at(i,t))return!0;if(i.tag==="null")return nt(t);if(t.tag==="object")return nt(i);if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&nt(t.element)&&K(i.element,t.element);if(i.tag==="typevar"&&i.symbol)return i.symbol.bounds.some(s=>K(s,t));if(i.tag==="class"&&t.tag==="class"){let s=se(i,t.symbol);return s?t.args?.length?(s.args?.length??0)>0&&yr(s,t):!0:!1}if(i.tag==="class"&&i.symbol.isEnum&&t.tag==="library"&&t.symbol.name==="Comparable"){let s=t.args[0];return!s||at(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?K(s.bound,i):K(i,s.bound)))}if(i.tag==="class"&&t.tag==="library")return Le(i).some(s=>{let r=Dt(s,t.symbol);return r!==null&&yr(r,t)});if((i.tag==="string"||i.tag==="library"&&(i.symbol.box!==void 0||i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer"))&&t.tag==="library"&&t.symbol.name==="Comparable"){let s=t.args[0];return!s||at(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?K(s.bound,i):K(i,s.bound)))}if(t.tag!=="library")return!1;if(t.symbol.name==="CharSequence"&&(i.tag==="string"||i.tag==="library"&&(i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer")))return!0;if(i.tag==="printstream")return t.symbol.name==="OutputStream";if(i.tag==="diamond")return Dt(pt(i.symbol,i.symbol.typeParams.map(()=>G)),t.symbol)!==null;let n=Dt(i,t.symbol);return n?yr(n,t):!1}function Vo(i){return i.box!==void 0||i.name==="StringBuilder"||i.name==="StringBuffer"||i.name==="StringJoiner"||i.name==="Scanner"}function Yi(i){switch(i.tag){case"class":return{interface:i.symbol.isInterface,final:i.symbol.isFinal};case"library":case"diamond":return{interface:i.symbol.isInterface,final:!i.symbol.isInterface&&Vo(i.symbol)};case"string":return{interface:!1,final:!0};default:return null}}function ke(i,t){if(K(t,i)||K(i,t))return!0;if(i.tag==="typevar"&&i.symbol)return ke(gr(i),t);if(t.tag==="typevar"&&t.symbol)return ke(i,gr(t));if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&nt(t.element)?ke(i.element,t.element):at(i.element,t.element);let e=Yi(i),n=Yi(t);return!e||!n?!1:e.interface&&n.interface?!0:e.interface?!n.final:n.interface?!e.final:!1}function Ze(i,t){return i.tag==="error"||t.tag==="error"?!0:t.tag==="lambda"?ta(i,t)===null:at(i,t)||Bo(i,t)?!0:nt(i)&&K(t,i)}function Ht(i,t){if(Ze(i,t))return!0;if(st(t)&&nt(i)){if(i.tag==="object")return!0;let n=qt(t);return n!==null&&K(n,i)}let e=St(t);return e!==null&&st(i)&&Ze(i,e)}var Ho={byte:[-128,127],short:[-32768,32767],char:[0,65535]};function re(i,t,e){if(Ht(i,t))return!0;let n=i.tag==="library"?i.symbol.box:i.tag,s=n?Ho[n]:void 0;if(s&&["int","byte","short","char"].includes(t.tag)&&e&&(e.kind==="int"||e.kind==="char")){let r=e.value;return r>=s[0]&&r<=s[1]}return!1}function zo(i){if(i.tag==="class"&&i.symbol.isInterface&&!i.symbol.isSealed){let n=ks(i.symbol);return n.length===1?{params:n[0].params,returnType:n[0].returnType}:null}if(i.tag!=="library"||!i.symbol.functional)return null;let t=i.symbol.methods.find(n=>n.name===i.symbol.functional&&!n.isStatic),e=i.symbol.typeParams.map((n,s)=>{let r=i.args[s];return r?r.tag==="wildcard"?r.bound??G:r:G});return{params:t.params.map(n=>wt(n,i.symbol.typeParams,e)),returnType:wt(t.returnType,i.symbol.typeParams,e)}}function Zi(i){switch(i.tag){case"typevar":case"wildcard":case"object":return"Object";case"string":return"String";case"library":return i.symbol.qualifiedName;case"class":return i.symbol.binaryName;case"array":return Zi(i.element)+"[]";default:return i.tag}}function ks(i){let t=new Set(["equals(Object)","hashCode()","toString()"]),e=[],n=[i];for(let s=0;s<n.length;s++){let r=n[s];for(let a of r.methods){if(a.isStatic||a.isPrivate)continue;let o=`${a.name}(${a.params.map(Zi).join(",")})`;t.has(o)||(t.add(o),a.isAbstract&&e.push(a))}n.push(...r.interfaces)}return e}function ta(i,t){if(i.tag==="error")return null;let e=zo(i);return e?t.arity<0||e.params.length===t.arity?null:"incompatible parameter types in lambda expression":`${i.tag==="array"?"Array":i.tag==="library"||i.tag==="diamond"?i.symbol.name:i.tag==="class"?i.symbol.displayName:$(i)} is not a functional interface`}function Ue(i,t){return t.tag==="lambda"?ta(i,t)??"":Rt(i)&&Rt(t)?`possible lossy conversion from ${$(t)} to ${$(i)}`:`${$(t)} cannot be converted to ${$(i)}`}function Ft(i){switch(i.tag){case"int":return"I";case"char":return"C";case"boolean":return"Z";case"long":return"J";case"double":return"D";case"byte":return"B";case"short":return"S";case"float":return"F";case"string":return"Ljava.lang.String;";case"class":return`L${i.symbol.binaryName};`;case"library":case"diamond":return`L${i.symbol.qualifiedName};`;case"object":return"Ljava.lang.Object;";case"array":return"["+Ft(i.element);case"typevar":return Ft(W(i));default:throw new Error(`codegen: descriptor of ${$(i)}`)}}var ea=new WeakMap,na=new WeakMap,sa=new WeakMap;function Tr(i){let t=ea.get(i);return t||ea.set(i,t={kind:"type",symbol:i}),t}function wn(i,t){let e=na.get(i);return e||na.set(i,e={kind:"method",method:i,owner:t}),e}function xr(i){let t=sa.get(i);return t||sa.set(i,t={kind:"program",variable:i}),t}function ra(i,t){return i.symbol?{name:i.name,decl:xr(i.symbol)}:t?t.kind==="method"?t.method.typeParams?.includes(i.name)?{name:i.name,decl:t}:t.owner.typeParams.includes(i.name)?{name:i.name,decl:Tr(t.owner)}:null:t.kind==="type"&&t.symbol.typeParams.includes(i.name)?{name:i.name,decl:t}:null:null}function ia(i){if(i.decl.kind==="method"){let t=i.decl.method.typeParamBounds?.[i.name];return t?{type:t,decl:i.decl}:null}if(i.decl.kind==="program"){let t=i.decl.variable.bounds[0];return t?{type:t,decl:null}:null}return null}var vn=class{refs=[];#d=new Set;#z(t,e){return t.name===e.name&&t.decl===e.decl}add(t){if(this.refs.some(s=>this.#z(s,t)))return;this.refs.push(t);let e=ia(t);e&&this.visit(e.type,e.decl);let n=t.decl;if(!(n.kind!=="method"||this.#d.has(n))){this.#d.add(n);for(let s of n.method.typeParams??[])this.add({name:s,decl:n});for(let s of n.method.params)this.visit(s,n)}}visit(t,e){switch(t.tag){case"typevar":{let n=ra(t,e);n&&this.add(n);return}case"array":return this.visit(t.element,e);case"wildcard":t.bound&&this.visit(t.bound,e);return;case"library":return t.args.forEach(n=>this.visit(n,e));case"class":return t.args?.forEach(n=>this.visit(n,e));default:return}}label(t){let e=this.refs.filter(n=>n.name===t.name);return e.length>1?`${t.name}#${e.findIndex(n=>n.decl===t.decl)+1}`:t.name}render(t,e){switch(t.tag){case"typevar":{let n=ra(t,e);return n?this.label(n):t.name}case"array":return`${this.render(t.element,e)}[]`;case"wildcard":return t.bound?`? ${t.isSuper?"super":"extends"} ${this.render(t.bound,e)}`:"?";case"library":return t.args.length?`${t.symbol.name}<${t.args.map(n=>this.render(n,e)).join(",")}>`:t.symbol.name;case"class":return t.args?.length?`${t.name}<${t.args.map(n=>this.render(n,e)).join(",")}>`:t.name;default:return $(t)}}params(t){let e=t.method;return e.params.map((n,s)=>e.varargs&&s===e.params.length-1&&n.tag==="array"?`${this.render(n.element,t)}...`:this.render(n,t)).join(",")}#It(t){return t.kind==="type"?`${t.symbol.isInterface?"interface":"class"} ${t.symbol.name}`:t.kind==="program"?t.variable.declaredIn:`method <${(t.method.typeParams??[]).map(e=>this.label({name:e,decl:t})).join(",")}>${t.method.name}(${this.params(t)})`}#rt(t){let e=`Comparable<? super ${this.label(t)}>`;if(t.decl.kind==="method"&&t.decl.method.typeParamShown?.[t.name]){let s=t.decl,r=s.method.typeParamShown[t.name].replace(/\\bComparable\\b(?!<)/,e);for(let a of s.method.typeParams??[])r=r.replace(new RegExp(`\\\\b${a}\\\\b(?!#)`,"g"),this.label({name:a,decl:s}));return r}if(t.decl.kind==="method"&&t.decl.method.comparableParams?.includes(t.name))return e;let n=ia(t);return n?this.render(n.type,n.decl):"Object"}entries(){return this.refs.map(t=>({name:this.label(t),line:` ${this.label(t)} extends ${this.#rt(t)} declared in ${this.#It(t.decl)}`}))}};function aa(i,t,e){let n=new vn;n.add(i);for(let a of[...t,...e])n.visit(a.type,a.decl);let s=a=>[...new Set(a.map(o=>n.render(o.type,o.decl)))].join(","),r=n.entries();return[` reason: argument mismatch; inference variable ${n.label(i)} has incompatible bounds`,` upper bounds: ${s(t)}`,` lower bounds: ${s(e)}`,r.length===1?` where ${r[0].name} is a type-variable:`:` where ${r.map(a=>a.name).join(",")} are type-variables:`,...r.map(a=>a.line)]}function Cs(i){if(i.kind==="MethodRef")return ct(i);let t=i.kind==="Lambda"?la(i):ct(i);return t.length>=20?`${t.slice(0,10)}[...]${t.slice(-5)}`:t}function la(i){let t=i.params.every(n=>!n.type)?i.params.map(n=>n.name).join(","):i.params.map(n=>`${oe(n.type)} ${n.name}`).join(", "),e=i.body.kind==="Block"?ca(i.body.statements):ct(i.body);return`(${t})->${e}`}function oe(i){switch(i.kind){case"PrimitiveType":return i.name;case"ClassType":return i.names.join(".")+(i.typeArguments?`<${i.typeArguments.map(oe).join(",")}>`:i.diamond?"<>":"");case"ArrayType":return`${oe(i.element)}[]`;case"WildcardType":return i.bound?`? ${i.isSuper?"super":"extends"} ${oe(i.bound)}`:"?";case"VoidType":return"void";case"VarType":return"var"}}function oa(i,t){let e={"\\b":"\\\\b"," ":"\\\\t","\\n":"\\\\n","\\f":"\\\\f","\\r":"\\\\r",\'"\':\'\\\\"\',"\'":"\\\\\'","\\\\":"\\\\\\\\"},n="";for(let s of i){let r=s.charCodeAt(0);n+=e[s]??(r<32||r>126?`\\\\u${r.toString(16).padStart(4,"0")}`:s)}return t+n+t}function ct(i){switch(i.kind){case"Literal":switch(i.literalKind){case"long":return`${i.value}L`;case"double":return de(i.value);case"float":return`${de(parseFloat(String(i.value)))}F`;case"char":return oa(i.value,"\'");case"string":case"text-block":return oa(i.value,\'"\');default:return String(i.value)}case"Name":return i.identifier;case"FieldAccess":return`${ct(i.target)}.${i.name}`;case"MethodCall":return`${i.target?ct(i.target)+".":""}${i.name}(${i.args.map(ct).join(", ")})`;case"Unary":return i.operator+ct(i.operand);case"IncDec":return i.prefix?i.operator+ct(i.operand):ct(i.operand)+i.operator;case"Binary":return`${ct(i.left)} ${i.operator} ${ct(i.right)}`;case"Assignment":return`${ct(i.target)} ${i.operator} ${ct(i.value)}`;case"Parenthesized":return`(${ct(i.expression)})`;case"ArrayAccess":return`${ct(i.array)}[${ct(i.index)}]`;case"NewArray":{let t=i.dimensions.map(e=>`[${ct(e)}]`).join("")+"[]".repeat(i.extraDims);return i.initializer?`new ${oe(i.elementType)}${"[]".repeat(Math.max(1,i.extraDims))}{${i.initializer.elements.map(e=>e.kind==="ArrayInitializer"?"{...}":ct(e)).join(", ")}}`:`new ${oe(i.elementType)}${t}`}case"Cast":return`(${oe(i.targetType)})${ct(i.expression)}`;case"This":return"this";case"NewObject":return`${i.outerExpression?`${ct(i.outerExpression)}.`:""}new ${oe(i.classType)}(${i.args.map(ct).join(", ")})`;case"Conditional":return`${ct(i.condition)} ? ${ct(i.whenTrue)} : ${ct(i.whenFalse)}`;case"SwitchExpression":return`switch (${ct(i.selector)}) {...}`;case"Lambda":return la(i);case"MethodRef":return`${i.arrayType?oe(i.arrayType):i.target?ct(i.target):""}::${i.name}`;case"InstanceOf":return`${ct(i.expression)} instanceof ${oe(i.targetType)}${i.binding?` ${i.binding.name}`:""}`;case"Super":return"super";case"ClassLiteral":return`${ct(i.target)}.class`}}function ca(i){return i.length?`{ ${i.map(tn).join(" ")} }`:"{ }"}function tn(i){switch(i.kind){case"Block":return ca(i.statements);case"ReturnStatement":return i.value?`return ${ct(i.value)};`:"return;";case"ExpressionStatement":return`${ct(i.expression)};`;case"LocalVariableDeclaration":return`${oe(i.type)} ${i.declarators.map(t=>t.init&&t.init.kind!=="ArrayInitializer"?`${t.name} = ${ct(t.init)}`:t.name).join(", ")};`;case"IfStatement":return`if (${ct(i.condition)}) ${tn(i.then)}${i.otherwise?` else ${tn(i.otherwise)}`:""}`;case"WhileStatement":return`while (${ct(i.condition)}) ${tn(i.body)}`;case"DoStatement":return`do ${tn(i.body)} while (${ct(i.condition)});`;case"ForStatement":return`for (...) ${tn(i.body)}`;case"ForEachStatement":return`for (${oe(i.type)} ${i.name} : ${ct(i.iterable)}) ${tn(i.body)}`;case"BreakStatement":return i.label?`break ${i.label};`:"break;";case"ContinueStatement":return i.label?`continue ${i.label};`:"continue;";case"EmptyStatement":return";";case"YieldStatement":return`yield ${ct(i.value)};`;default:return"..."}}function zn(i){switch(i.kind){case"int":case"byte":case"short":case"long":return String(i.value);case"double":return de(i.value);case"float":return Fe(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";case"string":return i.value}}function X(i){return{kind:"int",value:i|0}}function Gn(i){return{kind:"char",value:i&65535}}function _t(i){return{kind:"long",value:BigInt.asIntN(64,i)}}function Es(i){return{kind:"byte",value:i<<24>>24}}function As(i){return{kind:"short",value:i<<16>>16}}function pe(i){return{kind:"float",value:Math.fround(i)}}function ie(i){return{kind:"double",value:i}}function Tt(i){return{kind:"boolean",value:i}}function vr(i){return{kind:"string",value:i}}var wr=new Set(["int","byte","short","char"]);function kn(i){return wr.has(i.kind)?i.value:void 0}function Cn(i){if(i.kind==="long")return i.value;if(wr.has(i.kind))return BigInt(i.value)}function Kn(i){if(i.kind==="double"||i.kind==="float")return i.value;if(i.kind==="long")return Ss(At(i.value));if(wr.has(i.kind))return i.value}function Is(i){if(i.kind==="long")return yn(At(i.value));let t=Kn(i);return t===void 0?void 0:Math.fround(t)}function ua(i,t){if(i.kind==="boolean"||i.kind==="string")return;let e=()=>i.kind==="double"||i.kind==="float"?Fn(i.value):i.kind==="long"?bs(At(i.value)):i.value;switch(t){case"double":return ie(Kn(i));case"float":return pe(Is(i));case"long":return i.kind==="double"||i.kind==="float"?_t(BigInt(Dn(i.value))):_t(Cn(i));case"int":return X(e());case"byte":return Es(e());case"short":return As(e());case"char":return Gn(e())}}function qn(i){return i!==void 0&&i.kind==="boolean"&&i.value}function Os(i){return i!==void 0&&i.kind==="boolean"&&!i.value}var le=["none","message","message-cause","cause"],Yt=["none","message"],Go=[["java.lang.Throwable",null,le],["java.lang.Exception","java.lang.Throwable",le],["java.lang.Error","java.lang.Throwable",le],["java.lang.RuntimeException","java.lang.Exception",le],["java.lang.ArithmeticException","java.lang.RuntimeException",Yt],["java.lang.ArrayStoreException","java.lang.RuntimeException",Yt],["java.lang.ClassCastException","java.lang.RuntimeException",Yt],["java.lang.IllegalArgumentException","java.lang.RuntimeException",le],["java.lang.IllegalStateException","java.lang.RuntimeException",le],["java.lang.IndexOutOfBoundsException","java.lang.RuntimeException",["none","message","index"],"Index out of range: "],["java.lang.ArrayIndexOutOfBoundsException","java.lang.IndexOutOfBoundsException",["none","message","index"],"Array index out of range: "],["java.lang.StringIndexOutOfBoundsException","java.lang.IndexOutOfBoundsException",["none","message","index"],"String index out of range: "],["java.lang.NegativeArraySizeException","java.lang.RuntimeException",Yt],["java.lang.NullPointerException","java.lang.RuntimeException",Yt],["java.lang.NumberFormatException","java.lang.IllegalArgumentException",Yt],["java.lang.UnsupportedOperationException","java.lang.RuntimeException",le],["java.lang.CloneNotSupportedException","java.lang.Exception",Yt],["java.lang.InterruptedException","java.lang.Exception",Yt],["java.lang.ReflectiveOperationException","java.lang.Exception",le],["java.lang.ClassNotFoundException","java.lang.ReflectiveOperationException",["none","message","message-cause"]],["java.lang.AssertionError","java.lang.Error",["none","object"]],["java.lang.LinkageError","java.lang.Error",["none","message","message-cause"]],["java.lang.ExceptionInInitializerError","java.lang.LinkageError",Yt],["java.lang.NoClassDefFoundError","java.lang.LinkageError",Yt],["java.lang.VirtualMachineError","java.lang.Error",le],["java.lang.StackOverflowError","java.lang.VirtualMachineError",Yt],["java.lang.OutOfMemoryError","java.lang.VirtualMachineError",Yt],["java.util.NoSuchElementException","java.lang.RuntimeException",le],["java.util.InputMismatchException","java.util.NoSuchElementException",Yt],["java.util.ConcurrentModificationException","java.lang.RuntimeException",le],["java.util.EmptyStackException","java.lang.RuntimeException",["none"]],["java.util.IllegalFormatException","java.lang.IllegalArgumentException",[]],["java.util.MissingFormatArgumentException","java.util.IllegalFormatException",[]],["java.util.UnknownFormatConversionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatConversionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatPrecisionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatWidthException","java.util.IllegalFormatException",[]],["java.util.MissingFormatWidthException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatCodePointException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.FormatFlagsConversionMismatchException","java.util.IllegalFormatException",[]],["java.util.DuplicateFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.UnknownFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.regex.PatternSyntaxException","java.lang.IllegalArgumentException",[]],["java.time.DateTimeException","java.lang.RuntimeException",["message","message-cause"]],["java.time.format.DateTimeParseException","java.time.DateTimeException",[]],["java.time.temporal.UnsupportedTemporalTypeException","java.time.DateTimeException",["message","message-cause"]],["java.io.IOException","java.lang.Exception",le],["java.io.FileNotFoundException","java.io.IOException",Yt],["java.io.EOFException","java.io.IOException",Yt],["java.io.UncheckedIOException","java.lang.RuntimeException",["message-cause","cause"]]],En=Go.map(([i,t,e,n])=>({name:i,superclass:t,constructors:e,...n?{indexPrefix:n}:{}})),yt={message:0,cause:1,trace:2,suppressed:3,causeSet:4},ha=5;function da(i){let t=i.lastIndexOf(".");return{pkg:i.slice(0,t),simple:i.slice(t+1)}}var An=new Set(["Object","Integer","Long","Double","Float","Short","Byte","Character","Boolean","Number","Math","StrictMath","StringBuilder","StringBuffer","CharSequence","Iterable","Comparable","Thread","Runnable","Runtime","Process","Class","Enum","Record","Void","IO","Throwable","Exception","Error","RuntimeException","ArithmeticException","ArrayIndexOutOfBoundsException","IndexOutOfBoundsException","StringIndexOutOfBoundsException","NullPointerException","ClassCastException","IllegalArgumentException","IllegalStateException","NumberFormatException","UnsupportedOperationException","NegativeArraySizeException","StackOverflowError","OutOfMemoryError","AssertionError","InterruptedException","CloneNotSupportedException","Override","Deprecated","FunctionalInterface","SuppressWarnings","SafeVarargs","Cloneable","AutoCloseable","Appendable","Readable","ThreadLocal"]),Ko=new Set(["printf","format","flush","write","append","close","checkError","writeBytes","charset"]),ma=new Set(["currentTimeMillis","nanoTime","exit","arraycopy","getProperty","getProperties","setProperty","clearProperty","lineSeparator","identityHashCode","getenv","gc","setOut","setErr","setIn","console","inheritedChannel","getLogger","load","loadLibrary","mapLibraryName","runFinalization"]),qo=new Set(["substring","indexOf","lastIndexOf","isBlank","toUpperCase","toLowerCase","trim","strip","stripLeading","stripTrailing","split","contains","startsWith","endsWith","replace","replaceAll","replaceFirst","compareToIgnoreCase","equalsIgnoreCase","concat","chars","codePoints","format","formatted","valueOf","copyValueOf","join","repeat","matches","hashCode","intern","codePointAt","codePointBefore","codePointCount","offsetByCodePoints","getBytes","getChars","lines","indent","translateEscapes","stripIndent","transform","describeConstable","resolveConstantDesc","contentEquals","regionMatches","subSequence","toString","getClass","wait","notify","notifyAll","splitWithDelimiters"]),Wo=new Set(["name","ordinal","compareTo","equals","hashCode","getDeclaringClass"]),Xo=new Set(["clone","getClass","hashCode","equals","toString","wait","notify","notifyAll"]),Ls={Pattern:{UNIX_LINES:{type:V,constant:X(1)},CASE_INSENSITIVE:{type:V,constant:X(2)},COMMENTS:{type:V,constant:X(4)},MULTILINE:{type:V,constant:X(8)},LITERAL:{type:V,constant:X(16)},DOTALL:{type:V,constant:X(32)},UNICODE_CASE:{type:V,constant:X(64)},CANON_EQ:{type:V,constant:X(128)},UNICODE_CHARACTER_CLASS:{type:V,constant:X(256)}},Integer:{MAX_VALUE:{type:V,constant:X(2147483647)},MIN_VALUE:{type:V,constant:X(-2147483648)},SIZE:{type:V,constant:X(32)},BYTES:{type:V,constant:X(4)}},Long:{MAX_VALUE:{type:Jt,constant:_t(or)},MIN_VALUE:{type:Jt,constant:_t(lr)},SIZE:{type:V,constant:X(64)},BYTES:{type:V,constant:X(8)}},Double:{MAX_VALUE:{type:ft,constant:ie(Number.MAX_VALUE)},MIN_VALUE:{type:ft,constant:ie(Number.MIN_VALUE)},MIN_NORMAL:{type:ft,constant:ie(22250738585072014e-324)},POSITIVE_INFINITY:{type:ft,constant:ie(1/0)},NEGATIVE_INFINITY:{type:ft,constant:ie(-1/0)},NaN:{type:ft,constant:ie(NaN)},SIZE:{type:V,constant:X(64)},BYTES:{type:V,constant:X(8)}},Float:{MAX_VALUE:{type:kt,constant:pe(34028234663852886e22)},MIN_VALUE:{type:kt,constant:pe(1401298464324817e-60)},MIN_NORMAL:{type:kt,constant:pe(11754943508222875e-54)},POSITIVE_INFINITY:{type:kt,constant:pe(1/0)},NEGATIVE_INFINITY:{type:kt,constant:pe(-1/0)},NaN:{type:kt,constant:pe(NaN)},MAX_EXPONENT:{type:V,constant:X(127)},MIN_EXPONENT:{type:V,constant:X(-126)},SIZE:{type:V,constant:X(32)},BYTES:{type:V,constant:X(4)}},Byte:{MAX_VALUE:{type:_n,constant:Es(127)},MIN_VALUE:{type:_n,constant:Es(-128)},SIZE:{type:V,constant:X(8)},BYTES:{type:V,constant:X(1)}},Short:{MAX_VALUE:{type:xn,constant:As(32767)},MIN_VALUE:{type:xn,constant:As(-32768)},SIZE:{type:V,constant:X(16)},BYTES:{type:V,constant:X(2)}},Character:{MAX_VALUE:{type:Ce,constant:Gn(65535)},MIN_VALUE:{type:Ce,constant:Gn(0)},MIN_RADIX:{type:V,constant:X(2)},MAX_RADIX:{type:V,constant:X(36)},SIZE:{type:V,constant:X(16)},BYTES:{type:V,constant:X(2)}},Math:{PI:{type:ft,constant:ie(Math.PI)},E:{type:ft,constant:ie(Math.E)}},StreamTokenizer:{TT_EOF:{type:V,constant:X(-1)},TT_EOL:{type:V,constant:X(10)},TT_NUMBER:{type:V,constant:X(-2)},TT_WORD:{type:V,constant:X(-3)}}},Wn={abs:[{params:[V],returnType:V,fn:"abs-int"},{params:[Jt],returnType:Jt,fn:"abs-long"},{params:[kt],returnType:kt,fn:"abs-float"},{params:[ft],returnType:ft,fn:"abs-double"}],max:[{params:[V,V],returnType:V,fn:"max-int"},{params:[Jt,Jt],returnType:Jt,fn:"max-long"},{params:[kt,kt],returnType:kt,fn:"max-float"},{params:[ft,ft],returnType:ft,fn:"max-double"}],min:[{params:[V,V],returnType:V,fn:"min-int"},{params:[Jt,Jt],returnType:Jt,fn:"min-long"},{params:[kt,kt],returnType:kt,fn:"min-float"},{params:[ft,ft],returnType:ft,fn:"min-double"}],sqrt:[{params:[ft],returnType:ft,fn:"sqrt"}],floor:[{params:[ft],returnType:ft,fn:"floor"}],ceil:[{params:[ft],returnType:ft,fn:"ceil"}],round:[{params:[kt],returnType:V,fn:"round-float"},{params:[ft],returnType:Jt,fn:"round-double"}]},fa=i=>i.target?.kind==="Name"&&i.target.staticOwner===!0,Xn=i=>i.tag==="int"||i.tag==="char"||i.tag==="long"||i.tag==="byte"||i.tag==="short",pa=i=>i.tag==="char"||i.tag==="byte"||i.tag==="short"?V:i;function ns(i,t){return i.tag==="double"||t.tag==="double"?ft:i.tag==="float"||t.tag==="float"?kt:i.tag==="long"||t.tag==="long"?Jt:V}var Ns=new Set(["java.lang","java.util","java.io","java.math","java.net","java.nio","java.nio.file","java.nio.charset","java.text","java.time","java.time.format","java.time.temporal","java.util.function","java.util.stream","java.util.concurrent","java.util.concurrent.atomic","java.util.regex","java.lang.reflect","java.security","java.awt","javax.swing"]),Ma=new Set(["LinkedList","TreeMap","TreeSet","LinkedHashMap","LinkedHashSet","Stack","Optional","OptionalInt","Date","Calendar","Locale","UUID","NoSuchElementException","ConcurrentModificationException","SortedMap","SortedSet","NavigableMap","NavigableSet","AbstractMap","EnumMap","EnumSet","IdentityHashMap","WeakHashMap","Properties","Timer","Formatter","Currency","InputMismatchException","Spliterator","IntSummaryStatistics","Base64","Map.Entry","Entry","EventListener","Observable","SequencedCollection"]),Yn={"java.util":[...Ma].filter(i=>!i.includes(".")),"java.io":["PrintStream","InputStream","File","FileReader","FileWriter","FileInputStream","FileOutputStream","DataInputStream","DataOutputStream","BufferedInputStream","BufferedOutputStream","ByteArrayInputStream","ByteArrayOutputStream","Serializable","Closeable","Flushable","Console"],"java.math":["BigInteger","BigDecimal","RoundingMode","MathContext"],"java.time":["Year","YearMonth","Clock"],"java.time.format":["TextStyle","FormatStyle"],"java.time.temporal":["TemporalAdjusters","TemporalUnit","Temporal"],"java.text":["DecimalFormat","NumberFormat","SimpleDateFormat","MessageFormat"],"java.util.regex":["PatternSyntaxException"],"java.util.concurrent":["ConcurrentHashMap","CopyOnWriteArrayList","ExecutorService","Executors","TimeUnit","Future","CompletableFuture","ThreadLocalRandom","CountDownLatch","ConcurrentLinkedQueue","LinkedBlockingQueue","ArrayBlockingQueue"],"java.util.concurrent.atomic":["AtomicInteger","AtomicLong","AtomicBoolean","AtomicReference"],"java.nio.file":["Files","Path","Paths"]},ya={private:0,package:1,protected:2,public:3},Yo={Comparable:["compareTo"],Comparator:["compare"],Iterable:["iterator"],Iterator:["hasNext","next"]},ga=new Set(["ArrayList","LinkedList","HashMap","LinkedHashMap","TreeMap","HashSet","LinkedHashSet","TreeSet","ArrayDeque","PriorityQueue","AbstractList"]),Qo={ArrayList:["add(E)","get(int)","size()"],HashMap:["put(K,V)","get(Object)","containsKey(Object)","remove(Object)"],LinkedHashMap:["put(K,V)","get(Object)","containsKey(Object)","remove(Object)","removeEldestEntry(Entry)"],TreeMap:["get(Object)","containsKey(Object)"],AbstractList:["get(int)","size()","add(int,E)","set(int,E)","remove(int)","add(E)"]},Zo={"ArrayDeque.<init>(Collection)":["size()"],"ArrayList.<init>(Collection)":[],"Collections.addAll(Collection,T[])":["add(E)"],"Collections.binarySearch(List,T)":["size()","get(int)"],"Collections.binarySearch(List,T,Comparator)":["size()","get(int)"],"Collections.disjoint(Collection,Collection)":["size()"],"Collections.fill(List,T)":["size()"],"Collections.frequency(Collection,Object)":[],"Collections.max(Collection)":[],"Collections.max(Collection,Comparator)":[],"Collections.min(Collection)":[],"Collections.min(Collection,Comparator)":[],"Collections.reverse(List)":["size()","get(int)"],"Collections.shuffle(List)":["size()","get(int)"],"Collections.shuffle(List,Random)":["size()","get(int)"],"Collections.sort(List)":[],"Collections.sort(List,Comparator)":[],"Collections.swap(List,int,int)":["get(int)"],"Collections.unmodifiableCollection(Collection)":["*"],"Collections.unmodifiableList(List)":["*"],"Collections.unmodifiableMap(Map)":["*"],"Collections.unmodifiableSet(Set)":["*"],"HashMap.<init>(Map)":["size()"],"HashSet.<init>(Collection)":["size()"],"LinkedHashMap.<init>(Map)":["size()"],"LinkedHashSet.<init>(Collection)":["size()"],"LinkedList.<init>(Collection)":[],"List.copyOf(Collection)":[],"Map.copyOf(Map)":[],"PriorityQueue.<init>(Collection)":[],"Set.copyOf(Collection)":["size()"],"String.join(CharSequence,Iterable)":[],"TreeMap.<init>(Map)":["size()"],"TreeMap.<init>(SortedMap)":["size()"],"TreeSet.<init>(Collection)":["size()"],"TreeSet.<init>(SortedSet)":["size()"],"addAll(Collection)":["size()"],"containsAll(Collection)":[],"putAll(Map)":["size()"],"removeAll(Collection)":["size()"],"retainAll(Collection)":[],"equals(Object)":["size()","get(Object)","containsKey(Object)"]},tl=["size()","get(int)","get(Object)","containsKey(Object)"],el={"java.util.regex.PatternSyntaxException":["getDescription","getIndex","getPattern"],"java.time.format.DateTimeParseException":["getParsedString","getErrorIndex"]},ba=new Set(["toString()","equals(Object)","hashCode()"]),nl=new Set(["Comparable","Comparator","Iterable","Iterator"]);function Sa(i){return nl.has(i.name)||i.functional!==void 0}var $s=new Set(["getClass","wait","notify","notifyAll","clone","finalize"]),kr=/^incompatible types: (bad return type in lambda expression|unexpected return value|lambda body is not compatible with a void functional interface|missing return value)/,en=i=>i.length?i.map($).join(","):"no arguments";function Ra(i,t,e){if(!nt(i)){let n=e?qt(i):null;return n!==null&&Ra(n,t,!1)}return!t||t.tag==="object"?!0:i.tag==="array"?!1:t.tag==="library"&&t.symbol.isInterface||i.tag==="library"&&i.symbol.isInterface||i.tag==="class"&&i.symbol.isInterface?!0:K(W(i),W(t))||K(W(t),W(i))}function sl(i,t){let e=[];for(let o=0;o<i.length;){let c=o;for(;c<i.length&&i[c].owner===i[o].owner;)c++;e.push(...i.slice(o,c).reverse()),o=c}let n=(o,c)=>t(o,c)&&!t(c,o),s=e[0],r=null;for(let o of e.slice(1)){if(!r){n(o,s)?s=o:t(s,o)||(r=[s,o]);continue}r.every(c=>n(o,c))?(s=o,r=null):r.every(c=>n(c,o))||r.unshift(o)}let a=(r??i.slice(0,2)).slice().reverse();return[a[0],a[1]]}var Ta=[gt,Ce,V,Jt,kt,ft,ee(Ce),mt,G];function rl(i){return(i==="println"?[[],...Ta.map(e=>[e])]:Ta.map(e=>[e])).map(e=>({owner:"PrintStream",name:i,params:e,returnType:xt}))}var Qn={length:{owner:"String",name:"length",params:[],returnType:V},charAt:{owner:"String",name:"charAt",params:[V],returnType:Ce},equals:{owner:"String",name:"equals",params:[G],returnType:gt},isEmpty:{owner:"String",name:"isEmpty",params:[],returnType:gt},toCharArray:{owner:"String",name:"toCharArray",params:[],returnType:ee(Ce)},compareTo:{owner:"String",name:"compareTo",params:[mt],returnType:V}},$e={toString:{owner:"Object",name:"toString",params:[],returnType:mt,objectMethod:"toString"},hashCode:{owner:"Object",name:"hashCode",params:[],returnType:V,objectMethod:"hashCode"},equals:{owner:"Object",name:"equals",params:[G],returnType:gt,objectMethod:"equals"}},Cr=()=>({all:!1,vars:new Set,unassigned:new Set}),Qt=()=>({all:!0,vars:new Set,unassigned:new Set}),ze=i=>({all:i.all,vars:new Set(i.vars),unassigned:new Set(i.unassigned)});function Ct(i,...t){let e=i;for(let n of t){if(e.all){e=ze(n);continue}if(n.all)continue;let s=new Set;for(let a of e.vars)n.vars.has(a)&&s.add(a);let r=new Set;for(let a of e.unassigned)n.unassigned.has(a)&&r.add(a);e={all:!1,vars:s,unassigned:r}}return e}function il(i,t){if(i.all||t.all)return i.all?ze(t.all?i:t):ze(i);let e=new Set;for(let n of i.unassigned)t.unassigned.has(n)&&e.add(n);return{all:!1,vars:new Set([...i.vars,...t.vars]),unassigned:e}}function In(i,t){return i.all||i.vars.has(t)}function Zn(i,t){return i.all||i.unassigned.has(t)}function Pe(i,t){if(i.all)return i;let e=ze(i);return e.vars.add(t),e.unassigned.delete(t),e}function al(i,t){if(i.all)return i;let e=ze(i);return e.vars.delete(t),e}function xa(i){return i.kind==="LocalVariableDeclaration"?i.declarators[0].pos:i.start}function Q(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}var jt=(i,t)=>i.keywords.some(e=>e.name===t),is=class extends Error{fileName;header;constructor(t,e=!1){super(`needs ${t}`),this.fileName=t,this.header=e}},He=class extends Error{};function Ja(i,t,e={}){let n=e.root??"",s=new Set;for(let r of e.files??[]){if(!r.endsWith(".java")||!r.startsWith(n))continue;let a=r.slice(n.length).split("/").slice(0,-1);a.length&&s.add(a.join("."))}return new Ir(i[0].file,t,e.available??new Set,n,s,e.deferred??new Set).checkUnits(i,e.launch??!0)}var va=(i,t,e)=>({file:i,launch:t,compact:e,pkg:"",programImports:new Map,programOnDemand:[],onDemandOrder:[],programStatic:[],ambiguousImports:new Map,imported:new Set,onDemand:new Set,staticSingle:new Map,staticOnDemand:[],unsupportedStaticSingle:new Map,unsupportedStaticOnDemand:[],unsupportedImports:new Map}),Ir=class{#d;#z=new WeakMap;#It;#rt;#G;#Ot=new Set;#O;#R=!0;#bt=0;#m;#C=[];#W=[];#V=[];get#ut(){return this.#d.file}get#X(){return this.#d.imported}get#r(){return this.#d.onDemand}get#p(){return this.#d.staticSingle}get#s(){return this.#d.staticOnDemand}get#n(){return this.#d.unsupportedStaticSingle}get#S(){return this.#d.unsupportedStaticOnDemand}get#l(){return this.#d.unsupportedImports}#i=[];#D=new Map;#kt=new Map;#E=[];#Y=!1;#A=0;#Q=!1;#u=null;#x;#I=[];#Ct=new Map;#me;get#o(){return this.#me}set#o(t){this.#me=t;let e=t?this.#z.get(t.topLevel):void 0;e&&(this.#d=e)}#b=null;#it=null;#St=null;#$=new Map;#t=!0;#f=[];#c=0;#y=[];#P=!1;#g=!1;#J=null;#ht="";#H=new Map;#Lt=[];#gt=[];#Tt=[];#ee=new Map;#j=[];#st=new Set;#L=new WeakMap;#ne=[];#N=new Map;#Et=new Map;#B=[];#dt=[];#K=new Map;#M=new Map;#Z=0;#F=[];constructor(t,e,n,s="",r=new Set,a=new Set){this.#d=va(t,!0,!1),this.#O=a,this.#It=n,this.#rt=s,this.#G=r,this.#m=e}#e(t,e,n,s){this.#m.error(this.#ut,t,"type",e,n,s)}#at(t,e,n,s){let r=a=>a!==void 0&&a.has(e);for(let a=this.#o??null;a;a=a.outer)if(r(a.suppressed))return;r(this.#x)||this.#I.some(r)||this.#m.warning(this.#ut,t,e,`[${e}] ${n}`,s)}#At(t,e){let n=this.#Ct.get(t);if(n)return n;let s=new Set;this.#Ct.set(t,s);let r=new Set,a={Override:["method"],FunctionalInterface:["type"],SafeVarargs:["method","constructor"],SuppressWarnings:["type","field","method","parameter","constructor","local"],Deprecated:["type","field","method","parameter","constructor","local"]};for(let o of t.annotations??[]){if(!(Object.hasOwn(a,o.name)&&(o.names.length===1?!this.#Gt(o.name):o.names.join(".")===`java.lang.${o.name}`))){o.names.length===1&&!this.#Gt(o.name)&&!An.has(o.name)&&!this.#l.has(o.name)?this.#e(o.namePos,w.cantResolve,"cannot find symbol",[` symbol: class ${o.name}`,` location: class ${this.#o.displayName}`]):this.#a(o.pos,`the annotation @${o.names.join(".")}`,!0);continue}if(r.has(o.name)){this.#e(o.pos,w.syntax,`${o.name} is not a repeatable annotation interface`);continue}if(r.add(o.name),!a[o.name].includes(e)){this.#e(o.pos,w.syntax,"annotation interface not applicable to this kind of declaration");continue}let u=o.args??[];if(o.name==="SuppressWarnings"){let d=u.find(h=>h.name===null||h.name==="value");if(!d||u.some(h=>h!==d)){d?this.#a(o.pos,"elements of @SuppressWarnings other than value"):this.#e(o.pos,w.syntax,"annotation @SuppressWarnings is missing a default value for the element \'value\'");continue}for(let h of d.value.kind==="ElementArray"?d.value.elements:[d.value])h.kind==="Literal"&&(h.literalKind==="string"||h.literalKind==="text-block")?s.add(h.value):h.kind==="Literal"?this.#e(h.pos,w.incompatibleTypes,`incompatible types: ${h.literalKind} cannot be converted to String`):this.#a(h.pos,"@SuppressWarnings values other than string literals")}else o.name==="Deprecated"?u.every(h=>h.name==="since"&&h.value.kind==="Literal"&&h.value.literalKind==="string"||h.name==="forRemoval"&&h.value.kind==="Literal"&&h.value.literalKind==="boolean")||this.#a(o.pos,"these elements of @Deprecated"):u.length&&this.#a(o.pos,`elements of @${o.name}`)}return s}#Jt(t,e){return t.annotations?.find(n=>n.name===e)}#a(t,e,n=!1){this.#e(t,w.unsupported,`${e} ${n?"is":"are"} not supported in this version`)}checkUnits(t,e=!0){let n=t[0].unit;if(this.#Ot=new Set(t.map(h=>h.file.name)),!n.types.length)return this.#m.launchError(this.#ut.name,w.noMain,"no class declared in source file"),null;let s=this.#d,r=[];t.forEach(({unit:h,file:m},p)=>{let k=h.types[0]?.implicit===!0,g=p===0?s:va(m,!1,k);if(g.compact=k,this.#d=g,h.package&&(k?this.#e(h.package.start,w.syntax,"compact source file should not have package declaration"):g.pkg=h.package.names.join(".")),p>0){let T=m.name.slice(this.#rt.length).split("/").slice(0,-1).join(".");if(g.pkg!==T)throw new He(g.pkg?`${m.name} declares package ${g.pkg}, but its folder makes it ${T?`package ${T}`:"the unnamed package"}`:`${m.name} declares no package, but it is in package ${T}\'s folder`)}p>0&&k&&r.push({declaration:h.types[0],file:m});for(let T of h.imports)this.#ot(T);if(k)for(let T of Object.keys(Yn))this.#Vt(T);let O=this.#W.length;for(let T of h.types)this.#jt(T,null);for(let T of this.#W.slice(O))T.file=m,this.#z.set(T,g);if(p>0&&!k){let T=m.name.replace(/^.*\\//,"").replace(/\\.java$/,"");if(!this.#W.slice(O).some(x=>x.name===T))throw new He(`${m.name} does not declare class ${T}, so the launcher cannot find that class there`)}}),this.#d=s;for(let{file:h}of t){let m=this.#W.map(p=>this.#z.get(p)).find(p=>p?.file===h);m&&this.#Ws(m)}this.#d=s,this.#xe();for(let h of this.#C)!h.typeParams||h.local||(this.#o=h,this.#Y=!1,this.#wn(h.typeParams,h.declaration.typeParams));let a=h=>h.anonymous===!0||h.local===!0||h.outer!==null&&a(h.outer);for(let h of this.#C)a(h)||this.#ve(h);this.#Qe(this.#C.filter(h=>!a(h)));for(let h of this.#C)a(h)||this.#le(h);for(let{file:h}of t){let m=this.#W.map(p=>this.#z.get(p)).find(p=>p?.file===h);m?.programStatic.length&&this.#re(m)}this.#d=s,this.#nn();let o=this.#W[0];for(let{declaration:h,file:m}of r){let p=h.symbol;if(this.#o=p,!this.#se(p))return this.#e(h.members[0].start,w.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;throw new He(`${m.name} is a compact source file; only the launched file may be one`)}if(o&&(this.#o=o),o?.declaration.implicit&&!this.#se(o))return this.#e(o.declaration.members[0].start,w.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;this.#R=!1,this.#bt=this.#m.items.length;let c=h=>this.#m.items.some((m,p)=>m.severity==="error"&&(h===null?p<this.#bt||!this.#O.has(m.file):p>=this.#bt&&m.file===h));for(let h of this.#W){this.#He(h);let m=h.file?.name??"";c(this.#O.has(m)?m:null)||this.#ui(h)}let u=new Set;if(this.#m.items.forEach((h,m)=>{m<this.#bt||!this.#O.has(h.file)||(h.deferred=!0,h.severity==="error"&&u.add(h.file))}),c(null)||!o)return null;let d=e?this.#Re(o):{classes:this.#C,mainClass:o,methods:this.#V,staticFields:this.#i,selectors:this.#kt,main:null,mainConstructor:null};return d&&u.size&&(d.failedFiles=[...u]),d}#Re(t){let e=this.#ut.name.replace(/^.*[\\\\/]/,"").replace(/\\.java$/,""),n=this.#se(t)?t:this.#W.find(a=>a.name===e&&a.file===t.file);if(!n)return this.#m.launchError(this.#ut.name,w.noMain,`can\'t find class: ${e}`),null;let s=this.#se(n);if(!s)return this.#m.launchError(this.#ut.name,w.noMain,`can\'t find main(String[]) or main() method in class: ${n.name}`),null;let r=null;return!s.isStatic&&(r=n.constructors.find(a=>a.params.length===0)??null,!r)?(this.#m.launchError(this.#ut.name,w.noMain,`can\'t find no argument constructor in class: ${n.name}`),null):{classes:this.#C,mainClass:n,methods:this.#V,staticFields:this.#i,selectors:this.#kt,main:s,mainConstructor:r}}#se(t){let e=t.methods.filter(n=>this.#xt(n.declaration));return e.find(n=>n.params.length===1)??e.find(n=>n.params.length===0)??null}#xt(t){if(t.isConstructor||t.name!=="main"||t.returnType.kind!=="VoidType"||jt(t.modifiers,"private"))return!1;if(t.params.length===0)return!0;if(t.params.length!==1)return!1;let e=t.params[0].type;return e.kind==="ArrayType"&&this.#Ut(e.element)}#Ut(t){if(t.kind!=="ClassType"||t.hasTypeArguments)return!1;let e=t.names.join(".");return e==="String"||e==="java.lang.String"}#ot(t){if(t.isStatic)return this.#Bt(t);let e=t.names,n=t.onDemand?e.join("."):e.slice(0,-1).join("."),s=e[e.length-1];if(t.onDemand&&!this.#d.onDemandOrder.includes(n)&&this.#d.onDemandOrder.push(n),t.onDemand&&this.#G.has(n)){this.#d.programOnDemand.includes(n)||this.#d.programOnDemand.push(n);return}let r=t.onDemand?e.length>1?t.dots[e.length-2]:t.firstPos:t.lastDotPos,a=this.#in(t.onDemand?[...e,"*"]:e);if(a){if(t.onDemand){this.#Dt(e.slice(0,a).join("."),e[a])?this.#a(t.start,"on-demand imports of a class\'s member types"):this.#e(r,w.cantResolve,`package ${n} does not exist`);return}let u=e.slice(0,a).join("."),d={pkg:u,names:e.slice(a),pos:t.lastDotPos,start:t.start};if(!(this.#Ot.has(`${this.#rt}${u.replaceAll(".","/")}/${e[a]}.java`)||this.#Dt(u,e[a]))){this.#e(t.dots[a-1]??t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${e[a]}`,` location: package ${u}`]);return}let p=this.#d.programImports.get(s);if(p&&(p.pkg!==d.pkg||p.names.join(".")!==d.names.join("."))){this.#e(t.start,w.alreadyDefined,`a type with the same simple name is already defined by the single-type-import of ${s}`),this.#d.ambiguousImports.set(s,[[p.pkg,...p.names].join("."),e.join(".")]);return}this.#d.programImports.set(s,d);return}let o=t.onDemand?e[e.length-1]:e[e.length-2],c=e.slice(0,t.onDemand?-1:-2).join(".");if(It[o]===c&&!Mt[o]){for(let[u,d]of Object.entries(Mt))d===o&&(t.onDemand||u===s)&&this.#X.add(u);if(t.onDemand||Mt[s]===o)return}if(!Ns.has(n)){this.#e(r,w.cantResolve,`package ${n} does not exist`);return}if(t.onDemand){this.#r.add(n),this.#Vt(n);return}if(It[s]===n&&!Mt[s]||En.some(u=>u.name===`${n}.${s}`)){this.#X.add(s);return}if(n==="java.util"&&!Ma.has(s)){this.#e(t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: package ${n}`]);return}this.#l.set(s,`${n}.${s}`)}#Bt(t){let e=t.names,n=t.onDemand?e:e.slice(0,-1),s=this.#in([...n,""]);if(s){let c=n.slice(0,s).join("."),u=this.#Ot.has(`${this.#rt}${c.replaceAll(".","/")}/${n[s]}.java`);if(s===n.length||!u&&!this.#Dt(c,n[s])){this.#e(t.dots[s-1]??t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${n[s]??e[e.length-1]}`,` location: package ${c}`]);return}this.#d.programStatic.push({pkg:c,names:n.slice(s),member:t.onDemand?null:e[e.length-1],pos:t.dots[n.length-1]??t.lastDotPos,start:t.start});return}let r=this.#Kt(t,n);if(typeof r=="object"&&r!==null){t.onDemand?this.#S.push(r.unsupported):this.#n.set(e[e.length-1],r.unsupported);return}if(r===null){t.onDemand||this.#e(t.start,w.cantResolve,"static import only from classes and interfaces");return}if(t.onDemand){this.#s.includes(r)||this.#s.push(r);for(let[c,u]of Object.entries(Mt))u===r&&this.#X.add(c);return}let a=e[e.length-1],o=Mt[a]===r;if(o&&this.#X.add(a),this.#tt(r,a)||this.#Nt(r,a)){let c=this.#p.get(a)??[];c.includes(r)||c.push(r),this.#p.set(a,c)}else if(!o){let c=this.#et(r)?.isInterface?"interface":"class";this.#e(t.start,w.cantResolve,"cannot find symbol",[` symbol: static ${a}`,` location: ${c} ${r}`])}}#Kt(t,e){let n=e[e.length-1],s=e.slice(0,-1).join("."),r=t.dots[e.length-2]??t.start,a=e[e.length-2];return a&&Mt[n]===a&&It[a]===e.slice(0,-2).join(".")||s==="java.lang"&&(n==="Math"||n==="System"||n==="String")||It[n]===s&&!Mt[n]?n:Ns.has(s)&&((s==="java.lang"?An.has(n):(Yn[s]??[]).includes(n))||En.some(c=>c.name===`${s}.${n}`))?{unsupported:`${s}.${n}`}:(Ns.has(s)||[...Ns].some(o=>o.startsWith(`${s}.`))?this.#e(r,w.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: package ${s}`]):this.#e(r,w.cantResolve,`package ${s} does not exist`),null)}#et(t){return t==="Math"||t==="String"||t==="System"?te(t):Wt(t)??null}#tt(t,e){if(t==="Math"&&Object.hasOwn(Wn,e))return!0;if(t==="System")return ma.has(e);let n=this.#et(t);return n?n.methods.some(s=>s.isStatic&&s.name===e)||t!=="String"&&n.unsupported.has(e):!1}#Nt(t,e){if(t==="System")return e==="out"||e==="err"||e==="in";if(Object.hasOwn(Ls,t)&&Object.hasOwn(Ls[t],e))return!0;if(t==="Math"||t==="String")return!1;let n=this.#et(t)?.staticFields;return n!==void 0&&Object.hasOwn(n,e)}#h(t,e){let n=(this.#p.get(t)??[]).filter(s=>e.call(this,s,t));return n.length?n:this.#s.filter(s=>e.call(this,s,t))}#fe(t,e){let n=this.#n.get(t)??this.#S[0];return n?(this.#a(e,`the class ${n}`,!0),!0):!1}#pe(t){for(let e=this.#o;e;e=e.outer)if(this.#wt(e,t).length)return!0;return Object.hasOwn($e,t)||$s.has(t)}#vt(t,e){return typeof t!="string"?{kind:"Name",identifier:t.name,depth:1,pos:e.pos,start:e.start,end:e.end,staticOwner:!0,staticClass:t}:{kind:"Name",identifier:t,depth:1,pos:e.pos,start:e.start,end:e.end,staticOwner:!0}}#ye(t,e){let n=a=>e==="method"?this.#wt(a,t).some(o=>o.isStatic):this.#Ee(a,t)?.isStatic===!0,s=a=>{let o=[];for(let c of this.#d.programStatic){if(c.member!==null!==a||a&&c.member!==t)continue;let u=this.#rn(c);u&&n(u)&&!o.includes(u)&&o.push(u)}return o},r=s(!0);return r.length?r:s(!1)}#re(t){this.#d=t;for(let e of t.programStatic){let n=this.#rn(e);if(!n)continue;if(n.topLevel.packageName!==t.pkg&&!n.topLevel.isPublic){this.#e(e.pos,w.cantResolve,`${n.topLevel.name} is not public in ${n.topLevel.packageName}; cannot be accessed from outside package`);continue}if(e.member===null)continue;this.#wt(n,e.member).some(r=>r.isStatic)||this.#Ee(n,e.member)?.isStatic===!0||n.membersByName.has(e.member)||this.#e(e.start,w.cantResolve,"cannot find symbol",[` symbol: static ${e.member}`,` location: ${n.isInterface?"interface":"class"} ${n.displayName}`])}}#ie(t,e){if(this.#pe(t.name))return!0;let n=this.#ye(t.name,"method");if(n.length)return t.target=this.#vt(n[0],{pos:t.selectPos,start:t.start,end:t.start}),!0;let s=this.#h(t.name,this.#tt);if(s.length>1){let r=this.#ge(t,s,e);if(!r)return!1;s=[r]}return s.length===1&&(t.target=this.#vt(s[0],{pos:t.selectPos,start:t.start,end:t.start})),!0}#ge(t,e,n){let s=e.flatMap(d=>this.#qt(d,t.name).map(h=>({owner:d,...h}))),r=s.filter(d=>this.#w(d,n,!0)),a=r.length?r:s.filter(d=>this.#w(d,n,!1));if(!a.length)return e.find(d=>this.#qt(d,t.name).some(h=>h.params.length===n.length))??e[0];let o=(d,h)=>d.params.length===h.params.length&&d.params.every((m,p)=>Ze(W(h.params[p]),W(m))),c=a.filter(d=>a.every(h=>d===h||o(d,h))),u=[...new Set(c.map(d=>d.owner))];if(u.length===1)return u[0];if(c.length>=2&&!c.some(d=>d.varargs)){let[d,h]=c,m=p=>`method ${t.name}(${p.params.map($).join(",")}) in ${p.owner}`;return this.#e(t.selectPos,w.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${m(d)} and ${m(h)} match`]),null}return this.#a(t.selectPos,`a call of ${t.name}(), which more than one static import could mean`,!0),null}#qt(t,e){let n=[];if(t==="Math"&&Object.hasOwn(Wn,e))for(let r of Wn[e])n.push({params:r.params,varargs:!1});let s=t==="System"?null:this.#et(t);for(let r of s?.methods??[])r.isStatic&&r.name===e&&n.push({params:r.params,varargs:r.varargs===!0});return n}#w(t,e,n=!1){let{params:s,varargs:r}=t;if(n&&r&&e.length!==s.length)return!1;let a=r?s.length-1:s.length;return(r?e.length<a:e.length!==a)?!1:e.every((o,c)=>{if(o.tag==="lambda"||o.tag==="diamond")return!0;let u=c<a||r&&e.length===s.length&&o.tag==="array"?s[c]:s[a].element;return n?Ze(W(u),o):Ht(W(u),o)})}#be(t){let e=this.#ye(t.identifier,"field");if(e.length)return{kind:"FieldAccess",target:this.#vt(e[0],t),name:t.identifier,namePos:t.pos,depth:2,pos:t.pos,start:t.start,end:t.end};let n=this.#h(t.identifier,this.#Nt);return n.length?n.length>1?(this.#e(t.pos,w.cantResolve,`reference to ${t.identifier} is ambiguous`,[` both variable ${t.identifier} in ${n[1]} and variable ${t.identifier} in ${n[0]} match`]),"error"):{kind:"FieldAccess",target:this.#vt(n[0],t),name:t.identifier,namePos:t.pos,depth:2,pos:t.pos,start:t.start,end:t.end}:null}#Vt(t){for(let e of Yn[t]??[])It[e]||En.some(n=>n.name===`${t}.${e}`)||this.#l.has(e)||this.#l.set(e,`${t}.${e}`)}#mt(t){let e;if(t.length===1){e=t[0];let n=It[e];if(!n||!(Mt[e]?this.#X.has(e):n==="java.lang"||this.#X.has(e)||this.#r.has(n)||this.#d.compact))return null}else if(t.length>=3&&t[0]==="java"&&It[t[t.length-1]]===t.slice(0,-1).join(".")&&!Mt[t[t.length-1]])e=t[t.length-1];else if(t.length===2&&Mt[t[1]]===t[0]&&this.#mt([t[0]]))e=t[1];else if(t.length===4&&t[0]==="java"&&Mt[t[3]]===t[2]&&It[t[2]]===`java.${t[1]}`)e=t[3];else return null;return Wt(e)??null}#jt(t,e){let n=t.modifiers,s=t.keyword==="interface",r=t.keyword==="enum",a=t.keyword==="record";for(let u of n.keywords)if(u.name!=="public"&&!(u.name==="abstract"&&!r&&!a)&&!(u.name==="final"&&!s&&!r)){if(u.name==="sealed"||u.name==="non-sealed"){if(!r&&!a)continue;this.#e(u.pos,w.syntax,`\'${u.name}\' is not allowed here`);continue}e&&["private","protected","static"].includes(u.name)||(u.name==="strictfp"?this.#a(u.pos,`\'strictfp\' ${s?"interfaces":"classes"}`):this.#e(t.keywordPos,w.syntax,`modifier ${u.name} not allowed here`))}if(e){if(e.membersByName.has(t.name)){this.#e(t.keywordPos,w.alreadyDefined,`class ${t.name} is already defined in class ${e.displayName}`);return}}else if(this.#W.some(u=>u.name===t.name&&u.packageName===this.#d.pkg)){this.#e(t.keywordPos,w.alreadyDefined,`duplicate class: ${this.#d.pkg?`${this.#d.pkg}.`:""}${t.name}`);return}let o=e?e.packageName:this.#d.pkg,c={kind:"class",name:t.name,binaryName:e?`${e.binaryName}$${t.name}`:o?`${o}.${t.name}`:t.name,packageName:o,isPublic:jt(n,"public")||e?.isInterface===!0,displayName:e?.topLevel.declaration.implicit?`${e.displayName}.${t.name}`:t.name,declaration:t,outer:e,topLevel:null,isInner:e!==null&&t.keyword==="class"&&!e.isInterface&&!jt(n,"static"),isPrivate:jt(n,"private"),isInterface:s,isAbstract:s||jt(n,"abstract"),isFinal:r&&!t.enumConstants?.some(u=>u.body)||a||jt(n,"final"),...jt(n,"sealed")?{isSealed:!0}:{},...jt(n,"non-sealed")?{isNonSealed:!0}:{},isEnum:r,isRecord:a,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:0,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1};if(c.topLevel=e?e.topLevel:c,t.typeParams?.length){let u=a?"record":s?"interface":"class";c.typeParams=this.#vn(t.typeParams,`${u} ${c.displayName}`,c)}t.symbol=c,this.#C.push(c),e?(e.members.push(c),e.membersByName.set(c.name,c)):this.#W.push(c);for(let u of t.members)u.kind==="ClassDeclaration"&&this.#jt(u,c);this.#Se(c)}#Se(t){let e=[],n=0,s=new Map,r=(a,o)=>{if(Array.isArray(a)){for(let u of a)r(u,o);return}if(a===null||typeof a!="object")return;let c=a;if(c.kind!=="ClassDeclaration"){if(c.kind==="NewObject"&&c.body){r(c.args,o);let u=c.body,d=this.#ae(t,u,++n,o);e.push(d);return}if(c.kind==="LocalClass"){let u=c.declaration,d=(s.get(u.name)??0)+1;s.set(u.name,d),e.push(this.#Te(t,u,d,o));return}for(let[u,d]of Object.entries(c))u!=="symbol"&&d&&typeof d=="object"&&r(d,o)}};for(let a of t.declaration.enumConstants??[])if(r(a.args,!0),a.body){let o=this.#ae(t,a.body,++n,!0);o.enumBody=!0,e.push(o)}for(let a of t.declaration.members){if(a.kind==="ClassDeclaration")continue;let o=jt(a.modifiers,"static")||t.isInterface&&a.kind==="FieldDeclaration";r(a,o)}e.length&&(t.anonymousClasses=e)}#Te(t,e,n,s){let r=e.keyword;for(let c of e.modifiers.keywords)c.name!=="abstract"&&c.name!=="final"&&c.name!=="strictfp"&&this.#e(e.keywordPos,w.syntax,`modifier ${c.name} not allowed here`);let a=this.#ae(t,e,0,s||r!=="class"),o=`${t.binaryName}$${n}${e.name}`;return Object.assign(a,{name:e.name,binaryName:o,displayName:e.name,anonymous:!1,local:!0,isInterface:r==="interface",isEnum:r==="enum",isRecord:r==="record",isAbstract:r==="interface"||jt(e.modifiers,"abstract"),isFinal:r==="enum"||r==="record"||jt(e.modifiers,"final")}),e.typeParams?.length&&(a.typeParams=this.#vn(e.typeParams,`${r==="record"?"record":r==="interface"?"interface":"class"} ${e.name}`,a)),a}#ae(t,e,n,s){let r=`${t.binaryName}$${n}`,a={kind:"class",name:"",binaryName:r,displayName:`<anonymous ${r}>`,packageName:t.packageName,isPublic:!1,declaration:e,outer:t,topLevel:t.topLevel,isInner:!s,isPrivate:!1,isInterface:!1,isAbstract:!1,isFinal:!1,isEnum:!1,isRecord:!1,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:0,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1,anonymous:!0};e.symbol=a,this.#C.push(a);for(let o of e.members)o.kind==="ClassDeclaration"&&this.#jt(o,a);return this.#Se(a),a}#xe(){let t=(o,c)=>{let{pkg:u,simple:d}=da(o),h={kind:"ClassDeclaration",keyword:c?"interface":"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:d,namePos:0,keywordPos:0,members:[],pos:0,start:0,end:0},m={kind:"class",name:d,binaryName:o,displayName:d,packageName:o.slice(0,o.lastIndexOf(".")),isPublic:!0,declaration:h,outer:null,topLevel:null,isInner:!1,isPrivate:!1,isInterface:c,isAbstract:c,isFinal:!1,isEnum:!1,isRecord:!1,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:2,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:c?0:ha,outerField:-1,membersEntered:!0,builtin:{pkg:u}};return m.topLevel=m,h.symbol=m,this.#C.push(m),this.#D.set(o,m),m};for(let o of En){let c=t(o.name,!1);c.superclass=o.superclass?this.#D.get(o.superclass):null,o.indexPrefix&&(c.builtin.indexPrefix=o.indexPrefix)}let e=this.#D.get("java.lang.Throwable"),n=tt(e);this.#_(e,"getMessage",[],mt,"throwable-getMessage"),this.#_(e,"getLocalizedMessage",[],mt,"throwable-getLocalizedMessage"),this.#_(e,"getCause",[],n,"throwable-getCause"),this.#_(e,"initCause",[n],n,"throwable-initCause"),this.#_(e,"toString",[],mt,"throwable-toString"),this.#_(e,"printStackTrace",[],xt,"throwable-printStackTrace"),this.#_(e,"addSuppressed",[n],xt,"throwable-addSuppressed",{isFinal:!0}),this.#_(e,"getSuppressed",[],ee(n),"throwable-getSuppressed",{isFinal:!0}),this.#_(e,"fillInStackTrace",[],n,"throwable-fillInStackTrace");let s={none:[],message:[mt],"message-cause":[mt,n],cause:[n],index:[V],object:[G]};for(let o of En){let c=this.#D.get(o.name);for(let u of o.constructors){let d=this.#_(c,c.name,s[u],xt,"throwable-constructor",{isConstructor:!0});d.throwableConstructor=u}}let r=t("java.lang.AutoCloseable",!0),a=this.#_(r,"close",[],xt,void 0,{throws:[tt(this.#D.get("java.lang.Exception"))]});a.isAbstract=!0,delete a.builtin}#Ye(t){if(t.length>1)return this.#D.get(t.join("."))??null;for(let e of this.#D.values()){if(e.name!==t[0])continue;let n=e.builtin.pkg;return n==="java.lang"||this.#X.has(e.name)||this.#r.has(n)||this.#d.compact?e:null}return null}#Wt(){return tt(this.#D.get("java.lang.Throwable"))}#oe(t){return t.tag==="null"||K(t,this.#Wt())}#Xt(t){return t.tag==="class"&&this.#oe(t)&&!K(t,tt(this.#D.get("java.lang.RuntimeException")))&&!K(t,tt(this.#D.get("java.lang.Error")))}#ve(t){if(t.hierarchyState!==0)return;t.hierarchyState=1;let e=this.#o;this.#o=t,this.#Y=!1,this.#E=[];let n=t.declaration,s=t.isInterface?[]:n.extendsTypes.slice(0,1);for(let a of s){let o=this.#tn(a);if(!o||o.tag==="object")continue;if(o.tag==="string"){this.#e(a.pos,w.syntax,"cannot inherit from final String");continue}if(o.tag==="library"){o.symbol.isInterface?this.#e(a.pos,w.syntax,"no interface expected here"):ga.has(o.symbol.name)?t.librarySuperclass=o:this.#a(a.pos,`extending the library class ${o.symbol.name}`,!0);continue}if(o.tag!=="class")continue;let c=o.symbol;if(c.isInterface){this.#e(a.pos,w.syntax,"no interface expected here");continue}if(c.hierarchyState===1||c===t){this.#e(this.#we(t).declaration.keywordPos,w.syntax,`cyclic inheritance involving ${this.#we(t).displayName}`);continue}if(this.#ve(c),c.isFinal){this.#e(a.pos,w.syntax,`cannot inherit from final ${c.displayName}`);continue}if(c.isInner){this.#a(a.pos,"extending an inner (non-static) class",!0);continue}t.superclass=c,t.superType=o}let r=t.isInterface?n.extendsTypes:n.implementsTypes;for(let a of r){let o=this.#tn(a);if(!o)continue;if(o.tag==="library"){o.symbol.isInterface?Sa(o.symbol)?t.libraryInterfaces.push(o):this.#a(a.pos,`implementing the library interface ${o.symbol.name}`,!0):this.#e(a.pos,w.syntax,"interface expected here");continue}if(o.tag!=="class"||!o.symbol.isInterface){o.tag!=="error"&&this.#e(a.pos,w.syntax,"interface expected here");continue}let c=o.symbol;if(c.hierarchyState===1||c===t){this.#e(this.#we(t).declaration.keywordPos,w.syntax,`cyclic inheritance involving ${this.#we(t).displayName}`);continue}this.#ve(c),t.interfaces.includes(c)||(t.interfaces.push(c),(t.interfaceTypes??=[]).push(o))}this.#o=e,t.hierarchyState=2}#Qe(t){let e=r=>r.binaryName.replace(/\\$/g,"."),n=r=>r.isInterface?"interface":"class",s=r=>[...r.superclass?[r.superclass]:[],...r.interfaces];for(let r of t){let a=r.declaration;if(r.isSealed&&r.isFinal&&!r.isEnum&&!r.isRecord){this.#e(a.keywordPos,w.syntax,"illegal combination of modifiers: final and sealed");continue}if(r.isSealed&&r.isNonSealed){this.#e(a.keywordPos,w.syntax,"illegal combination of modifiers: sealed and non-sealed");continue}if(r.isNonSealed&&!r.isFinal&&!s(r).some(c=>c.isSealed)&&this.#e(a.keywordPos,w.syntax,"non-sealed modifier not allowed here",[` (${n(r)} ${e(r)} does not have any sealed supertypes)`]),!r.isSealed)continue;let o=a.permits;if(o){let c=[];this.#o=r.outer??r;for(let u of o){let d=this.#U(u);if(d.tag!=="class")continue;let h=d.symbol;if(c.includes(h)){this.#e(u.pos,w.syntax,"invalid permits clause",[` (must not contain duplicates: ${$(d)})`]);continue}c.push(h),s(h).includes(r)||this.#e(u.pos,w.syntax,"invalid permits clause",[` (${n(h)} ${$(d)} must extend sealed ${n(r)})`])}r.permitted=c}else r.permitted=t.filter(c=>s(c).includes(r)),r.permitted.length||this.#e(a.keywordPos,w.syntax,"sealed class must have subclasses")}for(let r of t){let a=s(r).filter(c=>c.isSealed);if(!a.length)continue;let o=a.find(c=>c.declaration.permits&&!(c.permitted??[]).includes(r));if(o){this.#e(r.declaration.keywordPos,w.syntax,`class is not allowed to extend sealed class: ${o.displayName} (as it is not listed in its \'permits\' clause)`);continue}!r.isFinal&&!r.isSealed&&!r.isNonSealed&&this.#e(r.declaration.keywordPos,w.syntax,"sealed, non-sealed or final modifiers expected")}}#Ze(t){[...t.superclass?[t.superclass]:[],...t.interfaces].some(n=>n.isSealed)&&this.#e(t.declaration.keywordPos,w.syntax,`${t.anonymous?"anonymous":"local"} classes must not extend sealed classes`)}#we(t){return this.#C.filter(n=>n.hierarchyState===1).reduce((n,s)=>n.declaration.keywordPos<=s.declaration.keywordPos?n:s,t)}#tn(t){if(t.kind!=="ClassType")return this.#e(t.pos,w.syntax,"unexpected type"),null;let e=this.#U(t);return e.tag==="error"?null:e}#le(t){if(t.membersEntered)return;t.membersEntered=!0,t.superclass&&this.#le(t.superclass);let e=this.#o;this.#o=t,t.instanceCount=t.superclass?.instanceCount??0,t.isInner&&(t.outerField=t.instanceCount++),t.isEnum&&(t.instanceCount=2,this.#en(t)),t.isRecord&&this.#Ls(t);for(let a of t.declaration.members)a.kind==="FieldDeclaration"?this.#Ms(t,a):a.kind==="MethodDeclaration"&&this.#Rs(t,a);t.isRecord?t.constructors.some(a=>this.#Fn(t,a))||this.#_(t,t.name,t.components.map(a=>a.type),xt,"record-constructor",{isConstructor:!0}):!t.isInterface&&!t.anonymous&&!t.declaration.members.some(a=>a.kind==="MethodDeclaration"&&a.isConstructor)&&this.#Js(t),t.isEnum&&this.#Ns(t),t.isRecord&&this.#Ps(t),t.librarySuperclass&&this.#$s(t);let n=t.methodsByName.get("toString")?.find(a=>!a.isStatic&&a.params.length===0&&a.returnType.tag==="string");n&&(t.toStringMethod=n);let s=t.methodsByName.get("equals")?.find(a=>!a.isStatic&&a.params.length===1&&a.params[0].tag==="object"&&a.returnType.tag==="boolean");s&&(t.equalsMethod=s);let r=t.methodsByName.get("hashCode")?.find(a=>!a.isStatic&&a.params.length===0&&a.returnType.tag==="int");r&&(t.hashCodeMethod=r),this.#o=e}#en(t){let e=tt(t);(t.declaration.enumConstants??[]).forEach((s,r)=>{if(t.fieldsByName.has(s.name)){this.#e(s.pos,w.alreadyDefined,`variable ${s.name} is already defined in enum ${t.displayName}`);return}let a={name:s.name,extraDims:0,init:null,pos:s.pos,start:s.start,end:s.end},o={kind:"FieldDeclaration",modifiers:{keywords:[]},type:{kind:"VoidType",pos:s.pos,start:s.pos,end:s.pos},declarators:[a],pos:s.pos,start:s.start,end:s.end},c={kind:"field",name:s.name,type:e,owner:t,isStatic:!0,isFinal:!0,isPrivate:!1,access:"public",index:this.#i.length,order:t.fields.length,state:"done",declaration:o,declarator:a,enumConstant:{node:s,ordinal:r}};this.#i.push(c),s.field=c,t.fields.push(c),t.fieldsByName.set(c.name,c),t.enumConstants.push(c)})}#Ls(t){for(let e of t.declaration.components??[]){let n=this.#U(e.type);if(n.tag==="error")continue;if(t.fieldsByName.has(e.name)){this.#e(e.pos,w.alreadyDefined,`record component ${e.name} is already defined in record ${t.displayName}`);continue}let s={name:e.name,extraDims:0,init:null,pos:e.pos,start:e.start,end:e.end},r={kind:"FieldDeclaration",modifiers:{keywords:[{name:"private",pos:e.pos},{name:"final",pos:e.pos}]},type:e.type,declarators:[s],pos:e.pos,start:e.start,end:e.end},a={kind:"field",name:e.name,type:n,owner:t,isStatic:!1,isFinal:!0,isPrivate:!0,access:"private",index:t.instanceCount++,order:t.fields.length,state:"done",declaration:r,declarator:s};s.field=a,t.fields.push(a),t.fieldsByName.set(a.name,a),t.components.push(a)}}#Fn(t,e){return e.isConstructor&&(e.declaration.compact===!0||e.params.length===t.components.length&&e.params.every((n,s)=>at(n,t.components[s].type)))}#_(t,e,n,s,r,a={}){let o=t.declaration.keywordPos,c={kind:"MethodDeclaration",modifiers:{keywords:[]},returnType:{kind:"VoidType",pos:o,start:o,end:o},name:e,namePos:o,params:[],body:{kind:"Block",statements:[],pos:o,start:o,end:o+1},synthetic:!0,pos:o,start:o,end:o};a.isConstructor&&(c.isConstructor=!0);let u={kind:"method",name:e,owner:t,isStatic:a.isStatic??!1,isConstructor:a.isConstructor??!1,isPrivate:!1,isAbstract:!1,isFinal:a.isFinal??!1,access:a.isConstructor&&t.isEnum?"private":"public",params:n,returnType:s,index:this.#V.length,declaration:c,locals:[],maxSlots:(a.isStatic?0:1)+n.reduce((d,h)=>d+Be(h),0),builtin:r,throws:a.throws??[]};return a.component!==void 0&&(u.component=a.component),c.symbol=u,this.#V.push(u),u.isConstructor?t.constructors.push(u):(t.methods.push(u),t.methodsByName.set(e,[...t.methodsByName.get(e)??[],u])),u}#$t(t,e,n){return(t.methodsByName.get(e)??[]).some(s=>s.params.length===n.length&&s.params.every((r,a)=>at(r,n[a])))}#Ns(t){let e=tt(t);this.#$t(t,"values",[])||this.#_(t,"values",[],ee(e),"enum-values",{isStatic:!0}),this.#$t(t,"valueOf",[mt])||this.#_(t,"valueOf",[mt],e,"enum-valueOf",{isStatic:!0}),this.#$t(t,"name",[])||this.#_(t,"name",[],mt,"enum-name",{isFinal:!0}),this.#$t(t,"ordinal",[])||this.#_(t,"ordinal",[],V,"enum-ordinal",{isFinal:!0}),this.#$t(t,"compareTo",[e])||this.#_(t,"compareTo",[e],V,"enum-compareTo",{isFinal:!0}),this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"enum-toString")}#$s(t){this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"library-toString"),this.#$t(t,"hashCode",[])||this.#_(t,"hashCode",[],V,"library-hashCode"),this.#$t(t,"equals",[G])||this.#_(t,"equals",[G],gt,"library-equals")}#Ps(t){t.components.forEach((e,n)=>{(t.methodsByName.get(e.name)??[]).find(r=>r.params.length===0)||this.#_(t,e.name,[],e.type,"record-accessor",{component:n})}),this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"record-toString"),this.#$t(t,"hashCode",[])||this.#_(t,"hashCode",[],V,"record-hashCode"),this.#$t(t,"equals",[G])||this.#_(t,"equals",[G],gt,"record-equals")}#nn(t=this.#V){for(let e of t)e.selector===void 0&&(e.isStatic||e.isConstructor||e.isPrivate||e.lambda||(e.selector=this.#_n(ts(e.name,e.params,e.returnType))))}#_n(t){let e=this.#kt.get(t);return e===void 0&&this.#kt.set(t,e=this.#kt.size),e}#Ms(t,e){let n=e.modifiers.keywords.map(d=>d.name),s=this.#At(e.modifiers,"field");for(let d of e.modifiers.keywords){if(d.name==="transient"||d.name==="volatile"){this.#a(d.pos,`\'${d.name}\' fields`);return}if(["abstract","synchronized","native","strictfp","default"].includes(d.name)){this.#e(e.declarators[0].pos,w.syntax,`modifier ${d.name} not allowed here`);return}}let r=e.type;if(r.kind==="VarType"||r.kind==="ClassType"&&r.names.length===1&&r.names[0]==="var"&&!r.hasTypeArguments&&!this.#Gt("var")){this.#e(r.pos,w.syntax,"\'var\' is not allowed here");return}if(t.isInterface&&(n.includes("private")||n.includes("protected"))){this.#e(e.declarators[0].pos,w.syntax,`modifier ${n.includes("private")?"private":"protected"} not allowed here`);return}if(t.isRecord&&!n.includes("static")){this.#e(e.declarators[0].pos,w.syntax,"field declaration must be static",[" (consider replacing field with record component)"]);return}let a=t.isInterface||n.includes("static"),o=t.isInterface||n.includes("final");if(t.isInterface&&e.declarators.some(d=>!d.init)){let d=e.declarators.find(h=>!h.init);this.#e(d.end,w.syntax,"= expected");return}let c=this.#E;this.#Y=a,t.anonymous||(this.#E=[]);let u=this.#U(e.type);this.#Y=!1,this.#E=c;for(let d of e.declarators){let h=u;for(let p=0;p<d.extraDims&&h.tag!=="error";p++)h=ee(h);if(h.tag==="error")continue;if(t.fieldsByName.has(d.name)){this.#e(d.pos,w.alreadyDefined,`variable ${d.name} is already defined in class ${t.displayName}`);continue}let m={kind:"field",name:d.name,type:h,owner:t,isStatic:a,isFinal:o,isPrivate:n.includes("private"),access:n.includes("private")?"private":n.includes("public")||t.isInterface?"public":n.includes("protected")?"protected":"package",index:a?this.#i.length:t.instanceCount++,order:t.fields.length,state:"pending",declaration:e,declarator:d,...s.size?{suppressed:s}:{}};a&&this.#i.push(m),d.field=m,t.fields.push(m),t.fieldsByName.set(m.name,m)}}#Rs(t,e){let n=e.isConstructor===!0;for(let v of e.modifiers.keywords){if(n&&["static","final","abstract","native","synchronized","strictfp","default","transient","volatile"].includes(v.name)){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}if(["strictfp","native"].includes(v.name)){this.#a(v.pos,`\'${v.name}\' methods`);return}if(v.name==="default"&&!t.isInterface||v.name==="synchronized"&&t.isInterface||v.name==="transient"||v.name==="volatile"){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}if(t.isInterface&&(v.name==="protected"||v.name==="final")){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}}let s=this.#At(e.modifiers,n?"constructor":"method");if(e.compact){if(!t.isRecord){this.#e(e.namePos,w.syntax,"invalid method declaration; return type required");return}e.params=(t.declaration.components??[]).map(v=>({...v,symbol:void 0}))}if(n&&e.typeParams?.length){this.#a(e.typeParams[0].pos,"generic constructors");return}let r=this.#E;this.#Y=jt(e.modifiers,"static");let a=e.typeParams?.length?this.#vn(e.typeParams,"",null):void 0;a&&this.#wn(a,e.typeParams),this.#E=a?[...r,a]:r;let o=e.params.map(v=>this.#U(v.type)),c=e.returnType.kind==="VoidType"?xt:this.#U(e.returnType),u=[],d=!0;for(let v of e.throwsTypes??[]){let R=this.#U(v);if(R.tag==="error"){d=!1;break}if(!this.#oe(R)){this.#q(v,R,this.#Wt()),d=!1;break}u.push(R)}if(this.#E=r,this.#Y=!1,o.some(v=>v.tag==="error")||c.tag==="error"||!d)return;if(a){let v=e.params.map((R,L)=>R.varargs?`${$(o[L].element)}...`:$(o[L]));for(let R of a)R.declaredIn=`method <${a.map(L=>L.name).join(",")}>${e.name}(${v.join(",")})`}let h=n?t.constructors:t.methodsByName.get(e.name)??[];if(h.some(v=>v.params.length===o.length&&v.params.every((R,L)=>at(R,o[L])))){let v=n?"constructor":"method";this.#e(e.namePos,w.alreadyDefined,`${v} ${e.name}(${o.map($).join(",")}) is already defined in class ${t.displayName}`);return}let m=h.find(v=>ce(v.name,v.params)===ce(e.name,o));if(m){let v=(R,L)=>`${R}(${L.map($).join(",")})`;this.#e(e.namePos,w.alreadyDefined,`name clash: ${v(e.name,o)} and ${v(m.name,m.params)} have the same erasure`,Et([...o,...m.params]));return}if(n&&t.isInterface){this.#e(e.namePos,w.syntax,"invalid method declaration; return type required");return}if(n&&t.isEnum){let v=e.modifiers.keywords.find(R=>R.name==="public"||R.name==="protected");v&&this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`)}let p=v=>jt(e.modifiers,v),k=p("abstract")||t.isInterface&&!p("default")&&!p("static")&&!p("private");if(k&&(p("private")||p("static")||p("final")||p("synchronized"))){let v=p("private")?"private":p("static")?"static":p("final")?"final":"synchronized";this.#e(e.namePos,w.syntax,`illegal combination of modifiers: abstract and ${v}`);return}if(k&&e.body){let v=t.isInterface&&!p("abstract");this.#e(v?e.body.pos:e.namePos,w.syntax,v?"interface abstract methods cannot have body":"abstract methods cannot have a body");return}if(!k&&!e.body){this.#e(e.namePos,w.syntax,"missing method body, or declare abstract");return}let g=p("private")?"private":p("public")||t.isInterface?"public":p("protected")?"protected":"package",O={kind:"method",name:e.name,owner:t,isStatic:p("static"),isConstructor:n,isPrivate:p("private"),isAbstract:k,isFinal:p("final"),access:g,params:o,returnType:c,index:this.#V.length,...a?{typeParams:a}:{},declaration:e,locals:[],maxSlots:0,throws:u,...s.size?{suppressed:s}:{}},T=this.#Jt(e.modifiers,"SafeVarargs");if(T&&!e.params.some(v=>v.varargs))this.#e(e.namePos,w.syntax,`Invalid SafeVarargs annotation. ${n?"Constructor":"Method"} ${e.name}(${o.map($).join(",")}) is not a varargs method.`);else if(T&&!n&&!O.isStatic&&!O.isFinal&&!O.isPrivate){let v=a?`<${a.map(R=>R.name).join(",")}>`:"";this.#e(e.namePos,w.syntax,`Invalid SafeVarargs annotation. Instance method ${v}${this.#Ht(O)} is neither final nor private.`,Et(o))}e.symbol=O,this.#V.push(O),n?t.constructors.push(O):(t.methods.push(O),t.methodsByName.set(e.name,[...h,O]));let x=t.isRecord&&!n&&!O.isStatic&&o.length===0?t.components.find(v=>v.name===e.name):void 0;x&&(at(c,x.type)?g!=="public"&&this.#e(e.namePos,w.syntax,`invalid accessor method in record ${t.displayName}`,[" (accessor method must be public)"]):this.#e(e.namePos,w.syntax,`invalid accessor method in record ${t.displayName}`,[` (return type of accessor method ${e.name}() must match the type of record component ${e.name})`]))}#Js(t){let e=t.declaration.namePos,n={kind:"MethodDeclaration",modifiers:{keywords:t.isPrivate?[{name:"private",pos:e}]:[]},returnType:{kind:"VoidType",pos:e,start:e,end:e},name:t.name,namePos:e,params:[],body:{kind:"Block",statements:[],pos:e,start:e,end:e+1},isConstructor:!0,synthetic:!0,pos:e,start:e,end:e},s={kind:"method",name:t.name,owner:t,isStatic:!1,isConstructor:!0,isPrivate:t.isPrivate,isAbstract:!1,isFinal:!1,access:t.isPrivate?"private":t.isPublic?"public":jt(t.declaration.modifiers,"protected")?"protected":"package",params:[],returnType:xt,index:this.#V.length,declaration:n,locals:[],maxSlots:0,throws:[]};n.symbol=s,this.#V.push(s),t.constructors.push(s)}#Ht(t){let e=t.declaration.params.map((n,s)=>n.varargs?`${$(t.params[s].element)}...`:$(t.params[s]));return`${t.name}(${e.join(",")})`}#ke(){return{method:this.#b,field:this.#it,isStatic:this.#t,scopes:this.#f,nextSlot:this.#c,jumps:this.#y,typeScopes:this.#E,typeStatic:this.#Y,memberSuppressed:this.#x,localSuppressed:this.#I}}#Ce(t){this.#b=t.method,this.#it=t.field,this.#t=t.isStatic,this.#f=t.scopes,this.#c=t.nextSlot,this.#y=t.jumps,this.#E=t.typeScopes,this.#Y=t.typeStatic,this.#x=t.memberSuppressed,this.#I=t.localSuppressed}#He(t){this.#o=t;let e=this.#At(t.declaration.modifiers,"type");e.size&&(t.suppressed=e);let n=this.#Jt(t.declaration.modifiers,"FunctionalInterface");if(n){let s=t.isInterface?ks(t):[];if(s.length!==1){let r=[` ${t.displayName} is not a functional interface`];t.isInterface&&r.push(s.length?` multiple non-overriding abstract methods found in interface ${t.displayName}`:` no abstract method found in interface ${t.displayName}`),this.#e(n.pos,w.syntax,"Unexpected @FunctionalInterface annotation",r)}}this.#Vs(t),t.isEnum&&this.#Fs(t);for(let s of t.declaration.members)if(this.#o=t,s.kind==="FieldDeclaration")for(let r of s.declarators)r.field&&this.#Hn(r.field);else s.kind==="MethodDeclaration"?s.symbol&&this.#_s(s.symbol):s.kind==="Initializer"?this.#js(t,s):s.symbol&&this.#He(s.symbol);this.#o=t,this.#Hs(t)}#js(t,e){if(t.isInterface){this.#e(e.body.pos,w.syntax,"initializers not allowed in interfaces");return}if(t.isRecord&&!e.isStatic){this.#e(e.body.pos,w.syntax,"instance initializers not allowed in records");return}let n=e.isStatic?"static":"new",s={kind:"MethodDeclaration",modifiers:e.modifiers,returnType:{kind:"VoidType",pos:e.pos,start:e.pos,end:e.pos},name:n,namePos:e.pos,params:[],body:e.body,pos:e.pos,start:e.start,end:e.end},r={kind:"method",name:n,owner:t,isStatic:e.isStatic,isConstructor:!1,isPrivate:!0,isAbstract:!1,isFinal:!1,access:"private",params:[],returnType:xt,index:-1,declaration:s,locals:[],maxSlots:0,throws:[],initializer:e.isStatic?"static":"instance"};e.symbol=r;let a=this.#ke(),o=this.#St,c=t.fields.find(u=>!u.enumConstant&&!u.capturedLocal&&u.declarator.pos>e.start);this.#St={owner:t,isStatic:e.isStatic,order:c?c.order:t.fields.length},this.#o=t,this.#b=r,this.#it=null,this.#t=e.isStatic,this.#Y=e.isStatic,this.#E=[],this.#x=void 0,this.#I=[],this.#f=[],this.#c=e.isStatic?0:1,r.maxSlots=this.#c,this.#y=[],this.#Pt();for(let u of e.body.statements)this.#ce(u);this.#Mt(),this.#Ce(a),this.#St=o,this.#o=t}#Ds(t,e,n){t.superclass=e,t.superType=tt(e),t.hierarchyState=2;let s=this.#ke(),r=this.#J,a=this.#g;this.#le(t);let o=this.#cs(t,n);return this.#nn([...t.methods,...t.constructors]),this.#N.set(t,{scopes:[]}),this.#J=null,this.#g=!1,this.#He(t),this.#Ce(s),this.#J=r,this.#g=a,this.#o=e,o}#Fs(t){for(let e of t.enumConstants){let n=e.enumConstant.node,s=this.#ke();this.#b=null,this.#it=e,this.#t=!0,this.#f=[{names:new Map,nextSlot:0}],this.#c=0,this.#y=[];let r=this.#ue(n.args);if(!r.some(a=>a.tag==="error")){let a=this.#ct({pos:n.pos,name:t.name},this.#qe(t),r,"constructor");if(a&&!n.body&&t.enumAbstract)this.#e(n.pos,w.syntax,`${t.displayName} is abstract; cannot be instantiated`);else if(a){this.#de(n.args,a.params),n.ctor=n.body?.symbol?this.#Ds(n.body.symbol,t,a):a.method;let o=this.#_e(a,n.pos);o&&(n.varargs=o)}this.#Fe(n.args)}this.#Ce(s),this.#o=t}}#_s(t){if(t.builtin)return;this.#o=t.owner,this.#b=t,this.#it=null,this.#t=t.isStatic,this.#Y=t.isStatic,this.#E=t.typeParams?[t.typeParams]:[],this.#x=t.suppressed,this.#I=[],this.#f=[];let e=t.isConstructor&&t.owner.isInner?1:t.isConstructor&&t.owner.isEnum?2:0;this.#c=(t.isStatic?0:1)+e,t.maxSlots=this.#c,this.#y=[],this.#Us(t);let n=t.declaration.params[t.declaration.params.length-1];if(n?.varargs&&!Ln(t.params[t.params.length-1])&&!this.#Jt(t.declaration.modifiers,"SafeVarargs")){let a=t.params[t.params.length-1].element;this.#at(n.pos,"unchecked",`Possible heap pollution from parameterized vararg type ${$(a)}`,Et([a]))}if(t.isAbstract){this.#b=null;return}this.#Pt(),t.declaration.params.forEach((a,o)=>{this.#At(a.modifiers,"parameter");let c=this.#zt(a.name,t.params[o],a.pos,jt(a.modifiers,"final"));c.parameter=o+1+e,a.symbol=c});let s=t.declaration.body.statements;t.isConstructor&&t.owner.isRecord&&!this.#Fn(t.owner,t)&&!(s[0]?.kind==="ConstructorCall"&&s[0].keyword==="this")&&this.#e(t.declaration.namePos,w.syntax,`constructor is not canonical, so it must invoke another constructor of class ${t.owner.displayName}`),t.isConstructor&&t.owner.isEnum&&s[0]?.kind==="ConstructorCall"&&s[0].keyword==="super"&&this.#e(s[0].thisPos,w.syntax,"call to super not allowed in enum constructor");let r=s.some(a=>a.kind==="ConstructorCall");t.isConstructor&&!r&&!t.forwardsToSuper&&this.#Un(t),s.forEach((a,o)=>{a.kind==="ConstructorCall"?this.#Vn(a,o===0):this.#ce(a)}),this.#Mt(),this.#b=null}#Un(t){let e=t.owner.superclass,n=t.owner.librarySuperclass;if(n){let o=t.declaration.synthetic?t.owner.declaration.keywordPos:t.declaration.body.pos,c=this.#Nn(n,[],o);c&&(t.superLibrary=c.call);return}if(!e)return;let s=t.declaration.synthetic?t.owner.declaration.keywordPos:t.declaration.body.pos,r=this.#ct({pos:s,name:e.name,viaSuper:!0},this.#qe(e,t.owner.superType),[],"constructor");if(!r||!this.#Oe(r.method,s,`${e.name}()`,"super"))return;t.superConstructor=r.method;let a=this.#_e(r,s);a&&(t.superVarargs=a)}#Us(t){let e=t.declaration,n=this.#Jt(e.modifiers,"Override");if(t.isConstructor)return;let s=t.isPrivate?[]:this.#Bs(t);if(!s.length){n&&this.#e(n.pos,w.syntax,"method does not override or implement a method from a supertype");return}for(let r of s){if(r.libraryClass&&!t.isStatic&&!t.builtin&&!ba.has(r.native)&&!(Qo[r.libraryClass]??[]).includes(r.native)){this.#a(e.namePos,`overriding ${r.libraryClass}.${r.name}(${r.library.params.map(Je).join(", ")})`,!0);return}let a=r.fromInterface&&!t.owner.isInterface&&!t.isStatic?"implement":"override",o=`${this.#Ht(t)} in ${t.owner.displayName} cannot ${a} ${r.signature} in ${r.ownerName}`;if(t.isStatic&&!r.isStatic){this.#e(e.namePos,w.syntax,o,[" overriding method is static"]);return}if(!t.isStatic&&r.isStatic){this.#e(e.namePos,w.syntax,o,[" overridden method is static"]);return}if(t.isStatic)continue;if(r.isFinal){this.#e(e.namePos,w.syntax,o,[" overridden method is final"]);return}if(ya[t.access]<ya[r.access]){this.#e(e.namePos,w.syntax,o,[` attempting to assign weaker access privileges; was ${r.access}`]);return}let c=t.returnType;if(!(st(r.returnType)||r.returnType.tag==="void"?at(c,r.returnType):K(c,r.returnType))){this.#e(e.namePos,w.incompatibleTypes,o,[` return type ${$(c)} is not compatible with ${$(r.returnType)}`]);return}let d=t.throws.find(h=>this.#Xt(h)&&!(r.throws??[]).some(m=>K(h,m)));if(d){this.#e(e.namePos,w.syntax,o,[` overridden method does not throw ${$(d)}`]);return}}}#Bs(t){let e=[],n=ce(t.name,t.params);for(let s of this.#Bn(t.owner))s.name===t.name&&ce(s.name,s.params)===n&&e.push(s);return e}#Bn(t){let e=[],n=new Set,s=(h,m)=>{for(let p of h.methods){if(p.isPrivate||p.lambda||p.isStatic&&h.isInterface||h.isEnum&&p.builtin&&Wo.has(p.name))continue;let k=O=>p.isStatic?O:Ne(m,h,O),g=p.params.map(k);e.push({name:p.name,params:g,returnType:k(p.returnType),isStatic:p.isStatic,isFinal:p.isFinal,isAbstract:p.isAbstract,isDefault:h.isInterface&&!p.isAbstract&&!p.isStatic,access:p.access,ownerName:h.displayName,signature:this.#Ht(p),fromInterface:h.isInterface,interfaceSymbol:h.isInterface?h:void 0,throws:p.throws,method:p})}},r=fe(t),a=h=>Vn(h).filter(m=>m.tag==="class"&&m.symbol.isInterface),o=h=>{if(!n.has(h.symbol)){n.add(h.symbol),s(h.symbol,h);for(let m of a(h))o(m)}},c=[r];for(let h=t.superclass;h;h=h.superclass)c.push(se(r,h)??tt(h));for(let h of c.slice(1))s(h.symbol,h);let u=[];for(let h of c)u.push(...a(h));for(let h of u)o(h);for(let h of Le(r)){if(!h.symbol.isInterface){for(let m of h.symbol.methods){if(m.isStatic||!m.native)continue;let p=m.params.map(k=>wt(k,h.symbol.typeParams,h.args));e.push({name:m.name,params:p,returnType:wt(m.returnType,h.symbol.typeParams,h.args),isStatic:!1,isFinal:!1,isAbstract:m.abstractIn!==void 0,isDefault:!1,access:m.isProtected?"protected":"public",ownerName:m.abstractIn??h.symbol.name,signature:`${m.name}(${p.map($).join(",")})`,fromInterface:!1,library:{params:m.params,returnType:m.returnType},libraryClass:h.symbol.name,native:m.native})}continue}for(let m of Yo[h.symbol.name]??(h.symbol.functional?[h.symbol.functional]:[])){let p=h.symbol.methods.find(g=>g.name===m),k=p.params.map(g=>wt(g,h.symbol.typeParams,h.args));e.push({name:m,params:k,returnType:wt(p.returnType,h.symbol.typeParams,h.args),isStatic:!1,isFinal:!1,isAbstract:!0,isDefault:!1,access:"public",ownerName:h.symbol.name,signature:`${m}(${k.map($).join(",")})`,fromInterface:!0,library:{params:p.params,returnType:p.returnType}})}}let d=t.isEnum?t:t.enumBody?t.superclass:null;if(d){let h=tt(d),m=(p,k,g)=>({name:p,params:k,returnType:g,isStatic:!1,isFinal:!0,isAbstract:!1,isDefault:!1,access:"public",ownerName:"Enum",signature:`${p}(${k.map($).join(",")})`,fromInterface:!1});e.push(m("name",[],mt),m("ordinal",[],V),m("compareTo",[h],V),m("equals",[G],gt),m("hashCode",[],V))}for(let h of Object.values($e))e.push({name:h.name,params:h.params,returnType:h.returnType,isStatic:!1,isFinal:!1,isAbstract:!1,isDefault:!1,access:"public",ownerName:"Object",signature:`${h.name}(${h.params.map($).join(",")})`,fromInterface:!1,isObject:!0});return e}#Vs(t){if(t.isInterface)return;for(let d of t.constructors)d.declaration.synthetic&&!d.forwardsToSuper&&this.#Un(d);let e=new Set,n=new Map,s=fe(t);for(let d=t;d;d=d.superclass){let h=se(s,d)??tt(d);for(let m of d.methods){if(m.isAbstract||m.isStatic||m.lambda)continue;let p=ce(m.name,m.params.map(k=>Ne(h,d,k)));e.add(p),!m.isPrivate&&!n.has(p)&&n.set(p,m)}}for(let d of Object.values($e))e.add(ce(d.name,d.params));let r=this.#Bn(t),a=new Set(t.methods.filter(d=>!d.isStatic&&!d.isConstructor).map(d=>ts(d.name,d.params,d.returnType))),o=d=>{for(let h=t.superclass;h;h=h.superclass)if(h.bridges?.some(m=>m.key===d))return!0;return!1};for(let d of r){if(d.isStatic||d.isObject||!(d.method||d.library))continue;let h=d.method??d.library,m=n.get(ce(d.name,d.params));if(!m||m===d.method||m.selector===void 0)continue;let p=ts(d.name,h.params,h.returnType);if(p===ts(m.name,m.params,m.returnType)||a.has(p)||m.owner!==t&&o(p))continue;let k=t.bridges??=[];k.some(g=>g.key===p)||k.push({key:p,name:d.name,params:h.params.map(W),returnType:W(h.returnType),target:m,selector:this.#_n(p),library:!d.method,...m.builtin?{alias:!0}:{}})}for(let d of r){if(!d.libraryClass||ba.has(d.native))continue;let h=n.get(ce(d.name,d.params));if(!h||h.builtin||h.selector===void 0)continue;let m=t.bridges?.find(p=>p.key===ts(d.name,d.library.params,d.library.returnType));(t.libraryOverrides??=new Map).set(d.native,m?m.selector:h.selector)}let c=new Map;for(let d of r){if(!d.isDefault)continue;let h=ce(d.name,d.params);c.set(h,[...c.get(h)??[],d])}let u=t.isEnum&&t.declaration.enumConstants?.some(d=>d.body)===!0;if(!t.isAbstract){let d=t.methods.filter(h=>h.isAbstract).map(h=>({name:h.name,params:h.params,returnType:h.returnType,isStatic:!1,isFinal:!1,isAbstract:!0,isDefault:!1,access:h.access,ownerName:t.displayName,signature:this.#Ht(h),fromInterface:!1}));for(let h of[...d,...r]){if(!h.isAbstract)continue;let m=ce(h.name,h.params);if(!(e.has(m)||c.has(m))){if(u){t.enumAbstract=!0;break}this.#e(t.declaration.keywordPos,w.syntax,`${t.displayName} is not abstract and does not override abstract method ${h.signature} in ${h.ownerName}`);return}}}for(let[d,h]of c){if(e.has(d)||h.length<2)continue;let[m,p]=h;if(!(m.interfaceSymbol&&p.interfaceSymbol&&(Sn(m.interfaceSymbol,p.interfaceSymbol)||Sn(p.interfaceSymbol,m.interfaceSymbol))||m.interfaceSymbol===p.interfaceSymbol)){this.#e(t.declaration.keywordPos,w.syntax,`types ${m.ownerName} and ${p.ownerName} are incompatible;`,[` class ${t.displayName} inherits unrelated defaults for ${m.signature} from types ${m.ownerName} and ${p.ownerName}`]);return}}}#Vn(t,e){let n=this.#b;if(!n?.isConstructor){this.#e(t.pos,w.syntax,"explicit constructor invocation may only appear within a constructor body");return}if(!e){this.#a(t.thisPos,`statements before \'${t.keyword}(...)\' in a constructor`);return}this.#g=!0;let s=this.#ue(t.args);if(this.#g=!1,s.some(d=>d.tag==="error"))return;let r=t.keyword==="this"?n.owner:n.owner.superclass,a=t.keyword==="super"?n.owner.librarySuperclass:void 0;if(a){let d=this.#Nn(a,s,t.thisPos);if(!d)return;this.#g=!0,this.#de(t.args,d.candidate.params),this.#Fe(t.args),this.#g=!1,t.libraryCall=d.call;return}if(!r){s.length&&this.#e(t.thisPos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${s.map($).join(",")}`," reason: actual and formal argument lists differ in length"]);return}if(this.#In(r,s.length,t.thisPos))return;let o=t.keyword==="this"?fe(r):n.owner.superType,c=this.#ct({pos:t.thisPos,name:r.name,viaSuper:t.keyword==="super"},this.#qe(r,o),s,"constructor");if(!c||!this.#Oe(c.method,t.thisPos,`${r.name}(${c.params.map($).join(",")})`,t.keyword==="super"?"super":null))return;this.#g=!0,this.#de(t.args,c.params),this.#Fe(t.args),this.#g=!1,t.target=c.method;let u=this.#_e(c,t.thisPos);u&&(t.varargs=u)}#Hs(t){let e=new Map;for(let s of t.constructors){let r=s.declaration.body?.statements[0];r?.kind==="ConstructorCall"&&r.keyword==="this"&&r.target&&e.set(s,r)}let n=new Set;for(let s of t.constructors){let r=new Set,a=s;for(;a&&!n.has(a);){r.add(a);let o=e.get(a),c=o?.target;if(c&&r.has(c)){this.#e(o.thisPos,w.syntax,"recursive constructor invocation"),e.delete(a);break}a=c}for(let o of r)n.add(o)}}#Hn(t){if(t.state!=="pending")return;t.state="attributing";let e=this.#ke(),n=this.#o;this.#o=t.owner,this.#b=null,this.#it=t,this.#t=t.isStatic,this.#Y=t.isStatic,this.#E=[],this.#x=t.suppressed,this.#I=[],this.#f=[{names:new Map,nextSlot:0}],this.#c=0,this.#y=[];let s=t.declarator.init;if(s)if(s.kind==="ArrayInitializer")this.#je(s,t.type);else{let r=this.#k(s,t.type);this.#ln(t.type,r,s)?t.isFinal&&s.constant&&(st(t.type)||t.type.tag==="string")&&(t.constant=On(s.constant,t.type)):this.#q(s,r,t.type)}this.#Ce(e),this.#o=n,t.state="done"}#Pt(){this.#f.push({names:new Map,nextSlot:this.#c})}#Mt(){let t=this.#f.pop();this.#c=t.nextSlot}#lt(t){for(let e=this.#f.length-1;e>=0;e--){let n=this.#f[e].names.get(t);if(n)return n}}#zt(t,e,n,s,r=!1){let a=this.#b,o=this.#lt(t)||r?null:this.#Pn(t),c=o?.method??a;!r&&(this.#lt(t)||o&&c)&&this.#e(n,w.alreadyDefined,`variable ${t} is already defined in ${c.isConstructor?"constructor":"method"} ${this.#Ht(c)}`);let u={kind:"local",name:t,type:e,index:a.locals.length,slot:this.#c,isFinal:s,declPos:n};return this.#c+=Be(e),a.maxSlots=Math.max(a.maxSlots,this.#c),a.locals.push(u),this.#f[this.#f.length-1].names.set(t,u),u}#Yt(t){let e=0;for(let n=this.#o;n;n=n.outer,e++){let s=this.#Ee(n,t);if(s&&!(n.enumBody&&s.isPrivate&&s.owner!==n))return{field:s,hops:e};let r=n.anonymous||n.local?this.#Cr(n,t):null;if(r)return{field:r,hops:e}}return null}#Ee(t,e,n=new Set){if(n.has(t))return null;n.add(t);let s=t.fieldsByName.get(e);if(s)return s;if(t.superclass){let r=this.#Ee(t.superclass,e,n);if(r)return r}for(let r of t.interfaces){let a=this.#Ee(r,e,n);if(a)return a}return null}#wt(t,e){let n=[],s=new Set,r=new Set,a=fe(t),o=(c,u)=>{if(!r.has(c)){r.add(c);for(let d of c.methodsByName.get(e)??[]){if(u&&(d.isPrivate||d.isStatic&&c.isInterface))continue;let h=ce(d.name,d.isStatic?d.params:d.params.map(m=>Ne(a,c,m)));s.has(h)||(s.add(h),n.push(d))}c.superclass&&o(c.superclass,!0);for(let d of c.interfaces)o(d,!0)}};return o(t,!1),n}#sn(t){let e=this.#o;for(let n=0;n<t;n++,e=e.outer)if(!e?.isInner)return!1;return!0}#zs(t){let e=this.#o;for(let n=0;n<t&&e;n++)e=e.outer;return e}#Gs(t,e){for(let n=e;n;n=n.outer)if(n===t)return!0;return!1}#Ks(t,e){for(let n=t.superclass;n;n=n.superclass){let s=n.methodsByName.get(e)?.find(r=>r.isPrivate);if(s)return s}return null}#Gt(t){let e=s=>{for(let r=s.length-1;r>=0;r--){let a=s[r].classes?.get(t);if(a)return a}return null},n=e(this.#f);if(n)return n;for(let s=this.#J;s;s=s.outer){let r=e(s.scopes);if(r)return r}for(let s=this.#o;s;s=s.outer){let r=s.membersByName.get(t);if(r)return r;if(s.name===t&&!s.declaration.implicit)return s;let a=s.anonymous||s.local?this.#N.get(s):void 0,o=a?e(a.scopes):null;if(o)return o}return this.#qs(t)}#qs(t){let e=this.#W.find(a=>a.name===t&&!a.declaration.implicit&&this.#z.get(a)===this.#d);if(e)return e;let n=this.#d.programImports.get(t),s=n?this.#rn(n):null;if(s)return s;if(this.#X.has(t))return null;let r=this.#Dt(this.#d.pkg,t);if(r)return r;for(let a of this.#d.programOnDemand){let o=this.#Dt(a,t);if(o?.isPublic)return o}return null}#Dt(t,e){let n=this.#W.find(r=>r.packageName===t&&r.name===e&&!r.declaration.implicit);if(n){let r=this.#z.get(n);if(r&&!r.launch&&r!==this.#d&&`${e}.java`!==r.file.name.replace(/^.*\\//,""))throw new He(`class ${e} is declared in ${r.file.name}, a file not named after it, and used from another file`);return n}let s=`${this.#rt}${t?`${t.replaceAll(".","/")}/`:""}${e}.java`;if(this.#It.has(s))throw new is(s,this.#R||this.#O.has(this.#ut.name));return null}#rn(t){let e=this.#Dt(t.pkg,t.names[0]);for(let n of t.names.slice(1))e=e?.membersByName.get(n)??null;return e}#in(t){for(let e=t.length-1;e>0;e--)if(this.#G.has(t.slice(0,e).join(".")))return e;return 0}#zn(t,e){if(this.#W.some(r=>r.name===t&&this.#z.get(r)===this.#d))return!1;let n=this.#d.ambiguousImports.get(t);if(n){let r=a=>`class ${a} in ${a.slice(0,a.lastIndexOf("."))}`;return this.#e(e,w.cantResolve,`reference to ${t} is ambiguous`,[` both ${r(n[0])} and ${r(n[1])} match`]),!0}if(!this.#d.programOnDemand.length||this.#d.programImports.has(t)||this.#X.has(t)||this.#Dt(this.#d.pkg,t))return!1;let s=[];for(let r of["java.lang",...this.#d.onDemandOrder]){if(this.#G.has(r)){let c=this.#Dt(r,t);c?.isPublic&&s.push(`${c.isInterface?"interface":c.isEnum?"enum":c.isRecord?"record":"class"} ${r}.${t} in ${r}`);continue}if(!(r==="java.lang"&&(t==="String"||t==="System"||t==="Math"||An.has(t)))&&!(It[t]===r&&!Mt[t])&&!(Yn[r]??[]).includes(t))continue;let o=It[t]===r?Wt(t):void 0;s.push(`${o?.isInterface?"interface":o?.enumConstants?"enum":"class"} ${r}.${t} in ${r}`)}return s.length<2||!s.some(r=>this.#d.programOnDemand.some(a=>r.endsWith(` in ${a}`)))?!1:(this.#e(e,w.cantResolve,`reference to ${t} is ambiguous`,[` both ${s[s.length-1]} and ${s[s.length-2]} match`]),!0)}#Gn(t,e,n=!0){let s=this.#o.topLevel.packageName;if(t.topLevel.packageName===s)return!0;for(let r=t;r;r=r.outer)if(!(r.isPublic||!r.outer&&!n)){if(!r.outer)return this.#e(e,w.cantResolve,`${r.name} is not public in ${r.packageName}; cannot be accessed from outside package`),!1;if(!r.isPrivate){if(jt(r.declaration.modifiers,"protected")){let a=!1;for(let o=this.#o;o&&!a;o=o.outer)for(let c=o;c&&!a;c=c.superclass)a=c===r.outer;if(a)continue;return this.#e(e,w.cantResolve,`${r.name} has protected access in ${r.outer.displayName}`),!1}return this.#e(e,w.cantResolve,`${r.name} is not public in ${r.outer.displayName}; cannot be accessed from outside package`),!1}}return!0}#Ws(t){this.#d=t;for(let[e,n]of t.programImports){let s=this.#rn(n);if(!s)continue;let r=this.#W.find(a=>a.name===e&&this.#z.get(a)===t);if(r&&r!==s){this.#e(n.start,w.alreadyDefined,`${e} is already defined in this compilation unit`);continue}s.topLevel.packageName!==t.pkg&&!s.topLevel.isPublic&&this.#e(n.pos,w.cantResolve,`${s.topLevel.name} is not public in ${s.topLevel.packageName}; cannot be accessed from outside package`)}}#ze(t){this.#Pt();for(let e of t.statements)this.#ce(e);this.#Mt()}#ce(t){let e=this.#c,n=this.#j.length;this.#Xs(t);let s=this.#j.slice(n);if(t.kind==="LocalVariableDeclaration")for(let r of t.declarators)r.symbol&&s.push(r.symbol);this.#c=Math.max(e,...s.map(r=>r.slot+Be(r.type)))}#Xs(t){switch(t.kind){case"Block":this.#ze(t);return;case"LocalVariableDeclaration":this.#Xn(t);return;case"ExpressionStatement":this.#k(t.expression);return;case"IfStatement":{this.#Ae(t.condition);let e=this.#ft(t.condition,!0),n=this.#ft(t.condition,!1);this.#Qt(e,()=>this.#Tn(t.then)),t.otherwise&&this.#Qt(n,()=>this.#Tn(t.otherwise)),n.length&&!this.#xn(t.then)&&this.#Ke(n),e.length&&t.otherwise&&!this.#xn(t.otherwise)&&this.#Ke(e);return}case"WhileStatement":this.#Ae(t.condition),this.#Qt(this.#ft(t.condition,!0),()=>this.#an(t,t.body)),ye(t.body,t)||this.#Ke(this.#ft(t.condition,!1));return;case"DoStatement":this.#an(t,t.body),this.#Ae(t.condition),ye(t.body,t)||this.#Ke(this.#ft(t.condition,!1));return;case"ForStatement":this.#er(t);return;case"ForEachStatement":this.#nr(t);return;case"LabeledStatement":this.#sr(t);return;case"SwitchStatement":this.#Kn(t,void 0);return;case"YieldStatement":this.#ar(t);return;case"BreakStatement":t.liveSlots=this.#c,this.#rr(t);return;case"ContinueStatement":t.liveSlots=this.#c,this.#ir(t);return;case"ReturnStatement":if(this.#b?.initializer){this.#e(t.pos,w.syntax,"return outside method");return}t.liveSlots=this.#c+(t.value&&this.#b?Be(this.#b.returnType):0),this.#cr(t);return;case"EmptyStatement":return;case"ConstructorCall":this.#Vn(t,!1);return;case"ThrowStatement":{let e=this.#nt(t.expression);e.tag!=="error"&&!this.#oe(e)&&this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${Ue(this.#Wt(),e)}`);return}case"TryStatement":this.#Qs(t);return;case"AssertStatement":this.#Ae(t.condition),t.message&&this.#nt(t.message);return;case"LocalClass":this.#Ys(t.declaration);return}}#Ys(t){let e=t.symbol;if(!e)return;let n=this.#f[this.#f.length-1];if(this.#f.some(h=>h.classes?.has(e.name))&&this.#b){this.#e(t.keywordPos,w.alreadyDefined,`class ${e.name} is already defined in ${this.#b.isConstructor?"constructor":"method"} ${this.#Ht(this.#b)}`);return}(n.classes??=new Map).set(e.name,e);let r=this.#ke(),a=this.#o,o=this.#J,c=this.#ht,u=this.#g;e.declaration.keyword==="class"&&this.#N.set(e,{scopes:r.scopes});let d=[e,...Lr(e,!0)];for(let h of d)h.typeParams&&(this.#o=h,this.#wn(h.typeParams,h.declaration.typeParams));for(let h of d)this.#ve(h);this.#Ze(e);for(let h of d)this.#le(h);for(let h of d)this.#nn([...h.methods,...h.constructors]);this.#J=null,this.#g=!1,this.#He(e),this.#Ce(r),this.#o=a,this.#J=o,this.#ht=c,this.#g=u}#Qs(t){this.#Pt();for(let n of t.resources)this.#Zs(n);this.#ze(t.block),this.#Mt();let e=[];for(let n of t.catches){let s=[];for(let o of n.types){let c=this.#U(o);if(c.tag==="error")continue;if(!this.#oe(c)){this.#q(o,c,this.#Wt());continue}let u=s.find(d=>K(c,d)||K(d,c));if(u){let[d,h]=K(c,u)?[c,u]:[u,c];this.#e(o.pos,w.syntax,"Alternatives in a multi-catch statement cannot be related by subclassing",[` Alternative ${$(d)} is a subclass of alternative ${$(h)}`]);continue}if(e.some(d=>K(c,d))){this.#e(n.types.length===1?n.pos:o.pos,w.syntax,`exception ${$(c)} has already been caught`);continue}s.push(c)}e.push(...s),n.caught=s,this.#Pt();let r=s.length===1?s[0]:s.length?this.#tr(s):A,a=this.#zt(n.name,r,n.namePos,n.isFinal||n.types.length>1);n.types.length>1&&(a.multiCatch=!0),a.catchParameter=!0,n.symbol=a,this.#ze(n.block),this.#Mt()}if(t.finallyBlock){let n=this.#b,s=n.maxSlots,r=this.#c,a=n.locals.length;this.#ze(t.finallyBlock);let o=Math.max(0,...n.locals.slice(a).map(c=>c.slot+Be(c.type)-r));t.finallySlots={base:r,extent:o,before:s},n.finallySlots=Math.max(n.finallySlots??0,n.maxSlots)+3+2*o}}#Zs(t){if(t.kind==="variable"){let r=this.#k(t.expression),a=Q(t.expression);a.kind==="Name"&&a.symbol?.kind==="local"&&(t.symbol=a.symbol),r.tag!=="error"&&!this.#bn(r)?this.#Sn(t.expression,r):t.closeMethod=this.#gn(r);return}if(t.type.kind==="VarType"){let r=this.#k(t.init),a=r.tag==="null"||r.tag==="void"?A:r;if(a.tag==="error"&&r.tag!=="error"&&this.#e(t.namePos,w.cantResolve,`cannot infer type for local variable ${t.name}`,[` (variable initializer is \'${r.tag}\')`]),t.symbol=this.#zt(t.name,a,t.namePos,!0),a.tag==="error")return;this.#bn(a)?t.closeMethod=this.#gn(a):this.#Sn(t.init,a);return}let e=this.#U(t.type),n=this.#zt(t.name,e,t.namePos,!0);t.symbol=n;let s=this.#k(t.init,e);if(!(e.tag==="error"||s.tag==="error")){if(!re(e,s,t.init.constant)){this.#q(t.init,s,e);return}this.#bn(e)?t.closeMethod=this.#gn(e):this.#Sn(t.type,e)}}#gn(t){if(t.tag==="class")return this.#wt(t.symbol,"close").find(e=>e.params.length===0)}#bn(t){return t.tag==="library"?t.symbol.closeable===!0:K(t,tt(this.#D.get("java.lang.AutoCloseable")))}#Sn(t,e){this.#e(t.pos,w.incompatibleTypes,"incompatible types: try-with-resources not applicable to variable type",[` (${$(e)} cannot be converted to AutoCloseable)`])}#tr(t){let s=(r=>{let a=[];for(let o=r.tag==="class"?r.symbol:null;o;o=o.superclass)a.push(o);return a})(t[0]).find(r=>t.every(a=>a.tag==="class"&&K(a,tt(r))));return s?tt(s):this.#Wt()}#Tn(t){this.#Pt(),this.#ce(t),this.#Mt()}#er(t){if(this.#Pt(),t.init&&!Array.isArray(t.init))this.#Xn(t.init);else for(let s of t.init??[])this.#k(s);t.condition&&this.#Ae(t.condition);let e=t.condition?this.#ft(t.condition,!0):[];this.#Qt(e,()=>{for(let s of t.update)this.#k(s);this.#an(t,t.body)});let n=t.condition?this.#ft(t.condition,!1):[];this.#Mt(),ye(t.body,t)||this.#Ke(n)}#xn(t){let e=[this.#B,this.#dt,this.#K,this.#Z,this.#F,this.#M];this.#B=[],this.#dt=[],this.#K=new Map,this.#Z=0,this.#F=[],this.#M=new Map;let n=this.#Rt(t,Qt(),!0).completes;return[this.#B,this.#dt,this.#K,this.#Z,this.#F,this.#M]=e,n}#an(t,e){this.#y.push({kind:"loop",node:t}),this.#Tn(e),this.#y.pop()}#nr(t){let e=this.#k(t.iterable);this.#Pt();let n=A,s=c=>c.tag==="library"?[c]:c.tag==="diamond"?[this.#Ln(c)]:c.tag==="class"?Le(c):c.tag==="typevar"&&c.symbol?c.symbol.bounds.flatMap(s):[],r=s(e).map(c=>Dt(c,Wt("Iterable"))).find(c=>c!==null)??null;e.tag==="array"?(n=e.element,t.hidden={array:this.#Je(e),length:this.#Je(V),index:this.#Je(V)}):r?(n=Me(r.args[0]??G),t.element=n,t.iterator=this.#Je(G)):e.tag!=="error"&&this.#e(t.iterable.pos,w.incompatibleTypes,"for-each not applicable to expression type",[" required: array or java.lang.Iterable",` found: ${$(e)}`]),this.#At(t.modifiers,"local");let a=t.type.kind==="VarType"?n:this.#U(t.type),o=this.#zt(t.name,a,t.namePos,jt(t.modifiers,"final"));o.forEach=!0,t.symbol=o,n.tag!=="error"&&a.tag!=="error"&&!re(a,n)&&this.#q(t.iterable,n,a),this.#an(t,t.body),this.#Mt()}#sr(t){this.#y.some(s=>s.kind==="label"&&s.label===t.label)&&this.#e(t.pos,w.syntax,`label ${t.label} already in use`);let e=t.body,n=["WhileStatement","DoStatement","ForStatement","ForEachStatement"].includes(e.kind);this.#y.push({kind:"label",node:t,label:t.label,loop:n?e:void 0}),this.#ce(e),this.#y.pop()}#rr(t){for(let e=this.#y.length-1;e>=0;e--){let n=this.#y[e];if(n.kind==="switch-expression"){this.#e(t.pos,w.syntax,"attempt to break out of a switch expression");return}if(t.label===void 0?n.kind==="loop"||n.kind==="switch":n.kind==="label"&&n.label===t.label){t.target=n.node;return}}t.label!==void 0?this.#e(t.pos,w.syntax,`undefined label: ${t.label}`):this.#e(t.pos,w.syntax,"break outside switch or loop")}#ir(t){for(let e=this.#y.length-1;e>=0;e--){let n=this.#y[e];if(n.kind==="switch-expression"){this.#e(t.pos,w.syntax,"attempt to continue out of a switch expression");return}if(t.label===void 0&&n.kind==="loop"){t.target=n.node;return}if(t.label!==void 0&&n.kind==="label"&&n.label===t.label){n.loop?t.target=n.loop:this.#e(t.pos,w.syntax,`not a loop label: ${t.label}`);return}}t.label!==void 0?this.#e(t.pos,w.syntax,`undefined label: ${t.label}`):this.#e(t.pos,w.syntax,"continue outside of loop")}#ar(t){let e=[...this.#y].reverse().find(s=>s.kind==="switch-expression");if(!e){this.#e(t.pos,w.syntax,"yield outside of switch expression"),this.#k(t.value);return}t.target=e.node;let n=this.#nt(t.value,e.target);e.results.push({expression:t.value,type:n})}#Je(t){let e=this.#b;if(!e)throw new Error("checker: hidden local outside a method");let n={kind:"local",name:"",type:t,index:e.locals.length,slot:this.#c,isFinal:!1,declPos:-1};return this.#c+=Be(t),e.maxSlots=Math.max(e.maxSlots,this.#c),e.locals.push(n),n}#Kn(t,e){let n=t.kind==="SwitchExpression",s=this.#k(t.selector),r=s.tag!=="error",a=s.tag==="class"&&s.symbol.isEnum?s.symbol:null,o=s.tag==="library"&&s.symbol.enumConstants?s.symbol:null,c=a!==null||o!==null||["int","byte","short","char","string"].includes(s.tag)||St(s)!==null;if(r&&(t.cases.some(k=>k.pattern||k.nullLabel)||!c&&nt(s)))return this.#or(t,s,e);r&&!a&&!o&&!["int","byte","short","char","string"].includes(s.tag)&&(r=!1,St(s)?this.#a(t.selectorPos,`switching on ${nn($(s))}`,!0):st(s)?this.#e(t.selectorPos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#a(t.selectorPos,`switching on ${nn($(s))}`,!0)),this.#Pt(),r&&s.tag==="string"&&(this.#b?t.hidden={copy:this.#Je(mt),index:this.#Je(V)}:(this.#a(t.pos,"a switch on a String in a field initializer",!0),r=!1));let u=n?{kind:"switch-expression",node:t,results:[],target:e}:{kind:"switch",node:t};this.#y.push(u);let d=new Set,h=0,m=!1,p=t.cases[0]?.arrow??!1;for(let k of t.cases){if(k.arrow!==p&&!m&&(m=!0,this.#e(k.pos,w.syntax,"different case kinds used in the switch")),k.isDefault&&++h>1&&this.#e(k.pos,w.syntax,"duplicate default label"),o){k.ordinals=[];for(let g of k.labels){let O=this.#lr(g,o);O!==null&&(d.has(`e:${O}`)&&this.#e(g.pos,w.syntax,"duplicate case label"),d.add(`e:${O}`),k.ordinals.push(O))}this.#on(k,n,u);continue}if(a){k.ordinals=[];for(let g of k.labels){let O=this.#qn(g,a);O!==null&&(d.has(`e:${O}`)&&this.#e(g.pos,w.syntax,"duplicate case label"),d.add(`e:${O}`),k.ordinals.push(O))}this.#on(k,n,u);continue}for(let g of k.labels){let O=this.#k(g,r?s:void 0);if(!r||O.tag==="error")continue;if(!g.constant){this.#e(g.pos,w.syntax,"constant expression required");continue}if(!re(s,O,g.constant)){this.#q(g,O,s);continue}let T=g.constant.kind==="string"?`s:${g.constant.value}`:`n:${kn(g.constant)}`;d.has(T)&&this.#e(k.pos,w.syntax,"duplicate case label"),d.add(T)}this.#on(k,n,u)}return this.#y.pop(),this.#Mt(),a&&(t.coversAllConstants=a.enumConstants.every(k=>d.has(`e:${k.enumConstant.ordinal}`))),o&&(t.libraryEnum=wa(o),t.coversAllConstants=o.enumConstants.every((k,g)=>d.has(`e:${g}`))),n?this.#Wn(t,u.results,e):xt}#or(t,e,n){let s=t.kind==="SwitchExpression";t.patternSwitch=!0;let r=e.tag==="class"&&e.symbol.isEnum?e.symbol:null;this.#Pt();let a=s?{kind:"switch-expression",node:t,results:[],target:n}:{kind:"switch",node:t};this.#y.push(a);let o=!1,c=0,u=!1,d=t.cases[0]?.arrow??!1,h=[],m=new Set,p=null,k=[],g=!1,O=St(e);t.cases.forEach((x,v)=>{x.arrow!==d&&!o&&(o=!0,this.#e(x.pos,w.syntax,"different case kinds used in the switch")),x.isDefault&&++c>1&&this.#e(x.pos,w.syntax,"duplicate default label");let R=[];x.nullLabel&&st(e)&&this.#q({pos:x.pos},br,e);for(let L of x.labels){if(r){let M=this.#qn(L,r);if(M===null)continue;m.has(`e:${M}`)&&this.#e(L.pos,w.syntax,"duplicate case label"),m.add(`e:${M}`),(x.ordinals??=[]).push(M),k.push({constantOf:r,ordinal:M})}else{let M=this.#k(L,O??e);if(M.tag==="error")continue;let _=L.kind==="FieldAccess"?L.fieldSymbol:void 0;if(M.tag==="class"&&M.symbol.isEnum&&_?.enumConstant&&K(M,e)){(x.enumFields??=[]).push(_),k.push({constantOf:M.symbol,ordinal:_.enumConstant.ordinal}),h.some(B=>K(M,B))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label");continue}if(!(e.tag==="string"?M.tag==="string":O!==null&&st(M)&&L.constant!==void 0&&re(O,M,L.constant))){O&&L.constant?this.#q(L,M,O):this.#a(L.pos,`constant labels in a switch on ${nn($(e))}`,!0);continue}if(!L.constant){this.#e(L.pos,w.syntax,"constant expression required");continue}let P=L.constant.kind==="string"?`s:${L.constant.value}`:`n:${kn(L.constant)}`;m.has(P)&&this.#e(x.pos,w.syntax,"duplicate case label"),m.add(P)}let C=r||O?e:mt;h.some(M=>K(C,M))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label")}if(x.pattern){let L=x.pattern;if(!this.#kn(L,e,!0,R))g=!0;else{let M=L.tested;(u||h.some(j=>K(W(M),W(j))))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label");let _=x.guard!==void 0;L.kind==="TypePattern"&&!_&&(h.push(M),L.unconditional&&(p=x)),(!x.guard||qn(x.guard.constant))&&k.push({pattern:L})}let C=t.cases[v-1];!x.arrow&&C&&!C.arrow&&C.statements.length&&R.length&&this.#xn({kind:"Block",statements:C.statements,pos:C.pos,start:C.start,end:C.end})&&this.#e(L.pos,w.syntax,"illegal fall-through to a pattern",[" (the previous case label is missing a break)"])}x.isDefault&&(u=!0,k.push({all:!0})),this.#Qt(R,()=>{let L=[];x.guard&&(this.#Ae(x.guard),Os(x.guard.constant)&&this.#e(x.guard.pos,w.syntax,"this case label has a guard that is a constant expression with value \'false\'"),L=this.#ft(x.guard,!0)),this.#Qt(L,()=>this.#on(x,s,a))})});let T=t.cases.find(x=>x.isDefault&&!x.nullLabel)??t.cases.find(x=>x.isDefault);return p&&T&&this.#e(T.pos,w.syntax,"switch has both an unconditional pattern and a default label"),this.#y.pop(),this.#Mt(),t.exhaustive=dl(e,k),!t.exhaustive&&!g&&this.#e(t.pos,w.syntax,`the switch ${s?"expression":"statement"} does not cover all possible input values`),s?this.#Wn(t,a.results,n):xt}#lr(t,e){let n=Q(t),s=e.enumConstants,r=n.kind==="Name"?n.identifier:n.kind==="FieldAccess"&&ss(n.target)?.split(".").pop()===e.name?n.name:null,a=r===null?-1:s.indexOf(r);return a>=0?(t.type=pt(e),a):n.kind==="Name"?(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#o.displayName}`]),null):(this.#k(t).tag!=="error"&&this.#e(t.pos,w.syntax,"constant expression required"),null)}#qn(t,e){let n=Q(t);if(n.kind==="Name"){let a=e.fieldsByName.get(n.identifier);return a?.enumConstant?(n.symbol=a,t.type=tt(e),a.enumConstant.ordinal):(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#o.displayName}`]),null)}let s=this.#k(t);if(s.tag==="error")return null;let r=n.kind==="FieldAccess"?n.fieldSymbol:void 0;return r?.enumConstant&&r.owner===e?r.enumConstant.ordinal:(re(tt(e),s)?this.#e(t.pos,w.syntax,"constant expression required"):this.#q(t,s,tt(e)),null)}#on(t,e,n){if(!t.arrow){for(let r of t.statements)this.#ce(r);return}let s=t.body;s.kind==="Block"?this.#ze(s):e?n.results.push({expression:s,type:this.#nt(s,n.target)}):this.#k(s)}#Wn(t,e,n){if(e.some(r=>r.type.tag==="error"))return A;if(n&&n.tag!=="error"){let r=!0;for(let{expression:a,type:o}of e)re(n,o,a.constant)||(this.#e(a.pos,w.incompatibleTypes,"incompatible types: bad type in switch expression",[` ${Ue(n,o)}`]),r=!1);return r?n:A}let s=e.map(r=>r.type);return s.length?s.every(r=>r.tag==="boolean")?gt:s.every(r=>Rt(r))?s.every(r=>at(r,s[0]))?s[0]:s.reduce((r,a)=>ns(r,a)):s.every(r=>nt(r))?s.reduce((r,a)=>Pa(r,a)):(this.#a(t.pos,"switch expressions that need boxing"),A):A}#cr(t){let e=this.#b.returnType;if(this.#b.lambda&&this.#b.returnType===es){if(!t.value)return;let s=this.#k(t.value);s.tag!=="error"&&(this.#b.returnType=qt(s)??(s.tag==="null"?G:s));return}if(this.#b.lambda){let s=`incompatible types: bad return type in ${this.#b.lambda.reference?"method reference":"lambda expression"}`;if(!t.value){e.tag!=="void"&&this.#e(t.pos,w.incompatibleTypes,s,[" missing return value"]);return}if(e.tag==="void"){this.#k(t.value),this.#e(t.value.pos,w.incompatibleTypes,"incompatible types: unexpected return value");return}let r=this.#k(t.value,e);r.tag!=="error"&&!re(e,r,t.value.constant)&&this.#e(t.value.pos,w.incompatibleTypes,s,[` ${Ue(e,r)}`]);return}if(!t.value){e.tag!=="void"&&this.#e(t.pos,w.incompatibleTypes,"incompatible types: missing return value");return}let n=this.#k(t.value,e.tag==="void"?void 0:e);if(e.tag==="void"){n.tag!=="error"&&this.#e(t.value.pos,w.incompatibleTypes,"incompatible types: unexpected return value");return}this.#ln(e,n,t.value)||this.#q(t.value,n,e)}#Ae(t){let e=this.#k(t);e.tag!=="error"&&(St(e)??e).tag!=="boolean"&&this.#q(t,e,gt)}#Xn(t){let e=jt(t.modifiers,"final"),n=this.#At(t.modifiers,"local");if(this.#I=[...this.#I,n],this.#Jt(t.modifiers,"Deprecated"))for(let s of t.declarators)this.#at(s.pos,"deprecation","@Deprecated annotation has no effect on this variable declaration");t.type.kind==="VarType"?this.#hr(t,e):this.#ur(t,e),this.#I=this.#I.slice(0,-1)}#ur(t,e){let n=this.#U(t.type);for(let s of t.declarators){let r=n;for(let u=0;u<s.extraDims&&r.tag!=="error";u++)r=ee(r);let a=this.#zt(s.name,r,s.pos,e);s.symbol=a;let o=s.init;if(o||(a.noInitializer=!0),!o){e&&this.#a(s.pos,"final local variables without an initializer");continue}if(o.kind==="ArrayInitializer"){this.#je(o,r);continue}let c=this.#k(o,r);this.#ln(r,c,o)?e&&o.constant&&(st(r)||r.tag==="string")&&(a.constant=On(o.constant,r)):this.#q(o,c,r)}}#hr(t,e){let n=t.type.pos;if(t.declarators.length>1){this.#e(n,w.syntax,"\'var\' is not allowed in a compound declaration");return}let s=t.declarators[0];if(s.extraDims){this.#e(n,w.syntax,"\'var\' is not allowed as an element type of an array");return}let r=d=>this.#e(s.pos,w.cantResolve,`cannot infer type for local variable ${s.name}`,[` (${d})`]),a=s.init,o=a&&a.kind!=="ArrayInitializer"?Q(a):null,c=A;if(!a)r("cannot use \'var\' on variable without initializer");else if(a.kind==="ArrayInitializer")r("array initializer needs an explicit target-type");else if(o.kind==="Lambda")r("lambda expression needs an explicit target-type");else if(o.kind==="MethodRef")r("method reference needs an explicit target-type");else if(gl(a,s.name))r("cannot use \'var\' on self-referencing variable");else{let d=this.#k(a);d.tag==="null"?r("variable initializer is \'null\'"):d.tag==="void"?r("variable initializer is \'void\'"):c=d.tag==="diamond"?this.#Ln(d):d,c.tag==="class"&&c.args?.includes(Hn)&&(c=A)}let u=this.#zt(s.name,c,s.pos,e);s.symbol=u,a||(u.noInitializer=!0),a&&a.kind!=="ArrayInitializer"&&e&&a.constant&&(st(c)||c.tag==="string")&&(u.constant=On(a.constant,c))}#ln(t,e,n){return W(t).tag==="object"&&delete Q(n).genericCast,re(t,e,n.constant)?!0:Re(t,e)?(this.#at(n.pos,"unchecked","unchecked conversion",[` required: ${$(t)}`,` found: ${$(e)}`,...Et([t,e])]),!0):!1}#je(t,e){if(e.tag==="error"){for(let n of t.elements)n.kind==="ArrayInitializer"?this.#je(n,A):this.#k(n);return}if(e.tag!=="array"){this.#e(t.pos,w.incompatibleTypes,`illegal initializer for ${$(e)}`);return}t.elementType=e.element;for(let n of t.elements){if(n.kind==="ArrayInitializer"){this.#je(n,e.element);continue}let s=this.#k(n,e.element);re(e.element,s,n.constant)||this.#q(n,s,e.element)}}#vn(t,e,n){let s=[];for(let r of t){if(s.some(a=>a.name===r.name)){this.#e(r.pos,w.alreadyDefined,`type variable ${r.name} is already defined in ${e}`);continue}s.push({kind:"typevar",name:r.name,key:`${r.name}#${this.#A++}`,bounds:[],declaredIn:e,pos:r.pos,ofClass:n})}return s}#wn(t,e){this.#E=[...this.#E,t.filter(s=>!s.ofClass)];let n=this.#Q;this.#Q=!0;for(let s of t){let r=e.find(a=>a.name===s.name&&a.pos===s.pos);for(let a of r?.bounds??[]){let o=this.#U(a);if(o.tag!=="error"){if(!nt(o)||o.tag==="array"){this.#e(a.pos,w.incompatibleTypes,"unexpected type",[" required: class",` found: ${$(o)}`]);continue}o.tag==="object"&&r.bounds.length===1||s.bounds.push(o)}}}this.#Q=n,this.#E=this.#E.slice(0,-1)}#dr(t,e){for(let s=this.#E.length-1;s>=0;s--){let r=this.#E[s].find(a=>a.name===t);if(r)return me(r)}let n=this.#Y;for(let s=this.#o??null;s;s=s.outer){let r=s.typeParams?.find(a=>a.name===t);if(r)return n?(this.#e(e,w.syntax,`non-static type variable ${t} cannot be referenced from a static context`),A):me(r);s.isInner||(n=!0)}return null}#Ge(t){if(t.kind==="WildcardType"){if(!t.bound)return{tag:"wildcard",bound:null};let e=this.#Ge(t.bound);return e.tag==="error"||e.tag==="wildcard"?A:{tag:"wildcard",bound:e,isSuper:t.isSuper}}return t.kind==="PrimitiveType"?(this.#e(t.pos,w.incompatibleTypes,"unexpected type",[" required: reference",` found: ${t.name}`]),A):this.#U(t)}#mr(t,e){let n=t.typeParams??[];if(e.diamond)return tt(t);if(!n.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,`type ${t.displayName} does not take parameters`),A;let s=e.typeArguments??[];if(s.length!==n.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,`wrong number of type arguments; required ${n.length}`),A;let r=[];for(let o of s){let c=this.#Ge(o);if(c.tag==="error")return A;r.push(c)}let a=tt(t,r);if(!this.#Q){let o=Un(a);for(let c=0;c<n.length;c++){let u=r[c];if(u.tag==="wildcard")continue;if(!n[c].bounds.every(h=>K(u,Kt(h,o))))return this.#e(s[c].pos,w.incompatibleTypes,`type argument ${$(u)} is not within bounds of type-variable ${n[c].name}`,Et([me(n[c])])),A}}return a}#U(t,e=!1){switch(t.kind){case"PrimitiveType":return t.name==="int"?V:t.name==="boolean"?gt:t.name==="char"?Ce:t.name==="long"?Jt:t.name==="double"?ft:t.name==="float"?kt:t.name==="byte"?_n:xn;case"VarType":return this.#a(t.pos,"\'var\' declarations"),A;case"WildcardType":return this.#a(t.pos,"wildcard types"),A;case"VoidType":return this.#e(t.pos,w.syntax,"\'void\' type not allowed here"),A;case"ArrayType":{let n=this.#U(t.element);return n.tag==="error"?A:ee(n)}case"ClassType":{let n=t.names.join(".");if((n==="Object"||n==="java.lang.Object")&&!this.#Ie(t.names))return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,"type Object does not take parameters"),A):G;if(n==="String"||n==="java.lang.String")return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,"type String does not take parameters"),A):mt;if(t.names.length===1){let c=this.#dr(n,t.pos);if(c)return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,`type ${n} does not take parameters`),A):c}if(t.names.length===1&&this.#zn(n,t.pos))return A;let s=this.#Ie(t.names)??this.#Ye(t.names);if(s&&t.names.length>1&&!this.#Gn(s,t.lastDotPos??t.pos,!this.#Gt(t.names[0])))return A;if(s)return t.hasTypeArguments?this.#mr(s,t):tt(s);let r=this.#mt(t.names);if(r)return this.#fr(r,t,e);let a=t.names.length===1?this.#l.get(n):void 0;if(a)return this.#a(t.pos,`the class ${a}`,!0),A;if(t.names.length===1&&(An.has(n)||n===this.#pr()))return this.#a(t.pos,`the type ${n}`,!0),A;if(t.names.length>1&&(t.names[0]==="java"||t.names[0]==="javax"))return this.#a(t.pos,`the type ${n}`,!0),A;let o=t.names.length>1&&!this.#Gt(t.names[0])?this.#in(t.names):0;return o?(this.#e(t.lastDotPos??t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${t.names[o]}`,` location: package ${t.names.slice(0,o).join(".")}`]),A):t.names.length>1?(this.#e(t.lastDotPos??t.pos,w.cantResolve,`package ${t.names.slice(0,-1).join(".")} does not exist`),A):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: class ${this.#o.displayName}`]),A)}}}#fr(t,e,n=!1){let s=t.typeParams;if(t.name==="Class"&&e.typeArguments)return this.#a(e.typeArgumentsPos??e.pos,"Class<...> types (declare the variable as Class)"),A;if(!e.typeArguments)return e.diamond?{tag:"diamond",symbol:t,fromArgs:null}:pt(t);if(e.typeArguments.length!==s.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,s.length?`wrong number of type arguments; required ${s.length}`:`type ${t.name} does not take parameters`),A;let r=[];for(let a of e.typeArguments){let o=this.#Ge(a);if(o.tag==="error")return A;r.push(o)}return pt(t,r)}#Ie(t){let e=this.#Gt(t[0]),n=t.slice(1),s=e||t.length<2?0:this.#in(t);s&&(e=this.#Dt(t.slice(0,s).join("."),t[s]),n=t.slice(s+1));for(let r of n)e=e?.membersByName.get(r)??null;return e}#pr(){return this.#W.find(t=>t.declaration.implicit)?.name}#q(t,e,n){e.tag==="error"||n.tag==="error"||this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${Ue(n,e)}`,Et([e,n]))}#k(t,e){let n=this.#yr(t,e);return t.type=n,n}#nt(t,e){let n=this.#k(t,e);return n.tag==="void"?(this.#e(t.pos,w.incompatibleTypes,"\'void\' type not allowed here"),A):n}#yr(t,e){switch(t.kind){case"Literal":switch(t.literalKind){case"int":return t.constant=X(t.value),V;case"char":return t.constant=Gn(t.value.charCodeAt(0)),Ce;case"boolean":return t.constant=Tt(t.value),gt;case"long":return t.constant=_t(t.value),Jt;case"double":return t.constant=ie(t.value),ft;case"float":return t.constant=pe(t.value),kt;case"string":return t.constant=vr(t.value),mt;case"null":return br;default:return this.#a(t.pos,`\'${t.literalKind}\' literals`),A}case"Name":return this.#Er(t);case"Parenthesized":{let n=this.#k(t.expression,e);return t.expression.constant&&(t.constant=t.expression.constant),n}case"FieldAccess":return this.#ns(t);case"MethodCall":{let n=this.#Mr(t,e);return this.#Fe(t.args),n}case"Unary":return this.#ni(t);case"IncDec":return this.#ri(t);case"Binary":return this.#ii(t);case"Assignment":return this.#ai(t);case"ArrayAccess":return this.#oi(t);case"NewArray":return this.#li(t);case"Cast":return this.#ci(t);case"This":return this.#wr(t);case"NewObject":{let n=this.#_r(t,e);return this.#Fe(t.args),n}case"Conditional":return this.#qr(t,e);case"SwitchExpression":return this.#Kn(t,e);case"Lambda":return this.#$n(t,e);case"MethodRef":return t.lambda?.method?e??A:this.#hs(t,e);case"InstanceOf":return this.#Tr(t);case"Super":return this.#Qn(t);case"ClassLiteral":return this.#gr(t)}}#gr(t){let e=this.#cn(t.target);if(!("kind"in e))return e.tag!=="error"&&this.#e(t.target.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${ss(t.target)??"?"}`,` location: class ${this.#o.displayName}`]),A;let n=s=>pt(Wt("Class"),[s]);if(e.symbol)return t.className=e.symbol.binaryName,t.isInterface=e.symbol.isInterface,n(tt(e.symbol));if(e.name==="String")return t.className="java.lang.String",n(mt);if(It[e.name]){let s=Wt(e.name);return t.className=s.qualifiedName,t.isInterface=s.isInterface,n(pt(s))}return e.name==="Object"||e.name==="System"||e.name==="Math"?(t.className=`java.lang.${e.name}`,pt(Wt("Class"))):(this.#a(t.pos,`the class literal ${e.name}.class`,!0),A)}#Yn(t,e){if(!e&&(this.#t||this.#g))return this.#te(t.selectPos,"non-static method getClass() cannot be referenced from a static context"),A;if(e||this.#Zt(),e&&st(e))return this.#e(t.selectPos,w.cantResolve,`${$(e)} cannot be dereferenced`),A;let n=Wt("Class");return t.libraryCall={native:"Object.getClass",isStatic:!1,params:[],returnsValue:!0,display:"Object.getClass()"},pt(n)}#Qn(t){return t.qualifier?this.#br(t,t.qualifier):this.#t?(this.#te(t.pos,"non-static variable super cannot be referenced from a static context"),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),A):this.#o.isInterface?(this.#a(t.pos,"\'super\' in an interface",!0),A):this.#o.superType??(this.#o.superclass?tt(this.#o.superclass):this.#o.librarySuperclass??G))}#br(t,e){let n=t.dotPos??t.pos,s=e.length===1?this.#Gt(e[0]):this.#An(this.#Sr(e,t.qualifierPos??t.pos));if(!s){let a=e[e.length-1];return It[a]||An.has(a)||this.#l.has(a)?(this.#a(t.qualifierPos??t.pos,`\'${a}.super\' of a library type`,!0),A):(this.#e(t.qualifierPos??t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${a}`,` location: class ${this.#o.displayName}`]),A)}let r=()=>(this.#e(n,w.cantResolve,`not an enclosing class: ${s.displayName}`),A);if(s.isInterface){if(this.#t||!this.#o.interfaces.includes(s))return r();let a=this.#o.interfaces.find(o=>o!==s&&Sn(o,s));return a?(this.#e(n,w.cantResolve,`bad type qualifier ${s.displayName} in default super call`,[` redundant interface ${s.displayName} is extended by ${a.displayName}`]),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),A):(t.interfaceSymbol=s,tt(s)))}if(s===this.#o){let a={...t};return delete a.qualifier,this.#Qn(a)}for(let a=this.#o.outer;a;a=a.outer)if(a===s)return this.#a(t.qualifierPos??t.pos,`\'${s.displayName}.super\' of an enclosing class`,!0),A;return r()}#Sr(t,e){let n={kind:"Name",identifier:t[0],depth:1,pos:e,start:e,end:e};for(let s of t.slice(1))n={kind:"FieldAccess",target:n,name:s,namePos:e,depth:1,pos:e,start:e,end:e};return n}#Tr(t){if(t.recordPattern){let r=this.#nt(t.expression);if(r.tag==="error")return A;if(!this.#b)return this.#a(t.recordPattern.pos,"pattern variables in field initializers"),A;let a=[];return this.#kn(t.recordPattern,r,!0,a)?(t.testedType=t.recordPattern.tested,t.patternBindings=a,gt):A}let e=this.#nt(t.expression),n=t.targetType.kind==="ClassType"&&!t.targetType.hasTypeArguments?this.#mt(t.targetType.names):null,s=n&&n.typeParams.length?pt(n):this.#U(t.targetType);if(e.tag==="error"||s.tag==="error")return A;if(st(e)||st(s))return st(s)?this.#e(t.targetType.pos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#e(t.expression.pos,w.incompatibleTypes,"unexpected type",[" required: reference",` found: ${$(e)}`]),A;if(s.tag==="library"&&s.args.some(r=>r.tag!=="wildcard"||r.bound!==null))return this.#a(t.targetType.pos,"instanceof with a generic type",!0),A;if(!ke(s,e))return this.#q(t.expression,e,s),A;if(t.testedType=s,t.binding){if(!this.#b)return this.#a(t.binding.pos,"pattern variables in field initializers"),A;t.binding.symbol=this.#Cn(t.binding.name,s,t.binding.pos,t.binding.isFinal)}return gt}#kn(t,e,n,s){let r=this.#xr(t,e,n,s);return r||this.#Zn(t,s),r}#Zn(t,e){if(t.kind==="RecordPattern")return t.components.forEach(n=>this.#Zn(n,e));t.symbol||t.name==="_"||(t.symbol=this.#Cn(t.name,A,t.namePos,t.isFinal),e.push(t.symbol))}#xr(t,e,n,s){if(t.kind==="TypePattern"){let h;if(t.type===null)h=e;else{let m=t.type.kind==="ClassType"&&!t.type.hasTypeArguments?this.#mt(t.type.names):null;if(h=m&&m.typeParams.length?pt(m):this.#U(t.type,!0),h.tag==="error")return!1;if(n&&(st(e)||st(h))||!n&&st(h)!==st(e)||st(h)&&!at(h,e))return this.#e(t.pos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]),!1;if(h.tag==="library"&&h.args.some(p=>p.tag!=="wildcard"||p.bound!==null))return this.#a(t.pos,"patterns of a parameterized type",!0),!1;if(!st(h)&&!ke(h,e))return this.#q(t,e,h),!1}return t.tested=h,t.unconditional=st(h)||K(W(e),W(h)),t.name!=="_"&&(t.symbol=this.#Cn(t.name,h,t.namePos,t.isFinal),s.push(t.symbol)),!0}let r=this.#U(t.type,!0);if(r.tag==="error")return!1;if(r.tag!=="class"||!r.symbol.isRecord)return this.#e(t.pos,w.syntax,`deconstruction patterns can only be applied to records, ${$(r)} is not a record`),!1;let a=r.symbol,o=r;if(a.typeParams?.length&&!r.args?.length){let h=e.tag==="class"?se(e,a):null;o=h?.args?.length?h:r}if(!ke(o,e))return this.#q(t,e,o),!1;let c=a.components,u=c.map(h=>Me(Ne(o,a,h.type)));if(c.length!==t.components.length){let h=t.components.map(m=>m.kind==="TypePattern"&&m.type===null?"var":$(this.#vr(m)));return this.#e(t.pos,w.syntax,"incorrect number of nested patterns",[` required: ${u.map($).join(",")}`,` found: ${h.join(",")}`]),!1}t.tested=o,t.accessors=c.map(h=>this.#wt(a,h.name).find(m=>!m.isStatic&&m.params.length===0));let d=!0;return t.components.forEach((h,m)=>{this.#kn(h,u[m],!1,s)||(d=!1)}),d}#vr(t){return t.type?this.#ms(t.type):G}#Cn(t,e,n,s){let r=this.#b;(this.#lt(t)||this.#Pn(t))&&this.#e(n,w.alreadyDefined,`variable ${t} is already defined in ${r.isConstructor?"constructor":"method"} ${this.#Ht(r)}`);let a={kind:"local",name:t,type:e,index:r.locals.length,slot:this.#c,isFinal:s,declPos:n,binding:!0};return this.#c+=Be(e),r.maxSlots=Math.max(r.maxSlots,this.#c),r.locals.push(a),a}#ft(t,e){switch(t.kind){case"Parenthesized":return this.#ft(t.expression,e);case"Unary":return t.operator==="!"?this.#ft(t.operand,!e):[];case"InstanceOf":return e?t.binding?.symbol?[t.binding.symbol]:t.patternBindings??[]:[];case"Binary":return t.operator==="&&"&&e?[...this.#ft(t.left,!0),...this.#ft(t.right,!0)]:t.operator==="||"&&!e?[...this.#ft(t.left,!1),...this.#ft(t.right,!1)]:[];default:return[]}}#Qt(t,e){if(!t.length)return e();this.#Pt();let n=this.#f[this.#f.length-1];for(let a of t)n.names.set(a.name,a);let s=e(),r=this.#c;return this.#Mt(),this.#c=r,s}#Ke(t){let e=this.#f[this.#f.length-1];for(let n of t)e.names.has(n.name)||this.#lt(n.name)||(e.names.set(n.name,n),this.#j.push(n))}#wr(t){return t.qualifier?this.#kr(t,t.qualifier):this.#t?(this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'this\' in the arguments of \'this(...)\'",!0),A):fe(this.#o))}#kr(t,e){let n=this.#Ie(e),s=0,r=this.#o;for(;r&&r!==n;)r=r.outer,s++;return!n||!r?(this.#e(t.pos,w.syntax,`not an enclosing class: ${e[e.length-1]}`),A):this.#t||!this.#sn(s)?(this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A):(this.#Zt(),s&&(t.outerHops=s),fe(n))}#Cr(t,e){let n=t.captures?.find(d=>d.local.name===e);if(n)return n.field;let s=this.#N.get(t);if(!s)return null;let r;for(let d=s.scopes.length-1;d>=0&&!r;d--)r=s.scopes[d].names.get(e);if(!r)return null;let a=t.declaration.pos,o={name:`val$${e}`,extraDims:0,init:null,pos:a,start:a,end:a},c={kind:"FieldDeclaration",modifiers:{keywords:[]},type:{kind:"VoidType",pos:a,start:a,end:a},declarators:[o],pos:a,start:a,end:a},u={kind:"field",name:`val$${e}`,type:r.type,owner:t,isStatic:!1,isFinal:!0,isPrivate:!0,access:"private",index:t.instanceCount++,order:t.fields.length,state:"done",declaration:c,declarator:o,capturedLocal:r};return t.fields.push(u),(t.captures??=[]).push({field:u,local:r}),u}#Er(t){let e=this.#lt(t.identifier);if(e)return e.captureOf&&this.#ne.push({local:e,pos:t.pos,top:this.#o.topLevel}),t.symbol=e,e.constant&&(t.constant=e.constant),e.type;let n=this.#Yt(t.identifier);if(n){let{field:r,hops:a}=n,o=this.#o;for(let u=0;u<a;u++)o=o.outer;if(r.isPrivate&&r.owner!==o&&!this.#Gs(r.owner,o))return this.#e(t.pos,w.cantResolve,`${r.name} has private access in ${r.owner.displayName}`),A;if(!r.isStatic){if(this.#t||!this.#sn(a))return this.#te(t.pos,`non-static variable ${r.name} cannot be referenced from a static context`),A;if(this.#Zt(),this.#g&&a===0)return this.#a(t.pos,"using the object\'s fields in the arguments of \'this(...)\'"),A}let c=this.#it??this.#St;return a===0&&c&&!this.#P&&!r.capturedLocal&&r.owner===c.owner&&r.isStatic===c.isStatic&&r.order>=c.order?(this.#e(t.pos,w.syntax,r===c?"self-reference in initializer":"illegal forward reference"),A):(t.symbol=r,a>0&&!r.isStatic&&(t.outerHops=a),r.capturedLocal&&this.#ne.push({local:r.capturedLocal,pos:t.pos,top:this.#o.topLevel,inner:!0}),this.#En(t,r,r.isStatic?void 0:fe(o)))}let s=this.#be(t);if(s==="error")return A;if(s){t.imported=s;let r=this.#ns(s);return s.type=r,s.constant&&(t.constant=s.constant),r}return this.#fe(t.identifier,t.pos)?A:(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.identifier}`,` location: class ${this.#o.displayName}`]),A)}#En(t,e,n){if(e.isFinal&&e.state==="pending"&&this.#Hn(e),e.constant&&(t.constant=e.constant),!n)return e.type;let s=Me(Ne(n,e.owner,e.type));return Ca(t,e.type,s),s}#cn(t){if(t.kind==="Name"&&t.staticOwner)return t.staticClass?(t.symbol={kind:"type",name:t.identifier,symbol:t.staticClass},{kind:"type",name:t.identifier,symbol:t.staticClass}):(t.symbol={kind:"type",name:t.identifier},{kind:"type",name:t.identifier,qualified:!0});if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)&&(this.#h(t.identifier,this.#Nt).length||this.#ye(t.identifier,"field").length))return this.#k(t);if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)){let e=t.identifier;if(this.#zn(e,t.pos))return A;let n=this.#Gt(e);if(n)return t.symbol={kind:"type",name:e,symbol:n},{kind:"type",name:e,symbol:n};let s=this.#Ye([e]);if(s)return t.symbol={kind:"type",name:e,symbol:s},{kind:"type",name:e,symbol:s};if(e==="System"||e==="String"||An.has(e)||It[e]&&this.#un(e))return t.symbol={kind:"type",name:e},{kind:"type",name:e};if(this.#l.get(e))return t.symbol={kind:"type",name:e},{kind:"type",name:e}}if(t.kind==="FieldAccess"){if(t.target.kind==="Name"&&Mt[t.name]===t.target.identifier&&!this.#lt(t.target.identifier)&&this.#un(t.target.identifier))return{kind:"type",name:t.name,qualified:!0};let e=ss(t.target);if(e?.startsWith("java.")&&!this.#lt("java")&&!this.#Yt("java")){if(It[t.name]===e&&!Mt[t.name]||e==="java.lang"&&(t.name==="Math"||t.name==="System"||t.name==="String"))return{kind:"type",name:t.name,qualified:!0};let o=e.slice(e.lastIndexOf(".")+1);if(Mt[t.name]===o&&It[o]===e.slice(0,e.lastIndexOf(".")))return{kind:"type",name:t.name,qualified:!0};if((Yn[e]??[]).includes(t.name))return this.#a(t.target.pos,`the class ${e}.${t.name}`,!0),A}let n=this.#ts(t.target);if(n!==null){let a=this.#Dt(n,t.name);return a?this.#Gn(a,t.pos)?(t.typeSymbol=a,{kind:"type",name:a.name,symbol:a}):A:(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${t.name}`,` location: package ${n}`]),A)}let s=this.#An(t.target),r=s?.membersByName.get(t.name);if(s&&r&&!s.fieldsByName.has(t.name))return t.typeSymbol=r,{kind:"type",name:r.name,symbol:r}}return this.#k(t)}#ts(t){let e=ss(t);if(e===null||!this.#G.has(e))return null;let n=t;for(;n.kind==="FieldAccess";)n=n.target;return n.kind!=="Name"||this.#lt(n.identifier)||this.#Yt(n.identifier)||this.#Gt(n.identifier)?null:e}#un(t){let e=It[t];return Mt[t]?this.#X.has(t):e==="java.lang"||this.#X.has(t)||e!==void 0&&this.#r.has(e)||this.#d.compact}#An(t){if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)){let e=this.#Gt(t.identifier);return e&&(t.symbol={kind:"type",name:t.identifier,symbol:e}),e}if(t.kind==="FieldAccess"){let e=this.#ts(t.target);if(e!==null){let r=this.#Dt(e,t.name);return r&&(t.typeSymbol=r),r}let n=this.#An(t.target),s=n?.membersByName.get(t.name);if(n&&s&&!n.fieldsByName.has(t.name))return t.typeSymbol=s,s}return null}#De(t,e){if(!t)return` location: class ${this.#o.displayName}`;let n=Q(t);return n.kind==="Name"&&n.symbol?.kind==="local"?` location: variable ${n.identifier} of type ${$(e)}`:n.kind==="Name"&&n.symbol?.kind==="field"?` location: variable ${n.identifier} of type ${$(e)}`:n.kind==="FieldAccess"&&(n.field&&n.field!=="length"||n.fieldSymbol)?` location: variable ${n.name} of type ${$(e)}`:` location: ${e.tag==="library"&&e.symbol.isInterface||e.tag==="class"&&e.symbol.isInterface?"interface":"class"} ${$(e)}`}#Oe(t,e,n,s=null){if(t.isPrivate)return t.owner.topLevel===this.#o.topLevel?!0:(this.#e(e,w.cantResolve,`${n} has private access in ${t.owner.displayName}`),!1);let r=this.#es(t,n,s);return r&&this.#e(e,w.cantResolve,r),r===null}#es(t,e,n=null){let s=t.access??"public";return s==="public"||s==="private"||t.owner.packageName===this.#o.packageName||s==="protected"&&this.#Ar(t,n)?null:s==="protected"?`${e} has protected access in ${t.owner.displayName}`:`${e} is not public in ${t.owner.displayName}; cannot be accessed from outside package`}#Ar(t,e){if(t.isConstructor)return e==="super";let n=(s,r)=>{for(let a=s;a;a=a.superclass)if(a===r)return!0;return!1};for(let s=this.#o;s;s=s.outer)if(n(s,t.owner)&&(t.isStatic||e===null||e==="super"||n(e,s)))return!0;return!1}#ns(t){let e=Q(t.target);if(e.kind==="Super"&&e.qualifier){if(this.#k(e).tag==="error")return A;if(e.interfaceSymbol)return this.#e(e.dotPos??e.pos,w.cantResolve,`not an enclosing class: ${e.interfaceSymbol.displayName}`),A}let n=this.#cn(t.target);if("kind"in n&&n.kind==="type"){if(n.symbol){let d=n.symbol,h=this.#Ee(d,t.name);return h?h.isPrivate&&h.owner!==d?(this.#e(t.pos,w.cantResolve,`${h.name} has private access in ${h.owner.displayName}`),A):h.isStatic?this.#Oe(h,t.pos,h.name)?(t.fieldSymbol=h,this.#En(t,h)):A:(this.#te(t.pos,`non-static variable ${h.name} cannot be referenced from a static context`),A):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,` location: class ${d.displayName}`]),A)}if(n.name==="System")return t.name==="out"||t.name==="err"?(t.field=t.name==="out"?"System.out":"System.err",Qi):t.name==="in"?(t.field="System.in",pt(te("InputStream"))):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`," location: class System"]),A);let a=Object.hasOwn(Ls,n.name)?Ls[n.name]:{},o=Object.hasOwn(a,t.name)?a[t.name]:void 0;if(o)return t.constant=o.constant,o.type;let c=It[n.name]?n.qualified?Wt(n.name)??null:this.#mt([n.name]):n.name==="String"&&!n.symbol?te("String"):null,u=c?.staticFields&&Object.hasOwn(c.staticFields,t.name)?c.staticFields[t.name]:void 0;return c&&u?(t.libraryField=`${c.name}.${t.name}`,u):(this.#a(t.pos,`the field ${n.name}.${t.name}`,!0),A)}let s=n,r=s.tag==="typevar"&&s.symbol?s.symbol.bounds.find(a=>a.tag==="class")??G:s;switch(r.tag){case"error":return A;case"class":{let a=this.#Ee(r.symbol,t.name);if(a){if(a.isPrivate&&a.owner!==r.symbol)return this.#e(t.pos,w.cantResolve,`${a.name} has private access in ${a.owner.displayName}`),A;let o=Q(t.target).kind;return this.#Oe(a,t.pos,a.name,o==="This"||o==="Super"?null:r.symbol)?(t.fieldSymbol=a,this.#En(t,a,a.isStatic?void 0:s)):A}break}case"library":{let a=r.symbol.instanceFields;if(a&&Object.hasOwn(a,t.name))return t.libraryField=`${r.symbol.name}#${t.name}`,a[t.name];break}case"null":return this.#e(t.pos,w.cantResolve,"<null> cannot be dereferenced"),A;case"array":if(t.name==="length")return t.field="length",V;break;default:if(st(s)||s.tag==="void")return this.#e(t.pos,w.cantResolve,`${$(s)} cannot be dereferenced`),A}return this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,this.#De(t.target,s),...Et([s])]),A}#ue(t){return t.map(e=>{let n=Q(e);if(n.kind==="MethodRef")return{tag:"lambda",arity:this.#We(n)?.params.length??-1,text:Cs(n)};if(n.kind==="Lambda")return{tag:"lambda",arity:n.params.length,text:Cs(n)};let s=this.#ss(e);if(s)return this.#st.add(e),{tag:"diamond",symbol:s,fromArgs:null};let r=n.kind==="NewObject"&&n.body&&n.classType.kind==="ClassType"&&n.classType.diamond?this.#mt(n.classType.names):null;if(r)return this.#st.add(e),{tag:"diamond",symbol:r,fromArgs:null};this.#u=e;let a=this.#nt(e),o=this.#L.get(n);if(!o||a.tag!=="library"||n.kind!=="MethodCall")return a;let c=new Map;return this.#he(o.method,o.types,c),{...a,args:a.args.map((u,d)=>{let h=o.method.returnType.tag==="library"?o.method.returnType.args[d]:void 0;if(!o.flags[d]||h?.tag!=="typevar")return u;let m=Ve([h],o.symbol,Oa(o.symbol,o.method,o.types.length));return{tag:"wildcard",bound:u,poly:{name:h.name,lows:c.get(h.name)??[],where:m}}})}})}#ss(t){if(t.kind!=="MethodCall")return null;let e;if(t.target){let a=Ee(t.target);if(!a||this.#lt(a[0])||this.#Yt(a[0]))return null;e=a.length===2&&Mt[a[1]]===a[0]&&this.#un(a[0])?Wt(a[1])??null:this.#mt(a)}else{let a=this.#p.size||this.#s.length?this.#h(t.name,this.#tt):[];if(a.length!==1||this.#pe(t.name))return null;e=this.#et(a[0])}if(!e)return null;let n=e.methods.filter(a=>a.name===t.name&&a.isStatic);if(!n.length||n.some(a=>!a.typeParams?.length))return null;let s=n[0].returnType;return s.tag!=="library"||n.some(a=>a.returnType.tag!=="library"||a.returnType.symbol!==s.symbol)?null:t.args.length===0||t.args.some(a=>{let o=Q(a);return o.kind==="Lambda"&&o.params.some(c=>!c.type)||o.kind==="MethodRef"&&(!this.#We(o)||this.#On(o))||this.#ss(o)!==null})?s.symbol:null}#Fe(t){for(let e of t)this.#st.has(e)&&(this.#st.delete(e),e.type=this.#k(e))}#Ft(t,e){return`${t}(${e.map($).join(",")})`}#Ir(t,e,n=fe(t)){let s=this.#wt(t,e).map(a=>{let o=c=>a.isStatic?c:Me(Ne(n,a.owner,c));return{owner:a.owner.displayName,name:a.name,params:a.params.map(o),returnType:o(a.returnType),method:a,...Ea(a)?{varargs:!0}:{}}}),r=$e[e];return r&&Object.hasOwn($e,e)&&!s.some(a=>a.params.length===r.params.length&&a.params.every((o,c)=>at(o,r.params[c])))&&s.push(r),s}#In(t,e,n){return!t.builtin||t.constructors.some(s=>s.params.length===e)?!1:(this.#a(n,`this ${t.name} constructor`,!0),!0)}#Or(t,e){if(!this.#oe(tt(t)))return null;let n=this.#wt(t,e.name);return(e.name==="getStackTrace"||e.name==="setStackTrace")&&!n.length?`the method Throwable.${e.name}()`:e.name==="printStackTrace"&&e.args.length&&!n.some(r=>r.params.length===e.args.length)?"printStackTrace to a stream":el[t.binaryName]?.includes(e.name)&&!n.length?`the method ${t.name}.${e.name}()`:null}#qe(t,e){let n=t.isEnum?"enum":t.isRecord?"record":"class",s=e?.tag==="class"?Un(e):new Map,r=e!==void 0&&Bn(e);return t.constructors.map(a=>({owner:t.displayName,ownerKind:n,name:t.name,params:a.params.map(o=>r?W(o):Kt(o,s)),returnType:xt,method:a,...Ea(a)?{varargs:!0}:{}}))}#_e(t,e){if(!t.expanded||!t.method)return;let n=t.params[t.params.length-1],s=n.element;return!Ln(n)&&!this.#Jt(t.method.declaration.modifiers,"SafeVarargs")&&this.#at(e,"unchecked",`unchecked generic array creation for varargs parameter of type ${$(n)}`,Et([n])),{from:t.params.length-1,element:s}}#Lr(t,e,n,s,r,a){let o=t.method?.typeParams;if(!o)return t;let c=o.map(h=>h.key),u=new Map,d=new Map;if(n){if(n.length!==o.length)return{...t,shown:t.params,problem:{reason:`wrong number of type arguments; required ${o.length}`,alone:!0}};o.forEach((h,m)=>u.set(h.key,n[m]))}else{ka(c,Aa(t,e),e,u,d);let h=[...d.keys()].filter(m=>!u.has(m));for(let[m,p]of d)u.has(m)||u.set(m,p.reduce(Ar));if(s&&(t.returnType.tag==="library"||t.returnType.tag==="class")){let m=new Map;bt(t.returnType,s,m);for(let p of h){let k=m.get(p);!k||k===Hn||k.tag==="wildcard"||k.tag==="typevar"&&!k.symbol||d.get(p).every(g=>K(g,k))&&u.set(p,k)}}r.forEach((m,p)=>{let k=Q(m),g=k.kind==="MethodRef"&&t.params[p]?Ps(Kt(t.params[p],u)):null;if(!g||k.kind!=="MethodRef")return;let O=this.#We(k,g.params[0]&&!ue(g.params[0],c)?g.params[0]:void 0);O&&(O.params.forEach((T,x)=>g.params[x]&&bt(g.params[x],qt(T)??T,u)),O.returnType.tag!=="void"&&bt(g.returnType,qt(O.returnType)??O.returnType,u))}),a&&o.some(m=>!u.has(m.key))&&this.#Nr(t.params,r,u,c),s&&t.returnType.tag!=="void"&&o.some(m=>!u.has(m.key))&&bt(t.returnType,s,u);for(let m of o){let p=u.get(m.key);if(!p||m.bounds.every(T=>K(p,Kt(T,u))))continue;let k=d.get(m.key)??[p],g=`inference variable ${m.name} has incompatible bounds`,O=k.length>1&&m.bounds.some(T=>ue(T,[m.key]))?[g,` equality constraints: ${k.map($).join(",")}`,` lower bounds: ${[...k].reverse().map($).join(",")}`]:[g,` upper bounds: ${m.bounds.map($).join(",")}`,` lower bounds: ${k.map($).join(",")}`];return{...t,shown:t.params,problem:{reason:O.join(`\n`)}}}}for(let h of o)u.has(h.key)||u.set(h.key,W(me(h)));return{...t,shown:t.params,params:t.params.map(h=>Kt(h,u)),returnType:Kt(t.returnType,u)}}#Nr(t,e,n,s){let r=a=>ue(a,s.filter(o=>!n.has(o)));e.forEach((a,o)=>{let c=Q(a);if(!t[o])return;if(c.kind==="MethodRef"&&c.name==="new"&&!c.arrayType&&c.target){let m=this.#dn(Kt(t[o],n)),p=Ee(c.target),k=p&&!this.#lt(p[0])?this.#mt(p):null;k&&!("problem"in m)&&!m.params.some(r)&&r(m.returnType)&&bt(m.returnType,{tag:"library",symbol:k,args:k.typeParams.map(()=>G)},n);return}if(c.kind!=="Lambda"||c.method)return;let u=Kt(t[o],n),d=this.#dn(u);if("problem"in d||d.params.some(r)||!r(d.returnType))return;this.#$n(c,u,s.filter(m=>!n.has(m)));let h=c.method?.returnType;h&&h.tag!=="error"&&h.tag!=="void"&&bt(d.returnType,qt(h)??h,n)})}#$r(t){let e=0;for(let n=this.#o;n;n=n.outer,e++)if(this.#wt(n,t).length||Object.hasOwn($e,t))return{owner:n,hops:e};return{owner:this.#o,hops:0}}#Pr(t,e){return t.tag!=="class"?null:Le(t).find(n=>n.symbol.methods.some(s=>s.name===e&&!s.isStatic))??null}#Mr(t,e){let n=null,s=t.target===null?this.#ue(t.args):null;if(s&&(this.#p.size||this.#s.length||this.#d.programStatic.length)&&!s.some(m=>m.tag==="error")&&!this.#ie(t,s))return A;t.target&&(n=this.#cn(t.target));let r=s??this.#ue(t.args);if(r.some(m=>m.tag==="error")||n&&"tag"in n&&n.tag==="error")return A;let a=t.typeArguments?t.typeArguments.map(m=>this.#Ge(m)):null;if(a?.some(m=>m.tag==="error"))return A;let o=n;if(n&&"tag"in n&&n.tag==="typevar"&&n.symbol){let m=k=>k.tag==="class"&&this.#wt(k.symbol,t.name).length>0||k.tag==="library"&&k.symbol.methods.some(g=>g.name===t.name),p=n.symbol.bounds.find(m)??(Object.hasOwn($e,t.name)?G:null);if(!p)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,this.#De(t.target,n),...Et([n,...r])]),A;n=p}if(t.name==="getClass"&&!r.length&&(n===null||"tag"in n)&&!(n===null&&this.#wt(this.#o,"getClass").length))return this.#Yn(t,n);let c=n===null?this.#o.isEnum:"tag"in n&&n.tag==="class"&&n.symbol.isEnum;if(t.name==="getDeclaringClass"&&!r.length&&c){let m=this.#Yn(t,n);return t.libraryCall&&(t.libraryCall.native="Enum.getDeclaringClass",t.libraryCall.display=`${n?.symbol.binaryName??this.#o.binaryName}.getDeclaringClass()`),m}let u=n!==null&&"kind"in n&&n.symbol!==void 0,d=n!==null&&"tag"in n&&n.tag==="class";if(!n||u||d){let m,p=0;if(n?m=n.symbol:{owner:m,hops:p}=this.#$r(t.name),$s.has(t.name)&&!this.#wt(m,t.name).length)return this.#a(t.selectPos,`the method Object.${t.name}()`,!0),A;let k=this.#Or(m,t);if(k)return this.#a(t.selectPos,k,!0),A;let g=d?o:fe(m),O=this.#Ir(m,t.name,g),T=O.map(P=>this.#Lr(P,r,a,e,t.args,O.length===1)),x=t.target?Q(t.target):null,v=x?.kind==="Super"?x.interfaceSymbol:void 0;if(!T.length&&v)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`]),A;let R=P=>P.params.length===r.length&&P.params.every((B,N)=>Ht(B,r[N])||Re(B,r[N]))||P.varargs===!0&&r.length>=P.params.length-1,L=!u&&!v&&!T.some(R)?this.#Pr(g,t.name):null;if(L){if(!n){if(p>0)return this.#a(t.selectPos,"calling an enclosing class\'s library methods by simple name",!0),A;if(this.#t)return this.#te(t.selectPos,`non-static method ${t.name}(${L.symbol.methods.find(B=>B.name===t.name).params.map($).join(",")}) cannot be referenced from a static context`),A;let P={kind:"This",depth:0,pos:t.pos,start:t.pos,end:t.pos};this.#k(P),t.target=P}return this.#Ue(t,L.symbol,L,r,e)}if(!T.length){let P=this.#Ks(m,t.name);if(P)return this.#e(t.selectPos,w.cantResolve,`${t.name}(${P.params.map($).join(",")}) has private access in ${P.owner.displayName}`),A;if(!n&&this.#fe(t.name,t.selectPos))return A;let B=u?` location: class ${m.displayName}`:n?this.#De(t.target,n):` location: class ${this.#o.displayName}`;return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,B,...Et([...d?[n]:[],...r])]),A}let C=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},T,r,"method");if(!C)return A;let M=C.method?C.method.isStatic:!1;if(v&&M)return this.#e(t.pos,w.cantResolve,"illegal static interface method call",[` the receiver expression should be replaced with the type qualifier \'${v.displayName}\'`]),A;let _=u||!n&&(this.#t||!this.#sn(p));if(!M&&_)return this.#te(t.selectPos,`non-static method ${t.name}(${C.params.map($).join(",")}) cannot be referenced from a static context`),A;if(!M&&!n&&this.#Zt(),!M&&!n&&this.#g&&p===0)return this.#a(t.selectPos,"calling the object\'s methods in the arguments of \'this(...)\'"),A;let j=t.target!==null&&Q(t.target).kind==="Super";if(C.method){if(!this.#Oe(C.method,t.selectPos,`${t.name}(${C.params.map($).join(",")})`,d&&!j&&t.target&&Q(t.target).kind!=="This"?m:null))return A;if(j&&C.method.isAbstract)return this.#e(t.selectPos,w.syntax,`abstract method ${this.#Ht(C.method)} in ${C.method.owner.displayName} cannot be accessed directly`),A;if(u&&C.method.isStatic&&C.method.owner.isInterface&&C.method.owner!==m)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,` location: class ${m.displayName}`]),A;if(!this.#ls(t,C,r))return A;t.method=C.method;let P=this.#_e(C,t.pos);P&&(t.varargs=P);let B=C.method.params;d&&Bn(o)&&B.some(N=>rs([N]).some(F=>F.ofClass))&&this.#at(t.pos,"unchecked",`unchecked call to ${this.#Ht(C.method)} as a member of the raw type ${$(o)}`,Et(B)),this.#rs(t.pos,`method ${t.name} in ${m.isInterface?"interface":"class"} ${m.displayName}`,B,C.params,r,t.args,Et),this.#hn(t.args,B.map(W)),t.qualifier=C.method.isStatic?C.method.owner.binaryName:m.binaryName}else t.objectMethod=C.objectMethod,t.qualifier=m.isInterface&&!j?m.binaryName:"Object";return j&&(t.isSuper=!0),!n&&p>0&&!M&&(t.outerHops=p),C.method&&Ca(t,C.method.returnType,C.returnType),C.returnType}if("kind"in n&&n.name==="IO")return this.#Xr(t,r);if("kind"in n&&n.name==="Math"&&Object.hasOwn(Wn,t.name))return this.#Wr(t,r);if("kind"in n&&!n.symbol&&(n.name==="Math"||n.name==="String"))return this.#Ue(t,te(n.name),null,r,e);if("kind"in n&&this.#l.has(n.name))return this.#a(t.target.pos,`the class ${this.#l.get(n.name)}`,!0),A;if("kind"in n&&It[n.name]&&(n.qualified||this.#un(n.name)))return this.#Ue(t,Wt(n.name),null,r,e);if("kind"in n)return n.name==="System"&&!n.symbol?ma.has(t.name)?this.#Ue(t,te("System"),null,r,e):(this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`," location: class System"]),A):(this.#a(t.selectPos,`${n.name}.${t.name}()`,!0),A);let h=n.tag==="diamond"?this.#Ln(n):n;switch(h.tag){case"null":return this.#e(t.selectPos,w.cantResolve,"<null> cannot be dereferenced"),A;case"printstream":return this.#ei(t,h,r);case"library":return this.#Ue(t,h.symbol,h,r,e);case"string":{let m=Object.hasOwn(Qn,t.name)?Qn[t.name]:void 0;if(m){let p=this.#ct({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.stringMethod=t.name,p.returnType):A}if(qo.has(t.name)){let p=te("String");return this.#Ue(t,p,pt(p),r,e)}break}case"object":case"array":{let m=Object.hasOwn($e,t.name)?$e[t.name]:void 0;if(m){let p=this.#ct({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.objectMethod=p.objectMethod,t.qualifier="Object",Q(t.target).kind==="Super"&&(t.isSuper=!0),p.returnType):A}if(h.tag==="array"&&t.name==="clone"&&!r.length)return te("String"),t.libraryCall={native:"Array.clone()",isStatic:!1,params:[],returnsValue:!0,display:`${Ft(h)}.clone()`},h;if($s.has(t.name)||h.tag==="array"&&Xo.has(t.name))return this.#a(t.selectPos,h.tag==="array"?`the array method ${t.name}()`:`the method Object.${t.name}()`,!0),A;break}default:if(st(h)||h.tag==="void")return this.#e(t.selectPos,w.cantResolve,`${$(h)} cannot be dereferenced`),A}return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,this.#De(t.target,h)]),A}#Ue(t,e,n,s,r){let a=n?n.args:[],o=n!==null&&!n.args.length&&e.typeParams.length>0,c=e.methods.filter(P=>P.name===t.name);if(!c.length&&(e.unsupported.has(t.name)||$s.has(t.name)))return this.#a(t.selectPos,`the ${e.name} method ${t.name}()`,!0),A;if(!c.length){let P=n?this.#De(t.target,n):` location: class ${e.name}`;return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,s)}`,P]),A}let u=t.typeArguments?t.typeArguments.map(P=>this.#Ge(P)):null,d=P=>u!==null&&u.length===(P.typeParams?.length??0)&&u.length>0,h=c.map(P=>{let B=[...P.isStatic?[]:e.typeParams,...P.typeParams??[]],N=u&&u.length===(P.typeParams?.length??0)?u:this.#Jr(P,s),F=[...P.isStatic?[]:a.map(bl),...N],q=[...P.isStatic?[]:a.map(Me),...N],Z=o&&!P.isStatic;return{owner:P.owner,name:P.name,params:P.params.map(ne=>Z?W(ne):wt(ne,B,F)),returnType:Z?W(P.returnType):wt(P.returnType,B,q),library:P,...P.varargs?{varargs:!0}:{}}}),m=this.#ct({pos:t.selectPos,name:t.name,imported:fa(t),args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},h,s,"method");if(!m)return A;let p=m.library,k=this.#he(p,s),g=!o&&s.some((P,B)=>p.params[B]!==void 0&&Re(p.params[B],P));if(p.comparableParams&&!g&&p.comparableParams.some(P=>k.has(P)&&!ja(k.get(P))))return this.#a(t.selectPos,`${e.name}.${t.name}() of elements that are not Comparable`,!0),A;if(!p.native)return this.#a(t.selectPos,`${e.name}.${t.name}(${p.params.map(Je).join(", ")})`,!0),A;if(!p.isStatic&&!n)return this.#e(t.selectPos,w.cantResolve,`non-static method ${t.name}(${m.params.map($).join(",")}) cannot be referenced from a static context`),A;let O=!o&&p.typeParams?.length&&!d(p)&&t.args.some(P=>["Lambda","MethodRef"].includes(Q(P).kind)||this.#st.has(P)),T=t.args.filter(P=>this.#st.has(P)),x=this.#m.items.length,v=O?this.#Rr(p,e,a,t.args,s,r,m.params):null;if(O&&this.#os(t,m,p,e,a,s,x))return A;let R=!O&&p.isStatic&&p.typeParams?.length&&!d(p)&&r?this.#is(t,e,p,s,r):null;if(!O&&!r&&p.isStatic&&p.typeParams?.length&&!d(p)&&p.returnType.tag==="library"){let P=new Map;this.#he(p,s,P);let B=p.returnType.args.map(N=>N.tag==="typevar"&&!N.symbol&&P.has(N.name));B.some(Boolean)&&this.#L.set(t,{flags:B,symbol:e,method:p,types:s})}if(R==="error")return A;let L=R?p.typeParams.map(P=>R.get(P)??G):[];if(R&&(m.params=m.params.map((P,B)=>wt(p.params[Math.min(B,p.params.length-1)],p.typeParams,L))),v||p.typeParams?.length){if(this.#de(t.args,v?v.params:m.params),p.typeParams?.length&&this.#os(t,m,p,e,a,s,x))return A}else if(!this.#ls(t,m,s))return A;let C=t.target?Q(t.target).kind:null;if(p.isProtected&&!(C==="This"||C==="Super"))return this.#e(t.selectPos,w.cantResolve,`${p.name}(${p.params.map($).join(",")}) has protected access in ${e.name}`,Ve(p.params,e,p)),A;t.libraryCall=this.#Xe(p,n??pt(e),m.params),u||(t.libraryMethod={method:p,symbol:e,classArgs:a}),m.expanded&&(t.libraryCall.varargsFrom=m.params.length-1),C==="Super"&&(t.libraryCall.onBase=!0);let M=P=>Ve(P,e,p);if(o&&!p.isStatic&&p.params.some(P=>ue(P,null))&&this.#at(t.pos,"unchecked",`unchecked call to ${p.name}(${p.params.map($).join(",")}) as a member of the raw type ${e.name}`,M(p.params)),this.#rs(t.pos,`method ${p.name} in ${e.isInterface?"interface":"class"} ${e.name}`,p.params,m.params,s,t.args,M),this.#hn(t.args,p.params.map(W)),o)return Me(m.returnType);if(g)return W(p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a));let _=d(p)?m.returnType:R?wt(p.returnType,p.typeParams,L):v?.returnType??this.#as(p,e,a,s,r)??m.returnType;if(p.typeParams?.length&&T.length&&!d(p)){let P=new Map(v?.bound??this.#he(p,s)),B=p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a);if(r?.tag==="library"&&B.tag==="library"){let N=Dt(B,r.symbol);N&&N.args.forEach((F,q)=>ge(r.args[q])&&bt(F,ge(r.args[q]),P))}t.args.forEach((N,F)=>T.includes(N)&&N.type&&bt(p.params[Math.min(F,p.params.length-1)],N.type,P)),_=this.#as(p,e,a,s,r,P)??_}let j=_.tag==="typevar"&&!_.symbol?G:Me(_);return p.returnType.tag==="typevar"&&yl(j)&&(t.genericCast=W(j)),j}#rs(t,e,n,s,r,a,o){let c=r.map((u,d)=>s[d]!==void 0&&(!Ht(s[d],u)||n[d]!==void 0)&&Re(n[d]??s[d],u));c.some(Boolean)&&(this.#at(t,"unchecked",`unchecked method invocation: ${e} is applied to given types`,[` required: ${n.map($).join(",")}`,` found: ${r.map($).join(",")}`,...o([...n,...r])]),c.forEach((u,d)=>{u&&this.#at(a[d].pos,"unchecked","unchecked conversion",[` required: ${$(n[d])}`,` found: ${$(r[d])}`,...o([n[d],r[d]])])}))}#hn(t,e){t.forEach((n,s)=>{e[Math.min(s,e.length-1)]?.tag==="object"&&delete Q(n).genericCast})}#Rr(t,e,n,s,r,a,o){let c=t.typeParams,u=C=>t.isStatic?C:Xt(C,e.typeParams,n),d=C=>u(t.params[Math.min(C,t.params.length-1)]),h=this.#he(t,r),m=C=>ue(C,c.filter(M=>!h.has(M))),p=(C,M)=>{let _=M.params[0]&&!m(M.params[0])?M.params[0]:void 0;if(!_&&this.#On(C))return!1;let j=this.#We(C,_);return j&&(j.params.forEach((P,B)=>M.params[B]&&bt(M.params[B],P,h)),j.returnType.tag!=="void"&&bt(M.returnType,qt(j.returnType)??j.returnType,h)),!0},k=[];s.forEach((C,M)=>{let _=Q(C),j=Ps(d(M));j&&(_.kind==="MethodRef"?p(_,j)||k.push(M):_.kind==="Lambda"&&_.params.length&&_.params.every(P=>P.type)&&_.params.forEach((P,B)=>{let N=this.#U(P.type);N.tag!=="error"&&j.params[B]&&bt(j.params[B],N,h)}))});let g=u(t.returnType);if(a?.tag==="library"&&g.tag==="library"){let C=Dt(g,a.symbol);C&&C.args.forEach((M,_)=>ge(a.args[_])&&bt(M,ge(a.args[_]),h))}for(let C of k){let M=c.filter(j=>h.has(j)),_=Ps(Xt(d(C),M,M.map(j=>h.get(j))));_&&p(Q(s[C]),_)}let O=()=>c.filter(C=>h.has(C)),T=C=>Xt(d(C),O(),O().map(M=>h.get(M)));s.forEach((C,M)=>{this.#st.has(C)&&(this.#st.delete(C),C.type=this.#k(C,T(M)),C.type.tag!=="error"&&bt(d(M),C.type,h))});let x=new Map;s.forEach((C,M)=>{let _=Q(C);if(_.kind==="Lambda"?_.method:_.kind!=="MethodRef"||_.lambda)return;let j=T(M),P=Ps(j);if(!P||P.params.some(m)||!m(P.returnType))return;let B;_.kind==="Lambda"?(this.#$n(_,j,!0),B=_.method?.returnType):_.kind==="MethodRef"&&(this.#hs(_,j,!0),B=_.lambda?.method?.returnType),B?.tag==="diamond"&&P.returnType.tag==="typevar"?x.set(P.returnType.name,B):B&&B.tag!=="error"&&B.tag!=="void"&&bt(P.returnType,qt(B)??B,h)});for(let[C,M]of x){if(h.has(C))continue;let _=t.typeParamBounds?.[C],j=c.filter(N=>h.has(N)),P=_?Xt(u(_),j,j.map(N=>h.get(N))):void 0,B=Ms(M.symbol,P);h.set(C,pt(M.symbol,M.symbol.typeParams.map(N=>B.get(N)??G)))}let v=c.map(C=>h.get(C)??G),R=C=>wt(u(C),c,v);return{params:o.map((C,M)=>R(t.params[Math.min(M,t.params.length-1)])),returnType:R(t.returnType),bound:h}}#On(t){if(!t.target||t.name==="new"||t.arrayType)return!1;let e=Ee(t.target);if(!e||this.#lt(e[0])||this.#Yt(e[0]))return!1;let n=this.#Ie(e);return n!==null&&(n.typeParams?.length??0)>0&&this.#wt(n,t.name).some(s=>!s.isStatic)}#We(t,e){if(t.arrayType){let c=this.#U(t.arrayType);return c.tag==="error"?null:{params:[V],returnType:c}}if(!t.target||t.name==="new")return null;let n=Ee(t.target);if(!n||this.#lt(n[0])||this.#Yt(n[0]))return null;let s=this.#Ie(n);if(s){let c=this.#wt(s,t.name);if(c.length!==1||c[0].declaration.params.some(d=>d.varargs)||c[0].typeParams?.length)return null;let u=c[0];if(u.isStatic)return{params:u.params,returnType:u.returnType};if(s.typeParams?.length&&e){let d=se(e,s);if(!d?.args?.length)return null;let h=m=>Me(Ne(d,u.owner,m));return{params:[d,...u.params.map(h)],returnType:h(u.returnType)}}return{params:[tt(s),...u.params],returnType:u.returnType}}if(n.length===1&&n[0]==="String"){if(Object.hasOwn(Qn,t.name))return{params:[mt,...Qn[t.name].params],returnType:Qn[t.name].returnType};let c=te("String").methods.filter(u=>u.name===t.name);return c.length!==1||c[0].varargs?null:{params:c[0].isStatic?c[0].params:[mt,...c[0].params],returnType:c[0].returnType}}let r=this.#mt(n);if(!r)return null;let a=r.methods.filter(c=>c.name===t.name);if(a.length!==1||a[0].varargs||a[0].typeParams?.length||r.typeParams.length)return null;let o=a[0];return{params:o.isStatic?o.params:[pt(r),...o.params],returnType:o.returnType}}#he(t,e,n){let s=new Map,r=new Map,a=(u,d)=>{if(u.tag==="typevar"&&!u.symbol&&t.typeParams?.includes(u.name)&&d&&d.tag!=="wildcard"){if(d.tag==="null"||d.tag==="diamond"||d.tag==="lambda"||d.tag==="error"||d.tag==="typevar"&&!d.symbol)return;let h=nt(d)?Nr(d):qt(d);h&&r.set(u.name,[...r.get(u.name)??[],h]);return}bt(u,d,s)},o=t.params,c=t.varargs?o.length-1:o.length;for(let u=0;u<c;u++)a(o[u],e[u]);if(t.varargs){let u=o[o.length-1],d=e.slice(c);if(d.length===1&&d[0].tag==="array"&&nt(d[0].element))bt(u,d[0],s);else for(let m of d)a(u.element,m)}for(let[u,d]of r)s.has(u)||(s.set(u,d.reduce(Ar)),n?.set(u,d));return s}#is(t,e,n,s,r,a=!1){let o=n.returnType;if(r.tag!=="library"||o.tag!=="library")return null;let c=Dt(o,r.symbol);if(!c)return null;let u=new Map,d=this.#he(n,s,u),h=!1;for(let[m,p]of c.args.entries()){let k=r.args[m];if(p.tag!=="typevar"||p.symbol||!u.has(p.name)||!k||k.tag==="wildcard"||k.tag==="typevar"&&!k.symbol)continue;let g=u.get(p.name);if(g.some(O=>!K(O,k))){if(a)return null;let O=g.filter((T,x)=>g.findIndex(v=>at(v,T))===x);return this.#e(t.pos,w.incompatibleTypes,`incompatible types: inference variable ${p.name} has incompatible bounds`,[` equality constraints: ${$(k)}`,` lower bounds: ${[...O].reverse().map($).join(",")}`,...Ve([p],e,Oa(e,n,s.length))]),"error"}at(d.get(p.name),k)||(d.set(p.name,k),h=!0)}return h?d:null}#Jr(t,e){if(!t.typeParams)return[];let n=this.#he(t,e);return t.typeParams.map(s=>n.get(s)??G)}#as(t,e,n,s,r,a){if(!t.typeParams)return null;let o=a??this.#he(t,s),c=t.isStatic?t.returnType:Xt(t.returnType,e.typeParams,n);if(t.typeParams.every(m=>o.has(m)))return a?wt(c,t.typeParams,t.typeParams.map(m=>o.get(m))):null;if(r?.tag==="library"&&c.tag==="library"){let m=Dt(c,r.symbol);m&&m.args.forEach((p,k)=>ge(r.args[k])&&bt(p,ge(r.args[k]),o))}r&&c.tag==="typevar"&&!c.symbol&&t.typeParams.includes(c.name)&&!o.has(c.name)&&nt(r)&&o.set(c.name,r);let u=t.typeParams.map(m=>o.get(m)??G),d=wt(c,t.typeParams,u),h=t.typeParams.filter(m=>!o.has(m));if(!r&&h.length&&c.tag==="library"&&c.args.some(m=>m.tag==="typevar"&&h.includes(m.name))){let m=c.args.every(p=>p.tag==="typevar"&&h.includes(p.name))?null:d.args;return{tag:"diamond",symbol:c.symbol,fromArgs:m}}return d}#Xe(t,e,n){let s=e.tag==="library"?wa(e.symbol):$(e),r=t.name==="<init>"?"<init>":t.name,a=t.isStatic||t.name==="<init>"?0:1,o=0;return t.params.forEach((c,u)=>{(c.tag==="library"&&!c.symbol.functional&&c.symbol.name!=="Comparator"||t.name==="equals"&&u===0)&&(o|=1<<u+a)}),{...o?{unwrap:o,unwrapCalls:Zo[t.native]??tl}:{},native:t.native,isStatic:t.isStatic,params:n,returnsValue:t.name==="<init>"||t.returnType.tag!=="void",display:`${s}.${r}(${t.params.map(Je).join(", ")})`,...t.throws?{throws:t.throws}:{}}}#Ln(t){return pt(t.symbol,t.fromArgs??t.symbol.typeParams.map(()=>G))}#os(t,e,n,s,r,a,o){let c=this.#m.items.slice(o),u=t.args.map(Q).filter(N=>N.kind==="Lambda"),d=c.findIndex(N=>N.severity==="error"&&kr.test(N.message)&&u.some(F=>N.offset!==void 0&&N.offset>=F.start&&N.offset<=F.end));if(d<0)return!1;let h=c[d],m=t.args.findIndex(N=>h.offset>=N.start&&h.offset<=N.end);this.#m.items.splice(o+d,1);let p=h.message.replace(/^incompatible types: /,""),k=(h.details??[]).map(N=>` ${N.trimStart()}`),g=[`(argument mismatch; ${p}`,...k];g[g.length-1]+=")";let O=wn(n,s),T=new vn,x=n.typeParams,v=n.params.map(N=>n.isStatic?N:Xt(N,s.typeParams,r)),R=N=>{let F=[],q=Z=>{Z.tag==="typevar"&&!Z.symbol&&x.includes(Z.name)?F.push(Z.name):Z.tag==="array"?q(Z.element):Z.tag==="wildcard"&&Z.bound?q(Z.bound):Z.tag==="library"&&Z.args.forEach(q)};return q(N),F},L=v[Math.min(m,v.length-1)],C=new Set(v.filter((N,F)=>F!==m).flatMap(R));if(R(L).every(N=>C.has(N))){for(let F of x)T.add({name:F,decl:O});let N=x.map(F=>T.label({name:F,decl:O})).join(",");return this.#e(t.pos,w.incompatibleTypes,`incompatible types: cannot infer type-variable(s) ${N}`,[...g.map(F=>` ${F}`),...Et([],T.entries())]),!0}let _=s.methods.filter(N=>N.name===t.name&&N.isStatic===n.isStatic&&N.native!=="");if(_.length>1){let N=_.map(q=>wn(q,s));for(let q of N){for(let Z of q.method.typeParams??[])T.add({name:Z,decl:q});for(let Z of q.method.params)T.visit(Z,q)}let F=[];for(let q of N){let Z=q.method,ne=Z.typeParams??[];F.push(` method ${e.owner}.${ne.length?`<${ne.map(it=>T.label({name:it,decl:q})).join(",")}>`:""}${Z.name}(${T.params(q)}) is not applicable`);let rt=(Z===n?[`cannot infer type-variable(s) ${ne.map(it=>T.label({name:it,decl:q})).join(",")}`,...g.map(it=>` ${it}`)].join(`\n`):$a({owner:e.owner,name:Z.name,params:Z.params,returnType:Z.returnType,library:Z,...Z.varargs?{varargs:!0}:{}},q,a,T)??"actual and formal argument lists differ in length").split(`\n`);F.push(` (${rt[0]}${rt.length>1?"":")"}`,...rt.slice(1).map((it,D,vt)=>`${it.trimStart().startsWith("(")?" ":" "}${it.trimStart()}${D===vt.length-1?")":""}`))}return this.#e(t.selectPos,w.cantResolve,`no suitable method found for ${this.#Ft(t.name,a)}`,[...F,...Et([],T.entries())]),!0}for(let N of x)T.add({name:N,decl:O});for(let N of v)T.visit(N,O);let j=v.map(N=>T.render(N,O)).join(","),P=x.map(N=>T.label({name:N,decl:O})).join(","),B=k.some(N=>/ cannot be converted to /.test(N));return this.#e(B?t.pos:t.selectPos,w.cantResolve,`method ${t.name} in ${Rs(e).text} cannot be applied to given types;`,[` required: ${j}`,` found: ${en(a)}`,` reason: cannot infer type-variable(s) ${P}`,...g.map(N=>` ${N}`),...Et([],T.entries())]),!0}#ls(t,e,n){let s=this.#m.items.length;this.#de(t.args,e.params);let r=this.#m.items.slice(s),a=t.args.map(Q).filter(T=>T.kind==="Lambda"),o=r.findIndex(T=>T.severity==="error"&&kr.test(T.message)&&a.some(x=>T.offset!==void 0&&T.offset>=x.start&&T.offset<=x.end));if(o<0)return!0;let c=r[o],u=a.find(T=>c.offset>=T.start&&c.offset<=T.end);this.#m.items.splice(s+o,1);let d=c.message.replace(/^incompatible types: /,""),h=(c.details??[]).map(T=>` ${T}`),m=u.params.length>0&&u.params.some(T=>!T.type),p=d==="unexpected return value"&&!m?["argument mismatch; bad return type in lambda expression"," unexpected return value"]:[`argument mismatch; ${d}`,...h],k=h.some(T=>/ cannot be converted to /.test(T)),g=e.shown??e.params,O=Rs(e);return this.#e(k?t.pos:t.selectPos,w.cantResolve,`method ${t.name} in ${O.text} cannot be applied to given types;`,[` required: ${en(g)}`,` found: ${en(n)}`,` reason: ${p[0]}`,...p.slice(1),...Et([...g,...n],O.where)]),!1}#de(t,e){t.forEach((n,s)=>{let r=Q(n),a=r.kind==="MethodCall"?this.#L.get(r):void 0;if(a&&r.kind==="MethodCall"){this.#L.delete(r);let d=e[Math.min(s,e.length-1)],h=d?this.#is(r,a.symbol,a.method,a.types,d,!0):null;if(h&&h!=="error"){let m=a.method.typeParams.map(k=>h.get(k)??G),p=wt(a.method.returnType,a.method.typeParams,m);r.type=p,n!==r&&(n.type=p),r.libraryCall&&(r.libraryCall.params=r.libraryCall.params.map((k,g)=>wt(a.method.params[Math.min(g,a.method.params.length-1)],a.method.typeParams,m)))}return}if(this.#st.has(n)){this.#st.delete(n),n.type=this.#k(n,e[Math.min(s,e.length-1)]);return}let o=Q(n).kind;if(o==="Lambda"||o==="MethodRef"){this.#k(n,e[s]);return}if(n.kind==="NewObject"&&n.openDiamond){let{symbol:d,bound:h}=n.openDiamond;delete n.openDiamond;let m=Er(d,e[Math.min(s,e.length-1)]);n.type=tt(d,d.typeParams.map(p=>h.get(p.key)??m.get(p.key)??W(me(p))));return}let c=n.type;if(c?.tag!=="diamond")return;let u=Ms(c.symbol,e[s]);n.type=pt(c.symbol,c.symbol.typeParams.map((d,h)=>u.get(d)??c.fromArgs?.[h]??G))})}#Nn(t,e,n){let s=t.symbol,r=s.constructors.map(c=>({owner:s.name,name:s.name,params:c.params.map(u=>wt(u,s.typeParams,t.args)),returnType:xt,library:c,...c.varargs?{varargs:!0}:{}})),a=this.#ct({pos:n,name:s.name},r,e,"constructor");if(!a)return null;let o=a.library;return o.native?a.expanded?(this.#a(n,`a variable-arity constructor of ${s.name} as a superclass constructor`,!0),null):{candidate:a,call:this.#Xe({...o,name:"<init>"},pt(s),a.params)}:(this.#a(n,`the constructor ${s.name}(${o.params.map(Je).join(", ")})`,!0),null)}#jr(t,e,n){let s=e.tag==="library"||e.tag==="diamond"?e.symbol:null;if(!s)return A;let r=this.#ue(t.args);if(r.some(T=>T.tag==="error"))return A;if(s.isInterface||s.isAbstract||s.name==="Number")return this.#e(t.pos,w.cantResolve,`${s.name} is abstract; cannot be instantiated`),A;if(!s.constructors.length)return this.#a(t.pos,`creating ${nn(s.name)} with \'new\'`,!0),A;let a=e.tag==="diamond";n===es&&(n=void 0);let o=a&&n?Ms(s,n,!0):new Map,c=T=>{if(!a)return e.args.slice();let x=new Map(o);return T.params.forEach((v,R)=>bt(v,r[R],x)),s.typeParams.map(v=>x.get(v)??G)},u=e.tag==="library"&&!e.args.length&&s.typeParams.length>0,d=s.constructors.map(T=>{let x=c(T);return{owner:s.name,name:s.name,params:T.params.map(v=>u?W(v):wt(v,s.typeParams,x)),returnType:xt,library:T,...T.varargs?{varargs:!0}:{}}}),h=this.#m.items.length,m=this.#ct({pos:t.pos,name:s.name,args:t.args},d,r,"constructor");if(!m)return a&&this.#Vr(t,s,d,r,h),A;let p=m.library;if(!p.native)return this.#a(t.pos,`the constructor ${s.name}(${p.params.map(Je).join(", ")})`,!0),A;u&&p.params.some(T=>ue(T,null))&&this.#at(t.pos,"unchecked",`unchecked call to ${s.name}(${p.params.map($).join(",")}) as a member of the raw type ${s.name}`,Ve(p.params,s)),s.box&&this.#at(t.pos,"deprecation",`${s.name}(${p.params.map($).join(",")}) in ${s.name} has been deprecated`);let k=this.#m.items.length;if(this.#de(t.args,m.params),a&&this.#Hr(t,s,k))return A;let g=a&&r.some((T,x)=>p.params[x]!==void 0&&Re(p.params[x],T));g&&this.#at(t.pos,"unchecked",`unchecked method invocation: constructor <init> in class ${s.name} is applied to given types`,[` required: ${p.params.map($).join(",")}`,` found: ${r.map($).join(",")}`,...Ve([...p.params,...r],s)]);let O;if(g)O=pt(s);else if(!a)O=e;else{let T=new Map(o);p.params.forEach((R,L)=>bt(R,r[L],T));let x=s.typeParams.every(R=>T.has(R)),v=s.typeParams.map(R=>T.get(R)??G);O=x||n?pt(s,v):{tag:"diamond",symbol:s,fromArgs:s.typeParams.some(R=>T.has(R))?v:null}}return t.libraryCall=this.#Xe({...p,name:"<init>"},pt(s),m.params),m.expanded&&(t.libraryCall.varargsFrom=m.params.length-1),O}#Dr(t,e){if(e.length)return this.#e(t.pos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${e.map($).join(",")}`," reason: actual and formal argument lists differ in length"]),A;te("String");let n={name:"<init>",params:[],returnType:G,isStatic:!0,native:"Object.<init>()",owner:"Object"};return t.libraryCall=this.#Xe(n,G,[]),G}#Fr(t){let e=this.#ue(t.args);if(e.some(a=>a.tag==="error"))return A;let s=te("String").constructors.map(a=>({owner:"String",name:"String",params:a.params,returnType:xt,library:a})),r=this.#ct({pos:t.pos,name:"String",args:t.args},s,e,"constructor");return r?(t.libraryCall=this.#Xe({...r.library,name:"<init>"},mt,r.params),mt):A}#_r(t,e){if(t.body)return this.#Ur(t,t.body,e);let n=this.#u===t;this.#u=null;let s=t.outerExpression?this.#Br(t):this.#U(t.classType);if(s.tag==="library"||s.tag==="diamond")return this.#jr(t,s,e);if(s.tag==="string")return this.#Fr(t);let r=this.#ue(t.args);if(s.tag==="error"||r.some(m=>m.tag==="error"))return A;if(s.tag==="typevar")return this.#e(t.classType.pos,w.incompatibleTypes,"unexpected type",[" required: class",` found: type parameter ${s.name}`,...Et([s])]),A;if(s.tag==="object")return this.#Dr(t,r);if(s.tag!=="class")return this.#a(t.pos,`creating ${nn($(s))} with \'new\'`,!0),A;let a=s.symbol;if(a.isEnum)return this.#e(t.pos,w.syntax,"enum classes may not be instantiated"),A;if(a.isAbstract)return this.#e(t.pos,w.cantResolve,`${a.displayName} is abstract; cannot be instantiated`),A;if(this.#In(a,r.length,t.pos))return A;let o=t.classType.kind==="ClassType"?t.classType:null,c=o?.diamond===!0;if(c&&!a.typeParams?.length)return this.#e(o.typeArgumentsPos??t.pos,w.cantResolve,`cannot infer type arguments for ${a.displayName}`,[` reason: cannot use \'<>\' with non-generic class ${a.displayName}`]),A;let u=this.#qe(a,c?void 0:s),d=s;if(c){let m=a.typeParams,p=m.map(C=>C.key),k=Er(a,e),g=new Map;u=u.map(C=>{let M=new Map(k),_=new Map;ka(p,Aa(C,r),r,M,_);for(let P of m){let B=_.get(P.key);if(!B)continue;let N=k.get(P.key);if(N&&B.some(F=>!K(F,N))){let F=[`inference variable ${P.name} has incompatible bounds`,` equality constraints: ${$(N)}`,` lower bounds: ${B.map($).join(",")}`];return{...C,shown:C.params,problem:{reason:F.join(`\n`),diamond:!0}}}M.has(P.key)||M.set(P.key,B.reduce(Ar))}let j={...C,shown:C.params,params:C.params.map(P=>Kt(P,M))};return g.set(j,M),j});let O=u.filter(C=>C.params.length===r.length),T=O.length===1&&O[0].problem?.diamond&&!La(O[0],r,m)?O[0]:null;if(T){let[C,...M]=T.problem.reason.split(`\n`);return this.#e(o.typeArgumentsPos??t.pos,w.incompatibleTypes,`incompatible types: cannot infer type arguments for ${a.displayName}<>`,[` reason: ${C}`,...M.map(_=>` ${_}`),...Et(m.map(me))]),A}let x=this.#m.items.length,v=this.#ct({pos:t.pos,name:a.name,args:t.args},u,r,"constructor");if(!v)return this.#zr(t,a,u,r,x),A;let R=g.get(u.find(C=>C.method===v.method))??new Map;return m.filter(C=>!R.has(C.key)).length&&n&&!e?(t.openDiamond={symbol:a,bound:R},d=tt(a,m.map(C=>R.get(C.key)??Hn))):d=tt(a,m.map(C=>R.get(C.key)??W(me(C)))),this.#us(t,a,v,d)}let h=this.#ct({pos:t.pos,name:a.name,args:t.args},u,r,"constructor");return h?(Bn(s)&&h.method.params.some(m=>rs([m]).length)&&this.#at(t.pos,"unchecked",`unchecked call to ${this.#Ht(h.method).replace(/^[^(]*/,a.name)} as a member of the raw type ${a.displayName}`,Et(h.method.params)),this.#hn(t.args,h.method.params.map(W)),this.#us(t,a,h,d)):A}#Ur(t,e,n){this.#u=null;let s=e.symbol,r=this.#U(t.classType),a=this.#ue(t.args);if(r.tag==="error"||a.some(x=>x.tag==="error"))return A;if(r.tag==="diamond"){let x=Ms(r.symbol,n);r=pt(r.symbol,r.symbol.typeParams.map(v=>x.get(v)??G))}else if(r.tag==="class"&&t.classType.kind==="ClassType"&&t.classType.diamond&&r.symbol.typeParams?.length){let x=Er(r.symbol,n);r=tt(r.symbol,r.symbol.typeParams.map(v=>x.get(v.key)??W(me(v))))}if((r.tag==="library"||r.tag==="class")&&r.symbol.isInterface&&t.args.length)return this.#e(t.args[0].pos,w.syntax,"anonymous class implements interface; cannot have arguments"),A;let c=r.tag==="string"?"String":r.tag==="class"&&(r.symbol.isFinal||r.symbol.isEnum)?r.symbol.displayName:r.tag==="library"&&!r.symbol.isInterface&&r.symbol.box?r.symbol.name:null;if(c)return this.#e(t.classType.pos,w.syntax,`cannot inherit from final ${c}`),A;if(r.tag==="library"&&!r.symbol.isInterface){if(!ga.has(r.symbol.name))return this.#a(t.classType.pos,`extending the library class ${r.symbol.name}`,!0),A;s.librarySuperclass=r}else if(r.tag==="library"){if(!Sa(r.symbol))return this.#a(t.classType.pos,`implementing the library interface ${r.symbol.name}`,!0),A;s.libraryInterfaces.push(r)}else if(r.tag==="class")if(r.symbol.isInterface)s.interfaces.push(r.symbol),s.interfaceTypes=[r];else{if(r.symbol.isInner)return this.#a(t.classType.pos,"extending an inner (non-static) class",!0),A;s.superclass=r.symbol,s.superType=r}else if(r.tag!=="object")return this.#a(t.pos,`creating ${nn($(r))} with \'new\'`,!0),A;if(r.tag==="class"&&r.symbol.isSealed)return this.#Ze(s),A;let u=null,d=null;if(s.librarySuperclass){let x=this.#Nn(s.librarySuperclass,a,t.pos);if(!x)return A;u=x.candidate,d=x.call}else if(s.superclass){if(this.#In(s.superclass,a.length,t.pos))return A;if(u=this.#ct({pos:t.pos,name:s.superclass.name,viaSuper:!0},this.#qe(s.superclass,s.superType),a,"constructor"),!u)return A;if(!this.#Oe(u.method,t.pos,`${s.superclass.name}(${u.method.params.map($).join(",")})`,"super"))return A}else if(a.length)return this.#e(t.pos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${a.map($).join(",")}`," reason: actual and formal argument lists differ in length"]),A;s.hierarchyState=2;let h=this.#ke(),m=this.#o,p=this.#J,k=this.#ht,g=this.#g;this.#le(s);let O=this.#cs(s,u);d&&(O.superLibrary=d),this.#nn([...s.methods,...s.constructors]),this.#N.set(s,{scopes:h.scopes}),this.#J=null,this.#g=!1,this.#He(s),this.#Ce(h),this.#o=m,this.#J=p,this.#ht=k,this.#g=g,u&&this.#de(t.args,u.params),this.#Fe(t.args);let T=u?this.#_e(u,t.pos):void 0;return T&&(t.varargs=T),s.isInner&&(t.outer=0,this.#Zt()),t.ctor=O,tt(s)}#cs(t,e){let n=t.declaration.pos,s=e?e.params.slice():[],r={kind:"MethodDeclaration",modifiers:{keywords:[]},returnType:{kind:"VoidType",pos:n,start:n,end:n},name:"<init>",namePos:n,params:[],body:{kind:"Block",statements:[],pos:n,start:n,end:n+1},isConstructor:!0,synthetic:!0,pos:n,start:n,end:n},a={kind:"method",name:t.binaryName.slice(t.binaryName.lastIndexOf("$")+1),owner:t,isStatic:!1,isConstructor:!0,isPrivate:!1,isAbstract:!1,isFinal:!1,access:"package",params:s,returnType:xt,index:this.#V.length,declaration:r,locals:[],maxSlots:1+(t.isInner?1:t.enumBody?2:0)+s.reduce((o,c)=>o+Be(c),0),throws:e?.method?.throws??[],forwardsToSuper:!0,...e?.method?{superConstructor:e.method}:{}};return r.symbol=a,this.#V.push(a),t.constructors.push(a),a}#Br(t){let e=this.#nt(t.outerExpression);if(e.tag==="error")return A;let n=t.classType,s=n.names[0];if(e.tag!=="class")return this.#a(t.pos,`\'.new\' on ${nn($(e))}`,!0),A;let r;for(let a=e.symbol;a&&!r;a=a.superclass)r=a.membersByName.get(s);return r?r.isInner?r.typeParams?.length||r.outer?.typeParams?.length||n.typeArguments||n.diamond?(this.#a(t.pos,"\'.new\' of a generic class, or of a generic class\'s inner class",!0),A):tt(r):(this.#e(t.start,w.syntax,"qualified new of static class"),A):(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: class ${e.symbol.displayName}`]),A)}#Vr(t,e,n,s,r){let a=this.#m.items.slice(r);if(!a.length||!/cannot be applied to given types|no suitable constructor/.test(a[0].message))return;this.#m.items.splice(r);let o=`cannot infer type arguments for ${e.name}<>`;if(n.length!==1){this.#e(t.pos,w.cantResolve,o);return}let c=n[0].library.params,u=e.typeParams.join(","),d=s.length!==c.length?[`cannot infer type-variable(s) ${u}`," (actual and formal argument lists differ in length)"]:[`cannot infer type-variable(s) ${u}`,` (argument mismatch; ${$(s[Math.max(0,s.findIndex((h,m)=>!Ht(n[0].params[m],h)))])} cannot be converted to ${$(c[Math.max(0,s.findIndex((h,m)=>!Ht(n[0].params[m],h)))])})`];this.#e(t.pos,w.cantResolve,o,[` reason: ${d[0]}`,...d.slice(1).map(h=>` ${h}`),...Ve(e.typeParams.map(h=>({tag:"typevar",name:h})),e)])}#Hr(t,e,n){let s=this.#m.items.slice(n),r=t.args.map(Q).filter(d=>d.kind==="Lambda"),a=s.findIndex(d=>d.severity==="error"&&kr.test(d.message)&&r.some(h=>d.offset!==void 0&&d.offset>=h.start&&d.offset<=h.end));if(a<0)return!1;let o=s[a];this.#m.items.splice(n+a,1);let c=[`(argument mismatch; ${o.message.replace(/^incompatible types: /,"")}`,...(o.details??[]).map(d=>` ${d.trimStart()}`)];c[c.length-1]+=")";let u=t.classType.kind==="ClassType"?t.classType:null;return this.#e(u?.typeArgumentsPos??t.pos,w.incompatibleTypes,`incompatible types: cannot infer type arguments for ${e.name}<>`,[` reason: cannot infer type-variable(s) ${e.typeParams.join(",")}`,...c.map(d=>` ${d}`),...Ve(e.typeParams.map(d=>({tag:"typevar",name:d})),e)]),!0}#zr(t,e,n,s,r){let a=this.#m.items.slice(r);if(!a.length||!/cannot be applied to given types|no suitable constructor/.test(a[0].message))return;this.#m.items.splice(r);let o=e.typeParams,c=o.map(k=>k.name).join(","),u=`cannot infer type arguments for ${e.displayName}<>`;if(n.length!==1){this.#e(t.pos,w.cantResolve,u);return}let d=n[0],h=d.shown??d.params,m,p=La(d,s,o);if(d.varargs?s.length<h.length-1:s.length!==h.length)m=[`cannot infer type-variable(s) ${c}`," (actual and formal argument lists differ in length)"];else if(p)m=[`inference variable ${p.variable.name} has incompatible bounds`,` upper bounds: ${p.variable.bounds.map($).join(",")}`,` lower bounds: ${$(p.lower)}`];else if(d.problem)m=d.problem.reason.split(`\n`);else{let k=s.findIndex((T,x)=>!Ht(d.params[x],T)),g=h[Math.max(k,0)],O=s[Math.max(k,0)];m=[`cannot infer type-variable(s) ${c}`,` (argument mismatch; ${$(O)} cannot be converted to ${$(g)})`]}this.#e(t.pos,w.cantResolve,u,[` reason: ${m[0]}`,...m.slice(1).map(k=>` ${k}`),...Et(o.map(me))])}#us(t,e,n,s){let r=n.method,a=this.#_e(n,t.pos);if(a&&(t.varargs=a),!this.#Oe(r,t.pos,`${e.name}(${r.params.map($).join(",")})`,e.anonymous?"super":null))return A;if(this.#de(t.args,n.params),e.isInner&&!t.outerExpression){let o=0;for(let u=this.#o;u&&u!==e.outer;u=u.outer)o++;let c=this.#o===e.outer||o>0&&this.#sn(o)&&this.#zs(o)===e.outer;if(!this.#t&&!this.#g&&c&&(t.outer=o),t.outer!==void 0)this.#Zt();else return this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A}return t.ctor=r,s}#dn(t){if(t.tag==="library"&&t.symbol.functional){let s=t.symbol,r=s.methods.find(c=>c.name===s.functional&&!c.isStatic),a=s.typeParams.map((c,u)=>{let d=t.args[u];return d?d.tag==="wildcard"?d.bound??G:d:G}),o=c=>wt(c,s.typeParams,a);return{params:r.params.map(o),returnType:o(r.returnType),iface:s.qualifiedName,samKey:r.native}}if(t.tag==="class"&&t.symbol.isInterface){let s=ks(t.symbol),r=t.symbol.displayName;if(s.length===1&&!t.symbol.isSealed){let o=s[0],c=tt(t.symbol,t.args?.map(d=>Me(d))),u=d=>Ne(c,o.owner,d);return{params:o.params.map(u),returnType:u(o.returnType),iface:t.symbol.binaryName,sam:o}}let a=t.symbol.isSealed?[]:[s.length?` multiple non-overriding abstract methods found in interface ${r}`:` no abstract method found in interface ${r}`];return{problem:`${r} is not a functional interface`,details:a}}let e=t.tag==="array"?"Array":t.tag==="library"||t.tag==="diamond"?t.symbol.name:t.tag==="class"?t.symbol.displayName:$(t),n=t.tag==="library"&&t.symbol.isInterface?[` multiple non-overriding abstract methods found in interface ${t.symbol.name}`]:void 0;return{problem:`${e} is not a functional interface`,details:n}}#$n(t,e,n=!1){if(t.method)return e??A;if(!e)return this.#e(t.pos,w.incompatibleTypes,"lambda expression not expected here"),A;if(e.tag==="error")return A;if(e.tag==="library"&&e.symbol.name==="Iterable")return this.#a(t.pos,"lambda expressions that implement Iterable"),A;let s=this.#dn(e);if("problem"in s)return this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),A;if(s.params.length!==t.params.length)return this.#e(t.pos,w.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),A;for(let[a,o]of t.params.entries()){if(!o.type)continue;let c=this.#U(o.type);if(c.tag==="error")return A;if(!at(c,s.params[a]))return this.#e(t.pos,w.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),A}if(s.returnType.tag==="void"&&t.body.kind!=="Block"&&!cl(t.body))return this.#e(t.body.pos,w.incompatibleTypes,"incompatible types: lambda body is not compatible with a void functional interface",[" (consider using a block lambda body, or use a statement expression instead)"]),A;n&&ue(s.returnType,Array.isArray(n)?n:null)&&(s.returnType=es);let r=t.body.kind==="Block"?t.body:s.returnType.tag==="void"?{kind:"Block",statements:[{kind:"ExpressionStatement",expression:t.body,pos:t.body.pos,start:t.body.start,end:t.body.end}],pos:t.body.pos,start:t.body.start,end:t.body.end}:{kind:"Block",statements:[{kind:"ReturnStatement",value:t.body,pos:t.body.pos,start:t.body.start,end:t.body.end}],pos:t.body.pos,start:t.body.start,end:t.body.end};return this.#Le(t,s,r,[],()=>{for(let a of r.statements)this.#ce(a)}),e}#Le(t,e,n,s,r){let a=t.reference===!0,o,c=this.#ht;if(a)o=`lambda$ref$${this.#V.length}`;else{c=this.#J?this.#ht:this.#b?this.#b.isConstructor?"new":this.#b.name:this.#t?"static":"new";let C=this.#H.get(this.#o)??new Map;this.#H.set(this.#o,C);let M=C.get(c)??0;C.set(c,M+1),o=`lambda$${c}$${M}`}let u=[],d=new Set(t.params.map(C=>C.name));Js(n,(C,M)=>{if(d.has(C))return;let _=this.#lt(C)??this.#Pn(C)?.local;_&&!u.some(j=>j.outer===_)&&u.push({outer:_,pos:M})});let h={keywords:[],annotations:[]},m={kind:"VoidType",pos:t.pos,start:t.pos,end:t.pos},p=t.params.map(C=>({modifiers:C.modifiers??h,type:C.type??m,name:C.name,varargs:!1,pos:C.pos,start:C.pos,end:C.pos})),k={kind:"MethodDeclaration",modifiers:h,returnType:m,name:o,namePos:t.pos,params:p,body:n,pos:t.pos,start:t.start,end:t.end},g={kind:"method",name:o,owner:this.#o,isStatic:!0,isConstructor:!1,isPrivate:!0,isAbstract:!1,isFinal:!1,access:"private",params:[...s.map(C=>C.type),...u.map(C=>C.outer.type),...e.params],returnType:e.returnType,index:this.#V.length,declaration:k,locals:[],maxSlots:0,lambda:t,throws:[],...a?{hidden:!0}:{}};k.symbol=g,this.#V.push(g),!this.#b&&!this.#J&&this.#Et.set(this.#o,[...this.#Et.get(this.#o)??[],g]),t.method=g,t.captures=u.map(C=>C.outer),t.capturedAt=u.map(C=>C.pos),t.functional={iface:e.iface,...e.samKey?{samKey:e.samKey}:{},...e.sam?{sam:e.sam}:{}};let O=this.#ke(),T=this.#J,x=this.#ht,v=this.#t;this.#J={scopes:this.#f,method:this.#b,isStatic:v,outer:this.#J},this.#ht=c,this.#b=g,this.#it=null,this.#t=v,this.#f=[],this.#c=0,this.#y=[];let R=this.#m.items.length;this.#Pt();let L=0;for(let C of s){let M=this.#zt(C.name,C.type,t.pos,!0,!0);M.parameter=++L}for(let C of u){let M=this.#zt(C.outer.name,C.outer.type,C.pos,!1,!0);M.parameter=++L,M.captureOf=C.outer}return p.forEach((C,M)=>{let _=this.#zt(C.name,e.params[M],C.pos,t.params[M]?.modifiers?jt(t.params[M].modifiers,"final"):!1);_.parameter=++L,C.symbol=_}),r(),this.#Mt(),t.body.kind==="Block"&&e.returnType.tag!=="void"&&this.#m.items.length===R&&this.#Kr(g)&&this.#e(t.pos,w.incompatibleTypes,"incompatible types: bad return type in lambda expression",[" missing return value"]),g.usesThis&&(g.isStatic=!1,ul(g,1)),this.#Ce(O),this.#J=T,this.#ht=x,g}#Zt(){let t=this.#b;for(let e=this.#J;t?.lambda&&e;e=e.outer)t.usesThis=!0,t=e.method}#hs(t,e,n=!1){if(!e)return this.#e(t.start,w.incompatibleTypes,"method reference not expected here"),A;if(e.tag==="error")return A;let s=this.#dn(e);if("problem"in s)return this.#e(t.start,w.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),A;n&&ue(s.returnType,null)&&(s.returnType=es);let r=s.params.length,a={kind:"Lambda",params:Array.from({length:r},(T,x)=>({name:`$${x}`,pos:t.start,type:null})),body:{kind:"Block",statements:[],pos:t.start,start:t.start,end:t.end},reference:!0,depth:t.depth,pos:t.start,start:t.start,end:t.end};t.lambda=a;let o=T=>({kind:"Name",identifier:`$${T}`,depth:1,pos:t.start,start:t.start,end:t.end}),c=T=>Array.from({length:r-T},(x,v)=>o(T+v)),u={depth:2,pos:t.start,start:t.start,end:t.end},d=(T,x)=>({kind:"MethodCall",target:T,name:t.name,namePos:t.namePos,selectPos:t.start,args:c(x),plainNpe:!0,...u}),h=T=>s.returnType.tag==="void"?{kind:"ExpressionStatement",expression:T,...u}:{kind:"ReturnStatement",value:T,...u},m=a.body;if(t.arrayType){let x={kind:"NewArray",elementType:t.arrayType.kind==="ArrayType"?t.arrayType.element:t.arrayType,dimensions:r?[o(0)]:[],extraDims:0,initializer:null,...u};return m.statements.push(h(x)),this.#Le(a,s,m,[],()=>this.#Ne(m)),e}let p=t.target;if(p.kind==="Super"||p.kind==="This")return m.statements.push(h(d(p,0))),this.#Le(a,s,m,[],()=>this.#Ne(m)),e;if(p.kind==="FieldAccess"&&p.target.kind==="Name"&&p.target.identifier==="System"&&(p.name==="out"||p.name==="err")&&!this.#lt("System"))return m.statements.push(h(d(p,0))),this.#Le(a,s,m,[],()=>this.#Ne(m)),e;if(t.name==="new"){let T=this.#Gr(p)?this.#ds(p):null;if(!T)return this.#e(t.start,w.cantResolve,"cannot find symbol",[` symbol: class ${this.#fs(p)}`,` location: class ${this.#o.displayName}`]),A;let x={kind:"NewObject",classType:T,args:c(0),...u};return m.statements.push(h(x)),this.#Le(a,s,m,[],()=>this.#Ne(m)),e}let k=this.#cn(p);if("tag"in k){if(k.tag==="error")return A;t.receiver=p;let T={kind:"Name",identifier:"$recv",depth:1,pos:t.start,start:t.start,end:t.end},x=d(T,0);return m.statements.push(h(x)),this.#Le(a,s,m,[{name:"$recv",type:k}],()=>this.#Ne(m)),e}let g=this.#fs(p),O=T=>h(T?d(o(0),1):d(p,0));return this.#Le(a,s,m,[],()=>{let T=j=>{let P=O(j),B=this.#m.items.length;m.statements=[P],this.#Ne(m);let N=this.#m.items.splice(B),F=P.kind==="ReturnStatement"?P.value:P.expression,q=F.method!==void 0||F.libraryCall!==void 0||F.stringMethod!==void 0||F.mathFunction!==void 0||F.objectMethod!==void 0,Z=F.method?F.method.isStatic:F.libraryCall?F.libraryCall.isStatic:F.mathFunction!==void 0,ne=F.method?`method ${F.method.name}(${F.method.params.map($).join(",")}) in ${F.method.owner.displayName}`:F.libraryCall?`method ${t.name}(${F.libraryCall.params.map($).join(",")}) in ${g}`:void 0;return{ok:q&&Z!==j,...ne?{found:ne}:{},...N[0]?{message:N[0].message}:{}}},x=T(!1),v=this.#ds(p),R=v?this.#ms(v):null,L=R?.tag==="diamond"?pt(R.symbol):R,C=s.params[0],M=!L||L.tag==="error"||C===void 0||C===es||K(qt(C)??C,L)||C.tag==="typevar",_=r>0&&M?T(!0):{ok:!1};if(x.ok&&_.ok){this.#e(t.start,w.incompatibleTypes,"incompatible types: invalid method reference",[` reference to ${t.name} is ambiguous`,` both ${x.found} and ${_.found} match`]);return}if(!x.ok&&!_.ok){let j=/^non-static method (.*) cannot be referenced from a static context$/.exec(x.message??"");if(j){this.#e(t.start,w.incompatibleTypes,"incompatible types: invalid method reference",[` unexpected instance method ${j[1]} found in unbound lookup`]);return}this.#e(t.start,w.cantResolve,"invalid method reference",[" cannot find symbol",` symbol: method ${t.name}(${s.params.map($).join(",")})`,` location: class ${g}`]);return}m.statements=[O(!x.ok)],this.#Ne(m)}),e}#Ne(t){for(let e of t.statements)this.#ce(e)}#Gr(t){let e=Ee(t);return e!==null&&(this.#Ie(e)!==null||this.#mt(e)!==null||e.join(".")==="String")}#ds(t){let e=Ee(t);if(!e)return null;let n=this.#Ie(e)?null:this.#mt(e);return{kind:"ClassType",names:e,hasTypeArguments:!1,...n&&n.typeParams.length?{diamond:!0}:{},pos:t.pos,start:t.start,end:t.end}}#ms(t){let e=this.#m.items.length,n=this.#U(t,!0);return this.#m.items.splice(e),n}#fs(t){return Ee(t)?.join(".")??Cs(t)}#Kr(t){let e=this.#B,n=this.#dt,s=[this.#K,this.#Z,this.#F,this.#M];this.#B=[],this.#dt=[];let r=this.#Me(t.declaration.body.statements,Qt(),!0).completes;return this.#B=e,this.#dt=n,[this.#K,this.#Z,this.#F,this.#M]=s,r}#Pn(t){for(let e=this.#J;e;e=e.outer)for(let n=e.scopes.length-1;n>=0;n--){let s=e.scopes[n].names.get(t);if(s){let r=e.method;for(let a=e.outer;a&&r?.lambda;a=a.outer)r=a.method;return{local:s,method:r}}}return null}#te(t,e){this.#e(t,w.cantResolve,e)}#qr(t,e){this.#Ae(t.condition);let n=t.condition.type??A,s=e!==void 0&&e.tag!=="error"?e:void 0,r=this.#Qt(this.#ft(t.condition,!0),()=>this.#nt(t.whenTrue,s)),a=this.#Qt(this.#ft(t.condition,!1),()=>this.#nt(t.whenFalse,s));if(n.tag!=="boolean"||r.tag==="error"||a.tag==="error")return A;let o,c=St(r)??r,u=St(a)??a;if(st(c)&&st(u)&&!(nt(r)&&nt(a)&&s&&nt(s)))if(c.tag==="boolean"&&u.tag==="boolean")o=gt;else if(Rt(c)&&Rt(u))o=Tl(c,u,t.whenTrue.constant,t.whenFalse.constant);else return this.#a(t.pos,"conditional expressions mixing boolean and numeric operands"),A;else if(st(r)&&a.tag==="null"||st(a)&&r.tag==="null"){let h=st(r)?r:a,m=this.#ps(h);if(!m)return A;if(o=s&&nt(s)?s:m,s&&!re(s,m))return this.#q(st(r)?t.whenTrue:t.whenFalse,h,s),A}else{if(s){let h=!0;for(let[m,p]of[[t.whenTrue,r],[t.whenFalse,a]])re(s,p,m.constant)||(this.#e(m.pos,w.incompatibleTypes,"incompatible types: bad type in conditional expression",[` ${Ue(s,p)}`]),h=!1);if(!h)return A}if(st(r)||st(a))return this.#a(t.pos,"conditional expressions that need boxing"),A;o=s&&nt(s)?s:Pa(r,a)}let d=t.condition.constant;return d?.kind==="boolean"&&t.whenTrue.constant&&t.whenFalse.constant&&(t.constant=On(d.value?t.whenTrue.constant:t.whenFalse.constant,o)),o}#Wr(t,e){let n=Wn[t.name],s=n.map(o=>({owner:"Math",name:t.name,params:o.params,returnType:o.returnType})),r=this.#ct({pos:t.selectPos,name:t.name,imported:fa(t),args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},s,e,"method");if(!r)return A;let a=n[s.indexOf(r)];return a.fn?(t.mathFunction={fn:a.fn,params:a.params},r.returnType):(this.#a(t.selectPos,`Math.${t.name}(${r.params.map($).join(",")})`,!0),A)}#ps(t){let e={int:"Integer",long:"Long",double:"Double",char:"Character",boolean:"Boolean",float:"Float",byte:"Byte",short:"Short"}[t.tag],n=e?Wt(e):void 0;return n?pt(n):null}#Xr(t,e){if(t.name==="readln"){te("System");let o=[{owner:"IO",name:"readln",params:[],returnType:mt},{owner:"IO",name:"readln",params:[mt],returnType:mt}],c=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},o,e,"method");if(!c)return A;let u=`readln(${c.params.length?"String":""})`;return t.libraryCall={native:`IO.${u}`,isStatic:!0,params:c.params,returnsValue:!0,display:`java.lang.IO.${u}`},mt}if(t.name!=="print"&&t.name!=="println")return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,e)}`," location: class IO"]),A;let n=t.name==="println"?[{owner:"IO",name:"println",params:[G],returnType:xt},{owner:"IO",name:"println",params:[],returnType:xt}]:[{owner:"IO",name:"print",params:[G],returnType:xt}];if(!this.#ct({pos:t.selectPos,name:t.name},n,e,"method"))return A;let r=e[0],a="none";if(r)switch(r.tag){case"int":a="int";break;case"char":a="char";break;case"boolean":a="boolean";break;case"long":a="long";break;case"double":a="double";break;case"string":case"null":a="string";break;default:a="object"}return t.print={stream:"out",newline:t.name==="println",argument:a},xt}#Yr(t){let e=Q(t);if(e.kind==="FieldAccess")return e.field;if(e.kind==="Name"&&e.imported)return e.imported.field}#Qr(t,e,n){te("System");let s={owner:"PrintStream",name:t.name,params:[mt,ee(G)],returnType:xt,varargs:!0},r=this.#ct({pos:t.selectPos,name:t.name},[s],n,"method");return r?(t.libraryCall={native:`PrintStream.${e}.printf(String,Object[])`,isStatic:!0,params:r.params,returnsValue:!1,display:`java.io.PrintStream.${t.name}(String, Object[])`},r.expanded&&(t.libraryCall.varargsFrom=1),xt):A}#ys(t){let e=Q(t);if(e.kind!=="MethodCall"||e.typeArguments)return null;if(e.libraryMethod){let{method:a,symbol:o,classArgs:c}=e.libraryMethod,u=a.typeParams??[];if(!u.length)return null;let d=wn(a,o);return{call:e,result:a.returnType,params:a.params.map(h=>a.isStatic?h:Xt(h,o.typeParams,c)),varOf:h=>h.tag==="typevar"&&!h.symbol&&u.includes(h.name)?h.name:null,ref:h=>({name:h,decl:d}),bound:h=>{let m=a.typeParamBounds?.[h];return m?{type:m,decl:d}:null}}}let n=e.method;if(!n?.typeParams?.length)return null;let s=n.typeParams,r=a=>s.find(o=>o.name===a);return{call:e,result:n.returnType,params:n.params,varOf:a=>a.tag==="typevar"&&a.symbol&&s.includes(a.symbol)?a.name:null,ref:a=>({name:a,decl:xr(r(a))}),bound:a=>{let o=r(a).bounds[0];return o?{type:o,decl:null}:null}}}#gs(t,e=!1){let n=this.#ys(t);if(!n)return null;let s=n.varOf(n.result),r=e&&n.result.tag==="library"?n.result.args[n.result.args.length-1]:void 0,a=s??(r?n.varOf(r):null);if(!a)return null;let o=m=>{let p=[],k=g=>{let O=n.varOf(g);O?p.push(O):g.tag==="array"?k(g.element):g.tag==="wildcard"&&g.bound?k(g.bound):g.tag==="library"?g.args.forEach(k):g.tag==="class"&&g.args?.forEach(k)};return k(m),p},c=m=>{let p=Q(m);return p.kind==="Lambda"&&p.params.some(k=>!k.type)||p.kind==="MethodRef"&&(!this.#We(p)||this.#On(p))},u=new Set,d=null,h=null;return n.call.args.forEach((m,p)=>{let k=n.params[Math.min(p,n.params.length-1)];if(!k)return;if(c(m)){!h&&o(k).includes(a)&&(h=m);return}let g=this.#gs(m,!0);if(g){o(k).includes(a)&&(d??=g);return}for(let O of o(k))u.add(O)}),u.has(a)?null:d??{call:n,name:a,by:h}}#Zr(t,e){let n=this.#ys(t);if(!n)return null;let s=n.varOf(n.result);if(!s)return null;let r=this.#gs(t);if(!r)return null;let a=r.call.bound(r.name),o=r.by&&Q(r.by),c={type:G,decl:null};if(o?.kind==="MethodRef"&&o.name==="new"&&!o.arrayType){let u=o.target?Ee(o.target):null,d=u?this.#mt(u):null,h=d?{type:{tag:"library",symbol:d,args:d.typeParams.map(p=>({tag:"typevar",name:p}))},decl:Tr(d)}:{type:e,decl:null},m=[...a?[a]:[],n.bound(s)??c];return{bound:a?.type??null,variable:n.ref(s),upper:m,lower:h}}return{bound:a?.type??null,variable:r.call.ref(r.name),upper:[a??c],lower:o?.kind==="MethodRef"&&this.#ti(o)||{type:e,decl:null}}}#ti(t){let e=t.target?Ee(t.target):null,n=e&&!this.#lt(e[0])?this.#mt(e):null,s=n?.methods.filter(r=>r.name===t.name)??[];return s.length!==1||!s[0].typeParams?.length?null:{type:s[0].returnType,decl:wn(s[0],n)}}#ei(t,e,n){let s=this.#Yr(t.target)==="System.err"?"err":"out";if(t.name==="printf"||t.name==="format")return this.#Qr(t,s,n);if((t.name==="flush"||t.name==="close"||t.name==="checkError")&&!n.length)return te("System"),t.libraryCall={native:`PrintStream.${s}.${t.name}()`,isStatic:!0,params:[],returnsValue:t.name==="checkError",display:`java.io.PrintStream.${t.name}()`},t.name==="checkError"?gt:xt;if(t.name!=="print"&&t.name!=="println")return Ko.has(t.name)?this.#a(t.selectPos,`PrintStream.${t.name}()`,!0):this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,n)}`,this.#De(t.target,e)]),A;let r=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos},rl(t.name),n,"method");if(!r)return A;let a=r.params[0],o="none";if(a)switch(a.tag){case"int":o="int";break;case"char":o="char";break;case"boolean":o="boolean";break;case"string":o="string";break;case"array":o="char-array";break;case"object":o="object",this.#hn(t.args,[G]);break;case"long":o="long";break;case"double":o="double";break;case"float":o="float";break;default:throw new Error(`checker: unexpected print overload ${$(a)}`)}return t.print={stream:s,newline:t.name==="println",argument:o},xt}#ct(t,e,n,s){let r=t.args?.map((g,O)=>n[O]?this.#Zr(g,n[O]):null),a=(g,O,T=!1)=>{if(g.params.length!==n.length)return"actual and formal argument lists differ in length";if(g.problem)return g.problem.reason;for(let x=0;x<n.length;x++){let v=r?.[x];if(!(v?Ra(g.params[x],v.bound,T):O(g.params[x],n[x])))return`argument mismatch; ${hl(g.params[x],n[x])??Ue(g.params[x],n[x])}`}return null},o=g=>{let O=r?.findIndex((v,R)=>v&&!Ht(g.params[R],n[R]))??-1;if(O<0)return g;let T=r[O],x=g.shown??g.params;return this.#e(t.callPos??t.pos,w.cantResolve,`${s} ${t.name} in ${Rs(g).text} cannot be applied to given types;`,[` required: ${en(x)}`,` found: ${en(n)}`,...aa(T.variable,[{type:g.params[O],decl:null},...T.upper],[T.lower])]),null};e.length>1&&(e=e.map(g=>{let O=g.method,T=O&&!g.problem?this.#es(O,`${O.isConstructor?O.owner.name:O.name}(${g.params.map($).join(",")})`,t.viaSuper?"super":null):null;return T?{...g,problem:{reason:T}}:g}));let c=g=>a(g,(O,T)=>Ht(O,T)||Re(O,T),!0),u=e.filter(g=>a(g,Ze)===null);if(u.length||(u=e.filter(g=>c(g)===null)),!u.length)for(let g of e){if(!g.varargs||n.length<g.params.length-1)continue;let O=g.params[g.params.length-1].element;if([...g.params.slice(0,-1),...n.slice(g.params.length-1).map(()=>O)].every((x,v)=>Ht(x,n[v])))return{...g,expanded:!0}}if(!u.length){if(e.length===1){let L=e[0],C=L.shown??L.params,M=((t.explicit?null:Na(L,n," "))??Ia(L,n)??c(L)).split(`\n`),_=L.problem?.alone?[` reason: ${M[0]}`]:[` required: ${en(C)}`,` found: ${en(n)}`,` reason: ${M[0]}`,...M.slice(1)],j=Rs(L);return this.#e(t.pos,w.cantResolve,`${s} ${t.name} in ${j.text} cannot be applied to given types;`,[..._,...L.problem?.alone?[]:Et([...C,...n],j.where)]),null}let g=[],O=[],T=t.imported?[...e].reverse():e,x=new vn,v=L=>{let C=L.library?.isStatic&&L.library.typeParams?.length&&It[L.owner]?Wt(L.owner):void 0;return C?wn(L.library,C):null};for(let L of T){let C=v(L);if(C){for(let M of C.method.typeParams)x.add({name:M,decl:C});for(let M of C.method.params)x.visit(M,C)}}for(let L of T){let C=v(L);if(C){g.push(` ${s} ${L.owner}.<${C.method.typeParams.map(F=>x.label({name:F,decl:C})).join(",")}>${L.name}(${x.params(C)}) is not applicable`);let N=($a(L,C,n,x)??c(L)).split(`\n`);g.push(` (${N[0]}${N.length>1?"":")"}`,...N.slice(1).map((F,q,Z)=>` ${F}${q===Z.length-1?")":""}`));continue}let M=L.shown??L.params,_=L.method?.typeParams;O.push(...M);let j=M.map((B,N)=>L.varargs&&N===M.length-1&&B.tag==="array"?`${$(B.element)}...`:$(B));g.push(` ${s} ${L.owner}.${_?`<${_.map(B=>B.name).join(",")}>`:""}${L.name}(${j.join(",")}) is not applicable`);let P=((t.explicit?null:Na(L,n," "))??Ia(L,n)??c(L)).split(`\n`);g.push(` (${P[0]}${P.length>1?"":")"}`,...P.slice(1).map((B,N,F)=>` ${B}${N===F.length-1?")":""}`))}let R=n.length?this.#Ft(t.name,n):`${t.name}(no arguments)`;return this.#e(t.pos,w.cantResolve,`no suitable ${s} found for ${R}`,[...g,...Et([...O,...n],x.entries())]),null}let d=(g,O)=>g.params.every((T,x)=>Ze(O.params[x],T)),h=u.filter(g=>u.every(O=>g===O||d(g,O)));if(h.length===1)return o(h[0]);let[m,p]=sl(u,d),k=g=>`${s} ${g.name}(${g.params.map($).join(",")}) in ${g.owner}`;return this.#e(t.pos,w.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${k(m)} and ${k(p)} match`]),o(m),null}#ni(t){let e=this.#nt(t.operand);if(e.tag==="error")return A;let n=St(e)??e;if(t.operator==="!")return n.tag!=="boolean"?this.#Mn(t,n):(t.operand.constant?.kind==="boolean"&&(t.constant=Tt(!t.operand.constant.value)),gt);if(!Rt(n)||t.operator==="~"&&!Xn(n))return this.#Mn(t,n);let s=pa(n),r=t.operand.constant;return r&&(t.constant=xl(t.operator,r,s)),s}#Mn(t,e){return this.#e(t.pos,w.badOperands,`bad operand type ${$(e)} for unary operator \'${t.operator}\'`),A}#bs(t){let e=Q(t);this.#P=e.kind==="Name";let n=this.#k(e);if(this.#P=!1,t.type=n,n.tag==="error")return null;if(e.kind==="Name"&&e.symbol?.kind==="local"){if(e.symbol.multiCatch)return this.#e(e.pos,w.finalAssign,`multi-catch parameter ${e.identifier} may not be assigned`),null;let r=e.symbol.forEach||e.symbol.parameter!==void 0||e.symbol.catchParameter;return e.symbol.isFinal&&!r?(this.#e(e.pos,w.finalAssign,`cannot assign a value to final variable ${e.identifier}`),null):(e.symbol.reassigned=!0,e.symbol.assignCount=(e.symbol.assignCount??0)+1,{kind:"local",variable:e.symbol})}let s=e.kind==="Name"&&e.symbol?.kind==="field"?e.symbol:e.kind==="FieldAccess"?e.fieldSymbol:void 0;if(s)return s.isFinal&&!this.#si(e,s)?(this.#e(e.pos,w.finalAssign,`cannot assign a value to ${s.isStatic?"static final":"final"} variable ${s.name}`),null):{kind:"field",field:s};if(e.kind==="ArrayAccess")return{kind:"element",type:n};if(e.kind==="Name"&&e.imported)return this.#e(e.pos,w.finalAssign,`cannot assign a value to static final variable ${e.identifier}`),null;if(e.kind==="FieldAccess"&&e.field){let r=e.field==="length"?"final variable length":`static final variable ${e.name}`;return this.#e(e.pos,w.finalAssign,`cannot assign a value to ${r}`),null}return this.#e(e.pos,w.incompatibleTypes,"unexpected type",[" required: variable"," found: value"]),null}#si(t,e){if(e.declarator.init)return!1;let n=this.#b?.initializer;return n&&this.#b.owner===e.owner&&n==="static"===e.isStatic?t.kind==="Name"?!t.outerHops:!e.isStatic&&t.kind==="FieldAccess"&&Q(t.target).kind==="This":e.isStatic||!this.#b?.isConstructor||this.#b.owner!==e.owner||this.#b.declaration.compact?!1:t.kind==="Name"?!t.outerHops:t.kind==="FieldAccess"&&Q(t.target).kind==="This"}#ri(t){if(!this.#bs(t.operand))return A;let n=t.operand.type;return Rt(St(n)??n)?n:this.#Mn(t,n)}#Ss(t,e,n,s){return this.#e(t.pos,w.badOperands,`bad operand types for binary operator \'${e}\'`,[` first type: ${$(n)}`,` second type: ${$(s)}`]),A}#Ts(t,e,n){if(t==="+"&&(e.tag==="string"||n.tag==="string"))return mt;if((t==="=="||t==="!=")&&nt(e)&&nt(n))return ke(e,n)?gt:null;let s=St(e)??e,r=St(n)??n,a=Rt(s)&&Rt(r);switch(t){case"+":return s.tag==="string"||r.tag==="string"?mt:a?ns(s,r):null;case"-":case"*":case"/":case"%":return a?ns(s,r):null;case"<<":case">>":case">>>":return Xn(s)&&Xn(r)?pa(s):null;case"<":case">":case"<=":case">=":return a?gt:null;case"==":case"!=":return a?gt:s.tag==="boolean"&&r.tag==="boolean"?gt:nt(s)&&nt(r)&&(K(s,r)||K(r,s))?gt:null;case"&":case"|":case"^":return Xn(s)&&Xn(r)?ns(s,r):s.tag==="boolean"&&r.tag==="boolean"?gt:null;case"&&":case"||":return s.tag==="boolean"&&r.tag==="boolean"?gt:null}return null}#ii(t){let e=this.#nt(t.left),n=t.operator==="&&"||t.operator==="||"?this.#Qt(this.#ft(t.left,t.operator==="&&"),()=>this.#nt(t.right)):this.#nt(t.right);if(e.tag==="error"||n.tag==="error")return A;let s=this.#Ts(t.operator,e,n);if(!s){let o=c=>st(c)||nt(c);return(t.operator==="=="||t.operator==="!=")&&o(e)&&o(n)&&st(e)===st(n)?(this.#e(t.pos,w.badOperands,`incomparable types: ${$(e)} and ${$(n)}`),A):this.#Ss(t,t.operator,e,n)}let r=t.left.constant,a=t.right.constant;if(r&&a){let o=vl(t.operator,r,a,s);o&&(t.constant=o)}return s}#ai(t){let e=this.#bs(t.target),n=t.target.type??A,s=this.#nt(t.value,t.operator==="="?n:void 0);if(!e||n.tag==="error"||s.tag==="error")return e?n:A;if(t.operator==="="){if(!this.#ln(n,s,t.value))return this.#q(t.value,s,n),A;let u=Q(t.target);return u.kind==="FieldAccess"&&u.fieldSymbol&&u.target.type&&Bn(u.target.type)&&rs([u.fieldSymbol.type]).length&&this.#at(u.pos,"unchecked",`unchecked assignment to variable ${u.name} as member of raw type ${$(u.target.type)}`),n}let r=t.operator.slice(0,-1),a=this.#Ts(r,n,s);if(!a)return this.#Ss(t,r,n,s);let o=St(n);return(o?at(o,a):Rt(a)&&Rt(n)||at(a,n))?n:(this.#e(t.value.pos,w.incompatibleTypes,`incompatible types: ${$(a)} cannot be converted to ${$(n)}`),A)}#oi(t){let e=this.#nt(t.array),n=this.#nt(t.index);return e.tag==="error"||n.tag==="error"?A:e.tag!=="array"?(this.#e(t.pos,w.incompatibleTypes,`array required, but ${$(e)} found`),A):Ht(V,n)?e.element:(this.#q(t.index,n,V),A)}#li(t){let e=this.#U(t.elementType,!0);if(e.tag!=="error"&&!Ln(e)){this.#e(t.pos,w.syntax,"generic array creation");for(let s of t.dimensions)this.#nt(s);return A}for(let s of t.dimensions){let r=this.#nt(s);r.tag!=="error"&&!Ht(V,r)&&this.#q(s,r,V)}if(e.tag==="error")return t.initializer&&this.#je(t.initializer,A),A;let n=e;for(let s=0;s<t.dimensions.length+t.extraDims;s++)n=ee(n);return t.initializer&&this.#je(t.initializer,n),n}#ci(t){let e=this.#U(t.targetType),n=this.#nt(t.expression);if(e.tag==="error"||n.tag==="error")return A;let s=St(n),r=Rt(e)&&Rt(n)||e.tag==="boolean"&&n.tag==="boolean"||nt(e)&&nt(n)&&ke(e,n)||nt(e)&&st(n)&&re(e,n)||st(e)&&s!==null&&(at(s,e)||Rt(s)&&Rt(e)&&Ht(e,s));if(!r&&st(e)&&nt(n)&&!s){let o=this.#ps(e);o&&ke(o,n)&&(t.checked=o,r=!0)}if(!r)return this.#q(t.expression,n,e),A;if(pl(e,n))return this.#q(t.expression,n,e),A;if(nt(e)&&nt(n)&&!Ln(e)&&!K(n,e)&&!ol(e,n)){this.#at(t.expression.pos,"unchecked","unchecked cast",[` required: ${$(e)}`,` found: ${$(n)}`,...Et([e,n])]);let o=W(e);!K(n,o)&&o.tag!=="object"&&(t.checked=o)}else nt(e)&&nt(n)&&!K(n,e)&&(t.checked=e);let a=t.expression.constant;return a&&(st(e)||e.tag==="string")&&(t.constant=On(a,e)),e}#$e(t,e,n){!this.#Z&&!this.#B.some(([s])=>s===t)&&this.#B.push([t,e,n])}#Pe(t,e){this.#dt.some(([n])=>n===t)||this.#dt.push([t,e])}#ui(t){this.#B=[],this.#dt=[];let e=Lr(t);for(let n of e)this.#ws(n);this.#ws(t);for(let[n,s,r]of this.#B)this.#e(n,s==="missing return statement"?w.missingReturn:w.unreachable,s,r);for(let[n,s]of this.#dt)this.#e(n,w.uninitialized,s);this.#Lt=[];for(let n of e)this.#xs(n);this.#xs(t);for(let[n,s,r]of this.#Lt)this.#e(n,w.unreported,s,r);for(let n of this.#ne)n.top!==t||ll(n.local)||this.#e(n.pos,w.notEffectivelyFinal,`local variables referenced from ${n.inner?"an inner class":"a lambda expression"} must be final or effectively final`)}#xs(t){this.#o=t;for(let e of t.fields){let n=e.declarator.init;n&&this.#Be([],()=>n.kind==="ArrayInitializer"?this.#mn(n):this.#T(n));let s=e.enumConstant?.node;s&&this.#Be([],()=>{for(let r of s.args)this.#T(r);if(s.ctor)for(let r of s.ctor.throws)this.#_t(r,s.pos)})}for(let e of t.declaration.members){if(e.kind==="Initializer"&&e.symbol){this.#Be(e.isStatic?[]:this.#hi(t),()=>{for(let s of e.body.statements)this.#pt(s)});continue}if(e.kind!=="MethodDeclaration"||!e.symbol||e.symbol.isAbstract||e.symbol.builtin)continue;let n=e.symbol;this.#Be(n.throws,()=>{if(n.superConstructor)for(let s of n.superConstructor.throws)this.#_t(s,n.declaration.synthetic?t.declaration.keywordPos:n.declaration.body.pos);for(let s of n.declaration.body.statements)this.#pt(s)})}for(let e of t.constructors)!e.declaration.synthetic||e.builtin||!e.superConstructor||e.forwardsToSuper||this.#Be([],()=>{for(let n of e.superConstructor.throws)this.#_t(n,t.declaration.keywordPos)})}#hi(t){let e=t.constructors.filter(n=>!n.declaration.synthetic&&!n.builtin);return e.length?e.flatMap(n=>n.throws).filter(n=>e.every(s=>s.throws.some(r=>K(n,r)))):[]}#Be(t,e){let n=[this.#gt,this.#Tt];this.#gt=t,this.#Tt=[],e(),[this.#gt,this.#Tt]=n}#_t(t,e,n){if(this.#Xt(t)){for(let s=this.#Tt.length-1;s>=0;s--){let r=this.#Tt[s];if(r.thrown.push(t),r.caught.some(a=>K(t,a)))return}this.#gt.some(s=>K(t,s))||this.#Lt.some(([s])=>s===e)||this.#Lt.push([e,`unreported exception ${$(t)}; must be caught or declared to be thrown`,n])}}#pt(t){switch(t.kind){case"Block":for(let e of t.statements)this.#pt(e);return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init?.kind==="ArrayInitializer"?this.#mn(e.init):e.init&&this.#T(e.init);return;case"ExpressionStatement":this.#T(t.expression);return;case"IfStatement":this.#T(t.condition),this.#pt(t.then),t.otherwise&&this.#pt(t.otherwise);return;case"WhileStatement":case"DoStatement":this.#T(t.condition),this.#pt(t.body);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#pt(t.init);else for(let e of t.init??[])this.#T(e);t.condition&&this.#T(t.condition);for(let e of t.update)this.#T(e);this.#pt(t.body);return;case"ForEachStatement":this.#T(t.iterable),this.#pt(t.body);return;case"LabeledStatement":this.#pt(t.body);return;case"SwitchStatement":this.#vs(t);return;case"YieldStatement":this.#T(t.value);return;case"ReturnStatement":t.value&&this.#T(t.value);return;case"ConstructorCall":for(let e of t.args)this.#T(e);if(t.target)for(let e of t.target.throws)this.#_t(e,t.thisPos);return;case"AssertStatement":this.#T(t.condition),t.message&&this.#T(t.message);return;case"LocalClass":return;case"ThrowStatement":{this.#T(t.expression);let e=Q(t.expression),n=e.kind==="Name"&&e.symbol?.kind==="local"&&!e.symbol.reassigned?this.#ee.get(e.symbol):void 0;if(n)for(let s of n)this.#_t(s,t.pos);else t.expression.type&&this.#_t(t.expression.type,t.pos);return}case"TryStatement":this.#di(t);return;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":return}}#vs(t){this.#T(t.selector);for(let e of t.cases){for(let n of e.statements)this.#pt(n);e.body?.kind==="Block"?this.#pt(e.body):e.body&&this.#T(e.body)}}#di(t){let n={caught:t.catches.flatMap(r=>r.caught??[]),thrown:[]};this.#Tt.push(n);for(let r of t.resources)r.kind==="declaration"?this.#T(r.init):this.#T(r.expression);this.#pt(t.block);for(let r of[...t.resources].reverse()){let a=r.kind==="declaration"?r.symbol?.type:r.expression.type,o=r.kind==="declaration"?r.name:r.symbol?.name??"";for(let c of this.#mi(a))this.#_t(c,r.pos,[` exception thrown from implicit call to close() on resource variable \'${o}\'`])}this.#Tt.pop();let s=[];for(let r of t.catches){if(r.types.forEach((a,o)=>{let c=r.caught?.[o];if(!c||!this.#Xt(c))return;let u=c.tag==="class"?c.symbol.binaryName:"";u==="java.lang.Exception"||u==="java.lang.Throwable"||n.thrown.some(d=>K(d,c)||K(c,d))||this.#Lt.push([r.types.length===1?r.pos:a.pos,`exception ${$(c)} is never thrown in body of corresponding try statement`,void 0])}),r.symbol){let a=r.caught??[];this.#ee.set(r.symbol,n.thrown.filter(o=>a.some(c=>K(o,c))&&!s.some(c=>K(o,c))))}s.push(...r.caught??[]),this.#pt(r.block)}t.finallyBlock&&this.#pt(t.finallyBlock)}#mi(t){return t?.tag==="library"?this.#Rn(t.symbol.methods.find(n=>n.name==="close"&&!n.params.length)?.throws):!t||t.tag!=="class"?[]:this.#wt(t.symbol,"close").find(n=>n.params.length===0)?.throws??[]}#Rn(t){return(t??[]).map(e=>tt(this.#D.get(e)))}#mn(t){for(let e of t.elements)e.kind==="ArrayInitializer"?this.#mn(e):this.#T(e)}#T(t){switch(t.kind){case"MethodCall":t.target&&this.#T(t.target);for(let e of t.args)this.#T(e);if(t.method)for(let e of t.method.throws)this.#_t(e,t.pos);for(let e of this.#Rn(t.libraryCall?.throws))this.#_t(e,t.pos);return;case"NewObject":t.outerExpression&&this.#T(t.outerExpression);for(let e of t.args)this.#T(e);if(t.ctor)for(let e of t.ctor.throws)this.#_t(e,t.pos);for(let e of this.#Rn(t.libraryCall?.throws))this.#_t(e,t.pos);return;case"MethodRef":t.receiver&&this.#T(t.receiver),t.lambda&&this.#T(t.lambda);return;case"Lambda":if(t.method){let e=t.method.declaration.body;this.#Be([],()=>{for(let n of e.statements)this.#pt(n)})}return;case"SwitchExpression":this.#vs(t);return;case"FieldAccess":this.#T(t.target);return;case"Unary":case"IncDec":this.#T(t.operand);return;case"Binary":this.#T(t.left),this.#T(t.right);return;case"Assignment":this.#T(t.target),this.#T(t.value);return;case"Parenthesized":this.#T(t.expression);return;case"ArrayAccess":this.#T(t.array),this.#T(t.index);return;case"NewArray":for(let e of t.dimensions)this.#T(e);t.initializer&&this.#mn(t.initializer);return;case"Cast":this.#T(t.expression);return;case"Conditional":this.#T(t.condition),this.#T(t.whenTrue),this.#T(t.whenFalse);return;case"InstanceOf":this.#T(t.expression);return;case"ClassLiteral":case"Literal":case"Name":case"This":case"Super":return}}#ws(t){this.#o=t;let e=t.constructors.some(r=>!r.declaration.synthetic),n=this.#ks(t,!0),s=this.#ks(t,!1);this.#$.set(t,s);for(let r of t.fields)!r.isFinal||r.declarator.init||r.enumConstant||r.capturedLocal||(r.isStatic?n.get(r)?.assigned||this.#dt.push([r.declarator.pos,`variable ${r.name} might not have been initialized`]):!e&&!t.isRecord&&!s.get(r)?.assigned&&this.#dt.push([r.declarator.pos,`variable ${r.name} not initialized in the default constructor`]));for(let r of t.declaration.members)r.kind==="MethodDeclaration"&&r.symbol&&!r.symbol.declaration.synthetic&&!r.symbol.isAbstract&&this.#fn(r.symbol);for(let r of this.#Et.get(t)??[])this.#fn(r)}#ks(t,e){let n=new Map;for(let a of t.fields)a.isStatic===e&&a.isFinal&&!a.declarator.init&&!a.enumConstant&&!a.capturedLocal&&n.set(a,1e6+n.size);let s=Cr();for(let a of n.values())s.unassigned.add(a);for(let a of t.declaration.members){if(a.kind!=="Initializer"||a.isStatic!==e||!a.symbol)continue;this.#K=new Map,this.#Z=0,this.#F=[],this.#M=n;let o=this.#Me(a.body.statements,s,!0);o.completes||this.#$e(a.pos,"initializer must be able to complete normally");let c=Cr();for(let u of n.values())In(o.after,u)&&c.vars.add(u),Zn(o.after,u)&&c.unassigned.add(u);s=c}this.#M=new Map;let r=new Map;for(let[a,o]of n)r.set(a,{assigned:In(s,o),unassigned:Zn(s,o)});return r}#fn(t){let e=Cr();for(let o of t.declaration.params)o.symbol&&(e=Pe(e,o.symbol.index));for(let o of t.locals)o.parameter!==void 0&&(e=Pe(e,o.index));this.#K=new Map,this.#Z=0,this.#F=[],this.#M=new Map;let n=t.declaration.body,s=n.statements[0],r=t.isConstructor&&!t.declaration.compact&&!(s?.kind==="ConstructorCall"&&s.keyword==="this");if(r){let o=this.#$.get(t.owner);for(let c of t.owner.fields){if(c.isStatic||!c.isFinal||c.declarator.init||c.capturedLocal)continue;let u=t.locals.length+this.#M.size;this.#M.set(c,u);let d=o?.get(c);d?.assigned&&e.vars.add(u),(!d||d.unassigned)&&e.unassigned.add(u)}}let a=this.#Me(n.statements,e,!0);if(a.completes&&!a.recovery&&t.returnType.tag!=="void"&&!t.lambda&&this.#$e(t.declaration.closeBracePos??n.end-1,"missing return statement"),r){for(let[o,c]of this.#M)In(a.after,c)||this.#Pe(t.declaration.closeBracePos??n.end-1,`variable ${o.name} might not have been initialized`);for(let o of this.#F)for(let[c,u]of this.#M)In(o.state,u)||this.#Pe(o.pos,`variable ${c.name} might not have been initialized`)}this.#M=new Map}#Me(t,e,n){let s=e,r=n,a=!1;for(let o of t){r||(this.#$e(xa(o),"unreachable statement"),r=!0,a=!0,s=Qt());let c=this.#Rt(o,s,r);s=c.after,r=c.completes,c.recovery&&(a=!0)}return{after:s,completes:r,...a&&r?{recovery:!0}:{}}}#Rt(t,e,n){switch(t.kind){case"Block":return this.#Me(t.statements,e,n);case"LocalVariableDeclaration":return{after:this.#As(t,e),completes:n};case"ExpressionStatement":return{after:this.#v(t.expression,e),completes:n};case"EmptyStatement":return{after:e,completes:n};case"ConstructorCall":{let s=e;for(let r of t.args)s=this.#v(r,s);return{after:s,completes:n}}case"IfStatement":{let s=this.#yt(t.condition,e),r=this.#Rt(t.then,s.whenTrue,n);if(!t.otherwise)return{after:Ct(r.after,s.whenFalse),completes:n};let a=this.#Rt(t.otherwise,s.whenFalse,n);return{after:Ct(r.after,a.after),completes:r.completes||a.completes}}case"WhileStatement":return this.#Cs(t,t.condition,t.body,[],e,n);case"ForStatement":{let s=e;if(t.init&&!Array.isArray(t.init))s=this.#As(t.init,s);else for(let r of t.init??[])s=this.#v(r,s);return this.#Cs(t,t.condition,t.body,t.update,s,n)}case"DoStatement":return this.#pi(t,e,n);case"ForEachStatement":return this.#yi(t,e,n);case"LabeledStatement":{let s=this.#Ve(t),r=this.#Rt(t.body,e,n);return{after:Ct(r.after,...s.breaks),completes:r.completes||s.breaks.length>0}}case"SwitchStatement":return this.#gi(t,e,n);case"YieldStatement":{let s=this.#v(t.value,e);return t.target&&this.#K.get(t.target)?.yields.push(s),{after:Qt(),completes:!1}}case"BreakStatement":return t.target&&this.#K.get(t.target)?.breaks.push(e),{after:Qt(),completes:!1};case"ContinueStatement":return t.target&&this.#K.get(t.target)?.continues.push(e),{after:Qt(),completes:!1};case"ReturnStatement":{let s=t.value?this.#v(t.value,e):e;return this.#M.size&&this.#F.push({pos:t.pos,state:s}),{after:Qt(),completes:!1}}case"ThrowStatement":return this.#v(t.expression,e),{after:Qt(),completes:!1};case"AssertStatement":{let s=this.#yt(t.condition,e);return t.message&&this.#v(t.message,s.whenFalse),{after:e,completes:n}}case"TryStatement":return this.#fi(t,e,n);case"LocalClass":return{after:e,completes:n}}}#fi(t,e,n){let s=e;for(let h of t.resources)h.kind==="declaration"?(s=this.#v(h.init,s),h.symbol&&(s=Pe(s,h.symbol.index))):s=this.#v(h.expression,s);let r=this.#Rt(t.block,s,n);t.blockCompletes=r.completes;let a=[r],o=h=>{let m=ze(e);if(!h.all)for(let p of[...m.unassigned])h.unassigned.has(p)||m.unassigned.delete(p);return m};for(let h of t.catches){let m=o(r.after);h.symbol&&(m=Pe(m,h.symbol.index));let p=this.#Rt(h.block,m,n);h.completes=p.completes,a.push(p)}let c=a.filter(h=>h.completes),u=c.length?Ct(c[0].after,...c.slice(1).map(h=>h.after)):Qt();if(!t.finallyBlock)return{after:u,completes:c.length>0};let d=this.#Rt(t.finallyBlock,o(Ct(r.after,...a.map(h=>h.after))),n);return{after:il(u,d.after),completes:c.length>0&&d.completes}}#Ve(t){let e={breaks:[],continues:[],yields:[]};return this.#K.set(t,e),e}#Jn(t,e){let n=e(t,!0),s=[...t.unassigned].some(o=>!Zn(n.backEdge,o));if(!this.#M.size||t.all||!s)return n.result;let r=ze(t);for(let o of[...r.unassigned])Zn(n.backEdge,o)||r.unassigned.delete(o);this.#Z++;let a=e(r,!1);return this.#Z--,a.result}#Cs(t,e,n,s,r,a){return this.#Jn(r,(o,c)=>{let u=e?this.#yt(e,o):{whenTrue:o,whenFalse:Qt()},d=e?e.constant:Tt(!0),h=a&&!Os(d);c&&a&&!h&&this.#$e(xa(n),"unreachable statement");let m=this.#Ve(t),p=this.#Rt(n,h?u.whenTrue:Qt(),!0),k=Ct(p.after,...m.continues);for(let g of s)k=this.#v(g,k);return{backEdge:k,result:{after:Ct(u.whenFalse,...m.breaks),completes:a&&(!qn(d)||m.breaks.length>0)}}})}#pi(t,e,n){return this.#Jn(e,s=>{let r=this.#Ve(t),a=this.#Rt(t.body,s,n),o=Ct(a.after,...r.continues),c=this.#yt(t.condition,o),u=a.completes||r.continues.length>0;return{backEdge:c.whenTrue,result:{after:Ct(c.whenFalse,...r.breaks),completes:n&&(u&&!qn(t.condition.constant)||r.breaks.length>0)}}})}#yi(t,e,n){let s=this.#v(t.iterable,e);return this.#Jn(s,r=>{let a=this.#Ve(t),o=t.symbol?Pe(r,t.symbol.index):r,c=this.#Rt(t.body,o,n);return{backEdge:Ct(c.after,...a.continues),result:{after:Ct(r,...a.breaks),completes:n}}})}#gi(t,e,n){let s=this.#Es(t,this.#v(t.selector,e)),r=this.#Ve(t),a=[],o=!1;if(t.cases[0]?.arrow)for(let c of t.cases){let u=c.body,d=u.kind==="Block"?this.#Rt(u,s,n):{after:this.#v(u,s),completes:n};d.completes&&(a.push(d.after),o=!0)}else{let c=null;for(let u of t.cases){let d=c?.completes?Ct(s,c.after):s;c=this.#Me(u.statements,d,n)}(!c||c.completes)&&(a.push(c?c.after:s),o=!0)}return!t.cases.some(c=>c.isDefault)&&!t.exhaustive&&(a.push(s),o=!0),a.push(...r.breaks),r.breaks.length&&(o=!0),{after:a.length?Ct(a[0],...a.slice(1)):Qt(),completes:n&&o}}#Es(t,e){let n=e;for(let s of t.cases)s.guard&&(n=Ct(n,this.#v(s.guard,n)));return n}#bi(t,e){let n=this.#Es(t,this.#v(t.selector,e)),s=this.#Ve(t),r=[];if(t.cases[0]?.arrow)for(let a of t.cases){let o=a.body;if(o.kind!=="Block"){r.push(this.#v(o,n));continue}this.#Me(o.statements,n,!0).completes&&this.#$e(o.end-1,"switch rule completes without providing a value",[" (switch rules in switch expressions must either provide a value or throw)"])}else{let a=null;for(let o of t.cases){let c=a?.completes?Ct(n,a.after):n;a=this.#Me(o.statements,c,!0)}a?.completes&&this.#$e(t.end-1,"switch expression completes without providing a value",[" (switch expressions must either provide a value or throw for all possible input values)"])}return!t.patternSwitch&&!t.cases.some(a=>a.isDefault)&&!t.coversAllConstants&&this.#$e(t.pos,"the switch expression does not cover all possible input values"),r.push(...s.yields),r.length?Ct(r[0],...r.slice(1)):Qt()}#jn(t,e){let n=e;for(let s of t.elements)n=s.kind==="ArrayInitializer"?this.#jn(s,n):this.#v(s,n);return n}#As(t,e){let n=e;for(let s of t.declarators){let r=s.symbol;r&&(n=al(n,r.index));let a=s.init;a&&(n=a.kind==="ArrayInitializer"?this.#jn(a,n):this.#v(a,n),r&&(n=Pe(n,r.index)))}return n}#yt(t,e){if(qn(t.constant))return{whenTrue:e,whenFalse:Qt()};if(Os(t.constant))return{whenTrue:Qt(),whenFalse:e};if(t.kind==="Parenthesized")return this.#yt(t.expression,e);if(t.kind==="Unary"&&t.operator==="!"){let s=this.#yt(t.operand,e);return{whenTrue:s.whenFalse,whenFalse:s.whenTrue}}if(t.kind==="Binary"&&t.operator==="&&"){let s=this.#yt(t.left,e),r=this.#yt(t.right,s.whenTrue);return{whenTrue:r.whenTrue,whenFalse:Ct(s.whenFalse,r.whenFalse)}}if(t.kind==="Binary"&&t.operator==="||"){let s=this.#yt(t.left,e),r=this.#yt(t.right,s.whenFalse);return{whenTrue:Ct(s.whenTrue,r.whenTrue),whenFalse:r.whenFalse}}if(t.kind==="Conditional"&&t.type?.tag==="boolean"){let s=this.#yt(t.condition,e),r=this.#yt(t.whenTrue,s.whenTrue),a=this.#yt(t.whenFalse,s.whenFalse);return{whenTrue:Ct(r.whenTrue,a.whenTrue),whenFalse:Ct(r.whenFalse,a.whenFalse)}}let n=this.#v(t,e);return{whenTrue:n,whenFalse:n}}#Dn(t,e,n){return t.binding||In(n,t.index)?n:(this.#Pe(e,`variable ${t.name} might not have been initialized`),Pe(n,t.index))}#pn(t){if(!this.#M.size)return null;let e;t.kind==="Name"&&t.symbol?.kind==="field"&&!t.outerHops?e=t.symbol:t.kind==="FieldAccess"&&t.fieldSymbol&&Q(t.target).kind==="This"&&(e=t.fieldSymbol);let n=e&&this.#M.get(e);return e&&n!==void 0?{field:e,index:n}:null}#yn(t,e,n){if(In(n,t.index))return n;this.#Pe(e,`variable ${t.field.name} might not have been initialized`);let s=ze(n);return s.vars.add(t.index),s}#v(t,e){switch(t.kind){case"Literal":case"This":case"Super":return e;case"InstanceOf":return this.#v(t.expression,e);case"ClassLiteral":return e;case"Lambda":{let n=e;t.captures?.forEach((r,a)=>n=this.#Dn(r,t.capturedAt[a],n));let s=[this.#K,this.#Z,this.#F,this.#M];return t.method&&this.#fn(t.method),[this.#K,this.#Z,this.#F,this.#M]=s,n}case"MethodRef":{let n=t.receiver?this.#v(t.receiver,e):e,s=[this.#K,this.#Z,this.#F,this.#M];return t.lambda?.method&&this.#fn(t.lambda.method),[this.#K,this.#Z,this.#F,this.#M]=s,n}case"Name":{if(t.symbol?.kind==="local"&&!t.constant)return this.#Dn(t.symbol,t.pos,e);let n=this.#pn(t);return n?this.#yn(n,t.pos,e):e}case"Parenthesized":return this.#v(t.expression,e);case"FieldAccess":{let n=this.#pn(t);return n?this.#yn(n,t.pos,e):this.#v(t.target,e)}case"MethodCall":{let n=t.target?this.#v(t.target,e):e;for(let s of t.args)n=this.#v(s,n);return n}case"NewObject":{let n=t.outerExpression?this.#v(t.outerExpression,e):e;for(let s of t.args)n=this.#v(s,n);return n}case"Conditional":{let n=this.#yt(t.condition,e);return Ct(this.#v(t.whenTrue,n.whenTrue),this.#v(t.whenFalse,n.whenFalse))}case"Unary":if(t.operator==="!"){let n=this.#yt(t,e);return Ct(n.whenTrue,n.whenFalse)}return this.#v(t.operand,e);case"IncDec":{let n=Q(t.operand);n.kind==="Name"&&n.symbol?.kind==="local"&&this.#Is(n.symbol,n.pos);let s=this.#pn(Q(t.operand));return s?this.#Os(s,Q(t.operand).pos,this.#yn(s,Q(t.operand).pos,e)):this.#v(t.operand,e)}case"Cast":return this.#v(t.expression,e);case"ArrayAccess":return this.#v(t.index,this.#v(t.array,e));case"NewArray":{let n=e;for(let s of t.dimensions)n=this.#v(s,n);return t.initializer?this.#jn(t.initializer,n):n}case"SwitchExpression":return this.#bi(t,e);case"Binary":{if(t.operator==="&&"||t.operator==="||"){let n=this.#yt(t,e);return Ct(n.whenTrue,n.whenFalse)}return this.#v(t.right,this.#v(t.left,e))}case"Assignment":{let n=Q(t.target);if(n.kind==="Name"&&n.symbol?.kind==="local"){let r=t.operator==="="?e:this.#Dn(n.symbol,n.pos,e);return r=this.#v(t.value,r),this.#Is(n.symbol,n.pos),Pe(r,n.symbol.index)}let s=this.#pn(n);if(s){let r=t.operator==="="?e:this.#yn(s,n.pos,e);return r=this.#v(t.value,r),this.#Os(s,n.pos,r)}return this.#v(t.value,this.#v(t.target,e))}}}#Is(t,e){t.isFinal&&(t.forEach?this.#Pe(e,`variable ${t.name} might already have been assigned`):(t.parameter!==void 0||t.catchParameter)&&this.#Pe(e,`final parameter ${t.name} may not be assigned`))}#Os(t,e,n){if(!Zn(n,t.index)){let s=this.#Z?"might be assigned in loop":"might already have been assigned";this.#Pe(e,`variable ${t.field.name} ${s}`)}return Pe(n,t.index)}};function ce(i,t){return`${i}(${t.map(Je).join(",")})`}function ol(i,t){if(i.tag==="library"&&t.tag==="library"){if(!i.args.length||i.args.some(n=>n.tag==="wildcard"))return!1;let e=Dt(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&at(e,t)}if(i.tag!=="class"||!i.args?.length||i.args.some(e=>e.tag==="wildcard"))return!1;if(t.tag==="library"){let e=Le(i).map(n=>Dt(n,t.symbol)).find(n=>n);return e!=null&&at(e,t)}if(t.tag==="class"){let e=se(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&at(e,t)}return!1}function ts(i,t,e){return`${ce(i,t)}${Je(e)}`}function Be(i){return i.tag==="long"||i.tag==="double"?2:1}function ye(i,t){let e=n=>n.some(s=>ye(s,t));switch(i.kind){case"BreakStatement":return i.target===t;case"Block":return e(i.statements);case"IfStatement":return ye(i.then,t)||i.otherwise!==null&&ye(i.otherwise,t);case"WhileStatement":case"DoStatement":case"ForStatement":case"ForEachStatement":case"LabeledStatement":return ye(i.body,t);case"SwitchStatement":return i.cases.some(n=>e(n.statements)||n.body?.kind==="Block"&&ye(n.body,t));case"TryStatement":return ye(i.block,t)||i.catches.some(n=>ye(n.block,t))||i.finallyBlock!==null&&ye(i.finallyBlock,t);default:return!1}}function wa(i){return i.qualifiedName==="java.lang.String"?"String":i.qualifiedName}function Je(i){switch(i.tag){case"typevar":return i.symbol?Je(W(i)):"Object";case"wildcard":case"object":return"Object";case"string":return"String";case"library":return i.symbol.qualifiedName;case"class":return i.symbol.binaryName;case"array":return Je(i.element)+"[]";default:return $(i)}}function ja(i){return i.tag==="typevar"&&i.symbol?i.symbol.bounds.some(t=>ja(t)||t.tag==="library"&&t.symbol.name==="Comparable"):i.tag==="class"?i.symbol.isEnum||Tn(i.symbol).some(t=>t.symbol.name==="Comparable"):i.tag==="string"||i.tag==="library"&&(i.symbol.box!==void 0||i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer"||i.symbol.supertypes.some(t=>t.tag==="library"&&t.symbol.name==="Comparable"))}function ss(i){if(i.kind==="Name")return i.identifier;if(i.kind!=="FieldAccess")return null;let t=ss(i.target);return t===null?null:`${t}.${i.name}`}function nn(i){return`${/^[AEIOU]/i.test(i)?"an":"a"} ${i}`}function ge(i){if(!i)return;let t=i.tag==="wildcard"?i.bound??void 0:i;return t?.tag==="object"?void 0:t}var es={tag:"typevar",name:"?return"};function ue(i,t){switch(i.tag){case"typevar":return t===null?!i.symbol:t.includes(ws(i));case"class":return i.args?.some(e=>ue(e,t))??!1;case"array":return ue(i.element,t);case"wildcard":return i.bound!==null&&ue(i.bound,t);case"library":return i.args.some(e=>ue(e,t));default:return!1}}function Ps(i){if(i.tag!=="library"||!i.symbol.functional)return null;let t=i.symbol.methods.find(n=>n.name===i.symbol.functional&&!n.isStatic);if(!t)return null;let e=i.symbol.typeParams.map((n,s)=>{let r=i.args[s];return r?r.tag==="wildcard"?r.bound??G:r:G});return{params:t.params.map(n=>Xt(n,i.symbol.typeParams,e)),returnType:Xt(t.returnType,i.symbol.typeParams,e)}}function ll(i){let t=0,e=i;for(let n=i;n;n=n.captureOf)t+=n.assignCount??0,e=n;return e.isFinal&&!e.forEach?!0:e.noInitializer?t<=1:t===0}function cl(i){return i.kind==="MethodCall"||i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="NewObject"}function Ee(i){if(i.kind==="Name")return[i.identifier];if(i.kind==="FieldAccess"){let t=Ee(i.target);return t?[...t,i.name]:null}return null}var Da=new Set(["type","symbol","method","constant","libraryCall","ctor","fieldSymbol","captures","functional","caught","finallySlots","lambda","receiver","mathFunction","interfaceSymbol","imported"]);function Js(i,t){if(Array.isArray(i)){for(let n of i)Js(n,t);return}if(i===null||typeof i!="object")return;let e=i;e.kind==="Name"&&typeof e.identifier=="string"&&t(e.identifier,e.pos);for(let[n,s]of Object.entries(e))Da.has(n)||s===null||typeof s!="object"||Js(s,t)}function ul(i,t){for(let n of i.locals)n.slot+=t;i.maxSlots+=t,i.finallySlots!==void 0&&(i.finallySlots+=t);let e=n=>{if(Array.isArray(n)){for(let a of n)e(a);return}if(n===null||typeof n!="object")return;let s=n;if(s.kind==="Lambda"||s.kind==="MethodRef"||s.kind==="ClassDeclaration")return;typeof s.liveSlots=="number"&&(s.liveSlots=s.liveSlots+t);let r=s.finallySlots;r&&typeof r.base=="number"&&(r.base+=t,r.before+=t);for(let[a,o]of Object.entries(s))!Da.has(a)&&o&&typeof o=="object"&&e(o)};e(i.declaration.body)}function bt(i,t,e){if(!t)return;if(i.tag==="typevar"){let s=ws(i);if(e.has(s)||t.tag==="null"||t.tag==="diamond"||t.tag==="lambda"||t.tag==="error"||t.tag==="typevar"&&!t.symbol)return;let r=t.tag==="wildcard"&&t.poly?t.bound:nt(t)?Nr(t):t.tag==="wildcard"?t:qt(t);r&&e.set(s,r);return}if(i.tag==="wildcard"){i.bound&&bt(i.bound,t,e);return}if(i.tag==="array"&&t.tag==="array"){if(i.element.tag==="typevar"&&!nt(t.element))return;bt(i.element,t.element,e);return}let n=s=>s.tag==="wildcard"?s.bound??G:s;if(i.tag==="library"&&(t.tag==="library"||t.tag==="class"||t.tag==="typevar")){let s=t.tag==="library"?Dt(t,i.symbol):t.tag==="class"?Le(t).map(r=>Dt(r,i.symbol)).find(r=>r)??null:null;if(s)i.args.forEach((r,a)=>s.args[a]&&bt(r,r.tag==="typevar"&&!Or(s.args[a])?s.args[a]:n(s.args[a]),e));else if(t.tag==="typevar"&&t.symbol)for(let r of t.symbol.bounds)bt(i,r,e);return}if(i.tag==="class"&&i.args?.length&&(t.tag==="class"||t.tag==="typevar")){let s=se(t,i.symbol);s?.args&&i.args.forEach((r,a)=>s.args[a]&&bt(r,n(s.args[a]),e))}}function Or(i){return i.tag==="wildcard"&&i.poly!==void 0}function hl(i,t){if(i.tag!=="library"||t.tag!=="library")return null;let e=Dt(t,i.symbol);if(!e)return null;for(let[n,s]of e.args.entries()){let r=i.args[n];if(s.tag!=="wildcard"||!s.poly||!r||r.tag==="wildcard"||!s.poly.lows.some(o=>!K(o,r)))continue;let a=s.poly.lows.filter((o,c)=>s.poly.lows.findIndex(u=>at(u,o))===c);return[`inference variable ${s.poly.name} has incompatible bounds`,` equality constraints: ${$(r)}`,` lower bounds: ${[...a].reverse().map($).join(",")}`,...s.poly.where].join(`\n`)}return null}function Nr(i){return i.tag==="library"&&i.args.some(Or)?{...i,args:i.args.map(t=>Or(t)?t.bound:t)}:i}function Ms(i,t,e=!1){let n=new Map;if(t?.tag!=="library")return n;let s=pt(i,i.typeParams.map(o=>({tag:"typevar",name:o}))),r=Dt(s,t.symbol),a=o=>e&&o?.tag==="object"?o:ge(o);return r&&r.args.forEach((o,c)=>a(t.args[c])&&bt(o,a(t.args[c]),n)),n}function Er(i,t){let e=new Map;if(!t)return e;let n=fe(i);if(t.tag==="class"){let s=se(n,t.symbol);s?.args&&t.args&&s.args.forEach((r,a)=>ge(t.args[a])&&bt(r,ge(t.args[a]),e))}else if(t.tag==="library"){let s=Le(n).map(r=>Dt(r,t.symbol)).find(r=>r);s&&s.args.forEach((r,a)=>ge(t.args[a])&&bt(r,ge(t.args[a]),e))}return e}function ka(i,t,e,n,s){t.forEach((r,a)=>{let o=e[a];if(!(!o||o.tag==="null"||o.tag==="lambda"||o.tag==="diamond"||o.tag==="error"))if(r.tag==="typevar"&&r.symbol&&i.includes(r.symbol.key)){let c=nt(o)?Nr(o):qt(o);if(!c)return;let u=s.get(r.symbol.key)??[];u.some(d=>at(d,c))||u.push(c),s.set(r.symbol.key,u)}else bt(r,o,n)})}function Ca(i,t,e){if(!rs([t]).length||!nt(e))return;let n=W(e);n.tag!=="object"&&n.tag!=="null"&&!K(W(t),n)&&(i.genericCast=n)}function dl(i,t){if(t.some(s=>"all"in s))return!0;let e=t.flatMap(s=>"pattern"in s?[s.pattern]:[]),n=t.flatMap(s=>"constantOf"in s?[s]:[]);return $r(i,e,n,new Set)}function $r(i,t,e,n){let s=W(i);if(t.some(o=>o.kind==="TypePattern"&&o.tested&&K(s,W(o.tested))))return!0;let r=i.tag==="typevar"&&i.symbol?fl(i):i;if(r.tag!=="class")return!1;let a=r.symbol;if(n.has(a))return!1;if(a.isEnum){let o=new Set(e.filter(c=>c.constantOf===a).map(c=>c.ordinal));return a.enumConstants.every(c=>o.has(c.enumConstant.ordinal))}if(a.isSealed&&a.permitted){if(!a.isAbstract)return!1;let o=new Set(n).add(a);return a.permitted.every(c=>$r(tt(c),t,e,o))}if(a.isRecord){let o=t.filter(u=>u.kind==="RecordPattern"&&u.tested?.tag==="class"&&u.tested.symbol===a);if(!o.length)return!1;let c=a.components.map(u=>u.type);return Fa(c,o.map(u=>u.components),n)}return!1}function Fa(i,t,e){if(!i.length)return t.length>0;let[n,...s]=i;return _a(n).every(r=>{let a=t.filter(o=>ml(o[0],r,e));return Fa(s,a.map(o=>o.slice(1)),e)})}function _a(i){return i.tag==="class"&&i.symbol.isSealed&&i.symbol.isAbstract&&i.symbol.permitted?i.symbol.permitted.flatMap(t=>_a(tt(t))):[i]}function ml(i,t,e){return i.kind==="TypePattern"?i.unconditional===!0||i.tested!==void 0&&(st(t)?at(t,i.tested):K(W(t),W(i.tested))):t.tag==="class"&&$r(t,[i],[],e)}function fl(i){return i.symbol?.bounds[0]??G}function Lr(i,t=!1){let e=[];for(let n of t?i.members:[...i.members,...i.anonymousClasses??[]])!t&&(n.anonymous||n.local)&&n.hierarchyState!==2||e.push(...Lr(n,t),n);return e}function Ea(i){return i.declaration.params[i.declaration.params.length-1]?.varargs===!0}function Aa(i,t){let e=i.params[i.params.length-1];return!i.varargs||e?.tag!=="array"||t.length===i.params.length&&t[t.length-1].tag==="array"?i.params:[...i.params.slice(0,-1),...t.slice(i.params.length-1).map(()=>e.element)]}function Ia(i,t){if(!i.varargs||i.problem||t.length<i.params.length-1)return null;let e=i.params[i.params.length-1].element;for(let n=i.params.length-1;n<t.length;n++)if(!Ht(e,t[n]))return`varargs mismatch; ${Ue(e,t[n])}`;return null}function Ln(i){switch(i.tag){case"typevar":return!1;case"array":return Ln(i.element);case"library":return i.args.every(t=>t.tag==="wildcard"&&!t.bound);case"class":return(i.args??[]).every(t=>t.tag==="wildcard"&&!t.bound);default:return!0}}function pl(i,t){let e=n=>n.tag!=="wildcard"&&n.tag!=="typevar"&&Ln(n);if(i.tag==="library"&&t.tag==="library"&&i.args.length){let n=Dt(t,i.symbol);return n!==null&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!at(s,i.args[r]))}if(i.tag==="class"&&t.tag==="class"&&i.args?.length){let n=se(t,i.symbol);return n?.args!==void 0&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!at(s,i.args[r]))}return!1}function yl(i){return i.tag==="string"||i.tag==="class"||i.tag==="array"||i.tag==="library"&&i.symbol.box!==void 0}function Oa(i,t,e){if(!t.varargs||t.name!=="of"||!["List","Set"].includes(i.name)||e>10||t.params.length!==1)return t;let n=t.params[0].element;return{...t,varargs:!1,params:Array.from({length:e},()=>n)}}function Ve(i,t,e){let n=[],s=a=>{a.tag==="typevar"&&!a.symbol&&!n.includes(a.name)?n.push(a.name):a.tag==="array"?s(a.element):a.tag==="wildcard"&&a.bound?s(a.bound):a.tag==="library"&&a.args.forEach(s)};if(i.forEach(s),!n.length)return[];let r=[n.length===1?` where ${n[0]} is a type-variable:`:` where ${n.join(",")} are type-variables:`];for(let a of n)if(e?.typeParams?.includes(a)){let o=e.typeParamBounds?.[a],c=e.params.map((u,d)=>e.varargs&&d===e.params.length-1&&u.tag==="array"?`${$(u.element)}...`:$(u));r.push(` ${a} extends ${e.typeParamShown?.[a]??(o?$(o):"Object")} declared in method <${e.typeParams.join(",")}>${e.name}(${c.join(",")})`)}else r.push(` ${a} extends Object declared in ${t.isInterface?"interface":"class"} ${t.name}`);return r}function Re(i,t){if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&Re(i.element,t.element);let e=t.tag==="library"&&t.symbol.typeParams.length>0&&!t.args.length||t.tag==="class"&&(t.symbol.typeParams?.length??0)>0&&!t.args?.length,n=i.tag==="library"?i.args:i.tag==="class"?i.args??[]:[],s=n.length>0&&!n.every(r=>r.tag==="wildcard"&&!r.bound);return e&&s&&K(t,W(i))}function gl(i,t){let e=!1;return Js(i,n=>{n===t&&(e=!0)}),e}function Ar(i,t){if(K(i,t))return t;if(K(t,i))return i;let e=[],n=[i];for(;n.length;){let r=n.shift(),a=r.tag==="class"?Vn(r):r.tag==="library"?Sr(r):[];for(let o of a)e.some(c=>at(c,o))||(e.push(o),n.push(o))}let s=e.filter(r=>K(t,r)&&!at(r,G));return s.find(r=>r.tag==="class"&&!r.symbol.isInterface)??s.find(r=>r.tag==="class")??s.find(r=>r.tag==="library"&&!r.symbol.isInterface)??G}function bl(i){if(i.tag!=="wildcard")return i;if(i.isSuper)return i.bound??G;let t=i.bound??G;return{tag:"typevar",name:"CAP#1",symbol:{kind:"typevar",name:"CAP#1",key:`capture#${++Sl}`,bounds:[t],declaredIn:"",pos:0,ofClass:null,capture:$(i)}}}var Sl=0;function Me(i){return i.tag==="wildcard"?i.isSuper?G:i.bound??G:i}function rs(i,t=[]){let e=n=>{switch(n.tag){case"typevar":n.symbol&&!t.includes(n.symbol)&&t.push(n.symbol);return;case"array":return e(n.element);case"wildcard":n.bound&&e(n.bound);return;case"library":return n.args.forEach(e);case"class":return n.args?.forEach(e)}};return i.forEach(e),t}function Et(i,t=[]){let e=[...t],n=[];for(let r of rs(i)){if(r.capture){n.some(a=>a.name===r.name)||n.push({name:r.name,line:` ${r.name} extends ${r.bounds.map($).join(",")} from capture of ${r.capture}`});continue}e.some(a=>a.name===r.name)||e.push({name:r.name,line:` ${r.name} extends ${r.bounds.length?r.bounds.map($).join(","):"Object"} declared in ${r.declaredIn}`})}let s=(r,a,o)=>{if(!r.length)return[];let c=r.map(u=>u.name);return[c.length===1?` where ${c[0]} is ${a}:`:` where ${c.join(",")} are ${o}:`,...r.map(u=>u.line)]};return[...s(e,"a type-variable","type-variables"),...s(n,"a fresh type-variable","fresh type-variables")]}function La(i,t,e){let n=i.shown??i.params;for(let s=0;s<Math.min(t.length,n.length);s++){let r=n[s],a=r.tag==="typevar"?e.find(c=>c.name===r.name):void 0,o=qt(t[s])??t[s];if(a?.bounds.length&&o.tag!=="null"&&!a.bounds.every(c=>K(o,c)))return{variable:a,lower:o}}return null}function Na(i,t,e){let n=i.method?.typeParams;if(!n?.length||i.problem||!i.shown)return null;let s=n.map(r=>r.name).join(",");if(i.varargs?t.length<i.params.length-1:t.length!==i.params.length)return`cannot infer type-variable(s) ${s}\n${e}(actual and formal argument lists differ in length)`;for(let r=0;r<t.length&&r<i.params.length;r++)if(!(Ht(i.params[r],t[r])||Re(i.params[r],t[r])))return`cannot infer type-variable(s) ${s}\n${e}(argument mismatch; ${$(t[r])} cannot be converted to ${$(i.shown[r])})`;return null}function $a(i,t,e,n){let s=t.method,r=s.typeParams.map(o=>n.label({name:o,decl:t})).join(",");if(!(s.varargs?e.length>=s.params.length-1:e.length===s.params.length))return`cannot infer type-variable(s) ${r}\n (actual and formal argument lists differ in length)`;for(let o=0;o<Math.min(e.length,i.params.length);o++){let c=i.params[o],u=e[o];if(Ht(c,u)||Re(c,u))continue;let d=s.params[Math.min(o,s.params.length-1)];if(d.tag==="array"&&d.element.tag==="typevar"&&s.typeParams.includes(d.element.name)&&u.tag==="array"&&!nt(u.element)){let h={name:d.element.name,decl:t},m=s.typeParamBounds?.[d.element.name];return`inference variable ${n.label(h)} has incompatible bounds\n equality constraints: ${$(u.element)}\n upper bounds: ${m?n.render(m,t):"Object"}`}return`cannot infer type-variable(s) ${r}\n (argument mismatch; ${$(u)} cannot be converted to ${n.render(d,t)})`}return null}function Rs(i){let t=i.method?.owner;if(t?.typeParams?.length){let n=t.typeParams;return{text:`${i.ownerKind??(t.isInterface?"interface":"class")} ${i.owner}<${n.map(s=>s.name).join(",")}>`,where:n.map(s=>({name:s.name,line:` ${s.name} extends ${s.bounds.length?s.bounds.map($).join(","):"Object"} declared in ${s.declaredIn}`}))}}let e=i.library&&It[i.owner]?Wt(i.owner):void 0;if(e){let n=e.isInterface?"interface":"class";return e.typeParams.length?{text:`${n} ${i.owner}<${e.typeParams.join(",")}>`,where:e.typeParams.map(s=>({name:s,line:` ${s} extends Object declared in ${n} ${e.name}`}))}:{text:`${n} ${i.owner}`,where:[]}}return{text:`${i.ownerKind??"class"} ${i.owner}`,where:[]}}function Tl(i,t,e,n){if(at(i,t))return i;if(i.tag==="byte"&&t.tag==="short"||i.tag==="short"&&t.tag==="byte")return xn;let s={byte:[-128,127],short:[-32768,32767],char:[0,65535]},r=(a,o)=>{let c=s[a.tag];return c!==void 0&&o?.kind==="int"&&o.value>=c[0]&&o.value<=c[1]};return r(i,n)?i:r(t,e)?t:ns(i,t)}function Pa(i,t){return at(i,t)?i:i.tag==="null"?t:t.tag==="null"?i:G}function On(i,t){return Rt(t)?ua(i,t.tag)??i:i}function xl(i,t,e){let n=On(t,e);switch(n.kind){case"int":return X(i==="-"?-n.value:i==="~"?~n.value:n.value);case"long":return _t(i==="-"?-n.value:i==="~"?~n.value:n.value);case"double":return ie(i==="-"?-n.value:n.value);case"float":return pe(i==="-"?-n.value:n.value)}}function vl(i,t,e,n){if(i==="+"&&(t.kind==="string"||e.kind==="string"))return vr(zn(t)+zn(e));let s=t.kind==="double"||e.kind==="double"?"double":t.kind==="float"||e.kind==="float"?"float":t.kind==="long"||e.kind==="long"?"long":"int",r=i==="<<"||i===">>"||i===">>>";if(n?.tag==="long"||!r&&s==="long"&&t.kind!=="boolean"){if(r){let d=Cn(t),h=Cn(e);if(d===void 0||h===void 0)return;let m=BigInt(Number(BigInt.asUintN(6,h)));return i==="<<"?_t(d<<m):i===">>"?_t(d>>m):_t(BigInt.asUintN(64,d)>>m)}let c=Cn(t),u=Cn(e);if(c===void 0||u===void 0)return;switch(i){case"+":return _t(c+u);case"-":return _t(c-u);case"*":return _t(c*u);case"/":return u===0n?void 0:_t(c/u);case"%":return u===0n?void 0:_t(c%u);case"&":return _t(c&u);case"|":return _t(c|u);case"^":return _t(c^u);case"<":return Tt(c<u);case">":return Tt(c>u);case"<=":return Tt(c<=u);case">=":return Tt(c>=u);case"==":return Tt(c===u);case"!=":return Tt(c!==u)}return}if((s==="double"||s==="float")&&!r){let c=s==="float",u=c?Is(t):Kn(t),d=c?Is(e):Kn(e);if(u===void 0||d===void 0)return;let h=c?pe:ie;switch(i){case"+":return h(u+d);case"-":return h(u-d);case"*":return h(u*d);case"/":return h(u/d);case"%":return h(u%d);case"<":return Tt(u<d);case">":return Tt(u>d);case"<=":return Tt(u<=d);case">=":return Tt(u>=d);case"==":return Tt(u===d);case"!=":return Tt(u!==d)}return}let a=kn(t),o=t.kind==="long"||e.kind==="long"?e.kind==="long"?Number(BigInt.asIntN(32,e.value)):kn(e):kn(e);if(a!==void 0&&o!==void 0){switch(i){case"+":return X(a+o);case"-":return X(a-o);case"*":return X(Math.imul(a,o));case"/":return o===0?void 0:X(a/o);case"%":return o===0?void 0:X(a%o);case"<<":return X(a<<o);case">>":return X(a>>o);case">>>":return X(a>>>o);case"&":return X(a&o);case"|":return X(a|o);case"^":return X(a^o);case"<":return Tt(a<o);case">":return Tt(a>o);case"<=":return Tt(a<=o);case">=":return Tt(a>=o);case"==":return Tt(a===o);case"!=":return Tt(a!==o)}return}if(t.kind==="boolean"&&e.kind==="boolean"){let c=t.value,u=e.value;switch(i){case"&&":case"&":return Tt(c&&u);case"||":case"|":return Tt(c||u);case"^":case"!=":return Tt(c!==u);case"==":return Tt(c===u)}return}if(t.kind==="string"&&e.kind==="string"&&(i==="=="||i==="!=")){let c=t.value===e.value;return Tt(i==="=="?c:!c)}}var l={ICONST:1,SCONST:2,ACONST_NULL:3,LOAD:4,STORE:5,POP:6,DUP:7,DUP_X1:8,DUP_X2:9,DUP2:24,IADD:10,ISUB:11,IMUL:12,IDIV:13,IREM:14,INEG:15,ISHL:16,ISHR:17,IUSHR:18,IAND:19,IOR:20,IXOR:21,INOT:22,BNOT:23,I2C:25,ICMPEQ:30,ICMPNE:31,ICMPLT:32,ICMPLE:33,ICMPGT:34,ICMPGE:35,ACMPEQ:36,ACMPNE:37,JUMP:40,JUMP_IF_FALSE:41,JUMP_IF_TRUE:42,IINC:43,TOSTRING_INT:50,TOSTRING_BOOL:51,TOSTRING_REF:52,SCONCAT:53,TOSTRING_CHAR:54,PRINT:60,RETURN:70,RETURN_VALUE:71,INVOKE:72,NEWARRAY:80,NEWARRAY_REF:84,ALOAD:81,ASTORE:82,ARRAYLENGTH:83,STR_LENGTH:90,STR_CHARAT:91,STR_EQUALS:92,GETSTATIC:100,PUTSTATIC:101,GETFIELD:102,PUTFIELD:103,NEW:104,VALUEOF:110,OBJ_TOSTRING:111,OBJ_HASHCODE:112,OBJ_EQUALS:113,NCONST:120,LADD:121,LSUB:122,LMUL:123,LDIV:124,LREM:125,LNEG:126,LSHL:127,LSHR:128,LUSHR:129,LAND:130,LOR:131,LXOR:132,DADD:133,DSUB:134,DMUL:135,DDIV:136,DREM:137,DNEG:138,L2I:139,L2D:140,D2I:141,D2L:142,TOSTRING_LONG:143,TOSTRING_DOUBLE:144,NEWMULTI:145,CHECKNULL:146,MATH:147,INVOKE_NATIVE:148,BOX:149,UNBOX:150,STR_TOCHARS:151,LAMBDA:152,STR_COMPARETO:153,HOST_ARG:154,HOST_RESULT:155,INVOKE_VIRTUAL:156,CHECKCAST:157,INSTANCEOF:158,OBJ_SUPER:159,ENUM_VALUEOF:160,ATHROW:161,THROWABLE:162,I2B:163,I2S:164,I2F:165,L2F:166,D2F:167,FADD:168,FSUB:169,FMUL:170,FDIV:171,FREM:172,TOSTRING_FLOAT:173,IF_CMP:180,IF_K:181,IF_LL:182,IF_LK:183,IF_LNULL:184,LOAD2:185,LOADK:186,IADDK:187,IINC_JUMP:188,ALOAD_LL:189,IOPK:190,SET_BASE:191,BASE:192},Ut={FILL_TRACE:0,PRINT_TRACE:1,ADD_SUPPRESSED:2,GET_SUPPRESSED:3,CLASS_NAME:4,PRINT_UNCAUGHT:5,INIT_CAUSE:6},wl=[[1,1],[1,0],[2,0],[1,1],[1,1],[1,0],[2,1]],je={INT:0,LONG:1,DOUBLE:2,CHAR:3,BOOLEAN:4,FLOAT:5,BYTE:6,SHORT:7},Pr=["int","long","double","char","boolean","float","byte","short"],ht={ABS_I:0,ABS_L:1,ABS_D:2,MAX_I:3,MAX_L:4,MAX_D:5,MIN_I:6,MIN_L:7,MIN_D:8,SQRT:9,FLOOR:10,CEIL:11,ROUND:12,ROUND_F:13},kl=[1,1,1,2,2,2,2,2,2,1,1,1,1,1],Ot={NONE:0,INT:1,BOOLEAN:2,STRING:3,CHAR:4,CHAR_ARRAY:5,OBJECT:6,LONG:7,DOUBLE:8,FLOAT:9},Y={INT:0,BOOLEAN:1,CHAR:2,REF:3,LONG:4,DOUBLE:5,BYTE:6,SHORT:7,FLOAT:8},sn={};for(let[i,t]of Object.entries(l))sn[t]={name:i,operands:0,pop:0,push:0};var z=(i,t,e,n)=>Object.assign(sn[i],{operands:t,pop:e,push:n});z(l.ICONST,1,0,1);z(l.SCONST,1,0,1);z(l.ACONST_NULL,0,0,1);z(l.LOAD,1,0,1);z(l.STORE,1,1,0);z(l.POP,0,1,0);z(l.SET_BASE,0,2,0);z(l.BASE,0,1,1);z(l.DUP,0,1,2);z(l.DUP_X1,0,2,3);z(l.DUP_X2,0,3,4);z(l.DUP2,0,2,4);for(let i of[l.IADD,l.ISUB,l.IMUL,l.IDIV,l.IREM,l.ISHL,l.ISHR,l.IUSHR,l.IAND,l.IOR,l.IXOR])z(i,0,2,1);for(let i of[l.ICMPEQ,l.ICMPNE,l.ICMPLT,l.ICMPLE,l.ICMPGT,l.ICMPGE,l.ACMPEQ,l.ACMPNE])z(i,0,2,1);for(let i of[l.INEG,l.INOT,l.BNOT,l.I2C,l.TOSTRING_INT,l.TOSTRING_BOOL,l.TOSTRING_REF,l.TOSTRING_CHAR])z(i,0,1,1);z(l.JUMP,1,0,0);z(l.JUMP_IF_FALSE,1,1,0);z(l.JUMP_IF_TRUE,1,1,0);z(l.IINC,2,0,0);z(l.SCONCAT,0,2,1);z(l.PRINT,3,0,0);z(l.RETURN,0,0,0);z(l.RETURN_VALUE,0,1,0);z(l.INVOKE,2,0,0);z(l.NEWARRAY,1,1,1);z(l.NEWARRAY_REF,1,1,1);z(l.ALOAD,2,2,1);z(l.ASTORE,2,3,0);z(l.ARRAYLENGTH,1,1,1);z(l.STR_LENGTH,1,1,1);z(l.STR_CHARAT,1,2,1);z(l.STR_EQUALS,1,2,1);z(l.GETSTATIC,1,0,1);z(l.PUTSTATIC,1,1,0);z(l.GETFIELD,2,1,1);z(l.PUTFIELD,2,2,0);z(l.NEW,1,0,1);z(l.VALUEOF,0,1,1);z(l.OBJ_TOSTRING,1,1,1);z(l.OBJ_HASHCODE,1,1,1);z(l.OBJ_EQUALS,1,2,1);z(l.NCONST,1,0,1);for(let i of[l.LADD,l.LSUB,l.LMUL,l.LDIV,l.LREM,l.LSHL,l.LSHR,l.LUSHR,l.LAND,l.LOR,l.LXOR])z(i,0,2,1);for(let i of[l.DADD,l.DSUB,l.DMUL,l.DDIV,l.DREM])z(i,0,2,1);for(let i of[l.LNEG,l.DNEG,l.L2I,l.L2D,l.D2I,l.D2L,l.TOSTRING_LONG,l.TOSTRING_DOUBLE])z(i,0,1,1);for(let i of[l.I2B,l.I2S,l.I2F,l.L2F,l.D2F,l.TOSTRING_FLOAT])z(i,0,1,1);for(let i of[l.FADD,l.FSUB,l.FMUL,l.FDIV,l.FREM])z(i,0,2,1);z(l.NEWMULTI,2,0,1);z(l.CHECKNULL,1,1,0);z(l.MATH,1,0,1);z(l.INVOKE_NATIVE,2,0,0);z(l.BOX,1,1,1);z(l.UNBOX,2,1,1);z(l.STR_TOCHARS,1,1,1);z(l.LAMBDA,5,0,1);z(l.STR_COMPARETO,2,2,1);z(l.HOST_ARG,1,0,1);z(l.HOST_RESULT,0,1,0);z(l.INVOKE_VIRTUAL,2,0,0);z(l.CHECKCAST,1,1,1);z(l.INSTANCEOF,1,1,1);z(l.OBJ_SUPER,1,0,1);z(l.ENUM_VALUEOF,1,1,1);z(l.ATHROW,1,1,0);z(l.THROWABLE,1,0,0);z(l.IF_CMP,2,2,0);z(l.IF_K,3,1,0);z(l.IF_LL,4,0,0);z(l.IF_LK,4,0,0);z(l.IF_LNULL,3,0,0);z(l.LOAD2,2,0,2);z(l.LOADK,2,0,2);z(l.IADDK,1,1,1);z(l.IINC_JUMP,3,0,0);z(l.ALOAD_LL,4,0,1);z(l.IOPK,2,1,1);var Mr={[l.IF_CMP]:2,[l.IF_K]:3,[l.IF_LL]:4,[l.IF_LK]:4,[l.IF_LNULL]:3,[l.IINC_JUMP]:3},Cl={[l.IF_LL]:[2,3],[l.IF_LK]:[2],[l.IF_LNULL]:[2],[l.LOAD2]:[1,2],[l.LOADK]:[1],[l.IINC_JUMP]:[1],[l.ALOAD_LL]:[1,2]},Rr=new Set([l.IMUL,l.IDIV,l.IREM,l.IAND,l.IOR,l.IXOR,l.ISHL,l.ISHR,l.IUSHR]),El=new Set([l.IF_CMP,l.IF_K,l.IF_LL,l.IF_LK]),Al=new Set([l.ATHROW,l.ARRAYLENGTH,l.STR_LENGTH,l.STR_CHARAT,l.STR_EQUALS,l.OBJ_TOSTRING,l.OBJ_HASHCODE,l.OBJ_EQUALS,l.CHECKNULL,l.STR_TOCHARS,l.STR_COMPARETO]),Il=new Set([l.ALOAD,l.ASTORE,l.INVOKE,l.INVOKE_VIRTUAL,l.GETFIELD,l.PUTFIELD,l.INVOKE_NATIVE,l.UNBOX,l.STR_COMPARETO]),Ua=new Set(["removeEldestEntry(Entry)"]),ot=class extends Error{constructor(t){super(`invalid bytecode: ${t}`),this.name="BytecodeError"}};function Ba(i,t){let e=t.classes??[],n=Math.max(0,...e.map(d=>d.instanceFieldIsReference.length)),s=i.code,r=new Set;for(let d=0;d<s.length;){let h=sn[s[d]];if(!h)throw new ot(`unknown opcode ${s[d]} at ${d}`);if(r.add(d),d+=1+h.operands,d>s.length)throw new ot("truncated instruction at end")}let a=new Map,o=[[0,0]],c=i.handlers??new Int32Array(0);if(c.length%4!==0)throw new ot("bad handler table");for(let d=0;d<c.length;d+=4){let[h,m,p,k]=[c[d],c[d+1],c[d+2],c[d+3]];if(!r.has(h)||!(r.has(m)||m===s.length)||m<=h||!r.has(p))throw new ot(`bad handler ${d/4}`);if(k<-1||k>=t.strings.length)throw new ot(`bad handler type ${d/4}`);o.push([p,1])}let u=0;for(;o.length;){let[d,h]=o.pop(),m=d,p=h;for(;;){if(!r.has(m))throw new ot(`control reaches non-instruction offset ${m}`);let k=a.get(m);if(k!==void 0){if(k!==p)throw new ot(`stack height ${p} != ${k} at merge ${m}`);break}a.set(m,p);let g=s[m],O=sn[g],T=O.pop,x=O.push;if(g===l.PRINT&&(T=s[m+3]===Ot.NONE?0:1),g===l.NEWMULTI&&(T=s[m+2]),g===l.MATH){let C=kl[s[m+1]];if(C===void 0)throw new ot(`bad Math function at ${m}`);T=C}if(g===l.INVOKE||g===l.INVOKE_VIRTUAL){let C=t.methods[s[m+1]];if(!C)throw new ot(`call to unknown method ${s[m+1]} at ${m}`);T=C.argCount,x=C.returnsValue?1:0}if(g===l.INVOKE_NATIVE){let C=t.natives?.[s[m+1]];if(!C)throw new ot(`call to unknown native ${s[m+1]} at ${m}`);T=C.argCount,x=C.returnsValue?1:0}if((g===l.BOX||g===l.UNBOX)&&(s[m+1]<0||s[m+1]>=Pr.length))throw new ot(`bad box kind at ${m}`);if(g===l.LAMBDA){let C=t.methods[s[m+1]],M=s[m+2];if(!C||M<0||M>C.argCount)throw new ot(`bad lambda method at ${m}`);if(s[m+3]<0||s[m+3]>=t.strings.length||s[m+5]>=t.strings.length)throw new ot(`bad lambda interface at ${m}`);T=M}if(g===l.NEW&&(s[m+1]<0||s[m+1]>=e.length))throw new ot(`bad class index at ${m}`);if(g===l.INVOKE_VIRTUAL&&t.methods[s[m+1]]?.selector===void 0)throw new ot(`virtual call to a method without a selector at ${m}`);if(g===l.THROWABLE){let C=wl[s[m+1]];if(!C)throw new ot(`bad Throwable operation at ${m}`);[T,x]=C}if(g===l.OBJ_SUPER){let C=s[m+1];if(C<0||C>2)throw new ot(`bad Object method at ${m}`);T=C===2?2:1}if((g===l.NEWARRAY_REF||g===l.NEWMULTI||g===l.CHECKCAST||g===l.INSTANCEOF)&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new ot(`bad descriptor index at ${m}`);if(g===l.NEWMULTI&&s[m+2]<2)throw new ot(`NEWMULTI needs two or more lengths at ${m}`);if(g===l.NCONST&&(s[m+1]<0||s[m+1]>=(t.numbers?.length??0)))throw new ot(`bad number index at ${m}`);if(p<T)throw new ot(`stack underflow at ${m} (${O.name})`);if(p=p-T+x,u=Math.max(u,p),g===l.LOAD||g===l.STORE||g===l.IINC){let C=s[m+1];if(C<0||C>=i.maxLocals)throw new ot(`bad local slot ${C} at ${m}`)}for(let C of Cl[g]??[]){let M=s[m+C];if(M<0||M>=i.maxLocals)throw new ot(`bad local slot ${M} at ${m}`)}if(g===l.IOPK&&!Rr.has(s[m+1]))throw new ot(`bad operator at ${m}`);if(g===l.IOPK&&(s[m+1]===l.IDIV||s[m+1]===l.IREM)&&s[m+2]===0)throw new ot(`division by a zero constant at ${m}`);if(El.has(g)&&(s[m+1]<0||s[m+1]>11))throw new ot(`bad condition at ${m}`);if(g===l.ALOAD_LL&&(s[m+4]<-1||s[m+4]>=t.messages.length))throw new ot(`bad message index at ${m}`);if(g===l.SCONST&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new ot(`bad string index at ${m}`);if(g===l.GETSTATIC||g===l.PUTSTATIC||g===l.GETFIELD||g===l.PUTFIELD){let C=g<=l.PUTSTATIC?t.staticFieldIsReference?.length??0:n;if(s[m+1]<0||s[m+1]>=C)throw new ot(`bad field index at ${m}`)}let v=Il.has(g)?s[m+2]:Al.has(g)?s[m+1]:null;if(v!==null&&(v<-1||v>=t.messages.length))throw new ot(`bad message index at ${m}`);if(g===l.RETURN||g===l.RETURN_VALUE){if(g===l.RETURN_VALUE!==i.returnsValue)throw new ot(`wrong return kind at ${m}`);if(p!==0)throw new ot(`return with non-empty stack at ${m}`);break}if(g===l.ATHROW)break;let R=m+1+O.operands,L=Mr[g];if(L!==void 0){let C=s[m+L];if(!r.has(C))throw new ot(`jump to ${C} at ${m}`);if(o.push([C,p]),g===l.IINC_JUMP)break}if(g===l.JUMP||g===l.JUMP_IF_FALSE||g===l.JUMP_IF_TRUE){let C=s[m+1];if(!r.has(C))throw new ot(`jump to ${C} at ${m}`);if(o.push([C,p]),g===l.JUMP)break}if(R>=s.length)throw new ot(`falls off the end at ${m}`);m=R}}return u}function Va(i,t){let e=i.lines,n=0;for(let s=0;s<e.length&&!(e[s]>t);s+=2)n=e[s+1];return n}var Ol=l.ICMPEQ,js=i=>i!==void 0&&i>=l.ICMPEQ&&i<=l.ICMPGE,Ds=(i,t)=>i-Ol+(t===l.JUMP_IF_FALSE?6:0),as=i=>i===l.JUMP_IF_FALSE||i===l.JUMP_IF_TRUE;function Ha(i){let t=i.code,e=[];for(let u=0;u<t.length;u+=1+sn[t[u]].operands)e.push(u);let n=new Set;for(let u of e){let d=t[u];(d===l.JUMP||d===l.JUMP_IF_FALSE||d===l.JUMP_IF_TRUE)&&n.add(t[u+1])}let s=i.handlers??new Int32Array(0);for(let u=0;u<s.length;u+=4)n.add(s[u]).add(s[u+1]).add(s[u+2]);for(let u=0;u<i.lines.length;u+=2)n.add(i.lines[u]);let r=[],a=new Map,o=[];for(let u=0;u<e.length;){let d=x=>e[u+x],h=x=>d(x)===void 0?void 0:t[d(x)],m=(x,v=1)=>t[d(x)+v],p=x=>{for(let v=1;v<x;v++)if(d(v)===void 0||n.has(d(v)))return!1;return!0},k=(x,...v)=>{let R=r.length;for(let C=0;C<x;C++)a.set(d(C),R);r.push(...v);let L=Mr[v[0]];L!==void 0&&o.push(R+L),u+=x},g=h(0);if(g===l.LOAD&&h(1)===l.LOAD&&js(h(2))&&as(h(3))&&p(4)){k(4,l.IF_LL,Ds(h(2),h(3)),m(0),m(1),m(3));continue}if(g===l.LOAD&&h(1)===l.ICONST&&js(h(2))&&as(h(3))&&p(4)){k(4,l.IF_LK,Ds(h(2),h(3)),m(0),m(1),m(3));continue}if(g===l.LOAD&&h(1)===l.ACONST_NULL&&(h(2)===l.ACMPEQ||h(2)===l.ACMPNE)&&as(h(3))&&p(4)){let x=h(2)===l.ACMPEQ==(h(3)===l.JUMP_IF_TRUE);k(4,l.IF_LNULL,x?1:0,m(0),m(3));continue}if(g===l.ICONST&&js(h(1))&&as(h(2))&&p(3)){k(3,l.IF_K,Ds(h(1),h(2)),m(0),m(2));continue}if(js(g)&&as(h(1))&&p(2)){k(2,l.IF_CMP,Ds(g,h(1)),m(1));continue}if(g===l.LOAD&&h(1)===l.LOAD&&h(2)===l.ALOAD&&p(3)){k(3,l.ALOAD_LL,m(0),m(1),m(2),m(2,2));continue}if(g===l.ICONST&&(h(1)===l.IADD||h(1)===l.ISUB)&&p(2)){k(2,l.IADDK,h(1)===l.IADD?m(0):-m(0)|0);continue}if(g===l.ICONST&&Rr.has(h(1))&&p(2)&&!((h(1)===l.IDIV||h(1)===l.IREM)&&m(0)===0)){k(2,l.IOPK,h(1),m(0));continue}if(g===l.IINC&&h(1)===l.JUMP&&p(2)){k(2,l.IINC_JUMP,m(0),m(0,2),m(1));continue}if(g===l.LOAD&&h(1)===l.LOAD&&p(2)){k(2,l.LOAD2,m(0),m(1));continue}if(g===l.LOAD&&h(1)===l.ICONST&&p(2)){k(2,l.LOADK,m(0),m(1));continue}let O=d(0),T=1+sn[g].operands;a.set(O,r.length),(g===l.JUMP||g===l.JUMP_IF_FALSE||g===l.JUMP_IF_TRUE)&&o.push(r.length+1);for(let x=0;x<T;x++)r.push(t[O+x]);u++}if(r.length===t.length)return;a.set(t.length,r.length);let c=u=>{let d=a.get(u);if(d===void 0)throw new Error(`fuse: offset ${u} is not an instruction start`);return d};for(let u of o)r[u]=c(r[u]);i.code=Int32Array.from(r),i.lines=i.lines.map((u,d)=>d%2===0?c(u):u),i.handlers&&(i.handlers=i.handlers.map((u,d)=>d%4===3?u:c(u)))}var Nl=["getMessage","getLocalizedMessage","getCause","toString","fillInStackTrace"];function Fr(i,t){return i.declaration.members.filter(e=>e.kind==="Initializer"&&e.isStatic===t&&e.symbol!==void 0)}function za(i){return Math.max(i.maxSlots,i.finallySlots??0)}function Ur(i,t,e){let n=new _r(t),s=i.classes.find(g=>g.binaryName==="java.lang.Throwable");n.useThrowable(s);let r=new Set(i.failedFiles??[]),a=g=>g.topLevel.file!==void 0&&r.has(g.topLevel.file.name),o=i.methods.map(g=>g.builtin?n.builtin(g):g.isAbstract||a(g.owner)?n.abstractStub(g):g.isConstructor?n.constructorCode(g):n.method(g)),c=new Map;for(let g of i.classes)for(let O of g.bridges??[])c.set(O,O.alias?O.target.index:o.push(n.bridge(g,O))-1);let u=$l(i,c),d=g=>i.selectors.get(g)??-1,h=i.classes.map(g=>{let O=g.fields.filter(j=>j.isStatic&&j.declarator.init&&!j.constant),T=Fr(g,!0),x=!a(g)&&(O.length||g.enumConstants.length||T.length)?o.push(n.staticInitializer(g,O))-1:-1,v=new Array(g.instanceCount).fill(!1);for(let j=g;j;j=j.superclass){j.outerField>=0&&(v[j.outerField]=!0);for(let P of j.fields)P.isStatic||(v[P.index]=ls(P.type));j===s&&v.fill(!0,yt.message,yt.causeSet)}let R=u.get(g),L=j=>d(j)>=0?R[d(j)]:-1,C={};R.forEach(j=>{if(j<0||j>=i.methods.length)return;let P=i.methods[j],B=`${P.name}/${P.params.length}`;(!(B in C)||P.owner===g)&&(C[B]=j)});let M=[];for(let j=g;j;j=j.superclass)M.unshift(j);for(let j of M)for(let P of j.bridges??[])P.library&&(C[`${P.name}/${P.params.length}`]=R[P.selector]);let _={};for(let j of M)for(let[P,B]of j.libraryOverrides??[])_[P]=R[B];return{name:g.binaryName,instanceFieldIsReference:v,clinit:x,toString:L("toString()String"),equals:L("equals(Object)boolean"),hashCode:L("hashCode()int"),superclass:g.superclass?.index??-1,isInterface:g.isInterface,types:Pl(g),vtable:R,virtuals:C,...Object.keys(_).length?{libraryOverrides:_}:{},...g.isEnum?{enumConstants:g.enumConstants.map(j=>j.index),canonicalName:g.binaryName.replace(/\\$/g,".")}:{}}}),m=o.push(e?n.practiceLauncher(e):n.launcher(i))-1,p=o.push(n.uncaughtPrinter(s))-1,k={version:14,classes:h,strings:n.strings,numbers:n.numbers,natives:n.natives,messages:n.messages,methods:o,staticFieldIsReference:i.staticFields.map(g=>ls(g.type)),staticFieldOwner:i.staticFields.map(g=>g.owner.index),entry:m,uncaught:p};for(let g of o)Ha(g),g.maxStack=Ba(g,k);return k}function $l(i,t){let e=i.selectors.size,n=new Map,s=(a,o=[])=>{for(let c of a.interfaces)o.includes(c)||o.push(c),s(c,o);return a.superclass&&s(a.superclass,o),o},r=a=>{let o=n.get(a);if(o)return o;let c=a.superclass?r(a.superclass).slice():new Int32Array(e).fill(-1);for(let u of a.methods)u.selector!==void 0&&(c[u.selector]=u.index);for(let u of s(a))for(let d of u.methods){if(d.selector===void 0||d.isAbstract)continue;let h=c[d.selector];(h<0||i.methods[h].isAbstract)&&(c[d.selector]=d.index)}for(let u of a.bridges??[])c[u.selector]=t.get(u);return n.set(a,c),c};for(let a of i.classes)r(a);return n}function Pl(i){let t=new Set,e=s=>{t.add(s.qualifiedName);for(let r of s.supertypes)r.tag==="library"&&e(r.symbol)},n=s=>{t.add(s.binaryName),s.isEnum&&t.add("java.lang.Enum").add("java.lang.Comparable");for(let r of s.libraryInterfaces)t.add(r.symbol.qualifiedName);s.librarySuperclass&&e(s.librarySuperclass.symbol),s.superclass&&n(s.superclass);for(let r of s.interfaces)n(r)};return n(i),i.isRecord&&t.add("java.lang.Record"),t.add("java.lang.Object"),[...t]}var et=class{pc=-1;uses=[]};function Ge(i){switch(i.tag){case"int":return Y.INT;case"boolean":return Y.BOOLEAN;case"char":return Y.CHAR;case"long":return Y.LONG;case"double":return Y.DOUBLE;case"byte":return Y.BYTE;case"short":return Y.SHORT;case"float":return Y.FLOAT;case"string":case"class":case"array":case"library":case"diamond":case"object":case"typevar":return Y.REF;default:throw new Error(`codegen: array of ${$(i)}`)}}var Ga=["int","byte/boolean","char","object","long","double","byte/boolean","short","float"];function Nn(i){return i.tag==="class"?i.symbol.binaryName:i.tag==="array"?Nn(i.element)+"[]":$(i)}function De(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}function Jr(i){let t=De(i);return t.kind==="Name"&&t.symbol?.kind==="type"||t.kind==="FieldAccess"&&t.typeSymbol!==void 0}function jr(i,t){return i.tag==="double"||t.tag==="double"?ft:i.tag==="float"||t.tag==="float"?kt:i.tag==="long"||t.tag==="long"?Jt:V}var Ml=new Set(["int","byte","short","char","long","float","double"]),os=i=>i!==void 0&&Ml.has(i.tag),Dr=i=>i.tag==="int"||i.tag==="byte"||i.tag==="short"||i.tag==="char",Ae=i=>os(i)||i?.tag==="boolean",ae={int:je.INT,long:je.LONG,double:je.DOUBLE,char:je.CHAR,boolean:je.BOOLEAN,float:je.FLOAT,byte:je.BYTE,short:je.SHORT},Rl={int:"java.lang.Integer.intValue()",long:"java.lang.Long.longValue()",double:"java.lang.Double.doubleValue()",char:"java.lang.Character.charValue()",boolean:"java.lang.Boolean.booleanValue()",float:"java.lang.Float.floatValue()",byte:"java.lang.Byte.byteValue()",short:"java.lang.Short.shortValue()"},Jl={"+":{int:l.IADD,long:l.LADD,double:l.DADD,float:l.FADD},"-":{int:l.ISUB,long:l.LSUB,double:l.DSUB,float:l.FSUB},"*":{int:l.IMUL,long:l.LMUL,double:l.DMUL,float:l.FMUL},"/":{int:l.IDIV,long:l.LDIV,double:l.DDIV,float:l.FDIV},"%":{int:l.IREM,long:l.LREM,double:l.DREM,float:l.FREM},"<<":{int:l.ISHL,long:l.LSHL},">>":{int:l.ISHR,long:l.LSHR},">>>":{int:l.IUSHR,long:l.LUSHR},"&":{int:l.IAND,long:l.LAND},"|":{int:l.IOR,long:l.LOR},"^":{int:l.IXOR,long:l.LXOR}},Fs={"<":l.ICMPLT,"<=":l.ICMPLE,">":l.ICMPGT,">=":l.ICMPGE,"==":l.ICMPEQ,"!=":l.ICMPNE},jl={"abs-int":ht.ABS_I,"abs-long":ht.ABS_L,"abs-double":ht.ABS_D,"max-int":ht.MAX_I,"max-long":ht.MAX_L,"max-double":ht.MAX_D,"min-int":ht.MIN_I,"min-long":ht.MIN_L,"min-double":ht.MIN_D,"abs-float":ht.ABS_D,"max-float":ht.MAX_D,"min-float":ht.MIN_D,"round-float":ht.ROUND_F,sqrt:ht.SQRT,floor:ht.FLOOR,ceil:ht.CEIL,"round-double":ht.ROUND},_s=class{segments=[];start=-1;open(t){this.start<0&&(this.start=t)}close(t){this.start>=0&&t>this.start&&this.segments.push([this.start,t]),this.start=-1}},_r=class{strings=[];numbers=[];natives=[];#d=new Map;messages=[];#z=new Map;#It=new Map;#rt=new Map;#G;get#Ot(){return this.#O?.topLevel?.file??this.#G}#O;#R=[];#bt=[];#m=-1;#C=new Map;#W=V;#V=0;#ut=!1;#X=[];#r=0;#p=0;#s=0;#n=0;#S=[];#l=[];#i=Object.create(null);constructor(t){this.#G=t}#D(t){return`${t.owner.binaryName}.${t.name}(${t.params.map(Nn).join(", ")})`}#kt(t,e){return`${t.qualifier??e.owner.binaryName}.${e.name}(${e.params.map(Nn).join(", ")})`}#E(t,e,n){this.#O=t,this.#R=[],this.#bt=[],this.#m=-1,this.#C=new Map,this.#W=n,this.#V=e,this.#X=[],this.#r=0,this.#p=0,this.#s=0,this.#n=0,this.#S=[],this.#l=[]}useThrowable(t){for(let e of t.methods)Nl.includes(e.name)&&(this.#i[e.name]=e)}#Y(t){if(t.lambda){let s=t.locals.filter(r=>r.parameter!==void 0).sort((r,a)=>r.parameter-a.parameter);return s.some(r=>r.type.tag==="long"||r.type.tag==="double")?Int32Array.from([...t.isStatic?[]:[0],...s.map(r=>r.slot)]):void 0}let e=t.declaration.params;if(!e.some(s=>s.symbol&&(s.symbol.type.tag==="long"||s.symbol.type.tag==="double")))return;let n=(t.isStatic?0:1)+(t.isConstructor&&t.owner.isInner?1:0)+(t.isConstructor&&(t.owner.isEnum||t.owner.enumBody)?2:0);return Int32Array.from([...Array.from({length:n},(s,r)=>r),...e.map(s=>s.symbol.slot)])}#A(t,e){let n={className:t.binaryName,classIndex:t.index,isStatic:e.isStatic,name:e.name,display:e.display,file:this.#Ot.name.replace(/^.*\\//,""),argCount:e.argCount,returnsValue:e.returnsValue,code:Int32Array.from(this.#R),lines:Int32Array.from(this.#bt),maxLocals:Math.max(1,this.#V+this.#n),maxStack:0};return e.hidden&&(n.hidden=!0),this.#S.length&&(n.handlers=Int32Array.from(this.#S)),n}#Q(t){return t.parameter!==void 0?`<parameter${t.parameter}>`:`<local${this.#u(t)}>`}#u(t){let e=t.slot;for(let n of this.#X)t.slot>=n.from&&(e+=n.by);return e}#x(){let t=this.#V+this.#s++;return this.#n=Math.max(this.#n,this.#s),t}#I(){this.#s--}staticInitializer(t,e){this.#E(t,Math.max(1,...Fr(t,!0).map(n=>za(n.symbol))),V);for(let n of t.enumConstants){let{node:s,ordinal:r}=n.enumConstant;this.#f(s.pos),this.#t(l.NEW,s.ctor.owner.index,l.DUP,l.SCONST,this.#g(s.name),l.ICONST,r),this.#et(s.args,s.ctor.params,s.varargs),this.#t(l.INVOKE,s.ctor.index,-1,l.PUTSTATIC,n.index)}return this.#Ct(t,!0,n=>e.includes(n),0),this.#t(l.RETURN),this.#A(t,{name:"<clinit>",display:`${t.binaryName}.<clinit>()`,isStatic:!0,argCount:0,returnsValue:!1})}#Ct(t,e,n,s){for(let r of t.declaration.members)if(r.kind==="FieldDeclaration")for(let a of r.declarators){let o=a.field;o&&o.isStatic===e&&n(o)&&this.#me(o)}else r.kind==="Initializer"&&r.isStatic===e&&r.symbol&&(s&&this.#X.push({from:1,by:s}),this.#L(r.body),s&&this.#X.pop())}#me(t){let e=t.declarator.init;this.#f(t.declarator.pos),t.isStatic||this.#t(l.LOAD,0),e.kind==="ArrayInitializer"?this.#w(e):(this.#h(e,!0),this.#ot(t.type,e)),t.isStatic?this.#t(l.PUTSTATIC,t.index):this.#t(l.PUTFIELD,t.index,-1)}constructorCode(t){let e=t.owner,n=e.isInner?1:e.isEnum||e.enumBody?2:0,s=t.params.length+1+n,r=1+n+t.params.reduce((m,p)=>m+(p.tag==="long"||p.tag==="double"?2:1),0),a=Fr(e,!1).map(m=>r-1+za(m.symbol));this.#E(e,Math.max(s,t.maxSlots,t.finallySlots??0,...a),V);let o=t.declaration.body,c=o.statements,u=c[0];if(u?.kind==="ConstructorCall"&&u.keyword==="this")this.#f(u.start),this.#t(l.LOAD,0),n&&this.#t(l.LOAD,1),n===2&&this.#t(l.LOAD,2),this.#et(u.args,u.target.params,u.varargs),this.#t(l.INVOKE,u.target.index,-1),c=c.slice(1);else{if(e.isInner&&this.#t(l.LOAD,0,l.LOAD,1,l.PUTFIELD,e.outerField,-1),e.isEnum&&this.#t(l.LOAD,0,l.LOAD,1,l.PUTFIELD,0,-1,l.LOAD,0,l.LOAD,2,l.PUTFIELD,1,-1),u?.kind==="ConstructorCall")u.target?(this.#f(u.start),this.#t(l.LOAD,0),this.#et(u.args,u.target.params,u.varargs),this.#t(l.INVOKE,u.target.index,-1)):u.libraryCall&&(this.#f(u.start),this.#t(l.LOAD,0),this.#et(u.args,u.libraryCall.params),this.#t(l.INVOKE_NATIVE,this.#H(u.libraryCall.native,u.args.length,!0,u.libraryCall.unwrap,u.libraryCall.unwrapCalls),-1,l.SET_BASE)),c=c.slice(1);else if(t.forwardsToSuper){if(t.superLibrary){this.#f(o.pos),this.#t(l.LOAD,0);let m=1+n;for(let p of t.params)this.#t(l.LOAD,m),m+=p.tag==="long"||p.tag==="double"?2:1;this.#t(l.INVOKE_NATIVE,this.#H(t.superLibrary.native,t.params.length,!0,t.superLibrary.unwrap,t.superLibrary.unwrapCalls),-1,l.SET_BASE)}else if(t.superConstructor){this.#f(o.pos),this.#t(l.LOAD,0),e.enumBody&&this.#t(l.LOAD,1,l.LOAD,2);let m=1+n;for(let p of t.params)this.#t(l.LOAD,m),m+=p.tag==="long"||p.tag==="double"?2:1;this.#t(l.INVOKE,t.superConstructor.index,-1)}}else t.superConstructor?(this.#f(o.pos),this.#t(l.LOAD,0),this.#et([],t.superConstructor.params,t.superVarargs),this.#t(l.INVOKE,t.superConstructor.index,-1)):t.superLibrary&&(this.#f(o.pos),this.#t(l.LOAD,0,l.INVOKE_NATIVE,this.#H(t.superLibrary.native,0,!0),-1,l.SET_BASE));this.#Ct(e,!1,m=>m.declarator.init!==void 0&&m.declarator.init!==null,r-1)}for(let m of c)this.#L(m);this.#f(o.end-1),t.declaration.compact&&t.declaration.params.forEach((m,p)=>this.#t(l.LOAD,0,l.LOAD,m.symbol.slot,l.PUTFIELD,e.components[p].index,-1)),this.#t(l.RETURN);let d=this.#A(e,{name:"<init>",display:`${e.binaryName}.<init>(${t.params.map(Nn).join(", ")})`,isStatic:!1,argCount:s,returnsValue:!1}),h=this.#Y(t);return h&&(d.argSlots=h),d}launcher(t){let e=t.main,n=t.mainClass;return this.#E(n,1,V),e.isStatic||this.#t(l.NEW,n.index,l.DUP,l.INVOKE,t.mainConstructor.index,-1),e.params.length&&this.#t(l.ICONST,0,l.NEWARRAY,Y.REF),this.#t(l.INVOKE,e.index,-1,l.RETURN),this.#bt=[],this.#A(n,{name:"<launch>",display:"<launch>",isStatic:!0,argCount:0,returnsValue:!1,hidden:!0})}practiceLauncher(t){let{method:e}=t,n=e.owner;return this.#E(n,1,V),e.isStatic||this.#t(l.NEW,n.index,l.DUP,l.INVOKE,t.constructor.index,-1),e.params.forEach((s,r)=>this.#t(l.HOST_ARG,r)),this.#t(l.INVOKE,e.index,-1),e.returnType.tag!=="void"&&this.#t(l.HOST_RESULT),this.#t(l.RETURN),this.#bt=[],this.#A(n,{name:"<practice>",display:"<practice>",isStatic:!0,argCount:0,returnsValue:!1,hidden:!0})}builtin(t){let e=t.owner,n=t.params.length+(t.isStatic?0:1);this.#E(e,Math.max(n,t.maxSlots,t.finallySlots??0),t.returnType),this.#f(e.declaration.keywordPos);let s=a=>this.#t(l.LOAD,0,l.GETFIELD,a.index,-1);switch(t.builtin){case"enum-values":this.#t(l.ICONST,e.enumConstants.length,l.NEWARRAY_REF,this.#g(`[L${e.binaryName};`)),e.enumConstants.forEach((a,o)=>this.#t(l.DUP,l.ICONST,o,l.GETSTATIC,a.index,l.ASTORE,Y.REF,-1)),this.#t(l.RETURN_VALUE);break;case"enum-valueOf":this.#t(l.LOAD,0,l.ENUM_VALUEOF,e.index,l.RETURN_VALUE);break;case"enum-name":case"enum-toString":this.#t(l.LOAD,0,l.GETFIELD,0,-1,l.RETURN_VALUE);break;case"enum-ordinal":this.#t(l.LOAD,0,l.GETFIELD,1,-1,l.RETURN_VALUE);break;case"library-toString":this.#t(l.LOAD,0,l.BASE,l.INVOKE_NATIVE,this.#H("toString()",1,!0),-1,l.RETURN_VALUE);break;case"library-hashCode":this.#t(l.LOAD,0,l.BASE,l.INVOKE_NATIVE,this.#H("hashCode()",1,!0),-1,l.RETURN_VALUE);break;case"library-equals":this.#t(l.LOAD,0,l.BASE,l.LOAD,1,l.INVOKE_NATIVE,this.#H("equals(Object)",2,!0,2,["size()","get(Object)","containsKey(Object)"]),-1,l.RETURN_VALUE);break;case"enum-compareTo":this.#t(l.LOAD,0,l.GETFIELD,1,-1,l.LOAD,1,l.GETFIELD,1,this.#ee(\'Cannot invoke "Object.getClass()" because "other" is null\'),l.ISUB,l.RETURN_VALUE);break;case"record-constructor":{let a=1;for(let o of e.components)this.#t(l.LOAD,0,l.LOAD,a,l.PUTFIELD,o.index,-1),a+=o.type.tag==="long"||o.type.tag==="double"?2:1;this.#t(l.RETURN);break}case"record-accessor":s(e.components[t.component]),this.#t(l.RETURN_VALUE);break;case"record-toString":this.#it(e);break;case"record-hashCode":this.#St(e);break;case"record-equals":this.#$(e);break;case"throwable-constructor":this.#o(t);break;case"throwable-getMessage":this.#t(l.LOAD,0,l.GETFIELD,yt.message,-1,l.RETURN_VALUE);break;case"throwable-getLocalizedMessage":this.#t(l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.getMessage.index,-1,l.RETURN_VALUE);break;case"throwable-getCause":this.#t(l.LOAD,0,l.GETFIELD,yt.cause,-1,l.RETURN_VALUE);break;case"throwable-initCause":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,Ut.INIT_CAUSE,l.RETURN_VALUE);break;case"throwable-toString":{let a=new et,o=this.#x();this.#t(l.LOAD,0,l.THROWABLE,Ut.CLASS_NAME,l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.getLocalizedMessage.index,-1,l.STORE,o),this.#t(l.LOAD,o,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,a),this.#t(l.SCONST,this.#g(": "),l.SCONCAT,l.LOAD,o,l.SCONCAT),this.#P(a),this.#t(l.RETURN_VALUE),this.#I();break}case"throwable-printStackTrace":this.#t(l.LOAD,0,l.THROWABLE,Ut.PRINT_TRACE,l.RETURN);break;case"throwable-addSuppressed":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,Ut.ADD_SUPPRESSED,l.RETURN);break;case"throwable-getSuppressed":this.#t(l.LOAD,0,l.THROWABLE,Ut.GET_SUPPRESSED,l.RETURN_VALUE);break;case"throwable-fillInStackTrace":this.#t(l.LOAD,0,l.THROWABLE,Ut.FILL_TRACE,l.RETURN_VALUE);break}let r=this.#A(e,{name:t.isConstructor?"<init>":t.name,display:t.isConstructor?`${e.binaryName}.<init>(${t.params.map(Nn).join(", ")})`:this.#D(t),isStatic:t.isStatic,argCount:n,returnsValue:t.returnType.tag!=="void"});if(t.selector!==void 0&&(r.selector=t.selector),(t.builtin==="enum-name"||t.builtin==="enum-ordinal"||t.builtin==="enum-compareTo"||t.builtin==="enum-toString"||t.builtin.startsWith("throwable-"))&&(r.hidden=!0),t.builtin==="record-constructor"&&e.components.some(a=>a.type.tag==="long"||a.type.tag==="double")){let a=[0],o=1;for(let c of e.components)a.push(o),o+=c.type.tag==="long"||c.type.tag==="double"?2:1;r.argSlots=Int32Array.from(a)}return r}#o(t){let e=(n,s)=>{this.#t(l.LOAD,0),s(),this.#t(l.PUTFIELD,n,-1)};switch(this.#t(l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.fillInStackTrace.index,-1,l.POP),t.throwableConstructor){case"message":e(yt.message,()=>this.#t(l.LOAD,1));break;case"message-cause":e(yt.message,()=>this.#t(l.LOAD,1)),e(yt.cause,()=>this.#t(l.LOAD,2)),e(yt.causeSet,()=>this.#t(l.ICONST,1));break;case"cause":{let n=new et;this.#t(l.LOAD,1,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,n),e(yt.message,()=>this.#t(l.LOAD,1,l.INVOKE_VIRTUAL,this.#i.toString.index,-1)),this.#P(n),e(yt.cause,()=>this.#t(l.LOAD,1)),e(yt.causeSet,()=>this.#t(l.ICONST,1));break}case"index":e(yt.message,()=>this.#t(l.SCONST,this.#g(t.owner.builtin.indexPrefix),l.LOAD,1,l.TOSTRING_INT,l.SCONCAT));break;case"object":{e(yt.message,()=>this.#t(l.LOAD,1,l.VALUEOF,l.TOSTRING_REF));let n=new et;this.#t(l.LOAD,1,l.INSTANCEOF,this.#g("Ljava.lang.Throwable;")),this.#c(l.JUMP_IF_FALSE,n),e(yt.cause,()=>this.#t(l.LOAD,1)),e(yt.causeSet,()=>this.#t(l.ICONST,1)),this.#P(n);break}}this.#t(l.RETURN)}uncaughtPrinter(t){return this.#E(t,1,V),this.#t(l.LOAD,0,l.THROWABLE,Ut.PRINT_UNCAUGHT,l.RETURN),this.#A(t,{name:"<uncaught>",display:"<uncaught>",isStatic:!0,argCount:1,returnsValue:!1,hidden:!0})}#b(t){this.#t(l.LOAD,0,l.GETFIELD,t.index,-1);let e={int:l.TOSTRING_INT,byte:l.TOSTRING_INT,short:l.TOSTRING_INT,char:l.TOSTRING_CHAR,boolean:l.TOSTRING_BOOL,long:l.TOSTRING_LONG,float:l.TOSTRING_FLOAT,double:l.TOSTRING_DOUBLE}[t.type.tag];e!==void 0?this.#t(e):this.#t(l.VALUEOF,l.TOSTRING_REF)}#it(t){t.components.forEach((e,n)=>{this.#t(l.SCONST,this.#g(`${n===0?`${t.name}[`:", "}${e.name}=`)),n>0&&this.#t(l.SCONCAT),this.#b(e),this.#t(l.SCONCAT)}),this.#t(l.SCONST,this.#g(t.components.length?"]":`${t.name}[]`)),t.components.length&&this.#t(l.SCONCAT),this.#t(l.RETURN_VALUE)}#St(t){this.#t(l.ICONST,0);for(let e of t.components){this.#t(l.ICONST,31,l.IMUL,l.LOAD,0,l.GETFIELD,e.index,-1);let n=ae[e.type.tag];if(n!==void 0)this.#t(l.BOX,n,l.OBJ_HASHCODE,-1);else{let s=new et,r=new et;this.#t(l.DUP,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,s),this.#t(l.OBJ_HASHCODE,-1),this.#c(l.JUMP,r),this.#P(s),this.#t(l.POP,l.ICONST,0),this.#P(r)}this.#t(l.IADD)}this.#t(l.RETURN_VALUE)}#$(t){let e=new et,n=new et;this.#t(l.LOAD,0,l.LOAD,1,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,e),this.#t(l.LOAD,1,l.INSTANCEOF,this.#g(`L${t.binaryName};`)),this.#c(l.JUMP_IF_FALSE,n);for(let s of t.components){let r=a=>this.#t(l.LOAD,a,l.GETFIELD,s.index,-1);if(s.type.tag==="double"||s.type.tag==="float")r(0),this.#t(l.BOX,ae[s.type.tag]),r(1),this.#t(l.BOX,ae[s.type.tag],l.OBJ_EQUALS,-1),this.#c(l.JUMP_IF_FALSE,n);else if(ae[s.type.tag]!==void 0)r(0),r(1),this.#t(l.ICMPEQ),this.#c(l.JUMP_IF_FALSE,n);else{let a=new et;r(0),r(1),this.#t(l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,a),r(0),this.#t(l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,n),r(0),r(1),this.#t(l.OBJ_EQUALS,-1),this.#c(l.JUMP_IF_FALSE,n),this.#P(a)}}this.#P(e),this.#t(l.ICONST,1,l.RETURN_VALUE),this.#P(n),this.#t(l.ICONST,0,l.RETURN_VALUE)}abstractStub(t){let e=t.params.length+(t.isStatic?0:1);this.#E(t.owner,Math.max(1,e),t.returnType),t.returnType.tag==="void"?this.#t(l.RETURN):this.#t(l.ACONST_NULL,l.RETURN_VALUE);let n=this.#A(t.owner,{name:t.name,display:this.#D(t),isStatic:t.isStatic,argCount:e,returnsValue:t.returnType.tag!=="void"});return t.selector!==void 0&&(n.selector=t.selector),n}bridge(t,e){let n=[0],s=1;for(let a of e.params)n.push(s),s+=a.tag==="long"||a.tag==="double"?2:1;this.#E(t,s,e.returnType),this.#f(t.declaration.keywordPos),this.#t(l.LOAD,0),e.params.forEach((a,o)=>{this.#t(l.LOAD,n[o+1]);let c=W(e.target.params[o]);c.tag!=="object"&&Ft(c)!==Ft(a)&&ls(c)&&this.#t(l.CHECKCAST,this.#g(Ft(c)))}),this.#t(l.INVOKE_VIRTUAL,e.target.index,-1,e.returnType.tag==="void"?l.RETURN:l.RETURN_VALUE);let r=this.#A(t,{name:e.name,display:`${t.binaryName}.${e.name}(${e.params.map(Nn).join(", ")})`,isStatic:!1,argCount:e.params.length+1,returnsValue:e.returnType.tag!=="void"});return r.selector=e.selector,s!==e.params.length+1&&(r.argSlots=Int32Array.from(n)),r}method(t){let e=t.params.length+(t.isStatic?0:1);this.#E(t.owner,Math.max(e,t.maxSlots,t.finallySlots??0),t.returnType);let n=t.declaration.body;this.#ut=t.lambda?.reference===!0;for(let a of n.statements)this.#L(a);this.#ut=!1,t.returnType.tag==="void"&&(this.#f(n.end-1),this.#t(l.RETURN));let s=this.#A(t.owner,{name:t.name,display:this.#D(t),isStatic:t.isStatic,argCount:e,returnsValue:t.returnType.tag!=="void"});t.selector!==void 0&&(s.selector=t.selector),t.hidden&&(s.hidden=!0);let r=this.#Y(t);return r&&(s.argSlots=r),s}#t(...t){for(let e of t)this.#R.push(e)}#f(t){let{line:e}=ps(this.#Ot,t);e!==this.#m&&(this.#m=e,this.#bt.push(this.#R.length,e))}#c(t,e){this.#t(t,-1),e.uses.push(this.#R.length-1),e.pc>=0&&(this.#R[this.#R.length-1]=e.pc)}#y(t){t.pc=this.#R.length;for(let e of t.uses)this.#R[e]=t.pc;this.#m=-1}#P(t){t.pc=this.#R.length;for(let e of t.uses)this.#R[e]=t.pc}#g(t){let e=this.#z.get(t);return e===void 0&&(e=this.strings.length,this.strings.push(t),this.#z.set(t,e)),e}#J(t){if(typeof t=="number"&&t===(t|0)&&!Object.is(t,-0)){this.#t(l.ICONST,t);return}let e=typeof t=="bigint"?`L${t}`:Object.is(t,-0)?"-0":String(t),n=this.#It.get(e);n===void 0&&(n=this.numbers.length,this.numbers.push(t),this.#It.set(e,n)),this.#t(l.NCONST,n)}#ht(t){switch(t.kind){case"int":case"byte":case"short":case"char":this.#t(l.ICONST,t.value);return;case"long":this.#J(At(t.value));return;case"double":case"float":this.#J(t.value);return;case"boolean":this.#t(l.ICONST,t.value?1:0);return;case"string":this.#t(l.SCONST,this.#g(t.value));return}}#H(t,e,n,s,r){let a=`${t}/${n}`,o=this.#d.get(a);return o===void 0&&(o=this.natives.length,this.natives.push({name:t,argCount:e,returnsValue:n,...s?{unwrap:s,unwrapCalls:r??[]}:{}}),this.#d.set(a,o)),o}#Lt(t,e,n,s){let r=-1;e&&(this.#h(e,!0),r=this.#st(`Cannot invoke "${t.display}"`,e),t.onBase&&this.#t(l.BASE));let a=n.length;if(t.varargsFrom===void 0)this.#et(n,t.params);else{let c=t.varargsFrom;this.#et(n.slice(0,c),t.params);let u=t.params[c].element,d=n.slice(c);this.#t(l.ICONST,d.length),this.#re(u),d.forEach((h,m)=>{this.#t(l.DUP,l.ICONST,m),this.#h(h,!0),this.#ot(u,h),this.#t(l.ASTORE,Ge(u),-1)}),a=c+1}let o=a+(e?1:0);this.#t(l.INVOKE_NATIVE,this.#H(t.native,o,t.returnsValue,t.unwrap,t.unwrapCalls),r),!s&&t.returnsValue&&this.#t(l.POP)}#gt(t){let e=De(t);switch(e.kind){case"Name":return e.symbol?.kind==="field"?e.outerHops?`${this.#ye(e.outerHops)}.${e.symbol.name}`:this.#Tt(e.symbol):e.symbol?.kind!=="local"?null:this.#Q(e.symbol);case"FieldAccess":{let n=e.fieldSymbol;if(!n)return null;if(n.isStatic)return this.#Tt(n);if(De(e.target).kind==="This")return`this.${n.name}`;let s=this.#gt(e.target);return s===null?null:`${s}.${n.name}`}case"MethodCall":return e.method?this.#kt(e,e.method):e.objectMethod?`${e.qualifier??"Object"}.${Ka[e.objectMethod]}`:e.libraryCall?e.libraryCall.display:null;case"ArrayAccess":{let n=this.#gt(e.array);if(n===null)return null;let s=De(e.index),r=e.index.constant&&(e.index.constant.kind==="int"||e.index.constant.kind==="char")?String(e.index.constant.value):s.kind==="Name"?this.#gt(s)??"...":"...";return`${n}[${r}]`}case"Cast":return this.#gt(e.expression);default:return null}}#Tt(t){return t.isStatic?`${t.owner.binaryName}.${t.name}`:`this.${t.name}`}#ee(t){let e=this.#rt.get(t);return e===void 0&&(e=this.messages.length,this.messages.push(t),this.#rt.set(t,e)),e}#j(t,e){if(this.#ut)return-1;let n=t;if(typeof e=="string")n+=` because "${e}" is null`;else{let r=De(e);if(r.kind==="MethodCall"&&(r.method||r.objectMethod||r.libraryCall))n+=` because the return value of "${this.#gt(r)}" is null`;else{let a=this.#gt(e);a!==null&&(n+=` because "${a}" is null`)}}let s=this.#rt.get(n);return s===void 0&&(s=this.messages.length,this.messages.push(n),this.#rt.set(n,s)),s}#st(t,e){return De(e).kind==="This"?-1:this.#j(t,e)}#L(t){switch(t.kind){case"Block":for(let e of t.statements)this.#L(e);return;case"EmptyStatement":return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init&&(this.#f(e.pos),e.init.kind==="ArrayInitializer"?this.#w(e.init):(this.#h(e.init,!0),this.#ot(e.symbol.type,e.init)),this.#t(l.STORE,this.#u(e.symbol)));return;case"ExpressionStatement":this.#f(t.start),this.#h(t.expression,!1);return;case"IfStatement":{let e=t.condition.constant;if(e&&e.kind==="boolean"){e.value?this.#L(t.then):t.otherwise&&this.#L(t.otherwise);return}this.#f(t.start);let n=new et;if(this.#a(t.condition,n,!1),this.#L(t.then),t.otherwise){let s=new et;this.#c(l.JUMP,s),this.#y(n),this.#L(t.otherwise),this.#y(s)}else this.#y(n);return}case"WhileStatement":this.#M(t,t.start,t.condition,t.body,[]);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#L(t.init);else for(let e of t.init??[])this.#f(e.start),this.#h(e,!1);this.#M(t,t.start,t.condition,t.body,t.update);return;case"DoStatement":{let e=new et,n=new et,s=new et;this.#C.set(t,{breakLabel:s,continueLabel:n,tryDepth:this.#l.length}),this.#y(e),this.#L(t.body),this.#y(n),this.#f(t.condition.start),this.#a(t.condition,e,!0),this.#y(s);return}case"ForEachStatement":this.#Z(t);return;case"LabeledStatement":{let e=new et;this.#C.set(t,{breakLabel:e,tryDepth:this.#l.length}),this.#L(t.body),this.#y(e);return}case"SwitchStatement":this.#e(t,!1);return;case"YieldStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#h(t.value,!0),this.#ot(e.resultType,t.value),this.#c(l.JUMP,e.breakLabel);return}case"BreakStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#K(e.tryDepth??0,t.liveSlots,()=>this.#c(l.JUMP,e.breakLabel));return}case"ContinueStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#K(e.tryDepth??0,t.liveSlots,()=>this.#c(l.JUMP,e.continueLabel));return}case"ReturnStatement":if(this.#f(t.start),t.value){if(this.#h(t.value,!0),this.#ot(this.#W,t.value),!this.#l.length){this.#t(l.RETURN_VALUE);return}let e=this.#x();this.#t(l.STORE,e),this.#K(0,t.liveSlots,()=>this.#t(l.LOAD,e,l.RETURN_VALUE)),this.#I()}else this.#K(0,t.liveSlots,()=>this.#t(l.RETURN));return;case"ConstructorCall":throw new Error("codegen: this(...) outside a constructor prologue");case"ThrowStatement":this.#f(t.start),this.#h(t.expression,!0),this.#t(l.ATHROW,this.#j("Cannot throw exception",t.expression));return;case"AssertStatement":return;case"LocalClass":return;case"TryStatement":this.#ne(t);return}}#ne(t){let e=t.catches.map(o=>({types:(o.caught??[]).map(c=>Ft(c)),body:()=>{this.#t(l.STORE,this.#u(o.symbol)),this.#L(o.block)}})),n=t.finallyBlock,s=t.resources.length?()=>this.#B(t.resources,0,()=>this.#L(t.block)):()=>this.#L(t.block);if(!e.length&&!n){s();return}let r=t.finallySlots,a=n&&r?{run:(o,c)=>{let u=o??r.base,d=c&&!this.#p;d&&(this.#r=Math.max(this.#r,u+r.extent)),d||this.#p++,this.#X.push({from:r.base,by:u-r.base}),this.#L(n),this.#X.pop(),d||this.#p--},anyAt:()=>Math.max(r.before,this.#r)+1,blockCompletes:t.blockCompletes??!0,handlerCompletes:t.catches.map(o=>o.completes??!0)}:null;this.#Et(s,e,a)}#N(t){return{run:()=>t(),anyAt:()=>0,blockCompletes:!0,handlerCompletes:[]}}#Et(t,e,n){let s=new _s,r=n?new _s:null,a=new et,o={regions:r?[s,r]:[s],finallyBody:n};this.#l.push(o),s.open(this.#R.length),r?.open(this.#R.length),t(),s.close(this.#R.length),r?.close(this.#R.length),this.#l.pop(),n?.run(void 0,n.blockCompletes),this.#c(l.JUMP,a);let c=[];for(let[u,d]of e.entries()){let h=this.#R.length;this.#m=-1,this.#l.push({regions:r?[r]:[],finallyBody:n}),r?.open(this.#R.length),d.body(),r?.close(this.#R.length),this.#l.pop(),n?.run(void 0,n.handlerCompletes[u]??!0),this.#c(l.JUMP,a);for(let m of d.types){let p=m===null?-1:this.#g(m);for(let[k,g]of s.segments)c.push(k,g,h,p)}}if(r&&n){let u=this.#R.length;this.#m=-1;let d=this.#x();this.#t(l.STORE,d),n.run(n.anyAt(),!0),this.#t(l.LOAD,d,l.ATHROW,-1),this.#I();for(let[h,m]of r.segments)c.push(h,m,u,-1)}this.#S.push(...c),this.#y(a)}#B(t,e,n){if(e===t.length){n();return}let s=t[e];this.#f(s.start);let r=s.symbol?this.#u(s.symbol):this.#x();s.kind==="declaration"?(this.#h(s.init,!0),this.#ot(s.symbol.type,s.init)):this.#h(s.expression,!0),this.#t(l.STORE,r);let a=this.#x();this.#t(l.ACONST_NULL,l.STORE,a);let o=()=>this.#dt(s,r);this.#Et(()=>this.#B(t,e+1,n),[{types:[null],body:()=>this.#t(l.DUP,l.STORE,a,l.ATHROW,-1)}],this.#N(()=>{let c=new et,u=new et;this.#t(l.LOAD,r,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c),this.#t(l.LOAD,a,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,u),this.#Et(o,[{types:[null],body:()=>{let d=this.#x();this.#t(l.STORE,d,l.LOAD,a,l.LOAD,d,l.THROWABLE,Ut.ADD_SUPPRESSED),this.#I()}}],null),this.#c(l.JUMP,c),this.#P(u),o(),this.#P(c)})),s.kind==="declaration"&&!this.#p&&(this.#r=Math.max(this.#r,r+3)),this.#I(),s.symbol||this.#I()}#dt(t,e){this.#t(l.LOAD,e),t.closeMethod?this.#t(l.INVOKE_VIRTUAL,t.closeMethod.index,-1):this.#t(l.INVOKE_NATIVE,this.#H("close()",1,!1),-1)}#K(t,e,n){let s=this.#l.slice(t);if(!s.length){n();return}let r=this.#l;for(let a=s.length-1;a>=0;a--){for(let o of s[a].regions)o.close(this.#R.length);this.#l=r.slice(0,t+a),s[a].finallyBody?.run(e,!0)}this.#l=r,n();for(let a of s)for(let o of a.regions)o.open(this.#R.length)}#M(t,e,n,s,r){let a=n?.constant;if(a&&a.kind==="boolean"&&!a.value)return;let o=new et,c=new et,u=new et;this.#C.set(t,{breakLabel:u,continueLabel:c,tryDepth:this.#l.length}),this.#y(o),this.#f(e),n&&!a&&this.#a(n,u,!1),this.#L(s),this.#y(c);for(let d of r)this.#f(d.start),this.#h(d,!1);this.#c(l.JUMP,o),this.#y(u)}#Z(t){if(t.iterator){this.#F(t);return}let{array:e,length:n,index:s}=t.hidden,r=e.type.element;this.#f(t.start),this.#h(t.iterable,!0),this.#t(l.STORE,this.#u(e),l.LOAD,this.#u(e)),this.#t(l.ARRAYLENGTH,this.#j("Cannot read the array length",this.#Q(e))),this.#t(l.STORE,this.#u(n),l.ICONST,0,l.STORE,this.#u(s));let a=new et,o=new et,c=new et;this.#C.set(t,{breakLabel:c,continueLabel:o,tryDepth:this.#l.length}),this.#y(a),this.#f(t.start),this.#t(l.LOAD,this.#u(s),l.LOAD,this.#u(n),l.ICMPLT),this.#c(l.JUMP_IF_FALSE,c),this.#t(l.LOAD,this.#u(e),l.LOAD,this.#u(s),l.ALOAD,Ge(r),-1),this.#Bt(r,t.symbol.type,{description:`${this.#Q(e)}[${this.#Q(s)}]`}),this.#t(l.STORE,this.#u(t.symbol)),this.#L(t.body),this.#y(o),this.#f(t.start),this.#t(l.IINC,this.#u(s),1),this.#c(l.JUMP,a),this.#y(c)}#F(t){let e=t.iterator,n=t.iterable.type,s=n.tag==="library"||n.tag==="diamond"?n.symbol.qualifiedName:"java.lang.Iterable";this.#f(t.start),this.#h(t.iterable,!0),this.#t(l.INVOKE_NATIVE,this.#H("Iterable.iterator",1,!0),this.#j(`Cannot invoke "${s}.iterator()"`,t.iterable)),this.#t(l.STORE,this.#u(e));let r=new et,a=new et;this.#C.set(t,{breakLabel:a,continueLabel:r,tryDepth:this.#l.length}),this.#y(r),this.#f(t.start),this.#t(l.LOAD,this.#u(e),l.INVOKE_NATIVE,this.#H("Iterator.hasNext",1,!0),-1),this.#c(l.JUMP_IF_FALSE,a),this.#t(l.LOAD,this.#u(e),l.INVOKE_NATIVE,this.#H("Iterator.next",1,!0),-1);let o=t.element??qa(n),c=t.symbol.type,u=Ae(c)?qt(c):W(c);u&&u.tag!=="object"&&(u.tag==="string"||u.tag==="class"||u.tag==="array"||u.tag==="library"&&u.symbol.box)&&this.#t(l.CHECKCAST,this.#g(Ft(u))),this.#Bt(o,t.symbol.type,{returnValue:"java.util.Iterator.next()"}),this.#t(l.STORE,this.#u(t.symbol)),this.#L(t.body),this.#c(l.JUMP,r),this.#y(a)}#e(t,e){if(t.patternSwitch)return this.#at(t,e);this.#f(t.start);let n=t.selector.type?.tag==="string",s=t.selector.type,r=s?.tag==="class"&&s.symbol.isEnum?s.symbol:null;this.#h(t.selector,!0);let a;if(r)this.#t(l.GETFIELD,1,this.#j(`Cannot invoke "${r.binaryName}.ordinal()"`,t.selector)),a=this.#x(),this.#t(l.STORE,a);else if(t.libraryEnum)this.#t(l.INVOKE_NATIVE,this.#H("ordinal()",1,!0),this.#j(`Cannot invoke "${t.libraryEnum}.ordinal()"`,t.selector)),a=this.#x(),this.#t(l.STORE,a);else if(n){let h=t.hidden.copy;a=this.#u(h),this.#t(l.STORE,a,l.LOAD,a),this.#t(l.CHECKNULL,this.#j(\'Cannot invoke "String.hashCode()"\',this.#Q(h)))}else a=this.#x(),this.#t(l.STORE,a);let o=new et,c=e?t.type:void 0;this.#C.set(t,{breakLabel:o,resultType:c,tryDepth:this.#l.length});let u=t.cases.map(()=>new et),d=o;t.cases.forEach((h,m)=>{if(h.isDefault&&(d=u[m]),r||t.libraryEnum){for(let p of h.ordinals??[])this.#t(l.LOAD,a,l.ICONST,p,l.ICMPEQ),this.#c(l.JUMP_IF_TRUE,u[m]);return}for(let p of h.labels)this.#t(l.LOAD,a),this.#ht(p.constant),this.#t(n?l.STR_EQUALS:l.ICMPEQ,...n?[-1]:[]),this.#c(l.JUMP_IF_TRUE,u[m])}),e&&d===o&&u.length&&(d=u[0]),this.#c(l.JUMP,d),t.cases.forEach((h,m)=>{this.#y(u[m]),this.#Jt(h,e,o,c)}),this.#P(o),this.#m=-1,n||this.#I()}#at(t,e){this.#f(t.start);let n=t.selector.type,s=n?.tag==="class"&&n.symbol.isEnum?n.symbol:null;this.#h(t.selector,!0);let r=this.#x();this.#t(l.STORE,r);let a=new et,o=e?t.type:void 0;this.#C.set(t,{breakLabel:a,resultType:o,tryDepth:this.#l.length});let c=t.cases.map(()=>new et),u=t.cases.findIndex(h=>h.nullLabel);this.#t(l.LOAD,r),u>=0?(this.#t(l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c[u])):this.#t(l.CHECKNULL,-1);let d=null;t.cases.forEach((h,m)=>{if(h.isDefault&&(d=c[m]),s)for(let p of h.ordinals??[])this.#t(l.LOAD,r,l.GETFIELD,1,-1,l.ICONST,p,l.ICMPEQ),this.#c(l.JUMP_IF_TRUE,c[m]);else{let p=n?St(n):null;for(let k of h.enumFields??[])this.#t(l.LOAD,r,l.GETSTATIC,k.index,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c[m]);for(let k of h.enumFields?.length?[]:h.labels)this.#t(l.LOAD,r),p&&this.#t(l.UNBOX,ae[p.tag],-1),this.#ht(k.constant),p&&this.#xt(k.type,p),this.#t(p?l.ICMPEQ:l.STR_EQUALS,...p?[]:[-1]),this.#c(l.JUMP_IF_TRUE,c[m])}if(h.pattern){let p=new et,k=this.#At(h.pattern,r,p,!1);h.guard&&this.#a(h.guard,p,!1),this.#c(l.JUMP,c[m]),this.#P(p);for(let g=0;g<k;g++)this.#I()}}),this.#c(l.JUMP,d??(t.exhaustive&&c.length?c[0]:a)),t.cases.forEach((h,m)=>{this.#y(c[m]),this.#Jt(h,e,a,o)}),this.#P(a),this.#m=-1,this.#I()}#At(t,e,n,s){if(t.kind==="TypePattern")return!(s&&t.unconditional)&&!Ae(t.tested)&&(this.#t(l.LOAD,e,l.INSTANCEOF,this.#g(Ft(W(t.tested)))),this.#c(l.JUMP_IF_FALSE,n)),t.symbol&&this.#t(l.LOAD,e,l.STORE,this.#u(t.symbol)),0;this.#t(l.LOAD,e,l.INSTANCEOF,this.#g(Ft(W(t.tested)))),this.#c(l.JUMP_IF_FALSE,n);let r=0;return t.components.forEach((a,o)=>{let c=t.accessors[o],u=this.#x();r++,this.#t(l.LOAD,e,c.selector!==void 0?l.INVOKE_VIRTUAL:l.INVOKE,c.index,-1,l.STORE,u),r+=this.#At(a,u,n,!0)}),r}#Jt(t,e,n,s){if(!t.arrow){for(let a of t.statements)this.#L(a);return}let r=t.body;if(r.kind==="Block"){this.#L(r),e||this.#c(l.JUMP,n);return}this.#f(r.start),e?(this.#h(r,!0),this.#ot(s,r)):this.#h(r,!1),this.#c(l.JUMP,n)}#a(t,e,n){let s=t.constant;if(s&&s.kind==="boolean"){s.value===n&&this.#c(l.JUMP,e);return}if(t.kind==="Parenthesized")return this.#a(t.expression,e,n);if(t.kind==="Unary"&&t.operator==="!")return this.#a(t.operand,e,!n);if(t.kind==="Binary"&&(t.operator==="&&"||t.operator==="||")){if(t.operator==="&&"!==n)this.#a(t.left,e,n),this.#a(t.right,e,n);else{let a=new et;this.#a(t.left,a,!n),this.#a(t.right,e,n),this.#P(a)}return}if(t.kind==="InstanceOf"){this.#Re(t,e,n);return}this.#tt(t,gt),this.#c(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e)}#Re(t,e,n){if(t.recordPattern){let c=this.#x();this.#h(t.expression,!0),this.#t(l.STORE,c);let u=new et,d=this.#At(t.recordPattern,c,n?u:e,!1);n&&this.#c(l.JUMP,e),this.#P(u);for(let h=0;h<=d;h++)this.#I();return}let s=this.#g(Ft(this.#se(t))),r=t.binding?.symbol;if(!r){this.#h(t.expression,!0),this.#t(l.INSTANCEOF,s),this.#c(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e);return}let a=this.#x();this.#h(t.expression,!0),this.#t(l.STORE,a,l.LOAD,a,l.INSTANCEOF,s);let o=new et;this.#c(l.JUMP_IF_FALSE,n?o:e),this.#t(l.LOAD,a,l.STORE,this.#u(r)),n&&this.#c(l.JUMP,e),this.#P(o),this.#I()}#se(t){return t.binding?.symbol?.type??t.testedType}#xt(t,e){t&&(t.tag==="long"&&e.tag==="double"?this.#t(l.L2D):e.tag==="float"&&t.tag==="long"?this.#t(l.L2F):e.tag==="float"&&Dr(t)&&this.#t(l.I2F))}#Ut(t,e){if(!os(t)||!os(e))return;let n=Dr(t)?"int":t.tag;switch(e.tag){case"char":case"byte":case"short":case"int":n==="long"&&this.#t(l.L2I),(n==="double"||n==="float")&&this.#t(l.D2I),e.tag==="char"&&t.tag!=="char"&&this.#t(l.I2C),e.tag==="byte"&&t.tag!=="byte"&&this.#t(l.I2B),e.tag==="short"&&t.tag!=="byte"&&t.tag!=="short"&&this.#t(l.I2S);return;case"long":(n==="double"||n==="float")&&this.#t(l.D2L);return;case"float":n==="double"?this.#t(l.D2F):this.#xt(t,e);return;case"double":n==="long"&&this.#t(l.L2D);return}}#ot(t,e){this.#Bt(e.type,t,e,e.constant!==void 0)}#Bt(t,e,n,s=!1){let r=St(t);if(Ae(e)){if(r&&(this.#t(l.UNBOX,ae[r.tag],this.#Kt(r,n)),t=r),s){this.#xt(t,e);return}e.tag==="char"&&t.tag!=="char"?this.#t(l.I2C):this.#xt(t,e);return}if(Ae(t)){let a=St(e)?.tag??t.tag;!s&&a==="char"&&t.tag==="int"&&this.#t(l.I2C),t.tag==="long"&&a==="double"&&this.#t(l.L2D),this.#t(l.BOX,ae[a])}}#Kt(t,e){let n=`Cannot invoke "${Rl[t.tag]}"`;return"returnValue"in e?this.#ee(`${n} because the return value of "${e.returnValue}" is null`):"description"in e?this.#j(n,e.description):this.#j(n,e)}#et(t,e,n){if(!n){t.forEach((r,a)=>{this.#h(r,!0),this.#ot(e[a],r)});return}this.#et(t.slice(0,n.from),e);let s=t.slice(n.from);this.#t(l.ICONST,s.length),this.#re(n.element),s.forEach((r,a)=>{this.#t(l.DUP,l.ICONST,a),this.#h(r,!0),this.#ot(n.element,r),this.#t(l.ASTORE,Ge(n.element),-1)})}#tt(t,e){if(this.#h(t,!0),t.constant){this.#xt(t.type,e);return}let n=St(t.type);if(n){this.#t(l.UNBOX,ae[n.tag],this.#Kt(n,t)),this.#xt(n,e);return}this.#xt(t.type,e)}#Nt(t,e){let n=Jl[t];return e.tag==="double"?n.double:e.tag==="float"?n.float:e.tag==="long"?n.long:n.int}#h(t,e){if(e&&t.genericCast){let n=t.genericCast;t.genericCast=void 0,this.#h(t,!0),t.genericCast=n,this.#t(l.CHECKCAST,this.#g(Ft(n)));return}if(t.constant){e&&this.#ht(t.constant);return}switch(t.kind){case"Literal":if(t.literalKind!=="null")throw new Error(`codegen: unexpected literal ${t.literalKind}`);e&&this.#t(l.ACONST_NULL);return;case"Name":{if(t.imported){this.#h(t.imported,e);return}if(t.symbol?.kind==="field"){if(!e)return;let n=t.symbol;n.isStatic?this.#t(l.GETSTATIC,n.index):(this.#vt(t.outerHops),this.#t(l.GETFIELD,n.index,-1));return}if(t.symbol?.kind!=="local")throw new Error("codegen: unresolved name");e&&this.#t(l.LOAD,this.#u(t.symbol));return}case"This":e&&this.#vt(t.outerHops);return;case"Super":e&&this.#t(l.LOAD,0);return;case"ClassLiteral":e&&this.#t(l.SCONST,this.#g(t.className),l.ICONST,t.isInterface?1:0,l.INVOKE_NATIVE,this.#H("Class.literal",2,!0),-1);return;case"InstanceOf":{let n=new et,s=new et;this.#Re(t,n,!0),this.#t(l.ICONST,0),this.#c(l.JUMP,s),this.#P(n),this.#t(l.ICONST,1),this.#P(s),e||this.#t(l.POP);return}case"Parenthesized":this.#h(t.expression,e);return;case"Unary":{let n=t.type;this.#tt(t.operand,n),t.operator==="-"?this.#t(n.tag==="double"||n.tag==="float"?l.DNEG:n.tag==="long"?l.LNEG:l.INEG):t.operator==="~"?n.tag==="long"?this.#t(l.ICONST,-1,l.LXOR):this.#t(l.INOT):t.operator==="!"&&this.#t(l.BNOT),e||this.#t(l.POP);return}case"Cast":{let n=t.expression.type;if(t.checked&&Ae(t.type)){this.#h(t.expression,!0),this.#t(l.CHECKCAST,this.#g(Ft(t.checked)));let r=St(t.checked);this.#t(l.UNBOX,ae[r.tag],this.#Kt(r,t.expression)),this.#Ut(r,t.type),e||this.#t(l.POP);return}let s=Ae(t.type)?St(n):null;s?this.#tt(t.expression,s):this.#h(t.expression,!0),Ae(n)&&!Ae(t.type)?this.#Bt(n,t.type,t.expression,t.expression.constant!==void 0):this.#Ut(s??n,t.type),t.checked&&this.#t(l.CHECKCAST,this.#g(Ft(t.checked))),e||this.#t(l.POP);return}case"IncDec":this.#mt(t,e);return;case"Binary":this.#pe(t),e||this.#t(l.POP);return;case"Assignment":this.#jt(t,e);return;case"ArrayAccess":this.#h(t.array,!0),this.#tt(t.index,V),this.#ge(t.type,t.array),e||this.#t(l.POP);return;case"NewArray":this.#ie(t),e||this.#t(l.POP);return;case"FieldAccess":if(t.fieldSymbol){let n=t.fieldSymbol;n.isStatic?(Jr(t.target)||this.#h(t.target,!1),e&&this.#t(l.GETSTATIC,n.index)):(this.#h(t.target,!0),this.#t(l.GETFIELD,n.index,this.#st(`Cannot read field "${n.name}"`,t.target)),e||this.#t(l.POP));return}if(t.field==="System.in"){e&&this.#t(l.INVOKE_NATIVE,this.#H("System.in",0,!0),-1);return}if(t.field==="System.out"||t.field==="System.err"){e&&this.#t(l.INVOKE_NATIVE,this.#H(t.field,0,!0),-1);return}if(t.libraryField?.includes("#")){this.#h(t.target,!0),this.#t(l.INVOKE_NATIVE,this.#H(t.libraryField,1,!0),this.#st(`Cannot read field "${t.name}"`,t.target)),e||this.#t(l.POP);return}if(t.libraryField){e&&this.#t(l.INVOKE_NATIVE,this.#H(t.libraryField,0,!0),-1);return}if(t.field!=="length")throw new Error("codegen: field access used as a value");this.#h(t.target,!0),this.#t(l.ARRAYLENGTH,this.#j("Cannot read the array length",t.target)),e||this.#t(l.POP);return;case"MethodCall":this.#be(t,e);return;case"NewObject":{if(t.libraryCall){this.#Lt(t.libraryCall,null,t.args,e);return}let n=t.ctor;this.#t(l.NEW,n.owner.index,l.DUP);for(let s of n.owner.captures??[]){this.#t(l.DUP);let r=Dl(this.#O,n.owner);r>=0?(this.#vt(r),this.#t(l.GETFIELD,s.field.index,-1)):this.#t(l.LOAD,this.#u(s.local)),this.#t(l.PUTFIELD,s.field.index,-1)}t.outerExpression?(this.#h(t.outerExpression,!0),this.#t(l.DUP,l.CHECKNULL,-1)):t.outer!==void 0&&this.#vt(t.outer),this.#et(t.args,n.params,t.varargs),this.#t(l.INVOKE,n.index,-1),e||this.#t(l.POP);return}case"Conditional":{let n=t.condition.constant;if(n?.kind==="boolean"){let a=n.value?t.whenTrue:t.whenFalse;this.#h(a,e),e&&this.#ot(t.type,a);return}let s=new et,r=new et;this.#a(t.condition,s,!1),this.#h(t.whenTrue,!0),this.#ot(t.type,t.whenTrue),this.#c(l.JUMP,r),this.#P(s),this.#h(t.whenFalse,!0),this.#ot(t.type,t.whenFalse),this.#P(r),e||this.#t(l.POP);return}case"SwitchExpression":this.#e(t,!0),e||this.#t(l.POP);return;case"Lambda":this.#fe(t,null,e);return;case"MethodRef":this.#fe(t.lambda,t.receiver??null,e);return}}#fe(t,e,n){let s=t.method,r=0;s.usesThis&&(this.#t(l.LOAD,0),r++),e&&(this.#h(e,!0),this.#t(l.DUP,l.CHECKNULL,-1),r++);for(let o of t.captures??[])this.#t(l.LOAD,this.#u(o)),r++;let a=t.functional;this.#t(l.LAMBDA,s.index,r,this.#g(a.iface),a.sam?.selector??-1,a.samKey?this.#g(a.samKey):-1),n||this.#t(l.POP)}#pe(t){let e=t.operator;if(e==="&&"||e==="||"){let a=new et,o=new et;this.#a(t,a,!1),this.#t(l.ICONST,1),this.#c(l.JUMP,o),this.#P(a),this.#t(l.ICONST,0),this.#P(o);return}let n=t.left.type,s=t.right.type;if(t.type?.tag==="string"){this.#xe(t.left),this.#xe(t.right),this.#t(l.SCONCAT);return}if(e in Fs){let a=St(n)??n,o=St(s)??s,c=Ae(n)||Ae(s)||e!=="=="&&e!=="!=";if(c&&a.tag==="boolean"&&o.tag==="boolean"){this.#tt(t.left,gt),this.#tt(t.right,gt),this.#t(Fs[e]);return}if(c&&os(a)&&os(o)){let d=jr(a,o);this.#tt(t.left,d),this.#tt(t.right,d),this.#t(Fs[e]);return}this.#h(t.left,!0),this.#h(t.right,!0);let u=ls(n)||ls(s);this.#t(e==="=="?u?l.ACMPEQ:l.ICMPEQ:e==="!="?u?l.ACMPNE:l.ICMPNE:Fs[e]);return}let r=t.type;if(e==="<<"||e===">>"||e===">>>"){this.#tt(t.left,r),this.#h(t.right,!0),s.tag==="long"&&this.#t(l.L2I),this.#t(this.#Nt(e,r));return}this.#tt(t.left,r),this.#tt(t.right,r),this.#t(this.#Nt(e,r.tag==="boolean"?V:r))}#vt(t=0){this.#t(l.LOAD,0);let e=this.#O;for(let n=0;n<t&&e;n++,e=e.outer)this.#t(l.GETFIELD,e.outerField,-1)}#ye(t){let e=r=>{let a=0;for(let o=r.outer;o;o=o.outer)a++;return a},n="this",s=this.#O;for(let r=0;r<t&&s?.outer;r++,s=s.outer)n+=`.this$${e(s)-1}`;return n}#re(t){Ge(t)===Y.REF&&t.tag!=="string"?this.#t(l.NEWARRAY_REF,this.#g("["+Ft(t))):this.#t(l.NEWARRAY,Ge(t))}#ie(t){if(t.initializer){this.#w(t.initializer);return}let e=t.type;for(let n of t.dimensions)this.#tt(n,V);t.dimensions.length===1?this.#re(e.element):this.#t(l.NEWMULTI,this.#g(Ft(e)),t.dimensions.length)}#ge(t,e){let n=Ge(t);this.#t(l.ALOAD,n,this.#j(`Cannot load from ${Ga[n]} array`,e))}#qt(t,e){let n=Ge(t);this.#t(l.ASTORE,n,this.#j(`Cannot store to ${Ga[n]} array`,e))}#w(t){let e=t.elementType,n=Ge(e);this.#t(l.ICONST,t.elements.length),this.#re(e),t.elements.forEach((s,r)=>{this.#t(l.DUP,l.ICONST,r),s.kind==="ArrayInitializer"?this.#w(s):(this.#h(s,!0),this.#ot(e,s)),this.#t(l.ASTORE,n,-1)})}#be(t,e){if(t.print){let s=Ot.NONE;if(t.print.argument!=="none"){let r=t.args[0];this.#h(r,!0),t.print.argument==="object"?(this.#t(l.VALUEOF,l.TOSTRING_REF),s=Ot.STRING):s={int:Ot.INT,char:Ot.CHAR,boolean:Ot.BOOLEAN,long:Ot.LONG,float:Ot.FLOAT,double:Ot.DOUBLE,string:Ot.STRING,"char-array":Ot.CHAR_ARRAY}[t.print.argument]}this.#t(l.PRINT,t.print.stream==="err"?1:0,t.print.newline?1:0,s);return}if(t.libraryCall){let s=t.libraryCall.isStatic?null:t.target??{kind:"This",depth:1,pos:t.pos,start:t.pos,end:t.pos};this.#Lt(t.libraryCall,s,t.args,e);return}if(t.mathFunction){this.#et(t.args,t.mathFunction.params),this.#t(l.MATH,jl[t.mathFunction.fn]),e||this.#t(l.POP);return}let n=t.target?De(t.target):null;if(t.method){let s=t.method,r=-1;s.isStatic?n&&!Jr(n)&&this.#h(n,!1):n?(this.#h(n,!0),r=this.#st(`Cannot invoke "${this.#kt(t,s)}"`,n)):this.#vt(t.outerHops),this.#et(t.args,s.params,t.varargs);let a=s.selector!==void 0&&!t.isSuper;this.#t(a?l.INVOKE_VIRTUAL:l.INVOKE,s.index,r),!e&&s.returnType.tag!=="void"&&this.#t(l.POP);return}if(t.objectMethod){let s=-1;if(n?(this.#h(n,!0),s=this.#st(`Cannot invoke "${t.qualifier??"Object"}.${Ka[t.objectMethod]}"`,n)):this.#vt(),this.#et(t.args,t.args.map(()=>G)),t.isSuper)this.#t(l.OBJ_SUPER,{toString:0,hashCode:1,equals:2}[t.objectMethod]);else{let r={toString:l.OBJ_TOSTRING,hashCode:l.OBJ_HASHCODE,equals:l.OBJ_EQUALS}[t.objectMethod];this.#t(r,s)}e||this.#t(l.POP);return}if(t.stringMethod){this.#h(t.target,!0);for(let s of t.args)this.#h(s,!0);switch(t.stringMethod){case"length":this.#t(l.STR_LENGTH,this.#j(\'Cannot invoke "String.length()"\',t.target));break;case"charAt":this.#t(l.STR_CHARAT,this.#j(\'Cannot invoke "String.charAt(int)"\',t.target));break;case"equals":this.#t(l.STR_EQUALS,this.#j(\'Cannot invoke "String.equals(Object)"\',t.target));break;case"isEmpty":this.#t(l.STR_LENGTH,this.#j(\'Cannot invoke "String.isEmpty()"\',t.target),l.ICONST,0,l.ICMPEQ);break;case"toCharArray":this.#t(l.STR_TOCHARS,this.#j(\'Cannot invoke "String.toCharArray()"\',t.target));break;case"compareTo":this.#t(l.STR_COMPARETO,this.#j(\'Cannot invoke "String.compareTo(String)"\',t.target),this.#ee(\'Cannot read field "value" because "anotherString" is null\'));break}e||this.#t(l.POP);return}throw new Error(`codegen: unresolved call to ${t.name}`)}#Vt(t,e,n){let s=St(t);s&&this.#t(l.UNBOX,ae[s.tag],this.#Kt(s,n));let r=s??t;this.#t(l.ICONST,e,r.tag==="double"?l.DADD:r.tag==="float"?l.FADD:r.tag==="long"?l.LADD:l.IADD),r.tag==="char"&&this.#t(l.I2C),r.tag==="byte"&&this.#t(l.I2B),r.tag==="short"&&this.#t(l.I2S),s&&this.#t(l.BOX,ae[s.tag])}#mt(t,e){let n=De(t.operand),s=t.operator==="++"?1:-1,r=t.type;if(n.kind==="Name"&&n.symbol?.kind==="local"){let o=this.#u(n.symbol);if(r.tag==="int"){e&&!t.prefix&&this.#t(l.LOAD,o),this.#t(l.IINC,o,s),e&&t.prefix&&this.#t(l.LOAD,o);return}this.#t(l.LOAD,o),e&&!t.prefix&&this.#t(l.DUP),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.STORE,o);return}let a=this.#Se(n);if(a){if(a.isStatic)this.#ae(n),this.#t(l.GETSTATIC,a.index),e&&!t.prefix&&this.#t(l.DUP),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.PUTSTATIC,a.index);else{let o=this.#Te(n,a,"read");this.#t(l.DUP,l.GETFIELD,a.index,o),e&&!t.prefix&&this.#t(l.DUP_X1),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,-1)}return}if(n.kind!=="ArrayAccess")throw new Error("codegen: ++/-- target");this.#h(n.array,!0),this.#h(n.index,!0),this.#t(l.DUP2),this.#ge(r,n.array),e&&!t.prefix&&this.#t(l.DUP_X2),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP_X2),this.#qt(r,n.array)}#jt(t,e){let n=De(t.target),s=t.target.type,r=()=>{if(t.operator==="="){this.#h(t.value,!0),this.#ot(s,t.value);return}if(s.tag==="string"){this.#t(l.TOSTRING_REF),this.#xe(t.value),this.#t(l.SCONCAT);return}let o=t.operator.slice(0,-1),c=t.value.type;if(o==="<<"||o===">>"||o===">>>"){let h=Dr(s)?V:s;this.#h(t.value,!0),c.tag==="long"&&this.#t(l.L2I),this.#t(this.#Nt(o,h)),this.#Ut(h,s);return}if(s.tag==="boolean"){this.#tt(t.value,gt),this.#t(this.#Nt(o,V));return}let u=St(s);if(u){this.#t(l.UNBOX,ae[u.tag],this.#Kt(u,n));let h=jr(u,St(c)??c);this.#xt(u,h),this.#tt(t.value,h),this.#t(this.#Nt(o,h)),this.#Ut(h,u),this.#t(l.BOX,ae[u.tag]);return}let d=jr(s,St(c)??c);this.#xt(s,d),this.#tt(t.value,d),this.#t(this.#Nt(o,d)),this.#Ut(d,s)};if(n.kind==="Name"&&n.symbol?.kind==="local"){t.operator!=="="&&this.#t(l.LOAD,this.#u(n.symbol)),r(),e&&this.#t(l.DUP),this.#t(l.STORE,this.#u(n.symbol));return}let a=this.#Se(n);if(a){if(a.isStatic)this.#ae(n),t.operator!=="="&&this.#t(l.GETSTATIC,a.index),r(),e&&this.#t(l.DUP),this.#t(l.PUTSTATIC,a.index);else if(t.operator==="="){let o=this.#Te(n,a,"assign");r(),e&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,o)}else{let o=this.#Te(n,a,"read");this.#t(l.DUP,l.GETFIELD,a.index,o),r(),e&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,-1)}return}if(n.kind!=="ArrayAccess")throw new Error("codegen: assignment target");this.#h(n.array,!0),this.#h(n.index,!0),t.operator!=="="&&(this.#t(l.DUP2),this.#ge(s,n.array)),r(),e&&this.#t(l.DUP_X2),this.#qt(s,n.array)}#Se(t){if(t.kind==="Name"&&t.symbol?.kind==="field")return t.symbol;if(t.kind==="FieldAccess")return t.fieldSymbol}#Te(t,e,n){if(t.kind==="FieldAccess"){this.#h(t.target,!0);let s=n==="read"?"Cannot read field":"Cannot assign field";return this.#st(`${s} "${e.name}"`,t.target)}return this.#vt(t.kind==="Name"?t.outerHops:0),-1}#ae(t){t.kind==="FieldAccess"&&!Jr(t.target)&&this.#h(t.target,!1)}#xe(t){if(t.constant){this.#t(l.SCONST,this.#g(zn(t.constant)));return}switch(this.#h(t,!0),t.type?.tag){case"int":case"byte":case"short":this.#t(l.TOSTRING_INT);return;case"float":this.#t(l.TOSTRING_FLOAT);return;case"char":this.#t(l.TOSTRING_CHAR);return;case"boolean":this.#t(l.TOSTRING_BOOL);return;case"long":this.#t(l.TOSTRING_LONG);return;case"double":this.#t(l.TOSTRING_DOUBLE);return;case"string":case"null":case"array":this.#t(l.TOSTRING_REF);return;case"class":case"object":case"library":case"diamond":case"typevar":this.#t(l.VALUEOF,l.TOSTRING_REF);return;default:throw new Error(`codegen: string conversion of ${t.type?.tag}`)}}},Ka={toString:"toString()",hashCode:"hashCode()",equals:"equals(Object)"};function Dl(i,t){let e=0;for(let n=i;n;n=n.outer,e++)if(n===t)return e;return-1}function ls(i){return i!==void 0&&["string","null","array","class","object","library","diamond","typevar"].includes(i.tag)}function qa(i){if(i.tag==="class"){let n=Tn(i.symbol).find(s=>s.symbol.name==="Iterable"||s.symbol.supertypes.some(r=>r.tag==="library"&&r.symbol.name==="Iterable"));return n?qa(n):{tag:"object"}}if(i.tag!=="library")return{tag:"object"};let t=i,e=new Set;for(;t&&t.tag==="library"&&t.symbol.name!=="Iterable"&&!e.has(t.symbol);){e.add(t.symbol);let n=t,s=n.symbol.supertypes[0];t=s?Wa(s,n):null}return t&&t.tag==="library"?t.args[0]??{tag:"object"}:{tag:"object"}}function Wa(i,t){if(i.tag==="typevar"){let e=t.symbol.typeParams.indexOf(i.name);return t.args[e]??{tag:"object"}}return i.tag==="library"?{tag:"library",symbol:i.symbol,args:i.args.map(e=>Wa(e,t))}:i}var lt=class{value;constructor(t){this.value=t}},zt=class{kind;data;hash;descriptor;constructor(t,e,n,s=Fl[t]){this.kind=t,this.data=e,this.hash=n,this.descriptor=s}},Bt=class{className;classIndex;fields;hash;base=null;constructor(t,e,n,s){this.className=t,this.classIndex=e,this.fields=n,this.hash=s}},Zt=class{kind;value;constructor(t,e){this.kind=t,this.value=e}},be=class{hash;constructor(t){this.hash=t}},Se=class extends be{className;method;captured;iface;samSelector;samKey;constructor(t,e,n,s=[],r="java.util.Comparator",a=-1,o="compare(T,T)"){super(n),this.className=t,this.method=e,this.captured=s,this.iface=r,this.samSelector=a,this.samKey=o}},Ke=class i{invoke;args;then;resumes;convert;constructor(t,e,n,s=null,r=null){this.invoke=t,this.args=e,this.then=n,this.resumes=s,this.convert=r}*[Symbol.iterator](){let t=this;for(;t instanceof i;)t=t.then(yield t);return t!==null&&typeof t=="object"&&Symbol.iterator in t?yield*t:t}},Fl=["[I","[Z","[C","[Ljava.lang.String;","[J","[D","[B","[S","[F"];function qe(i){return i instanceof zt?Br(i):`${i.className}@${i.hash.toString(16)}`}function Br(i){return`${i.descriptor}@${i.hash.toString(16)}`}var Us=class{#d=new Map;intern(t){let e=this.#d.get(t);return e||(e=new lt(t),this.#d.set(t,e)),e}},Bs=class{#d=625341585;next(){let t=this.#d;return t^=t<<13,t^=t>>>17,t^=t<<5,this.#d=t>>>0,this.#d&2147483647||1}};var Xa=i=>`${i.className}.${i.method}(${i.file}:${i.line})`;var zs=class{className;message;cause;constructor(t,e,n){this.className=t,this.message=e,this.cause=n}},cs=class{message;constructor(t){this.message=t}},an=class{result;constructor(t){this.result=t}},$n=class{thrown;constructor(t){this.thrown=t}},Gs=class{frames;constructor(t){this.frames=t}},Ks=class{message;constructor(t){this.message=t}};function Ul(i,t,e){switch(i){case 12:return Math.imul(t,e);case 13:return t/e|0;case 14:return t%e|0;case 19:return t&e;case 20:return t|e;case 21:return t^e;case 16:return t<<e;case 17:return t>>e;default:return t>>>e|0}}function Vs(i,t,e){switch(i){case 0:return t===e;case 1:return t!==e;case 2:return t<e;case 3:return t<=e;case 4:return t>e;case 5:return t>=e;case 6:return t!==e;case 7:return t===e;case 8:return!(t<e);case 9:return!(t<=e);case 10:return!(t>e);default:return!(t>=e)}}var Bl=Object.getPrototypeOf(Object.getPrototypeOf((function*(){})())),Vr=i=>typeof i=="object"&&i!==null&&Object.getPrototypeOf(Object.getPrototypeOf(i))===Bl;function Hr(i){switch(i.kind){case"double":return de(i.value);case"float":return Fe(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";default:return String(i.value)}}var Qa={className:"",classIndex:-1,isStatic:!0,name:"<native>",display:"<native>",file:"",argCount:0,returnsValue:!1,hidden:!0,code:new Int32Array(0),lines:new Int32Array(0),maxLocals:0,maxStack:0},Vl=0,Hl=1,rn=2,Za=3,Kr="\\0launcher",zl=Array.from({length:5},(i,t)=>`${Kr}${t}`),to=65536;function zr(i,t){switch(i){case Y.INT:return new Int32Array(t);case Y.BOOLEAN:return new Uint8Array(t);case Y.CHAR:return new Uint16Array(t);case Y.LONG:return new Array(t).fill(0);case Y.DOUBLE:return new Float64Array(t);case Y.BYTE:return new Int8Array(t);case Y.SHORT:return new Int16Array(t);case Y.FLOAT:return new Float32Array(t);default:return new Array(t).fill(null)}}var Hs=(i,t)=>`Index ${i} out of bounds for length ${t}`;function Gl(i){switch(i){case"I":return Y.INT;case"Z":return Y.BOOLEAN;case"C":return Y.CHAR;case"J":return Y.LONG;case"D":return Y.DOUBLE;case"B":return Y.BYTE;case"S":return Y.SHORT;case"F":return Y.FLOAT;default:return Y.REF}}function Kl(i){let t="";for(let e=0;e<i.length;e+=8192)t+=String.fromCharCode(...i.subarray(e,e+8192));return t}var eo=["java.lang.String","java.lang.Object","java.lang.Comparable","java.lang.CharSequence"],qr={int:"java.lang.Integer",long:"java.lang.Long",double:"java.lang.Double",char:"java.lang.Character",boolean:"java.lang.Boolean",float:"java.lang.Float",byte:"java.lang.Byte",short:"java.lang.Short"},ql=Object.fromEntries(Object.keys(qr).map(i=>[i,[qr[i],"java.lang.Object","java.lang.Comparable",...i==="char"||i==="boolean"?[]:["java.lang.Number"]]])),Wl=["java.lang.Object","java.lang.Cloneable","java.io.Serializable"],Xl="com.sun.tools.javac.launcher.MemoryClassLoader @6d06d69c";function Yl(i){let t=0;for(let e=0;e<i.length;e++)t=Math.imul(t,31)+i.charCodeAt(e)|0;return t}var Gr=new DataView(new ArrayBuffer(8));function Ql(i){switch(i.kind){case"int":case"char":case"byte":case"short":return i.value;case"float":return Ts(i.value);case"long":{let t=BigInt.asUintN(64,BigInt(i.value));return Number(BigInt.asIntN(32,t^t>>32n))}case"double":return Gr.setFloat64(0,Number.isNaN(i.value)?NaN:i.value),Gr.getInt32(0)^Gr.getInt32(4)|0;case"boolean":return i.value?1231:1237}}function no(i,t,e,n,s,r=""){let a=new Us,o=new Bs,c=i.strings.map(f=>a.intern(f)),u=i.numbers,d=bn(),h=i.natives.map(f=>{let S=d?.natives[f.name];if(!S)throw new Error(`interpreter: the library native ${f.name} is not loaded`);return S}),m=i.messages,p=i.methods,k=globalThis.performance,g=e.maxDurationMs>0?k.now()+e.maxDurationMs:1/0,O=(f,S=-1)=>({method:f,code:f.code,locals:new Array(f.maxLocals).fill(0),stack:new Array(f.maxStack+1).fill(0),sp:0,pc:0,returnPc:0,initClass:S}),T=i.staticFieldIsReference.map(f=>f?null:0),x=i.staticFieldOwner,v=i.classes,R=v.map(f=>f.instanceFieldIsReference.map(S=>S?null:0)),L=new Uint8Array(v.length),C=new Int32Array(v.length).fill(-1),M=(i.loadWarnings??[]).map((f,S)=>{for(let I of f.classes)C[I]=S;return!0}),_=new Map(v.map(f=>[f.name,f.types])),j=new Map(v.map((f,S)=>[f.name,S])),P=f=>f instanceof Bt?v[f.classIndex].types:f instanceof lt?eo:f instanceof Zt?ql[f.kind]:f instanceof zt?Wl:f instanceof Se?_.get(f.iface)??d?.typesOf(f.iface)??[f.iface,"java.lang.Object"]:f instanceof be?d?.typesOf(f.className)??["java.lang.Object"]:["java.lang.Object"],B=(f,S)=>{if(f===S)return!0;let I=f.slice(1),J=S.slice(1);if(J==="Ljava.lang.Object;")return I.startsWith("[")||I.startsWith("L");if(I.startsWith("[")&&J.startsWith("["))return B(I,J);if(I.startsWith("L")&&J.startsWith("L")){let U=I.slice(1,-1);return(_.get(U)??(U==="java.lang.String"?eo:[U,"java.lang.Object"])).includes(J.slice(1,-1))}return!1},N=(f,S)=>f instanceof lt?S==="[Ljava.lang.String;"||q(f,S.slice(1)):f instanceof Bt&&S.length===f.className.length+3&&S.slice(2,-1)===f.className?!0:q(f,S.slice(1)),F=new Map,q=(f,S)=>{if(f===null||typeof f!="object")return!1;if(S.charCodeAt(0)===91)return f instanceof zt&&B(f.descriptor,S);let I=F.get(S);return I===void 0&&F.set(S,I=S.slice(1,-1)),P(f).includes(I)},Z=f=>f instanceof Bt?f.className:f instanceof lt?"java.lang.String":f instanceof Zt?qr[f.kind]:f instanceof zt?f.descriptor:f.className,ne=f=>{let S=f.replace(/^\\[+/,"").replace(/^L(.*);$/,"$1");return _.has(S)&&!S.includes(".")?`unnamed module of loader ${Xl}`:"module java.base of loader \'bootstrap\'"},cn=(f,S)=>{let I=Z(f),J=ne(I),U=ne(S),H=J===U?`${I} and ${S} are in ${J}`:`${I} is in ${J}; ${S} is in ${U}`;return`class ${I} cannot be cast to class ${S} (${H})`},rt=O(p[i.entry]),it=[rt],D=rt.code,vt=rt.locals,b=rt.stack,y=0,E=0,$t=0,Xr=Math.min(to,e.maxInstructions+1),Ws=0,xe=0,Ie=(f,S)=>({outcome:{kind:"resource-limit",limit:f,message:S},instructions:Math.min($t,e.maxInstructions)}),Yr=f=>{rt.pc=E;let S=[],I=f!==void 0;for(let J=it.length-1;J>=0&&S.length<1024;J--){let U=it[J];U.method.hidden||I&&f(U)||(I=!1,S.push({className:U.method.className,method:U.method.name,file:U.method.file,line:Va(U.method,U.pc)}))}return S},Qr=new Map(v.map((f,S)=>[f.name,S])),ds=(f,S,I=null,J)=>{let U=Qr.get(f)??Qr.get("java.lang.RuntimeException"),H=R[U].slice();return H[yt.message]=S===null?null:new lt(S),H[yt.trace]=new Gs(J??Yr()),I&&(H[yt.cause]=I,H[yt.causeSet]=1),new Bt(f,U,H,o.next())},dt=(f,S,I=null)=>{throw new $n(ds(f,S,I))},Zr=[],ko=f=>{let S=Zr[f],I=S.fields[yt.message],J=I===null?S.className:`${S.className}: ${I.value}`,U=S.fields[yt.trace]?.frames??[],H=ds("java.lang.ExceptionInInitializerError",`Exception ${J} [in thread "main"]`,null,U);return dt("java.lang.NoClassDefFoundError",`Could not initialize class ${v[f].name}`,H)},Rn=null,Xs="",ti=()=>({outcome:{kind:"exception",className:Rn.className,text:Xs},instructions:$t,...Qs?{inputExhausted:Qs}:{}}),Co=f=>{let S=f;for(rt.pc=E;it.length;){let J=it[it.length-1],U=J.method.handlers;if(U)for(let H=0;H<U.length;H+=4){if(J.pc<U[H]||J.pc>=U[H+1])continue;let ut=U[H+3];if(!(ut>=0&&!q(S,i.strings[ut])))return rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,b[y++]=S,E=U[H+2],null}it.pop(),J.initClass>=0&&(L[J.initClass]=Za,Zr[J.initClass]=S,!q(S,"Ljava.lang.Error;")&&it.length&&(rt=it[it.length-1],E=rt.pc,S=ds("java.lang.ExceptionInInitializerError",null,S)))}if(Rn)return Xs+=`\nException: ${S.className} thrown from the UncaughtExceptionHandler in thread "main"\n`,ti();Rn=S;let I=O(p[i.uncaught]);return I.locals[0]=S,it.push(I),rt=I,D=I.code,vt=I.locals,b=I.stack,y=0,E=0,null},ei=new Map,ni=new Map,Ys=(f,S)=>{if(!(f==="boolean"||f==="byte"||(f==="int"||f==="long"||f==="short")&&S>=-128&&S<=127||f==="char"&&S<=127))return new Zt(f,S);let J=f+S,U=ni.get(J);return U||ni.set(J,U=new Zt(f,S)),U},Qs=!1,Zs={stdout:!1,stderr:!1},We={hash:()=>o.next(),intern:f=>a.intern(f),fail:(f,S,I)=>{throw new zs(f,S,I)},raise:f=>{throw new $n(f)},limitation:f=>{throw new Ks(f)},charge:f=>{$t+=f},allocate:f=>{if(xe+f>e.maxArrayElements)throw new cs(`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f},print:(f,S)=>{let I=ui(f==="out"?"stdout":"stderr",S);if(I)throw new an(I)},closeStream:f=>{Zs[f==="out"?"stdout":"stderr"]=!0},streamClosed:f=>Zs[f==="out"?"stdout":"stderr"],exit:f=>{throw new an({outcome:{kind:"exit",status:f},instructions:$t})},seed:()=>BigInt(Math.floor(Math.random()*2**32))*2n**16n+BigInt(Math.floor(Math.random()*2**16)),stdin:()=>r,inputExhausted:()=>{Qs=!0},checkString:f=>{if(f>e.maxStringLength)throw new cs(`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`)},methodOf:(f,S,I)=>v[f.classIndex].virtuals[`${S}/${I}`]??-1,overrideOf:(f,S)=>v[f.classIndex].libraryOverrides?.[S]??-1,castMessage:cn,storable:(f,S)=>N(f,S),className:f=>Z(f),toStringMethod:f=>v[f.classIndex].toString,equalsMethod:f=>v[f.classIndex].equals,hashCodeMethod:f=>v[f.classIndex].hashCode,box:Ys,staticMethod:(f,S,I)=>p.findIndex(J=>J.isStatic&&J.className===f&&J.name===S&&J.argCount===I)},ms=f=>f instanceof zs?dt(f.className,f.message,f.cause?ds(f.cause.className,f.cause.message,null):null):f instanceof Ks?{outcome:{kind:"engine-limitation",message:f.message},instructions:$t}:f instanceof cs?Ie("memory",f.message):f instanceof an?f.result:null,tr=(f,S)=>{let I=p[f];if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);let J=li(I,-1),U=I.argSlots;for(let H=0;H<S.length;H++)J.locals[U?U[H]:H]=S[H];return it.push(J),rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,E=0,I.isStatic&&L[I.classIndex]!==rn&&hn(I.classIndex),null},er=[],si=f=>{let S=rt,I;try{let U=S.then;if(U){if(I=U(f),I instanceof Ke)return I.resumes?(S.then=null,S.native=I.resumes,S.convert=I.convert):S.then=I.then,tr(I.invoke,I.args);Vr(I)&&(S.then=null,S.native=I,f=void 0)}if(!S.then){let H=S.native.next(f);if(!H.done)return tr(H.value.invoke,H.value.args);let ut=S.convert;I=ut?ut(H.value):H.value}}catch(U){let H=ms(U);if(H)return H;throw U}it.pop();let J=S.nativeReturns;return S.native=null,S.then=null,S.convert=null,er.length<32&&er.push(S),rt=it[it.length-1],D=rt.code,vt=rt.locals,b=rt.stack,y=rt.sp,E=rt.returnPc,J&&(b[y++]=I??null),null},ri=(f,S)=>{if(rt.pc=E,rt.returnPc=S,rt.sp=y,it.length>e.maxCallDepth)return null;let I=er.pop()??O(Qa);return I.nativeReturns=f,it.push(I),rt=I,I},un=(f,S,I)=>{let J=ri(S,I);return J?(J.native=f,si(void 0)):dt("java.lang.StackOverflowError",null)},ii=(f,S,I)=>{let J=ri(S,I);return J?(f.resumes?(J.native=f.resumes,J.convert=f.convert):J.then=f.then,tr(f.invoke,f.args)):dt("java.lang.StackOverflowError",null)};function*ai(f){let S=yield*d.toString(We,f);return new lt(S)}let oi=(f,S,I)=>{y-=S.length;let J;try{J=d.natives[f](We,S)}catch(U){let H=ms(U);if(H)return H;throw U}return J instanceof Ke?ii(J,!0,I):Vr(J)?un(J,!0,I):(b[y++]=J??null,E=I,null)};for(let f of p)f.freeFrames=[];let li=(f,S)=>{let I=f.freeFrames.pop();if(!I)return O(f,S);let J=I.locals;for(let U=0;U<J.length;U++)J[U]=0;return I.sp=0,I.pc=0,I.returnPc=0,I.initClass=S,I},Eo=f=>{let S=f.method.freeFrames;S&&S.length<32&&S.push(f)},Xe=(f,S,I=-1)=>{rt.pc=E,rt.returnPc=S,y-=f.argCount,rt.sp=y;let J=li(f,I),U=f.argSlots;if(U)for(let H=0;H<f.argCount;H++)J.locals[U[H]]=b[y+H];else for(let H=0;H<f.argCount;H++)J.locals[H]=b[y+H];it.push(J),rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,E=0},hn=f=>{if(L[f]!==Vl)return L[f]===Za&&ko(f),!1;for(let J of v[f].types){let U=j.get(J),H=U===void 0?-1:C[U];if(!(H<0||!M[H])&&(M[H]=!1,t("stderr",i.loadWarnings[H].text),i.loadWarnings[H].fails))throw new an({outcome:{kind:"compile-error"},instructions:$t})}let S=v[f].superclass;if(S>=0&&hn(S))return!0;let I=v[f].clinit;return I<0?(L[f]=rn,!1):(L[f]=Hl,Xe(p[I],E,f),!0)},Lt=f=>dt("java.lang.NullPointerException",f>=0?m[f]:null),ci=(f,S,I)=>{let J=S[I],U=f.slice(1);if(I===S.length-1){let ut=Gl(U);return new zt(ut,zr(ut,J),o.next(),f)}let H=new Array(J);for(let ut=0;ut<J;ut++)H[ut]=ci(U,S,I+1);return new zt(Y.REF,H,o.next(),f)},ui=(f,S)=>{if(Zs[f])return null;if(Rn&&f==="stderr")return Xs+=S,null;if(Ws+S.length>e.maxOutputChars){let I=e.maxOutputChars-Ws;return I>0&&t(f,S.slice(0,I)),Ie("output",`the program printed more than ${e.maxOutputChars.toLocaleString("en-US")} characters`)}return Ws+=S.length,$t+=S.length>>>6,S&&t(f,S),null},hi=[];if(s){let f={string:S=>new lt(S),box:Ys,array:(S,I,J)=>new zt(S,I,o.next(),J),object:S=>{let I=i.classes[S];return new Bt(I.name,S,I.instanceFieldIsReference.map(J=>J?null:0),o.next())},list:S=>{if(!d)throw new Error("interpreter: practice lists need the Java library");return d.newList(We,S)},allocate:S=>We.allocate(S)};try{hi=s.args(f)}catch(S){let I=ms(S);if(I)return I;throw S}}for(;;)try{for(;;){if(++$t>=Xr){if($t>e.maxInstructions)return Ie("instructions",`the program ran more than ${e.maxInstructions.toLocaleString("en-US")} steps`);if(g!==1/0&&k.now()>g)return Ie("time",`the program ran longer than ${e.maxDurationMs} ms`);Xr=Math.min($t+to,e.maxInstructions+1),n?.()}switch(D[E]){case 1:b[y++]=D[E+1],E+=2;break;case 2:b[y++]=c[D[E+1]],E+=2;break;case 3:b[y++]=null,E+=1;break;case 4:b[y++]=vt[D[E+1]],E+=2;break;case 5:vt[D[E+1]]=b[--y],E+=2;break;case 6:y--,E+=1;break;case 7:b[y]=b[y-1],y++,E+=1;break;case 8:{let f=b[y-1];b[y-1]=b[y-2],b[y-2]=f,b[y++]=f,E+=1;break}case 9:{let f=b[y-1];b[y-1]=b[y-2],b[y-2]=b[y-3],b[y-3]=f,b[y++]=f,E+=1;break}case 24:b[y]=b[y-2],b[y+1]=b[y-1],y+=2,E+=1;break;case 10:{let f=b[--y];b[y-1]=b[y-1]+f|0,E+=1;break}case 11:{let f=b[--y];b[y-1]=b[y-1]-f|0,E+=1;break}case 12:{let f=b[--y];b[y-1]=Math.imul(b[y-1],f),E+=1;break}case 13:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=b[y-1]/f|0,E+=1;break}case 14:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=b[y-1]%f|0,E+=1;break}case 15:b[y-1]=-b[y-1]|0,E+=1;break;case 16:{let f=b[--y];b[y-1]=b[y-1]<<f,E+=1;break}case 17:{let f=b[--y];b[y-1]=b[y-1]>>f,E+=1;break}case 18:{let f=b[--y];b[y-1]=b[y-1]>>>f|0,E+=1;break}case 19:{let f=b[--y];b[y-1]=b[y-1]&f,E+=1;break}case 20:{let f=b[--y];b[y-1]=b[y-1]|f,E+=1;break}case 21:{let f=b[--y];b[y-1]=b[y-1]^f,E+=1;break}case 22:b[y-1]=~b[y-1],E+=1;break;case 23:b[y-1]=b[y-1]^1,E+=1;break;case 25:b[y-1]=b[y-1]&65535,E+=1;break;case 163:b[y-1]=b[y-1]<<24>>24,E+=1;break;case 164:b[y-1]=b[y-1]<<16>>16,E+=1;break;case 165:case 167:b[y-1]=Math.fround(b[y-1]),E+=1;break;case 166:b[y-1]=yn(b[y-1]),E+=1;break;case 168:{let f=b[--y];b[y-1]=Math.fround(b[y-1]+f),E+=1;break}case 169:{let f=b[--y];b[y-1]=Math.fround(b[y-1]-f),E+=1;break}case 170:{let f=b[--y];b[y-1]=Math.fround(b[y-1]*f),E+=1;break}case 171:{let f=b[--y];b[y-1]=Math.fround(b[y-1]/f),E+=1;break}case 172:{let f=b[--y];b[y-1]=Math.fround(b[y-1]%f),E+=1;break}case 173:b[y-1]=new lt(Fe(b[y-1])),E+=1;break;case 30:case 36:{let f=b[--y];b[y-1]=b[y-1]===f?1:0,E+=1;break}case 31:case 37:{let f=b[--y];b[y-1]=b[y-1]!==f?1:0,E+=1;break}case 32:{let f=b[--y];b[y-1]=b[y-1]<f?1:0,E+=1;break}case 33:{let f=b[--y];b[y-1]=b[y-1]<=f?1:0,E+=1;break}case 34:{let f=b[--y];b[y-1]=b[y-1]>f?1:0,E+=1;break}case 35:{let f=b[--y];b[y-1]=b[y-1]>=f?1:0,E+=1;break}case 40:E=D[E+1];break;case 41:E=b[--y]===0?D[E+1]:E+2;break;case 180:{let f=b[--y],S=b[--y];E=Vs(D[E+1],S,f)?D[E+2]:E+3;break}case 181:E=Vs(D[E+1],b[--y],D[E+2])?D[E+3]:E+4;break;case 182:E=Vs(D[E+1],vt[D[E+2]],vt[D[E+3]])?D[E+4]:E+5;break;case 183:E=Vs(D[E+1],vt[D[E+2]],D[E+3])?D[E+4]:E+5;break;case 184:E=vt[D[E+2]]===null==(D[E+1]===1)?D[E+3]:E+4;break;case 185:b[y++]=vt[D[E+1]],b[y++]=vt[D[E+2]],E+=3;break;case 186:b[y++]=vt[D[E+1]],b[y++]=D[E+2],E+=3;break;case 187:b[y-1]=b[y-1]+D[E+1]|0,E+=2;break;case 191:{let f=b[--y],S=b[--y];S.base=f,f.owner=S,E+=1;break}case 192:{let f=b[y-1];f instanceof Bt&&f.base!==null&&(b[y-1]=f.base),E+=1;break}case 190:b[y-1]=Ul(D[E+1],b[y-1],D[E+2]),E+=3;break;case 188:{let f=D[E+1];vt[f]=vt[f]+D[E+2]|0,E=D[E+3];break}case 189:{let f=vt[D[E+1]],S=vt[D[E+2]];if(f===null)return Lt(D[E+4]);if(S<0||S>=f.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(S,f.data.length));b[y++]=f.data[S],E+=5;break}case 42:E=b[--y]!==0?D[E+1]:E+2;break;case 43:{let f=D[E+1];vt[f]=vt[f]+D[E+2]|0,E+=3;break}case 50:b[y-1]=new lt(String(b[y-1])),E+=1;break;case 54:b[y-1]=new lt(String.fromCharCode(b[y-1])),E+=1;break;case 143:b[y-1]=new lt(String(b[y-1])),E+=1;break;case 144:b[y-1]=new lt(de(b[y-1])),E+=1;break;case 120:b[y++]=u[D[E+1]],E+=2;break;case 121:{let f=b[--y];b[y-1]=vi(b[y-1],f),E+=1;break}case 122:{let f=b[--y];b[y-1]=wi(b[y-1],f),E+=1;break}case 123:{let f=b[--y];b[y-1]=ki(b[y-1],f),E+=1;break}case 124:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=Ci(b[y-1],f),E+=1;break}case 125:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=Ei(b[y-1],f),E+=1;break}case 126:b[y-1]=cr(b[y-1]),E+=1;break;case 127:{let f=b[--y];b[y-1]=Ai(b[y-1],f),E+=1;break}case 128:{let f=b[--y];b[y-1]=Ii(b[y-1],f),E+=1;break}case 129:{let f=b[--y];b[y-1]=Oi(b[y-1],f),E+=1;break}case 130:{let f=b[--y];b[y-1]=Li(b[y-1],f),E+=1;break}case 131:{let f=b[--y];b[y-1]=Ni(b[y-1],f),E+=1;break}case 132:{let f=b[--y];b[y-1]=$i(b[y-1],f),E+=1;break}case 133:{let f=b[--y];b[y-1]=b[y-1]+f,E+=1;break}case 134:{let f=b[--y];b[y-1]=b[y-1]-f,E+=1;break}case 135:{let f=b[--y];b[y-1]=b[y-1]*f,E+=1;break}case 136:{let f=b[--y];b[y-1]=b[y-1]/f,E+=1;break}case 137:{let f=b[--y];b[y-1]=b[y-1]%f,E+=1;break}case 138:b[y-1]=-b[y-1],E+=1;break;case 139:b[y-1]=bs(b[y-1]),E+=1;break;case 140:b[y-1]=Ss(b[y-1]),E+=1;break;case 141:b[y-1]=Fn(b[y-1]),E+=1;break;case 142:b[y-1]=Dn(b[y-1]),E+=1;break;case 146:if(b[--y]===null)return Lt(D[E+1]);E+=2;break;case 147:{switch(D[E+1]){case ht.ABS_I:b[y-1]=Math.abs(b[y-1])|0;break;case ht.ABS_L:{let S=b[y-1];b[y-1]=S<0?cr(S):S;break}case ht.ABS_D:b[y-1]=Math.abs(b[y-1]);break;case ht.MAX_I:case ht.MAX_D:{let S=b[--y];b[y-1]=Math.max(b[y-1],S);break}case ht.MIN_I:case ht.MIN_D:{let S=b[--y];b[y-1]=Math.min(b[y-1],S);break}case ht.MAX_L:{let S=b[--y],I=b[y-1];b[y-1]=I>=S?I:S;break}case ht.MIN_L:{let S=b[--y],I=b[y-1];b[y-1]=I<=S?I:S;break}case ht.SQRT:b[y-1]=Math.sqrt(b[y-1]);break;case ht.FLOOR:b[y-1]=Math.floor(b[y-1]);break;case ht.CEIL:b[y-1]=Math.ceil(b[y-1]);break;case ht.ROUND:b[y-1]=Mi(b[y-1]);break;case ht.ROUND_F:b[y-1]=Pi(b[y-1]);break}E+=2;break}case 145:{let f=i.strings[D[E+1]],S=D[E+2],I=b.slice(y-S,y);y-=S;for(let H of I)if(H<0)return dt("java.lang.NegativeArraySizeException",String(H));let J=0,U=1;for(let H of I)U*=H,J+=U;if(xe+J>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=J,$t+=J>>>4,b[y++]=ci(f,I,0),E+=3;break}case 51:b[y-1]=new lt(b[y-1]?"true":"false"),E+=1;break;case 52:{let f=b[y-1];f===null?b[y-1]=new lt("null"):f instanceof Zt?b[y-1]=new lt(Hr(f)):f instanceof lt||(b[y-1]=new lt(qe(f))),E+=1;break}case 53:{let f=b[--y],S=b[y-1],I=S.value.length+f.value.length;if(I>e.maxStringLength)return Ie("memory",`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`);$t+=I>>>6,b[y-1]=new lt(S.value+f.value),E+=1;break}case 60:{let f=D[E+3],S="";if(f!==Ot.NONE){let J=b[--y];switch(f){case Ot.INT:S=String(J);break;case Ot.CHAR:S=String.fromCharCode(J);break;case Ot.BOOLEAN:S=J?"true":"false";break;case Ot.STRING:S=J===null?"null":J.value;break;case Ot.LONG:S=String(J);break;case Ot.DOUBLE:S=de(J);break;case Ot.FLOAT:S=Fe(J);break;case Ot.CHAR_ARRAY:if(J===null)return dt("java.lang.NullPointerException",\'Cannot read the array length because "cbuf" is null\');S=Kl(J.data);break;default:S=J===null?"null":J instanceof lt?J.value:qe(J)}}D[E+2]===1&&(S+=`\n`);let I=ui(D[E+1]===1?"stderr":"stdout",S);if(I)return I;E+=4;break}case 72:{let f=p[D[E+1]];if(f.isStatic&&L[f.classIndex]!==rn&&hn(f.classIndex))break;let S=D[E+2];if(S>=0&&b[y-f.argCount]===null)return Lt(S);if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(f,E+3);break}case 70:case 71:{let f=D[E]===l.RETURN_VALUE?b[--y]:void 0,S=it.pop();if(S.initClass>=0&&(L[S.initClass]=rn),Eo(S),!it.length)return Rn?ti():{outcome:{kind:"completed"},instructions:$t};if(rt=it[it.length-1],rt.method===Qa){let I=si(f);if(I)return I;break}D=rt.code,vt=rt.locals,b=rt.stack,y=rt.sp,E=rt.returnPc,f!==void 0&&(b[y++]=f);break}case 80:{let f=b[y-1];if(f<0)return dt("java.lang.NegativeArraySizeException",String(f));if(xe+f>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f,$t+=f>>>4,b[y-1]=new zt(D[E+1],zr(D[E+1],f),o.next()),E+=2;break}case 84:{let f=b[y-1];if(f<0)return dt("java.lang.NegativeArraySizeException",String(f));if(xe+f>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f,$t+=f>>>4,b[y-1]=new zt(Y.REF,zr(Y.REF,f),o.next(),i.strings[D[E+1]]),E+=2;break}case 81:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+2]);if(f<0||f>=S.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(f,S.data.length));b[y-1]=S.data[f],E+=3;break}case 82:{let f=b[--y],S=b[--y],I=b[--y];if(I===null)return Lt(D[E+2]);if(S<0||S>=I.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(S,I.data.length));if(f!==null&&D[E+1]===Y.REF&&I.descriptor!=="[Ljava.lang.Object;"&&!N(f,I.descriptor))return dt("java.lang.ArrayStoreException",Z(f));I.data[S]=f,E+=3;break}case 83:{let f=b[y-1];if(f===null)return Lt(D[E+1]);b[y-1]=f.data.length,E+=2;break}case 90:{let f=b[y-1];if(f===null)return Lt(D[E+1]);b[y-1]=f.value.length,E+=2;break}case 91:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);if(f<0||f>=S.value.length)return dt("java.lang.StringIndexOutOfBoundsException",Hs(f,S.value.length));b[y-1]=S.value.charCodeAt(f),E+=2;break}case 92:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);b[y-1]=f instanceof lt&&f.value===S.value?1:0,E+=2;break}case 153:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);if(f===null)return Lt(D[E+2]);let I=S.value,J=f.value,U=Math.min(I.length,J.length),H=I.length-J.length;for(let ut=0;ut<U;ut++){let ve=I.charCodeAt(ut)-J.charCodeAt(ut);if(ve!==0){H=ve;break}}$t+=U>>>4,b[y-1]=H,E+=3;break}case 100:{let f=D[E+1],S=x[f];if(L[S]!==rn&&hn(S))break;b[y++]=T[f],E+=2;break}case 101:{let f=D[E+1],S=x[f];if(L[S]!==rn&&hn(S))break;T[f]=b[--y],E+=2;break}case 102:{let f=b[y-1];if(f===null)return Lt(D[E+2]);b[y-1]=f.fields[D[E+1]],E+=3;break}case 103:{let f=b[--y],S=b[--y];if(S===null)return Lt(D[E+2]);S.fields[D[E+1]]=f,E+=3;break}case 104:{let f=D[E+1];if(L[f]!==rn&&hn(f))break;b[y++]=new Bt(v[f].name,f,R[f].slice(),o.next()),E+=2;break}case 110:{let f=b[y-1];if(f instanceof Bt){let S=v[f.classIndex].toString;if(S>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[S],E+1);break}b[y-1]=new lt(qe(f))}else if(f===null)b[y-1]=new lt("null");else if(f instanceof zt)b[y-1]=new lt(Br(f));else if(f instanceof Zt)b[y-1]=new lt(Hr(f));else if(f instanceof be){y--;let S=un(ai(f),!0,E+1);if(S)return S;break}E+=1;break}case 148:{let f=D[E+1],S=i.natives[f],I=D[E+2];if(I>=0&&b[y-S.argCount]===null)return Lt(I);let J=b.slice(y-S.argCount,y);if(y-=S.argCount,S.unwrap)for(let H=0;H<J.length;H++){let ut=J[H];if(!(S.unwrap>>H&1)||!(ut instanceof Bt)||ut.base===null)continue;if(ut.base.opaque)return{outcome:{kind:"engine-limitation",message:`passing a ${ut.className}, an AbstractList subclass, to ${S.name.slice(0,S.name.indexOf("("))}()`},instructions:$t};let ve=S.unwrapCalls,Ye=Object.keys(v[ut.classIndex].libraryOverrides??{}).find(Jn=>!Ua.has(Jn)&&(ve.includes("*")||ve.includes(Jn)));if(Ye!==void 0)return{outcome:{kind:"engine-limitation",message:`passing a ${ut.className}, which overrides ${Ye.slice(0,Ye.indexOf("("))}(), to ${S.name.slice(0,S.name.indexOf("("))}(), which would call it`},instructions:$t};J[H]=ut.base}let U;try{U=h[f](We,J)}catch(H){let ut=ms(H);if(ut)return ut;throw H}if(U instanceof Ke){let H=ii(U,S.returnsValue,E+3);if(H)return H;break}if(Vr(U)){let H=un(U,S.returnsValue,E+3);if(H)return H;break}S.returnsValue&&(b[y++]=U??null),E+=3;break}case 149:b[y-1]=Ys(Pr[D[E+1]],b[y-1]),E+=2;break;case 150:{let f=b[y-1];if(f===null)return Lt(D[E+2]);b[y-1]=f.value,E+=3;break}case 154:b[y++]=hi[D[E+1]],E+=2;break;case 155:s.result(b[--y]),E+=1;break;case 152:{let f=D[E+1],S=D[E+2],I=c[D[E+3]].value,J=D[E+5]>=0?c[D[E+5]].value:null;if(S===0){let U=ei.get(f);U||ei.set(f,U=new Se(`${p[f].className}$$Lambda`,f,o.next(),[],I,D[E+4],J)),b[y++]=U}else{let U=b.slice(y-S,y);y-=S,b[y++]=new Se(`${p[f].className}$$Lambda`,f,o.next(),U,I,D[E+4],J)}E+=6;break}case 151:{let f=b[y-1];if(f===null)return Lt(D[E+1]);let S=new Uint16Array(f.value.length);for(let I=0;I<S.length;I++)S[I]=f.value.charCodeAt(I);if(xe+S.length>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=S.length,$t+=S.length>>>4,b[y-1]=new zt(Y.CHAR,S,o.next()),E+=2;break}case 111:{let f=b[y-1];if(f===null)return Lt(D[E+1]);if(f instanceof Bt&&v[f.classIndex].toString>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[f.classIndex].toString],E+2);break}if(f instanceof be){y--;let S=un(ai(f),!0,E+2);if(S)return S;break}f instanceof Zt?b[y-1]=new lt(Hr(f)):f instanceof lt||(b[y-1]=new lt(qe(f))),E+=2;break}case 112:{let f=b[y-1];if(f===null)return Lt(D[E+1]);if(f instanceof Bt&&v[f.classIndex].hashCode>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[f.classIndex].hashCode],E+2);break}if(f instanceof be&&!(f instanceof Se)&&d?.natives["hashCode()"]){let S=oi("hashCode()",[f],E+2);if(S)return S;break}b[y-1]=f instanceof lt?Yl(f.value):f instanceof Zt?Ql(f):f.hash,E+=2;break}case 113:{let f=b[y-1],S=b[y-2];if(S===null)return Lt(D[E+1]);if(S instanceof Bt&&v[S.classIndex].equals>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[S.classIndex].equals],E+2);break}if(S instanceof be&&!(S instanceof Se)&&d?.natives["equals(Object)"]){let I=oi("equals(Object)",[S,f],E+2);if(I)return I;break}y--,S instanceof lt?b[y-1]=f instanceof lt&&f.value===S.value?1:0:S instanceof Zt?b[y-1]=f instanceof Zt&&f.kind===S.kind&&Object.is(f.value,S.value)?1:0:b[y-1]=S===f?1:0,E+=2;break}case 159:{let f=D[E+1];if(f===2){let S=b[--y];b[y-1]=b[y-1]===S?1:0}else{let S=b[y-1];b[y-1]=f===0?new lt(qe(S)):S.hash}E+=2;break}case 156:{let f=p[D[E+1]],S=D[E+2],I=b[y-f.argCount];if(I===null)return Lt(S);let J=f;if(I instanceof Bt){let U=v[I.classIndex].vtable[f.selector];U>=0&&(J=p[U])}else if(I instanceof Se&&I.samSelector===f.selector){let U=y-f.argCount,H=b.slice(U+1,y);y=U;for(let ut of I.captured)b[y++]=ut;for(let ut of H)b[y++]=ut;J=p[I.method]}if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(J,E+3);break}case 157:{let f=b[y-1],S=i.strings[D[E+1]];if(f!==null&&!q(f,S)){let I=S.startsWith("[")?S:S.slice(1,-1);return dt("java.lang.ClassCastException",cn(f,I))}E+=2;break}case 160:{let f=v[D[E+1]],S=b[y-1];if(S===null)return dt("java.lang.NullPointerException","Name is null");let I=f.enumConstants.find(J=>T[J].fields[0].value===S.value);if(I===void 0)return dt("java.lang.IllegalArgumentException",`No enum constant ${f.canonicalName}.${S.value}`);b[y-1]=T[I],E+=2;break}case 158:b[y-1]=q(b[y-1],i.strings[D[E+1]])?1:0,E+=2;break;case 161:{let f=b[--y];if(f===null)return Lt(D[E+1]);throw new $n(f)}case 162:{let f=D[E+1];if(f===Ut.PRINT_TRACE||f===Ut.PRINT_UNCAUGHT){let S=b[--y],I=un(Io(S,f===Ut.PRINT_UNCAUGHT),!1,E+2);if(I)return I;break}if(f===Ut.FILL_TRACE){let S=b[y-1],I=v[S.classIndex].types,J=U=>(U.method.name==="<init>"||U.method.name==="fillInStackTrace")&&I.includes(U.method.className);S.fields[yt.trace]=new Gs(Yr(J))}else if(f===Ut.ADD_SUPPRESSED){let S=b[--y],I=b[--y];if(S===I)return dt("java.lang.IllegalArgumentException","Self-suppression not permitted",S);if(S===null)return dt("java.lang.NullPointerException","Cannot suppress a null exception.");let J=I.fields[yt.suppressed];J?J.push(S):I.fields[yt.suppressed]=[S]}else if(f===Ut.GET_SUPPRESSED){let S=b[y-1],I=nr(S);We.allocate(I.length),b[y-1]=new zt(Y.REF,I.slice(),o.next(),"[Ljava.lang.Throwable;")}else if(f===Ut.CLASS_NAME)b[y-1]=new lt(b[y-1].className);else if(f===Ut.INIT_CAUSE){let S=b[y-1],I=b[y-2];if(I.fields[yt.causeSet]){y-=2;let J=un(Ao(I,S),!1,E+2);if(J)return J;break}if(S===I)return dt("java.lang.IllegalArgumentException","Self-causation not permitted",I);I.fields[yt.cause]=S,I.fields[yt.causeSet]=1,y--}E+=2;break}default:throw new Error(`interpreter: unknown opcode ${D[E]} at ${E}`)}}}catch(f){if(f instanceof an)return f.result;if(!(f instanceof $n))throw f;let S=Co(f.thrown);if(S)return S}function nr(f){return f.fields[yt.suppressed]??[]}function*fs(f){let S=yield{invoke:v[f.classIndex].toString,args:[f]};return S==null?"null":S.value}function*Ao(f,S){let I=S===null?"a null":yield*fs(S);return dt("java.lang.IllegalStateException",`Can\'t overwrite cause with ${I}`,f)}function*Io(f,S){let I=Nt=>We.print("err",Nt),J=new Set([f]),U=Nt=>(Nt.fields[yt.trace]?.frames??[]).map(Xa),H=Nt=>[...U(Nt),...zl].slice(0,1024);function*ut(Nt){return yield{invoke:v[Nt.classIndex].virtuals["getCause/0"],args:[Nt]}}function*ve(Nt,di,mi,dn){if(J.has(Nt)){I(`${dn}${mi}[CIRCULAR REFERENCE: ${yield*fs(Nt)}]\n`);return}J.add(Nt);let Qe=H(Nt),jn=Qe.length-1;for(let we=di.length-1;jn>=0&&we>=0&&Qe[jn]===di[we];we--)jn--;let fi=Qe.length-1-jn;I(`${dn}${mi}${yield*fs(Nt)}\n`);for(let we=0;we<=jn;we++)Qe[we].startsWith(Kr)||I(`${dn} at ${Qe[we]}\n`);fi&&I(`${dn} ... ${fi} more\n`);for(let we of nr(Nt))yield*ve(we,Qe,"Suppressed: ",dn+" ");let pi=yield*ut(Nt);pi&&(yield*ve(pi,Qe,"Caused by: ",dn))}S&&I(\'Exception in thread "main" \'),I(`${yield*fs(f)}\n`);let Ye=S?U(f):H(f);for(let Nt of Ye)Nt.startsWith(Kr)||I(` at ${Nt}\n`);for(let Nt of nr(f))yield*ve(Nt,Ye,"Suppressed: "," ");let Jn=yield*ut(f);Jn&&(yield*ve(Jn,Ye,"Caused by: ",""))}}var Gt=class extends Error{},Te=class extends Error{},ln=class extends Error{},so=i=>i.replace(/\\s+/g,"");function io(i,t){let e=t.className?i.classes.filter(h=>h.name===t.className||h.displayName===t.className):i.classes;if(t.className&&!e.length)throw new Gt(`no class ${t.className} in the program`);let n=e.flatMap(h=>h.methods.filter(m=>m.name===t.method&&!m.lambda));if(t.params){let h=t.params.map(so);n=n.filter(m=>m.params.length===h.length&&m.params.every((p,k)=>so($(p))===h[k]))}let s=`${t.method}(${(t.params??[]).join(", ")})`;if(!n.length)throw new Gt(`no method ${t.params?s:t.method+"(...)"}${t.className?` in class ${t.className}`:""}`);if(n.length>1)throw new Gt(`${n.length} methods named ${t.method}: list its parameter types in practice.params to choose one`);let r=n[0],a=null;if(!r.isStatic){if(r.owner.isInner)throw new Gt(`${r.name} is an instance method of an inner class; make the class static or the method static`);if(a=r.owner.constructors.find(h=>h.params.length===0)??null,!a)throw new Gt(`${r.owner.displayName} needs a constructor with no parameters, to call its instance method ${r.name}`)}let o=r.params.map((h,m)=>hs(h,t,`parameter ${m+1} of ${r.name}`)),c=t.compare??{kind:"return"},u=null,d=null;if(c.kind==="argument"){if(!Number.isInteger(c.index)||c.index<0||c.index>=o.length)throw new Gt(`compare.index ${c.index} is not a parameter of ${r.name}`);d=c.index}else{if(r.returnType.tag==="void")throw new Gt(`${r.name} returns nothing: compare one of its arguments instead ({ kind: \'argument\', index })`);u=hs(r.returnType,t,`the result of ${r.name}`)}return{target:{method:r,constructor:a},params:o,result:u,compareIndex:d,tolerance:c.tolerance??0,signature:`${r.owner.displayName}.${r.name}(${r.params.map($).join(", ")})`}}function ao(i){switch(i.tag){case"int":return"I";case"long":return"J";case"double":return"D";case"char":return"C";case"boolean":return"Z";case"string":return"Ljava.lang.String;";case"class":return`L${i.symbol.binaryName};`;case"library":return`L${i.symbol.qualifiedName};`;case"array":return`[${ao(i.element)}`;default:return"Ljava.lang.Object;"}}var Zl={int:Y.INT,boolean:Y.BOOLEAN,char:Y.CHAR,long:Y.LONG,double:Y.DOUBLE};function hs(i,t,e){switch(i.tag){case"int":case"long":case"double":case"char":case"boolean":return{kind:i.tag};case"string":return{kind:"string"};case"array":return{kind:"array",element:hs(i.element,t,e),arrayKind:Zl[i.element.tag]??Y.REF,descriptor:ao(i),type:$(i)};case"library":let n=i.symbol.box;if(n&&n!=="float"&&n!=="byte"&&n!=="short")return{kind:"box",box:n};if(["List","ArrayList","Collection"].includes(i.symbol.name)&&i.args[0])return{kind:"list",element:hs(i.args[0],t,e)};break;case"class":return tc(i.symbol,t,e)}throw new Gt(`${e} has type ${$(i)}, which practice cases cannot pass or compare yet`)}function tc(i,t,e){let n=i.fields.filter(k=>!k.isStatic),s=k=>{let g=n.find(O=>O.name===k);if(!g)throw new Gt(`practice.nodes.${i.name}: ${i.name} has no field ${k}`);return g},r=n.filter(k=>k.type.tag==="class"&&k.type.symbol===i),a=n.filter(k=>!r.includes(k)),o=t.nodes?.[i.name],c=o?.kind??(r.length===1&&a.length===1?"list":r.length===2&&a.length===1?"tree":null);if(!c)throw new Gt(`${e} has type ${i.displayName}, which is not a list or tree node; describe it in practice.nodes`);let u=o?.value?s(o.value):a[0];if(!u)throw new Gt(`practice.nodes.${i.name} needs its value field`);let d=hs(u.type,t,`${i.name}.${u.name}`);if(c==="list"){let k=o?.next?s(o.next):r[0];if(!k)throw new Gt(`practice.nodes.${i.name} needs its next field`);return{kind:"linked-list",cls:i,value:u,valueCodec:d,next:k}}let h=k=>r.find(g=>g.name===k),m=o?.left?s(o.left):h("left")??r[0],p=o?.right?s(o.right):h("right")??r.find(k=>k!==m);if(!m||!p)throw new Gt(`practice.nodes.${i.name} needs its left and right fields`);return{kind:"tree",cls:i,value:u,valueCodec:d,left:m,right:p}}var ec=-2147483648,nc=2147483647,sc=-(1n<<63n),rc=(1n<<63n)-1n;function Pn(i){return JSON.stringify(i)??"undefined"}function ro(i,t,e){let n=s=>{throw new Te(`${e}: expected ${s}, got ${Pn(i)}`)};switch(t){case"int":return(typeof i!="number"||!Number.isInteger(i)||i<ec||i>nc)&&n("an int"),i;case"long":{let s;if(typeof i=="string"&&/^-?\\d+$/.test(i))s=BigInt(i);else if(typeof i=="number"&&Number.isSafeInteger(i))s=BigInt(i);else return n("a long, as a decimal string");return(s<sc||s>rc)&&n("a long in range"),At(s)}case"double":return typeof i=="number"?i:i==="NaN"?NaN:i==="Infinity"?1/0:i==="-Infinity"?-1/0:n(\'a double (a number, or "NaN", "Infinity", "-Infinity")\');case"char":return(typeof i!="string"||i.length!==1)&&n("a char, as a one-character string"),i.charCodeAt(0);case"boolean":return typeof i!="boolean"&&n("a boolean"),i?1:0}}function us(i,t,e,n){switch(t.kind){case"int":case"long":case"double":case"char":case"boolean":return ro(i,t.kind,n);case"string":if(i===null)return null;if(typeof i!="string")throw new Te(`${n}: expected a String, got ${Pn(i)}`);return e.string(i);case"box":return i===null?null:e.box(t.box,ro(i,t.box,n));case"array":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected ${t.type}, an array, got ${Pn(i)}`);e.allocate(i.length);let s=i.map((a,o)=>us(a,t.element,e,`${n}[${o}]`)),r;switch(t.arrayKind){case Y.INT:r=Int32Array.from(s);break;case Y.BOOLEAN:r=Uint8Array.from(s);break;case Y.CHAR:r=Uint16Array.from(s);break;case Y.DOUBLE:r=Float64Array.from(s);break;default:r=s}return e.array(t.arrayKind,r,t.descriptor)}case"list":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a List, an array, got ${Pn(i)}`);return e.list(i.map((s,r)=>us(s,t.element,e,`${n}[${r}]`)))}case"linked-list":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a ${t.cls.name} list, an array of values, got ${Pn(i)}`);e.allocate(i.length);let s=null;for(let r=i.length-1;r>=0;r--){let a=e.object(t.cls.index);a.fields[t.value.index]=us(i[r],t.valueCodec,e,`${n}[${r}]`),a.fields[t.next.index]=s,s=a}return s}case"tree":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a ${t.cls.name} tree, a level-order array, got ${Pn(i)}`);if(!i.length||i[0]===null)return null;e.allocate(i.length);let s=c=>{let u=e.object(t.cls.index);return u.fields[t.value.index]=us(i[c],t.valueCodec,e,`${n}[${c}]`),u},r=s(0),a=[r],o=1;for(let c=0;c<a.length&&o<i.length;c++){let u=a[c];for(let d of[t.left,t.right]){if(o>=i.length)break;if(i[o]!==null){let h=s(o);u.fields[d.index]=h,a.push(h)}o++}}return r}}}var oo=1e5;function on(i,t,e){let n=s=>{if(e.nodes-=s,e.nodes<0)throw new ln(`the result has more than ${oo.toLocaleString("en-US")} elements, or is cyclic`)};switch(t.kind){case"int":return i;case"long":return String(i);case"double":return ic(i);case"char":return String.fromCharCode(i);case"boolean":return i===1;case"string":return i===null?null:i.value;case"box":return i===null?null:on(i.value,{kind:t.box},e);case"array":{if(i===null)return null;let s=i.data;return n(s.length),Array.from(s,r=>on(r,t.element,e))}case"list":{if(i===null)return null;let s=bn()?.listItems(i);if(!s)throw new ln("the result is not an ArrayList");return n(s.length),s.map(r=>on(r,t.element,e))}case"linked-list":{let s=[],r=new Set;for(let a=i;a;a=a.fields[t.next.index]){if(r.has(a))throw new ln(`the ${t.cls.name} list has a cycle`);r.add(a),n(1),s.push(on(a.fields[t.value.index],t.valueCodec,e))}return s}case"tree":{if(i===null)return[];let s=[],r=[i];for(let a=0;a<r.length;a++){let o=r[a];if(n(1),!o){s.push(null);continue}s.push(on(o.fields[t.value.index],t.valueCodec,e)),r.push(o.fields[t.left.index],o.fields[t.right.index])}for(;s.length&&s[s.length-1]===null;)s.pop();return s}}}function ic(i){return Number.isNaN(i)?"NaN":i===1/0?"Infinity":i===-1/0?"-Infinity":i}function qs(i,t,e=0){if(typeof i=="number"&&typeof t=="number")return i===t||Math.abs(i-t)<=e;if(Array.isArray(i)&&Array.isArray(t))return i.length===t.length&&i.every((n,s)=>qs(n,t[s],e));if(i&&t&&typeof i=="object"&&typeof t=="object"&&!Array.isArray(i)&&!Array.isArray(t)){let n=Object.keys(i);return n.length===Object.keys(t).length&&n.every(s=>qs(i[s],t[s],e))}return i===t}function lo(i,t){if(t.length!==i.params.length)throw new Te(`${i.signature} takes ${i.params.length} argument${i.params.length===1?"":"s"}, the case has ${t.length}`);let e=[],n=null;return{host:{args:a=>e=t.map((o,c)=>us(o,i.params[c],a,`argument ${c+1}`)),result:a=>{n=a}},actual:()=>{let a={nodes:oo};return i.compareIndex!==null?on(e[i.compareIndex],i.params[i.compareIndex],a):on(n,i.result,a)}}}function ac(i,t){let e=`${i}(${t.args.map(a=>JSON.stringify(a)).join(", ")})`,n=a=>JSON.stringify(a),s=[];switch(t.status){case"passed":s.push(`\\u2713 ${t.id} ${e} \\u2192 ${n(t.actual)}`);break;case"failed":s.push(`\\u2717 ${t.id} ${e} \\u2192 ${n(t.actual)}, expected ${n(t.expected)}`);break;case"completed":s.push(`\\u2022 ${t.id} ${e} \\u2192 ${n(t.actual)}`);break;case"invalid-case":s.push(`? ${t.id} invalid case: ${t.error}`);break;case"not-run":s.push(`- ${t.id} not run (${t.reason})`);break;default:s.push(`\\u2717 ${t.id} ${e}: ${t.status.replace("-"," ")}`),t.error&&s.push(...t.error.trimEnd().split(`\n`).map(a=>` ${a}`))}let r=t.stdout+t.stderr;return r&&s.push(...r.trimEnd().split(`\n`).map(a=>` | ${a}`)),s}function co(i,t){let e=t.flatMap(r=>ac(i,r)),n=t.filter(r=>r.expected!==void 0).length,s=t.filter(r=>r.status==="passed").length;return e.push(n?`${s} of ${n} passed`:`${t.length} case${t.length===1?"":"s"} run`),e.join(`\n`)+`\n`}var Wr={maxFiles:32,maxSourceChars:5e5,maxTotalSourceChars:1e6,maxNestingDepth:200,maxExpressionDepth:1e3,maxInstructions:2e8,maxOutputChars:1e6,maxStringLength:1e7,maxArrayElements:16e6,maxCallDepth:5e4,maxDurationMs:0},Mn=()=>globalThis.performance.now();function oc(i,t){let e=Object.keys(i);return t||("Main.java"in i?"Main.java":e.find(n=>n.endsWith(".java"))??e[0]??"Main.java")}function ho(i,t={}){return mo(i,t).result}function mo(i,t,e=!0){let n=Mn(),s={...Wr,...t.limits},r=oc(i,t.entry),a=i[r]??"",o=sr(r,a),c=new mn,u=new Map([[r,o]]),d=null,h=v=>({result:{program:v,diagnostics:c.items,entry:r,diagnosticText:c.items.length?rr(c.items,u):"",compileMs:Mn()-n},checked:d,source:o});if(Object.keys(i).length>s.maxFiles)return c.launchError(r,w.limit,`too many files for this engine (limit ${s.maxFiles})`),h(null);if(!(r in i)){let v=c.launchError(r,w.noMain,`could not find or load main class ${r}`);return v.text=`Error: Could not find or load main class ${r}\nCaused by: java.lang.ClassNotFoundException: ${r}`,h(null)}let m=Object.keys(i).filter(v=>v.endsWith(".java")&&v.includes("\\\\"));if(m.length)return c.launchError(r,w.unsupported,`${m.join(", ")}: file names with \\\\ are not supported in this version; separate folders with /`),h(null);let p=new Set(Object.keys(i).filter(v=>v!==r&&v.endsWith(".java"))),k=null,g=new Set,O=[r],T=[],x=0;for(;;){for(let v of O.slice(T.length)){let R=i[v]??"",L=v===r?o:sr(v,R);if(u.set(v,L),R.length>s.maxSourceChars)return c.launchError(v,w.limit,`${v} is too large for this engine (limit ${s.maxSourceChars.toLocaleString("en-US")} characters)`),h(null);if(x+=R.length,x>s.maxTotalSourceChars)return c.launchError(v,w.limit,`the program\'s files are too large for this engine together (limit ${s.maxTotalSourceChars.toLocaleString("en-US")} characters)`),h(null);let C=Ti(R);if(C.errors.some(j=>j.code!=="syntax"||j.token===void 0)){for(let j of C.errors)c.error(L,j.offset,"lex",j.code,j.message);return h(null)}let M=zi(v,C.tokens,s,C.errors),_=M.errors[0];if(_){if(_.code==="no-class")v===r?c.launchError(v,w.noMain,_.message):c.launchError(r,w.unsupported,`${v} declares no class, so the launcher cannot find ${v.replace(/\\.java$/,"")} there`);else for(let j of M.errors)c.error(L,j.offset,"parse",j.code,j.message,j.details);return h(null)}T.push({unit:M.unit,file:L})}if(k===null){let v=T[0].unit.types[0]?.implicit?[]:T[0].unit.package?.names??[],R=r.split("/").slice(0,-1);if(v.length>R.length||v.some((L,C)=>R[R.length-v.length+C]!==L))return c.launchError(r,w.noMain,`end of path to source file does not match its package name ${v.join(".")}: ${r}`),h(null);k=R.slice(0,R.length-v.length).map(L=>`${L}/`).join("")}try{let v=new Set([...p].filter(_=>!O.includes(_)&&_.startsWith(k))),R=Ja(T,c,{launch:e,available:v,root:k,files:Object.keys(i),deferred:g}),L=[...c.items];if(c.items.splice(0,c.items.length,...L.filter(_=>!_.deferred)),!R||c.hasErrors)return h(null);d=R;let C=e?lc(Ur(R,o),R,L,u,r,g):null,M=C&&pr(C.natives);return M?{result:{program:null,diagnostics:[],entry:r,diagnosticText:"",compileMs:Mn()-n,needsLibrary:M},checked:null,source:o}:h(C)}catch(v){if(v instanceof is){O.push(v.fileName),v.header&&e&&g.add(v.fileName),T.length=0,x=0,c=new mn,u=new Map([[r,o]]);continue}if(v instanceof He)return c=new mn,c.launchError(r,w.unsupported,`${v.message}: not supported in this version`),h(null);if(!(v instanceof gn))throw v;return{result:{program:null,diagnostics:[],entry:r,diagnosticText:"",compileMs:Mn()-n,needsLibrary:v.module},checked:null,source:o}}}}function lc(i,t,e,n,s,r){let a=[];for(let o of n.keys()){if(o===s)continue;let c=r.has(o)?e.filter(d=>d.deferred&&d.file===o):e.filter(d=>d.severity==="warning"&&d.file===o);if(!c.length)continue;let u=t.classes.filter(d=>d.topLevel.file?.name===o).map(d=>d.index);a.push({classes:u,text:rr(c,n),...c.some(d=>d.severity==="error")?{fails:!0}:{}})}return a.length&&(i.loadWarnings=a),i}var cc={instructions:"The program ran for a very long time, so it was stopped. Look for a loop whose condition never becomes false.",output:"The program printed more output than this page can show, so it was stopped. Look for a print inside a loop that never ends.",memory:"The program used more memory (a very large array or String) than this in-browser Java engine allows, so it was stopped.",time:"The program ran longer than the time allowed, so it was stopped."},uc="This program reached Java behavior this in-browser engine does not reproduce exactly, so it stopped rather than show something that might differ from a real JVM.";function fo(i,t={}){return po(i,t)}var hc="The program read more input than standard input had (a Scanner found nothing left to read). Type the input in the input box, one value or line for each read, then run again.";function po(i,t,e){let n={...Wr,...t.limits},s="",r="",a=(p,k)=>{p==="stdout"?s+=k:r+=k,t.onOutput?.(p,k)};t.warnings&&a("stderr",t.warnings);let o=Mn(),{outcome:c,instructions:u,inputExhausted:d}=no(i,a,n,t.onCheckpoint,e,t.stdin??""),h=Mn()-o,m={stdout:s,diagnostics:[],instructions:u,compileMs:t.compileMs??0,runMs:h};switch(c.kind){case"completed":return{...m,status:"success",stderr:r,exitCode:0};case"exception":{let p=c.text;return d&&c.className==="java.util.NoSuchElementException"?{...m,status:"runtime-error",stderr:r+p,errorText:p,hint:hc,hintAbout:"stdin",exitCode:1}:{...m,status:"runtime-error",stderr:r+p,errorText:p,exitCode:1}}case"resource-limit":{let p=`Stopped: ${c.message} (limit of this in-browser Java engine).\n`;return{...m,status:"resource-limit",stderr:r+p,errorText:p,hint:cc[c.limit],exitCode:1}}case"engine-limitation":{let p=`Stopped: ${c.message} (limitation of this in-browser Java engine).\n`;return{...m,status:"engine-limitation",stderr:r+p,errorText:p,hint:uc,exitCode:1}}case"exit":return{...m,status:c.status===0?"success":"exited",stderr:r,exitCode:c.status,exited:!0};case"compile-error":return{...m,status:"compile-error",stderr:r,errorText:r,exitCode:2}}}var uo=500;function yo(i,t,e={}){let n={...Wr,...e.limits},s=Array.isArray(t.cases)?t.cases:[],r=g=>s.map((O,T)=>({id:O.id??String(T+1),status:"not-run",args:O.args??[],expected:O.expected,stdout:"",stderr:"",reason:g,instructions:0,durationMs:0})),{result:a,checked:o,source:c}=mo(i,e,!1),u={passed:0,total:s.length,diagnostics:a.diagnostics,diagnosticText:a.diagnosticText,compileMs:a.compileMs},d=g=>({...u,status:"invalid-practice",message:g,cases:r("invalid-practice")});if(!Array.isArray(t.cases)||typeof t.method!="string")return d("practice needs a method name and a list of cases");if(s.length>uo)return d(`too many cases (limit ${uo})`);if(a.needsLibrary)return{...u,status:"compile-error",cases:[],needsLibrary:a.needsLibrary};if(!o)return{...u,status:"compile-error",cases:r("compile-error")};let h;try{h=io(o,t)}catch(g){if(g instanceof Gt)return d(g.message);throw g}let m=Ur(o,c,h.target),p=pr(m.natives);if(p)return{...u,status:"compile-error",cases:[],needsLibrary:p};let k=[];for(let[g,O]of s.entries()){let T=Array.isArray(O.args)?O.args:[],x={id:O.id??String(g+1),status:"not-run",args:T,expected:O.expected,stdout:"",stderr:"",instructions:0,durationMs:0};k.push(x);let v,R;try{let L=lo(h,T);R=L.actual,v=po(m,{limits:n},L.host)}catch(L){if(L instanceof Te){x.status="invalid-case",x.error=L.message;continue}let C=L instanceof Error?L.message:String(L);x.reason="engine-failure";for(let M of r("engine-failure").slice(g+1))k.push(M);return{...u,status:"internal-error",message:`Internal error in the Java engine: ${C}`,cases:k,passed:k.filter(M=>M.status==="passed").length}}if(x.stdout=v.stdout,x.stderr=v.errorText?v.stderr.slice(0,v.stderr.length-v.errorText.length):v.stderr,x.instructions=v.instructions,x.durationMs=Math.round(v.runMs*100)/100,v.exited){x.status="runtime-error",x.error=`System.exit(${v.exitCode}) ended the program before ${t.method}() returned`;continue}if(v.status!=="success"){x.status=v.status==="runtime-error"||v.status==="resource-limit"||v.status==="engine-limitation"?v.status:"runtime-error",x.error=v.errorText,v.hint&&(x.hint=v.hint);continue}try{x.actual=R()}catch(L){if(!(L instanceof ln))throw L;x.status="runtime-error",x.error=`ResultEncodingError: ${L.message}`;continue}x.status=O.expected===void 0?"completed":qs(x.actual,O.expected,h.tolerance)?"passed":"failed"}return{...u,status:"completed",cases:k,passed:k.filter(g=>g.status==="passed").length}}var dc={JString:lt,JArray:zt,JObject:Bt,JBox:Zt,JLibObject:be,JLambda:Se,NativeThen:Ke,doubleToString:de,objectToString:qe,normLong:At,floatToString:Fe,floatToIntBits:Ts,intBitsToFloat:Ji,parseDecimalFloat:ur,parseHexFloating:Fi,l2f:yn};function go(i){qi(i(dc))}function bo(i,t){Wi(i,t)}var So="0.39.0";async function mc(i){let t=globalThis,e=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));try{let n=!1;if(typeof t.importScripts=="function")try{t.importScripts(e),n=!0}catch{}n||await import(e)}finally{URL.revokeObjectURL(e)}}async function fc(i,t,e){await e(t);let n=globalThis;if(i===vs){let r=n[mr];if(typeof r!="function")throw new Error("the library script did not define its factory");go(r);return}let s=n[Gi]?.[i];if(!s)throw new Error(`the script for ${i} did not define its natives`);bo(i,s)}var pc=8192,xo=16;function vo(i,t={}){let e=t.now??(()=>globalThis.performance.now()),n=[],s=0,r=0,a=0,o=null,c=(k,g)=>{o={job:k,module:g},i({type:"module-request",id:k.id,name:g})},u=()=>{if(r=e(),!n.length)return;let k=n;n=[],s=0;for(let g of k)i({type:g.type,id:a,text:g.text})},d=(k,g)=>{let O=n[n.length-1];O&&O.type===k?O.text+=g:n.push({type:k,text:g}),s+=g.length,(s>=pc||e()-r>=xo)&&u()},h=k=>{a=k.id,n=[],s=0,r=e();let g=e(),O=k.entry||"Main.java",T=k.files&&Object.keys(k.files).length?{...k.files}:{},x=Object.keys(T).length>0;!(O in T)&&(!x||k.code)&&(T[O]=k.code??"");try{let v=()=>{n.length&&e()-r>=xo&&u()};if(k.practice){m(k,T,O,g);return}let R=ho(T,{entry:O,limits:t.limits});if(R.needsLibrary){c(k,R.needsLibrary);return}let L=R.program?fo(R.program,{limits:t.limits,stdin:k.stdin??"",onOutput:d,onCheckpoint:v,compileMs:R.compileMs,warnings:R.diagnosticText}):{status:"compile-error",stdout:"",stderr:R.diagnosticText,errorText:R.diagnosticText,diagnostics:R.diagnostics,exitCode:1,instructions:0,compileMs:R.compileMs,runMs:0};u();let C=e()-g;if(L.status==="success"){i({type:"result",id:k.id,durationMs:C,status:"success"});return}if(L.status==="cancelled")return;i({type:"error",id:k.id,message:L.status==="exited"?`Exited with status ${L.exitCode}.`:(L.errorText??"").replace(/\\n$/,""),hint:L.hint,...L.hintAbout?{hintAbout:L.hintAbout}:{},durationMs:C,status:L.status,...L.diagnostics.length?{diagnostics:L.diagnostics}:{}})}catch(v){u();let R=v instanceof Error?v.message:String(v);i({type:"fatal",id:k.id,message:`Internal error in the Java engine: ${R}`})}},m=(k,g,O,T)=>{let x=k.practice,v=yo(g,x,{entry:O,limits:t.limits});if(v.needsLibrary){c(k,v.needsLibrary);return}let R=e()-T;switch(v.status){case"completed":i({type:"stdout",id:k.id,text:co(x.method,v.cases)}),i({type:"result",id:k.id,durationMs:R,status:"success",cases:v.cases,passed:v.passed,total:v.total});return;case"compile-error":i({type:"error",id:k.id,message:v.diagnosticText.replace(/\\n$/,""),durationMs:R,status:"compile-error",cases:v.cases,...v.diagnostics.length?{diagnostics:v.diagnostics}:{}});return;case"invalid-practice":i({type:"error",id:k.id,message:`Practice: ${v.message}`,durationMs:R,status:"invalid-practice",cases:v.cases});return;case"internal-error":i({type:"fatal",id:k.id,message:v.message??"Internal error in the Java engine"});return}},p=async k=>{if(!o||k.name!==o.module)return;let{job:g}=o;o=null;try{if(k.code===void 0)throw new Error(k.error??"the host sent no code");await fc(k.name,k.code,t.evaluate??mc)}catch(O){let T=O instanceof Error?O.message:String(O);i({type:"fatal",id:g.id,message:`Internal error in the Java engine: could not load the Java library (${T})`});return}h(g)};return k=>{switch(k.type){case"init":i({type:"ready",version:"25",interactiveStdin:!1,java:"25",engine:So});return;case"run":h(k);return;case"stdin-response":return;case"module":return p(k)}}}var wo=globalThis,yc=vo(i=>wo.postMessage(i));wo.onmessage=i=>yc(i.data);})();\n',n={"java-library":()=>import(`./java-library.generated-B7ib0gOX.js`),"java-library-time":()=>import(`./java-library-time.generated-Dl0XA7nZ.js`),"java-library-math":()=>import(`./java-library-math.generated-BQwpn8sQ.js`),"java-library-regex":()=>import(`./java-library-regex.generated-ItYSF2aV.js`),"java-library-bitset":()=>import(`./java-library-bitset.generated-C3m-nf8F.js`)},r=new class extends e{id=`java`;supportsPractice=!0;statusDecidesFailure=!0;get source(){return t}async loadModule(e){let t=n[e];if(!t)throw Error(`no module named ${e}`);return(await t()).JAVA_LIBRARY_SOURCE}get label(){return this.version?`Java ${this.version} (subset)`:`Java`}async editorLanguage(){let{java:e}=await import(`@codemirror/lang-java`);return e()}};export{r as javaRuntime};
|
|
1
|
+
import{t as e}from"./worker-runtime-VpuXbObm.js";var t='"use strict";(()=>{function sr(i,t){let e=[0];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);s===13?(t.charCodeAt(n+1)===10&&n++,e.push(n+1)):s===10&&e.push(n+1)}return{name:i,text:t,lineStarts:e}}function ps(i,t){let e=i.lineStarts,n=0,s=e.length-1;for(;n<s;){let r=n+s+1>>1;e[r]<=t?n=r:s=r-1}return{line:n+1,column:t-e[n]+1}}function yi(i,t){let e=i.lineStarts[t-1];if(e===void 0)return"";let n=i.lineStarts[t],s=n===void 0?i.text.length:n;for(;s>e&&(i.text.charCodeAt(s-1)===10||i.text.charCodeAt(s-1)===13);)s--;return i.text.slice(e,s)}var w={syntax:"syntax",unsupported:"unsupported",limit:"limit",cantResolve:"cant-resolve",incompatibleTypes:"incompatible-types",badOperands:"bad-operands",alreadyDefined:"already-defined",uninitialized:"var-might-not-have-been-initialized",unreported:"unreported-exception",notEffectivelyFinal:"not-effectively-final",unreachable:"unreachable",missingReturn:"missing-return",finalAssign:"final-assign",notStatement:"not-a-statement",numberTooLarge:"int-number-too-large",noMain:"no-main",unchecked:"unchecked",deprecation:"deprecation"},mn=class{items=[];error(t,e,n,s,r,a){let{line:o,column:c}=ps(t,e),u={code:s,phase:n,severity:"error",file:t.name,line:o,column:c,message:r,offset:e};return a&&a.length&&(u.details=a),this.items.push(u),u}warning(t,e,n,s,r){let a=this.error(t,e,"type",n,s,r);return a.severity="warning",a}launchError(t,e,n){let s={code:e,phase:"launch",severity:"error",file:t,line:0,column:0,message:n};return this.items.push(s),s}get hasErrors(){return this.items.some(t=>t.severity==="error")}};function rr(i,t){let e=i.filter(h=>h.phase!=="launch"),n=i.filter(h=>h.phase==="launch"),s=[],r=100,a=0,o=0,c=new Set;for(let h of e){if(h.severity==="error"?++a>r:++o>r){h.severity==="warning"&&h.message.startsWith("[unchecked]")&&c.add(h.file);continue}s.push(`${h.file}:${h.line}: ${h.severity}: ${h.message}`);let m=t.get(h.file);if(m&&h.line>0&&!(h.line>m.lineStarts.length-1&&m.lineStarts[h.line-1]===m.text.length&&m.text.length>0)){let p=yi(m,h.line);s.push(p);let k="";for(let g=0;g<h.column-1;g++)k+=p[g]===" "?" ":" ";s.push(k+"^")}for(let p of h.details??[])s.push(p)}let u=e.filter(h=>h.severity==="error").length,d=e.filter(h=>h.severity==="warning").length;for(let h of c)s.push(`Note: ${h} has additional unchecked or unsafe operations.`);u&&s.push(u===1?"1 error":`${Math.min(u,r)} errors`),u>r&&s.push(`only showing the first ${r} errors, of ${u} total; use -Xmaxerrs if you would like to see more`),d&&s.push(d===1?"1 warning":`${Math.min(d,r)} warnings`),u&&s.push("error: compilation failed");for(let h of n)s.push(h.text??`error: ${h.message}`);return s.join(`\n`)+`\n`}function Oo(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function gi(i){if(i.indexOf("\\\\u")===-1){let a=new Int32Array(i.length+1);for(let o=0;o<=i.length;o++)a[o]=o;return{text:i,offsets:a,errors:[]}}let t=[],e=[],n=[],s=0,r=0;for(;r<i.length;){let a=i.charCodeAt(r);if(a===92&&s%2===0&&i.charCodeAt(r+1)===117){let o=r+1;for(;i.charCodeAt(o)===117;)o++;let c=0,u=-1;for(let d=0;d<4;d++){let h=Oo(i.charCodeAt(o+d));if(h<0){u=o+d;break}c=c*16+h}if(u>=0){n.push({offset:u,message:"illegal unicode escape"}),t.push("\\\\"),e.push(r),s=1,r++;continue}t.push(String.fromCharCode(c)),e.push(r),s=0,r=o+4;continue}s=a===92?s+1:0,t.push(i[r]),e.push(r),r++}return e.push(i.length),{text:t.join(""),offsets:Int32Array.from(e),errors:n}}var Lo=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","_","true","false","null"]),No=[">>>=","<<=",">>=",">>>","...","->","::","++","--","&&","||","==","!=","<=",">=","+=","-=","*=","/=","&=","|=","^=","%=","<<",">>","(",")","{","}","[","]",";",",",".","@","=",">","<","!","~","?",":","+","-","*","/","&","|","^","%"];function Si(i){return i>=65&&i<=90||i>=97&&i<=122||i===95||i===36}function bi(i){return Si(i)||i>=48&&i<=57}function he(i){return i>=48&&i<=57}function $o(i){let t=i.charCodeAt(0);return t>=32&&t<127?`\'${i}\'`:`\'\\\\u${t.toString(16).padStart(4,"0")}\'`}function Ti(i){let t=gi(i),e=t.text,n=t.offsets,s=[],r=t.errors.map(T=>({offset:T.offset,code:"syntax",message:T.message}));if(r.length)return{tokens:[{kind:"eof",text:"",start:i.length,end:i.length}],errors:r};let a=(T,x,v="syntax")=>{r.push({offset:n[T],code:v,message:x,token:s.length})},o=(T,x)=>c("error",T,Math.max(x,T+1)),c=(T,x,v,R)=>{s.push({kind:T,text:e.slice(x,v),start:n[x],end:n[v],...R})},u=e.length;u>0&&e.charCodeAt(u-1)===26&&u--;let d=0;for(;d<u;){let T=e.charCodeAt(d);if(T===32||T===9||T===12||T===10||T===13){d++;continue}if(T===47&&e.charCodeAt(d+1)===47){for(;d<u&&e.charCodeAt(d)!==10&&e.charCodeAt(d)!==13;)d++;continue}if(T===47&&e.charCodeAt(d+1)===42){let v=e.indexOf("*/",d+2);if(v===-1||v+2>u){a(d,"unclosed comment"),d=u;break}d=v+2;continue}if(Si(T)){let v=d;for(;d<u&&bi(e.charCodeAt(d));)d++;if(d<u&&e.charCodeAt(d)>127&&/[\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Sc}]/u.test(e[d]))for(a(d,"identifiers containing non-ASCII characters are not supported in this version","unsupported");d<u&&(bi(e.charCodeAt(d))||e.charCodeAt(d)>127);)d++;let R=e.slice(v,d);c(Lo.has(R)?"keyword":"identifier",v,d);continue}if(he(T)||T===46&&he(e.charCodeAt(d+1))){d=h(d);continue}if(T===39){d=p(d);continue}if(T===34){e.startsWith(\'"""\',d)?d=g(d):d=k(d);continue}let x=No.find(v=>e.startsWith(v,d));if(x){c("operator",d,d+x.length),d+=x.length;continue}T>127&&/[\\p{L}\\p{Nl}\\p{Sc}\\p{Pc}]/u.test(e[d])?a(d,"identifiers containing non-ASCII characters are not supported in this version","unsupported"):(a(d,`illegal character: ${$o(e[d])}`),o(d,d+1)),d++}return s.push({kind:"eof",text:"",start:n[u],end:n[u]}),{tokens:s,errors:r};function h(T){let x=N=>N<u?e.charCodeAt(N):-1,v=N=>x(N)|32,R=N=>he(N)||(N|32)>=97&&(N|32)<=102,L=(N,F)=>{let q=N;for(;q<u&&(F(x(q))||x(q)===95);)q++;return q>N&&x(q-1)===95&&a(q-1,"illegal underscore"),q},C=(N,F="int-literal")=>(c(F,T,N,F==="int-literal"?{integer:{value:0n,radix:10}}:{}),N),M=(N,F,q)=>{let Z=e.slice(q,N).replace(/_/g,""),cn=BigInt((F===16?"0x":F===8?"0o":F===2?"0b":"")+(Z||"0"));return(x(N)|32)===108?(c("long-literal",T,N+1,{integer:{value:cn,radix:F}}),N+1):(c("int-literal",T,N,{integer:{value:cn,radix:F}}),N)},_=(N,F)=>{if(v(N)!==F)return N;let q=N+1;return(x(q)===43||x(q)===45)&&q++,he(x(q))?L(q,he):(a(T,"malformed floating-point literal"),q)},j=N=>{let F=v(N);return F===102?(c("float-literal",T,N+1),N+1):F===100?(c("double-literal",T,N+1),N+1):(c("double-literal",T,N),N)};if(x(T)===48&&v(T+1)===120){let N=T+2;if(x(N)===95)return a(N,"illegal underscore"),C(N+1);let F=L(N,R),q=F>N;if(x(F)===46||v(F)===112){if(x(F)===46){let Z=L(F+1,R);if(!q&&Z===F+1)return a(T,"hexadecimal numbers must contain at least one hexadecimal digit"),C(Z,"double-literal");F=Z}return v(F)!==112?(a(T,"malformed floating-point literal"),C(F,"double-literal")):j(_(F,112))}return q?M(F,16,N):(a(T,"hexadecimal numbers must contain at least one hexadecimal digit"),C(F))}if(x(T)===48&&v(T+1)===98){let N=T+2;if(x(N)===95)return a(N,"illegal underscore"),C(N+1);let F=L(N,he);return F===N?(a(T,"binary numbers must contain at least one binary digit"),C(F)):/[2-9]/.test(e.slice(N,F))?(a(T,"illegal digit in a binary literal"),C(F)):M(F,2,N)}let P=T;if(he(x(T))&&(P=L(T,he)),x(P)===46&&(P>T||he(x(P+1)))||v(P)===101||v(P)===102||v(P)===100)return x(P)===46&&(P=he(x(P+1))?L(P+1,he):P+1),j(_(P,101));if(x(T)===48&&P>T+1){for(let N=T+1;N<P;N++)if(x(N)===56||x(N)===57)return a(N,"illegal digit in an octal literal"),C(P);return M(P,8,T+1)}return M(P,10,T)}function m(T){let x=e[T+1];switch(x){case"b":return["\\b",T+2];case"s":return[" ",T+2];case"t":return[" ",T+2];case"n":return[`\n`,T+2];case"f":return["\\f",T+2];case"r":return["\\r",T+2];case\'"\':return[\'"\',T+2];case"\'":return["\'",T+2];case"\\\\":return["\\\\",T+2]}if(x!==void 0&&x>="0"&&x<="7"){let v=x<="3"?3:2,R=T+1,L="";for(;L.length<v&&R<u&&e[R]>="0"&&e[R]<="7";)L+=e[R++];return[String.fromCharCode(parseInt(L,8)),R]}return null}function p(T){let x=T+1,v=x<u?e.charCodeAt(x):-1;if(v===39)return a(T,"empty character literal"),o(T,x+1),x+1;if(v===-1||v===10||v===13)return a(T,"unclosed character literal"),o(T,x),x;let R;if(v===92){let L=m(x);if(!L){a(x+1,"illegal escape character");let C=O(x);return o(T,C),C}R=L[0],x=L[1]}else R=e[x],x++;return x>=u||e.charCodeAt(x)!==39?(a(T,"unclosed character literal"),o(T,x),x):(c("char-literal",T,x+1,{stringValue:R}),x+1)}function k(T){let x=T+1,v="";for(;x<u;){let R=e.charCodeAt(x);if(R===34)return c("string-literal",T,x+1,{stringValue:v}),x+1;if(R===10||R===13)break;if(R===92){let L=m(x);if(!L){a(x+1,"illegal escape character");let C=O(x);return o(T,C),C}v+=L[0],x=L[1];continue}v+=e[x],x++}return a(T,"unclosed string literal"),o(T,x),x}function g(T){let x=T+3;for(;x<u&&(e[x]===" "||e[x]===" "||e[x]==="\\f");)x++;if(x<u&&e[x]!==`\n`&&e[x]!=="\\r")return a(x,"illegal text block open delimiter sequence, missing line terminator"),o(T,x),x;if(x>=u)return a(T,"unclosed text block"),o(T,u),u;x+=e[x]==="\\r"&&e[x+1]===`\n`?2:1;let v=x;for(;x<u;){if(e.charCodeAt(x)===92){let L=e[x+1];if(L===`\n`||L==="\\r"){x+=L==="\\r"&&e[x+2]===`\n`?3:2;continue}let C=m(x);if(!C){a(x+1,"illegal escape character"),x+=2;continue}x=C[1];continue}if(e.startsWith(\'"""\',x))return c("text-block",T,x+3,{stringValue:Po(e.slice(v,x))}),x+3;x++}return a(T,"unclosed text block"),o(T,u),u}function O(T){for(;T<u&&e.charCodeAt(T)!==10&&e.charCodeAt(T)!==13;)T++;return T}}var ir=/[\\t\\x0b\\f\\x1c-\\x20\\u1680\\u2000-\\u2006\\u2008-\\u200a\\u2028\\u2029\\u205f\\u3000]/;function Po(i){let t=i.replace(/\\r\\n?/g,`\n`).split(`\n`),e=a=>[...a].every(o=>ir.test(o)),n=a=>{let o=0;for(;o<a.length&&ir.test(a[o]);)o++;return o},s=1/0;t.forEach((a,o)=>{(!e(a)||o===t.length-1)&&(s=Math.min(s,n(a)))});let r=t.map(a=>{if(e(a))return"";let o=a.length;for(;o>0&&ir.test(a[o-1]);)o--;return a.slice(s,o)});return Mo(r.join(`\n`))}function Mo(i){if(!i.includes("\\\\"))return i;let t="";for(let e=0;e<i.length;e++){let n=i[e];if(n!=="\\\\"){t+=n;continue}let s=i[++e];switch(s){case`\n`:continue;case"b":t+="\\b";continue;case"s":t+=" ";continue;case"t":t+=" ";continue;case"n":t+=`\n`;continue;case"f":t+="\\f";continue;case"r":t+="\\r";continue}if(s>="0"&&s<="7"){let r=s<="3"?3:2,a="";for(;a.length<r&&e<i.length&&i[e]>="0"&&i[e]<="7";)a+=i[e++];e--,t+=String.fromCharCode(parseInt(a,8));continue}t+=s}return t}var fn=Number.MAX_SAFE_INTEGER,or=9223372036854775807n,lr=-9223372036854775808n,xi=9223372036854776e3;function At(i){let t=BigInt.asIntN(64,i);return t>=-9007199254740991n&&t<=9007199254740991n?Number(t):t}var Pt=i=>typeof i=="bigint"?i:BigInt(i),pn=i=>i===0?0:i;function vi(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i+t;if(e<=fn&&e>=-fn)return e}return At(Pt(i)+Pt(t))}function wi(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i-t;if(e<=fn&&e>=-fn)return e}return At(Pt(i)-Pt(t))}function ki(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i*t;if(e<=fn&&e>=-fn)return pn(e)}return At(Pt(i)*Pt(t))}function Ci(i,t){return typeof i=="number"&&typeof t=="number"?pn(Math.trunc(i/t)):At(Pt(i)/Pt(t))}function Ei(i,t){return typeof i=="number"&&typeof t=="number"?pn(i%t):At(Pt(i)%Pt(t))}function cr(i){return typeof i=="number"?pn(-i):At(-i)}function Ai(i,t){return At(Pt(i)<<BigInt(t&63))}function Ii(i,t){return At(Pt(i)>>BigInt(t&63))}function Oi(i,t){return At(BigInt.asUintN(64,Pt(i))>>BigInt(t&63))}function Li(i,t){return At(Pt(i)&Pt(t))}function Ni(i,t){return At(Pt(i)|Pt(t))}function $i(i,t){return At(Pt(i)^Pt(t))}function bs(i){return typeof i=="number"?i|0:Number(BigInt.asIntN(32,i))}function Ss(i){return Number(i)}function yn(i){if(typeof i=="number")return Math.fround(i);let t=i<0n,e=t?-i:i,n=e.toString(2).length;if(n>26){let s=BigInt(n-26),r=(e&(1n<<s)-1n)!==0n?1n:0n;e=e>>s<<1n|r;let a=Math.fround(Number(e)*2**(n-27));return t?-a:a}return Math.fround(Number(i))}function Dn(i){if(Number.isNaN(i))return 0;if(i>=xi)return or;if(i<=-xi)return lr;let t=Math.trunc(i);return Number.isSafeInteger(t)?pn(t):BigInt(t)}function Fn(i){return Number.isNaN(i)?0:i>=2147483647?2147483647:i<=-2147483648?-2147483648:pn(Math.trunc(i))}function Pi(i){return Number.isNaN(i)?0:Fn(Math.abs(i)>=8388608?i:Math.floor(i+.5))}function Mi(i){return Dn(Math.round(i))}function Ro(i,t,e,n){if(n){if(t=t.replace(/0+$/,"")||"0",e>=0){let s=t.slice(0,e+1).padEnd(e+1,"0"),r=t.slice(e+1)||"0";return`${i}${s}.${r}`}return`${i}0.${"0".repeat(-e-1)}${t}`}return`${i}${t[0]}.${t.slice(1).replace(/0+$/,"")||"0"}E${e}`}var ys=new DataView(new ArrayBuffer(4));function Ri(i){return ys.setFloat32(0,i),ys.getInt32(0)}function Ts(i){return Number.isNaN(i)?2143289344:Ri(i)}function Ji(i){return ys.setInt32(0,i),ys.getFloat32(0)}var gs=i=>10n**BigInt(i);function Fe(i){if(Number.isNaN(i))return"NaN";if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(i===0)return Object.is(i,-0)?"-0.0":"0.0";let t=Ri(i),e=t>>>23&255,n=t&8388607,s=BigInt(e===0?n:n|8388608),r=e===0?-149:e-150,a=Math.max(0,2-r),o=(L,C)=>C>=0?L<<BigInt(C):L>>BigInt(-C),c=o(s,r+a),u=o(2n*s+1n,r-1+a),d=n===0&&e>1?o(4n*s-1n,r-2+a):o(2n*s-1n,r-1+a),h=(s&1n)===0n,m=1n<<BigInt(a),p=L=>L<0?{A:gs(-L),B:m}:{A:1n,B:gs(L)*m},k=L=>{let{A:C,B:M}=p(L),_=d*C,j=u*C,P=(_+M-1n)/M;!h&&P*M===_&&P++;let B=j/M;return!h&&B*M===j&&B--,{dLo:P,dHi:B,A:C,B:M}},g=L=>{let{dLo:C,dHi:M,A:_,B:j}=k(L);if(C>M)return null;let P=c*_,B=P/j,N=2n*P,F=(2n*B+1n)*j;return(N>F||N===F&&(B&1n)===1n)&&B++,B<C&&(B=C),B>M&&(B=M),B},O=Math.floor(Math.log10(Math.abs(i)))+2,T=g(O);for(;T===null;)T=g(--O);T<10n&&(O--,T=g(O));let x=T.toString(),v=O+x.length-1,R=Math.abs(i);return Ro(i<0?"-":"",x,v,R>=.001&&R<1e7)}function Jo(i,t,e){let n=o=>e?-o:o;if(i===0n)return n(0);let s=i.toString().length;if(s+t<-46)return n(0);if(s+t-1>39)return n(1/0);let r=t>=0?i*gs(t):i,a=t>=0?1n:gs(-t);return n(ar(r,a))}function ar(i,t){let e=s=>s.toString(2).length,n=e(i)-e(t)-24;for(;;){n<-149&&(n=-149);let s=n>=0?i:i<<BigInt(-n),r=n>=0?t<<BigInt(n):t,a=s/r;if(a>=1n<<24n){n++;continue}if(a<1n<<23n&&n>-149){n--;continue}let o=s-a*r;return(2n*o>r||2n*o===r&&(a&1n)===1n)&&a++,a===1n<<24n&&(a=1n<<23n,n++),n>104?1/0:Number(a)*2**n}}function ji(i,t){return i===0n?0:t>=0?ar(i<<BigInt(t),1n):ar(i,1n<<BigInt(-t))}function Di(i){let t=i.replace(/_/g,"").replace(/[fF]$/,""),e,n;if(/^0[xX]/.test(t)){let s=/^0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)$/.exec(t),r=s[1]??"",a=s[2]??"",o=BigInt("0x"+(r+a||"0"));n=o!==0n,e=ji(o,Number(s[3])-4*a.length)}else e=ur(t),n=/[1-9]/.test(t.replace(/[eE].*$/,""));return e===1/0?{error:"too-large"}:e===0&&n?{error:"too-small"}:{value:e}}function Fi(i,t){let e=/^([+-]?)0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)[fFdD]?$/.exec(i);if(!e||!(e[2]||e[3]))return NaN;let n=e[3]??"",s=BigInt("0x"+((e[2]??"")+n||"0")),r=Math.max(-1e5,Math.min(1e5,Number(e[4])))-4*n.length,a=t?ji(s,r):Ui(s,r);return e[1]==="-"?-a:a}function ur(i){let t=/^([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?$/.exec(i);if(!t)return NaN;let e=t[2]??"",n=t[3]??"",s=BigInt((e+n).replace(/^0+(?=\\d)/,"")||"0"),r=Math.max(-1e5,Math.min(1e5,Number(t[4]??"0")))-n.length;return Jo(s,r,t[1]==="-")}function de(i){if(Number.isNaN(i))return"NaN";if(i===1/0)return"Infinity";if(i===-1/0)return"-Infinity";if(i===0)return Object.is(i,-0)?"-0.0":"0.0";let t=i<0?"-":"",e=Math.abs(i),[n,s]=e.toExponential().split("e");n.includes(".")||([n,s]=e.toExponential(1).split("e"));let r=n.replace(".",""),a=Number(s);if(e>=.001&&e<1e7){if(r=r.replace(/0+$/,"")||"0",a>=0){let o=r.slice(0,a+1).padEnd(a+1,"0"),c=r.slice(a+1)||"0";return`${t}${o}.${c}`}return`${t}0.${"0".repeat(-a-1)}${r}`}return`${t}${r[0]}.${r.slice(1)||"0"}E${a}`}function _i(i){let t=i.replace(/_/g,"").replace(/[dD]$/,""),e,n;if(/^0[xX]/.test(t)){let s=/^0[xX]([0-9a-fA-F]*)(?:\\.([0-9a-fA-F]*))?[pP]([+-]?\\d+)$/.exec(t),r=s[1]??"",a=s[2]??"",o=BigInt("0x"+(r+a||"0"));n=o!==0n,e=Ui(o,Number(s[3])-4*a.length)}else e=Number(t),n=/[1-9]/.test(t.replace(/[eE].*$/,""));return e===1/0?{error:"too-large"}:e===0&&n?{error:"too-small"}:{value:e}}function Ui(i,t){if(i===0n)return 0;let e=i.toString(2).length,n=i,s=t;if(e>64){let r=BigInt(e-64),a=(n&(1n<<r)-1n)!==0n?1n:0n;n=n>>r|a,s+=e-64}return Number(n)*2**s}function hr(i){return i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="MethodCall"||i.kind==="NewObject"}var Vt=class extends Error{info;constructor(t){super(t.message),this.info=t}},xs=class extends Error{},Oe=new Set(["int","boolean","byte","short","long","char","float","double"]),Bi=new Set(["public","protected","private","static","final","abstract","native","synchronized","transient","volatile","strictfp","default"]),jo={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"<":7,">":7,"<=":7,">=":7,instanceof:7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Vi=new Set(["=","+=","-=","*=","/=","%=","&=","|=","^=","<<=",">>=",">>>="]),Do={synchronized:"\'synchronized\' statements"},Fo=new Set(["}","{","if","for","while","do","try","switch","return","throw","break","continue","else","final","class","int","long","double","boolean","char","byte","short","float","case","default","yield","assert","synchronized"]),Hi=new Set(["}","public","protected","private","static","final","abstract","class","interface","enum","void","int","long","double","boolean","char","byte","short","float","@","<"]),_o=new Set(["(","!","~","this","super","new","true","false","null","switch"]);function zi(i,t,e,n=[]){let s=new dr(i,t,e,n);try{let r=s.compilationUnit();return s.errors.length?{unit:null,errors:s.errors}:{unit:r,errors:[]}}catch(r){if(r instanceof xs)return{unit:null,errors:s.errors};if(!(r instanceof Vt))throw r;return s.errors.length?(r.info.code==="syntax"&&s.report(r.info),{unit:null,errors:s.errors}):{unit:null,errors:[r.info]}}}var dr=class{#d;#z;#It=[];#rt;#G=0;errors=[];#Ot=-1;#O=-1;#R;#bt=-1;#m=0;#C=!1;#W=0;#V=new Map;#ut=new Map;constructor(t,e,n,s){this.#d=t,this.#z=[...e],this.#rt=n,this.#R=s.some(r=>r.message==="unclosed comment");for(let r of s){let a=e[Math.min(r.token??e.length-1,e.length-1)];this.#V.set(a,[...this.#V.get(a)??[],r]),this.#ut.set(a,Math.max(this.#ut.get(a)??-1,r.offset))}this.#X()}#X(){let t=this.#ut.get(this.#r());t!==void 0&&(this.#bt=Math.max(this.#bt,t));for(let e of[this.#r(),this.#r(1)]){let n=this.#V.get(e);if(n){this.#V.delete(e);for(let s of n)this.errors.push({offset:s.offset,code:"syntax",message:s.message}),s.message.startsWith("illegal text block open delimiter")&&(this.#Ot=Math.max(this.#Ot,s.offset))}}}#r(t=0){return this.#z[Math.min(this.#G+t,this.#z.length-1)]}#p(){return this.#z[Math.max(this.#G-1,0)]}#s(){let t=this.#r();return this.#G<this.#z.length-1&&this.#G++,this.#ut.size&&this.#X(),t}#n(t,e=0){let n=this.#r(e);return(n.kind==="operator"||n.kind==="keyword")&&n.text===t}#S(t=0,e){let n=this.#r(t);return n.kind==="identifier"&&(e===void 0||n.text===e)}#l(t){return this.#n(t)?(this.#s(),!0):!1}#i(t,e=`\'${t}\' expected`){if(this.#n(t))return this.#s();if(this.#m)throw this.#r().kind==="eof"&&t==="}"&&this.#Q(),this.#u(this.#p().end,e);let n=this.#p().end;return this.#O=Math.max(this.#O,this.#r().start),this.report({offset:n,code:"syntax",message:e}),{kind:"operator",text:t,start:n,end:n}}report(t){let e=this.#r().kind==="eof",n=e&&this.#R,s=e&&t.code==="syntax"?{...t,offset:n?this.#r().start:this.#p().end,message:"reached end of file while parsing"}:t,r=this.#r().kind==="error"&&s.offset>=this.#p().end||e&&this.#p().kind==="error";if(s.offset>this.#Ot&&!r&&this.errors.push(s),this.#Ot=Math.max(this.#Ot,s.offset),e)throw new xs}#D(t,e,n){let s={offset:t,code:"syntax",message:e,...n?{details:n}:{}};if(this.#m)throw new Vt(s);this.report(s)}#kt(t){this.#m++;try{return t()}finally{this.#m--}}#E(t,e){if(!(t instanceof Vt)||t.info.code!=="syntax"||this.#m)throw t;this.#O=Math.max(this.#O,t.info.offset,this.#r().start),this.report(t.info),this.#Y(e)}#Y(t){for(;this.#r().start<=this.#bt&&this.#r().kind!=="eof"&&!this.#n("}");){if(this.#n(";")){this.#s();return}this.#s()}if(!(this.#r().start>this.#O))for(;;){let e=this.#r();if(e.kind==="eof")return;if(this.#n(";")){this.#s();return}if(t(e))return;this.#s()}}#A(){let t=this.#r();if(t.kind==="identifier")return this.#s();if(t.kind==="keyword"&&t.text==="_")throw this.#x(t.start,"the unnamed variable \'_\'",!0);t.kind==="eof"&&this.#Q();let e=t.kind==="keyword"?t.start:this.#p().end;if(this.#m)throw this.#u(e,"<identifier> expected");return this.#O=Math.max(this.#O,t.start),this.report({offset:e,code:"syntax",message:"<identifier> expected"}),{kind:"identifier",text:"<error>",start:e,end:e}}#Q(){throw this.#m||this.report({offset:this.#p().end,code:"syntax",message:"reached end of file while parsing"}),this.#u(this.#p().end,"reached end of file while parsing")}#u(t,e){return new Vt({offset:t,code:"syntax",message:e})}#x(t,e,n=!1){return new Vt({offset:t,code:"unsupported",message:`${e} ${n?"is":"are"} not supported in this version`})}#I(){return{i:this.#G,splits:this.#It.length}}#Ct(t){for(;this.#It.length>t.splits;){let e=this.#It.pop();this.#z.splice(e.index,2,e.token)}this.#G=t.i}#me(){let t=this.#r();if(t.kind==="operator"&&t.text===">"){this.#s();return}if(t.kind==="operator"&&(t.text===">>"||t.text===">>>"||t.text===">="||t.text===">>=")){let e={...t,text:">",end:t.start+1},n={...t,text:t.text.slice(1),start:t.start+1};this.#It.push({index:this.#G,token:t}),this.#z.splice(this.#G,1,e,n),this.#s();return}if(t.kind==="eof"&&this.#Q(),this.#m)throw this.#u(t.start,"\'>\' expected");this.#O=Math.max(this.#O,t.start),this.report({offset:this.#p().end,code:"syntax",message:"> expected"})}#o(){this.#i("<");let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#x(e.start,"annotations");let n=this.#A(),s=[];if(this.#l("extends"))do s.push(this.#N());while(this.#l("&"));t.push({name:n.text,pos:n.start,bounds:s})}while(this.#l(","));return this.#me(),t}#b(){if(this.#i("<"),this.#l(">"))return"diamond";let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#x(e.start,"annotations");if(this.#l("?")){let n=null,s=!1;this.#l("extends")?n=this.#N():this.#l("super")&&(s=!0,n=this.#N()),t.push({kind:"WildcardType",bound:n,isSuper:s,pos:e.start,start:e.start,end:this.#p().end})}else t.push(this.#N())}while(this.#l(","));return this.#me(),t}#it(){if(++this.#W>this.#rt.maxNestingDepth)throw new Vt({offset:this.#r().start,code:"limit",message:`code is nested too deeply for this engine (limit ${this.#rt.maxNestingDepth})`})}#St(){this.#W--}#$(t,...e){let n=0;for(let s of e)n=Math.max(n,s.depth);if(t.depth=n+1,t.depth>this.#rt.maxExpressionDepth)throw new Vt({offset:t.start,code:"limit",message:`expression is nested too deeply for this engine (limit ${this.#rt.maxExpressionDepth})`});return t}compilationUnit(){let t={file:this.#d,imports:[],types:[]},e=[];if(this.#n("package")){let n=this.#s().start,s=[this.#A().text],r=[];for(;this.#n(".");)r.push(this.#s().start),s.push(this.#A().text);this.#i(";"),t.package={names:s,start:n,dots:r}}for(;this.#n("import");)t.imports.push(this.#t());for(;this.#r().kind!=="eof";){if(this.#l(";"))continue;let n=this.#r().start;if(this.#n("import"))throw this.#f(t,e);let s=this.#y();if(this.#n("class")||this.#n("interface")){t.types.push(this.#Tt(s,n));continue}if(this.#n("enum")){t.types.push(this.#Lt(s,n));continue}if(this.#n("@")&&this.#n("interface",1))throw this.#x(this.#r().start,"annotation interface declarations");if(this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2))){t.types.push(this.#gt(s,n));continue}if(this.#c()){e.push(this.#j(s,n,null));continue}let r=this.#f(t,e);if(r.info.code!=="syntax"||this.#m)throw r;for(this.report(r.info),this.#s();this.#r().kind!=="eof"&&!this.#n("class")&&!this.#n("interface")&&!this.#n("enum")&&!(this.#s().text===";"&&this.#p().kind==="operator"););}if(e.length){let n=[...e,...t.types].sort((a,o)=>a.start-o.start),s=n[0],r=this.#d.replace(/^.*[\\\\/]/,"").replace(/\\.java$/,"");t.types=[{kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:r,namePos:s.start,keywordPos:s.start,members:n,implicit:!0,pos:s.start,start:s.start,end:n[n.length-1].end}]}return t}#t(){let t=this.#i("import"),e=this.#n("static");e&&this.#s();let n=[this.#A().text],s=t.start,r=[],a=!1,o=this.#p().start,c=o;for(;this.#n(".");){if(s=this.#s().start,r.push(s),this.#n("*")){o=this.#s().start,a=!0;break}let d=this.#A();n.push(d.text),o=d.start}let u=this.#i(";");return{names:n,onDemand:a,lastDotPos:s,dots:r,firstPos:c,...e?{isStatic:!0}:{},pos:o,start:t.start,end:u.end}}#f(t,e){let n=this.#z.some(s=>s.kind==="keyword"&&(s.text==="class"||s.text==="interface"||s.text==="enum"));return!t.types.length&&!e.length&&!n?new Vt({offset:0,code:"no-class",message:"no class declared in source file"}):this.#u(this.#r().start,"class, interface, annotation type, enum, record, method or field expected")}#c(){let t=this.#I();try{if(this.#n("<"))try{this.#kt(()=>this.#o())}catch{return!1}if(this.#n("void"))this.#s();else if(!this.#Et())return!1;return this.#S()?(this.#s(),this.#n("(")||this.#n("=")||this.#n(";")||this.#n(",")):!1}finally{this.#Ct(t)}}#y(){let t={keywords:[]};for(;;){let e=this.#r();if(e.kind==="operator"&&e.text==="@"){if(this.#n("interface",1))return t;(t.annotations??=[]).push(this.#P());continue}if(e.kind==="keyword"&&Bi.has(e.text)){t.keywords.some(n=>n.name===e.text)&&this.#D(e.start,"repeated modifier"),t.keywords.push({name:e.text,pos:e.start}),this.#s();continue}if(e.kind==="identifier"){let n=a=>this.#n("class",a)||this.#n("interface",a)||this.#S(a,"sealed")||this.#S(a,"non")||this.#n("abstract",a)||this.#r(a).kind==="keyword"&&Bi.has(this.#r(a).text),s=e.text==="sealed"&&n(1),r=e.text==="non"&&this.#n("-",1)&&this.#S(2,"sealed")&&this.#r(1).start===e.end&&this.#r(2).start===this.#r(1).end&&n(3);if(s||r){let a=s?"sealed":"non-sealed";t.keywords.some(o=>o.name===a)&&this.#D(e.start,"repeated modifier"),t.keywords.push({name:a,pos:e.start}),this.#s(),r&&(this.#s(),this.#s());continue}}return t}}#P(){let t=this.#i("@"),e=this.#A(),n=[e.text];for(;this.#n(".")&&this.#S(1);)this.#s(),n.push(this.#s().text);let s={name:n[n.length-1],names:n,pos:t.start,namePos:e.start};if(this.#l("(")){let r=[];for(;!this.#n(")");){let a=this.#r().start,o=null;if(this.#S()&&this.#n("=",1)&&(o=this.#s().text,this.#s()),r.push({name:o,value:this.#g(),pos:a}),!this.#l(","))break}this.#i(")"),s.args=r}return s}#g(){if(this.#n("@"))throw this.#x(this.#r().start,"nested annotations");if(!this.#n("{"))return this.#w();let t=this.#s(),e=[];for(;!this.#n("}")&&(e.push(this.#g()),!!this.#l(",")););return this.#i("}"),{kind:"ElementArray",elements:e,pos:t.start}}#J(t,e){let n=s=>Hi.has(s.text);for(;!this.#n("}")&&(this.#r().kind==="eof"&&this.#Q(),this.#Y(n),!this.#n("}"));){if(this.#r().kind==="eof"&&this.#Q(),this.#l(";"))continue;let s=this.#G;try{t.members.push(this.#ee(t.name,e))}catch(r){this.#E(r,n),this.#G===s&&!this.#n("}")&&this.#s()}}t.end=this.#i("}").end}#ht(){return this.#n("{")||this.#m?(this.#i("{"),!0):(this.#i("{"),this.#Y(t=>Hi.has(t.text)||t.text==="{"),this.#l("{"))}#H(t){if(this.#l("implements"))do t.implementsTypes.push(this.#N());while(this.#l(","))}#Lt(t,e){let n=this.#i("enum"),s=this.#A(),r={kind:"ClassDeclaration",keyword:"enum",extendsTypes:[],implementsTypes:[],enumConstants:[],modifiers:t,name:s.text,namePos:s.start,keywordPos:n.start,members:[],pos:s.start,start:e,end:e};if(this.#n("<"))throw this.#x(this.#r().start,"generic enums");if(this.#n("extends")||this.#H(r),!this.#ht())return r.end=this.#p().end,r;for(;this.#S()||this.#n("@");){if(this.#n("@"))throw this.#x(this.#r().start,"annotations");let a=this.#s(),o=this.#n("(")?this.#Xt():[],c;if(this.#n("{")){let u=this.#s();c={kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:"",namePos:a.start,keywordPos:a.start,members:[],anonymous:!0,pos:a.start,start:u.start,end:u.start},this.#J(c)}if(r.enumConstants.push({name:a.text,args:o,...c?{body:c}:{},pos:a.start,start:a.start,end:this.#p().end}),!this.#l(","))break}if(!this.#n("}")&&!this.#l(";")){if(this.#m)throw this.#u(this.#p().end,"\',\', \'}\', or \';\' expected");this.#i(";","\',\', \'}\', or \';\' expected"),this.#Y(a=>a.text==="}")}return this.#J(r),r}#gt(t,e){let n=this.#s(),s=this.#A(),r=this.#n("<")?this.#o():void 0,a={...r?{typeParams:r}:{},kind:"ClassDeclaration",keyword:"record",extendsTypes:[],implementsTypes:[],components:[],modifiers:t,name:s.text,namePos:s.start,keywordPos:n.start,members:[],pos:s.start,start:e,end:e};if(this.#i("("),!this.#n(")"))do{let o=this.#ne();if(o.varargs)throw this.#x(o.pos,"variable-arity record components");a.components.push(o)}while(this.#l(","));return this.#i(")"),this.#n("extends")||this.#H(a),this.#ht()?(this.#J(a,a.name),a):(a.end=this.#p().end,a)}#Tt(t,e){let n=this.#n("interface"),s=this.#s(),r=this.#A(),a={kind:"ClassDeclaration",keyword:n?"interface":"class",extendsTypes:[],implementsTypes:[],modifiers:t,name:r.text,namePos:r.start,keywordPos:s.start,members:[],pos:r.start,start:e,end:e};if(this.#n("<")&&(a.typeParams=this.#o()),this.#l("extends"))do a.extendsTypes.push(this.#N());while(n&&this.#l(","));if(this.#n("implements")){if(n)throw this.#u(this.#r().start,"\'{\' expected");this.#s();do a.implementsTypes.push(this.#N());while(this.#l(","))}if(this.#S(0,"permits")){this.#s(),a.permits=[];do a.permits.push(this.#N());while(this.#l(","))}return this.#ht()?(this.#J(a),a):(a.end=this.#p().end,a)}#ee(t,e){let n=this.#r().start;if(this.#n("{")||this.#n("static")&&this.#n("{",1)){let r={keywords:[]};this.#n("static")&&r.keywords.push({name:"static",pos:this.#s().start});let a=this.#B();return{kind:"Initializer",modifiers:r,isStatic:r.keywords.length>0,body:a,pos:n,start:n,end:a.end}}let s=this.#y();if(this.#n("class")||this.#n("interface"))return this.#Tt(s,n);if(this.#n("enum"))return this.#Lt(s,n);if(this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2)))return this.#gt(s,n);if(e!==void 0&&this.#S(0,e)&&this.#n("{",1)){let r=this.#s(),a=this.#B();return{kind:"MethodDeclaration",modifiers:s,returnType:{kind:"VoidType",pos:r.start,start:r.start,end:r.start},name:r.text,namePos:r.start,params:[],body:a,closeBracePos:a.end-1,isConstructor:!0,compact:!0,pos:r.start,start:n,end:a.end}}return this.#j(s,n,t)}#j(t,e,n){if(this.#n("<")){let a=this.#o(),o=this.#j(t,e,n);if(o.kind!=="MethodDeclaration")throw this.#u(o.pos,"<identifier> expected");return o.typeParams=a,o}if(n!==null&&this.#S()&&this.#n("(",1)){let a=this.#r();if(a.text!==n){if(this.#m)throw this.#u(a.start,"invalid method declaration; return type required");this.report({offset:a.start,code:"syntax",message:"invalid method declaration; return type required"})}this.#s();let o={kind:"VoidType",pos:a.start,start:a.start,end:a.start},c=this.#L(t,o,a,e);return c.isConstructor=!0,c}let s;if(this.#n("(")&&!this.#m)throw this.#u(this.#r().start,"illegal start of type");if(this.#n("void")){let a=this.#s();s={kind:"VoidType",pos:a.start,start:a.start,end:a.end}}else s=this.#N();if(this.#r().kind==="keyword"&&!this.#m&&this.#r().text!=="_"){let a=this.#r();throw this.#O=Math.max(this.#O,this.#p().end),this.report({offset:this.#p().end,code:"syntax",message:"<identifier> expected"}),s.kind==="VoidType"?this.#u(a.start,"\'(\' expected"):this.#u(this.#p().end,"<identifier> expected")}if(this.#n("(")&&!this.#m){let a=this.#p().end;return this.#O=Math.max(this.#O,this.#r().start),this.report({offset:a,code:"syntax",message:"<identifier> expected"}),this.#L(t,s,{kind:"identifier",text:"<error>",start:a,end:a},e)}let r=this.#A();if(!this.#n("(")){if(s.kind!=="VoidType"&&(this.#n("=")||this.#n(";")||this.#n(",")||this.#n("[")))return this.#st(t,s,r,e);throw this.#u(this.#p().end,"\'(\' expected")}return this.#L(t,s,r,e)}#st(t,e,n,s){let r=[],a=n;for(;;){let c=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),c++;let u=null;if(this.#l("=")&&(u=this.#n("{")?this.#ie():this.#w()),r.push({name:a.text,extraDims:c,init:u,pos:a.start,start:a.start,end:this.#p().end}),!this.#l(","))break;a=this.#A()}let o=this.#i(";");return{kind:"FieldDeclaration",modifiers:t,type:e,declarators:r,pos:n.start,start:s,end:o.end}}#L(t,e,n,s){let r={kind:"MethodDeclaration",modifiers:t,returnType:e,name:n.text,namePos:n.start,params:[],body:null,pos:n.start,start:s,end:s};if(this.#i("("),this.#n(")"))this.#i(")");else{do{let a=r.params[r.params.length-1];a?.varargs&&this.#D(a.pos,"varargs parameter must be the last parameter"),r.params.push(this.#ne())}while(this.#l(","));this.#i(")","\',\', \')\', or \'[\' expected")}if(this.#n("["))throw this.#x(this.#r().start,"array dimensions after a parameter list");if(this.#l("throws")){r.throwsTypes=[];do r.throwsTypes.push(this.#N());while(this.#l(","))}if(this.#l(";"))return r.end=this.#p().end,r;if(this.#n("{"))r.body=this.#B();else{if(this.#m)throw this.#u(this.#p().end,"\'{\' or \';\' expected");let a=this.#p().end;this.#O=Math.max(this.#O,this.#r().start),this.report({offset:a,code:"syntax",message:"\'{\' or \';\' expected"}),r.body=this.#B({kind:"operator",text:"{",start:a,end:a})}return r.end=r.body.end,r.closeBracePos=r.body.end-1,r}#ne(){let t=this.#r().start,e=this.#y(),n=this.#N(),s=!1;this.#l("...")&&(s=!0);let r=this.#A();for(;this.#n("[")&&this.#n("]",1);){let a=this.#s(),o=this.#s();n={kind:"ArrayType",element:n,pos:a.start,start:n.start,end:o.end}}if(s){let a=this.#p().end;n={kind:"ArrayType",element:n,pos:n.pos,start:n.start,end:a}}return{modifiers:e,type:n,name:r.text,varargs:s,pos:r.start,start:t,end:r.end}}#N(){let t=this.#r(),e;if(t.kind==="keyword"&&Oe.has(t.text))this.#s(),e={kind:"PrimitiveType",name:t.text,pos:t.start,start:t.start,end:t.end};else if(t.kind==="identifier"){let n=[this.#s().text],s=!1,r,a,o;for(;;){if(this.#n("<")){let c=this.#r().start;r??=c;let u=this.#b();if(u==="diamond")throw this.#u(this.#p().start,"illegal start of type");a=u,s=!0}if(this.#n(".")&&this.#S(1)){o=this.#s().start,n.push(this.#s().text);continue}break}e={kind:"ClassType",names:n,hasTypeArguments:s,typeArgumentsPos:r,typeArguments:a,lastDotPos:o,pos:t.start,start:t.start,end:this.#p().end}}else if(t.kind==="eof")this.#Q();else throw this.#u(t.start,t.kind==="keyword"?"<identifier> expected":"illegal start of type");for(;this.#n("[")&&this.#n("]",1);){let n=this.#s(),s=this.#s();e={kind:"ArrayType",element:e,pos:n.start,start:e.start,end:s.end}}return e}#Et(){let t=this.#I();try{return this.#kt(()=>this.#N()),!0}catch(e){if(!(e instanceof Vt))throw e;return this.#Ct(t),!1}}#B(t=this.#i("{")){this.#it();let e=this.#dt(()=>this.#n("}")),n=this.#i("}");return this.#St(),{kind:"Block",statements:e,pos:t.start,start:t.start,end:n.end}}#dt(t){let e=[],n=s=>Fo.has(s.text)||s.kind==="identifier";for(;!t()&&(this.#r().kind==="eof"&&this.#Q(),this.#Y(n),!t());){this.#r().kind==="eof"&&this.#Q();let s=this.#G;try{e.push(this.#K())}catch(r){this.#E(r,n)}this.#G===s&&!t()&&this.#s()}return e}#K(){if(this.#At())return this.#F();if(this.#n("static")&&(this.#n("class",1)||this.#n("interface",1)))throw this.#u(this.#r().start,"illegal start of expression");let t=this.#n("class")||this.#n("interface")||this.#n("enum")||(this.#n("abstract")||this.#n("final"))&&this.#n("class",1),e=this.#S(0,"record")&&this.#S(1)&&(this.#n("(",2)||this.#n("<",2));if(t||e){let s=this.#r().start,r=this.#y(),a=this.#n("enum")?this.#Lt(r,s):e?this.#gt(r,s):this.#Tt(r,s);return{kind:"LocalClass",declaration:a,pos:a.keywordPos,start:s,end:a.end}}let n=this.#r();return n.kind==="keyword"&&Oe.has(n.text)&&!this.#S(1)&&!this.#n("[",1)&&!this.#n(".",1)&&!this.#m?(this.report({offset:n.start,code:"syntax",message:"not a statement"}),this.#s(),this.#i(";"),{kind:"EmptyStatement",pos:n.start,start:n.start,end:n.end}):this.#M()?this.#Z():this.#F()}#M(){if(this.#n("final")||this.#n("@")&&!this.#n("interface",1))return!0;let t=this.#r();if(t.kind==="keyword"&&Oe.has(t.text))return!this.#n(".",1);if(t.kind!=="identifier")return!1;let e=this.#I();try{if(!this.#Et())return!1;let n=this.#r();return n.kind==="identifier"||n.kind==="keyword"&&n.text==="_"}finally{this.#Ct(e)}}#Z(){let t=this.#r().start,e=this.#y();for(let a of e.keywords)if(a.name!=="final")throw this.#u(a.pos,"illegal start of expression");let n=this.#N();n.kind==="ClassType"&&n.names.length===1&&n.names[0]==="var"&&!n.hasTypeArguments&&(n={kind:"VarType",pos:n.pos,start:n.start,end:n.end});let s=[];do{let a=this.#A(),o=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),o++;let c=null;this.#l("=")&&(c=this.#n("{")?this.#ie():this.#w()),s.push({name:a.text,extraDims:o,init:c,pos:a.start,start:a.start,end:this.#p().end})}while(this.#l(","));let r=this.#i(";");return{kind:"LocalVariableDeclaration",modifiers:e,type:n,declarators:s,pos:t,start:t,end:r.end}}#F(){this.#it();try{let t=this.#r();if(t.kind==="operator"&&t.text==="{")return this.#B();if(t.kind==="operator"&&t.text===";")return this.#s(),{kind:"EmptyStatement",pos:t.start,start:t.start,end:t.end};if(t.kind==="keyword"){if((t.text==="this"||t.text==="super")&&this.#n("(",1))return this.#e();if(t.text==="if")return this.#at();if(t.text==="while")return this.#Kt();if(t.text==="do")return this.#Re();if(t.text==="switch")return this.#se();if(t.text==="for")return this.#et();if(t.text==="return")return this.#fe();if(t.text==="break"||t.text==="continue")return this.#re();if(t.text==="throw")return this.#pe();if(t.text==="try")return this.#ye();if(t.text==="assert")return this.#vt();let e=Do[t.text];if(e)throw this.#x(t.start,e);if(t.text==="else")throw this.#u(t.start,"\'else\' without \'if\'")}if(t.kind==="identifier"){if(this.#n(":",1))return this.#a();if(this.#At())return this.#Jt()}if(this.#M()){let e=this.#Z();return this.#D(e.declarators[0].pos,"variable declaration not allowed here"),e}return this.#ge()}finally{this.#St()}}#e(){let t=this.#s(),e=this.#r().start,n=this.#Xt(),s=this.#i(";");return{kind:"ConstructorCall",keyword:t.text,thisPos:t.start,args:n,pos:e,start:t.start,end:s.end}}#at(){let t=this.#i("if");this.#i("(");let e=this.#w();this.#i(")");let n=this.#F(),s=null;this.#l("else")&&(s=this.#F());let r=(s??n).end;return{kind:"IfStatement",condition:e,then:n,otherwise:s,pos:t.start,start:t.start,end:r}}#At(){if(!this.#S(0,"yield"))return!1;let t=this.#r(1);return t.kind==="eof"?!1:t.kind!=="operator"?!0:Vi.has(t.text)?!1:![".","(","[","++","--",";",":",")",","].includes(t.text)}#Jt(){let t=this.#s(),e=this.#w(),n=this.#i(";");return{kind:"YieldStatement",value:e,pos:t.start,start:t.start,end:n.end}}#a(){let t=this.#s();this.#i(":");let e=this.#F();return{kind:"LabeledStatement",label:t.text,body:e,pos:t.start,start:t.start,end:e.end}}#Re(){let t=this.#i("do"),e=this.#F();this.#i("while"),this.#i("(");let n=this.#w();this.#i(")");let s=this.#i(";");return{kind:"DoStatement",body:e,condition:n,pos:t.start,start:t.start,end:s.end}}#se(){let t=this.#i("switch"),e=this.#r().start,n=this.#xt(),{cases:s,end:r}=this.#Ut(!1);return{kind:"SwitchStatement",selector:n,selectorPos:e,cases:s,pos:t.start,start:t.start,end:r}}#xt(){this.#i("(");let t=this.#w();return this.#i(")"),t}#Ut(t){this.#i("{"),this.#it();let e=[];for(;!this.#n("}");){this.#r().kind==="eof"&&this.#Q();let s=this.#r(),r=[],a=!1,o={};if(this.#l("default"))a=!0;else if(this.#l("case")){let u,d,h=!1;do{if(this.#n("null")&&(this.#n(",",1)||this.#n("->",1)||this.#n(":",1))){this.#s(),h=!0;continue}if(h&&this.#n("default")){this.#s(),a=!0;continue}if(this.#ot()){if(u||r.length)throw this.#x(this.#r().start,"several patterns in one case label");if(u=this.#Bt(!0),this.#S(0,"when")){this.#s(),this.#C=!0;try{d=this.#w()}finally{this.#C=!1}}continue}if(this.#S()&&(this.#n("->",1)||this.#n(",",1)||this.#n(":",1))){let m=this.#s();r.push({kind:"Name",identifier:m.text,depth:1,pos:m.start,start:m.start,end:m.end})}else r.push(this.#be())}while(this.#l(","));if(u&&(r.length||h))throw this.#x(u.pos,"a pattern combined with other case labels");o={...u?{pattern:u}:{},...d?{guard:d}:{},...h?{nullLabel:h}:{}}}else throw this.#u(s.start,"\'case\', \'default\', or \'}\' expected");let c={labels:r,isDefault:a,arrow:!1,statements:[],body:null,...o,pos:s.start,start:s.start,end:s.end};if(this.#l("->"))if(c.arrow=!0,this.#n("{"))c.body=this.#B();else if(this.#n("throw")){let u=this.#pe();c.body={kind:"Block",statements:[u],pos:u.pos,start:u.start,end:u.end}}else{let u=this.#w();!t&&!hr(u)&&this.#qt(u),this.#i(";"),c.body=u}else this.#i(":",": or -> expected"),c.statements.push(...this.#dt(()=>this.#n("case")||this.#n("default")||this.#n("}")));c.end=this.#p().end,e.push(c)}let n=this.#i("}");return this.#St(),{cases:e,end:n.end}}#ot(){let t=this.#I();try{this.#l("final");let e=this.#r();return!(e.kind==="identifier"||e.kind==="keyword"&&Oe.has(e.text))||!this.#Et()?!1:this.#S()||this.#n("(")||this.#n("_")}finally{this.#Ct(t)}}#Bt(t){let e=this.#r().start;if(!t&&this.#n("_")){let a=this.#s();return{kind:"TypePattern",type:null,name:"_",namePos:a.start,isFinal:!1,pos:a.start,start:a.start,end:a.end}}let n=this.#l("final"),s;if(!t&&this.#S(0,"var")&&(this.#S(1)||this.#n("_",1))?(this.#s(),s=null):s=this.#N(),s&&this.#n("(")){if(n)throw this.#u(e,"illegal start of expression");this.#s();let a=[];if(!this.#n(")"))do a.push(this.#Bt(!1));while(this.#l(","));let o=this.#i(")");return{kind:"RecordPattern",type:s,components:a,pos:e,start:e,end:o.end}}let r=this.#r();if(this.#n("_"))return this.#s(),{kind:"TypePattern",type:s,name:"_",namePos:r.start,isFinal:n,pos:e,start:e,end:r.end};if(!this.#S())throw this.#u(this.#p().end,"<identifier> expected");return this.#s(),{kind:"TypePattern",type:s,name:r.text,namePos:r.start,isFinal:n,pos:e,start:e,end:r.end}}#Kt(){let t=this.#i("while");this.#i("(");let e=this.#w();this.#i(")");let n=this.#F();return{kind:"WhileStatement",condition:e,body:n,pos:t.start,start:t.start,end:n.end}}#et(){let t=this.#i("for");if(this.#i("("),this.#Nt())return this.#tt(t);let e=null;this.#M()?e=this.#Z():(this.#n(";")||(e=this.#h()),this.#i(";"));let n=this.#n(";")?null:this.#w();this.#i(";");let s=this.#n(")")?[]:this.#h();this.#i(")");let r=this.#F();return{kind:"ForStatement",init:e,condition:n,update:s,body:r,pos:t.start,start:t.start,end:r.end}}#tt(t){let e=this.#y();for(let o of e.keywords)if(o.name!=="final")throw this.#u(o.pos,"illegal start of expression");let n=this.#N();n.kind==="ClassType"&&n.names.length===1&&n.names[0]==="var"&&!n.hasTypeArguments&&(n={kind:"VarType",pos:n.pos,start:n.start,end:n.end});let s=this.#A();this.#i(":");let r=this.#w();this.#i(")");let a=this.#F();return{kind:"ForEachStatement",modifiers:e,type:n,name:s.text,namePos:s.start,iterable:r,body:a,pos:t.start,start:t.start,end:a.end}}#Nt(){let t=this.#I();try{return this.#kt(()=>this.#y()),!this.#Et()||!this.#S()?!1:(this.#s(),this.#n(":"))}catch(e){if(e instanceof Vt)return!1;throw e}finally{this.#Ct(t)}}#h(){let t=[];do{let e=this.#w();hr(e)||this.#qt(e),t.push(e)}while(this.#l(","));return t}#fe(){let t=this.#i("return"),e=this.#n(";")?null:this.#w(),n=this.#i(";");return{kind:"ReturnStatement",value:e,pos:t.start,start:t.start,end:n.end}}#pe(){let t=this.#i("throw"),e=this.#w(),n=this.#i(";");return{kind:"ThrowStatement",expression:e,pos:t.start,start:t.start,end:n.end}}#vt(){let t=this.#i("assert"),e=this.#w(),n=this.#l(":")?this.#w():null,s=this.#i(";");return{kind:"AssertStatement",condition:e,message:n,pos:t.start,start:t.start,end:s.end}}#ye(){let t=this.#i("try"),e=[];if(this.#l("(")){for(;!this.#n(")");){let o=this.#r().start;if(this.#S()&&(this.#n(";",1)||this.#n(")",1))){let c=this.#s();e.push({kind:"variable",expression:{kind:"Name",identifier:c.text,depth:1,pos:c.start,start:c.start,end:c.end},pos:c.start,start:o,end:c.end})}else{this.#y();let c=this.#N();c.kind==="ClassType"&&c.names.length===1&&c.names[0]==="var"&&!c.hasTypeArguments&&(c={kind:"VarType",pos:c.pos,start:c.start,end:c.end});let u=this.#A();this.#i("=");let d=this.#w();e.push({kind:"declaration",type:c,name:u.text,namePos:u.start,init:d,pos:u.start,start:o,end:d.end})}if(!this.#l(";"))break}this.#i(")")}let n=this.#B(),s=[];for(;this.#n("catch");){let o=this.#s();this.#i("(");let c=this.#y(),u=[this.#N()];for(;this.#l("|");)u.push(this.#N());let d=this.#A();this.#i(")");let h=this.#B();s.push({types:u,name:d.text,namePos:d.start,isFinal:c.keywords.some(m=>m.name==="final"),block:h,pos:o.start,start:o.start,end:h.end})}let r=this.#l("finally")?this.#B():null;!s.length&&!r&&!e.length&&this.#D(t.start,"\'try\' without \'catch\', \'finally\' or resource declarations");let a=(r??s[s.length-1]?.block??n).end;return{kind:"TryStatement",resources:e,block:n,catches:s,finallyBlock:r,pos:t.start,start:t.start,end:a}}#re(){let t=this.#s(),e=this.#S()?this.#s().text:void 0,n=this.#i(";");return{kind:t.text==="break"?"BreakStatement":"ContinueStatement",label:e,pos:t.start,start:t.start,end:n.end}}#ie(){let t=this.#i("{");this.#it();let e=[];for(;!this.#n("}")&&(e.push(this.#n("{")?this.#ie():this.#w()),!!this.#l(",")););let n=this.#i("}");return this.#St(),{kind:"ArrayInitializer",elements:e,pos:t.start,start:t.start,end:n.end}}#ge(){let t=this.#w();hr(t)||this.#qt(t);let e=this.#i(";");return{kind:"ExpressionStatement",expression:t,pos:t.pos,start:t.start,end:e.end}}#qt(t){if(this.#m)throw this.#u(t.pos,"not a statement");this.report({offset:t.pos,code:"syntax",message:"not a statement"})}#w(){this.#it();try{let t=this.#be(),e=this.#r();if(e.kind==="operator"&&Vi.has(e.text)){this.#s();let n=this.#w();return this.#$({kind:"Assignment",operator:e.text,target:t,value:n,depth:0,pos:e.start,start:t.start,end:n.end},t,n)}return t}finally{this.#St()}}#be(){let t=this.#Vt(1);if(!this.#n("?"))return t;let e=this.#s(),n=this.#w();this.#i(":");let s=this.#be();return this.#$({kind:"Conditional",condition:t,whenTrue:n,whenFalse:s,depth:0,pos:e.start,start:t.start,end:s.end},t,n,s)}#Vt(t){let e=this.#jt();for(;;){let n=this.#r();if(n.kind!=="operator"&&!(n.kind==="keyword"&&n.text==="instanceof"))break;let s=jo[n.text];if(s===void 0||s<t)break;if(n.text==="instanceof"){e=this.#mt(e);continue}this.#s();let r=this.#Vt(s+1);e=this.#$({kind:"Binary",operator:n.text,left:e,right:r,depth:0,pos:n.start,start:e.start,end:r.end},e,r)}return e}#mt(t){let e=this.#s(),n=!1;this.#n("final")&&(this.#s(),n=!0);let s=this.#N(),r,a;if(this.#n("(")){this.#s();let c=[];if(!this.#n(")"))do c.push(this.#Bt(!1));while(this.#l(","));let u=this.#i(")");a={kind:"RecordPattern",type:s,components:c,pos:s.pos,start:s.start,end:u.end}}else if(this.#S()){let c=this.#s();r={name:c.text,pos:c.start,isFinal:n}}else if(n)throw this.#u(this.#p().end,"<identifier> expected");let o={kind:"InstanceOf",expression:t,targetType:s,...r?{binding:r}:{},...a?{recordPattern:a}:{},depth:0,pos:e.start,start:t.start,end:this.#p().end};return this.#$(o,t)}#jt(){this.#it();try{let t=this.#r();if(t.kind==="operator")switch(t.text){case"-":case"+":{this.#s();let e=this.#r(),n=t.text==="-"&&e.kind==="int-literal"&&e.integer?.radix===10&&e.integer.value===2147483648n?this.#ve(!0):t.text==="-"&&e.kind==="long-literal"&&e.integer?.radix===10&&e.integer.value===9223372036854775808n?this.#Qe(!0):this.#jt();return this.#$({kind:"Unary",operator:t.text,operand:n,depth:0,pos:t.start,start:t.start,end:n.end},n)}case"!":case"~":{this.#s();let e=this.#jt();return this.#$({kind:"Unary",operator:t.text,operand:e,depth:0,pos:t.start,start:t.start,end:e.end},e)}case"++":case"--":{this.#s();let e=this.#jt();return this.#$({kind:"IncDec",operator:t.text,prefix:!0,operand:e,depth:0,pos:t.start,start:t.start,end:e.end},e)}case"(":if(this.#Se()){this.#s();let e=this.#N();this.#i(")");let n=this.#jt();return this.#$({kind:"Cast",targetType:e,expression:n,depth:0,pos:t.start,start:t.start,end:n.end},n)}break}return this.#Te(this.#Ze())}finally{this.#St()}}#Se(){if(this.#en())return!1;let t=this.#r(1);if(t.kind==="keyword"&&Oe.has(t.text))return this.#n(")",2)||this.#n("[",2)&&this.#n("]",3);if(t.kind!=="identifier")return!1;let e=this.#I();try{if(this.#s(),!this.#Et()||!this.#l(")"))return!1;let n=this.#r();return n.kind==="identifier"||n.kind.endsWith("-literal")||n.kind==="text-block"?!0:(n.kind==="operator"||n.kind==="keyword")&&_o.has(n.text)}finally{this.#Ct(e)}}#Te(t){let e=t;for(;;){let n=this.#r();if(n.kind!=="operator")return e;if(n.text==="."){this.#s();let s;if(this.#n("<")){let o=this.#b();if(o==="diamond")throw this.#u(this.#r().start,"illegal start of type");if(s=o,!this.#S()||!this.#n("(",1))throw this.#u(this.#r().start,"<identifier> expected")}let r=this.#r();if(r.kind==="keyword"&&r.text==="class"){this.#s(),e=this.#$({kind:"ClassLiteral",target:e,depth:0,pos:n.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="this"&&(e.kind==="Name"||e.kind==="FieldAccess")){this.#s();let o=[];for(let c=e;;c=c.target){if(c.kind==="Name"){o.unshift(c.identifier);break}if(c.kind!=="FieldAccess")throw this.#u(r.start,"<identifier> expected");o.unshift(c.name)}e=this.#$({kind:"This",qualifier:o,depth:0,pos:e.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="super"&&(e.kind==="Name"||e.kind==="FieldAccess")&&(this.#n(".",1)||this.#n("::",1))){let o=[];for(let c=e;;){if(c.kind==="Name"){o.unshift(c.identifier);break}if(c.kind!=="FieldAccess")throw this.#u(r.start,"<identifier> expected");o.unshift(c.name),c=c.target}this.#s(),e=this.#$({kind:"Super",qualifier:o,qualifierPos:e.start,dotPos:n.start,depth:0,pos:r.start,start:e.start,end:r.end},e);continue}if(r.kind==="keyword"&&r.text==="new"){let o=this.#we();if(o.kind!=="NewObject"||o.classType.kind!=="ClassType"||o.classType.names.length!==1)throw this.#u(r.start,"\'(\' expected");if(o.body)throw this.#x(r.start,"\'.new\' with an anonymous class body",!0);o.outerExpression=e,o.start=e.start,e=this.#$(o,e);continue}if(r.kind==="keyword"&&["this","super"].includes(r.text))throw this.#x(r.start,`\'.${r.text}\' expressions`);let a=this.#A();if(this.#n("(")){let o=this.#r().start,c=this.#Xt();e=this.#$({kind:"MethodCall",target:e,name:a.text,namePos:a.start,selectPos:n.start,args:c,...s?{typeArguments:s}:{},depth:0,pos:o,start:e.start,end:this.#p().end},e,...c)}else e=this.#$({kind:"FieldAccess",target:e,name:a.text,namePos:a.start,depth:0,pos:n.start,start:e.start,end:a.end},e);continue}if(n.text==="["&&this.#n("]",1)&&this.#xe()){let s=this.#Ye(e);for(;this.#n("[");){this.#s();let r=this.#i("]");s={kind:"ArrayType",element:s,pos:s.pos,start:s.start,end:r.end}}return this.#Wt(null,s,e.start)}if(n.text==="["){this.#s();let s=this.#w(),r=this.#i("]");e=this.#$({kind:"ArrayAccess",array:e,index:s,depth:0,pos:n.start,start:e.start,end:r.end},e,s);continue}if(n.text==="::")return this.#Wt(e,void 0,e.start);if(n.text==="<"&&(e.kind==="Name"||e.kind==="FieldAccess")&&this.#ae())throw this.#x(n.start,"method references on a parameterized type (write a lambda)");if(n.text==="++"||n.text==="--"){this.#s(),e=this.#$({kind:"IncDec",operator:n.text,prefix:!1,operand:e,depth:0,pos:n.start,start:e.start,end:n.end},e);continue}return e}}#ae(){let t=this.#I();try{return this.#kt(()=>this.#b())!=="diamond"&&this.#n("::")}catch(e){if(!(e instanceof Vt))throw e;return!1}finally{this.#Ct(t)}}#xe(){let t=0;for(;this.#n("[",t)&&this.#n("]",t+1);)t+=2;return t>0&&this.#n("::",t)}#Ye(t){let e=[],n=t;for(;n.kind==="FieldAccess";)e.unshift(n.name),n=n.target;if(n.kind!=="Name")throw this.#u(t.pos,"<identifier> expected");return e.unshift(n.identifier),{kind:"ClassType",names:e,hasTypeArguments:!1,pos:t.pos,start:t.start,end:t.end}}#Wt(t,e,n){let s=this.#i("::"),r=this.#r();if(r.kind==="operator"&&r.text==="<")throw this.#x(r.start,"explicit type arguments in method references");if(!(r.kind==="identifier"||r.kind==="keyword"&&r.text==="new"))throw this.#u(r.start,"<identifier> expected");if(this.#s(),e&&r.text!=="new")throw this.#u(r.start,"<identifier> expected");return{kind:"MethodRef",target:t,...e?{arrayType:e}:{},name:r.text,namePos:r.start,depth:(t?.depth??0)+1,pos:s.start,start:n,end:r.end}}#oe(t){let e=this.#C;this.#C=!1;try{return t()}finally{this.#C=e}}#Xt(){this.#i("(");let t=[];if(!this.#n(")")){do t.push(this.#oe(()=>this.#w()));while(this.#l(","));return this.#i(")","\')\' or \',\' expected"),t}return this.#i(")"),t}#ve(t){let e=this.#s(),{value:n,radix:s}=e.integer,r;if(s===10){if(n>2147483648n||n===2147483648n&&!t)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});r=Number(BigInt.asIntN(32,n))}else{if(n>0xffffffffn)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});r=Number(BigInt.asIntN(32,n))}return{kind:"Literal",literalKind:"int",value:r,depth:1,pos:e.start,start:e.start,end:e.end}}#Qe(t){let e=this.#s(),{value:n,radix:s}=e.integer;if(s===10?n>9223372036854775808n||n===9223372036854775808n&&!t:n>0xffffffffffffffffn)throw new Vt({offset:e.start,code:"int-number-too-large",message:"integer number too large"});return{kind:"Literal",literalKind:"long",value:BigInt.asIntN(64,n),depth:1,pos:e.start,start:e.start,end:e.end}}#Ze(){let t=this.#r(),e=(r,a)=>(this.#s(),{kind:"Literal",literalKind:r,value:a,depth:1,pos:t.start,start:t.start,end:t.end});switch(t.kind){case"int-literal":return this.#ve(!1);case"long-literal":return this.#Qe(!1);case"float-literal":case"double-literal":{let r=t.kind==="float-literal",a=r?Di(t.text):_i(t.text);if("error"in a)throw new Vt({offset:t.start,code:"fp-number-out-of-range",message:a.error==="too-large"?"floating-point number too large":"floating-point number too small"});return this.#s(),{kind:"Literal",literalKind:r?"float":"double",value:a.value,depth:1,pos:t.start,start:t.start,end:t.end}}case"char-literal":return e("char",t.stringValue??"");case"string-literal":return e("string",t.stringValue??"");case"text-block":return e("string",t.stringValue??"");case"identifier":{if(this.#n("->",1)&&!this.#C)return this.#s(),this.#le(t.start,[{name:t.text,pos:t.start,type:null}]);if(this.#s(),this.#n("(")){let r=this.#r().start,a=this.#Xt();return this.#$({kind:"MethodCall",target:null,name:t.text,namePos:t.start,selectPos:t.start,args:a,depth:0,pos:r,start:t.start,end:this.#p().end},...a)}return{kind:"Name",identifier:t.text,depth:1,pos:t.start,start:t.start,end:t.end}}case"keyword":switch(t.text){case"true":case"false":return this.#s(),{kind:"Literal",literalKind:"boolean",value:t.text==="true",depth:1,pos:t.start,start:t.start,end:t.end};case"null":return this.#s(),{kind:"Literal",literalKind:"null",value:null,depth:1,pos:t.start,start:t.start,end:t.end};case"this":if(this.#n("(",1))throw this.#x(t.start,"constructor calls with \'this(...)\'");return this.#s(),{kind:"This",depth:1,pos:t.start,start:t.start,end:t.end};case"super":if(!this.#n(".",1)&&!this.#n("::",1))throw this.#x(t.start,"\'super\' other than in super.member or super(...)",!0);return this.#s(),{kind:"Super",depth:1,pos:t.start,start:t.start,end:t.end};case"new":return this.#we();case"switch":{this.#s();let r=this.#r().start,a=this.#xt(),{cases:o,end:c}=this.#Ut(!0);return this.#$({kind:"SwitchExpression",selector:a,selectorPos:r,cases:o,depth:0,pos:t.start,start:t.start,end:c},a)}}if(Oe.has(t.text)&&this.#n("[",1)&&this.#n("]",2)){this.#s();let r={kind:"PrimitiveType",name:t.text,pos:t.start,start:t.start,end:t.end};for(;this.#n("[")&&this.#n("]",1);){this.#s();let a=this.#i("]");r={kind:"ArrayType",element:r,pos:r.pos,start:r.start,end:a.end}}if(this.#n("::"))return this.#Wt(null,r,t.start)}if(Oe.has(t.text)||t.text==="void")throw this.#x(t.start,"class literals");break;case"operator":if(t.text==="("){if(!this.#C&&this.#en())return this.#tn();this.#s();let r=this.#oe(()=>this.#w()),a=this.#i(")");return this.#$({kind:"Parenthesized",expression:r,depth:0,pos:t.start,start:t.start,end:a.end},r)}break;case"eof":this.#Q()}if(this.#m)throw this.#u(t.start,"illegal start of expression");let n=t.kind==="operator"&&t.text==="<",s=n?this.#r(1):t;return n&&s.kind!=="identifier"&&!(s.kind==="keyword"&&Oe.has(s.text))&&this.#s(),this.#O=Math.max(this.#O,s.start),this.report({offset:s.start,code:"syntax",message:n&&this.#G>0&&this.#p()===t?"illegal start of type":"illegal start of expression"}),{kind:"Name",identifier:"<error>",depth:1,pos:s.start,start:s.start,end:s.start}}#we(){let t=this.#i("new"),e=this.#r(),n;if(e.kind==="keyword"&&Oe.has(e.text))this.#s(),n={kind:"PrimitiveType",name:e.text,pos:e.start,start:e.start,end:e.end};else if(e.kind==="identifier"){let a=[this.#s().text],o;for(;this.#n(".")&&this.#S(1);)o=this.#s().start,a.push(this.#s().text);let c,u=!1,d;if(this.#n("<")){d=this.#r().start;let h=this.#b();if(h==="diamond"?u=!0:c=h,!this.#n("(")&&u)throw this.#x(d,"array creation with \'<>\'",!0)}if(n={kind:"ClassType",names:a,hasTypeArguments:u||c!==void 0,typeArgumentsPos:d,typeArguments:c,diamond:u,lastDotPos:o,pos:e.start,start:e.start,end:this.#p().end},this.#n("(")){let h=this.#Xt(),m;if(this.#n("{")){let p=this.#s();m={kind:"ClassDeclaration",keyword:"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:"",namePos:p.start,keywordPos:p.start,members:[],anonymous:!0,pos:p.start,start:p.start,end:p.start},this.#it(),this.#J(m),this.#St()}return this.#$({kind:"NewObject",classType:n,args:h,...m?{body:m}:{},depth:0,pos:t.start,start:t.start,end:this.#p().end},...h)}}else throw this.#u(e.start,"<identifier> expected");if(!this.#n("["))throw this.#u(this.#p().end,"\'(\' or \'[\' expected");if(this.#n("]",1)){let a=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),a++;if(!this.#n("{"))throw this.#u(this.#p().end,"array dimension missing");let o=this.#ie();return this.#$({kind:"NewArray",elementType:n,dimensions:[],extraDims:a,initializer:o,depth:0,pos:t.start,start:t.start,end:o.end})}let s=[],r=0;for(;this.#n("[");){if(this.#n("]",1)){this.#s(),this.#s(),r++;continue}if(r)throw this.#u(this.#r().start,"\']\' expected");this.#s(),s.push(this.#w()),this.#i("]")}if(this.#n("{"))throw this.#u(this.#r().start,"\';\' expected");return this.#$({kind:"NewArray",elementType:n,dimensions:s,extraDims:r,initializer:null,depth:0,pos:t.start,start:t.start,end:this.#p().end},...s)}#tn(){let t=this.#i("("),e=[];if(!this.#n(")"))do{if(this.#S()&&(this.#n(",",1)||this.#n(")",1))){let d=this.#s();e.push({name:d.text,pos:d.start,type:null});continue}let a=[];for(;this.#n("final");)a.push({name:"final",pos:this.#s().start});let o=a.length?{keywords:a,annotations:[]}:void 0;if(this.#S(0,"var")&&this.#S(1)){this.#s();let d=this.#A();if(this.#n("["))for(this.#D(d.start,"\'var\' is not allowed as an element type of an array");this.#n("[")&&this.#n("]",1);)this.#s(),this.#s();e.push({name:d.text,pos:d.start,type:null,isVar:!0,...o?{modifiers:o}:{}});continue}let c=this.#N(),u=this.#A();e.push({name:u.text,pos:u.start,type:c,...o?{modifiers:o}:{}})}while(this.#l(","));this.#i(")");let n=e.filter(r=>r.isVar).length;if(n&&n<e.length){let r=e.some(a=>a.type);this.#D(t.start,"invalid lambda parameter declaration",[r?" (cannot mix \'var\' and explicitly-typed parameters)":" (cannot mix \'var\' and implicitly-typed parameters)"])}let s=e.filter(r=>r.type).length;return s&&s<e.length-n&&this.#D(t.start,"invalid lambda parameter declaration",[" (cannot mix implicitly-typed and explicitly-typed parameters)"]),this.#le(t.start,e)}#le(t,e){if(this.#i("->"),this.#n("{")){let s=this.#B();return{kind:"Lambda",params:e,body:s,depth:1,pos:t,start:t,end:s.end}}let n=this.#w();return this.#$({kind:"Lambda",params:e,body:n,depth:0,pos:t,start:t,end:n.end},n)}#en(){let t=0;for(let e=0;;e++){let n=this.#r(e);if(n.kind==="eof")return!1;if(n.kind==="operator")if(n.text==="(")t++;else{if(n.text===")"&&--t===0)return this.#n("->",e+1);if(n.text===";"||n.text==="{"||n.text==="}")return!1}}}};var Uo=[{module:"java-library-time",file:"time.ts",exported:"TIME_NATIVES",classes:["LocalDate","LocalTime","LocalDateTime","Instant","ZoneId","ZoneOffset","ZonedDateTime","Duration","DayOfWeek","Month","Period","DateTimeFormatter","ChronoUnit"]},{module:"java-library-math",file:"bigmath.ts",exported:"BIGMATH_NATIVES",classes:["BigInteger","BigDecimal","MathContext","RoundingMode"],natives:["nextBigInteger()","nextBigDecimal()"]},{module:"java-library-regex",file:"matcher.ts",exported:"PATTERN_STATICS",classes:["Pattern","Matcher","MatchResult"]},{module:"java-library-bitset",file:"bitset.ts",exported:"BITSET_NATIVES",classes:["BitSet"]}],mr="javaOnlineCompilerLibrary",Gi="javaOnlineCompilerLibraryParts";function Ki(i){let t=i.indexOf("."),e=i.indexOf("("),n=t>0&&(e<0||t<e)?i.slice(0,t):null;return Uo.find(s=>n!==null&&s.classes.includes(n)||s.natives?.includes(i))}var It={Runnable:"java.lang",Stream:"java.util.stream",IntStream:"java.util.stream",LongStream:"java.util.stream",DoubleStream:"java.util.stream",Collectors:"java.util.stream",Collector:"java.util.stream",Optional:"java.util",OptionalInt:"java.util",OptionalLong:"java.util",OptionalDouble:"java.util",IntSummaryStatistics:"java.util",LongSummaryStatistics:"java.util",DoubleSummaryStatistics:"java.util",LongPredicate:"java.util.function",DoublePredicate:"java.util.function",LongConsumer:"java.util.function",DoubleConsumer:"java.util.function",LongSupplier:"java.util.function",DoubleSupplier:"java.util.function",LongFunction:"java.util.function",DoubleFunction:"java.util.function",IntToLongFunction:"java.util.function",IntToDoubleFunction:"java.util.function",LongToIntFunction:"java.util.function",LongToDoubleFunction:"java.util.function",DoubleToIntFunction:"java.util.function",DoubleToLongFunction:"java.util.function",Function:"java.util.function",BiFunction:"java.util.function",Supplier:"java.util.function",Consumer:"java.util.function",BiConsumer:"java.util.function",Predicate:"java.util.function",BiPredicate:"java.util.function",UnaryOperator:"java.util.function",BinaryOperator:"java.util.function",IntBinaryOperator:"java.util.function",IntUnaryOperator:"java.util.function",IntPredicate:"java.util.function",IntFunction:"java.util.function",IntConsumer:"java.util.function",IntSupplier:"java.util.function",ToIntFunction:"java.util.function",ToLongFunction:"java.util.function",ToDoubleFunction:"java.util.function",ToIntBiFunction:"java.util.function",LongBinaryOperator:"java.util.function",LongUnaryOperator:"java.util.function",DoubleBinaryOperator:"java.util.function",DoubleUnaryOperator:"java.util.function",BooleanSupplier:"java.util.function",ObjIntConsumer:"java.util.function",List:"java.util",ArrayList:"java.util",Map:"java.util",HashMap:"java.util",Set:"java.util",HashSet:"java.util",LinkedHashMap:"java.util",TreeMap:"java.util",TreeSet:"java.util",SortedMap:"java.util",NavigableMap:"java.util",SortedSet:"java.util",NavigableSet:"java.util",LinkedList:"java.util",Stack:"java.util",Vector:"java.util",AbstractList:"java.util",LocalDate:"java.time",LocalTime:"java.time",LocalDateTime:"java.time",OffsetTime:"java.time",OffsetDateTime:"java.time",Instant:"java.time",ZoneId:"java.time",ZoneOffset:"java.time",ZonedDateTime:"java.time",Duration:"java.time",Temporal:"java.time.temporal",TemporalAccessor:"java.time.temporal",TemporalAmount:"java.time.temporal",TemporalUnit:"java.time.temporal",DayOfWeek:"java.time",Month:"java.time",Period:"java.time",DateTimeFormatter:"java.time.format",ChronoUnit:"java.time.temporal",BitSet:"java.util",Pattern:"java.util.regex",Matcher:"java.util.regex",MatchResult:"java.util.regex",Hashtable:"java.util",Dictionary:"java.util",Enumeration:"java.util",LinkedHashSet:"java.util",Entry:"java.util",Deque:"java.util",Queue:"java.util",ArrayDeque:"java.util",PriorityQueue:"java.util",Collection:"java.util",Iterator:"java.util",ListIterator:"java.util",Arrays:"java.util",Comparator:"java.util",Collections:"java.util",Random:"java.util",Scanner:"java.util",Iterable:"java.lang",Comparable:"java.lang",Class:"java.lang",Objects:"java.util",StringBuilder:"java.lang",StringBuffer:"java.lang",StringJoiner:"java.util",Number:"java.lang",Integer:"java.lang",Long:"java.lang",Double:"java.lang",Character:"java.lang",Boolean:"java.lang",Float:"java.lang",BigInteger:"java.math",EnumMap:"java.util",EnumSet:"java.util",BigDecimal:"java.math",RoundingMode:"java.math",MathContext:"java.math",Byte:"java.lang",Short:"java.lang",OutputStream:"java.io",Reader:"java.io",InputStreamReader:"java.io",StringReader:"java.io",BufferedReader:"java.io",Writer:"java.io",OutputStreamWriter:"java.io",BufferedWriter:"java.io",StringWriter:"java.io",PrintWriter:"java.io",StreamTokenizer:"java.io",StringTokenizer:"java.util",CharSequence:"java.lang"},Mt={Entry:"Map"},vs="java-library",gn=class extends Error{module;constructor(t=vs){super(`the Java library chunk ${t} is needed`),this.name="NeedsLibrary",this.module=t}},_e=null,fr=new Set;function qi(i){_e=i,fr.clear()}function Wi(i,t){if(!_e)throw new Error(`the Java library part ${i} was loaded before the library`);Object.assign(_e.natives,t),fr.add(i)}function pr(i){for(let{name:t}of i){let e=Ki(t);if(e&&!fr.has(e.module))return e.module}return null}function bn(){return _e}function Wt(i){if(i in It){if(!_e)throw new gn;return _e.classes.get(i)}}function te(i){if(!_e)throw new gn;return _e.classes.get(i)}var V={tag:"int"},_n={tag:"byte"},xn={tag:"short"},Ce={tag:"char"},gt={tag:"boolean"},Jt={tag:"long"},kt={tag:"float"},ft={tag:"double"},xt={tag:"void"},br={tag:"null"},mt={tag:"string"},G={tag:"object"},Qi={tag:"printstream"},A={tag:"error"};function ee(i){return{tag:"array",element:i}}function tt(i,t){return t?.length?{tag:"class",name:i.displayName,symbol:i,args:t}:{tag:"class",name:i.displayName,symbol:i}}function me(i){return{tag:"typevar",name:i.name,symbol:i}}function fe(i){return tt(i,i.typeParams?.map(me))}function ws(i){return i.symbol?.key??i.name}function gr(i){return i.symbol?.bounds[0]??G}function Kt(i,t){if(!t.size)return i;switch(i.tag){case"typevar":return t.get(ws(i))??i;case"array":return ee(Kt(i.element,t));case"library":return i.args.length?pt(i.symbol,i.args.map(e=>Kt(e,t))):i;case"class":return i.args?.length?tt(i.symbol,i.args.map(e=>Kt(e,t))):i;case"wildcard":return i.bound?{...i,bound:Kt(i.bound,t)}:i;default:return i}}function Un(i){let t=new Map,e=i.symbol.typeParams??[];return i.args?.length===e.length&&e.forEach((n,s)=>t.set(n.key,i.args[s])),t}function Bn(i){return i.tag==="class"&&(i.symbol.typeParams?.length??0)>0&&!i.args?.length}function W(i){switch(i.tag){case"typevar":return i.symbol?W(gr(i)):G;case"wildcard":return G;case"array":return ee(W(i.element));case"library":return i.args.length?pt(i.symbol):i;case"class":return i.args?.length?tt(i.symbol):i;default:return i}}function Vn(i){let t=i.symbol,e=[];if(t.superType?e.push(t.superType):t.superclass?e.push(tt(t.superclass)):t.librarySuperclass&&e.push(t.librarySuperclass),t.interfaceTypes?e.push(...t.interfaceTypes):e.push(...t.interfaces.map(s=>tt(s))),e.push(...t.libraryInterfaces),!t.typeParams?.length)return e;if(!i.args?.length)return e.map(W);let n=Un(i);return e.map(s=>Kt(s,n))}function se(i,t){if(i.tag==="typevar"&&i.symbol){for(let e of i.symbol.bounds){let n=se(e,t);if(n)return n}return null}if(i.tag!=="class")return null;if(i.symbol===t)return i;for(let e of Vn(i)){let n=se(e,t);if(n)return n}return null}function Le(i,t=new Set){if(t.has(i.symbol))return[];t.add(i.symbol);let e=[];for(let n of Vn(i))n.tag==="library"?e.push(n):n.tag==="class"&&e.push(...Le(n,t));return e}function Ne(i,t,e){if(!t.typeParams?.length)return e;let n=se(i,t);return n?n.args?.length?Kt(e,Un(n)):W(e):e}function pt(i,t=[]){return{tag:"library",symbol:i,args:t}}function wt(i,t,e){switch(i.tag){case"typevar":{if(i.symbol)return i;let n=t.indexOf(i.name);return n>=0&&e[n]?e[n]:G}case"array":return ee(wt(i.element,t,e));case"library":return i.args.length?pt(i.symbol,i.args.map(n=>wt(n,t,e))):i;case"wildcard":return i.bound?{...i,bound:wt(i.bound,t,e)}:i;default:return i}}function Xt(i,t,e){switch(i.tag){case"typevar":{if(i.symbol)return i;let n=t.indexOf(i.name);return n>=0&&e[n]?e[n]:i}case"array":return ee(Xt(i.element,t,e));case"library":return i.args.length?pt(i.symbol,i.args.map(n=>Xt(n,t,e))):i;case"wildcard":return i.bound?{...i,bound:Xt(i.bound,t,e)}:i;default:return i}}function Sr(i){return i.symbol.supertypes.map(t=>wt(t,i.symbol.typeParams,i.args))}function Dt(i,t){if(i.tag!=="library")return null;if(i.symbol===t)return i;for(let e of Sr(i)){let n=Dt(e,t);if(n)return n}return null}function qt(i){let t={int:"Integer",long:"Long",double:"Double",char:"Character",boolean:"Boolean",float:"Float",byte:"Byte",short:"Short"}[i.tag],e=t?bn()?.classes.get(t):void 0;return e?pt(e):null}function St(i){return i.tag!=="library"||!i.symbol.box?null:{int:V,long:Jt,double:ft,char:Ce,boolean:gt,float:kt,byte:_n,short:xn}[i.symbol.box]}function $(i){switch(i.tag){case"int":case"byte":case"short":case"char":case"boolean":case"long":case"float":case"double":case"void":return i.tag;case"null":return"<null>";case"string":return"String";case"object":return"Object";case"printstream":return"PrintStream";case"array":return $(i.element)+"[]";case"class":return i.args?.length?`${i.name}<${i.args.map($).join(",")}>`:i.name;case"library":return i.args.length?`${i.symbol.name}<${i.args.map($).join(",")}>`:i.symbol.name;case"diamond":return`${i.symbol.name}<>`;case"typevar":return i.name;case"wildcard":return i.poly&&i.bound?$(i.bound):i.bound?`? ${i.isSuper?"super":"extends"} ${$(i.bound)}`:"?";case"lambda":return i.text;case"error":return"<any>"}}function at(i,t){if(i.tag!==t.tag)return!1;if(i.tag==="array"&&t.tag==="array")return at(i.element,t.element);if(i.tag==="class"&&t.tag==="class"){let e=i.args??[],n=t.args??[];return i.symbol===t.symbol&&e.length===n.length&&e.every((s,r)=>at(s,n[r]))}return i.tag==="wildcard"&&t.tag==="wildcard"?i.isSuper===t.isSuper&&(i.bound===null?t.bound===null:t.bound!==null&&at(i.bound,t.bound)):i.tag==="library"&&t.tag==="library"?i.symbol===t.symbol&&i.args.length===t.args.length&&i.args.every((e,n)=>at(e,t.args[n])):i.tag==="typevar"&&t.tag==="typevar"?i.symbol===t.symbol&&i.name===t.name:i.tag==="diamond"&&t.tag==="diamond"?i.symbol===t.symbol:!0}function nt(i){return i.tag==="string"||i.tag==="null"||i.tag==="object"||i.tag==="printstream"||i.tag==="array"||i.tag==="class"||i.tag==="library"||i.tag==="typevar"||i.tag==="diamond"}function st(i){return["int","byte","short","char","boolean","long","float","double"].includes(i.tag)}function Rt(i){return["int","byte","short","char","long","float","double"].includes(i.tag)}var Xi={byte:0,short:1,char:1,int:2,long:3,float:4,double:5};function Bo(i,t){return!Rt(i)||!Rt(t)||i.tag==="char"||t.tag==="char"&&i.tag==="short"?!1:Xi[t.tag]<Xi[i.tag]}function Sn(i,t){return i===t||i.superclass&&Sn(i.superclass,t)?!0:i.interfaces.some(e=>Sn(e,t))}function Tn(i,t=new Set){if(t.has(i))return[];t.add(i);let e=[...i.libraryInterfaces];i.superclass&&e.push(...Tn(i.superclass,t));for(let n of i.interfaces)e.push(...Tn(n,t));return e}var Hn={tag:"typevar",name:"?open"};function yr(i,t){let e=t.args??[];return!i.args?.length&&e.length?!1:(i.args??[]).every((n,s)=>{let r=e[s];if(n===Hn||!r)return!0;let a=n.tag==="wildcard"&&n.poly&&n.bound?n.bound:n;return a!==n&&r.tag!=="wildcard"?K(a,r):r.tag==="wildcard"?r.bound?a.tag==="wildcard"?r.isSuper?a.isSuper===!0&&a.bound!==null&&K(r.bound,a.bound):a.isSuper?r.bound.tag==="object":K(a.bound??G,r.bound):r.isSuper?K(r.bound,a):K(a,r.bound):!0:at(a,r)})}function K(i,t){if(at(i,t))return!0;if(i.tag==="null")return nt(t);if(t.tag==="object")return nt(i);if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&nt(t.element)&&K(i.element,t.element);if(i.tag==="typevar"&&i.symbol)return i.symbol.bounds.some(s=>K(s,t));if(i.tag==="class"&&t.tag==="class"){let s=se(i,t.symbol);return s?t.args?.length?(s.args?.length??0)>0&&yr(s,t):!0:!1}if(i.tag==="class"&&i.symbol.isEnum&&t.tag==="library"&&t.symbol.name==="Comparable"){let s=t.args[0];return!s||at(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?K(s.bound,i):K(i,s.bound)))}if(i.tag==="class"&&t.tag==="library")return Le(i).some(s=>{let r=Dt(s,t.symbol);return r!==null&&yr(r,t)});if((i.tag==="string"||i.tag==="library"&&(i.symbol.box!==void 0||i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer"))&&t.tag==="library"&&t.symbol.name==="Comparable"){let s=t.args[0];return!s||at(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?K(s.bound,i):K(i,s.bound)))}if(t.tag!=="library")return!1;if(t.symbol.name==="CharSequence"&&(i.tag==="string"||i.tag==="library"&&(i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer")))return!0;if(i.tag==="printstream")return t.symbol.name==="OutputStream";if(i.tag==="diamond")return Dt(pt(i.symbol,i.symbol.typeParams.map(()=>G)),t.symbol)!==null;let n=Dt(i,t.symbol);return n?yr(n,t):!1}function Vo(i){return i.box!==void 0||i.name==="StringBuilder"||i.name==="StringBuffer"||i.name==="StringJoiner"||i.name==="Scanner"}function Yi(i){switch(i.tag){case"class":return{interface:i.symbol.isInterface,final:i.symbol.isFinal};case"library":case"diamond":return{interface:i.symbol.isInterface,final:!i.symbol.isInterface&&Vo(i.symbol)};case"string":return{interface:!1,final:!0};default:return null}}function ke(i,t){if(K(t,i)||K(i,t))return!0;if(i.tag==="typevar"&&i.symbol)return ke(gr(i),t);if(t.tag==="typevar"&&t.symbol)return ke(i,gr(t));if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&nt(t.element)?ke(i.element,t.element):at(i.element,t.element);let e=Yi(i),n=Yi(t);return!e||!n?!1:e.interface&&n.interface?!0:e.interface?!n.final:n.interface?!e.final:!1}function Ze(i,t){return i.tag==="error"||t.tag==="error"?!0:t.tag==="lambda"?ta(i,t)===null:at(i,t)||Bo(i,t)?!0:nt(i)&&K(t,i)}function Ht(i,t){if(Ze(i,t))return!0;if(st(t)&&nt(i)){if(i.tag==="object")return!0;let n=qt(t);return n!==null&&K(n,i)}let e=St(t);return e!==null&&st(i)&&Ze(i,e)}var Ho={byte:[-128,127],short:[-32768,32767],char:[0,65535]};function re(i,t,e){if(Ht(i,t))return!0;let n=i.tag==="library"?i.symbol.box:i.tag,s=n?Ho[n]:void 0;if(s&&["int","byte","short","char"].includes(t.tag)&&e&&(e.kind==="int"||e.kind==="char")){let r=e.value;return r>=s[0]&&r<=s[1]}return!1}function zo(i){if(i.tag==="class"&&i.symbol.isInterface&&!i.symbol.isSealed){let n=ks(i.symbol);return n.length===1?{params:n[0].params,returnType:n[0].returnType}:null}if(i.tag!=="library"||!i.symbol.functional)return null;let t=i.symbol.methods.find(n=>n.name===i.symbol.functional&&!n.isStatic),e=i.symbol.typeParams.map((n,s)=>{let r=i.args[s];return r?r.tag==="wildcard"?r.bound??G:r:G});return{params:t.params.map(n=>wt(n,i.symbol.typeParams,e)),returnType:wt(t.returnType,i.symbol.typeParams,e)}}function Zi(i){switch(i.tag){case"typevar":case"wildcard":case"object":return"Object";case"string":return"String";case"library":return i.symbol.qualifiedName;case"class":return i.symbol.binaryName;case"array":return Zi(i.element)+"[]";default:return i.tag}}function ks(i){let t=new Set(["equals(Object)","hashCode()","toString()"]),e=[],n=[i];for(let s=0;s<n.length;s++){let r=n[s];for(let a of r.methods){if(a.isStatic||a.isPrivate)continue;let o=`${a.name}(${a.params.map(Zi).join(",")})`;t.has(o)||(t.add(o),a.isAbstract&&e.push(a))}n.push(...r.interfaces)}return e}function ta(i,t){if(i.tag==="error")return null;let e=zo(i);return e?t.arity<0||e.params.length===t.arity?null:"incompatible parameter types in lambda expression":`${i.tag==="array"?"Array":i.tag==="library"||i.tag==="diamond"?i.symbol.name:i.tag==="class"?i.symbol.displayName:$(i)} is not a functional interface`}function Ue(i,t){return t.tag==="lambda"?ta(i,t)??"":Rt(i)&&Rt(t)?`possible lossy conversion from ${$(t)} to ${$(i)}`:`${$(t)} cannot be converted to ${$(i)}`}function Ft(i){switch(i.tag){case"int":return"I";case"char":return"C";case"boolean":return"Z";case"long":return"J";case"double":return"D";case"byte":return"B";case"short":return"S";case"float":return"F";case"string":return"Ljava.lang.String;";case"class":return`L${i.symbol.binaryName};`;case"library":case"diamond":return`L${i.symbol.qualifiedName};`;case"object":return"Ljava.lang.Object;";case"array":return"["+Ft(i.element);case"typevar":return Ft(W(i));default:throw new Error(`codegen: descriptor of ${$(i)}`)}}var ea=new WeakMap,na=new WeakMap,sa=new WeakMap;function Tr(i){let t=ea.get(i);return t||ea.set(i,t={kind:"type",symbol:i}),t}function wn(i,t){let e=na.get(i);return e||na.set(i,e={kind:"method",method:i,owner:t}),e}function xr(i){let t=sa.get(i);return t||sa.set(i,t={kind:"program",variable:i}),t}function ra(i,t){return i.symbol?{name:i.name,decl:xr(i.symbol)}:t?t.kind==="method"?t.method.typeParams?.includes(i.name)?{name:i.name,decl:t}:t.owner.typeParams.includes(i.name)?{name:i.name,decl:Tr(t.owner)}:null:t.kind==="type"&&t.symbol.typeParams.includes(i.name)?{name:i.name,decl:t}:null:null}function ia(i){if(i.decl.kind==="method"){let t=i.decl.method.typeParamBounds?.[i.name];return t?{type:t,decl:i.decl}:null}if(i.decl.kind==="program"){let t=i.decl.variable.bounds[0];return t?{type:t,decl:null}:null}return null}var vn=class{refs=[];#d=new Set;#z(t,e){return t.name===e.name&&t.decl===e.decl}add(t){if(this.refs.some(s=>this.#z(s,t)))return;this.refs.push(t);let e=ia(t);e&&this.visit(e.type,e.decl);let n=t.decl;if(!(n.kind!=="method"||this.#d.has(n))){this.#d.add(n);for(let s of n.method.typeParams??[])this.add({name:s,decl:n});for(let s of n.method.params)this.visit(s,n)}}visit(t,e){switch(t.tag){case"typevar":{let n=ra(t,e);n&&this.add(n);return}case"array":return this.visit(t.element,e);case"wildcard":t.bound&&this.visit(t.bound,e);return;case"library":return t.args.forEach(n=>this.visit(n,e));case"class":return t.args?.forEach(n=>this.visit(n,e));default:return}}label(t){let e=this.refs.filter(n=>n.name===t.name);return e.length>1?`${t.name}#${e.findIndex(n=>n.decl===t.decl)+1}`:t.name}render(t,e){switch(t.tag){case"typevar":{let n=ra(t,e);return n?this.label(n):t.name}case"array":return`${this.render(t.element,e)}[]`;case"wildcard":return t.bound?`? ${t.isSuper?"super":"extends"} ${this.render(t.bound,e)}`:"?";case"library":return t.args.length?`${t.symbol.name}<${t.args.map(n=>this.render(n,e)).join(",")}>`:t.symbol.name;case"class":return t.args?.length?`${t.name}<${t.args.map(n=>this.render(n,e)).join(",")}>`:t.name;default:return $(t)}}params(t){let e=t.method;return e.params.map((n,s)=>e.varargs&&s===e.params.length-1&&n.tag==="array"?`${this.render(n.element,t)}...`:this.render(n,t)).join(",")}#It(t){return t.kind==="type"?`${t.symbol.isInterface?"interface":"class"} ${t.symbol.name}`:t.kind==="program"?t.variable.declaredIn:`method <${(t.method.typeParams??[]).map(e=>this.label({name:e,decl:t})).join(",")}>${t.method.name}(${this.params(t)})`}#rt(t){let e=`Comparable<? super ${this.label(t)}>`;if(t.decl.kind==="method"&&t.decl.method.typeParamShown?.[t.name]){let s=t.decl,r=s.method.typeParamShown[t.name].replace(/\\bComparable\\b(?!<)/,e);for(let a of s.method.typeParams??[])r=r.replace(new RegExp(`\\\\b${a}\\\\b(?!#)`,"g"),this.label({name:a,decl:s}));return r}if(t.decl.kind==="method"&&t.decl.method.comparableParams?.includes(t.name))return e;let n=ia(t);return n?this.render(n.type,n.decl):"Object"}entries(){return this.refs.map(t=>({name:this.label(t),line:` ${this.label(t)} extends ${this.#rt(t)} declared in ${this.#It(t.decl)}`}))}};function aa(i,t,e){let n=new vn;n.add(i);for(let a of[...t,...e])n.visit(a.type,a.decl);let s=a=>[...new Set(a.map(o=>n.render(o.type,o.decl)))].join(","),r=n.entries();return[` reason: argument mismatch; inference variable ${n.label(i)} has incompatible bounds`,` upper bounds: ${s(t)}`,` lower bounds: ${s(e)}`,r.length===1?` where ${r[0].name} is a type-variable:`:` where ${r.map(a=>a.name).join(",")} are type-variables:`,...r.map(a=>a.line)]}function Cs(i){if(i.kind==="MethodRef")return ct(i);let t=i.kind==="Lambda"?la(i):ct(i);return t.length>=20?`${t.slice(0,10)}[...]${t.slice(-5)}`:t}function la(i){let t=i.params.every(n=>!n.type)?i.params.map(n=>n.name).join(","):i.params.map(n=>`${oe(n.type)} ${n.name}`).join(", "),e=i.body.kind==="Block"?ca(i.body.statements):ct(i.body);return`(${t})->${e}`}function oe(i){switch(i.kind){case"PrimitiveType":return i.name;case"ClassType":return i.names.join(".")+(i.typeArguments?`<${i.typeArguments.map(oe).join(",")}>`:i.diamond?"<>":"");case"ArrayType":return`${oe(i.element)}[]`;case"WildcardType":return i.bound?`? ${i.isSuper?"super":"extends"} ${oe(i.bound)}`:"?";case"VoidType":return"void";case"VarType":return"var"}}function oa(i,t){let e={"\\b":"\\\\b"," ":"\\\\t","\\n":"\\\\n","\\f":"\\\\f","\\r":"\\\\r",\'"\':\'\\\\"\',"\'":"\\\\\'","\\\\":"\\\\\\\\"},n="";for(let s of i){let r=s.charCodeAt(0);n+=e[s]??(r<32||r>126?`\\\\u${r.toString(16).padStart(4,"0")}`:s)}return t+n+t}function ct(i){switch(i.kind){case"Literal":switch(i.literalKind){case"long":return`${i.value}L`;case"double":return de(i.value);case"float":return`${de(parseFloat(String(i.value)))}F`;case"char":return oa(i.value,"\'");case"string":case"text-block":return oa(i.value,\'"\');default:return String(i.value)}case"Name":return i.identifier;case"FieldAccess":return`${ct(i.target)}.${i.name}`;case"MethodCall":return`${i.target?ct(i.target)+".":""}${i.name}(${i.args.map(ct).join(", ")})`;case"Unary":return i.operator+ct(i.operand);case"IncDec":return i.prefix?i.operator+ct(i.operand):ct(i.operand)+i.operator;case"Binary":return`${ct(i.left)} ${i.operator} ${ct(i.right)}`;case"Assignment":return`${ct(i.target)} ${i.operator} ${ct(i.value)}`;case"Parenthesized":return`(${ct(i.expression)})`;case"ArrayAccess":return`${ct(i.array)}[${ct(i.index)}]`;case"NewArray":{let t=i.dimensions.map(e=>`[${ct(e)}]`).join("")+"[]".repeat(i.extraDims);return i.initializer?`new ${oe(i.elementType)}${"[]".repeat(Math.max(1,i.extraDims))}{${i.initializer.elements.map(e=>e.kind==="ArrayInitializer"?"{...}":ct(e)).join(", ")}}`:`new ${oe(i.elementType)}${t}`}case"Cast":return`(${oe(i.targetType)})${ct(i.expression)}`;case"This":return"this";case"NewObject":return`${i.outerExpression?`${ct(i.outerExpression)}.`:""}new ${oe(i.classType)}(${i.args.map(ct).join(", ")})`;case"Conditional":return`${ct(i.condition)} ? ${ct(i.whenTrue)} : ${ct(i.whenFalse)}`;case"SwitchExpression":return`switch (${ct(i.selector)}) {...}`;case"Lambda":return la(i);case"MethodRef":return`${i.arrayType?oe(i.arrayType):i.target?ct(i.target):""}::${i.name}`;case"InstanceOf":return`${ct(i.expression)} instanceof ${oe(i.targetType)}${i.binding?` ${i.binding.name}`:""}`;case"Super":return"super";case"ClassLiteral":return`${ct(i.target)}.class`}}function ca(i){return i.length?`{ ${i.map(tn).join(" ")} }`:"{ }"}function tn(i){switch(i.kind){case"Block":return ca(i.statements);case"ReturnStatement":return i.value?`return ${ct(i.value)};`:"return;";case"ExpressionStatement":return`${ct(i.expression)};`;case"LocalVariableDeclaration":return`${oe(i.type)} ${i.declarators.map(t=>t.init&&t.init.kind!=="ArrayInitializer"?`${t.name} = ${ct(t.init)}`:t.name).join(", ")};`;case"IfStatement":return`if (${ct(i.condition)}) ${tn(i.then)}${i.otherwise?` else ${tn(i.otherwise)}`:""}`;case"WhileStatement":return`while (${ct(i.condition)}) ${tn(i.body)}`;case"DoStatement":return`do ${tn(i.body)} while (${ct(i.condition)});`;case"ForStatement":return`for (...) ${tn(i.body)}`;case"ForEachStatement":return`for (${oe(i.type)} ${i.name} : ${ct(i.iterable)}) ${tn(i.body)}`;case"BreakStatement":return i.label?`break ${i.label};`:"break;";case"ContinueStatement":return i.label?`continue ${i.label};`:"continue;";case"EmptyStatement":return";";case"YieldStatement":return`yield ${ct(i.value)};`;default:return"..."}}function zn(i){switch(i.kind){case"int":case"byte":case"short":case"long":return String(i.value);case"double":return de(i.value);case"float":return Fe(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";case"string":return i.value}}function X(i){return{kind:"int",value:i|0}}function Gn(i){return{kind:"char",value:i&65535}}function _t(i){return{kind:"long",value:BigInt.asIntN(64,i)}}function Es(i){return{kind:"byte",value:i<<24>>24}}function As(i){return{kind:"short",value:i<<16>>16}}function pe(i){return{kind:"float",value:Math.fround(i)}}function ie(i){return{kind:"double",value:i}}function Tt(i){return{kind:"boolean",value:i}}function vr(i){return{kind:"string",value:i}}var wr=new Set(["int","byte","short","char"]);function kn(i){return wr.has(i.kind)?i.value:void 0}function Cn(i){if(i.kind==="long")return i.value;if(wr.has(i.kind))return BigInt(i.value)}function Kn(i){if(i.kind==="double"||i.kind==="float")return i.value;if(i.kind==="long")return Ss(At(i.value));if(wr.has(i.kind))return i.value}function Is(i){if(i.kind==="long")return yn(At(i.value));let t=Kn(i);return t===void 0?void 0:Math.fround(t)}function ua(i,t){if(i.kind==="boolean"||i.kind==="string")return;let e=()=>i.kind==="double"||i.kind==="float"?Fn(i.value):i.kind==="long"?bs(At(i.value)):i.value;switch(t){case"double":return ie(Kn(i));case"float":return pe(Is(i));case"long":return i.kind==="double"||i.kind==="float"?_t(BigInt(Dn(i.value))):_t(Cn(i));case"int":return X(e());case"byte":return Es(e());case"short":return As(e());case"char":return Gn(e())}}function qn(i){return i!==void 0&&i.kind==="boolean"&&i.value}function Os(i){return i!==void 0&&i.kind==="boolean"&&!i.value}var le=["none","message","message-cause","cause"],Yt=["none","message"],Go=[["java.lang.Throwable",null,le],["java.lang.Exception","java.lang.Throwable",le],["java.lang.Error","java.lang.Throwable",le],["java.lang.RuntimeException","java.lang.Exception",le],["java.lang.ArithmeticException","java.lang.RuntimeException",Yt],["java.lang.ArrayStoreException","java.lang.RuntimeException",Yt],["java.lang.ClassCastException","java.lang.RuntimeException",Yt],["java.lang.IllegalArgumentException","java.lang.RuntimeException",le],["java.lang.IllegalStateException","java.lang.RuntimeException",le],["java.lang.IndexOutOfBoundsException","java.lang.RuntimeException",["none","message","index"],"Index out of range: "],["java.lang.ArrayIndexOutOfBoundsException","java.lang.IndexOutOfBoundsException",["none","message","index"],"Array index out of range: "],["java.lang.StringIndexOutOfBoundsException","java.lang.IndexOutOfBoundsException",["none","message","index"],"String index out of range: "],["java.lang.NegativeArraySizeException","java.lang.RuntimeException",Yt],["java.lang.NullPointerException","java.lang.RuntimeException",Yt],["java.lang.NumberFormatException","java.lang.IllegalArgumentException",Yt],["java.lang.UnsupportedOperationException","java.lang.RuntimeException",le],["java.lang.CloneNotSupportedException","java.lang.Exception",Yt],["java.lang.InterruptedException","java.lang.Exception",Yt],["java.lang.ReflectiveOperationException","java.lang.Exception",le],["java.lang.ClassNotFoundException","java.lang.ReflectiveOperationException",["none","message","message-cause"]],["java.lang.AssertionError","java.lang.Error",["none","object"]],["java.lang.LinkageError","java.lang.Error",["none","message","message-cause"]],["java.lang.ExceptionInInitializerError","java.lang.LinkageError",Yt],["java.lang.NoClassDefFoundError","java.lang.LinkageError",Yt],["java.lang.VirtualMachineError","java.lang.Error",le],["java.lang.StackOverflowError","java.lang.VirtualMachineError",Yt],["java.lang.OutOfMemoryError","java.lang.VirtualMachineError",Yt],["java.util.NoSuchElementException","java.lang.RuntimeException",le],["java.util.InputMismatchException","java.util.NoSuchElementException",Yt],["java.util.ConcurrentModificationException","java.lang.RuntimeException",le],["java.util.EmptyStackException","java.lang.RuntimeException",["none"]],["java.util.IllegalFormatException","java.lang.IllegalArgumentException",[]],["java.util.MissingFormatArgumentException","java.util.IllegalFormatException",[]],["java.util.UnknownFormatConversionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatConversionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatPrecisionException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatWidthException","java.util.IllegalFormatException",[]],["java.util.MissingFormatWidthException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatCodePointException","java.util.IllegalFormatException",[]],["java.util.IllegalFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.FormatFlagsConversionMismatchException","java.util.IllegalFormatException",[]],["java.util.DuplicateFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.UnknownFormatFlagsException","java.util.IllegalFormatException",[]],["java.util.regex.PatternSyntaxException","java.lang.IllegalArgumentException",[]],["java.time.DateTimeException","java.lang.RuntimeException",["message","message-cause"]],["java.time.format.DateTimeParseException","java.time.DateTimeException",[]],["java.time.temporal.UnsupportedTemporalTypeException","java.time.DateTimeException",["message","message-cause"]],["java.io.IOException","java.lang.Exception",le],["java.io.FileNotFoundException","java.io.IOException",Yt],["java.io.EOFException","java.io.IOException",Yt],["java.io.UncheckedIOException","java.lang.RuntimeException",["message-cause","cause"]]],En=Go.map(([i,t,e,n])=>({name:i,superclass:t,constructors:e,...n?{indexPrefix:n}:{}})),yt={message:0,cause:1,trace:2,suppressed:3,causeSet:4},ha=5;function da(i){let t=i.lastIndexOf(".");return{pkg:i.slice(0,t),simple:i.slice(t+1)}}var An=new Set(["Object","Integer","Long","Double","Float","Short","Byte","Character","Boolean","Number","Math","StrictMath","StringBuilder","StringBuffer","CharSequence","Iterable","Comparable","Thread","Runnable","Runtime","Process","Class","Enum","Record","Void","IO","Throwable","Exception","Error","RuntimeException","ArithmeticException","ArrayIndexOutOfBoundsException","IndexOutOfBoundsException","StringIndexOutOfBoundsException","NullPointerException","ClassCastException","IllegalArgumentException","IllegalStateException","NumberFormatException","UnsupportedOperationException","NegativeArraySizeException","StackOverflowError","OutOfMemoryError","AssertionError","InterruptedException","CloneNotSupportedException","Override","Deprecated","FunctionalInterface","SuppressWarnings","SafeVarargs","Cloneable","AutoCloseable","Appendable","Readable","ThreadLocal"]),Ko=new Set(["printf","format","flush","write","append","close","checkError","writeBytes","charset"]),ma=new Set(["currentTimeMillis","nanoTime","exit","arraycopy","getProperty","getProperties","setProperty","clearProperty","lineSeparator","identityHashCode","getenv","gc","setOut","setErr","setIn","console","inheritedChannel","getLogger","load","loadLibrary","mapLibraryName","runFinalization"]),qo=new Set(["substring","indexOf","lastIndexOf","isBlank","toUpperCase","toLowerCase","trim","strip","stripLeading","stripTrailing","split","contains","startsWith","endsWith","replace","replaceAll","replaceFirst","compareToIgnoreCase","equalsIgnoreCase","concat","chars","codePoints","format","formatted","valueOf","copyValueOf","join","repeat","matches","hashCode","intern","codePointAt","codePointBefore","codePointCount","offsetByCodePoints","getBytes","getChars","lines","indent","translateEscapes","stripIndent","transform","describeConstable","resolveConstantDesc","contentEquals","regionMatches","subSequence","toString","getClass","wait","notify","notifyAll","splitWithDelimiters"]),Wo=new Set(["name","ordinal","compareTo","equals","hashCode","getDeclaringClass"]),Xo=new Set(["clone","getClass","hashCode","equals","toString","wait","notify","notifyAll"]),Ls={Pattern:{UNIX_LINES:{type:V,constant:X(1)},CASE_INSENSITIVE:{type:V,constant:X(2)},COMMENTS:{type:V,constant:X(4)},MULTILINE:{type:V,constant:X(8)},LITERAL:{type:V,constant:X(16)},DOTALL:{type:V,constant:X(32)},UNICODE_CASE:{type:V,constant:X(64)},CANON_EQ:{type:V,constant:X(128)},UNICODE_CHARACTER_CLASS:{type:V,constant:X(256)}},Integer:{MAX_VALUE:{type:V,constant:X(2147483647)},MIN_VALUE:{type:V,constant:X(-2147483648)},SIZE:{type:V,constant:X(32)},BYTES:{type:V,constant:X(4)}},Long:{MAX_VALUE:{type:Jt,constant:_t(or)},MIN_VALUE:{type:Jt,constant:_t(lr)},SIZE:{type:V,constant:X(64)},BYTES:{type:V,constant:X(8)}},Double:{MAX_VALUE:{type:ft,constant:ie(Number.MAX_VALUE)},MIN_VALUE:{type:ft,constant:ie(Number.MIN_VALUE)},MIN_NORMAL:{type:ft,constant:ie(22250738585072014e-324)},POSITIVE_INFINITY:{type:ft,constant:ie(1/0)},NEGATIVE_INFINITY:{type:ft,constant:ie(-1/0)},NaN:{type:ft,constant:ie(NaN)},SIZE:{type:V,constant:X(64)},BYTES:{type:V,constant:X(8)}},Float:{MAX_VALUE:{type:kt,constant:pe(34028234663852886e22)},MIN_VALUE:{type:kt,constant:pe(1401298464324817e-60)},MIN_NORMAL:{type:kt,constant:pe(11754943508222875e-54)},POSITIVE_INFINITY:{type:kt,constant:pe(1/0)},NEGATIVE_INFINITY:{type:kt,constant:pe(-1/0)},NaN:{type:kt,constant:pe(NaN)},MAX_EXPONENT:{type:V,constant:X(127)},MIN_EXPONENT:{type:V,constant:X(-126)},SIZE:{type:V,constant:X(32)},BYTES:{type:V,constant:X(4)}},Byte:{MAX_VALUE:{type:_n,constant:Es(127)},MIN_VALUE:{type:_n,constant:Es(-128)},SIZE:{type:V,constant:X(8)},BYTES:{type:V,constant:X(1)}},Short:{MAX_VALUE:{type:xn,constant:As(32767)},MIN_VALUE:{type:xn,constant:As(-32768)},SIZE:{type:V,constant:X(16)},BYTES:{type:V,constant:X(2)}},Character:{MAX_VALUE:{type:Ce,constant:Gn(65535)},MIN_VALUE:{type:Ce,constant:Gn(0)},MIN_RADIX:{type:V,constant:X(2)},MAX_RADIX:{type:V,constant:X(36)},SIZE:{type:V,constant:X(16)},BYTES:{type:V,constant:X(2)}},Math:{PI:{type:ft,constant:ie(Math.PI)},E:{type:ft,constant:ie(Math.E)}},StreamTokenizer:{TT_EOF:{type:V,constant:X(-1)},TT_EOL:{type:V,constant:X(10)},TT_NUMBER:{type:V,constant:X(-2)},TT_WORD:{type:V,constant:X(-3)}}},Wn={abs:[{params:[V],returnType:V,fn:"abs-int"},{params:[Jt],returnType:Jt,fn:"abs-long"},{params:[kt],returnType:kt,fn:"abs-float"},{params:[ft],returnType:ft,fn:"abs-double"}],max:[{params:[V,V],returnType:V,fn:"max-int"},{params:[Jt,Jt],returnType:Jt,fn:"max-long"},{params:[kt,kt],returnType:kt,fn:"max-float"},{params:[ft,ft],returnType:ft,fn:"max-double"}],min:[{params:[V,V],returnType:V,fn:"min-int"},{params:[Jt,Jt],returnType:Jt,fn:"min-long"},{params:[kt,kt],returnType:kt,fn:"min-float"},{params:[ft,ft],returnType:ft,fn:"min-double"}],sqrt:[{params:[ft],returnType:ft,fn:"sqrt"}],floor:[{params:[ft],returnType:ft,fn:"floor"}],ceil:[{params:[ft],returnType:ft,fn:"ceil"}],round:[{params:[kt],returnType:V,fn:"round-float"},{params:[ft],returnType:Jt,fn:"round-double"}]},fa=i=>i.target?.kind==="Name"&&i.target.staticOwner===!0,Xn=i=>i.tag==="int"||i.tag==="char"||i.tag==="long"||i.tag==="byte"||i.tag==="short",pa=i=>i.tag==="char"||i.tag==="byte"||i.tag==="short"?V:i;function ns(i,t){return i.tag==="double"||t.tag==="double"?ft:i.tag==="float"||t.tag==="float"?kt:i.tag==="long"||t.tag==="long"?Jt:V}var Ns=new Set(["java.lang","java.util","java.io","java.math","java.net","java.nio","java.nio.file","java.nio.charset","java.text","java.time","java.time.format","java.time.temporal","java.util.function","java.util.stream","java.util.concurrent","java.util.concurrent.atomic","java.util.regex","java.lang.reflect","java.security","java.awt","javax.swing"]),Ma=new Set(["LinkedList","TreeMap","TreeSet","LinkedHashMap","LinkedHashSet","Stack","Optional","OptionalInt","Date","Calendar","Locale","UUID","NoSuchElementException","ConcurrentModificationException","SortedMap","SortedSet","NavigableMap","NavigableSet","AbstractMap","EnumMap","EnumSet","IdentityHashMap","WeakHashMap","Properties","Timer","Formatter","Currency","InputMismatchException","Spliterator","IntSummaryStatistics","Base64","Map.Entry","Entry","EventListener","Observable","SequencedCollection"]),Yn={"java.util":[...Ma].filter(i=>!i.includes(".")),"java.io":["PrintStream","InputStream","File","FileReader","FileWriter","FileInputStream","FileOutputStream","DataInputStream","DataOutputStream","BufferedInputStream","BufferedOutputStream","ByteArrayInputStream","ByteArrayOutputStream","Serializable","Closeable","Flushable","Console"],"java.math":["BigInteger","BigDecimal","RoundingMode","MathContext"],"java.time":["Year","YearMonth","Clock"],"java.time.format":["TextStyle","FormatStyle"],"java.time.temporal":["TemporalAdjusters","TemporalUnit","Temporal"],"java.text":["DecimalFormat","NumberFormat","SimpleDateFormat","MessageFormat"],"java.util.regex":["PatternSyntaxException"],"java.util.concurrent":["ConcurrentHashMap","CopyOnWriteArrayList","ExecutorService","Executors","TimeUnit","Future","CompletableFuture","ThreadLocalRandom","CountDownLatch","ConcurrentLinkedQueue","LinkedBlockingQueue","ArrayBlockingQueue"],"java.util.concurrent.atomic":["AtomicInteger","AtomicLong","AtomicBoolean","AtomicReference"],"java.nio.file":["Files","Path","Paths"]},ya={private:0,package:1,protected:2,public:3},Yo={Comparable:["compareTo"],Comparator:["compare"],Iterable:["iterator"],Iterator:["hasNext","next"]},ga=new Set(["ArrayList","LinkedList","HashMap","LinkedHashMap","TreeMap","HashSet","LinkedHashSet","TreeSet","ArrayDeque","PriorityQueue","AbstractList"]),Qo={ArrayList:["add(E)","get(int)","size()"],HashMap:["put(K,V)","get(Object)","containsKey(Object)","remove(Object)"],LinkedHashMap:["put(K,V)","get(Object)","containsKey(Object)","remove(Object)","removeEldestEntry(Entry)"],TreeMap:["get(Object)","containsKey(Object)"],AbstractList:["get(int)","size()","add(int,E)","set(int,E)","remove(int)","add(E)"]},Zo={"ArrayDeque.<init>(Collection)":["size()"],"ArrayList.<init>(Collection)":[],"Collections.addAll(Collection,T[])":["add(E)"],"Collections.binarySearch(List,T)":["size()","get(int)"],"Collections.binarySearch(List,T,Comparator)":["size()","get(int)"],"Collections.disjoint(Collection,Collection)":["size()"],"Collections.fill(List,T)":["size()"],"Collections.frequency(Collection,Object)":[],"Collections.max(Collection)":[],"Collections.max(Collection,Comparator)":[],"Collections.min(Collection)":[],"Collections.min(Collection,Comparator)":[],"Collections.reverse(List)":["size()","get(int)"],"Collections.shuffle(List)":["size()","get(int)"],"Collections.shuffle(List,Random)":["size()","get(int)"],"Collections.sort(List)":[],"Collections.sort(List,Comparator)":[],"Collections.swap(List,int,int)":["get(int)"],"Collections.unmodifiableCollection(Collection)":["*"],"Collections.unmodifiableList(List)":["*"],"Collections.unmodifiableMap(Map)":["*"],"Collections.unmodifiableSet(Set)":["*"],"HashMap.<init>(Map)":["size()"],"HashSet.<init>(Collection)":["size()"],"LinkedHashMap.<init>(Map)":["size()"],"LinkedHashSet.<init>(Collection)":["size()"],"LinkedList.<init>(Collection)":[],"List.copyOf(Collection)":[],"Map.copyOf(Map)":[],"PriorityQueue.<init>(Collection)":[],"Set.copyOf(Collection)":["size()"],"String.join(CharSequence,Iterable)":[],"TreeMap.<init>(Map)":["size()"],"TreeMap.<init>(SortedMap)":["size()"],"TreeSet.<init>(Collection)":["size()"],"TreeSet.<init>(SortedSet)":["size()"],"addAll(Collection)":["size()"],"containsAll(Collection)":[],"putAll(Map)":["size()"],"removeAll(Collection)":["size()"],"retainAll(Collection)":[],"equals(Object)":["size()","get(Object)","containsKey(Object)"]},tl=["size()","get(int)","get(Object)","containsKey(Object)"],el={"java.util.regex.PatternSyntaxException":["getDescription","getIndex","getPattern"],"java.time.format.DateTimeParseException":["getParsedString","getErrorIndex"]},ba=new Set(["toString()","equals(Object)","hashCode()"]),nl=new Set(["Comparable","Comparator","Iterable","Iterator"]);function Sa(i){return nl.has(i.name)||i.functional!==void 0}var $s=new Set(["getClass","wait","notify","notifyAll","clone","finalize"]),kr=/^incompatible types: (bad return type in lambda expression|unexpected return value|lambda body is not compatible with a void functional interface|missing return value)/,en=i=>i.length?i.map($).join(","):"no arguments";function Ra(i,t,e){if(!nt(i)){let n=e?qt(i):null;return n!==null&&Ra(n,t,!1)}return!t||t.tag==="object"?!0:i.tag==="array"?!1:t.tag==="library"&&t.symbol.isInterface||i.tag==="library"&&i.symbol.isInterface||i.tag==="class"&&i.symbol.isInterface?!0:K(W(i),W(t))||K(W(t),W(i))}function sl(i,t){let e=[];for(let o=0;o<i.length;){let c=o;for(;c<i.length&&i[c].owner===i[o].owner;)c++;e.push(...i.slice(o,c).reverse()),o=c}let n=(o,c)=>t(o,c)&&!t(c,o),s=e[0],r=null;for(let o of e.slice(1)){if(!r){n(o,s)?s=o:t(s,o)||(r=[s,o]);continue}r.every(c=>n(o,c))?(s=o,r=null):r.every(c=>n(c,o))||r.unshift(o)}let a=(r??i.slice(0,2)).slice().reverse();return[a[0],a[1]]}var Ta=[gt,Ce,V,Jt,kt,ft,ee(Ce),mt,G];function rl(i){return(i==="println"?[[],...Ta.map(e=>[e])]:Ta.map(e=>[e])).map(e=>({owner:"PrintStream",name:i,params:e,returnType:xt}))}var Qn={length:{owner:"String",name:"length",params:[],returnType:V},charAt:{owner:"String",name:"charAt",params:[V],returnType:Ce},equals:{owner:"String",name:"equals",params:[G],returnType:gt},isEmpty:{owner:"String",name:"isEmpty",params:[],returnType:gt},toCharArray:{owner:"String",name:"toCharArray",params:[],returnType:ee(Ce)},compareTo:{owner:"String",name:"compareTo",params:[mt],returnType:V}},$e={toString:{owner:"Object",name:"toString",params:[],returnType:mt,objectMethod:"toString"},hashCode:{owner:"Object",name:"hashCode",params:[],returnType:V,objectMethod:"hashCode"},equals:{owner:"Object",name:"equals",params:[G],returnType:gt,objectMethod:"equals"}},Cr=()=>({all:!1,vars:new Set,unassigned:new Set}),Qt=()=>({all:!0,vars:new Set,unassigned:new Set}),ze=i=>({all:i.all,vars:new Set(i.vars),unassigned:new Set(i.unassigned)});function Ct(i,...t){let e=i;for(let n of t){if(e.all){e=ze(n);continue}if(n.all)continue;let s=new Set;for(let a of e.vars)n.vars.has(a)&&s.add(a);let r=new Set;for(let a of e.unassigned)n.unassigned.has(a)&&r.add(a);e={all:!1,vars:s,unassigned:r}}return e}function il(i,t){if(i.all||t.all)return i.all?ze(t.all?i:t):ze(i);let e=new Set;for(let n of i.unassigned)t.unassigned.has(n)&&e.add(n);return{all:!1,vars:new Set([...i.vars,...t.vars]),unassigned:e}}function In(i,t){return i.all||i.vars.has(t)}function Zn(i,t){return i.all||i.unassigned.has(t)}function Pe(i,t){if(i.all)return i;let e=ze(i);return e.vars.add(t),e.unassigned.delete(t),e}function al(i,t){if(i.all)return i;let e=ze(i);return e.vars.delete(t),e}function xa(i){return i.kind==="LocalVariableDeclaration"?i.declarators[0].pos:i.start}function Q(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}var jt=(i,t)=>i.keywords.some(e=>e.name===t),is=class extends Error{fileName;header;constructor(t,e=!1){super(`needs ${t}`),this.fileName=t,this.header=e}},He=class extends Error{};function Ja(i,t,e={}){let n=e.root??"",s=new Set;for(let r of e.files??[]){if(!r.endsWith(".java")||!r.startsWith(n))continue;let a=r.slice(n.length).split("/").slice(0,-1);a.length&&s.add(a.join("."))}return new Ir(i[0].file,t,e.available??new Set,n,s,e.deferred??new Set).checkUnits(i,e.launch??!0)}var va=(i,t,e)=>({file:i,launch:t,compact:e,pkg:"",programImports:new Map,programOnDemand:[],onDemandOrder:[],programStatic:[],ambiguousImports:new Map,imported:new Set,onDemand:new Set,staticSingle:new Map,staticOnDemand:[],unsupportedStaticSingle:new Map,unsupportedStaticOnDemand:[],unsupportedImports:new Map}),Ir=class{#d;#z=new WeakMap;#It;#rt;#G;#Ot=new Set;#O;#R=!0;#bt=0;#m;#C=[];#W=[];#V=[];get#ut(){return this.#d.file}get#X(){return this.#d.imported}get#r(){return this.#d.onDemand}get#p(){return this.#d.staticSingle}get#s(){return this.#d.staticOnDemand}get#n(){return this.#d.unsupportedStaticSingle}get#S(){return this.#d.unsupportedStaticOnDemand}get#l(){return this.#d.unsupportedImports}#i=[];#D=new Map;#kt=new Map;#E=[];#Y=!1;#A=0;#Q=!1;#u=null;#x;#I=[];#Ct=new Map;#me;get#o(){return this.#me}set#o(t){this.#me=t;let e=t?this.#z.get(t.topLevel):void 0;e&&(this.#d=e)}#b=null;#it=null;#St=null;#$=new Map;#t=!0;#f=[];#c=0;#y=[];#P=!1;#g=!1;#J=null;#ht="";#H=new Map;#Lt=[];#gt=[];#Tt=[];#ee=new Map;#j=[];#st=new Set;#L=new WeakMap;#ne=[];#N=new Map;#Et=new Map;#B=[];#dt=[];#K=new Map;#M=new Map;#Z=0;#F=[];constructor(t,e,n,s="",r=new Set,a=new Set){this.#d=va(t,!0,!1),this.#O=a,this.#It=n,this.#rt=s,this.#G=r,this.#m=e}#e(t,e,n,s){this.#m.error(this.#ut,t,"type",e,n,s)}#at(t,e,n,s){let r=a=>a!==void 0&&a.has(e);for(let a=this.#o??null;a;a=a.outer)if(r(a.suppressed))return;r(this.#x)||this.#I.some(r)||this.#m.warning(this.#ut,t,e,`[${e}] ${n}`,s)}#At(t,e){let n=this.#Ct.get(t);if(n)return n;let s=new Set;this.#Ct.set(t,s);let r=new Set,a={Override:["method"],FunctionalInterface:["type"],SafeVarargs:["method","constructor"],SuppressWarnings:["type","field","method","parameter","constructor","local"],Deprecated:["type","field","method","parameter","constructor","local"]};for(let o of t.annotations??[]){if(!(Object.hasOwn(a,o.name)&&(o.names.length===1?!this.#Gt(o.name):o.names.join(".")===`java.lang.${o.name}`))){o.names.length===1&&!this.#Gt(o.name)&&!An.has(o.name)&&!this.#l.has(o.name)?this.#e(o.namePos,w.cantResolve,"cannot find symbol",[` symbol: class ${o.name}`,` location: class ${this.#o.displayName}`]):this.#a(o.pos,`the annotation @${o.names.join(".")}`,!0);continue}if(r.has(o.name)){this.#e(o.pos,w.syntax,`${o.name} is not a repeatable annotation interface`);continue}if(r.add(o.name),!a[o.name].includes(e)){this.#e(o.pos,w.syntax,"annotation interface not applicable to this kind of declaration");continue}let u=o.args??[];if(o.name==="SuppressWarnings"){let d=u.find(h=>h.name===null||h.name==="value");if(!d||u.some(h=>h!==d)){d?this.#a(o.pos,"elements of @SuppressWarnings other than value"):this.#e(o.pos,w.syntax,"annotation @SuppressWarnings is missing a default value for the element \'value\'");continue}for(let h of d.value.kind==="ElementArray"?d.value.elements:[d.value])h.kind==="Literal"&&(h.literalKind==="string"||h.literalKind==="text-block")?s.add(h.value):h.kind==="Literal"?this.#e(h.pos,w.incompatibleTypes,`incompatible types: ${h.literalKind} cannot be converted to String`):this.#a(h.pos,"@SuppressWarnings values other than string literals")}else o.name==="Deprecated"?u.every(h=>h.name==="since"&&h.value.kind==="Literal"&&h.value.literalKind==="string"||h.name==="forRemoval"&&h.value.kind==="Literal"&&h.value.literalKind==="boolean")||this.#a(o.pos,"these elements of @Deprecated"):u.length&&this.#a(o.pos,`elements of @${o.name}`)}return s}#Jt(t,e){return t.annotations?.find(n=>n.name===e)}#a(t,e,n=!1){this.#e(t,w.unsupported,`${e} ${n?"is":"are"} not supported in this version`)}checkUnits(t,e=!0){let n=t[0].unit;if(this.#Ot=new Set(t.map(h=>h.file.name)),!n.types.length)return this.#m.launchError(this.#ut.name,w.noMain,"no class declared in source file"),null;let s=this.#d,r=[];t.forEach(({unit:h,file:m},p)=>{let k=h.types[0]?.implicit===!0,g=p===0?s:va(m,!1,k);if(g.compact=k,this.#d=g,h.package&&(k?this.#e(h.package.start,w.syntax,"compact source file should not have package declaration"):g.pkg=h.package.names.join(".")),p>0){let T=m.name.slice(this.#rt.length).split("/").slice(0,-1).join(".");if(g.pkg!==T)throw new He(g.pkg?`${m.name} declares package ${g.pkg}, but its folder makes it ${T?`package ${T}`:"the unnamed package"}`:`${m.name} declares no package, but it is in package ${T}\'s folder`)}p>0&&k&&r.push({declaration:h.types[0],file:m});for(let T of h.imports)this.#ot(T);if(k)for(let T of Object.keys(Yn))this.#Vt(T);let O=this.#W.length;for(let T of h.types)this.#jt(T,null);for(let T of this.#W.slice(O))T.file=m,this.#z.set(T,g);if(p>0&&!k){let T=m.name.replace(/^.*\\//,"").replace(/\\.java$/,"");if(!this.#W.slice(O).some(x=>x.name===T))throw new He(`${m.name} does not declare class ${T}, so the launcher cannot find that class there`)}}),this.#d=s;for(let{file:h}of t){let m=this.#W.map(p=>this.#z.get(p)).find(p=>p?.file===h);m&&this.#Ws(m)}this.#d=s,this.#xe();for(let h of this.#C)!h.typeParams||h.local||(this.#o=h,this.#Y=!1,this.#wn(h.typeParams,h.declaration.typeParams));let a=h=>h.anonymous===!0||h.local===!0||h.outer!==null&&a(h.outer);for(let h of this.#C)a(h)||this.#ve(h);this.#Qe(this.#C.filter(h=>!a(h)));for(let h of this.#C)a(h)||this.#le(h);for(let{file:h}of t){let m=this.#W.map(p=>this.#z.get(p)).find(p=>p?.file===h);m?.programStatic.length&&this.#re(m)}this.#d=s,this.#nn();let o=this.#W[0];for(let{declaration:h,file:m}of r){let p=h.symbol;if(this.#o=p,!this.#se(p))return this.#e(h.members[0].start,w.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;throw new He(`${m.name} is a compact source file; only the launched file may be one`)}if(o&&(this.#o=o),o?.declaration.implicit&&!this.#se(o))return this.#e(o.declaration.members[0].start,w.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;this.#R=!1,this.#bt=this.#m.items.length;let c=h=>this.#m.items.some((m,p)=>m.severity==="error"&&(h===null?p<this.#bt||!this.#O.has(m.file):p>=this.#bt&&m.file===h));for(let h of this.#W){this.#He(h);let m=h.file?.name??"";c(this.#O.has(m)?m:null)||this.#ui(h)}let u=new Set;if(this.#m.items.forEach((h,m)=>{m<this.#bt||!this.#O.has(h.file)||(h.deferred=!0,h.severity==="error"&&u.add(h.file))}),c(null)||!o)return null;let d=e?this.#Re(o):{classes:this.#C,mainClass:o,methods:this.#V,staticFields:this.#i,selectors:this.#kt,main:null,mainConstructor:null};return d&&u.size&&(d.failedFiles=[...u]),d}#Re(t){let e=this.#ut.name.replace(/^.*[\\\\/]/,"").replace(/\\.java$/,""),n=this.#se(t)?t:this.#W.find(a=>a.name===e&&a.file===t.file);if(!n)return this.#m.launchError(this.#ut.name,w.noMain,`can\'t find class: ${e}`),null;let s=this.#se(n);if(!s)return this.#m.launchError(this.#ut.name,w.noMain,`can\'t find main(String[]) or main() method in class: ${n.name}`),null;let r=null;return!s.isStatic&&(r=n.constructors.find(a=>a.params.length===0)??null,!r)?(this.#m.launchError(this.#ut.name,w.noMain,`can\'t find no argument constructor in class: ${n.name}`),null):{classes:this.#C,mainClass:n,methods:this.#V,staticFields:this.#i,selectors:this.#kt,main:s,mainConstructor:r}}#se(t){let e=t.methods.filter(n=>this.#xt(n.declaration));return e.find(n=>n.params.length===1)??e.find(n=>n.params.length===0)??null}#xt(t){if(t.isConstructor||t.name!=="main"||t.returnType.kind!=="VoidType"||jt(t.modifiers,"private"))return!1;if(t.params.length===0)return!0;if(t.params.length!==1)return!1;let e=t.params[0].type;return e.kind==="ArrayType"&&this.#Ut(e.element)}#Ut(t){if(t.kind!=="ClassType"||t.hasTypeArguments)return!1;let e=t.names.join(".");return e==="String"||e==="java.lang.String"}#ot(t){if(t.isStatic)return this.#Bt(t);let e=t.names,n=t.onDemand?e.join("."):e.slice(0,-1).join("."),s=e[e.length-1];if(t.onDemand&&!this.#d.onDemandOrder.includes(n)&&this.#d.onDemandOrder.push(n),t.onDemand&&this.#G.has(n)){this.#d.programOnDemand.includes(n)||this.#d.programOnDemand.push(n);return}let r=t.onDemand?e.length>1?t.dots[e.length-2]:t.firstPos:t.lastDotPos,a=this.#in(t.onDemand?[...e,"*"]:e);if(a){if(t.onDemand){this.#Dt(e.slice(0,a).join("."),e[a])?this.#a(t.start,"on-demand imports of a class\'s member types"):this.#e(r,w.cantResolve,`package ${n} does not exist`);return}let u=e.slice(0,a).join("."),d={pkg:u,names:e.slice(a),pos:t.lastDotPos,start:t.start};if(!(this.#Ot.has(`${this.#rt}${u.replaceAll(".","/")}/${e[a]}.java`)||this.#Dt(u,e[a]))){this.#e(t.dots[a-1]??t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${e[a]}`,` location: package ${u}`]);return}let p=this.#d.programImports.get(s);if(p&&(p.pkg!==d.pkg||p.names.join(".")!==d.names.join("."))){this.#e(t.start,w.alreadyDefined,`a type with the same simple name is already defined by the single-type-import of ${s}`),this.#d.ambiguousImports.set(s,[[p.pkg,...p.names].join("."),e.join(".")]);return}this.#d.programImports.set(s,d);return}let o=t.onDemand?e[e.length-1]:e[e.length-2],c=e.slice(0,t.onDemand?-1:-2).join(".");if(It[o]===c&&!Mt[o]){for(let[u,d]of Object.entries(Mt))d===o&&(t.onDemand||u===s)&&this.#X.add(u);if(t.onDemand||Mt[s]===o)return}if(!Ns.has(n)){this.#e(r,w.cantResolve,`package ${n} does not exist`);return}if(t.onDemand){this.#r.add(n),this.#Vt(n);return}if(It[s]===n&&!Mt[s]||En.some(u=>u.name===`${n}.${s}`)){this.#X.add(s);return}if(n==="java.util"&&!Ma.has(s)){this.#e(t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: package ${n}`]);return}this.#l.set(s,`${n}.${s}`)}#Bt(t){let e=t.names,n=t.onDemand?e:e.slice(0,-1),s=this.#in([...n,""]);if(s){let c=n.slice(0,s).join("."),u=this.#Ot.has(`${this.#rt}${c.replaceAll(".","/")}/${n[s]}.java`);if(s===n.length||!u&&!this.#Dt(c,n[s])){this.#e(t.dots[s-1]??t.lastDotPos,w.cantResolve,"cannot find symbol",[` symbol: class ${n[s]??e[e.length-1]}`,` location: package ${c}`]);return}this.#d.programStatic.push({pkg:c,names:n.slice(s),member:t.onDemand?null:e[e.length-1],pos:t.dots[n.length-1]??t.lastDotPos,start:t.start});return}let r=this.#Kt(t,n);if(typeof r=="object"&&r!==null){t.onDemand?this.#S.push(r.unsupported):this.#n.set(e[e.length-1],r.unsupported);return}if(r===null){t.onDemand||this.#e(t.start,w.cantResolve,"static import only from classes and interfaces");return}if(t.onDemand){this.#s.includes(r)||this.#s.push(r);for(let[c,u]of Object.entries(Mt))u===r&&this.#X.add(c);return}let a=e[e.length-1],o=Mt[a]===r;if(o&&this.#X.add(a),this.#tt(r,a)||this.#Nt(r,a)){let c=this.#p.get(a)??[];c.includes(r)||c.push(r),this.#p.set(a,c)}else if(!o){let c=this.#et(r)?.isInterface?"interface":"class";this.#e(t.start,w.cantResolve,"cannot find symbol",[` symbol: static ${a}`,` location: ${c} ${r}`])}}#Kt(t,e){let n=e[e.length-1],s=e.slice(0,-1).join("."),r=t.dots[e.length-2]??t.start,a=e[e.length-2];return a&&Mt[n]===a&&It[a]===e.slice(0,-2).join(".")||s==="java.lang"&&(n==="Math"||n==="System"||n==="String")||It[n]===s&&!Mt[n]?n:Ns.has(s)&&((s==="java.lang"?An.has(n):(Yn[s]??[]).includes(n))||En.some(c=>c.name===`${s}.${n}`))?{unsupported:`${s}.${n}`}:(Ns.has(s)||[...Ns].some(o=>o.startsWith(`${s}.`))?this.#e(r,w.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: package ${s}`]):this.#e(r,w.cantResolve,`package ${s} does not exist`),null)}#et(t){return t==="Math"||t==="String"||t==="System"?te(t):Wt(t)??null}#tt(t,e){if(t==="Math"&&Object.hasOwn(Wn,e))return!0;if(t==="System")return ma.has(e);let n=this.#et(t);return n?n.methods.some(s=>s.isStatic&&s.name===e)||t!=="String"&&n.unsupported.has(e):!1}#Nt(t,e){if(t==="System")return e==="out"||e==="err"||e==="in";if(Object.hasOwn(Ls,t)&&Object.hasOwn(Ls[t],e))return!0;if(t==="Math"||t==="String")return!1;let n=this.#et(t)?.staticFields;return n!==void 0&&Object.hasOwn(n,e)}#h(t,e){let n=(this.#p.get(t)??[]).filter(s=>e.call(this,s,t));return n.length?n:this.#s.filter(s=>e.call(this,s,t))}#fe(t,e){let n=this.#n.get(t)??this.#S[0];return n?(this.#a(e,`the class ${n}`,!0),!0):!1}#pe(t){for(let e=this.#o;e;e=e.outer)if(this.#wt(e,t).length)return!0;return Object.hasOwn($e,t)||$s.has(t)}#vt(t,e){return typeof t!="string"?{kind:"Name",identifier:t.name,depth:1,pos:e.pos,start:e.start,end:e.end,staticOwner:!0,staticClass:t}:{kind:"Name",identifier:t,depth:1,pos:e.pos,start:e.start,end:e.end,staticOwner:!0}}#ye(t,e){let n=a=>e==="method"?this.#wt(a,t).some(o=>o.isStatic):this.#Ee(a,t)?.isStatic===!0,s=a=>{let o=[];for(let c of this.#d.programStatic){if(c.member!==null!==a||a&&c.member!==t)continue;let u=this.#rn(c);u&&n(u)&&!o.includes(u)&&o.push(u)}return o},r=s(!0);return r.length?r:s(!1)}#re(t){this.#d=t;for(let e of t.programStatic){let n=this.#rn(e);if(!n)continue;if(n.topLevel.packageName!==t.pkg&&!n.topLevel.isPublic){this.#e(e.pos,w.cantResolve,`${n.topLevel.name} is not public in ${n.topLevel.packageName}; cannot be accessed from outside package`);continue}if(e.member===null)continue;this.#wt(n,e.member).some(r=>r.isStatic)||this.#Ee(n,e.member)?.isStatic===!0||n.membersByName.has(e.member)||this.#e(e.start,w.cantResolve,"cannot find symbol",[` symbol: static ${e.member}`,` location: ${n.isInterface?"interface":"class"} ${n.displayName}`])}}#ie(t,e){if(this.#pe(t.name))return!0;let n=this.#ye(t.name,"method");if(n.length)return t.target=this.#vt(n[0],{pos:t.selectPos,start:t.start,end:t.start}),!0;let s=this.#h(t.name,this.#tt);if(s.length>1){let r=this.#ge(t,s,e);if(!r)return!1;s=[r]}return s.length===1&&(t.target=this.#vt(s[0],{pos:t.selectPos,start:t.start,end:t.start})),!0}#ge(t,e,n){let s=e.flatMap(d=>this.#qt(d,t.name).map(h=>({owner:d,...h}))),r=s.filter(d=>this.#w(d,n,!0)),a=r.length?r:s.filter(d=>this.#w(d,n,!1));if(!a.length)return e.find(d=>this.#qt(d,t.name).some(h=>h.params.length===n.length))??e[0];let o=(d,h)=>d.params.length===h.params.length&&d.params.every((m,p)=>Ze(W(h.params[p]),W(m))),c=a.filter(d=>a.every(h=>d===h||o(d,h))),u=[...new Set(c.map(d=>d.owner))];if(u.length===1)return u[0];if(c.length>=2&&!c.some(d=>d.varargs)){let[d,h]=c,m=p=>`method ${t.name}(${p.params.map($).join(",")}) in ${p.owner}`;return this.#e(t.selectPos,w.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${m(d)} and ${m(h)} match`]),null}return this.#a(t.selectPos,`a call of ${t.name}(), which more than one static import could mean`,!0),null}#qt(t,e){let n=[];if(t==="Math"&&Object.hasOwn(Wn,e))for(let r of Wn[e])n.push({params:r.params,varargs:!1});let s=t==="System"?null:this.#et(t);for(let r of s?.methods??[])r.isStatic&&r.name===e&&n.push({params:r.params,varargs:r.varargs===!0});return n}#w(t,e,n=!1){let{params:s,varargs:r}=t;if(n&&r&&e.length!==s.length)return!1;let a=r?s.length-1:s.length;return(r?e.length<a:e.length!==a)?!1:e.every((o,c)=>{if(o.tag==="lambda"||o.tag==="diamond")return!0;let u=c<a||r&&e.length===s.length&&o.tag==="array"?s[c]:s[a].element;return n?Ze(W(u),o):Ht(W(u),o)})}#be(t){let e=this.#ye(t.identifier,"field");if(e.length)return{kind:"FieldAccess",target:this.#vt(e[0],t),name:t.identifier,namePos:t.pos,depth:2,pos:t.pos,start:t.start,end:t.end};let n=this.#h(t.identifier,this.#Nt);return n.length?n.length>1?(this.#e(t.pos,w.cantResolve,`reference to ${t.identifier} is ambiguous`,[` both variable ${t.identifier} in ${n[1]} and variable ${t.identifier} in ${n[0]} match`]),"error"):{kind:"FieldAccess",target:this.#vt(n[0],t),name:t.identifier,namePos:t.pos,depth:2,pos:t.pos,start:t.start,end:t.end}:null}#Vt(t){for(let e of Yn[t]??[])It[e]||En.some(n=>n.name===`${t}.${e}`)||this.#l.has(e)||this.#l.set(e,`${t}.${e}`)}#mt(t){let e;if(t.length===1){e=t[0];let n=It[e];if(!n||!(Mt[e]?this.#X.has(e):n==="java.lang"||this.#X.has(e)||this.#r.has(n)||this.#d.compact))return null}else if(t.length>=3&&t[0]==="java"&&It[t[t.length-1]]===t.slice(0,-1).join(".")&&!Mt[t[t.length-1]])e=t[t.length-1];else if(t.length===2&&Mt[t[1]]===t[0]&&this.#mt([t[0]]))e=t[1];else if(t.length===4&&t[0]==="java"&&Mt[t[3]]===t[2]&&It[t[2]]===`java.${t[1]}`)e=t[3];else return null;return Wt(e)??null}#jt(t,e){let n=t.modifiers,s=t.keyword==="interface",r=t.keyword==="enum",a=t.keyword==="record";for(let u of n.keywords)if(u.name!=="public"&&!(u.name==="abstract"&&!r&&!a)&&!(u.name==="final"&&!s&&!r)){if(u.name==="sealed"||u.name==="non-sealed"){if(!r&&!a)continue;this.#e(u.pos,w.syntax,`\'${u.name}\' is not allowed here`);continue}e&&["private","protected","static"].includes(u.name)||(u.name==="strictfp"?this.#a(u.pos,`\'strictfp\' ${s?"interfaces":"classes"}`):this.#e(t.keywordPos,w.syntax,`modifier ${u.name} not allowed here`))}if(e){if(e.membersByName.has(t.name)){this.#e(t.keywordPos,w.alreadyDefined,`class ${t.name} is already defined in class ${e.displayName}`);return}}else if(this.#W.some(u=>u.name===t.name&&u.packageName===this.#d.pkg)){this.#e(t.keywordPos,w.alreadyDefined,`duplicate class: ${this.#d.pkg?`${this.#d.pkg}.`:""}${t.name}`);return}let o=e?e.packageName:this.#d.pkg,c={kind:"class",name:t.name,binaryName:e?`${e.binaryName}$${t.name}`:o?`${o}.${t.name}`:t.name,packageName:o,isPublic:jt(n,"public")||e?.isInterface===!0,displayName:e?.topLevel.declaration.implicit?`${e.displayName}.${t.name}`:t.name,declaration:t,outer:e,topLevel:null,isInner:e!==null&&t.keyword==="class"&&!e.isInterface&&!jt(n,"static"),isPrivate:jt(n,"private"),isInterface:s,isAbstract:s||jt(n,"abstract"),isFinal:r&&!t.enumConstants?.some(u=>u.body)||a||jt(n,"final"),...jt(n,"sealed")?{isSealed:!0}:{},...jt(n,"non-sealed")?{isNonSealed:!0}:{},isEnum:r,isRecord:a,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:0,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1};if(c.topLevel=e?e.topLevel:c,t.typeParams?.length){let u=a?"record":s?"interface":"class";c.typeParams=this.#vn(t.typeParams,`${u} ${c.displayName}`,c)}t.symbol=c,this.#C.push(c),e?(e.members.push(c),e.membersByName.set(c.name,c)):this.#W.push(c);for(let u of t.members)u.kind==="ClassDeclaration"&&this.#jt(u,c);this.#Se(c)}#Se(t){let e=[],n=0,s=new Map,r=(a,o)=>{if(Array.isArray(a)){for(let u of a)r(u,o);return}if(a===null||typeof a!="object")return;let c=a;if(c.kind!=="ClassDeclaration"){if(c.kind==="NewObject"&&c.body){r(c.args,o);let u=c.body,d=this.#ae(t,u,++n,o);e.push(d);return}if(c.kind==="LocalClass"){let u=c.declaration,d=(s.get(u.name)??0)+1;s.set(u.name,d),e.push(this.#Te(t,u,d,o));return}for(let[u,d]of Object.entries(c))u!=="symbol"&&d&&typeof d=="object"&&r(d,o)}};for(let a of t.declaration.enumConstants??[])if(r(a.args,!0),a.body){let o=this.#ae(t,a.body,++n,!0);o.enumBody=!0,e.push(o)}for(let a of t.declaration.members){if(a.kind==="ClassDeclaration")continue;let o=jt(a.modifiers,"static")||t.isInterface&&a.kind==="FieldDeclaration";r(a,o)}e.length&&(t.anonymousClasses=e)}#Te(t,e,n,s){let r=e.keyword;for(let c of e.modifiers.keywords)c.name!=="abstract"&&c.name!=="final"&&c.name!=="strictfp"&&this.#e(e.keywordPos,w.syntax,`modifier ${c.name} not allowed here`);let a=this.#ae(t,e,0,s||r!=="class"),o=`${t.binaryName}$${n}${e.name}`;return Object.assign(a,{name:e.name,binaryName:o,displayName:e.name,anonymous:!1,local:!0,isInterface:r==="interface",isEnum:r==="enum",isRecord:r==="record",isAbstract:r==="interface"||jt(e.modifiers,"abstract"),isFinal:r==="enum"||r==="record"||jt(e.modifiers,"final")}),e.typeParams?.length&&(a.typeParams=this.#vn(e.typeParams,`${r==="record"?"record":r==="interface"?"interface":"class"} ${e.name}`,a)),a}#ae(t,e,n,s){let r=`${t.binaryName}$${n}`,a={kind:"class",name:"",binaryName:r,displayName:`<anonymous ${r}>`,packageName:t.packageName,isPublic:!1,declaration:e,outer:t,topLevel:t.topLevel,isInner:!s,isPrivate:!1,isInterface:!1,isAbstract:!1,isFinal:!1,isEnum:!1,isRecord:!1,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:0,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1,anonymous:!0};e.symbol=a,this.#C.push(a);for(let o of e.members)o.kind==="ClassDeclaration"&&this.#jt(o,a);return this.#Se(a),a}#xe(){let t=(o,c)=>{let{pkg:u,simple:d}=da(o),h={kind:"ClassDeclaration",keyword:c?"interface":"class",extendsTypes:[],implementsTypes:[],modifiers:{keywords:[]},name:d,namePos:0,keywordPos:0,members:[],pos:0,start:0,end:0},m={kind:"class",name:d,binaryName:o,displayName:d,packageName:o.slice(0,o.lastIndexOf(".")),isPublic:!0,declaration:h,outer:null,topLevel:null,isInner:!1,isPrivate:!1,isInterface:c,isAbstract:c,isFinal:!1,isEnum:!1,isRecord:!1,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:2,index:this.#C.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:c?0:ha,outerField:-1,membersEntered:!0,builtin:{pkg:u}};return m.topLevel=m,h.symbol=m,this.#C.push(m),this.#D.set(o,m),m};for(let o of En){let c=t(o.name,!1);c.superclass=o.superclass?this.#D.get(o.superclass):null,o.indexPrefix&&(c.builtin.indexPrefix=o.indexPrefix)}let e=this.#D.get("java.lang.Throwable"),n=tt(e);this.#_(e,"getMessage",[],mt,"throwable-getMessage"),this.#_(e,"getLocalizedMessage",[],mt,"throwable-getLocalizedMessage"),this.#_(e,"getCause",[],n,"throwable-getCause"),this.#_(e,"initCause",[n],n,"throwable-initCause"),this.#_(e,"toString",[],mt,"throwable-toString"),this.#_(e,"printStackTrace",[],xt,"throwable-printStackTrace"),this.#_(e,"addSuppressed",[n],xt,"throwable-addSuppressed",{isFinal:!0}),this.#_(e,"getSuppressed",[],ee(n),"throwable-getSuppressed",{isFinal:!0}),this.#_(e,"fillInStackTrace",[],n,"throwable-fillInStackTrace");let s={none:[],message:[mt],"message-cause":[mt,n],cause:[n],index:[V],object:[G]};for(let o of En){let c=this.#D.get(o.name);for(let u of o.constructors){let d=this.#_(c,c.name,s[u],xt,"throwable-constructor",{isConstructor:!0});d.throwableConstructor=u}}let r=t("java.lang.AutoCloseable",!0),a=this.#_(r,"close",[],xt,void 0,{throws:[tt(this.#D.get("java.lang.Exception"))]});a.isAbstract=!0,delete a.builtin}#Ye(t){if(t.length>1)return this.#D.get(t.join("."))??null;for(let e of this.#D.values()){if(e.name!==t[0])continue;let n=e.builtin.pkg;return n==="java.lang"||this.#X.has(e.name)||this.#r.has(n)||this.#d.compact?e:null}return null}#Wt(){return tt(this.#D.get("java.lang.Throwable"))}#oe(t){return t.tag==="null"||K(t,this.#Wt())}#Xt(t){return t.tag==="class"&&this.#oe(t)&&!K(t,tt(this.#D.get("java.lang.RuntimeException")))&&!K(t,tt(this.#D.get("java.lang.Error")))}#ve(t){if(t.hierarchyState!==0)return;t.hierarchyState=1;let e=this.#o;this.#o=t,this.#Y=!1,this.#E=[];let n=t.declaration,s=t.isInterface?[]:n.extendsTypes.slice(0,1);for(let a of s){let o=this.#tn(a);if(!o||o.tag==="object")continue;if(o.tag==="string"){this.#e(a.pos,w.syntax,"cannot inherit from final String");continue}if(o.tag==="library"){o.symbol.isInterface?this.#e(a.pos,w.syntax,"no interface expected here"):ga.has(o.symbol.name)?t.librarySuperclass=o:this.#a(a.pos,`extending the library class ${o.symbol.name}`,!0);continue}if(o.tag!=="class")continue;let c=o.symbol;if(c.isInterface){this.#e(a.pos,w.syntax,"no interface expected here");continue}if(c.hierarchyState===1||c===t){this.#e(this.#we(t).declaration.keywordPos,w.syntax,`cyclic inheritance involving ${this.#we(t).displayName}`);continue}if(this.#ve(c),c.isFinal){this.#e(a.pos,w.syntax,`cannot inherit from final ${c.displayName}`);continue}if(c.isInner){this.#a(a.pos,"extending an inner (non-static) class",!0);continue}t.superclass=c,t.superType=o}let r=t.isInterface?n.extendsTypes:n.implementsTypes;for(let a of r){let o=this.#tn(a);if(!o)continue;if(o.tag==="library"){o.symbol.isInterface?Sa(o.symbol)?t.libraryInterfaces.push(o):this.#a(a.pos,`implementing the library interface ${o.symbol.name}`,!0):this.#e(a.pos,w.syntax,"interface expected here");continue}if(o.tag!=="class"||!o.symbol.isInterface){o.tag!=="error"&&this.#e(a.pos,w.syntax,"interface expected here");continue}let c=o.symbol;if(c.hierarchyState===1||c===t){this.#e(this.#we(t).declaration.keywordPos,w.syntax,`cyclic inheritance involving ${this.#we(t).displayName}`);continue}this.#ve(c),t.interfaces.includes(c)||(t.interfaces.push(c),(t.interfaceTypes??=[]).push(o))}this.#o=e,t.hierarchyState=2}#Qe(t){let e=r=>r.binaryName.replace(/\\$/g,"."),n=r=>r.isInterface?"interface":"class",s=r=>[...r.superclass?[r.superclass]:[],...r.interfaces];for(let r of t){let a=r.declaration;if(r.isSealed&&r.isFinal&&!r.isEnum&&!r.isRecord){this.#e(a.keywordPos,w.syntax,"illegal combination of modifiers: final and sealed");continue}if(r.isSealed&&r.isNonSealed){this.#e(a.keywordPos,w.syntax,"illegal combination of modifiers: sealed and non-sealed");continue}if(r.isNonSealed&&!r.isFinal&&!s(r).some(c=>c.isSealed)&&this.#e(a.keywordPos,w.syntax,"non-sealed modifier not allowed here",[` (${n(r)} ${e(r)} does not have any sealed supertypes)`]),!r.isSealed)continue;let o=a.permits;if(o){let c=[];this.#o=r.outer??r;for(let u of o){let d=this.#U(u);if(d.tag!=="class")continue;let h=d.symbol;if(c.includes(h)){this.#e(u.pos,w.syntax,"invalid permits clause",[` (must not contain duplicates: ${$(d)})`]);continue}c.push(h),s(h).includes(r)||this.#e(u.pos,w.syntax,"invalid permits clause",[` (${n(h)} ${$(d)} must extend sealed ${n(r)})`])}r.permitted=c}else r.permitted=t.filter(c=>s(c).includes(r)),r.permitted.length||this.#e(a.keywordPos,w.syntax,"sealed class must have subclasses")}for(let r of t){let a=s(r).filter(c=>c.isSealed);if(!a.length)continue;let o=a.find(c=>c.declaration.permits&&!(c.permitted??[]).includes(r));if(o){this.#e(r.declaration.keywordPos,w.syntax,`class is not allowed to extend sealed class: ${o.displayName} (as it is not listed in its \'permits\' clause)`);continue}!r.isFinal&&!r.isSealed&&!r.isNonSealed&&this.#e(r.declaration.keywordPos,w.syntax,"sealed, non-sealed or final modifiers expected")}}#Ze(t){[...t.superclass?[t.superclass]:[],...t.interfaces].some(n=>n.isSealed)&&this.#e(t.declaration.keywordPos,w.syntax,`${t.anonymous?"anonymous":"local"} classes must not extend sealed classes`)}#we(t){return this.#C.filter(n=>n.hierarchyState===1).reduce((n,s)=>n.declaration.keywordPos<=s.declaration.keywordPos?n:s,t)}#tn(t){if(t.kind!=="ClassType")return this.#e(t.pos,w.syntax,"unexpected type"),null;let e=this.#U(t);return e.tag==="error"?null:e}#le(t){if(t.membersEntered)return;t.membersEntered=!0,t.superclass&&this.#le(t.superclass);let e=this.#o;this.#o=t,t.instanceCount=t.superclass?.instanceCount??0,t.isInner&&(t.outerField=t.instanceCount++),t.isEnum&&(t.instanceCount=2,this.#en(t)),t.isRecord&&this.#Ls(t);for(let a of t.declaration.members)a.kind==="FieldDeclaration"?this.#Ms(t,a):a.kind==="MethodDeclaration"&&this.#Rs(t,a);t.isRecord?t.constructors.some(a=>this.#Fn(t,a))||this.#_(t,t.name,t.components.map(a=>a.type),xt,"record-constructor",{isConstructor:!0}):!t.isInterface&&!t.anonymous&&!t.declaration.members.some(a=>a.kind==="MethodDeclaration"&&a.isConstructor)&&this.#Js(t),t.isEnum&&this.#Ns(t),t.isRecord&&this.#Ps(t),t.librarySuperclass&&this.#$s(t);let n=t.methodsByName.get("toString")?.find(a=>!a.isStatic&&a.params.length===0&&a.returnType.tag==="string");n&&(t.toStringMethod=n);let s=t.methodsByName.get("equals")?.find(a=>!a.isStatic&&a.params.length===1&&a.params[0].tag==="object"&&a.returnType.tag==="boolean");s&&(t.equalsMethod=s);let r=t.methodsByName.get("hashCode")?.find(a=>!a.isStatic&&a.params.length===0&&a.returnType.tag==="int");r&&(t.hashCodeMethod=r),this.#o=e}#en(t){let e=tt(t);(t.declaration.enumConstants??[]).forEach((s,r)=>{if(t.fieldsByName.has(s.name)){this.#e(s.pos,w.alreadyDefined,`variable ${s.name} is already defined in enum ${t.displayName}`);return}let a={name:s.name,extraDims:0,init:null,pos:s.pos,start:s.start,end:s.end},o={kind:"FieldDeclaration",modifiers:{keywords:[]},type:{kind:"VoidType",pos:s.pos,start:s.pos,end:s.pos},declarators:[a],pos:s.pos,start:s.start,end:s.end},c={kind:"field",name:s.name,type:e,owner:t,isStatic:!0,isFinal:!0,isPrivate:!1,access:"public",index:this.#i.length,order:t.fields.length,state:"done",declaration:o,declarator:a,enumConstant:{node:s,ordinal:r}};this.#i.push(c),s.field=c,t.fields.push(c),t.fieldsByName.set(c.name,c),t.enumConstants.push(c)})}#Ls(t){for(let e of t.declaration.components??[]){let n=this.#U(e.type);if(n.tag==="error")continue;if(t.fieldsByName.has(e.name)){this.#e(e.pos,w.alreadyDefined,`record component ${e.name} is already defined in record ${t.displayName}`);continue}let s={name:e.name,extraDims:0,init:null,pos:e.pos,start:e.start,end:e.end},r={kind:"FieldDeclaration",modifiers:{keywords:[{name:"private",pos:e.pos},{name:"final",pos:e.pos}]},type:e.type,declarators:[s],pos:e.pos,start:e.start,end:e.end},a={kind:"field",name:e.name,type:n,owner:t,isStatic:!1,isFinal:!0,isPrivate:!0,access:"private",index:t.instanceCount++,order:t.fields.length,state:"done",declaration:r,declarator:s};s.field=a,t.fields.push(a),t.fieldsByName.set(a.name,a),t.components.push(a)}}#Fn(t,e){return e.isConstructor&&(e.declaration.compact===!0||e.params.length===t.components.length&&e.params.every((n,s)=>at(n,t.components[s].type)))}#_(t,e,n,s,r,a={}){let o=t.declaration.keywordPos,c={kind:"MethodDeclaration",modifiers:{keywords:[]},returnType:{kind:"VoidType",pos:o,start:o,end:o},name:e,namePos:o,params:[],body:{kind:"Block",statements:[],pos:o,start:o,end:o+1},synthetic:!0,pos:o,start:o,end:o};a.isConstructor&&(c.isConstructor=!0);let u={kind:"method",name:e,owner:t,isStatic:a.isStatic??!1,isConstructor:a.isConstructor??!1,isPrivate:!1,isAbstract:!1,isFinal:a.isFinal??!1,access:a.isConstructor&&t.isEnum?"private":"public",params:n,returnType:s,index:this.#V.length,declaration:c,locals:[],maxSlots:(a.isStatic?0:1)+n.reduce((d,h)=>d+Be(h),0),builtin:r,throws:a.throws??[]};return a.component!==void 0&&(u.component=a.component),c.symbol=u,this.#V.push(u),u.isConstructor?t.constructors.push(u):(t.methods.push(u),t.methodsByName.set(e,[...t.methodsByName.get(e)??[],u])),u}#$t(t,e,n){return(t.methodsByName.get(e)??[]).some(s=>s.params.length===n.length&&s.params.every((r,a)=>at(r,n[a])))}#Ns(t){let e=tt(t);this.#$t(t,"values",[])||this.#_(t,"values",[],ee(e),"enum-values",{isStatic:!0}),this.#$t(t,"valueOf",[mt])||this.#_(t,"valueOf",[mt],e,"enum-valueOf",{isStatic:!0}),this.#$t(t,"name",[])||this.#_(t,"name",[],mt,"enum-name",{isFinal:!0}),this.#$t(t,"ordinal",[])||this.#_(t,"ordinal",[],V,"enum-ordinal",{isFinal:!0}),this.#$t(t,"compareTo",[e])||this.#_(t,"compareTo",[e],V,"enum-compareTo",{isFinal:!0}),this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"enum-toString")}#$s(t){this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"library-toString"),this.#$t(t,"hashCode",[])||this.#_(t,"hashCode",[],V,"library-hashCode"),this.#$t(t,"equals",[G])||this.#_(t,"equals",[G],gt,"library-equals")}#Ps(t){t.components.forEach((e,n)=>{(t.methodsByName.get(e.name)??[]).find(r=>r.params.length===0)||this.#_(t,e.name,[],e.type,"record-accessor",{component:n})}),this.#$t(t,"toString",[])||this.#_(t,"toString",[],mt,"record-toString"),this.#$t(t,"hashCode",[])||this.#_(t,"hashCode",[],V,"record-hashCode"),this.#$t(t,"equals",[G])||this.#_(t,"equals",[G],gt,"record-equals")}#nn(t=this.#V){for(let e of t)e.selector===void 0&&(e.isStatic||e.isConstructor||e.isPrivate||e.lambda||(e.selector=this.#_n(ts(e.name,e.params,e.returnType))))}#_n(t){let e=this.#kt.get(t);return e===void 0&&this.#kt.set(t,e=this.#kt.size),e}#Ms(t,e){let n=e.modifiers.keywords.map(d=>d.name),s=this.#At(e.modifiers,"field");for(let d of e.modifiers.keywords){if(d.name==="transient"||d.name==="volatile"){this.#a(d.pos,`\'${d.name}\' fields`);return}if(["abstract","synchronized","native","strictfp","default"].includes(d.name)){this.#e(e.declarators[0].pos,w.syntax,`modifier ${d.name} not allowed here`);return}}let r=e.type;if(r.kind==="VarType"||r.kind==="ClassType"&&r.names.length===1&&r.names[0]==="var"&&!r.hasTypeArguments&&!this.#Gt("var")){this.#e(r.pos,w.syntax,"\'var\' is not allowed here");return}if(t.isInterface&&(n.includes("private")||n.includes("protected"))){this.#e(e.declarators[0].pos,w.syntax,`modifier ${n.includes("private")?"private":"protected"} not allowed here`);return}if(t.isRecord&&!n.includes("static")){this.#e(e.declarators[0].pos,w.syntax,"field declaration must be static",[" (consider replacing field with record component)"]);return}let a=t.isInterface||n.includes("static"),o=t.isInterface||n.includes("final");if(t.isInterface&&e.declarators.some(d=>!d.init)){let d=e.declarators.find(h=>!h.init);this.#e(d.end,w.syntax,"= expected");return}let c=this.#E;this.#Y=a,t.anonymous||(this.#E=[]);let u=this.#U(e.type);this.#Y=!1,this.#E=c;for(let d of e.declarators){let h=u;for(let p=0;p<d.extraDims&&h.tag!=="error";p++)h=ee(h);if(h.tag==="error")continue;if(t.fieldsByName.has(d.name)){this.#e(d.pos,w.alreadyDefined,`variable ${d.name} is already defined in class ${t.displayName}`);continue}let m={kind:"field",name:d.name,type:h,owner:t,isStatic:a,isFinal:o,isPrivate:n.includes("private"),access:n.includes("private")?"private":n.includes("public")||t.isInterface?"public":n.includes("protected")?"protected":"package",index:a?this.#i.length:t.instanceCount++,order:t.fields.length,state:"pending",declaration:e,declarator:d,...s.size?{suppressed:s}:{}};a&&this.#i.push(m),d.field=m,t.fields.push(m),t.fieldsByName.set(m.name,m)}}#Rs(t,e){let n=e.isConstructor===!0;for(let v of e.modifiers.keywords){if(n&&["static","final","abstract","native","synchronized","strictfp","default","transient","volatile"].includes(v.name)){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}if(["strictfp","native"].includes(v.name)){this.#a(v.pos,`\'${v.name}\' methods`);return}if(v.name==="default"&&!t.isInterface||v.name==="synchronized"&&t.isInterface||v.name==="transient"||v.name==="volatile"){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}if(t.isInterface&&(v.name==="protected"||v.name==="final")){this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`);return}}let s=this.#At(e.modifiers,n?"constructor":"method");if(e.compact){if(!t.isRecord){this.#e(e.namePos,w.syntax,"invalid method declaration; return type required");return}e.params=(t.declaration.components??[]).map(v=>({...v,symbol:void 0}))}if(n&&e.typeParams?.length){this.#a(e.typeParams[0].pos,"generic constructors");return}let r=this.#E;this.#Y=jt(e.modifiers,"static");let a=e.typeParams?.length?this.#vn(e.typeParams,"",null):void 0;a&&this.#wn(a,e.typeParams),this.#E=a?[...r,a]:r;let o=e.params.map(v=>this.#U(v.type)),c=e.returnType.kind==="VoidType"?xt:this.#U(e.returnType),u=[],d=!0;for(let v of e.throwsTypes??[]){let R=this.#U(v);if(R.tag==="error"){d=!1;break}if(!this.#oe(R)){this.#q(v,R,this.#Wt()),d=!1;break}u.push(R)}if(this.#E=r,this.#Y=!1,o.some(v=>v.tag==="error")||c.tag==="error"||!d)return;if(a){let v=e.params.map((R,L)=>R.varargs?`${$(o[L].element)}...`:$(o[L]));for(let R of a)R.declaredIn=`method <${a.map(L=>L.name).join(",")}>${e.name}(${v.join(",")})`}let h=n?t.constructors:t.methodsByName.get(e.name)??[];if(h.some(v=>v.params.length===o.length&&v.params.every((R,L)=>at(R,o[L])))){let v=n?"constructor":"method";this.#e(e.namePos,w.alreadyDefined,`${v} ${e.name}(${o.map($).join(",")}) is already defined in class ${t.displayName}`);return}let m=h.find(v=>ce(v.name,v.params)===ce(e.name,o));if(m){let v=(R,L)=>`${R}(${L.map($).join(",")})`;this.#e(e.namePos,w.alreadyDefined,`name clash: ${v(e.name,o)} and ${v(m.name,m.params)} have the same erasure`,Et([...o,...m.params]));return}if(n&&t.isInterface){this.#e(e.namePos,w.syntax,"invalid method declaration; return type required");return}if(n&&t.isEnum){let v=e.modifiers.keywords.find(R=>R.name==="public"||R.name==="protected");v&&this.#e(e.namePos,w.syntax,`modifier ${v.name} not allowed here`)}let p=v=>jt(e.modifiers,v),k=p("abstract")||t.isInterface&&!p("default")&&!p("static")&&!p("private");if(k&&(p("private")||p("static")||p("final")||p("synchronized"))){let v=p("private")?"private":p("static")?"static":p("final")?"final":"synchronized";this.#e(e.namePos,w.syntax,`illegal combination of modifiers: abstract and ${v}`);return}if(k&&e.body){let v=t.isInterface&&!p("abstract");this.#e(v?e.body.pos:e.namePos,w.syntax,v?"interface abstract methods cannot have body":"abstract methods cannot have a body");return}if(!k&&!e.body){this.#e(e.namePos,w.syntax,"missing method body, or declare abstract");return}let g=p("private")?"private":p("public")||t.isInterface?"public":p("protected")?"protected":"package",O={kind:"method",name:e.name,owner:t,isStatic:p("static"),isConstructor:n,isPrivate:p("private"),isAbstract:k,isFinal:p("final"),access:g,params:o,returnType:c,index:this.#V.length,...a?{typeParams:a}:{},declaration:e,locals:[],maxSlots:0,throws:u,...s.size?{suppressed:s}:{}},T=this.#Jt(e.modifiers,"SafeVarargs");if(T&&!e.params.some(v=>v.varargs))this.#e(e.namePos,w.syntax,`Invalid SafeVarargs annotation. ${n?"Constructor":"Method"} ${e.name}(${o.map($).join(",")}) is not a varargs method.`);else if(T&&!n&&!O.isStatic&&!O.isFinal&&!O.isPrivate){let v=a?`<${a.map(R=>R.name).join(",")}>`:"";this.#e(e.namePos,w.syntax,`Invalid SafeVarargs annotation. Instance method ${v}${this.#Ht(O)} is neither final nor private.`,Et(o))}e.symbol=O,this.#V.push(O),n?t.constructors.push(O):(t.methods.push(O),t.methodsByName.set(e.name,[...h,O]));let x=t.isRecord&&!n&&!O.isStatic&&o.length===0?t.components.find(v=>v.name===e.name):void 0;x&&(at(c,x.type)?g!=="public"&&this.#e(e.namePos,w.syntax,`invalid accessor method in record ${t.displayName}`,[" (accessor method must be public)"]):this.#e(e.namePos,w.syntax,`invalid accessor method in record ${t.displayName}`,[` (return type of accessor method ${e.name}() must match the type of record component ${e.name})`]))}#Js(t){let e=t.declaration.namePos,n={kind:"MethodDeclaration",modifiers:{keywords:t.isPrivate?[{name:"private",pos:e}]:[]},returnType:{kind:"VoidType",pos:e,start:e,end:e},name:t.name,namePos:e,params:[],body:{kind:"Block",statements:[],pos:e,start:e,end:e+1},isConstructor:!0,synthetic:!0,pos:e,start:e,end:e},s={kind:"method",name:t.name,owner:t,isStatic:!1,isConstructor:!0,isPrivate:t.isPrivate,isAbstract:!1,isFinal:!1,access:t.isPrivate?"private":t.isPublic?"public":jt(t.declaration.modifiers,"protected")?"protected":"package",params:[],returnType:xt,index:this.#V.length,declaration:n,locals:[],maxSlots:0,throws:[]};n.symbol=s,this.#V.push(s),t.constructors.push(s)}#Ht(t){let e=t.declaration.params.map((n,s)=>n.varargs?`${$(t.params[s].element)}...`:$(t.params[s]));return`${t.name}(${e.join(",")})`}#ke(){return{method:this.#b,field:this.#it,isStatic:this.#t,scopes:this.#f,nextSlot:this.#c,jumps:this.#y,typeScopes:this.#E,typeStatic:this.#Y,memberSuppressed:this.#x,localSuppressed:this.#I}}#Ce(t){this.#b=t.method,this.#it=t.field,this.#t=t.isStatic,this.#f=t.scopes,this.#c=t.nextSlot,this.#y=t.jumps,this.#E=t.typeScopes,this.#Y=t.typeStatic,this.#x=t.memberSuppressed,this.#I=t.localSuppressed}#He(t){this.#o=t;let e=this.#At(t.declaration.modifiers,"type");e.size&&(t.suppressed=e);let n=this.#Jt(t.declaration.modifiers,"FunctionalInterface");if(n){let s=t.isInterface?ks(t):[];if(s.length!==1){let r=[` ${t.displayName} is not a functional interface`];t.isInterface&&r.push(s.length?` multiple non-overriding abstract methods found in interface ${t.displayName}`:` no abstract method found in interface ${t.displayName}`),this.#e(n.pos,w.syntax,"Unexpected @FunctionalInterface annotation",r)}}this.#Vs(t),t.isEnum&&this.#Fs(t);for(let s of t.declaration.members)if(this.#o=t,s.kind==="FieldDeclaration")for(let r of s.declarators)r.field&&this.#Hn(r.field);else s.kind==="MethodDeclaration"?s.symbol&&this.#_s(s.symbol):s.kind==="Initializer"?this.#js(t,s):s.symbol&&this.#He(s.symbol);this.#o=t,this.#Hs(t)}#js(t,e){if(t.isInterface){this.#e(e.body.pos,w.syntax,"initializers not allowed in interfaces");return}if(t.isRecord&&!e.isStatic){this.#e(e.body.pos,w.syntax,"instance initializers not allowed in records");return}let n=e.isStatic?"static":"new",s={kind:"MethodDeclaration",modifiers:e.modifiers,returnType:{kind:"VoidType",pos:e.pos,start:e.pos,end:e.pos},name:n,namePos:e.pos,params:[],body:e.body,pos:e.pos,start:e.start,end:e.end},r={kind:"method",name:n,owner:t,isStatic:e.isStatic,isConstructor:!1,isPrivate:!0,isAbstract:!1,isFinal:!1,access:"private",params:[],returnType:xt,index:-1,declaration:s,locals:[],maxSlots:0,throws:[],initializer:e.isStatic?"static":"instance"};e.symbol=r;let a=this.#ke(),o=this.#St,c=t.fields.find(u=>!u.enumConstant&&!u.capturedLocal&&u.declarator.pos>e.start);this.#St={owner:t,isStatic:e.isStatic,order:c?c.order:t.fields.length},this.#o=t,this.#b=r,this.#it=null,this.#t=e.isStatic,this.#Y=e.isStatic,this.#E=[],this.#x=void 0,this.#I=[],this.#f=[],this.#c=e.isStatic?0:1,r.maxSlots=this.#c,this.#y=[],this.#Pt();for(let u of e.body.statements)this.#ce(u);this.#Mt(),this.#Ce(a),this.#St=o,this.#o=t}#Ds(t,e,n){t.superclass=e,t.superType=tt(e),t.hierarchyState=2;let s=this.#ke(),r=this.#J,a=this.#g;this.#le(t);let o=this.#cs(t,n);return this.#nn([...t.methods,...t.constructors]),this.#N.set(t,{scopes:[]}),this.#J=null,this.#g=!1,this.#He(t),this.#Ce(s),this.#J=r,this.#g=a,this.#o=e,o}#Fs(t){for(let e of t.enumConstants){let n=e.enumConstant.node,s=this.#ke();this.#b=null,this.#it=e,this.#t=!0,this.#f=[{names:new Map,nextSlot:0}],this.#c=0,this.#y=[];let r=this.#ue(n.args);if(!r.some(a=>a.tag==="error")){let a=this.#ct({pos:n.pos,name:t.name},this.#qe(t),r,"constructor");if(a&&!n.body&&t.enumAbstract)this.#e(n.pos,w.syntax,`${t.displayName} is abstract; cannot be instantiated`);else if(a){this.#de(n.args,a.params),n.ctor=n.body?.symbol?this.#Ds(n.body.symbol,t,a):a.method;let o=this.#_e(a,n.pos);o&&(n.varargs=o)}this.#Fe(n.args)}this.#Ce(s),this.#o=t}}#_s(t){if(t.builtin)return;this.#o=t.owner,this.#b=t,this.#it=null,this.#t=t.isStatic,this.#Y=t.isStatic,this.#E=t.typeParams?[t.typeParams]:[],this.#x=t.suppressed,this.#I=[],this.#f=[];let e=t.isConstructor&&t.owner.isInner?1:t.isConstructor&&t.owner.isEnum?2:0;this.#c=(t.isStatic?0:1)+e,t.maxSlots=this.#c,this.#y=[],this.#Us(t);let n=t.declaration.params[t.declaration.params.length-1];if(n?.varargs&&!Ln(t.params[t.params.length-1])&&!this.#Jt(t.declaration.modifiers,"SafeVarargs")){let a=t.params[t.params.length-1].element;this.#at(n.pos,"unchecked",`Possible heap pollution from parameterized vararg type ${$(a)}`,Et([a]))}if(t.isAbstract){this.#b=null;return}this.#Pt(),t.declaration.params.forEach((a,o)=>{this.#At(a.modifiers,"parameter");let c=this.#zt(a.name,t.params[o],a.pos,jt(a.modifiers,"final"));c.parameter=o+1+e,a.symbol=c});let s=t.declaration.body.statements;t.isConstructor&&t.owner.isRecord&&!this.#Fn(t.owner,t)&&!(s[0]?.kind==="ConstructorCall"&&s[0].keyword==="this")&&this.#e(t.declaration.namePos,w.syntax,`constructor is not canonical, so it must invoke another constructor of class ${t.owner.displayName}`),t.isConstructor&&t.owner.isEnum&&s[0]?.kind==="ConstructorCall"&&s[0].keyword==="super"&&this.#e(s[0].thisPos,w.syntax,"call to super not allowed in enum constructor");let r=s.some(a=>a.kind==="ConstructorCall");t.isConstructor&&!r&&!t.forwardsToSuper&&this.#Un(t),s.forEach((a,o)=>{a.kind==="ConstructorCall"?this.#Vn(a,o===0):this.#ce(a)}),this.#Mt(),this.#b=null}#Un(t){let e=t.owner.superclass,n=t.owner.librarySuperclass;if(n){let o=t.declaration.synthetic?t.owner.declaration.keywordPos:t.declaration.body.pos,c=this.#Nn(n,[],o);c&&(t.superLibrary=c.call);return}if(!e)return;let s=t.declaration.synthetic?t.owner.declaration.keywordPos:t.declaration.body.pos,r=this.#ct({pos:s,name:e.name,viaSuper:!0},this.#qe(e,t.owner.superType),[],"constructor");if(!r||!this.#Oe(r.method,s,`${e.name}()`,"super"))return;t.superConstructor=r.method;let a=this.#_e(r,s);a&&(t.superVarargs=a)}#Us(t){let e=t.declaration,n=this.#Jt(e.modifiers,"Override");if(t.isConstructor)return;let s=t.isPrivate?[]:this.#Bs(t);if(!s.length){n&&this.#e(n.pos,w.syntax,"method does not override or implement a method from a supertype");return}for(let r of s){if(r.libraryClass&&!t.isStatic&&!t.builtin&&!ba.has(r.native)&&!(Qo[r.libraryClass]??[]).includes(r.native)){this.#a(e.namePos,`overriding ${r.libraryClass}.${r.name}(${r.library.params.map(Je).join(", ")})`,!0);return}let a=r.fromInterface&&!t.owner.isInterface&&!t.isStatic?"implement":"override",o=`${this.#Ht(t)} in ${t.owner.displayName} cannot ${a} ${r.signature} in ${r.ownerName}`;if(t.isStatic&&!r.isStatic){this.#e(e.namePos,w.syntax,o,[" overriding method is static"]);return}if(!t.isStatic&&r.isStatic){this.#e(e.namePos,w.syntax,o,[" overridden method is static"]);return}if(t.isStatic)continue;if(r.isFinal){this.#e(e.namePos,w.syntax,o,[" overridden method is final"]);return}if(ya[t.access]<ya[r.access]){this.#e(e.namePos,w.syntax,o,[` attempting to assign weaker access privileges; was ${r.access}`]);return}let c=t.returnType;if(!(st(r.returnType)||r.returnType.tag==="void"?at(c,r.returnType):K(c,r.returnType))){this.#e(e.namePos,w.incompatibleTypes,o,[` return type ${$(c)} is not compatible with ${$(r.returnType)}`]);return}let d=t.throws.find(h=>this.#Xt(h)&&!(r.throws??[]).some(m=>K(h,m)));if(d){this.#e(e.namePos,w.syntax,o,[` overridden method does not throw ${$(d)}`]);return}}}#Bs(t){let e=[],n=ce(t.name,t.params);for(let s of this.#Bn(t.owner))s.name===t.name&&ce(s.name,s.params)===n&&e.push(s);return e}#Bn(t){let e=[],n=new Set,s=(h,m)=>{for(let p of h.methods){if(p.isPrivate||p.lambda||p.isStatic&&h.isInterface||h.isEnum&&p.builtin&&Wo.has(p.name))continue;let k=O=>p.isStatic?O:Ne(m,h,O),g=p.params.map(k);e.push({name:p.name,params:g,returnType:k(p.returnType),isStatic:p.isStatic,isFinal:p.isFinal,isAbstract:p.isAbstract,isDefault:h.isInterface&&!p.isAbstract&&!p.isStatic,access:p.access,ownerName:h.displayName,signature:this.#Ht(p),fromInterface:h.isInterface,interfaceSymbol:h.isInterface?h:void 0,throws:p.throws,method:p})}},r=fe(t),a=h=>Vn(h).filter(m=>m.tag==="class"&&m.symbol.isInterface),o=h=>{if(!n.has(h.symbol)){n.add(h.symbol),s(h.symbol,h);for(let m of a(h))o(m)}},c=[r];for(let h=t.superclass;h;h=h.superclass)c.push(se(r,h)??tt(h));for(let h of c.slice(1))s(h.symbol,h);let u=[];for(let h of c)u.push(...a(h));for(let h of u)o(h);for(let h of Le(r)){if(!h.symbol.isInterface){for(let m of h.symbol.methods){if(m.isStatic||!m.native)continue;let p=m.params.map(k=>wt(k,h.symbol.typeParams,h.args));e.push({name:m.name,params:p,returnType:wt(m.returnType,h.symbol.typeParams,h.args),isStatic:!1,isFinal:!1,isAbstract:m.abstractIn!==void 0,isDefault:!1,access:m.isProtected?"protected":"public",ownerName:m.abstractIn??h.symbol.name,signature:`${m.name}(${p.map($).join(",")})`,fromInterface:!1,library:{params:m.params,returnType:m.returnType},libraryClass:h.symbol.name,native:m.native})}continue}for(let m of Yo[h.symbol.name]??(h.symbol.functional?[h.symbol.functional]:[])){let p=h.symbol.methods.find(g=>g.name===m),k=p.params.map(g=>wt(g,h.symbol.typeParams,h.args));e.push({name:m,params:k,returnType:wt(p.returnType,h.symbol.typeParams,h.args),isStatic:!1,isFinal:!1,isAbstract:!0,isDefault:!1,access:"public",ownerName:h.symbol.name,signature:`${m}(${k.map($).join(",")})`,fromInterface:!0,library:{params:p.params,returnType:p.returnType}})}}let d=t.isEnum?t:t.enumBody?t.superclass:null;if(d){let h=tt(d),m=(p,k,g)=>({name:p,params:k,returnType:g,isStatic:!1,isFinal:!0,isAbstract:!1,isDefault:!1,access:"public",ownerName:"Enum",signature:`${p}(${k.map($).join(",")})`,fromInterface:!1});e.push(m("name",[],mt),m("ordinal",[],V),m("compareTo",[h],V),m("equals",[G],gt),m("hashCode",[],V))}for(let h of Object.values($e))e.push({name:h.name,params:h.params,returnType:h.returnType,isStatic:!1,isFinal:!1,isAbstract:!1,isDefault:!1,access:"public",ownerName:"Object",signature:`${h.name}(${h.params.map($).join(",")})`,fromInterface:!1,isObject:!0});return e}#Vs(t){if(t.isInterface)return;for(let d of t.constructors)d.declaration.synthetic&&!d.forwardsToSuper&&this.#Un(d);let e=new Set,n=new Map,s=fe(t);for(let d=t;d;d=d.superclass){let h=se(s,d)??tt(d);for(let m of d.methods){if(m.isAbstract||m.isStatic||m.lambda)continue;let p=ce(m.name,m.params.map(k=>Ne(h,d,k)));e.add(p),!m.isPrivate&&!n.has(p)&&n.set(p,m)}}for(let d of Object.values($e))e.add(ce(d.name,d.params));let r=this.#Bn(t),a=new Set(t.methods.filter(d=>!d.isStatic&&!d.isConstructor).map(d=>ts(d.name,d.params,d.returnType))),o=d=>{for(let h=t.superclass;h;h=h.superclass)if(h.bridges?.some(m=>m.key===d))return!0;return!1};for(let d of r){if(d.isStatic||d.isObject||!(d.method||d.library))continue;let h=d.method??d.library,m=n.get(ce(d.name,d.params));if(!m||m===d.method||m.selector===void 0)continue;let p=ts(d.name,h.params,h.returnType);if(p===ts(m.name,m.params,m.returnType)||a.has(p)||m.owner!==t&&o(p))continue;let k=t.bridges??=[];k.some(g=>g.key===p)||k.push({key:p,name:d.name,params:h.params.map(W),returnType:W(h.returnType),target:m,selector:this.#_n(p),library:!d.method,...m.builtin?{alias:!0}:{}})}for(let d of r){if(!d.libraryClass||ba.has(d.native))continue;let h=n.get(ce(d.name,d.params));if(!h||h.builtin||h.selector===void 0)continue;let m=t.bridges?.find(p=>p.key===ts(d.name,d.library.params,d.library.returnType));(t.libraryOverrides??=new Map).set(d.native,m?m.selector:h.selector)}let c=new Map;for(let d of r){if(!d.isDefault)continue;let h=ce(d.name,d.params);c.set(h,[...c.get(h)??[],d])}let u=t.isEnum&&t.declaration.enumConstants?.some(d=>d.body)===!0;if(!t.isAbstract){let d=t.methods.filter(h=>h.isAbstract).map(h=>({name:h.name,params:h.params,returnType:h.returnType,isStatic:!1,isFinal:!1,isAbstract:!0,isDefault:!1,access:h.access,ownerName:t.displayName,signature:this.#Ht(h),fromInterface:!1}));for(let h of[...d,...r]){if(!h.isAbstract)continue;let m=ce(h.name,h.params);if(!(e.has(m)||c.has(m))){if(u){t.enumAbstract=!0;break}this.#e(t.declaration.keywordPos,w.syntax,`${t.displayName} is not abstract and does not override abstract method ${h.signature} in ${h.ownerName}`);return}}}for(let[d,h]of c){if(e.has(d)||h.length<2)continue;let[m,p]=h;if(!(m.interfaceSymbol&&p.interfaceSymbol&&(Sn(m.interfaceSymbol,p.interfaceSymbol)||Sn(p.interfaceSymbol,m.interfaceSymbol))||m.interfaceSymbol===p.interfaceSymbol)){this.#e(t.declaration.keywordPos,w.syntax,`types ${m.ownerName} and ${p.ownerName} are incompatible;`,[` class ${t.displayName} inherits unrelated defaults for ${m.signature} from types ${m.ownerName} and ${p.ownerName}`]);return}}}#Vn(t,e){let n=this.#b;if(!n?.isConstructor){this.#e(t.pos,w.syntax,"explicit constructor invocation may only appear within a constructor body");return}if(!e){this.#a(t.thisPos,`statements before \'${t.keyword}(...)\' in a constructor`);return}this.#g=!0;let s=this.#ue(t.args);if(this.#g=!1,s.some(d=>d.tag==="error"))return;let r=t.keyword==="this"?n.owner:n.owner.superclass,a=t.keyword==="super"?n.owner.librarySuperclass:void 0;if(a){let d=this.#Nn(a,s,t.thisPos);if(!d)return;this.#g=!0,this.#de(t.args,d.candidate.params),this.#Fe(t.args),this.#g=!1,t.libraryCall=d.call;return}if(!r){s.length&&this.#e(t.thisPos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${s.map($).join(",")}`," reason: actual and formal argument lists differ in length"]);return}if(this.#In(r,s.length,t.thisPos))return;let o=t.keyword==="this"?fe(r):n.owner.superType,c=this.#ct({pos:t.thisPos,name:r.name,viaSuper:t.keyword==="super"},this.#qe(r,o),s,"constructor");if(!c||!this.#Oe(c.method,t.thisPos,`${r.name}(${c.params.map($).join(",")})`,t.keyword==="super"?"super":null))return;this.#g=!0,this.#de(t.args,c.params),this.#Fe(t.args),this.#g=!1,t.target=c.method;let u=this.#_e(c,t.thisPos);u&&(t.varargs=u)}#Hs(t){let e=new Map;for(let s of t.constructors){let r=s.declaration.body?.statements[0];r?.kind==="ConstructorCall"&&r.keyword==="this"&&r.target&&e.set(s,r)}let n=new Set;for(let s of t.constructors){let r=new Set,a=s;for(;a&&!n.has(a);){r.add(a);let o=e.get(a),c=o?.target;if(c&&r.has(c)){this.#e(o.thisPos,w.syntax,"recursive constructor invocation"),e.delete(a);break}a=c}for(let o of r)n.add(o)}}#Hn(t){if(t.state!=="pending")return;t.state="attributing";let e=this.#ke(),n=this.#o;this.#o=t.owner,this.#b=null,this.#it=t,this.#t=t.isStatic,this.#Y=t.isStatic,this.#E=[],this.#x=t.suppressed,this.#I=[],this.#f=[{names:new Map,nextSlot:0}],this.#c=0,this.#y=[];let s=t.declarator.init;if(s)if(s.kind==="ArrayInitializer")this.#je(s,t.type);else{let r=this.#k(s,t.type);this.#ln(t.type,r,s)?t.isFinal&&s.constant&&(st(t.type)||t.type.tag==="string")&&(t.constant=On(s.constant,t.type)):this.#q(s,r,t.type)}this.#Ce(e),this.#o=n,t.state="done"}#Pt(){this.#f.push({names:new Map,nextSlot:this.#c})}#Mt(){let t=this.#f.pop();this.#c=t.nextSlot}#lt(t){for(let e=this.#f.length-1;e>=0;e--){let n=this.#f[e].names.get(t);if(n)return n}}#zt(t,e,n,s,r=!1){let a=this.#b,o=this.#lt(t)||r?null:this.#Pn(t),c=o?.method??a;!r&&(this.#lt(t)||o&&c)&&this.#e(n,w.alreadyDefined,`variable ${t} is already defined in ${c.isConstructor?"constructor":"method"} ${this.#Ht(c)}`);let u={kind:"local",name:t,type:e,index:a.locals.length,slot:this.#c,isFinal:s,declPos:n};return this.#c+=Be(e),a.maxSlots=Math.max(a.maxSlots,this.#c),a.locals.push(u),this.#f[this.#f.length-1].names.set(t,u),u}#Yt(t){let e=0;for(let n=this.#o;n;n=n.outer,e++){let s=this.#Ee(n,t);if(s&&!(n.enumBody&&s.isPrivate&&s.owner!==n))return{field:s,hops:e};let r=n.anonymous||n.local?this.#Cr(n,t):null;if(r)return{field:r,hops:e}}return null}#Ee(t,e,n=new Set){if(n.has(t))return null;n.add(t);let s=t.fieldsByName.get(e);if(s)return s;if(t.superclass){let r=this.#Ee(t.superclass,e,n);if(r)return r}for(let r of t.interfaces){let a=this.#Ee(r,e,n);if(a)return a}return null}#wt(t,e){let n=[],s=new Set,r=new Set,a=fe(t),o=(c,u)=>{if(!r.has(c)){r.add(c);for(let d of c.methodsByName.get(e)??[]){if(u&&(d.isPrivate||d.isStatic&&c.isInterface))continue;let h=ce(d.name,d.isStatic?d.params:d.params.map(m=>Ne(a,c,m)));s.has(h)||(s.add(h),n.push(d))}c.superclass&&o(c.superclass,!0);for(let d of c.interfaces)o(d,!0)}};return o(t,!1),n}#sn(t){let e=this.#o;for(let n=0;n<t;n++,e=e.outer)if(!e?.isInner)return!1;return!0}#zs(t){let e=this.#o;for(let n=0;n<t&&e;n++)e=e.outer;return e}#Gs(t,e){for(let n=e;n;n=n.outer)if(n===t)return!0;return!1}#Ks(t,e){for(let n=t.superclass;n;n=n.superclass){let s=n.methodsByName.get(e)?.find(r=>r.isPrivate);if(s)return s}return null}#Gt(t){let e=s=>{for(let r=s.length-1;r>=0;r--){let a=s[r].classes?.get(t);if(a)return a}return null},n=e(this.#f);if(n)return n;for(let s=this.#J;s;s=s.outer){let r=e(s.scopes);if(r)return r}for(let s=this.#o;s;s=s.outer){let r=s.membersByName.get(t);if(r)return r;if(s.name===t&&!s.declaration.implicit)return s;let a=s.anonymous||s.local?this.#N.get(s):void 0,o=a?e(a.scopes):null;if(o)return o}return this.#qs(t)}#qs(t){let e=this.#W.find(a=>a.name===t&&!a.declaration.implicit&&this.#z.get(a)===this.#d);if(e)return e;let n=this.#d.programImports.get(t),s=n?this.#rn(n):null;if(s)return s;if(this.#X.has(t))return null;let r=this.#Dt(this.#d.pkg,t);if(r)return r;for(let a of this.#d.programOnDemand){let o=this.#Dt(a,t);if(o?.isPublic)return o}return null}#Dt(t,e){let n=this.#W.find(r=>r.packageName===t&&r.name===e&&!r.declaration.implicit);if(n){let r=this.#z.get(n);if(r&&!r.launch&&r!==this.#d&&`${e}.java`!==r.file.name.replace(/^.*\\//,""))throw new He(`class ${e} is declared in ${r.file.name}, a file not named after it, and used from another file`);return n}let s=`${this.#rt}${t?`${t.replaceAll(".","/")}/`:""}${e}.java`;if(this.#It.has(s))throw new is(s,this.#R||this.#O.has(this.#ut.name));return null}#rn(t){let e=this.#Dt(t.pkg,t.names[0]);for(let n of t.names.slice(1))e=e?.membersByName.get(n)??null;return e}#in(t){for(let e=t.length-1;e>0;e--)if(this.#G.has(t.slice(0,e).join(".")))return e;return 0}#zn(t,e){if(this.#W.some(r=>r.name===t&&this.#z.get(r)===this.#d))return!1;let n=this.#d.ambiguousImports.get(t);if(n){let r=a=>`class ${a} in ${a.slice(0,a.lastIndexOf("."))}`;return this.#e(e,w.cantResolve,`reference to ${t} is ambiguous`,[` both ${r(n[0])} and ${r(n[1])} match`]),!0}if(!this.#d.programOnDemand.length||this.#d.programImports.has(t)||this.#X.has(t)||this.#Dt(this.#d.pkg,t))return!1;let s=[];for(let r of["java.lang",...this.#d.onDemandOrder]){if(this.#G.has(r)){let c=this.#Dt(r,t);c?.isPublic&&s.push(`${c.isInterface?"interface":c.isEnum?"enum":c.isRecord?"record":"class"} ${r}.${t} in ${r}`);continue}if(!(r==="java.lang"&&(t==="String"||t==="System"||t==="Math"||An.has(t)))&&!(It[t]===r&&!Mt[t])&&!(Yn[r]??[]).includes(t))continue;let o=It[t]===r?Wt(t):void 0;s.push(`${o?.isInterface?"interface":o?.enumConstants?"enum":"class"} ${r}.${t} in ${r}`)}return s.length<2||!s.some(r=>this.#d.programOnDemand.some(a=>r.endsWith(` in ${a}`)))?!1:(this.#e(e,w.cantResolve,`reference to ${t} is ambiguous`,[` both ${s[s.length-1]} and ${s[s.length-2]} match`]),!0)}#Gn(t,e,n=!0){let s=this.#o.topLevel.packageName;if(t.topLevel.packageName===s)return!0;for(let r=t;r;r=r.outer)if(!(r.isPublic||!r.outer&&!n)){if(!r.outer)return this.#e(e,w.cantResolve,`${r.name} is not public in ${r.packageName}; cannot be accessed from outside package`),!1;if(!r.isPrivate){if(jt(r.declaration.modifiers,"protected")){let a=!1;for(let o=this.#o;o&&!a;o=o.outer)for(let c=o;c&&!a;c=c.superclass)a=c===r.outer;if(a)continue;return this.#e(e,w.cantResolve,`${r.name} has protected access in ${r.outer.displayName}`),!1}return this.#e(e,w.cantResolve,`${r.name} is not public in ${r.outer.displayName}; cannot be accessed from outside package`),!1}}return!0}#Ws(t){this.#d=t;for(let[e,n]of t.programImports){let s=this.#rn(n);if(!s)continue;let r=this.#W.find(a=>a.name===e&&this.#z.get(a)===t);if(r&&r!==s){this.#e(n.start,w.alreadyDefined,`${e} is already defined in this compilation unit`);continue}s.topLevel.packageName!==t.pkg&&!s.topLevel.isPublic&&this.#e(n.pos,w.cantResolve,`${s.topLevel.name} is not public in ${s.topLevel.packageName}; cannot be accessed from outside package`)}}#ze(t){this.#Pt();for(let e of t.statements)this.#ce(e);this.#Mt()}#ce(t){let e=this.#c,n=this.#j.length;this.#Xs(t);let s=this.#j.slice(n);if(t.kind==="LocalVariableDeclaration")for(let r of t.declarators)r.symbol&&s.push(r.symbol);this.#c=Math.max(e,...s.map(r=>r.slot+Be(r.type)))}#Xs(t){switch(t.kind){case"Block":this.#ze(t);return;case"LocalVariableDeclaration":this.#Xn(t);return;case"ExpressionStatement":this.#k(t.expression);return;case"IfStatement":{this.#Ae(t.condition);let e=this.#ft(t.condition,!0),n=this.#ft(t.condition,!1);this.#Qt(e,()=>this.#Tn(t.then)),t.otherwise&&this.#Qt(n,()=>this.#Tn(t.otherwise)),n.length&&!this.#xn(t.then)&&this.#Ke(n),e.length&&t.otherwise&&!this.#xn(t.otherwise)&&this.#Ke(e);return}case"WhileStatement":this.#Ae(t.condition),this.#Qt(this.#ft(t.condition,!0),()=>this.#an(t,t.body)),ye(t.body,t)||this.#Ke(this.#ft(t.condition,!1));return;case"DoStatement":this.#an(t,t.body),this.#Ae(t.condition),ye(t.body,t)||this.#Ke(this.#ft(t.condition,!1));return;case"ForStatement":this.#er(t);return;case"ForEachStatement":this.#nr(t);return;case"LabeledStatement":this.#sr(t);return;case"SwitchStatement":this.#Kn(t,void 0);return;case"YieldStatement":this.#ar(t);return;case"BreakStatement":t.liveSlots=this.#c,this.#rr(t);return;case"ContinueStatement":t.liveSlots=this.#c,this.#ir(t);return;case"ReturnStatement":if(this.#b?.initializer){this.#e(t.pos,w.syntax,"return outside method");return}t.liveSlots=this.#c+(t.value&&this.#b?Be(this.#b.returnType):0),this.#cr(t);return;case"EmptyStatement":return;case"ConstructorCall":this.#Vn(t,!1);return;case"ThrowStatement":{let e=this.#nt(t.expression);e.tag!=="error"&&!this.#oe(e)&&this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${Ue(this.#Wt(),e)}`);return}case"TryStatement":this.#Qs(t);return;case"AssertStatement":this.#Ae(t.condition),t.message&&this.#nt(t.message);return;case"LocalClass":this.#Ys(t.declaration);return}}#Ys(t){let e=t.symbol;if(!e)return;let n=this.#f[this.#f.length-1];if(this.#f.some(h=>h.classes?.has(e.name))&&this.#b){this.#e(t.keywordPos,w.alreadyDefined,`class ${e.name} is already defined in ${this.#b.isConstructor?"constructor":"method"} ${this.#Ht(this.#b)}`);return}(n.classes??=new Map).set(e.name,e);let r=this.#ke(),a=this.#o,o=this.#J,c=this.#ht,u=this.#g;e.declaration.keyword==="class"&&this.#N.set(e,{scopes:r.scopes});let d=[e,...Lr(e,!0)];for(let h of d)h.typeParams&&(this.#o=h,this.#wn(h.typeParams,h.declaration.typeParams));for(let h of d)this.#ve(h);this.#Ze(e);for(let h of d)this.#le(h);for(let h of d)this.#nn([...h.methods,...h.constructors]);this.#J=null,this.#g=!1,this.#He(e),this.#Ce(r),this.#o=a,this.#J=o,this.#ht=c,this.#g=u}#Qs(t){this.#Pt();for(let n of t.resources)this.#Zs(n);this.#ze(t.block),this.#Mt();let e=[];for(let n of t.catches){let s=[];for(let o of n.types){let c=this.#U(o);if(c.tag==="error")continue;if(!this.#oe(c)){this.#q(o,c,this.#Wt());continue}let u=s.find(d=>K(c,d)||K(d,c));if(u){let[d,h]=K(c,u)?[c,u]:[u,c];this.#e(o.pos,w.syntax,"Alternatives in a multi-catch statement cannot be related by subclassing",[` Alternative ${$(d)} is a subclass of alternative ${$(h)}`]);continue}if(e.some(d=>K(c,d))){this.#e(n.types.length===1?n.pos:o.pos,w.syntax,`exception ${$(c)} has already been caught`);continue}s.push(c)}e.push(...s),n.caught=s,this.#Pt();let r=s.length===1?s[0]:s.length?this.#tr(s):A,a=this.#zt(n.name,r,n.namePos,n.isFinal||n.types.length>1);n.types.length>1&&(a.multiCatch=!0),a.catchParameter=!0,n.symbol=a,this.#ze(n.block),this.#Mt()}if(t.finallyBlock){let n=this.#b,s=n.maxSlots,r=this.#c,a=n.locals.length;this.#ze(t.finallyBlock);let o=Math.max(0,...n.locals.slice(a).map(c=>c.slot+Be(c.type)-r));t.finallySlots={base:r,extent:o,before:s},n.finallySlots=Math.max(n.finallySlots??0,n.maxSlots)+3+2*o}}#Zs(t){if(t.kind==="variable"){let r=this.#k(t.expression),a=Q(t.expression);a.kind==="Name"&&a.symbol?.kind==="local"&&(t.symbol=a.symbol),r.tag!=="error"&&!this.#bn(r)?this.#Sn(t.expression,r):t.closeMethod=this.#gn(r);return}if(t.type.kind==="VarType"){let r=this.#k(t.init),a=r.tag==="null"||r.tag==="void"?A:r;if(a.tag==="error"&&r.tag!=="error"&&this.#e(t.namePos,w.cantResolve,`cannot infer type for local variable ${t.name}`,[` (variable initializer is \'${r.tag}\')`]),t.symbol=this.#zt(t.name,a,t.namePos,!0),a.tag==="error")return;this.#bn(a)?t.closeMethod=this.#gn(a):this.#Sn(t.init,a);return}let e=this.#U(t.type),n=this.#zt(t.name,e,t.namePos,!0);t.symbol=n;let s=this.#k(t.init,e);if(!(e.tag==="error"||s.tag==="error")){if(!re(e,s,t.init.constant)){this.#q(t.init,s,e);return}this.#bn(e)?t.closeMethod=this.#gn(e):this.#Sn(t.type,e)}}#gn(t){if(t.tag==="class")return this.#wt(t.symbol,"close").find(e=>e.params.length===0)}#bn(t){return t.tag==="library"?t.symbol.closeable===!0:K(t,tt(this.#D.get("java.lang.AutoCloseable")))}#Sn(t,e){this.#e(t.pos,w.incompatibleTypes,"incompatible types: try-with-resources not applicable to variable type",[` (${$(e)} cannot be converted to AutoCloseable)`])}#tr(t){let s=(r=>{let a=[];for(let o=r.tag==="class"?r.symbol:null;o;o=o.superclass)a.push(o);return a})(t[0]).find(r=>t.every(a=>a.tag==="class"&&K(a,tt(r))));return s?tt(s):this.#Wt()}#Tn(t){this.#Pt(),this.#ce(t),this.#Mt()}#er(t){if(this.#Pt(),t.init&&!Array.isArray(t.init))this.#Xn(t.init);else for(let s of t.init??[])this.#k(s);t.condition&&this.#Ae(t.condition);let e=t.condition?this.#ft(t.condition,!0):[];this.#Qt(e,()=>{for(let s of t.update)this.#k(s);this.#an(t,t.body)});let n=t.condition?this.#ft(t.condition,!1):[];this.#Mt(),ye(t.body,t)||this.#Ke(n)}#xn(t){let e=[this.#B,this.#dt,this.#K,this.#Z,this.#F,this.#M];this.#B=[],this.#dt=[],this.#K=new Map,this.#Z=0,this.#F=[],this.#M=new Map;let n=this.#Rt(t,Qt(),!0).completes;return[this.#B,this.#dt,this.#K,this.#Z,this.#F,this.#M]=e,n}#an(t,e){this.#y.push({kind:"loop",node:t}),this.#Tn(e),this.#y.pop()}#nr(t){let e=this.#k(t.iterable);this.#Pt();let n=A,s=c=>c.tag==="library"?[c]:c.tag==="diamond"?[this.#Ln(c)]:c.tag==="class"?Le(c):c.tag==="typevar"&&c.symbol?c.symbol.bounds.flatMap(s):[],r=s(e).map(c=>Dt(c,Wt("Iterable"))).find(c=>c!==null)??null;e.tag==="array"?(n=e.element,t.hidden={array:this.#Je(e),length:this.#Je(V),index:this.#Je(V)}):r?(n=Me(r.args[0]??G),t.element=n,t.iterator=this.#Je(G)):e.tag!=="error"&&this.#e(t.iterable.pos,w.incompatibleTypes,"for-each not applicable to expression type",[" required: array or java.lang.Iterable",` found: ${$(e)}`]),this.#At(t.modifiers,"local");let a=t.type.kind==="VarType"?n:this.#U(t.type),o=this.#zt(t.name,a,t.namePos,jt(t.modifiers,"final"));o.forEach=!0,t.symbol=o,n.tag!=="error"&&a.tag!=="error"&&!re(a,n)&&this.#q(t.iterable,n,a),this.#an(t,t.body),this.#Mt()}#sr(t){this.#y.some(s=>s.kind==="label"&&s.label===t.label)&&this.#e(t.pos,w.syntax,`label ${t.label} already in use`);let e=t.body,n=["WhileStatement","DoStatement","ForStatement","ForEachStatement"].includes(e.kind);this.#y.push({kind:"label",node:t,label:t.label,loop:n?e:void 0}),this.#ce(e),this.#y.pop()}#rr(t){for(let e=this.#y.length-1;e>=0;e--){let n=this.#y[e];if(n.kind==="switch-expression"){this.#e(t.pos,w.syntax,"attempt to break out of a switch expression");return}if(t.label===void 0?n.kind==="loop"||n.kind==="switch":n.kind==="label"&&n.label===t.label){t.target=n.node;return}}t.label!==void 0?this.#e(t.pos,w.syntax,`undefined label: ${t.label}`):this.#e(t.pos,w.syntax,"break outside switch or loop")}#ir(t){for(let e=this.#y.length-1;e>=0;e--){let n=this.#y[e];if(n.kind==="switch-expression"){this.#e(t.pos,w.syntax,"attempt to continue out of a switch expression");return}if(t.label===void 0&&n.kind==="loop"){t.target=n.node;return}if(t.label!==void 0&&n.kind==="label"&&n.label===t.label){n.loop?t.target=n.loop:this.#e(t.pos,w.syntax,`not a loop label: ${t.label}`);return}}t.label!==void 0?this.#e(t.pos,w.syntax,`undefined label: ${t.label}`):this.#e(t.pos,w.syntax,"continue outside of loop")}#ar(t){let e=[...this.#y].reverse().find(s=>s.kind==="switch-expression");if(!e){this.#e(t.pos,w.syntax,"yield outside of switch expression"),this.#k(t.value);return}t.target=e.node;let n=this.#nt(t.value,e.target);e.results.push({expression:t.value,type:n})}#Je(t){let e=this.#b;if(!e)throw new Error("checker: hidden local outside a method");let n={kind:"local",name:"",type:t,index:e.locals.length,slot:this.#c,isFinal:!1,declPos:-1};return this.#c+=Be(t),e.maxSlots=Math.max(e.maxSlots,this.#c),e.locals.push(n),n}#Kn(t,e){let n=t.kind==="SwitchExpression",s=this.#k(t.selector),r=s.tag!=="error",a=s.tag==="class"&&s.symbol.isEnum?s.symbol:null,o=s.tag==="library"&&s.symbol.enumConstants?s.symbol:null,c=a!==null||o!==null||["int","byte","short","char","string"].includes(s.tag)||St(s)!==null;if(r&&(t.cases.some(k=>k.pattern||k.nullLabel)||!c&&nt(s)))return this.#or(t,s,e);r&&!a&&!o&&!["int","byte","short","char","string"].includes(s.tag)&&(r=!1,St(s)?this.#a(t.selectorPos,`switching on ${nn($(s))}`,!0):st(s)?this.#e(t.selectorPos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#a(t.selectorPos,`switching on ${nn($(s))}`,!0)),this.#Pt(),r&&s.tag==="string"&&(this.#b?t.hidden={copy:this.#Je(mt),index:this.#Je(V)}:(this.#a(t.pos,"a switch on a String in a field initializer",!0),r=!1));let u=n?{kind:"switch-expression",node:t,results:[],target:e}:{kind:"switch",node:t};this.#y.push(u);let d=new Set,h=0,m=!1,p=t.cases[0]?.arrow??!1;for(let k of t.cases){if(k.arrow!==p&&!m&&(m=!0,this.#e(k.pos,w.syntax,"different case kinds used in the switch")),k.isDefault&&++h>1&&this.#e(k.pos,w.syntax,"duplicate default label"),o){k.ordinals=[];for(let g of k.labels){let O=this.#lr(g,o);O!==null&&(d.has(`e:${O}`)&&this.#e(g.pos,w.syntax,"duplicate case label"),d.add(`e:${O}`),k.ordinals.push(O))}this.#on(k,n,u);continue}if(a){k.ordinals=[];for(let g of k.labels){let O=this.#qn(g,a);O!==null&&(d.has(`e:${O}`)&&this.#e(g.pos,w.syntax,"duplicate case label"),d.add(`e:${O}`),k.ordinals.push(O))}this.#on(k,n,u);continue}for(let g of k.labels){let O=this.#k(g,r?s:void 0);if(!r||O.tag==="error")continue;if(!g.constant){this.#e(g.pos,w.syntax,"constant expression required");continue}if(!re(s,O,g.constant)){this.#q(g,O,s);continue}let T=g.constant.kind==="string"?`s:${g.constant.value}`:`n:${kn(g.constant)}`;d.has(T)&&this.#e(k.pos,w.syntax,"duplicate case label"),d.add(T)}this.#on(k,n,u)}return this.#y.pop(),this.#Mt(),a&&(t.coversAllConstants=a.enumConstants.every(k=>d.has(`e:${k.enumConstant.ordinal}`))),o&&(t.libraryEnum=wa(o),t.coversAllConstants=o.enumConstants.every((k,g)=>d.has(`e:${g}`))),n?this.#Wn(t,u.results,e):xt}#or(t,e,n){let s=t.kind==="SwitchExpression";t.patternSwitch=!0;let r=e.tag==="class"&&e.symbol.isEnum?e.symbol:null;this.#Pt();let a=s?{kind:"switch-expression",node:t,results:[],target:n}:{kind:"switch",node:t};this.#y.push(a);let o=!1,c=0,u=!1,d=t.cases[0]?.arrow??!1,h=[],m=new Set,p=null,k=[],g=!1,O=St(e);t.cases.forEach((x,v)=>{x.arrow!==d&&!o&&(o=!0,this.#e(x.pos,w.syntax,"different case kinds used in the switch")),x.isDefault&&++c>1&&this.#e(x.pos,w.syntax,"duplicate default label");let R=[];x.nullLabel&&st(e)&&this.#q({pos:x.pos},br,e);for(let L of x.labels){if(r){let M=this.#qn(L,r);if(M===null)continue;m.has(`e:${M}`)&&this.#e(L.pos,w.syntax,"duplicate case label"),m.add(`e:${M}`),(x.ordinals??=[]).push(M),k.push({constantOf:r,ordinal:M})}else{let M=this.#k(L,O??e);if(M.tag==="error")continue;let _=L.kind==="FieldAccess"?L.fieldSymbol:void 0;if(M.tag==="class"&&M.symbol.isEnum&&_?.enumConstant&&K(M,e)){(x.enumFields??=[]).push(_),k.push({constantOf:M.symbol,ordinal:_.enumConstant.ordinal}),h.some(B=>K(M,B))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label");continue}if(!(e.tag==="string"?M.tag==="string":O!==null&&st(M)&&L.constant!==void 0&&re(O,M,L.constant))){O&&L.constant?this.#q(L,M,O):this.#a(L.pos,`constant labels in a switch on ${nn($(e))}`,!0);continue}if(!L.constant){this.#e(L.pos,w.syntax,"constant expression required");continue}let P=L.constant.kind==="string"?`s:${L.constant.value}`:`n:${kn(L.constant)}`;m.has(P)&&this.#e(x.pos,w.syntax,"duplicate case label"),m.add(P)}let C=r||O?e:mt;h.some(M=>K(C,M))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label")}if(x.pattern){let L=x.pattern;if(!this.#kn(L,e,!0,R))g=!0;else{let M=L.tested;(u||h.some(j=>K(W(M),W(j))))&&this.#e(L.pos,w.syntax,"this case label is dominated by a preceding case label");let _=x.guard!==void 0;L.kind==="TypePattern"&&!_&&(h.push(M),L.unconditional&&(p=x)),(!x.guard||qn(x.guard.constant))&&k.push({pattern:L})}let C=t.cases[v-1];!x.arrow&&C&&!C.arrow&&C.statements.length&&R.length&&this.#xn({kind:"Block",statements:C.statements,pos:C.pos,start:C.start,end:C.end})&&this.#e(L.pos,w.syntax,"illegal fall-through to a pattern",[" (the previous case label is missing a break)"])}x.isDefault&&(u=!0,k.push({all:!0})),this.#Qt(R,()=>{let L=[];x.guard&&(this.#Ae(x.guard),Os(x.guard.constant)&&this.#e(x.guard.pos,w.syntax,"this case label has a guard that is a constant expression with value \'false\'"),L=this.#ft(x.guard,!0)),this.#Qt(L,()=>this.#on(x,s,a))})});let T=t.cases.find(x=>x.isDefault&&!x.nullLabel)??t.cases.find(x=>x.isDefault);return p&&T&&this.#e(T.pos,w.syntax,"switch has both an unconditional pattern and a default label"),this.#y.pop(),this.#Mt(),t.exhaustive=dl(e,k),!t.exhaustive&&!g&&this.#e(t.pos,w.syntax,`the switch ${s?"expression":"statement"} does not cover all possible input values`),s?this.#Wn(t,a.results,n):xt}#lr(t,e){let n=Q(t),s=e.enumConstants,r=n.kind==="Name"?n.identifier:n.kind==="FieldAccess"&&ss(n.target)?.split(".").pop()===e.name?n.name:null,a=r===null?-1:s.indexOf(r);return a>=0?(t.type=pt(e),a):n.kind==="Name"?(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#o.displayName}`]),null):(this.#k(t).tag!=="error"&&this.#e(t.pos,w.syntax,"constant expression required"),null)}#qn(t,e){let n=Q(t);if(n.kind==="Name"){let a=e.fieldsByName.get(n.identifier);return a?.enumConstant?(n.symbol=a,t.type=tt(e),a.enumConstant.ordinal):(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#o.displayName}`]),null)}let s=this.#k(t);if(s.tag==="error")return null;let r=n.kind==="FieldAccess"?n.fieldSymbol:void 0;return r?.enumConstant&&r.owner===e?r.enumConstant.ordinal:(re(tt(e),s)?this.#e(t.pos,w.syntax,"constant expression required"):this.#q(t,s,tt(e)),null)}#on(t,e,n){if(!t.arrow){for(let r of t.statements)this.#ce(r);return}let s=t.body;s.kind==="Block"?this.#ze(s):e?n.results.push({expression:s,type:this.#nt(s,n.target)}):this.#k(s)}#Wn(t,e,n){if(e.some(r=>r.type.tag==="error"))return A;if(n&&n.tag!=="error"){let r=!0;for(let{expression:a,type:o}of e)re(n,o,a.constant)||(this.#e(a.pos,w.incompatibleTypes,"incompatible types: bad type in switch expression",[` ${Ue(n,o)}`]),r=!1);return r?n:A}let s=e.map(r=>r.type);return s.length?s.every(r=>r.tag==="boolean")?gt:s.every(r=>Rt(r))?s.every(r=>at(r,s[0]))?s[0]:s.reduce((r,a)=>ns(r,a)):s.every(r=>nt(r))?s.reduce((r,a)=>Pa(r,a)):(this.#a(t.pos,"switch expressions that need boxing"),A):A}#cr(t){let e=this.#b.returnType;if(this.#b.lambda&&this.#b.returnType===es){if(!t.value)return;let s=this.#k(t.value);s.tag!=="error"&&(this.#b.returnType=qt(s)??(s.tag==="null"?G:s));return}if(this.#b.lambda){let s=`incompatible types: bad return type in ${this.#b.lambda.reference?"method reference":"lambda expression"}`;if(!t.value){e.tag!=="void"&&this.#e(t.pos,w.incompatibleTypes,s,[" missing return value"]);return}if(e.tag==="void"){this.#k(t.value),this.#e(t.value.pos,w.incompatibleTypes,"incompatible types: unexpected return value");return}let r=this.#k(t.value,e);r.tag!=="error"&&!re(e,r,t.value.constant)&&this.#e(t.value.pos,w.incompatibleTypes,s,[` ${Ue(e,r)}`]);return}if(!t.value){e.tag!=="void"&&this.#e(t.pos,w.incompatibleTypes,"incompatible types: missing return value");return}let n=this.#k(t.value,e.tag==="void"?void 0:e);if(e.tag==="void"){n.tag!=="error"&&this.#e(t.value.pos,w.incompatibleTypes,"incompatible types: unexpected return value");return}this.#ln(e,n,t.value)||this.#q(t.value,n,e)}#Ae(t){let e=this.#k(t);e.tag!=="error"&&(St(e)??e).tag!=="boolean"&&this.#q(t,e,gt)}#Xn(t){let e=jt(t.modifiers,"final"),n=this.#At(t.modifiers,"local");if(this.#I=[...this.#I,n],this.#Jt(t.modifiers,"Deprecated"))for(let s of t.declarators)this.#at(s.pos,"deprecation","@Deprecated annotation has no effect on this variable declaration");t.type.kind==="VarType"?this.#hr(t,e):this.#ur(t,e),this.#I=this.#I.slice(0,-1)}#ur(t,e){let n=this.#U(t.type);for(let s of t.declarators){let r=n;for(let u=0;u<s.extraDims&&r.tag!=="error";u++)r=ee(r);let a=this.#zt(s.name,r,s.pos,e);s.symbol=a;let o=s.init;if(o||(a.noInitializer=!0),!o){e&&this.#a(s.pos,"final local variables without an initializer");continue}if(o.kind==="ArrayInitializer"){this.#je(o,r);continue}let c=this.#k(o,r);this.#ln(r,c,o)?e&&o.constant&&(st(r)||r.tag==="string")&&(a.constant=On(o.constant,r)):this.#q(o,c,r)}}#hr(t,e){let n=t.type.pos;if(t.declarators.length>1){this.#e(n,w.syntax,"\'var\' is not allowed in a compound declaration");return}let s=t.declarators[0];if(s.extraDims){this.#e(n,w.syntax,"\'var\' is not allowed as an element type of an array");return}let r=d=>this.#e(s.pos,w.cantResolve,`cannot infer type for local variable ${s.name}`,[` (${d})`]),a=s.init,o=a&&a.kind!=="ArrayInitializer"?Q(a):null,c=A;if(!a)r("cannot use \'var\' on variable without initializer");else if(a.kind==="ArrayInitializer")r("array initializer needs an explicit target-type");else if(o.kind==="Lambda")r("lambda expression needs an explicit target-type");else if(o.kind==="MethodRef")r("method reference needs an explicit target-type");else if(gl(a,s.name))r("cannot use \'var\' on self-referencing variable");else{let d=this.#k(a);d.tag==="null"?r("variable initializer is \'null\'"):d.tag==="void"?r("variable initializer is \'void\'"):c=d.tag==="diamond"?this.#Ln(d):d,c.tag==="class"&&c.args?.includes(Hn)&&(c=A)}let u=this.#zt(s.name,c,s.pos,e);s.symbol=u,a||(u.noInitializer=!0),a&&a.kind!=="ArrayInitializer"&&e&&a.constant&&(st(c)||c.tag==="string")&&(u.constant=On(a.constant,c))}#ln(t,e,n){return W(t).tag==="object"&&delete Q(n).genericCast,re(t,e,n.constant)?!0:Re(t,e)?(this.#at(n.pos,"unchecked","unchecked conversion",[` required: ${$(t)}`,` found: ${$(e)}`,...Et([t,e])]),!0):!1}#je(t,e){if(e.tag==="error"){for(let n of t.elements)n.kind==="ArrayInitializer"?this.#je(n,A):this.#k(n);return}if(e.tag!=="array"){this.#e(t.pos,w.incompatibleTypes,`illegal initializer for ${$(e)}`);return}t.elementType=e.element;for(let n of t.elements){if(n.kind==="ArrayInitializer"){this.#je(n,e.element);continue}let s=this.#k(n,e.element);re(e.element,s,n.constant)||this.#q(n,s,e.element)}}#vn(t,e,n){let s=[];for(let r of t){if(s.some(a=>a.name===r.name)){this.#e(r.pos,w.alreadyDefined,`type variable ${r.name} is already defined in ${e}`);continue}s.push({kind:"typevar",name:r.name,key:`${r.name}#${this.#A++}`,bounds:[],declaredIn:e,pos:r.pos,ofClass:n})}return s}#wn(t,e){this.#E=[...this.#E,t.filter(s=>!s.ofClass)];let n=this.#Q;this.#Q=!0;for(let s of t){let r=e.find(a=>a.name===s.name&&a.pos===s.pos);for(let a of r?.bounds??[]){let o=this.#U(a);if(o.tag!=="error"){if(!nt(o)||o.tag==="array"){this.#e(a.pos,w.incompatibleTypes,"unexpected type",[" required: class",` found: ${$(o)}`]);continue}o.tag==="object"&&r.bounds.length===1||s.bounds.push(o)}}}this.#Q=n,this.#E=this.#E.slice(0,-1)}#dr(t,e){for(let s=this.#E.length-1;s>=0;s--){let r=this.#E[s].find(a=>a.name===t);if(r)return me(r)}let n=this.#Y;for(let s=this.#o??null;s;s=s.outer){let r=s.typeParams?.find(a=>a.name===t);if(r)return n?(this.#e(e,w.syntax,`non-static type variable ${t} cannot be referenced from a static context`),A):me(r);s.isInner||(n=!0)}return null}#Ge(t){if(t.kind==="WildcardType"){if(!t.bound)return{tag:"wildcard",bound:null};let e=this.#Ge(t.bound);return e.tag==="error"||e.tag==="wildcard"?A:{tag:"wildcard",bound:e,isSuper:t.isSuper}}return t.kind==="PrimitiveType"?(this.#e(t.pos,w.incompatibleTypes,"unexpected type",[" required: reference",` found: ${t.name}`]),A):this.#U(t)}#mr(t,e){let n=t.typeParams??[];if(e.diamond)return tt(t);if(!n.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,`type ${t.displayName} does not take parameters`),A;let s=e.typeArguments??[];if(s.length!==n.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,`wrong number of type arguments; required ${n.length}`),A;let r=[];for(let o of s){let c=this.#Ge(o);if(c.tag==="error")return A;r.push(c)}let a=tt(t,r);if(!this.#Q){let o=Un(a);for(let c=0;c<n.length;c++){let u=r[c];if(u.tag==="wildcard")continue;if(!n[c].bounds.every(h=>K(u,Kt(h,o))))return this.#e(s[c].pos,w.incompatibleTypes,`type argument ${$(u)} is not within bounds of type-variable ${n[c].name}`,Et([me(n[c])])),A}}return a}#U(t,e=!1){switch(t.kind){case"PrimitiveType":return t.name==="int"?V:t.name==="boolean"?gt:t.name==="char"?Ce:t.name==="long"?Jt:t.name==="double"?ft:t.name==="float"?kt:t.name==="byte"?_n:xn;case"VarType":return this.#a(t.pos,"\'var\' declarations"),A;case"WildcardType":return this.#a(t.pos,"wildcard types"),A;case"VoidType":return this.#e(t.pos,w.syntax,"\'void\' type not allowed here"),A;case"ArrayType":{let n=this.#U(t.element);return n.tag==="error"?A:ee(n)}case"ClassType":{let n=t.names.join(".");if((n==="Object"||n==="java.lang.Object")&&!this.#Ie(t.names))return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,"type Object does not take parameters"),A):G;if(n==="String"||n==="java.lang.String")return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,"type String does not take parameters"),A):mt;if(t.names.length===1){let c=this.#dr(n,t.pos);if(c)return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,w.syntax,`type ${n} does not take parameters`),A):c}if(t.names.length===1&&this.#zn(n,t.pos))return A;let s=this.#Ie(t.names)??this.#Ye(t.names);if(s&&t.names.length>1&&!this.#Gn(s,t.lastDotPos??t.pos,!this.#Gt(t.names[0])))return A;if(s)return t.hasTypeArguments?this.#mr(s,t):tt(s);let r=this.#mt(t.names);if(r)return this.#fr(r,t,e);let a=t.names.length===1?this.#l.get(n):void 0;if(a)return this.#a(t.pos,`the class ${a}`,!0),A;if(t.names.length===1&&(An.has(n)||n===this.#pr()))return this.#a(t.pos,`the type ${n}`,!0),A;if(t.names.length>1&&(t.names[0]==="java"||t.names[0]==="javax"))return this.#a(t.pos,`the type ${n}`,!0),A;let o=t.names.length>1&&!this.#Gt(t.names[0])?this.#in(t.names):0;return o?(this.#e(t.lastDotPos??t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${t.names[o]}`,` location: package ${t.names.slice(0,o).join(".")}`]),A):t.names.length>1?(this.#e(t.lastDotPos??t.pos,w.cantResolve,`package ${t.names.slice(0,-1).join(".")} does not exist`),A):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: class ${this.#o.displayName}`]),A)}}}#fr(t,e,n=!1){let s=t.typeParams;if(t.name==="Class"&&e.typeArguments)return this.#a(e.typeArgumentsPos??e.pos,"Class<...> types (declare the variable as Class)"),A;if(!e.typeArguments)return e.diamond?{tag:"diamond",symbol:t,fromArgs:null}:pt(t);if(e.typeArguments.length!==s.length)return this.#e(e.typeArgumentsPos??e.pos,w.syntax,s.length?`wrong number of type arguments; required ${s.length}`:`type ${t.name} does not take parameters`),A;let r=[];for(let a of e.typeArguments){let o=this.#Ge(a);if(o.tag==="error")return A;r.push(o)}return pt(t,r)}#Ie(t){let e=this.#Gt(t[0]),n=t.slice(1),s=e||t.length<2?0:this.#in(t);s&&(e=this.#Dt(t.slice(0,s).join("."),t[s]),n=t.slice(s+1));for(let r of n)e=e?.membersByName.get(r)??null;return e}#pr(){return this.#W.find(t=>t.declaration.implicit)?.name}#q(t,e,n){e.tag==="error"||n.tag==="error"||this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${Ue(n,e)}`,Et([e,n]))}#k(t,e){let n=this.#yr(t,e);return t.type=n,n}#nt(t,e){let n=this.#k(t,e);return n.tag==="void"?(this.#e(t.pos,w.incompatibleTypes,"\'void\' type not allowed here"),A):n}#yr(t,e){switch(t.kind){case"Literal":switch(t.literalKind){case"int":return t.constant=X(t.value),V;case"char":return t.constant=Gn(t.value.charCodeAt(0)),Ce;case"boolean":return t.constant=Tt(t.value),gt;case"long":return t.constant=_t(t.value),Jt;case"double":return t.constant=ie(t.value),ft;case"float":return t.constant=pe(t.value),kt;case"string":return t.constant=vr(t.value),mt;case"null":return br;default:return this.#a(t.pos,`\'${t.literalKind}\' literals`),A}case"Name":return this.#Er(t);case"Parenthesized":{let n=this.#k(t.expression,e);return t.expression.constant&&(t.constant=t.expression.constant),n}case"FieldAccess":return this.#ns(t);case"MethodCall":{let n=this.#Mr(t,e);return this.#Fe(t.args),n}case"Unary":return this.#ni(t);case"IncDec":return this.#ri(t);case"Binary":return this.#ii(t);case"Assignment":return this.#ai(t);case"ArrayAccess":return this.#oi(t);case"NewArray":return this.#li(t);case"Cast":return this.#ci(t);case"This":return this.#wr(t);case"NewObject":{let n=this.#_r(t,e);return this.#Fe(t.args),n}case"Conditional":return this.#qr(t,e);case"SwitchExpression":return this.#Kn(t,e);case"Lambda":return this.#$n(t,e);case"MethodRef":return t.lambda?.method?e??A:this.#hs(t,e);case"InstanceOf":return this.#Tr(t);case"Super":return this.#Qn(t);case"ClassLiteral":return this.#gr(t)}}#gr(t){let e=this.#cn(t.target);if(!("kind"in e))return e.tag!=="error"&&this.#e(t.target.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${ss(t.target)??"?"}`,` location: class ${this.#o.displayName}`]),A;let n=s=>pt(Wt("Class"),[s]);if(e.symbol)return t.className=e.symbol.binaryName,t.isInterface=e.symbol.isInterface,n(tt(e.symbol));if(e.name==="String")return t.className="java.lang.String",n(mt);if(It[e.name]){let s=Wt(e.name);return t.className=s.qualifiedName,t.isInterface=s.isInterface,n(pt(s))}return e.name==="Object"||e.name==="System"||e.name==="Math"?(t.className=`java.lang.${e.name}`,pt(Wt("Class"))):(this.#a(t.pos,`the class literal ${e.name}.class`,!0),A)}#Yn(t,e){if(!e&&(this.#t||this.#g))return this.#te(t.selectPos,"non-static method getClass() cannot be referenced from a static context"),A;if(e||this.#Zt(),e&&st(e))return this.#e(t.selectPos,w.cantResolve,`${$(e)} cannot be dereferenced`),A;let n=Wt("Class");return t.libraryCall={native:"Object.getClass",isStatic:!1,params:[],returnsValue:!0,display:"Object.getClass()"},pt(n)}#Qn(t){return t.qualifier?this.#br(t,t.qualifier):this.#t?(this.#te(t.pos,"non-static variable super cannot be referenced from a static context"),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),A):this.#o.isInterface?(this.#a(t.pos,"\'super\' in an interface",!0),A):this.#o.superType??(this.#o.superclass?tt(this.#o.superclass):this.#o.librarySuperclass??G))}#br(t,e){let n=t.dotPos??t.pos,s=e.length===1?this.#Gt(e[0]):this.#An(this.#Sr(e,t.qualifierPos??t.pos));if(!s){let a=e[e.length-1];return It[a]||An.has(a)||this.#l.has(a)?(this.#a(t.qualifierPos??t.pos,`\'${a}.super\' of a library type`,!0),A):(this.#e(t.qualifierPos??t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${a}`,` location: class ${this.#o.displayName}`]),A)}let r=()=>(this.#e(n,w.cantResolve,`not an enclosing class: ${s.displayName}`),A);if(s.isInterface){if(this.#t||!this.#o.interfaces.includes(s))return r();let a=this.#o.interfaces.find(o=>o!==s&&Sn(o,s));return a?(this.#e(n,w.cantResolve,`bad type qualifier ${s.displayName} in default super call`,[` redundant interface ${s.displayName} is extended by ${a.displayName}`]),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),A):(t.interfaceSymbol=s,tt(s)))}if(s===this.#o){let a={...t};return delete a.qualifier,this.#Qn(a)}for(let a=this.#o.outer;a;a=a.outer)if(a===s)return this.#a(t.qualifierPos??t.pos,`\'${s.displayName}.super\' of an enclosing class`,!0),A;return r()}#Sr(t,e){let n={kind:"Name",identifier:t[0],depth:1,pos:e,start:e,end:e};for(let s of t.slice(1))n={kind:"FieldAccess",target:n,name:s,namePos:e,depth:1,pos:e,start:e,end:e};return n}#Tr(t){if(t.recordPattern){let r=this.#nt(t.expression);if(r.tag==="error")return A;if(!this.#b)return this.#a(t.recordPattern.pos,"pattern variables in field initializers"),A;let a=[];return this.#kn(t.recordPattern,r,!0,a)?(t.testedType=t.recordPattern.tested,t.patternBindings=a,gt):A}let e=this.#nt(t.expression),n=t.targetType.kind==="ClassType"&&!t.targetType.hasTypeArguments?this.#mt(t.targetType.names):null,s=n&&n.typeParams.length?pt(n):this.#U(t.targetType);if(e.tag==="error"||s.tag==="error")return A;if(st(e)||st(s))return st(s)?this.#e(t.targetType.pos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#e(t.expression.pos,w.incompatibleTypes,"unexpected type",[" required: reference",` found: ${$(e)}`]),A;if(s.tag==="library"&&s.args.some(r=>r.tag!=="wildcard"||r.bound!==null))return this.#a(t.targetType.pos,"instanceof with a generic type",!0),A;if(!ke(s,e))return this.#q(t.expression,e,s),A;if(t.testedType=s,t.binding){if(!this.#b)return this.#a(t.binding.pos,"pattern variables in field initializers"),A;t.binding.symbol=this.#Cn(t.binding.name,s,t.binding.pos,t.binding.isFinal)}return gt}#kn(t,e,n,s){let r=this.#xr(t,e,n,s);return r||this.#Zn(t,s),r}#Zn(t,e){if(t.kind==="RecordPattern")return t.components.forEach(n=>this.#Zn(n,e));t.symbol||t.name==="_"||(t.symbol=this.#Cn(t.name,A,t.namePos,t.isFinal),e.push(t.symbol))}#xr(t,e,n,s){if(t.kind==="TypePattern"){let h;if(t.type===null)h=e;else{let m=t.type.kind==="ClassType"&&!t.type.hasTypeArguments?this.#mt(t.type.names):null;if(h=m&&m.typeParams.length?pt(m):this.#U(t.type,!0),h.tag==="error")return!1;if(n&&(st(e)||st(h))||!n&&st(h)!==st(e)||st(h)&&!at(h,e))return this.#e(t.pos,w.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]),!1;if(h.tag==="library"&&h.args.some(p=>p.tag!=="wildcard"||p.bound!==null))return this.#a(t.pos,"patterns of a parameterized type",!0),!1;if(!st(h)&&!ke(h,e))return this.#q(t,e,h),!1}return t.tested=h,t.unconditional=st(h)||K(W(e),W(h)),t.name!=="_"&&(t.symbol=this.#Cn(t.name,h,t.namePos,t.isFinal),s.push(t.symbol)),!0}let r=this.#U(t.type,!0);if(r.tag==="error")return!1;if(r.tag!=="class"||!r.symbol.isRecord)return this.#e(t.pos,w.syntax,`deconstruction patterns can only be applied to records, ${$(r)} is not a record`),!1;let a=r.symbol,o=r;if(a.typeParams?.length&&!r.args?.length){let h=e.tag==="class"?se(e,a):null;o=h?.args?.length?h:r}if(!ke(o,e))return this.#q(t,e,o),!1;let c=a.components,u=c.map(h=>Me(Ne(o,a,h.type)));if(c.length!==t.components.length){let h=t.components.map(m=>m.kind==="TypePattern"&&m.type===null?"var":$(this.#vr(m)));return this.#e(t.pos,w.syntax,"incorrect number of nested patterns",[` required: ${u.map($).join(",")}`,` found: ${h.join(",")}`]),!1}t.tested=o,t.accessors=c.map(h=>this.#wt(a,h.name).find(m=>!m.isStatic&&m.params.length===0));let d=!0;return t.components.forEach((h,m)=>{this.#kn(h,u[m],!1,s)||(d=!1)}),d}#vr(t){return t.type?this.#ms(t.type):G}#Cn(t,e,n,s){let r=this.#b;(this.#lt(t)||this.#Pn(t))&&this.#e(n,w.alreadyDefined,`variable ${t} is already defined in ${r.isConstructor?"constructor":"method"} ${this.#Ht(r)}`);let a={kind:"local",name:t,type:e,index:r.locals.length,slot:this.#c,isFinal:s,declPos:n,binding:!0};return this.#c+=Be(e),r.maxSlots=Math.max(r.maxSlots,this.#c),r.locals.push(a),a}#ft(t,e){switch(t.kind){case"Parenthesized":return this.#ft(t.expression,e);case"Unary":return t.operator==="!"?this.#ft(t.operand,!e):[];case"InstanceOf":return e?t.binding?.symbol?[t.binding.symbol]:t.patternBindings??[]:[];case"Binary":return t.operator==="&&"&&e?[...this.#ft(t.left,!0),...this.#ft(t.right,!0)]:t.operator==="||"&&!e?[...this.#ft(t.left,!1),...this.#ft(t.right,!1)]:[];default:return[]}}#Qt(t,e){if(!t.length)return e();this.#Pt();let n=this.#f[this.#f.length-1];for(let a of t)n.names.set(a.name,a);let s=e(),r=this.#c;return this.#Mt(),this.#c=r,s}#Ke(t){let e=this.#f[this.#f.length-1];for(let n of t)e.names.has(n.name)||this.#lt(n.name)||(e.names.set(n.name,n),this.#j.push(n))}#wr(t){return t.qualifier?this.#kr(t,t.qualifier):this.#t?(this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A):(this.#Zt(),this.#g?(this.#a(t.pos,"using \'this\' in the arguments of \'this(...)\'",!0),A):fe(this.#o))}#kr(t,e){let n=this.#Ie(e),s=0,r=this.#o;for(;r&&r!==n;)r=r.outer,s++;return!n||!r?(this.#e(t.pos,w.syntax,`not an enclosing class: ${e[e.length-1]}`),A):this.#t||!this.#sn(s)?(this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A):(this.#Zt(),s&&(t.outerHops=s),fe(n))}#Cr(t,e){let n=t.captures?.find(d=>d.local.name===e);if(n)return n.field;let s=this.#N.get(t);if(!s)return null;let r;for(let d=s.scopes.length-1;d>=0&&!r;d--)r=s.scopes[d].names.get(e);if(!r)return null;let a=t.declaration.pos,o={name:`val$${e}`,extraDims:0,init:null,pos:a,start:a,end:a},c={kind:"FieldDeclaration",modifiers:{keywords:[]},type:{kind:"VoidType",pos:a,start:a,end:a},declarators:[o],pos:a,start:a,end:a},u={kind:"field",name:`val$${e}`,type:r.type,owner:t,isStatic:!1,isFinal:!0,isPrivate:!0,access:"private",index:t.instanceCount++,order:t.fields.length,state:"done",declaration:c,declarator:o,capturedLocal:r};return t.fields.push(u),(t.captures??=[]).push({field:u,local:r}),u}#Er(t){let e=this.#lt(t.identifier);if(e)return e.captureOf&&this.#ne.push({local:e,pos:t.pos,top:this.#o.topLevel}),t.symbol=e,e.constant&&(t.constant=e.constant),e.type;let n=this.#Yt(t.identifier);if(n){let{field:r,hops:a}=n,o=this.#o;for(let u=0;u<a;u++)o=o.outer;if(r.isPrivate&&r.owner!==o&&!this.#Gs(r.owner,o))return this.#e(t.pos,w.cantResolve,`${r.name} has private access in ${r.owner.displayName}`),A;if(!r.isStatic){if(this.#t||!this.#sn(a))return this.#te(t.pos,`non-static variable ${r.name} cannot be referenced from a static context`),A;if(this.#Zt(),this.#g&&a===0)return this.#a(t.pos,"using the object\'s fields in the arguments of \'this(...)\'"),A}let c=this.#it??this.#St;return a===0&&c&&!this.#P&&!r.capturedLocal&&r.owner===c.owner&&r.isStatic===c.isStatic&&r.order>=c.order?(this.#e(t.pos,w.syntax,r===c?"self-reference in initializer":"illegal forward reference"),A):(t.symbol=r,a>0&&!r.isStatic&&(t.outerHops=a),r.capturedLocal&&this.#ne.push({local:r.capturedLocal,pos:t.pos,top:this.#o.topLevel,inner:!0}),this.#En(t,r,r.isStatic?void 0:fe(o)))}let s=this.#be(t);if(s==="error")return A;if(s){t.imported=s;let r=this.#ns(s);return s.type=r,s.constant&&(t.constant=s.constant),r}return this.#fe(t.identifier,t.pos)?A:(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.identifier}`,` location: class ${this.#o.displayName}`]),A)}#En(t,e,n){if(e.isFinal&&e.state==="pending"&&this.#Hn(e),e.constant&&(t.constant=e.constant),!n)return e.type;let s=Me(Ne(n,e.owner,e.type));return Ca(t,e.type,s),s}#cn(t){if(t.kind==="Name"&&t.staticOwner)return t.staticClass?(t.symbol={kind:"type",name:t.identifier,symbol:t.staticClass},{kind:"type",name:t.identifier,symbol:t.staticClass}):(t.symbol={kind:"type",name:t.identifier},{kind:"type",name:t.identifier,qualified:!0});if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)&&(this.#h(t.identifier,this.#Nt).length||this.#ye(t.identifier,"field").length))return this.#k(t);if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)){let e=t.identifier;if(this.#zn(e,t.pos))return A;let n=this.#Gt(e);if(n)return t.symbol={kind:"type",name:e,symbol:n},{kind:"type",name:e,symbol:n};let s=this.#Ye([e]);if(s)return t.symbol={kind:"type",name:e,symbol:s},{kind:"type",name:e,symbol:s};if(e==="System"||e==="String"||An.has(e)||It[e]&&this.#un(e))return t.symbol={kind:"type",name:e},{kind:"type",name:e};if(this.#l.get(e))return t.symbol={kind:"type",name:e},{kind:"type",name:e}}if(t.kind==="FieldAccess"){if(t.target.kind==="Name"&&Mt[t.name]===t.target.identifier&&!this.#lt(t.target.identifier)&&this.#un(t.target.identifier))return{kind:"type",name:t.name,qualified:!0};let e=ss(t.target);if(e?.startsWith("java.")&&!this.#lt("java")&&!this.#Yt("java")){if(It[t.name]===e&&!Mt[t.name]||e==="java.lang"&&(t.name==="Math"||t.name==="System"||t.name==="String"))return{kind:"type",name:t.name,qualified:!0};let o=e.slice(e.lastIndexOf(".")+1);if(Mt[t.name]===o&&It[o]===e.slice(0,e.lastIndexOf(".")))return{kind:"type",name:t.name,qualified:!0};if((Yn[e]??[]).includes(t.name))return this.#a(t.target.pos,`the class ${e}.${t.name}`,!0),A}let n=this.#ts(t.target);if(n!==null){let a=this.#Dt(n,t.name);return a?this.#Gn(a,t.pos)?(t.typeSymbol=a,{kind:"type",name:a.name,symbol:a}):A:(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${t.name}`,` location: package ${n}`]),A)}let s=this.#An(t.target),r=s?.membersByName.get(t.name);if(s&&r&&!s.fieldsByName.has(t.name))return t.typeSymbol=r,{kind:"type",name:r.name,symbol:r}}return this.#k(t)}#ts(t){let e=ss(t);if(e===null||!this.#G.has(e))return null;let n=t;for(;n.kind==="FieldAccess";)n=n.target;return n.kind!=="Name"||this.#lt(n.identifier)||this.#Yt(n.identifier)||this.#Gt(n.identifier)?null:e}#un(t){let e=It[t];return Mt[t]?this.#X.has(t):e==="java.lang"||this.#X.has(t)||e!==void 0&&this.#r.has(e)||this.#d.compact}#An(t){if(t.kind==="Name"&&!this.#lt(t.identifier)&&!this.#Yt(t.identifier)){let e=this.#Gt(t.identifier);return e&&(t.symbol={kind:"type",name:t.identifier,symbol:e}),e}if(t.kind==="FieldAccess"){let e=this.#ts(t.target);if(e!==null){let r=this.#Dt(e,t.name);return r&&(t.typeSymbol=r),r}let n=this.#An(t.target),s=n?.membersByName.get(t.name);if(n&&s&&!n.fieldsByName.has(t.name))return t.typeSymbol=s,s}return null}#De(t,e){if(!t)return` location: class ${this.#o.displayName}`;let n=Q(t);return n.kind==="Name"&&n.symbol?.kind==="local"?` location: variable ${n.identifier} of type ${$(e)}`:n.kind==="Name"&&n.symbol?.kind==="field"?` location: variable ${n.identifier} of type ${$(e)}`:n.kind==="FieldAccess"&&(n.field&&n.field!=="length"||n.fieldSymbol)?` location: variable ${n.name} of type ${$(e)}`:` location: ${e.tag==="library"&&e.symbol.isInterface||e.tag==="class"&&e.symbol.isInterface?"interface":"class"} ${$(e)}`}#Oe(t,e,n,s=null){if(t.isPrivate)return t.owner.topLevel===this.#o.topLevel?!0:(this.#e(e,w.cantResolve,`${n} has private access in ${t.owner.displayName}`),!1);let r=this.#es(t,n,s);return r&&this.#e(e,w.cantResolve,r),r===null}#es(t,e,n=null){let s=t.access??"public";return s==="public"||s==="private"||t.owner.packageName===this.#o.packageName||s==="protected"&&this.#Ar(t,n)?null:s==="protected"?`${e} has protected access in ${t.owner.displayName}`:`${e} is not public in ${t.owner.displayName}; cannot be accessed from outside package`}#Ar(t,e){if(t.isConstructor)return e==="super";let n=(s,r)=>{for(let a=s;a;a=a.superclass)if(a===r)return!0;return!1};for(let s=this.#o;s;s=s.outer)if(n(s,t.owner)&&(t.isStatic||e===null||e==="super"||n(e,s)))return!0;return!1}#ns(t){let e=Q(t.target);if(e.kind==="Super"&&e.qualifier){if(this.#k(e).tag==="error")return A;if(e.interfaceSymbol)return this.#e(e.dotPos??e.pos,w.cantResolve,`not an enclosing class: ${e.interfaceSymbol.displayName}`),A}let n=this.#cn(t.target);if("kind"in n&&n.kind==="type"){if(n.symbol){let d=n.symbol,h=this.#Ee(d,t.name);return h?h.isPrivate&&h.owner!==d?(this.#e(t.pos,w.cantResolve,`${h.name} has private access in ${h.owner.displayName}`),A):h.isStatic?this.#Oe(h,t.pos,h.name)?(t.fieldSymbol=h,this.#En(t,h)):A:(this.#te(t.pos,`non-static variable ${h.name} cannot be referenced from a static context`),A):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,` location: class ${d.displayName}`]),A)}if(n.name==="System")return t.name==="out"||t.name==="err"?(t.field=t.name==="out"?"System.out":"System.err",Qi):t.name==="in"?(t.field="System.in",pt(te("InputStream"))):(this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`," location: class System"]),A);let a=Object.hasOwn(Ls,n.name)?Ls[n.name]:{},o=Object.hasOwn(a,t.name)?a[t.name]:void 0;if(o)return t.constant=o.constant,o.type;let c=It[n.name]?n.qualified?Wt(n.name)??null:this.#mt([n.name]):n.name==="String"&&!n.symbol?te("String"):null,u=c?.staticFields&&Object.hasOwn(c.staticFields,t.name)?c.staticFields[t.name]:void 0;return c&&u?(t.libraryField=`${c.name}.${t.name}`,u):(this.#a(t.pos,`the field ${n.name}.${t.name}`,!0),A)}let s=n,r=s.tag==="typevar"&&s.symbol?s.symbol.bounds.find(a=>a.tag==="class")??G:s;switch(r.tag){case"error":return A;case"class":{let a=this.#Ee(r.symbol,t.name);if(a){if(a.isPrivate&&a.owner!==r.symbol)return this.#e(t.pos,w.cantResolve,`${a.name} has private access in ${a.owner.displayName}`),A;let o=Q(t.target).kind;return this.#Oe(a,t.pos,a.name,o==="This"||o==="Super"?null:r.symbol)?(t.fieldSymbol=a,this.#En(t,a,a.isStatic?void 0:s)):A}break}case"library":{let a=r.symbol.instanceFields;if(a&&Object.hasOwn(a,t.name))return t.libraryField=`${r.symbol.name}#${t.name}`,a[t.name];break}case"null":return this.#e(t.pos,w.cantResolve,"<null> cannot be dereferenced"),A;case"array":if(t.name==="length")return t.field="length",V;break;default:if(st(s)||s.tag==="void")return this.#e(t.pos,w.cantResolve,`${$(s)} cannot be dereferenced`),A}return this.#e(t.pos,w.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,this.#De(t.target,s),...Et([s])]),A}#ue(t){return t.map(e=>{let n=Q(e);if(n.kind==="MethodRef")return{tag:"lambda",arity:this.#We(n)?.params.length??-1,text:Cs(n)};if(n.kind==="Lambda")return{tag:"lambda",arity:n.params.length,text:Cs(n)};let s=this.#ss(e);if(s)return this.#st.add(e),{tag:"diamond",symbol:s,fromArgs:null};let r=n.kind==="NewObject"&&n.body&&n.classType.kind==="ClassType"&&n.classType.diamond?this.#mt(n.classType.names):null;if(r)return this.#st.add(e),{tag:"diamond",symbol:r,fromArgs:null};this.#u=e;let a=this.#nt(e),o=this.#L.get(n);if(!o||a.tag!=="library"||n.kind!=="MethodCall")return a;let c=new Map;return this.#he(o.method,o.types,c),{...a,args:a.args.map((u,d)=>{let h=o.method.returnType.tag==="library"?o.method.returnType.args[d]:void 0;if(!o.flags[d]||h?.tag!=="typevar")return u;let m=Ve([h],o.symbol,Oa(o.symbol,o.method,o.types.length));return{tag:"wildcard",bound:u,poly:{name:h.name,lows:c.get(h.name)??[],where:m}}})}})}#ss(t){if(t.kind!=="MethodCall")return null;let e;if(t.target){let a=Ee(t.target);if(!a||this.#lt(a[0])||this.#Yt(a[0]))return null;e=a.length===2&&Mt[a[1]]===a[0]&&this.#un(a[0])?Wt(a[1])??null:this.#mt(a)}else{let a=this.#p.size||this.#s.length?this.#h(t.name,this.#tt):[];if(a.length!==1||this.#pe(t.name))return null;e=this.#et(a[0])}if(!e)return null;let n=e.methods.filter(a=>a.name===t.name&&a.isStatic);if(!n.length||n.some(a=>!a.typeParams?.length))return null;let s=n[0].returnType;return s.tag!=="library"||n.some(a=>a.returnType.tag!=="library"||a.returnType.symbol!==s.symbol)?null:t.args.length===0||t.args.some(a=>{let o=Q(a);return o.kind==="Lambda"&&o.params.some(c=>!c.type)||o.kind==="MethodRef"&&(!this.#We(o)||this.#On(o))||this.#ss(o)!==null})?s.symbol:null}#Fe(t){for(let e of t)this.#st.has(e)&&(this.#st.delete(e),e.type=this.#k(e))}#Ft(t,e){return`${t}(${e.map($).join(",")})`}#Ir(t,e,n=fe(t)){let s=this.#wt(t,e).map(a=>{let o=c=>a.isStatic?c:Me(Ne(n,a.owner,c));return{owner:a.owner.displayName,name:a.name,params:a.params.map(o),returnType:o(a.returnType),method:a,...Ea(a)?{varargs:!0}:{}}}),r=$e[e];return r&&Object.hasOwn($e,e)&&!s.some(a=>a.params.length===r.params.length&&a.params.every((o,c)=>at(o,r.params[c])))&&s.push(r),s}#In(t,e,n){return!t.builtin||t.constructors.some(s=>s.params.length===e)?!1:(this.#a(n,`this ${t.name} constructor`,!0),!0)}#Or(t,e){if(!this.#oe(tt(t)))return null;let n=this.#wt(t,e.name);return(e.name==="getStackTrace"||e.name==="setStackTrace")&&!n.length?`the method Throwable.${e.name}()`:e.name==="printStackTrace"&&e.args.length&&!n.some(r=>r.params.length===e.args.length)?"printStackTrace to a stream":el[t.binaryName]?.includes(e.name)&&!n.length?`the method ${t.name}.${e.name}()`:null}#qe(t,e){let n=t.isEnum?"enum":t.isRecord?"record":"class",s=e?.tag==="class"?Un(e):new Map,r=e!==void 0&&Bn(e);return t.constructors.map(a=>({owner:t.displayName,ownerKind:n,name:t.name,params:a.params.map(o=>r?W(o):Kt(o,s)),returnType:xt,method:a,...Ea(a)?{varargs:!0}:{}}))}#_e(t,e){if(!t.expanded||!t.method)return;let n=t.params[t.params.length-1],s=n.element;return!Ln(n)&&!this.#Jt(t.method.declaration.modifiers,"SafeVarargs")&&this.#at(e,"unchecked",`unchecked generic array creation for varargs parameter of type ${$(n)}`,Et([n])),{from:t.params.length-1,element:s}}#Lr(t,e,n,s,r,a){let o=t.method?.typeParams;if(!o)return t;let c=o.map(h=>h.key),u=new Map,d=new Map;if(n){if(n.length!==o.length)return{...t,shown:t.params,problem:{reason:`wrong number of type arguments; required ${o.length}`,alone:!0}};o.forEach((h,m)=>u.set(h.key,n[m]))}else{ka(c,Aa(t,e),e,u,d);let h=[...d.keys()].filter(m=>!u.has(m));for(let[m,p]of d)u.has(m)||u.set(m,p.reduce(Ar));if(s&&(t.returnType.tag==="library"||t.returnType.tag==="class")){let m=new Map;bt(t.returnType,s,m);for(let p of h){let k=m.get(p);!k||k===Hn||k.tag==="wildcard"||k.tag==="typevar"&&!k.symbol||d.get(p).every(g=>K(g,k))&&u.set(p,k)}}r.forEach((m,p)=>{let k=Q(m),g=k.kind==="MethodRef"&&t.params[p]?Ps(Kt(t.params[p],u)):null;if(!g||k.kind!=="MethodRef")return;let O=this.#We(k,g.params[0]&&!ue(g.params[0],c)?g.params[0]:void 0);O&&(O.params.forEach((T,x)=>g.params[x]&&bt(g.params[x],qt(T)??T,u)),O.returnType.tag!=="void"&&bt(g.returnType,qt(O.returnType)??O.returnType,u))}),a&&o.some(m=>!u.has(m.key))&&this.#Nr(t.params,r,u,c),s&&t.returnType.tag!=="void"&&o.some(m=>!u.has(m.key))&&bt(t.returnType,s,u);for(let m of o){let p=u.get(m.key);if(!p||m.bounds.every(T=>K(p,Kt(T,u))))continue;let k=d.get(m.key)??[p],g=`inference variable ${m.name} has incompatible bounds`,O=k.length>1&&m.bounds.some(T=>ue(T,[m.key]))?[g,` equality constraints: ${k.map($).join(",")}`,` lower bounds: ${[...k].reverse().map($).join(",")}`]:[g,` upper bounds: ${m.bounds.map($).join(",")}`,` lower bounds: ${k.map($).join(",")}`];return{...t,shown:t.params,problem:{reason:O.join(`\n`)}}}}for(let h of o)u.has(h.key)||u.set(h.key,W(me(h)));return{...t,shown:t.params,params:t.params.map(h=>Kt(h,u)),returnType:Kt(t.returnType,u)}}#Nr(t,e,n,s){let r=a=>ue(a,s.filter(o=>!n.has(o)));e.forEach((a,o)=>{let c=Q(a);if(!t[o])return;if(c.kind==="MethodRef"&&c.name==="new"&&!c.arrayType&&c.target){let m=this.#dn(Kt(t[o],n)),p=Ee(c.target),k=p&&!this.#lt(p[0])?this.#mt(p):null;k&&!("problem"in m)&&!m.params.some(r)&&r(m.returnType)&&bt(m.returnType,{tag:"library",symbol:k,args:k.typeParams.map(()=>G)},n);return}if(c.kind!=="Lambda"||c.method)return;let u=Kt(t[o],n),d=this.#dn(u);if("problem"in d||d.params.some(r)||!r(d.returnType))return;this.#$n(c,u,s.filter(m=>!n.has(m)));let h=c.method?.returnType;h&&h.tag!=="error"&&h.tag!=="void"&&bt(d.returnType,qt(h)??h,n)})}#$r(t){let e=0;for(let n=this.#o;n;n=n.outer,e++)if(this.#wt(n,t).length||Object.hasOwn($e,t))return{owner:n,hops:e};return{owner:this.#o,hops:0}}#Pr(t,e){return t.tag!=="class"?null:Le(t).find(n=>n.symbol.methods.some(s=>s.name===e&&!s.isStatic))??null}#Mr(t,e){let n=null,s=t.target===null?this.#ue(t.args):null;if(s&&(this.#p.size||this.#s.length||this.#d.programStatic.length)&&!s.some(m=>m.tag==="error")&&!this.#ie(t,s))return A;t.target&&(n=this.#cn(t.target));let r=s??this.#ue(t.args);if(r.some(m=>m.tag==="error")||n&&"tag"in n&&n.tag==="error")return A;let a=t.typeArguments?t.typeArguments.map(m=>this.#Ge(m)):null;if(a?.some(m=>m.tag==="error"))return A;let o=n;if(n&&"tag"in n&&n.tag==="typevar"&&n.symbol){let m=k=>k.tag==="class"&&this.#wt(k.symbol,t.name).length>0||k.tag==="library"&&k.symbol.methods.some(g=>g.name===t.name),p=n.symbol.bounds.find(m)??(Object.hasOwn($e,t.name)?G:null);if(!p)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,this.#De(t.target,n),...Et([n,...r])]),A;n=p}if(t.name==="getClass"&&!r.length&&(n===null||"tag"in n)&&!(n===null&&this.#wt(this.#o,"getClass").length))return this.#Yn(t,n);let c=n===null?this.#o.isEnum:"tag"in n&&n.tag==="class"&&n.symbol.isEnum;if(t.name==="getDeclaringClass"&&!r.length&&c){let m=this.#Yn(t,n);return t.libraryCall&&(t.libraryCall.native="Enum.getDeclaringClass",t.libraryCall.display=`${n?.symbol.binaryName??this.#o.binaryName}.getDeclaringClass()`),m}let u=n!==null&&"kind"in n&&n.symbol!==void 0,d=n!==null&&"tag"in n&&n.tag==="class";if(!n||u||d){let m,p=0;if(n?m=n.symbol:{owner:m,hops:p}=this.#$r(t.name),$s.has(t.name)&&!this.#wt(m,t.name).length)return this.#a(t.selectPos,`the method Object.${t.name}()`,!0),A;let k=this.#Or(m,t);if(k)return this.#a(t.selectPos,k,!0),A;let g=d?o:fe(m),O=this.#Ir(m,t.name,g),T=O.map(P=>this.#Lr(P,r,a,e,t.args,O.length===1)),x=t.target?Q(t.target):null,v=x?.kind==="Super"?x.interfaceSymbol:void 0;if(!T.length&&v)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`]),A;let R=P=>P.params.length===r.length&&P.params.every((B,N)=>Ht(B,r[N])||Re(B,r[N]))||P.varargs===!0&&r.length>=P.params.length-1,L=!u&&!v&&!T.some(R)?this.#Pr(g,t.name):null;if(L){if(!n){if(p>0)return this.#a(t.selectPos,"calling an enclosing class\'s library methods by simple name",!0),A;if(this.#t)return this.#te(t.selectPos,`non-static method ${t.name}(${L.symbol.methods.find(B=>B.name===t.name).params.map($).join(",")}) cannot be referenced from a static context`),A;let P={kind:"This",depth:0,pos:t.pos,start:t.pos,end:t.pos};this.#k(P),t.target=P}return this.#Ue(t,L.symbol,L,r,e)}if(!T.length){let P=this.#Ks(m,t.name);if(P)return this.#e(t.selectPos,w.cantResolve,`${t.name}(${P.params.map($).join(",")}) has private access in ${P.owner.displayName}`),A;if(!n&&this.#fe(t.name,t.selectPos))return A;let B=u?` location: class ${m.displayName}`:n?this.#De(t.target,n):` location: class ${this.#o.displayName}`;return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,B,...Et([...d?[n]:[],...r])]),A}let C=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},T,r,"method");if(!C)return A;let M=C.method?C.method.isStatic:!1;if(v&&M)return this.#e(t.pos,w.cantResolve,"illegal static interface method call",[` the receiver expression should be replaced with the type qualifier \'${v.displayName}\'`]),A;let _=u||!n&&(this.#t||!this.#sn(p));if(!M&&_)return this.#te(t.selectPos,`non-static method ${t.name}(${C.params.map($).join(",")}) cannot be referenced from a static context`),A;if(!M&&!n&&this.#Zt(),!M&&!n&&this.#g&&p===0)return this.#a(t.selectPos,"calling the object\'s methods in the arguments of \'this(...)\'"),A;let j=t.target!==null&&Q(t.target).kind==="Super";if(C.method){if(!this.#Oe(C.method,t.selectPos,`${t.name}(${C.params.map($).join(",")})`,d&&!j&&t.target&&Q(t.target).kind!=="This"?m:null))return A;if(j&&C.method.isAbstract)return this.#e(t.selectPos,w.syntax,`abstract method ${this.#Ht(C.method)} in ${C.method.owner.displayName} cannot be accessed directly`),A;if(u&&C.method.isStatic&&C.method.owner.isInterface&&C.method.owner!==m)return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,` location: class ${m.displayName}`]),A;if(!this.#ls(t,C,r))return A;t.method=C.method;let P=this.#_e(C,t.pos);P&&(t.varargs=P);let B=C.method.params;d&&Bn(o)&&B.some(N=>rs([N]).some(F=>F.ofClass))&&this.#at(t.pos,"unchecked",`unchecked call to ${this.#Ht(C.method)} as a member of the raw type ${$(o)}`,Et(B)),this.#rs(t.pos,`method ${t.name} in ${m.isInterface?"interface":"class"} ${m.displayName}`,B,C.params,r,t.args,Et),this.#hn(t.args,B.map(W)),t.qualifier=C.method.isStatic?C.method.owner.binaryName:m.binaryName}else t.objectMethod=C.objectMethod,t.qualifier=m.isInterface&&!j?m.binaryName:"Object";return j&&(t.isSuper=!0),!n&&p>0&&!M&&(t.outerHops=p),C.method&&Ca(t,C.method.returnType,C.returnType),C.returnType}if("kind"in n&&n.name==="IO")return this.#Xr(t,r);if("kind"in n&&n.name==="Math"&&Object.hasOwn(Wn,t.name))return this.#Wr(t,r);if("kind"in n&&!n.symbol&&(n.name==="Math"||n.name==="String"))return this.#Ue(t,te(n.name),null,r,e);if("kind"in n&&this.#l.has(n.name))return this.#a(t.target.pos,`the class ${this.#l.get(n.name)}`,!0),A;if("kind"in n&&It[n.name]&&(n.qualified||this.#un(n.name)))return this.#Ue(t,Wt(n.name),null,r,e);if("kind"in n)return n.name==="System"&&!n.symbol?ma.has(t.name)?this.#Ue(t,te("System"),null,r,e):(this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`," location: class System"]),A):(this.#a(t.selectPos,`${n.name}.${t.name}()`,!0),A);let h=n.tag==="diamond"?this.#Ln(n):n;switch(h.tag){case"null":return this.#e(t.selectPos,w.cantResolve,"<null> cannot be dereferenced"),A;case"printstream":return this.#ei(t,h,r);case"library":return this.#Ue(t,h.symbol,h,r,e);case"string":{let m=Object.hasOwn(Qn,t.name)?Qn[t.name]:void 0;if(m){let p=this.#ct({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.stringMethod=t.name,p.returnType):A}if(qo.has(t.name)){let p=te("String");return this.#Ue(t,p,pt(p),r,e)}break}case"object":case"array":{let m=Object.hasOwn($e,t.name)?$e[t.name]:void 0;if(m){let p=this.#ct({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.objectMethod=p.objectMethod,t.qualifier="Object",Q(t.target).kind==="Super"&&(t.isSuper=!0),p.returnType):A}if(h.tag==="array"&&t.name==="clone"&&!r.length)return te("String"),t.libraryCall={native:"Array.clone()",isStatic:!1,params:[],returnsValue:!0,display:`${Ft(h)}.clone()`},h;if($s.has(t.name)||h.tag==="array"&&Xo.has(t.name))return this.#a(t.selectPos,h.tag==="array"?`the array method ${t.name}()`:`the method Object.${t.name}()`,!0),A;break}default:if(st(h)||h.tag==="void")return this.#e(t.selectPos,w.cantResolve,`${$(h)} cannot be dereferenced`),A}return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,r)}`,this.#De(t.target,h)]),A}#Ue(t,e,n,s,r){let a=n?n.args:[],o=n!==null&&!n.args.length&&e.typeParams.length>0,c=e.methods.filter(P=>P.name===t.name);if(!c.length&&(e.unsupported.has(t.name)||$s.has(t.name)))return this.#a(t.selectPos,`the ${e.name} method ${t.name}()`,!0),A;if(!c.length){let P=n?this.#De(t.target,n):` location: class ${e.name}`;return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,s)}`,P]),A}let u=t.typeArguments?t.typeArguments.map(P=>this.#Ge(P)):null,d=P=>u!==null&&u.length===(P.typeParams?.length??0)&&u.length>0,h=c.map(P=>{let B=[...P.isStatic?[]:e.typeParams,...P.typeParams??[]],N=u&&u.length===(P.typeParams?.length??0)?u:this.#Jr(P,s),F=[...P.isStatic?[]:a.map(bl),...N],q=[...P.isStatic?[]:a.map(Me),...N],Z=o&&!P.isStatic;return{owner:P.owner,name:P.name,params:P.params.map(ne=>Z?W(ne):wt(ne,B,F)),returnType:Z?W(P.returnType):wt(P.returnType,B,q),library:P,...P.varargs?{varargs:!0}:{}}}),m=this.#ct({pos:t.selectPos,name:t.name,imported:fa(t),args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},h,s,"method");if(!m)return A;let p=m.library,k=this.#he(p,s),g=!o&&s.some((P,B)=>p.params[B]!==void 0&&Re(p.params[B],P));if(p.comparableParams&&!g&&p.comparableParams.some(P=>k.has(P)&&!ja(k.get(P))))return this.#a(t.selectPos,`${e.name}.${t.name}() of elements that are not Comparable`,!0),A;if(!p.native)return this.#a(t.selectPos,`${e.name}.${t.name}(${p.params.map(Je).join(", ")})`,!0),A;if(!p.isStatic&&!n)return this.#e(t.selectPos,w.cantResolve,`non-static method ${t.name}(${m.params.map($).join(",")}) cannot be referenced from a static context`),A;let O=!o&&p.typeParams?.length&&!d(p)&&t.args.some(P=>["Lambda","MethodRef"].includes(Q(P).kind)||this.#st.has(P)),T=t.args.filter(P=>this.#st.has(P)),x=this.#m.items.length,v=O?this.#Rr(p,e,a,t.args,s,r,m.params):null;if(O&&this.#os(t,m,p,e,a,s,x))return A;let R=!O&&p.isStatic&&p.typeParams?.length&&!d(p)&&r?this.#is(t,e,p,s,r):null;if(!O&&!r&&p.isStatic&&p.typeParams?.length&&!d(p)&&p.returnType.tag==="library"){let P=new Map;this.#he(p,s,P);let B=p.returnType.args.map(N=>N.tag==="typevar"&&!N.symbol&&P.has(N.name));B.some(Boolean)&&this.#L.set(t,{flags:B,symbol:e,method:p,types:s})}if(R==="error")return A;let L=R?p.typeParams.map(P=>R.get(P)??G):[];if(R&&(m.params=m.params.map((P,B)=>wt(p.params[Math.min(B,p.params.length-1)],p.typeParams,L))),v||p.typeParams?.length){if(this.#de(t.args,v?v.params:m.params),p.typeParams?.length&&this.#os(t,m,p,e,a,s,x))return A}else if(!this.#ls(t,m,s))return A;let C=t.target?Q(t.target).kind:null;if(p.isProtected&&!(C==="This"||C==="Super"))return this.#e(t.selectPos,w.cantResolve,`${p.name}(${p.params.map($).join(",")}) has protected access in ${e.name}`,Ve(p.params,e,p)),A;t.libraryCall=this.#Xe(p,n??pt(e),m.params),u||(t.libraryMethod={method:p,symbol:e,classArgs:a}),m.expanded&&(t.libraryCall.varargsFrom=m.params.length-1),C==="Super"&&(t.libraryCall.onBase=!0);let M=P=>Ve(P,e,p);if(o&&!p.isStatic&&p.params.some(P=>ue(P,null))&&this.#at(t.pos,"unchecked",`unchecked call to ${p.name}(${p.params.map($).join(",")}) as a member of the raw type ${e.name}`,M(p.params)),this.#rs(t.pos,`method ${p.name} in ${e.isInterface?"interface":"class"} ${e.name}`,p.params,m.params,s,t.args,M),this.#hn(t.args,p.params.map(W)),o)return Me(m.returnType);if(g)return W(p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a));let _=d(p)?m.returnType:R?wt(p.returnType,p.typeParams,L):v?.returnType??this.#as(p,e,a,s,r)??m.returnType;if(p.typeParams?.length&&T.length&&!d(p)){let P=new Map(v?.bound??this.#he(p,s)),B=p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a);if(r?.tag==="library"&&B.tag==="library"){let N=Dt(B,r.symbol);N&&N.args.forEach((F,q)=>ge(r.args[q])&&bt(F,ge(r.args[q]),P))}t.args.forEach((N,F)=>T.includes(N)&&N.type&&bt(p.params[Math.min(F,p.params.length-1)],N.type,P)),_=this.#as(p,e,a,s,r,P)??_}let j=_.tag==="typevar"&&!_.symbol?G:Me(_);return p.returnType.tag==="typevar"&&yl(j)&&(t.genericCast=W(j)),j}#rs(t,e,n,s,r,a,o){let c=r.map((u,d)=>s[d]!==void 0&&(!Ht(s[d],u)||n[d]!==void 0)&&Re(n[d]??s[d],u));c.some(Boolean)&&(this.#at(t,"unchecked",`unchecked method invocation: ${e} is applied to given types`,[` required: ${n.map($).join(",")}`,` found: ${r.map($).join(",")}`,...o([...n,...r])]),c.forEach((u,d)=>{u&&this.#at(a[d].pos,"unchecked","unchecked conversion",[` required: ${$(n[d])}`,` found: ${$(r[d])}`,...o([n[d],r[d]])])}))}#hn(t,e){t.forEach((n,s)=>{e[Math.min(s,e.length-1)]?.tag==="object"&&delete Q(n).genericCast})}#Rr(t,e,n,s,r,a,o){let c=t.typeParams,u=C=>t.isStatic?C:Xt(C,e.typeParams,n),d=C=>u(t.params[Math.min(C,t.params.length-1)]),h=this.#he(t,r),m=C=>ue(C,c.filter(M=>!h.has(M))),p=(C,M)=>{let _=M.params[0]&&!m(M.params[0])?M.params[0]:void 0;if(!_&&this.#On(C))return!1;let j=this.#We(C,_);return j&&(j.params.forEach((P,B)=>M.params[B]&&bt(M.params[B],P,h)),j.returnType.tag!=="void"&&bt(M.returnType,qt(j.returnType)??j.returnType,h)),!0},k=[];s.forEach((C,M)=>{let _=Q(C),j=Ps(d(M));j&&(_.kind==="MethodRef"?p(_,j)||k.push(M):_.kind==="Lambda"&&_.params.length&&_.params.every(P=>P.type)&&_.params.forEach((P,B)=>{let N=this.#U(P.type);N.tag!=="error"&&j.params[B]&&bt(j.params[B],N,h)}))});let g=u(t.returnType);if(a?.tag==="library"&&g.tag==="library"){let C=Dt(g,a.symbol);C&&C.args.forEach((M,_)=>ge(a.args[_])&&bt(M,ge(a.args[_]),h))}for(let C of k){let M=c.filter(j=>h.has(j)),_=Ps(Xt(d(C),M,M.map(j=>h.get(j))));_&&p(Q(s[C]),_)}let O=()=>c.filter(C=>h.has(C)),T=C=>Xt(d(C),O(),O().map(M=>h.get(M)));s.forEach((C,M)=>{this.#st.has(C)&&(this.#st.delete(C),C.type=this.#k(C,T(M)),C.type.tag!=="error"&&bt(d(M),C.type,h))});let x=new Map;s.forEach((C,M)=>{let _=Q(C);if(_.kind==="Lambda"?_.method:_.kind!=="MethodRef"||_.lambda)return;let j=T(M),P=Ps(j);if(!P||P.params.some(m)||!m(P.returnType))return;let B;_.kind==="Lambda"?(this.#$n(_,j,!0),B=_.method?.returnType):_.kind==="MethodRef"&&(this.#hs(_,j,!0),B=_.lambda?.method?.returnType),B?.tag==="diamond"&&P.returnType.tag==="typevar"?x.set(P.returnType.name,B):B&&B.tag!=="error"&&B.tag!=="void"&&bt(P.returnType,qt(B)??B,h)});for(let[C,M]of x){if(h.has(C))continue;let _=t.typeParamBounds?.[C],j=c.filter(N=>h.has(N)),P=_?Xt(u(_),j,j.map(N=>h.get(N))):void 0,B=Ms(M.symbol,P);h.set(C,pt(M.symbol,M.symbol.typeParams.map(N=>B.get(N)??G)))}let v=c.map(C=>h.get(C)??G),R=C=>wt(u(C),c,v);return{params:o.map((C,M)=>R(t.params[Math.min(M,t.params.length-1)])),returnType:R(t.returnType),bound:h}}#On(t){if(!t.target||t.name==="new"||t.arrayType)return!1;let e=Ee(t.target);if(!e||this.#lt(e[0])||this.#Yt(e[0]))return!1;let n=this.#Ie(e);return n!==null&&(n.typeParams?.length??0)>0&&this.#wt(n,t.name).some(s=>!s.isStatic)}#We(t,e){if(t.arrayType){let c=this.#U(t.arrayType);return c.tag==="error"?null:{params:[V],returnType:c}}if(!t.target||t.name==="new")return null;let n=Ee(t.target);if(!n||this.#lt(n[0])||this.#Yt(n[0]))return null;let s=this.#Ie(n);if(s){let c=this.#wt(s,t.name);if(c.length!==1||c[0].declaration.params.some(d=>d.varargs)||c[0].typeParams?.length)return null;let u=c[0];if(u.isStatic)return{params:u.params,returnType:u.returnType};if(s.typeParams?.length&&e){let d=se(e,s);if(!d?.args?.length)return null;let h=m=>Me(Ne(d,u.owner,m));return{params:[d,...u.params.map(h)],returnType:h(u.returnType)}}return{params:[tt(s),...u.params],returnType:u.returnType}}if(n.length===1&&n[0]==="String"){if(Object.hasOwn(Qn,t.name))return{params:[mt,...Qn[t.name].params],returnType:Qn[t.name].returnType};let c=te("String").methods.filter(u=>u.name===t.name);return c.length!==1||c[0].varargs?null:{params:c[0].isStatic?c[0].params:[mt,...c[0].params],returnType:c[0].returnType}}let r=this.#mt(n);if(!r)return null;let a=r.methods.filter(c=>c.name===t.name);if(a.length!==1||a[0].varargs||a[0].typeParams?.length||r.typeParams.length)return null;let o=a[0];return{params:o.isStatic?o.params:[pt(r),...o.params],returnType:o.returnType}}#he(t,e,n){let s=new Map,r=new Map,a=(u,d)=>{if(u.tag==="typevar"&&!u.symbol&&t.typeParams?.includes(u.name)&&d&&d.tag!=="wildcard"){if(d.tag==="null"||d.tag==="diamond"||d.tag==="lambda"||d.tag==="error"||d.tag==="typevar"&&!d.symbol)return;let h=nt(d)?Nr(d):qt(d);h&&r.set(u.name,[...r.get(u.name)??[],h]);return}bt(u,d,s)},o=t.params,c=t.varargs?o.length-1:o.length;for(let u=0;u<c;u++)a(o[u],e[u]);if(t.varargs){let u=o[o.length-1],d=e.slice(c);if(d.length===1&&d[0].tag==="array"&&nt(d[0].element))bt(u,d[0],s);else for(let m of d)a(u.element,m)}for(let[u,d]of r)s.has(u)||(s.set(u,d.reduce(Ar)),n?.set(u,d));return s}#is(t,e,n,s,r,a=!1){let o=n.returnType;if(r.tag!=="library"||o.tag!=="library")return null;let c=Dt(o,r.symbol);if(!c)return null;let u=new Map,d=this.#he(n,s,u),h=!1;for(let[m,p]of c.args.entries()){let k=r.args[m];if(p.tag!=="typevar"||p.symbol||!u.has(p.name)||!k||k.tag==="wildcard"||k.tag==="typevar"&&!k.symbol)continue;let g=u.get(p.name);if(g.some(O=>!K(O,k))){if(a)return null;let O=g.filter((T,x)=>g.findIndex(v=>at(v,T))===x);return this.#e(t.pos,w.incompatibleTypes,`incompatible types: inference variable ${p.name} has incompatible bounds`,[` equality constraints: ${$(k)}`,` lower bounds: ${[...O].reverse().map($).join(",")}`,...Ve([p],e,Oa(e,n,s.length))]),"error"}at(d.get(p.name),k)||(d.set(p.name,k),h=!0)}return h?d:null}#Jr(t,e){if(!t.typeParams)return[];let n=this.#he(t,e);return t.typeParams.map(s=>n.get(s)??G)}#as(t,e,n,s,r,a){if(!t.typeParams)return null;let o=a??this.#he(t,s),c=t.isStatic?t.returnType:Xt(t.returnType,e.typeParams,n);if(t.typeParams.every(m=>o.has(m)))return a?wt(c,t.typeParams,t.typeParams.map(m=>o.get(m))):null;if(r?.tag==="library"&&c.tag==="library"){let m=Dt(c,r.symbol);m&&m.args.forEach((p,k)=>ge(r.args[k])&&bt(p,ge(r.args[k]),o))}r&&c.tag==="typevar"&&!c.symbol&&t.typeParams.includes(c.name)&&!o.has(c.name)&&nt(r)&&o.set(c.name,r);let u=t.typeParams.map(m=>o.get(m)??G),d=wt(c,t.typeParams,u),h=t.typeParams.filter(m=>!o.has(m));if(!r&&h.length&&c.tag==="library"&&c.args.some(m=>m.tag==="typevar"&&h.includes(m.name))){let m=c.args.every(p=>p.tag==="typevar"&&h.includes(p.name))?null:d.args;return{tag:"diamond",symbol:c.symbol,fromArgs:m}}return d}#Xe(t,e,n){let s=e.tag==="library"?wa(e.symbol):$(e),r=t.name==="<init>"?"<init>":t.name,a=t.isStatic||t.name==="<init>"?0:1,o=0;return t.params.forEach((c,u)=>{(c.tag==="library"&&!c.symbol.functional&&c.symbol.name!=="Comparator"||t.name==="equals"&&u===0)&&(o|=1<<u+a)}),{...o?{unwrap:o,unwrapCalls:Zo[t.native]??tl}:{},native:t.native,isStatic:t.isStatic,params:n,returnsValue:t.name==="<init>"||t.returnType.tag!=="void",display:`${s}.${r}(${t.params.map(Je).join(", ")})`,...t.throws?{throws:t.throws}:{}}}#Ln(t){return pt(t.symbol,t.fromArgs??t.symbol.typeParams.map(()=>G))}#os(t,e,n,s,r,a,o){let c=this.#m.items.slice(o),u=t.args.map(Q).filter(N=>N.kind==="Lambda"),d=c.findIndex(N=>N.severity==="error"&&kr.test(N.message)&&u.some(F=>N.offset!==void 0&&N.offset>=F.start&&N.offset<=F.end));if(d<0)return!1;let h=c[d],m=t.args.findIndex(N=>h.offset>=N.start&&h.offset<=N.end);this.#m.items.splice(o+d,1);let p=h.message.replace(/^incompatible types: /,""),k=(h.details??[]).map(N=>` ${N.trimStart()}`),g=[`(argument mismatch; ${p}`,...k];g[g.length-1]+=")";let O=wn(n,s),T=new vn,x=n.typeParams,v=n.params.map(N=>n.isStatic?N:Xt(N,s.typeParams,r)),R=N=>{let F=[],q=Z=>{Z.tag==="typevar"&&!Z.symbol&&x.includes(Z.name)?F.push(Z.name):Z.tag==="array"?q(Z.element):Z.tag==="wildcard"&&Z.bound?q(Z.bound):Z.tag==="library"&&Z.args.forEach(q)};return q(N),F},L=v[Math.min(m,v.length-1)],C=new Set(v.filter((N,F)=>F!==m).flatMap(R));if(R(L).every(N=>C.has(N))){for(let F of x)T.add({name:F,decl:O});let N=x.map(F=>T.label({name:F,decl:O})).join(",");return this.#e(t.pos,w.incompatibleTypes,`incompatible types: cannot infer type-variable(s) ${N}`,[...g.map(F=>` ${F}`),...Et([],T.entries())]),!0}let _=s.methods.filter(N=>N.name===t.name&&N.isStatic===n.isStatic&&N.native!=="");if(_.length>1){let N=_.map(q=>wn(q,s));for(let q of N){for(let Z of q.method.typeParams??[])T.add({name:Z,decl:q});for(let Z of q.method.params)T.visit(Z,q)}let F=[];for(let q of N){let Z=q.method,ne=Z.typeParams??[];F.push(` method ${e.owner}.${ne.length?`<${ne.map(it=>T.label({name:it,decl:q})).join(",")}>`:""}${Z.name}(${T.params(q)}) is not applicable`);let rt=(Z===n?[`cannot infer type-variable(s) ${ne.map(it=>T.label({name:it,decl:q})).join(",")}`,...g.map(it=>` ${it}`)].join(`\n`):$a({owner:e.owner,name:Z.name,params:Z.params,returnType:Z.returnType,library:Z,...Z.varargs?{varargs:!0}:{}},q,a,T)??"actual and formal argument lists differ in length").split(`\n`);F.push(` (${rt[0]}${rt.length>1?"":")"}`,...rt.slice(1).map((it,D,vt)=>`${it.trimStart().startsWith("(")?" ":" "}${it.trimStart()}${D===vt.length-1?")":""}`))}return this.#e(t.selectPos,w.cantResolve,`no suitable method found for ${this.#Ft(t.name,a)}`,[...F,...Et([],T.entries())]),!0}for(let N of x)T.add({name:N,decl:O});for(let N of v)T.visit(N,O);let j=v.map(N=>T.render(N,O)).join(","),P=x.map(N=>T.label({name:N,decl:O})).join(","),B=k.some(N=>/ cannot be converted to /.test(N));return this.#e(B?t.pos:t.selectPos,w.cantResolve,`method ${t.name} in ${Rs(e).text} cannot be applied to given types;`,[` required: ${j}`,` found: ${en(a)}`,` reason: cannot infer type-variable(s) ${P}`,...g.map(N=>` ${N}`),...Et([],T.entries())]),!0}#ls(t,e,n){let s=this.#m.items.length;this.#de(t.args,e.params);let r=this.#m.items.slice(s),a=t.args.map(Q).filter(T=>T.kind==="Lambda"),o=r.findIndex(T=>T.severity==="error"&&kr.test(T.message)&&a.some(x=>T.offset!==void 0&&T.offset>=x.start&&T.offset<=x.end));if(o<0)return!0;let c=r[o],u=a.find(T=>c.offset>=T.start&&c.offset<=T.end);this.#m.items.splice(s+o,1);let d=c.message.replace(/^incompatible types: /,""),h=(c.details??[]).map(T=>` ${T}`),m=u.params.length>0&&u.params.some(T=>!T.type),p=d==="unexpected return value"&&!m?["argument mismatch; bad return type in lambda expression"," unexpected return value"]:[`argument mismatch; ${d}`,...h],k=h.some(T=>/ cannot be converted to /.test(T)),g=e.shown??e.params,O=Rs(e);return this.#e(k?t.pos:t.selectPos,w.cantResolve,`method ${t.name} in ${O.text} cannot be applied to given types;`,[` required: ${en(g)}`,` found: ${en(n)}`,` reason: ${p[0]}`,...p.slice(1),...Et([...g,...n],O.where)]),!1}#de(t,e){t.forEach((n,s)=>{let r=Q(n),a=r.kind==="MethodCall"?this.#L.get(r):void 0;if(a&&r.kind==="MethodCall"){this.#L.delete(r);let d=e[Math.min(s,e.length-1)],h=d?this.#is(r,a.symbol,a.method,a.types,d,!0):null;if(h&&h!=="error"){let m=a.method.typeParams.map(k=>h.get(k)??G),p=wt(a.method.returnType,a.method.typeParams,m);r.type=p,n!==r&&(n.type=p),r.libraryCall&&(r.libraryCall.params=r.libraryCall.params.map((k,g)=>wt(a.method.params[Math.min(g,a.method.params.length-1)],a.method.typeParams,m)))}return}if(this.#st.has(n)){this.#st.delete(n),n.type=this.#k(n,e[Math.min(s,e.length-1)]);return}let o=Q(n).kind;if(o==="Lambda"||o==="MethodRef"){this.#k(n,e[s]);return}if(n.kind==="NewObject"&&n.openDiamond){let{symbol:d,bound:h}=n.openDiamond;delete n.openDiamond;let m=Er(d,e[Math.min(s,e.length-1)]);n.type=tt(d,d.typeParams.map(p=>h.get(p.key)??m.get(p.key)??W(me(p))));return}let c=n.type;if(c?.tag!=="diamond")return;let u=Ms(c.symbol,e[s]);n.type=pt(c.symbol,c.symbol.typeParams.map((d,h)=>u.get(d)??c.fromArgs?.[h]??G))})}#Nn(t,e,n){let s=t.symbol,r=s.constructors.map(c=>({owner:s.name,name:s.name,params:c.params.map(u=>wt(u,s.typeParams,t.args)),returnType:xt,library:c,...c.varargs?{varargs:!0}:{}})),a=this.#ct({pos:n,name:s.name},r,e,"constructor");if(!a)return null;let o=a.library;return o.native?a.expanded?(this.#a(n,`a variable-arity constructor of ${s.name} as a superclass constructor`,!0),null):{candidate:a,call:this.#Xe({...o,name:"<init>"},pt(s),a.params)}:(this.#a(n,`the constructor ${s.name}(${o.params.map(Je).join(", ")})`,!0),null)}#jr(t,e,n){let s=e.tag==="library"||e.tag==="diamond"?e.symbol:null;if(!s)return A;let r=this.#ue(t.args);if(r.some(T=>T.tag==="error"))return A;if(s.isInterface||s.isAbstract||s.name==="Number")return this.#e(t.pos,w.cantResolve,`${s.name} is abstract; cannot be instantiated`),A;if(!s.constructors.length)return this.#a(t.pos,`creating ${nn(s.name)} with \'new\'`,!0),A;let a=e.tag==="diamond";n===es&&(n=void 0);let o=a&&n?Ms(s,n,!0):new Map,c=T=>{if(!a)return e.args.slice();let x=new Map(o);return T.params.forEach((v,R)=>bt(v,r[R],x)),s.typeParams.map(v=>x.get(v)??G)},u=e.tag==="library"&&!e.args.length&&s.typeParams.length>0,d=s.constructors.map(T=>{let x=c(T);return{owner:s.name,name:s.name,params:T.params.map(v=>u?W(v):wt(v,s.typeParams,x)),returnType:xt,library:T,...T.varargs?{varargs:!0}:{}}}),h=this.#m.items.length,m=this.#ct({pos:t.pos,name:s.name,args:t.args},d,r,"constructor");if(!m)return a&&this.#Vr(t,s,d,r,h),A;let p=m.library;if(!p.native)return this.#a(t.pos,`the constructor ${s.name}(${p.params.map(Je).join(", ")})`,!0),A;u&&p.params.some(T=>ue(T,null))&&this.#at(t.pos,"unchecked",`unchecked call to ${s.name}(${p.params.map($).join(",")}) as a member of the raw type ${s.name}`,Ve(p.params,s)),s.box&&this.#at(t.pos,"deprecation",`${s.name}(${p.params.map($).join(",")}) in ${s.name} has been deprecated`);let k=this.#m.items.length;if(this.#de(t.args,m.params),a&&this.#Hr(t,s,k))return A;let g=a&&r.some((T,x)=>p.params[x]!==void 0&&Re(p.params[x],T));g&&this.#at(t.pos,"unchecked",`unchecked method invocation: constructor <init> in class ${s.name} is applied to given types`,[` required: ${p.params.map($).join(",")}`,` found: ${r.map($).join(",")}`,...Ve([...p.params,...r],s)]);let O;if(g)O=pt(s);else if(!a)O=e;else{let T=new Map(o);p.params.forEach((R,L)=>bt(R,r[L],T));let x=s.typeParams.every(R=>T.has(R)),v=s.typeParams.map(R=>T.get(R)??G);O=x||n?pt(s,v):{tag:"diamond",symbol:s,fromArgs:s.typeParams.some(R=>T.has(R))?v:null}}return t.libraryCall=this.#Xe({...p,name:"<init>"},pt(s),m.params),m.expanded&&(t.libraryCall.varargsFrom=m.params.length-1),O}#Dr(t,e){if(e.length)return this.#e(t.pos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${e.map($).join(",")}`," reason: actual and formal argument lists differ in length"]),A;te("String");let n={name:"<init>",params:[],returnType:G,isStatic:!0,native:"Object.<init>()",owner:"Object"};return t.libraryCall=this.#Xe(n,G,[]),G}#Fr(t){let e=this.#ue(t.args);if(e.some(a=>a.tag==="error"))return A;let s=te("String").constructors.map(a=>({owner:"String",name:"String",params:a.params,returnType:xt,library:a})),r=this.#ct({pos:t.pos,name:"String",args:t.args},s,e,"constructor");return r?(t.libraryCall=this.#Xe({...r.library,name:"<init>"},mt,r.params),mt):A}#_r(t,e){if(t.body)return this.#Ur(t,t.body,e);let n=this.#u===t;this.#u=null;let s=t.outerExpression?this.#Br(t):this.#U(t.classType);if(s.tag==="library"||s.tag==="diamond")return this.#jr(t,s,e);if(s.tag==="string")return this.#Fr(t);let r=this.#ue(t.args);if(s.tag==="error"||r.some(m=>m.tag==="error"))return A;if(s.tag==="typevar")return this.#e(t.classType.pos,w.incompatibleTypes,"unexpected type",[" required: class",` found: type parameter ${s.name}`,...Et([s])]),A;if(s.tag==="object")return this.#Dr(t,r);if(s.tag!=="class")return this.#a(t.pos,`creating ${nn($(s))} with \'new\'`,!0),A;let a=s.symbol;if(a.isEnum)return this.#e(t.pos,w.syntax,"enum classes may not be instantiated"),A;if(a.isAbstract)return this.#e(t.pos,w.cantResolve,`${a.displayName} is abstract; cannot be instantiated`),A;if(this.#In(a,r.length,t.pos))return A;let o=t.classType.kind==="ClassType"?t.classType:null,c=o?.diamond===!0;if(c&&!a.typeParams?.length)return this.#e(o.typeArgumentsPos??t.pos,w.cantResolve,`cannot infer type arguments for ${a.displayName}`,[` reason: cannot use \'<>\' with non-generic class ${a.displayName}`]),A;let u=this.#qe(a,c?void 0:s),d=s;if(c){let m=a.typeParams,p=m.map(C=>C.key),k=Er(a,e),g=new Map;u=u.map(C=>{let M=new Map(k),_=new Map;ka(p,Aa(C,r),r,M,_);for(let P of m){let B=_.get(P.key);if(!B)continue;let N=k.get(P.key);if(N&&B.some(F=>!K(F,N))){let F=[`inference variable ${P.name} has incompatible bounds`,` equality constraints: ${$(N)}`,` lower bounds: ${B.map($).join(",")}`];return{...C,shown:C.params,problem:{reason:F.join(`\n`),diamond:!0}}}M.has(P.key)||M.set(P.key,B.reduce(Ar))}let j={...C,shown:C.params,params:C.params.map(P=>Kt(P,M))};return g.set(j,M),j});let O=u.filter(C=>C.params.length===r.length),T=O.length===1&&O[0].problem?.diamond&&!La(O[0],r,m)?O[0]:null;if(T){let[C,...M]=T.problem.reason.split(`\n`);return this.#e(o.typeArgumentsPos??t.pos,w.incompatibleTypes,`incompatible types: cannot infer type arguments for ${a.displayName}<>`,[` reason: ${C}`,...M.map(_=>` ${_}`),...Et(m.map(me))]),A}let x=this.#m.items.length,v=this.#ct({pos:t.pos,name:a.name,args:t.args},u,r,"constructor");if(!v)return this.#zr(t,a,u,r,x),A;let R=g.get(u.find(C=>C.method===v.method))??new Map;return m.filter(C=>!R.has(C.key)).length&&n&&!e?(t.openDiamond={symbol:a,bound:R},d=tt(a,m.map(C=>R.get(C.key)??Hn))):d=tt(a,m.map(C=>R.get(C.key)??W(me(C)))),this.#us(t,a,v,d)}let h=this.#ct({pos:t.pos,name:a.name,args:t.args},u,r,"constructor");return h?(Bn(s)&&h.method.params.some(m=>rs([m]).length)&&this.#at(t.pos,"unchecked",`unchecked call to ${this.#Ht(h.method).replace(/^[^(]*/,a.name)} as a member of the raw type ${a.displayName}`,Et(h.method.params)),this.#hn(t.args,h.method.params.map(W)),this.#us(t,a,h,d)):A}#Ur(t,e,n){this.#u=null;let s=e.symbol,r=this.#U(t.classType),a=this.#ue(t.args);if(r.tag==="error"||a.some(x=>x.tag==="error"))return A;if(r.tag==="diamond"){let x=Ms(r.symbol,n);r=pt(r.symbol,r.symbol.typeParams.map(v=>x.get(v)??G))}else if(r.tag==="class"&&t.classType.kind==="ClassType"&&t.classType.diamond&&r.symbol.typeParams?.length){let x=Er(r.symbol,n);r=tt(r.symbol,r.symbol.typeParams.map(v=>x.get(v.key)??W(me(v))))}if((r.tag==="library"||r.tag==="class")&&r.symbol.isInterface&&t.args.length)return this.#e(t.args[0].pos,w.syntax,"anonymous class implements interface; cannot have arguments"),A;let c=r.tag==="string"?"String":r.tag==="class"&&(r.symbol.isFinal||r.symbol.isEnum)?r.symbol.displayName:r.tag==="library"&&!r.symbol.isInterface&&r.symbol.box?r.symbol.name:null;if(c)return this.#e(t.classType.pos,w.syntax,`cannot inherit from final ${c}`),A;if(r.tag==="library"&&!r.symbol.isInterface){if(!ga.has(r.symbol.name))return this.#a(t.classType.pos,`extending the library class ${r.symbol.name}`,!0),A;s.librarySuperclass=r}else if(r.tag==="library"){if(!Sa(r.symbol))return this.#a(t.classType.pos,`implementing the library interface ${r.symbol.name}`,!0),A;s.libraryInterfaces.push(r)}else if(r.tag==="class")if(r.symbol.isInterface)s.interfaces.push(r.symbol),s.interfaceTypes=[r];else{if(r.symbol.isInner)return this.#a(t.classType.pos,"extending an inner (non-static) class",!0),A;s.superclass=r.symbol,s.superType=r}else if(r.tag!=="object")return this.#a(t.pos,`creating ${nn($(r))} with \'new\'`,!0),A;if(r.tag==="class"&&r.symbol.isSealed)return this.#Ze(s),A;let u=null,d=null;if(s.librarySuperclass){let x=this.#Nn(s.librarySuperclass,a,t.pos);if(!x)return A;u=x.candidate,d=x.call}else if(s.superclass){if(this.#In(s.superclass,a.length,t.pos))return A;if(u=this.#ct({pos:t.pos,name:s.superclass.name,viaSuper:!0},this.#qe(s.superclass,s.superType),a,"constructor"),!u)return A;if(!this.#Oe(u.method,t.pos,`${s.superclass.name}(${u.method.params.map($).join(",")})`,"super"))return A}else if(a.length)return this.#e(t.pos,w.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${a.map($).join(",")}`," reason: actual and formal argument lists differ in length"]),A;s.hierarchyState=2;let h=this.#ke(),m=this.#o,p=this.#J,k=this.#ht,g=this.#g;this.#le(s);let O=this.#cs(s,u);d&&(O.superLibrary=d),this.#nn([...s.methods,...s.constructors]),this.#N.set(s,{scopes:h.scopes}),this.#J=null,this.#g=!1,this.#He(s),this.#Ce(h),this.#o=m,this.#J=p,this.#ht=k,this.#g=g,u&&this.#de(t.args,u.params),this.#Fe(t.args);let T=u?this.#_e(u,t.pos):void 0;return T&&(t.varargs=T),s.isInner&&(t.outer=0,this.#Zt()),t.ctor=O,tt(s)}#cs(t,e){let n=t.declaration.pos,s=e?e.params.slice():[],r={kind:"MethodDeclaration",modifiers:{keywords:[]},returnType:{kind:"VoidType",pos:n,start:n,end:n},name:"<init>",namePos:n,params:[],body:{kind:"Block",statements:[],pos:n,start:n,end:n+1},isConstructor:!0,synthetic:!0,pos:n,start:n,end:n},a={kind:"method",name:t.binaryName.slice(t.binaryName.lastIndexOf("$")+1),owner:t,isStatic:!1,isConstructor:!0,isPrivate:!1,isAbstract:!1,isFinal:!1,access:"package",params:s,returnType:xt,index:this.#V.length,declaration:r,locals:[],maxSlots:1+(t.isInner?1:t.enumBody?2:0)+s.reduce((o,c)=>o+Be(c),0),throws:e?.method?.throws??[],forwardsToSuper:!0,...e?.method?{superConstructor:e.method}:{}};return r.symbol=a,this.#V.push(a),t.constructors.push(a),a}#Br(t){let e=this.#nt(t.outerExpression);if(e.tag==="error")return A;let n=t.classType,s=n.names[0];if(e.tag!=="class")return this.#a(t.pos,`\'.new\' on ${nn($(e))}`,!0),A;let r;for(let a=e.symbol;a&&!r;a=a.superclass)r=a.membersByName.get(s);return r?r.isInner?r.typeParams?.length||r.outer?.typeParams?.length||n.typeArguments||n.diamond?(this.#a(t.pos,"\'.new\' of a generic class, or of a generic class\'s inner class",!0),A):tt(r):(this.#e(t.start,w.syntax,"qualified new of static class"),A):(this.#e(n.pos,w.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: class ${e.symbol.displayName}`]),A)}#Vr(t,e,n,s,r){let a=this.#m.items.slice(r);if(!a.length||!/cannot be applied to given types|no suitable constructor/.test(a[0].message))return;this.#m.items.splice(r);let o=`cannot infer type arguments for ${e.name}<>`;if(n.length!==1){this.#e(t.pos,w.cantResolve,o);return}let c=n[0].library.params,u=e.typeParams.join(","),d=s.length!==c.length?[`cannot infer type-variable(s) ${u}`," (actual and formal argument lists differ in length)"]:[`cannot infer type-variable(s) ${u}`,` (argument mismatch; ${$(s[Math.max(0,s.findIndex((h,m)=>!Ht(n[0].params[m],h)))])} cannot be converted to ${$(c[Math.max(0,s.findIndex((h,m)=>!Ht(n[0].params[m],h)))])})`];this.#e(t.pos,w.cantResolve,o,[` reason: ${d[0]}`,...d.slice(1).map(h=>` ${h}`),...Ve(e.typeParams.map(h=>({tag:"typevar",name:h})),e)])}#Hr(t,e,n){let s=this.#m.items.slice(n),r=t.args.map(Q).filter(d=>d.kind==="Lambda"),a=s.findIndex(d=>d.severity==="error"&&kr.test(d.message)&&r.some(h=>d.offset!==void 0&&d.offset>=h.start&&d.offset<=h.end));if(a<0)return!1;let o=s[a];this.#m.items.splice(n+a,1);let c=[`(argument mismatch; ${o.message.replace(/^incompatible types: /,"")}`,...(o.details??[]).map(d=>` ${d.trimStart()}`)];c[c.length-1]+=")";let u=t.classType.kind==="ClassType"?t.classType:null;return this.#e(u?.typeArgumentsPos??t.pos,w.incompatibleTypes,`incompatible types: cannot infer type arguments for ${e.name}<>`,[` reason: cannot infer type-variable(s) ${e.typeParams.join(",")}`,...c.map(d=>` ${d}`),...Ve(e.typeParams.map(d=>({tag:"typevar",name:d})),e)]),!0}#zr(t,e,n,s,r){let a=this.#m.items.slice(r);if(!a.length||!/cannot be applied to given types|no suitable constructor/.test(a[0].message))return;this.#m.items.splice(r);let o=e.typeParams,c=o.map(k=>k.name).join(","),u=`cannot infer type arguments for ${e.displayName}<>`;if(n.length!==1){this.#e(t.pos,w.cantResolve,u);return}let d=n[0],h=d.shown??d.params,m,p=La(d,s,o);if(d.varargs?s.length<h.length-1:s.length!==h.length)m=[`cannot infer type-variable(s) ${c}`," (actual and formal argument lists differ in length)"];else if(p)m=[`inference variable ${p.variable.name} has incompatible bounds`,` upper bounds: ${p.variable.bounds.map($).join(",")}`,` lower bounds: ${$(p.lower)}`];else if(d.problem)m=d.problem.reason.split(`\n`);else{let k=s.findIndex((T,x)=>!Ht(d.params[x],T)),g=h[Math.max(k,0)],O=s[Math.max(k,0)];m=[`cannot infer type-variable(s) ${c}`,` (argument mismatch; ${$(O)} cannot be converted to ${$(g)})`]}this.#e(t.pos,w.cantResolve,u,[` reason: ${m[0]}`,...m.slice(1).map(k=>` ${k}`),...Et(o.map(me))])}#us(t,e,n,s){let r=n.method,a=this.#_e(n,t.pos);if(a&&(t.varargs=a),!this.#Oe(r,t.pos,`${e.name}(${r.params.map($).join(",")})`,e.anonymous?"super":null))return A;if(this.#de(t.args,n.params),e.isInner&&!t.outerExpression){let o=0;for(let u=this.#o;u&&u!==e.outer;u=u.outer)o++;let c=this.#o===e.outer||o>0&&this.#sn(o)&&this.#zs(o)===e.outer;if(!this.#t&&!this.#g&&c&&(t.outer=o),t.outer!==void 0)this.#Zt();else return this.#te(t.pos,"non-static variable this cannot be referenced from a static context"),A}return t.ctor=r,s}#dn(t){if(t.tag==="library"&&t.symbol.functional){let s=t.symbol,r=s.methods.find(c=>c.name===s.functional&&!c.isStatic),a=s.typeParams.map((c,u)=>{let d=t.args[u];return d?d.tag==="wildcard"?d.bound??G:d:G}),o=c=>wt(c,s.typeParams,a);return{params:r.params.map(o),returnType:o(r.returnType),iface:s.qualifiedName,samKey:r.native}}if(t.tag==="class"&&t.symbol.isInterface){let s=ks(t.symbol),r=t.symbol.displayName;if(s.length===1&&!t.symbol.isSealed){let o=s[0],c=tt(t.symbol,t.args?.map(d=>Me(d))),u=d=>Ne(c,o.owner,d);return{params:o.params.map(u),returnType:u(o.returnType),iface:t.symbol.binaryName,sam:o}}let a=t.symbol.isSealed?[]:[s.length?` multiple non-overriding abstract methods found in interface ${r}`:` no abstract method found in interface ${r}`];return{problem:`${r} is not a functional interface`,details:a}}let e=t.tag==="array"?"Array":t.tag==="library"||t.tag==="diamond"?t.symbol.name:t.tag==="class"?t.symbol.displayName:$(t),n=t.tag==="library"&&t.symbol.isInterface?[` multiple non-overriding abstract methods found in interface ${t.symbol.name}`]:void 0;return{problem:`${e} is not a functional interface`,details:n}}#$n(t,e,n=!1){if(t.method)return e??A;if(!e)return this.#e(t.pos,w.incompatibleTypes,"lambda expression not expected here"),A;if(e.tag==="error")return A;if(e.tag==="library"&&e.symbol.name==="Iterable")return this.#a(t.pos,"lambda expressions that implement Iterable"),A;let s=this.#dn(e);if("problem"in s)return this.#e(t.pos,w.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),A;if(s.params.length!==t.params.length)return this.#e(t.pos,w.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),A;for(let[a,o]of t.params.entries()){if(!o.type)continue;let c=this.#U(o.type);if(c.tag==="error")return A;if(!at(c,s.params[a]))return this.#e(t.pos,w.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),A}if(s.returnType.tag==="void"&&t.body.kind!=="Block"&&!cl(t.body))return this.#e(t.body.pos,w.incompatibleTypes,"incompatible types: lambda body is not compatible with a void functional interface",[" (consider using a block lambda body, or use a statement expression instead)"]),A;n&&ue(s.returnType,Array.isArray(n)?n:null)&&(s.returnType=es);let r=t.body.kind==="Block"?t.body:s.returnType.tag==="void"?{kind:"Block",statements:[{kind:"ExpressionStatement",expression:t.body,pos:t.body.pos,start:t.body.start,end:t.body.end}],pos:t.body.pos,start:t.body.start,end:t.body.end}:{kind:"Block",statements:[{kind:"ReturnStatement",value:t.body,pos:t.body.pos,start:t.body.start,end:t.body.end}],pos:t.body.pos,start:t.body.start,end:t.body.end};return this.#Le(t,s,r,[],()=>{for(let a of r.statements)this.#ce(a)}),e}#Le(t,e,n,s,r){let a=t.reference===!0,o,c=this.#ht;if(a)o=`lambda$ref$${this.#V.length}`;else{c=this.#J?this.#ht:this.#b?this.#b.isConstructor?"new":this.#b.name:this.#t?"static":"new";let C=this.#H.get(this.#o)??new Map;this.#H.set(this.#o,C);let M=C.get(c)??0;C.set(c,M+1),o=`lambda$${c}$${M}`}let u=[],d=new Set(t.params.map(C=>C.name));Js(n,(C,M)=>{if(d.has(C))return;let _=this.#lt(C)??this.#Pn(C)?.local;_&&!u.some(j=>j.outer===_)&&u.push({outer:_,pos:M})});let h={keywords:[],annotations:[]},m={kind:"VoidType",pos:t.pos,start:t.pos,end:t.pos},p=t.params.map(C=>({modifiers:C.modifiers??h,type:C.type??m,name:C.name,varargs:!1,pos:C.pos,start:C.pos,end:C.pos})),k={kind:"MethodDeclaration",modifiers:h,returnType:m,name:o,namePos:t.pos,params:p,body:n,pos:t.pos,start:t.start,end:t.end},g={kind:"method",name:o,owner:this.#o,isStatic:!0,isConstructor:!1,isPrivate:!0,isAbstract:!1,isFinal:!1,access:"private",params:[...s.map(C=>C.type),...u.map(C=>C.outer.type),...e.params],returnType:e.returnType,index:this.#V.length,declaration:k,locals:[],maxSlots:0,lambda:t,throws:[],...a?{hidden:!0}:{}};k.symbol=g,this.#V.push(g),!this.#b&&!this.#J&&this.#Et.set(this.#o,[...this.#Et.get(this.#o)??[],g]),t.method=g,t.captures=u.map(C=>C.outer),t.capturedAt=u.map(C=>C.pos),t.functional={iface:e.iface,...e.samKey?{samKey:e.samKey}:{},...e.sam?{sam:e.sam}:{}};let O=this.#ke(),T=this.#J,x=this.#ht,v=this.#t;this.#J={scopes:this.#f,method:this.#b,isStatic:v,outer:this.#J},this.#ht=c,this.#b=g,this.#it=null,this.#t=v,this.#f=[],this.#c=0,this.#y=[];let R=this.#m.items.length;this.#Pt();let L=0;for(let C of s){let M=this.#zt(C.name,C.type,t.pos,!0,!0);M.parameter=++L}for(let C of u){let M=this.#zt(C.outer.name,C.outer.type,C.pos,!1,!0);M.parameter=++L,M.captureOf=C.outer}return p.forEach((C,M)=>{let _=this.#zt(C.name,e.params[M],C.pos,t.params[M]?.modifiers?jt(t.params[M].modifiers,"final"):!1);_.parameter=++L,C.symbol=_}),r(),this.#Mt(),t.body.kind==="Block"&&e.returnType.tag!=="void"&&this.#m.items.length===R&&this.#Kr(g)&&this.#e(t.pos,w.incompatibleTypes,"incompatible types: bad return type in lambda expression",[" missing return value"]),g.usesThis&&(g.isStatic=!1,ul(g,1)),this.#Ce(O),this.#J=T,this.#ht=x,g}#Zt(){let t=this.#b;for(let e=this.#J;t?.lambda&&e;e=e.outer)t.usesThis=!0,t=e.method}#hs(t,e,n=!1){if(!e)return this.#e(t.start,w.incompatibleTypes,"method reference not expected here"),A;if(e.tag==="error")return A;let s=this.#dn(e);if("problem"in s)return this.#e(t.start,w.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),A;n&&ue(s.returnType,null)&&(s.returnType=es);let r=s.params.length,a={kind:"Lambda",params:Array.from({length:r},(T,x)=>({name:`$${x}`,pos:t.start,type:null})),body:{kind:"Block",statements:[],pos:t.start,start:t.start,end:t.end},reference:!0,depth:t.depth,pos:t.start,start:t.start,end:t.end};t.lambda=a;let o=T=>({kind:"Name",identifier:`$${T}`,depth:1,pos:t.start,start:t.start,end:t.end}),c=T=>Array.from({length:r-T},(x,v)=>o(T+v)),u={depth:2,pos:t.start,start:t.start,end:t.end},d=(T,x)=>({kind:"MethodCall",target:T,name:t.name,namePos:t.namePos,selectPos:t.start,args:c(x),plainNpe:!0,...u}),h=T=>s.returnType.tag==="void"?{kind:"ExpressionStatement",expression:T,...u}:{kind:"ReturnStatement",value:T,...u},m=a.body;if(t.arrayType){let x={kind:"NewArray",elementType:t.arrayType.kind==="ArrayType"?t.arrayType.element:t.arrayType,dimensions:r?[o(0)]:[],extraDims:0,initializer:null,...u};return m.statements.push(h(x)),this.#Le(a,s,m,[],()=>this.#Ne(m)),e}let p=t.target;if(p.kind==="Super"||p.kind==="This")return m.statements.push(h(d(p,0))),this.#Le(a,s,m,[],()=>this.#Ne(m)),e;if(p.kind==="FieldAccess"&&p.target.kind==="Name"&&p.target.identifier==="System"&&(p.name==="out"||p.name==="err")&&!this.#lt("System"))return m.statements.push(h(d(p,0))),this.#Le(a,s,m,[],()=>this.#Ne(m)),e;if(t.name==="new"){let T=this.#Gr(p)?this.#ds(p):null;if(!T)return this.#e(t.start,w.cantResolve,"cannot find symbol",[` symbol: class ${this.#fs(p)}`,` location: class ${this.#o.displayName}`]),A;let x={kind:"NewObject",classType:T,args:c(0),...u};return m.statements.push(h(x)),this.#Le(a,s,m,[],()=>this.#Ne(m)),e}let k=this.#cn(p);if("tag"in k){if(k.tag==="error")return A;t.receiver=p;let T={kind:"Name",identifier:"$recv",depth:1,pos:t.start,start:t.start,end:t.end},x=d(T,0);return m.statements.push(h(x)),this.#Le(a,s,m,[{name:"$recv",type:k}],()=>this.#Ne(m)),e}let g=this.#fs(p),O=T=>h(T?d(o(0),1):d(p,0));return this.#Le(a,s,m,[],()=>{let T=j=>{let P=O(j),B=this.#m.items.length;m.statements=[P],this.#Ne(m);let N=this.#m.items.splice(B),F=P.kind==="ReturnStatement"?P.value:P.expression,q=F.method!==void 0||F.libraryCall!==void 0||F.stringMethod!==void 0||F.mathFunction!==void 0||F.objectMethod!==void 0,Z=F.method?F.method.isStatic:F.libraryCall?F.libraryCall.isStatic:F.mathFunction!==void 0,ne=F.method?`method ${F.method.name}(${F.method.params.map($).join(",")}) in ${F.method.owner.displayName}`:F.libraryCall?`method ${t.name}(${F.libraryCall.params.map($).join(",")}) in ${g}`:void 0;return{ok:q&&Z!==j,...ne?{found:ne}:{},...N[0]?{message:N[0].message}:{}}},x=T(!1),v=this.#ds(p),R=v?this.#ms(v):null,L=R?.tag==="diamond"?pt(R.symbol):R,C=s.params[0],M=!L||L.tag==="error"||C===void 0||C===es||K(qt(C)??C,L)||C.tag==="typevar",_=r>0&&M?T(!0):{ok:!1};if(x.ok&&_.ok){this.#e(t.start,w.incompatibleTypes,"incompatible types: invalid method reference",[` reference to ${t.name} is ambiguous`,` both ${x.found} and ${_.found} match`]);return}if(!x.ok&&!_.ok){let j=/^non-static method (.*) cannot be referenced from a static context$/.exec(x.message??"");if(j){this.#e(t.start,w.incompatibleTypes,"incompatible types: invalid method reference",[` unexpected instance method ${j[1]} found in unbound lookup`]);return}this.#e(t.start,w.cantResolve,"invalid method reference",[" cannot find symbol",` symbol: method ${t.name}(${s.params.map($).join(",")})`,` location: class ${g}`]);return}m.statements=[O(!x.ok)],this.#Ne(m)}),e}#Ne(t){for(let e of t.statements)this.#ce(e)}#Gr(t){let e=Ee(t);return e!==null&&(this.#Ie(e)!==null||this.#mt(e)!==null||e.join(".")==="String")}#ds(t){let e=Ee(t);if(!e)return null;let n=this.#Ie(e)?null:this.#mt(e);return{kind:"ClassType",names:e,hasTypeArguments:!1,...n&&n.typeParams.length?{diamond:!0}:{},pos:t.pos,start:t.start,end:t.end}}#ms(t){let e=this.#m.items.length,n=this.#U(t,!0);return this.#m.items.splice(e),n}#fs(t){return Ee(t)?.join(".")??Cs(t)}#Kr(t){let e=this.#B,n=this.#dt,s=[this.#K,this.#Z,this.#F,this.#M];this.#B=[],this.#dt=[];let r=this.#Me(t.declaration.body.statements,Qt(),!0).completes;return this.#B=e,this.#dt=n,[this.#K,this.#Z,this.#F,this.#M]=s,r}#Pn(t){for(let e=this.#J;e;e=e.outer)for(let n=e.scopes.length-1;n>=0;n--){let s=e.scopes[n].names.get(t);if(s){let r=e.method;for(let a=e.outer;a&&r?.lambda;a=a.outer)r=a.method;return{local:s,method:r}}}return null}#te(t,e){this.#e(t,w.cantResolve,e)}#qr(t,e){this.#Ae(t.condition);let n=t.condition.type??A,s=e!==void 0&&e.tag!=="error"?e:void 0,r=this.#Qt(this.#ft(t.condition,!0),()=>this.#nt(t.whenTrue,s)),a=this.#Qt(this.#ft(t.condition,!1),()=>this.#nt(t.whenFalse,s));if(n.tag!=="boolean"||r.tag==="error"||a.tag==="error")return A;let o,c=St(r)??r,u=St(a)??a;if(st(c)&&st(u)&&!(nt(r)&&nt(a)&&s&&nt(s)))if(c.tag==="boolean"&&u.tag==="boolean")o=gt;else if(Rt(c)&&Rt(u))o=Tl(c,u,t.whenTrue.constant,t.whenFalse.constant);else return this.#a(t.pos,"conditional expressions mixing boolean and numeric operands"),A;else if(st(r)&&a.tag==="null"||st(a)&&r.tag==="null"){let h=st(r)?r:a,m=this.#ps(h);if(!m)return A;if(o=s&&nt(s)?s:m,s&&!re(s,m))return this.#q(st(r)?t.whenTrue:t.whenFalse,h,s),A}else{if(s){let h=!0;for(let[m,p]of[[t.whenTrue,r],[t.whenFalse,a]])re(s,p,m.constant)||(this.#e(m.pos,w.incompatibleTypes,"incompatible types: bad type in conditional expression",[` ${Ue(s,p)}`]),h=!1);if(!h)return A}if(st(r)||st(a))return this.#a(t.pos,"conditional expressions that need boxing"),A;o=s&&nt(s)?s:Pa(r,a)}let d=t.condition.constant;return d?.kind==="boolean"&&t.whenTrue.constant&&t.whenFalse.constant&&(t.constant=On(d.value?t.whenTrue.constant:t.whenFalse.constant,o)),o}#Wr(t,e){let n=Wn[t.name],s=n.map(o=>({owner:"Math",name:t.name,params:o.params,returnType:o.returnType})),r=this.#ct({pos:t.selectPos,name:t.name,imported:fa(t),args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},s,e,"method");if(!r)return A;let a=n[s.indexOf(r)];return a.fn?(t.mathFunction={fn:a.fn,params:a.params},r.returnType):(this.#a(t.selectPos,`Math.${t.name}(${r.params.map($).join(",")})`,!0),A)}#ps(t){let e={int:"Integer",long:"Long",double:"Double",char:"Character",boolean:"Boolean",float:"Float",byte:"Byte",short:"Short"}[t.tag],n=e?Wt(e):void 0;return n?pt(n):null}#Xr(t,e){if(t.name==="readln"){te("System");let o=[{owner:"IO",name:"readln",params:[],returnType:mt},{owner:"IO",name:"readln",params:[mt],returnType:mt}],c=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos,explicit:t.typeArguments!==void 0},o,e,"method");if(!c)return A;let u=`readln(${c.params.length?"String":""})`;return t.libraryCall={native:`IO.${u}`,isStatic:!0,params:c.params,returnsValue:!0,display:`java.lang.IO.${u}`},mt}if(t.name!=="print"&&t.name!=="println")return this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,e)}`," location: class IO"]),A;let n=t.name==="println"?[{owner:"IO",name:"println",params:[G],returnType:xt},{owner:"IO",name:"println",params:[],returnType:xt}]:[{owner:"IO",name:"print",params:[G],returnType:xt}];if(!this.#ct({pos:t.selectPos,name:t.name},n,e,"method"))return A;let r=e[0],a="none";if(r)switch(r.tag){case"int":a="int";break;case"char":a="char";break;case"boolean":a="boolean";break;case"long":a="long";break;case"double":a="double";break;case"string":case"null":a="string";break;default:a="object"}return t.print={stream:"out",newline:t.name==="println",argument:a},xt}#Yr(t){let e=Q(t);if(e.kind==="FieldAccess")return e.field;if(e.kind==="Name"&&e.imported)return e.imported.field}#Qr(t,e,n){te("System");let s={owner:"PrintStream",name:t.name,params:[mt,ee(G)],returnType:xt,varargs:!0},r=this.#ct({pos:t.selectPos,name:t.name},[s],n,"method");return r?(t.libraryCall={native:`PrintStream.${e}.printf(String,Object[])`,isStatic:!0,params:r.params,returnsValue:!1,display:`java.io.PrintStream.${t.name}(String, Object[])`},r.expanded&&(t.libraryCall.varargsFrom=1),xt):A}#ys(t){let e=Q(t);if(e.kind!=="MethodCall"||e.typeArguments)return null;if(e.libraryMethod){let{method:a,symbol:o,classArgs:c}=e.libraryMethod,u=a.typeParams??[];if(!u.length)return null;let d=wn(a,o);return{call:e,result:a.returnType,params:a.params.map(h=>a.isStatic?h:Xt(h,o.typeParams,c)),varOf:h=>h.tag==="typevar"&&!h.symbol&&u.includes(h.name)?h.name:null,ref:h=>({name:h,decl:d}),bound:h=>{let m=a.typeParamBounds?.[h];return m?{type:m,decl:d}:null}}}let n=e.method;if(!n?.typeParams?.length)return null;let s=n.typeParams,r=a=>s.find(o=>o.name===a);return{call:e,result:n.returnType,params:n.params,varOf:a=>a.tag==="typevar"&&a.symbol&&s.includes(a.symbol)?a.name:null,ref:a=>({name:a,decl:xr(r(a))}),bound:a=>{let o=r(a).bounds[0];return o?{type:o,decl:null}:null}}}#gs(t,e=!1){let n=this.#ys(t);if(!n)return null;let s=n.varOf(n.result),r=e&&n.result.tag==="library"?n.result.args[n.result.args.length-1]:void 0,a=s??(r?n.varOf(r):null);if(!a)return null;let o=m=>{let p=[],k=g=>{let O=n.varOf(g);O?p.push(O):g.tag==="array"?k(g.element):g.tag==="wildcard"&&g.bound?k(g.bound):g.tag==="library"?g.args.forEach(k):g.tag==="class"&&g.args?.forEach(k)};return k(m),p},c=m=>{let p=Q(m);return p.kind==="Lambda"&&p.params.some(k=>!k.type)||p.kind==="MethodRef"&&(!this.#We(p)||this.#On(p))},u=new Set,d=null,h=null;return n.call.args.forEach((m,p)=>{let k=n.params[Math.min(p,n.params.length-1)];if(!k)return;if(c(m)){!h&&o(k).includes(a)&&(h=m);return}let g=this.#gs(m,!0);if(g){o(k).includes(a)&&(d??=g);return}for(let O of o(k))u.add(O)}),u.has(a)?null:d??{call:n,name:a,by:h}}#Zr(t,e){let n=this.#ys(t);if(!n)return null;let s=n.varOf(n.result);if(!s)return null;let r=this.#gs(t);if(!r)return null;let a=r.call.bound(r.name),o=r.by&&Q(r.by),c={type:G,decl:null};if(o?.kind==="MethodRef"&&o.name==="new"&&!o.arrayType){let u=o.target?Ee(o.target):null,d=u?this.#mt(u):null,h=d?{type:{tag:"library",symbol:d,args:d.typeParams.map(p=>({tag:"typevar",name:p}))},decl:Tr(d)}:{type:e,decl:null},m=[...a?[a]:[],n.bound(s)??c];return{bound:a?.type??null,variable:n.ref(s),upper:m,lower:h}}return{bound:a?.type??null,variable:r.call.ref(r.name),upper:[a??c],lower:o?.kind==="MethodRef"&&this.#ti(o)||{type:e,decl:null}}}#ti(t){let e=t.target?Ee(t.target):null,n=e&&!this.#lt(e[0])?this.#mt(e):null,s=n?.methods.filter(r=>r.name===t.name)??[];return s.length!==1||!s[0].typeParams?.length?null:{type:s[0].returnType,decl:wn(s[0],n)}}#ei(t,e,n){let s=this.#Yr(t.target)==="System.err"?"err":"out";if(t.name==="printf"||t.name==="format")return this.#Qr(t,s,n);if((t.name==="flush"||t.name==="close"||t.name==="checkError")&&!n.length)return te("System"),t.libraryCall={native:`PrintStream.${s}.${t.name}()`,isStatic:!0,params:[],returnsValue:t.name==="checkError",display:`java.io.PrintStream.${t.name}()`},t.name==="checkError"?gt:xt;if(t.name!=="print"&&t.name!=="println")return Ko.has(t.name)?this.#a(t.selectPos,`PrintStream.${t.name}()`,!0):this.#e(t.selectPos,w.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ft(t.name,n)}`,this.#De(t.target,e)]),A;let r=this.#ct({pos:t.selectPos,name:t.name,args:t.args,callPos:t.pos},rl(t.name),n,"method");if(!r)return A;let a=r.params[0],o="none";if(a)switch(a.tag){case"int":o="int";break;case"char":o="char";break;case"boolean":o="boolean";break;case"string":o="string";break;case"array":o="char-array";break;case"object":o="object",this.#hn(t.args,[G]);break;case"long":o="long";break;case"double":o="double";break;case"float":o="float";break;default:throw new Error(`checker: unexpected print overload ${$(a)}`)}return t.print={stream:s,newline:t.name==="println",argument:o},xt}#ct(t,e,n,s){let r=t.args?.map((g,O)=>n[O]?this.#Zr(g,n[O]):null),a=(g,O,T=!1)=>{if(g.params.length!==n.length)return"actual and formal argument lists differ in length";if(g.problem)return g.problem.reason;for(let x=0;x<n.length;x++){let v=r?.[x];if(!(v?Ra(g.params[x],v.bound,T):O(g.params[x],n[x])))return`argument mismatch; ${hl(g.params[x],n[x])??Ue(g.params[x],n[x])}`}return null},o=g=>{let O=r?.findIndex((v,R)=>v&&!Ht(g.params[R],n[R]))??-1;if(O<0)return g;let T=r[O],x=g.shown??g.params;return this.#e(t.callPos??t.pos,w.cantResolve,`${s} ${t.name} in ${Rs(g).text} cannot be applied to given types;`,[` required: ${en(x)}`,` found: ${en(n)}`,...aa(T.variable,[{type:g.params[O],decl:null},...T.upper],[T.lower])]),null};e.length>1&&(e=e.map(g=>{let O=g.method,T=O&&!g.problem?this.#es(O,`${O.isConstructor?O.owner.name:O.name}(${g.params.map($).join(",")})`,t.viaSuper?"super":null):null;return T?{...g,problem:{reason:T}}:g}));let c=g=>a(g,(O,T)=>Ht(O,T)||Re(O,T),!0),u=e.filter(g=>a(g,Ze)===null);if(u.length||(u=e.filter(g=>c(g)===null)),!u.length)for(let g of e){if(!g.varargs||n.length<g.params.length-1)continue;let O=g.params[g.params.length-1].element;if([...g.params.slice(0,-1),...n.slice(g.params.length-1).map(()=>O)].every((x,v)=>Ht(x,n[v])))return{...g,expanded:!0}}if(!u.length){if(e.length===1){let L=e[0],C=L.shown??L.params,M=((t.explicit?null:Na(L,n," "))??Ia(L,n)??c(L)).split(`\n`),_=L.problem?.alone?[` reason: ${M[0]}`]:[` required: ${en(C)}`,` found: ${en(n)}`,` reason: ${M[0]}`,...M.slice(1)],j=Rs(L);return this.#e(t.pos,w.cantResolve,`${s} ${t.name} in ${j.text} cannot be applied to given types;`,[..._,...L.problem?.alone?[]:Et([...C,...n],j.where)]),null}let g=[],O=[],T=t.imported?[...e].reverse():e,x=new vn,v=L=>{let C=L.library?.isStatic&&L.library.typeParams?.length&&It[L.owner]?Wt(L.owner):void 0;return C?wn(L.library,C):null};for(let L of T){let C=v(L);if(C){for(let M of C.method.typeParams)x.add({name:M,decl:C});for(let M of C.method.params)x.visit(M,C)}}for(let L of T){let C=v(L);if(C){g.push(` ${s} ${L.owner}.<${C.method.typeParams.map(F=>x.label({name:F,decl:C})).join(",")}>${L.name}(${x.params(C)}) is not applicable`);let N=($a(L,C,n,x)??c(L)).split(`\n`);g.push(` (${N[0]}${N.length>1?"":")"}`,...N.slice(1).map((F,q,Z)=>` ${F}${q===Z.length-1?")":""}`));continue}let M=L.shown??L.params,_=L.method?.typeParams;O.push(...M);let j=M.map((B,N)=>L.varargs&&N===M.length-1&&B.tag==="array"?`${$(B.element)}...`:$(B));g.push(` ${s} ${L.owner}.${_?`<${_.map(B=>B.name).join(",")}>`:""}${L.name}(${j.join(",")}) is not applicable`);let P=((t.explicit?null:Na(L,n," "))??Ia(L,n)??c(L)).split(`\n`);g.push(` (${P[0]}${P.length>1?"":")"}`,...P.slice(1).map((B,N,F)=>` ${B}${N===F.length-1?")":""}`))}let R=n.length?this.#Ft(t.name,n):`${t.name}(no arguments)`;return this.#e(t.pos,w.cantResolve,`no suitable ${s} found for ${R}`,[...g,...Et([...O,...n],x.entries())]),null}let d=(g,O)=>g.params.every((T,x)=>Ze(O.params[x],T)),h=u.filter(g=>u.every(O=>g===O||d(g,O)));if(h.length===1)return o(h[0]);let[m,p]=sl(u,d),k=g=>`${s} ${g.name}(${g.params.map($).join(",")}) in ${g.owner}`;return this.#e(t.pos,w.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${k(m)} and ${k(p)} match`]),o(m),null}#ni(t){let e=this.#nt(t.operand);if(e.tag==="error")return A;let n=St(e)??e;if(t.operator==="!")return n.tag!=="boolean"?this.#Mn(t,n):(t.operand.constant?.kind==="boolean"&&(t.constant=Tt(!t.operand.constant.value)),gt);if(!Rt(n)||t.operator==="~"&&!Xn(n))return this.#Mn(t,n);let s=pa(n),r=t.operand.constant;return r&&(t.constant=xl(t.operator,r,s)),s}#Mn(t,e){return this.#e(t.pos,w.badOperands,`bad operand type ${$(e)} for unary operator \'${t.operator}\'`),A}#bs(t){let e=Q(t);this.#P=e.kind==="Name";let n=this.#k(e);if(this.#P=!1,t.type=n,n.tag==="error")return null;if(e.kind==="Name"&&e.symbol?.kind==="local"){if(e.symbol.multiCatch)return this.#e(e.pos,w.finalAssign,`multi-catch parameter ${e.identifier} may not be assigned`),null;let r=e.symbol.forEach||e.symbol.parameter!==void 0||e.symbol.catchParameter;return e.symbol.isFinal&&!r?(this.#e(e.pos,w.finalAssign,`cannot assign a value to final variable ${e.identifier}`),null):(e.symbol.reassigned=!0,e.symbol.assignCount=(e.symbol.assignCount??0)+1,{kind:"local",variable:e.symbol})}let s=e.kind==="Name"&&e.symbol?.kind==="field"?e.symbol:e.kind==="FieldAccess"?e.fieldSymbol:void 0;if(s)return s.isFinal&&!this.#si(e,s)?(this.#e(e.pos,w.finalAssign,`cannot assign a value to ${s.isStatic?"static final":"final"} variable ${s.name}`),null):{kind:"field",field:s};if(e.kind==="ArrayAccess")return{kind:"element",type:n};if(e.kind==="Name"&&e.imported)return this.#e(e.pos,w.finalAssign,`cannot assign a value to static final variable ${e.identifier}`),null;if(e.kind==="FieldAccess"&&e.field){let r=e.field==="length"?"final variable length":`static final variable ${e.name}`;return this.#e(e.pos,w.finalAssign,`cannot assign a value to ${r}`),null}return this.#e(e.pos,w.incompatibleTypes,"unexpected type",[" required: variable"," found: value"]),null}#si(t,e){if(e.declarator.init)return!1;let n=this.#b?.initializer;return n&&this.#b.owner===e.owner&&n==="static"===e.isStatic?t.kind==="Name"?!t.outerHops:!e.isStatic&&t.kind==="FieldAccess"&&Q(t.target).kind==="This":e.isStatic||!this.#b?.isConstructor||this.#b.owner!==e.owner||this.#b.declaration.compact?!1:t.kind==="Name"?!t.outerHops:t.kind==="FieldAccess"&&Q(t.target).kind==="This"}#ri(t){if(!this.#bs(t.operand))return A;let n=t.operand.type;return Rt(St(n)??n)?n:this.#Mn(t,n)}#Ss(t,e,n,s){return this.#e(t.pos,w.badOperands,`bad operand types for binary operator \'${e}\'`,[` first type: ${$(n)}`,` second type: ${$(s)}`]),A}#Ts(t,e,n){if(t==="+"&&(e.tag==="string"||n.tag==="string"))return mt;if((t==="=="||t==="!=")&&nt(e)&&nt(n))return ke(e,n)?gt:null;let s=St(e)??e,r=St(n)??n,a=Rt(s)&&Rt(r);switch(t){case"+":return s.tag==="string"||r.tag==="string"?mt:a?ns(s,r):null;case"-":case"*":case"/":case"%":return a?ns(s,r):null;case"<<":case">>":case">>>":return Xn(s)&&Xn(r)?pa(s):null;case"<":case">":case"<=":case">=":return a?gt:null;case"==":case"!=":return a?gt:s.tag==="boolean"&&r.tag==="boolean"?gt:nt(s)&&nt(r)&&(K(s,r)||K(r,s))?gt:null;case"&":case"|":case"^":return Xn(s)&&Xn(r)?ns(s,r):s.tag==="boolean"&&r.tag==="boolean"?gt:null;case"&&":case"||":return s.tag==="boolean"&&r.tag==="boolean"?gt:null}return null}#ii(t){let e=this.#nt(t.left),n=t.operator==="&&"||t.operator==="||"?this.#Qt(this.#ft(t.left,t.operator==="&&"),()=>this.#nt(t.right)):this.#nt(t.right);if(e.tag==="error"||n.tag==="error")return A;let s=this.#Ts(t.operator,e,n);if(!s){let o=c=>st(c)||nt(c);return(t.operator==="=="||t.operator==="!=")&&o(e)&&o(n)&&st(e)===st(n)?(this.#e(t.pos,w.badOperands,`incomparable types: ${$(e)} and ${$(n)}`),A):this.#Ss(t,t.operator,e,n)}let r=t.left.constant,a=t.right.constant;if(r&&a){let o=vl(t.operator,r,a,s);o&&(t.constant=o)}return s}#ai(t){let e=this.#bs(t.target),n=t.target.type??A,s=this.#nt(t.value,t.operator==="="?n:void 0);if(!e||n.tag==="error"||s.tag==="error")return e?n:A;if(t.operator==="="){if(!this.#ln(n,s,t.value))return this.#q(t.value,s,n),A;let u=Q(t.target);return u.kind==="FieldAccess"&&u.fieldSymbol&&u.target.type&&Bn(u.target.type)&&rs([u.fieldSymbol.type]).length&&this.#at(u.pos,"unchecked",`unchecked assignment to variable ${u.name} as member of raw type ${$(u.target.type)}`),n}let r=t.operator.slice(0,-1),a=this.#Ts(r,n,s);if(!a)return this.#Ss(t,r,n,s);let o=St(n);return(o?at(o,a):Rt(a)&&Rt(n)||at(a,n))?n:(this.#e(t.value.pos,w.incompatibleTypes,`incompatible types: ${$(a)} cannot be converted to ${$(n)}`),A)}#oi(t){let e=this.#nt(t.array),n=this.#nt(t.index);return e.tag==="error"||n.tag==="error"?A:e.tag!=="array"?(this.#e(t.pos,w.incompatibleTypes,`array required, but ${$(e)} found`),A):Ht(V,n)?e.element:(this.#q(t.index,n,V),A)}#li(t){let e=this.#U(t.elementType,!0);if(e.tag!=="error"&&!Ln(e)){this.#e(t.pos,w.syntax,"generic array creation");for(let s of t.dimensions)this.#nt(s);return A}for(let s of t.dimensions){let r=this.#nt(s);r.tag!=="error"&&!Ht(V,r)&&this.#q(s,r,V)}if(e.tag==="error")return t.initializer&&this.#je(t.initializer,A),A;let n=e;for(let s=0;s<t.dimensions.length+t.extraDims;s++)n=ee(n);return t.initializer&&this.#je(t.initializer,n),n}#ci(t){let e=this.#U(t.targetType),n=this.#nt(t.expression);if(e.tag==="error"||n.tag==="error")return A;let s=St(n),r=Rt(e)&&Rt(n)||e.tag==="boolean"&&n.tag==="boolean"||nt(e)&&nt(n)&&ke(e,n)||nt(e)&&st(n)&&re(e,n)||st(e)&&s!==null&&(at(s,e)||Rt(s)&&Rt(e)&&Ht(e,s));if(!r&&st(e)&&nt(n)&&!s){let o=this.#ps(e);o&&ke(o,n)&&(t.checked=o,r=!0)}if(!r)return this.#q(t.expression,n,e),A;if(pl(e,n))return this.#q(t.expression,n,e),A;if(nt(e)&&nt(n)&&!Ln(e)&&!K(n,e)&&!ol(e,n)){this.#at(t.expression.pos,"unchecked","unchecked cast",[` required: ${$(e)}`,` found: ${$(n)}`,...Et([e,n])]);let o=W(e);!K(n,o)&&o.tag!=="object"&&(t.checked=o)}else nt(e)&&nt(n)&&!K(n,e)&&(t.checked=e);let a=t.expression.constant;return a&&(st(e)||e.tag==="string")&&(t.constant=On(a,e)),e}#$e(t,e,n){!this.#Z&&!this.#B.some(([s])=>s===t)&&this.#B.push([t,e,n])}#Pe(t,e){this.#dt.some(([n])=>n===t)||this.#dt.push([t,e])}#ui(t){this.#B=[],this.#dt=[];let e=Lr(t);for(let n of e)this.#ws(n);this.#ws(t);for(let[n,s,r]of this.#B)this.#e(n,s==="missing return statement"?w.missingReturn:w.unreachable,s,r);for(let[n,s]of this.#dt)this.#e(n,w.uninitialized,s);this.#Lt=[];for(let n of e)this.#xs(n);this.#xs(t);for(let[n,s,r]of this.#Lt)this.#e(n,w.unreported,s,r);for(let n of this.#ne)n.top!==t||ll(n.local)||this.#e(n.pos,w.notEffectivelyFinal,`local variables referenced from ${n.inner?"an inner class":"a lambda expression"} must be final or effectively final`)}#xs(t){this.#o=t;for(let e of t.fields){let n=e.declarator.init;n&&this.#Be([],()=>n.kind==="ArrayInitializer"?this.#mn(n):this.#T(n));let s=e.enumConstant?.node;s&&this.#Be([],()=>{for(let r of s.args)this.#T(r);if(s.ctor)for(let r of s.ctor.throws)this.#_t(r,s.pos)})}for(let e of t.declaration.members){if(e.kind==="Initializer"&&e.symbol){this.#Be(e.isStatic?[]:this.#hi(t),()=>{for(let s of e.body.statements)this.#pt(s)});continue}if(e.kind!=="MethodDeclaration"||!e.symbol||e.symbol.isAbstract||e.symbol.builtin)continue;let n=e.symbol;this.#Be(n.throws,()=>{if(n.superConstructor)for(let s of n.superConstructor.throws)this.#_t(s,n.declaration.synthetic?t.declaration.keywordPos:n.declaration.body.pos);for(let s of n.declaration.body.statements)this.#pt(s)})}for(let e of t.constructors)!e.declaration.synthetic||e.builtin||!e.superConstructor||e.forwardsToSuper||this.#Be([],()=>{for(let n of e.superConstructor.throws)this.#_t(n,t.declaration.keywordPos)})}#hi(t){let e=t.constructors.filter(n=>!n.declaration.synthetic&&!n.builtin);return e.length?e.flatMap(n=>n.throws).filter(n=>e.every(s=>s.throws.some(r=>K(n,r)))):[]}#Be(t,e){let n=[this.#gt,this.#Tt];this.#gt=t,this.#Tt=[],e(),[this.#gt,this.#Tt]=n}#_t(t,e,n){if(this.#Xt(t)){for(let s=this.#Tt.length-1;s>=0;s--){let r=this.#Tt[s];if(r.thrown.push(t),r.caught.some(a=>K(t,a)))return}this.#gt.some(s=>K(t,s))||this.#Lt.some(([s])=>s===e)||this.#Lt.push([e,`unreported exception ${$(t)}; must be caught or declared to be thrown`,n])}}#pt(t){switch(t.kind){case"Block":for(let e of t.statements)this.#pt(e);return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init?.kind==="ArrayInitializer"?this.#mn(e.init):e.init&&this.#T(e.init);return;case"ExpressionStatement":this.#T(t.expression);return;case"IfStatement":this.#T(t.condition),this.#pt(t.then),t.otherwise&&this.#pt(t.otherwise);return;case"WhileStatement":case"DoStatement":this.#T(t.condition),this.#pt(t.body);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#pt(t.init);else for(let e of t.init??[])this.#T(e);t.condition&&this.#T(t.condition);for(let e of t.update)this.#T(e);this.#pt(t.body);return;case"ForEachStatement":this.#T(t.iterable),this.#pt(t.body);return;case"LabeledStatement":this.#pt(t.body);return;case"SwitchStatement":this.#vs(t);return;case"YieldStatement":this.#T(t.value);return;case"ReturnStatement":t.value&&this.#T(t.value);return;case"ConstructorCall":for(let e of t.args)this.#T(e);if(t.target)for(let e of t.target.throws)this.#_t(e,t.thisPos);return;case"AssertStatement":this.#T(t.condition),t.message&&this.#T(t.message);return;case"LocalClass":return;case"ThrowStatement":{this.#T(t.expression);let e=Q(t.expression),n=e.kind==="Name"&&e.symbol?.kind==="local"&&!e.symbol.reassigned?this.#ee.get(e.symbol):void 0;if(n)for(let s of n)this.#_t(s,t.pos);else t.expression.type&&this.#_t(t.expression.type,t.pos);return}case"TryStatement":this.#di(t);return;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":return}}#vs(t){this.#T(t.selector);for(let e of t.cases){for(let n of e.statements)this.#pt(n);e.body?.kind==="Block"?this.#pt(e.body):e.body&&this.#T(e.body)}}#di(t){let n={caught:t.catches.flatMap(r=>r.caught??[]),thrown:[]};this.#Tt.push(n);for(let r of t.resources)r.kind==="declaration"?this.#T(r.init):this.#T(r.expression);this.#pt(t.block);for(let r of[...t.resources].reverse()){let a=r.kind==="declaration"?r.symbol?.type:r.expression.type,o=r.kind==="declaration"?r.name:r.symbol?.name??"";for(let c of this.#mi(a))this.#_t(c,r.pos,[` exception thrown from implicit call to close() on resource variable \'${o}\'`])}this.#Tt.pop();let s=[];for(let r of t.catches){if(r.types.forEach((a,o)=>{let c=r.caught?.[o];if(!c||!this.#Xt(c))return;let u=c.tag==="class"?c.symbol.binaryName:"";u==="java.lang.Exception"||u==="java.lang.Throwable"||n.thrown.some(d=>K(d,c)||K(c,d))||this.#Lt.push([r.types.length===1?r.pos:a.pos,`exception ${$(c)} is never thrown in body of corresponding try statement`,void 0])}),r.symbol){let a=r.caught??[];this.#ee.set(r.symbol,n.thrown.filter(o=>a.some(c=>K(o,c))&&!s.some(c=>K(o,c))))}s.push(...r.caught??[]),this.#pt(r.block)}t.finallyBlock&&this.#pt(t.finallyBlock)}#mi(t){return t?.tag==="library"?this.#Rn(t.symbol.methods.find(n=>n.name==="close"&&!n.params.length)?.throws):!t||t.tag!=="class"?[]:this.#wt(t.symbol,"close").find(n=>n.params.length===0)?.throws??[]}#Rn(t){return(t??[]).map(e=>tt(this.#D.get(e)))}#mn(t){for(let e of t.elements)e.kind==="ArrayInitializer"?this.#mn(e):this.#T(e)}#T(t){switch(t.kind){case"MethodCall":t.target&&this.#T(t.target);for(let e of t.args)this.#T(e);if(t.method)for(let e of t.method.throws)this.#_t(e,t.pos);for(let e of this.#Rn(t.libraryCall?.throws))this.#_t(e,t.pos);return;case"NewObject":t.outerExpression&&this.#T(t.outerExpression);for(let e of t.args)this.#T(e);if(t.ctor)for(let e of t.ctor.throws)this.#_t(e,t.pos);for(let e of this.#Rn(t.libraryCall?.throws))this.#_t(e,t.pos);return;case"MethodRef":t.receiver&&this.#T(t.receiver),t.lambda&&this.#T(t.lambda);return;case"Lambda":if(t.method){let e=t.method.declaration.body;this.#Be([],()=>{for(let n of e.statements)this.#pt(n)})}return;case"SwitchExpression":this.#vs(t);return;case"FieldAccess":this.#T(t.target);return;case"Unary":case"IncDec":this.#T(t.operand);return;case"Binary":this.#T(t.left),this.#T(t.right);return;case"Assignment":this.#T(t.target),this.#T(t.value);return;case"Parenthesized":this.#T(t.expression);return;case"ArrayAccess":this.#T(t.array),this.#T(t.index);return;case"NewArray":for(let e of t.dimensions)this.#T(e);t.initializer&&this.#mn(t.initializer);return;case"Cast":this.#T(t.expression);return;case"Conditional":this.#T(t.condition),this.#T(t.whenTrue),this.#T(t.whenFalse);return;case"InstanceOf":this.#T(t.expression);return;case"ClassLiteral":case"Literal":case"Name":case"This":case"Super":return}}#ws(t){this.#o=t;let e=t.constructors.some(r=>!r.declaration.synthetic),n=this.#ks(t,!0),s=this.#ks(t,!1);this.#$.set(t,s);for(let r of t.fields)!r.isFinal||r.declarator.init||r.enumConstant||r.capturedLocal||(r.isStatic?n.get(r)?.assigned||this.#dt.push([r.declarator.pos,`variable ${r.name} might not have been initialized`]):!e&&!t.isRecord&&!s.get(r)?.assigned&&this.#dt.push([r.declarator.pos,`variable ${r.name} not initialized in the default constructor`]));for(let r of t.declaration.members)r.kind==="MethodDeclaration"&&r.symbol&&!r.symbol.declaration.synthetic&&!r.symbol.isAbstract&&this.#fn(r.symbol);for(let r of this.#Et.get(t)??[])this.#fn(r)}#ks(t,e){let n=new Map;for(let a of t.fields)a.isStatic===e&&a.isFinal&&!a.declarator.init&&!a.enumConstant&&!a.capturedLocal&&n.set(a,1e6+n.size);let s=Cr();for(let a of n.values())s.unassigned.add(a);for(let a of t.declaration.members){if(a.kind!=="Initializer"||a.isStatic!==e||!a.symbol)continue;this.#K=new Map,this.#Z=0,this.#F=[],this.#M=n;let o=this.#Me(a.body.statements,s,!0);o.completes||this.#$e(a.pos,"initializer must be able to complete normally");let c=Cr();for(let u of n.values())In(o.after,u)&&c.vars.add(u),Zn(o.after,u)&&c.unassigned.add(u);s=c}this.#M=new Map;let r=new Map;for(let[a,o]of n)r.set(a,{assigned:In(s,o),unassigned:Zn(s,o)});return r}#fn(t){let e=Cr();for(let o of t.declaration.params)o.symbol&&(e=Pe(e,o.symbol.index));for(let o of t.locals)o.parameter!==void 0&&(e=Pe(e,o.index));this.#K=new Map,this.#Z=0,this.#F=[],this.#M=new Map;let n=t.declaration.body,s=n.statements[0],r=t.isConstructor&&!t.declaration.compact&&!(s?.kind==="ConstructorCall"&&s.keyword==="this");if(r){let o=this.#$.get(t.owner);for(let c of t.owner.fields){if(c.isStatic||!c.isFinal||c.declarator.init||c.capturedLocal)continue;let u=t.locals.length+this.#M.size;this.#M.set(c,u);let d=o?.get(c);d?.assigned&&e.vars.add(u),(!d||d.unassigned)&&e.unassigned.add(u)}}let a=this.#Me(n.statements,e,!0);if(a.completes&&!a.recovery&&t.returnType.tag!=="void"&&!t.lambda&&this.#$e(t.declaration.closeBracePos??n.end-1,"missing return statement"),r){for(let[o,c]of this.#M)In(a.after,c)||this.#Pe(t.declaration.closeBracePos??n.end-1,`variable ${o.name} might not have been initialized`);for(let o of this.#F)for(let[c,u]of this.#M)In(o.state,u)||this.#Pe(o.pos,`variable ${c.name} might not have been initialized`)}this.#M=new Map}#Me(t,e,n){let s=e,r=n,a=!1;for(let o of t){r||(this.#$e(xa(o),"unreachable statement"),r=!0,a=!0,s=Qt());let c=this.#Rt(o,s,r);s=c.after,r=c.completes,c.recovery&&(a=!0)}return{after:s,completes:r,...a&&r?{recovery:!0}:{}}}#Rt(t,e,n){switch(t.kind){case"Block":return this.#Me(t.statements,e,n);case"LocalVariableDeclaration":return{after:this.#As(t,e),completes:n};case"ExpressionStatement":return{after:this.#v(t.expression,e),completes:n};case"EmptyStatement":return{after:e,completes:n};case"ConstructorCall":{let s=e;for(let r of t.args)s=this.#v(r,s);return{after:s,completes:n}}case"IfStatement":{let s=this.#yt(t.condition,e),r=this.#Rt(t.then,s.whenTrue,n);if(!t.otherwise)return{after:Ct(r.after,s.whenFalse),completes:n};let a=this.#Rt(t.otherwise,s.whenFalse,n);return{after:Ct(r.after,a.after),completes:r.completes||a.completes}}case"WhileStatement":return this.#Cs(t,t.condition,t.body,[],e,n);case"ForStatement":{let s=e;if(t.init&&!Array.isArray(t.init))s=this.#As(t.init,s);else for(let r of t.init??[])s=this.#v(r,s);return this.#Cs(t,t.condition,t.body,t.update,s,n)}case"DoStatement":return this.#pi(t,e,n);case"ForEachStatement":return this.#yi(t,e,n);case"LabeledStatement":{let s=this.#Ve(t),r=this.#Rt(t.body,e,n);return{after:Ct(r.after,...s.breaks),completes:r.completes||s.breaks.length>0}}case"SwitchStatement":return this.#gi(t,e,n);case"YieldStatement":{let s=this.#v(t.value,e);return t.target&&this.#K.get(t.target)?.yields.push(s),{after:Qt(),completes:!1}}case"BreakStatement":return t.target&&this.#K.get(t.target)?.breaks.push(e),{after:Qt(),completes:!1};case"ContinueStatement":return t.target&&this.#K.get(t.target)?.continues.push(e),{after:Qt(),completes:!1};case"ReturnStatement":{let s=t.value?this.#v(t.value,e):e;return this.#M.size&&this.#F.push({pos:t.pos,state:s}),{after:Qt(),completes:!1}}case"ThrowStatement":return this.#v(t.expression,e),{after:Qt(),completes:!1};case"AssertStatement":{let s=this.#yt(t.condition,e);return t.message&&this.#v(t.message,s.whenFalse),{after:e,completes:n}}case"TryStatement":return this.#fi(t,e,n);case"LocalClass":return{after:e,completes:n}}}#fi(t,e,n){let s=e;for(let h of t.resources)h.kind==="declaration"?(s=this.#v(h.init,s),h.symbol&&(s=Pe(s,h.symbol.index))):s=this.#v(h.expression,s);let r=this.#Rt(t.block,s,n);t.blockCompletes=r.completes;let a=[r],o=h=>{let m=ze(e);if(!h.all)for(let p of[...m.unassigned])h.unassigned.has(p)||m.unassigned.delete(p);return m};for(let h of t.catches){let m=o(r.after);h.symbol&&(m=Pe(m,h.symbol.index));let p=this.#Rt(h.block,m,n);h.completes=p.completes,a.push(p)}let c=a.filter(h=>h.completes),u=c.length?Ct(c[0].after,...c.slice(1).map(h=>h.after)):Qt();if(!t.finallyBlock)return{after:u,completes:c.length>0};let d=this.#Rt(t.finallyBlock,o(Ct(r.after,...a.map(h=>h.after))),n);return{after:il(u,d.after),completes:c.length>0&&d.completes}}#Ve(t){let e={breaks:[],continues:[],yields:[]};return this.#K.set(t,e),e}#Jn(t,e){let n=e(t,!0),s=[...t.unassigned].some(o=>!Zn(n.backEdge,o));if(!this.#M.size||t.all||!s)return n.result;let r=ze(t);for(let o of[...r.unassigned])Zn(n.backEdge,o)||r.unassigned.delete(o);this.#Z++;let a=e(r,!1);return this.#Z--,a.result}#Cs(t,e,n,s,r,a){return this.#Jn(r,(o,c)=>{let u=e?this.#yt(e,o):{whenTrue:o,whenFalse:Qt()},d=e?e.constant:Tt(!0),h=a&&!Os(d);c&&a&&!h&&this.#$e(xa(n),"unreachable statement");let m=this.#Ve(t),p=this.#Rt(n,h?u.whenTrue:Qt(),!0),k=Ct(p.after,...m.continues);for(let g of s)k=this.#v(g,k);return{backEdge:k,result:{after:Ct(u.whenFalse,...m.breaks),completes:a&&(!qn(d)||m.breaks.length>0)}}})}#pi(t,e,n){return this.#Jn(e,s=>{let r=this.#Ve(t),a=this.#Rt(t.body,s,n),o=Ct(a.after,...r.continues),c=this.#yt(t.condition,o),u=a.completes||r.continues.length>0;return{backEdge:c.whenTrue,result:{after:Ct(c.whenFalse,...r.breaks),completes:n&&(u&&!qn(t.condition.constant)||r.breaks.length>0)}}})}#yi(t,e,n){let s=this.#v(t.iterable,e);return this.#Jn(s,r=>{let a=this.#Ve(t),o=t.symbol?Pe(r,t.symbol.index):r,c=this.#Rt(t.body,o,n);return{backEdge:Ct(c.after,...a.continues),result:{after:Ct(r,...a.breaks),completes:n}}})}#gi(t,e,n){let s=this.#Es(t,this.#v(t.selector,e)),r=this.#Ve(t),a=[],o=!1;if(t.cases[0]?.arrow)for(let c of t.cases){let u=c.body,d=u.kind==="Block"?this.#Rt(u,s,n):{after:this.#v(u,s),completes:n};d.completes&&(a.push(d.after),o=!0)}else{let c=null;for(let u of t.cases){let d=c?.completes?Ct(s,c.after):s;c=this.#Me(u.statements,d,n)}(!c||c.completes)&&(a.push(c?c.after:s),o=!0)}return!t.cases.some(c=>c.isDefault)&&!t.exhaustive&&(a.push(s),o=!0),a.push(...r.breaks),r.breaks.length&&(o=!0),{after:a.length?Ct(a[0],...a.slice(1)):Qt(),completes:n&&o}}#Es(t,e){let n=e;for(let s of t.cases)s.guard&&(n=Ct(n,this.#v(s.guard,n)));return n}#bi(t,e){let n=this.#Es(t,this.#v(t.selector,e)),s=this.#Ve(t),r=[];if(t.cases[0]?.arrow)for(let a of t.cases){let o=a.body;if(o.kind!=="Block"){r.push(this.#v(o,n));continue}this.#Me(o.statements,n,!0).completes&&this.#$e(o.end-1,"switch rule completes without providing a value",[" (switch rules in switch expressions must either provide a value or throw)"])}else{let a=null;for(let o of t.cases){let c=a?.completes?Ct(n,a.after):n;a=this.#Me(o.statements,c,!0)}a?.completes&&this.#$e(t.end-1,"switch expression completes without providing a value",[" (switch expressions must either provide a value or throw for all possible input values)"])}return!t.patternSwitch&&!t.cases.some(a=>a.isDefault)&&!t.coversAllConstants&&this.#$e(t.pos,"the switch expression does not cover all possible input values"),r.push(...s.yields),r.length?Ct(r[0],...r.slice(1)):Qt()}#jn(t,e){let n=e;for(let s of t.elements)n=s.kind==="ArrayInitializer"?this.#jn(s,n):this.#v(s,n);return n}#As(t,e){let n=e;for(let s of t.declarators){let r=s.symbol;r&&(n=al(n,r.index));let a=s.init;a&&(n=a.kind==="ArrayInitializer"?this.#jn(a,n):this.#v(a,n),r&&(n=Pe(n,r.index)))}return n}#yt(t,e){if(qn(t.constant))return{whenTrue:e,whenFalse:Qt()};if(Os(t.constant))return{whenTrue:Qt(),whenFalse:e};if(t.kind==="Parenthesized")return this.#yt(t.expression,e);if(t.kind==="Unary"&&t.operator==="!"){let s=this.#yt(t.operand,e);return{whenTrue:s.whenFalse,whenFalse:s.whenTrue}}if(t.kind==="Binary"&&t.operator==="&&"){let s=this.#yt(t.left,e),r=this.#yt(t.right,s.whenTrue);return{whenTrue:r.whenTrue,whenFalse:Ct(s.whenFalse,r.whenFalse)}}if(t.kind==="Binary"&&t.operator==="||"){let s=this.#yt(t.left,e),r=this.#yt(t.right,s.whenFalse);return{whenTrue:Ct(s.whenTrue,r.whenTrue),whenFalse:r.whenFalse}}if(t.kind==="Conditional"&&t.type?.tag==="boolean"){let s=this.#yt(t.condition,e),r=this.#yt(t.whenTrue,s.whenTrue),a=this.#yt(t.whenFalse,s.whenFalse);return{whenTrue:Ct(r.whenTrue,a.whenTrue),whenFalse:Ct(r.whenFalse,a.whenFalse)}}let n=this.#v(t,e);return{whenTrue:n,whenFalse:n}}#Dn(t,e,n){return t.binding||In(n,t.index)?n:(this.#Pe(e,`variable ${t.name} might not have been initialized`),Pe(n,t.index))}#pn(t){if(!this.#M.size)return null;let e;t.kind==="Name"&&t.symbol?.kind==="field"&&!t.outerHops?e=t.symbol:t.kind==="FieldAccess"&&t.fieldSymbol&&Q(t.target).kind==="This"&&(e=t.fieldSymbol);let n=e&&this.#M.get(e);return e&&n!==void 0?{field:e,index:n}:null}#yn(t,e,n){if(In(n,t.index))return n;this.#Pe(e,`variable ${t.field.name} might not have been initialized`);let s=ze(n);return s.vars.add(t.index),s}#v(t,e){switch(t.kind){case"Literal":case"This":case"Super":return e;case"InstanceOf":return this.#v(t.expression,e);case"ClassLiteral":return e;case"Lambda":{let n=e;t.captures?.forEach((r,a)=>n=this.#Dn(r,t.capturedAt[a],n));let s=[this.#K,this.#Z,this.#F,this.#M];return t.method&&this.#fn(t.method),[this.#K,this.#Z,this.#F,this.#M]=s,n}case"MethodRef":{let n=t.receiver?this.#v(t.receiver,e):e,s=[this.#K,this.#Z,this.#F,this.#M];return t.lambda?.method&&this.#fn(t.lambda.method),[this.#K,this.#Z,this.#F,this.#M]=s,n}case"Name":{if(t.symbol?.kind==="local"&&!t.constant)return this.#Dn(t.symbol,t.pos,e);let n=this.#pn(t);return n?this.#yn(n,t.pos,e):e}case"Parenthesized":return this.#v(t.expression,e);case"FieldAccess":{let n=this.#pn(t);return n?this.#yn(n,t.pos,e):this.#v(t.target,e)}case"MethodCall":{let n=t.target?this.#v(t.target,e):e;for(let s of t.args)n=this.#v(s,n);return n}case"NewObject":{let n=t.outerExpression?this.#v(t.outerExpression,e):e;for(let s of t.args)n=this.#v(s,n);return n}case"Conditional":{let n=this.#yt(t.condition,e);return Ct(this.#v(t.whenTrue,n.whenTrue),this.#v(t.whenFalse,n.whenFalse))}case"Unary":if(t.operator==="!"){let n=this.#yt(t,e);return Ct(n.whenTrue,n.whenFalse)}return this.#v(t.operand,e);case"IncDec":{let n=Q(t.operand);n.kind==="Name"&&n.symbol?.kind==="local"&&this.#Is(n.symbol,n.pos);let s=this.#pn(Q(t.operand));return s?this.#Os(s,Q(t.operand).pos,this.#yn(s,Q(t.operand).pos,e)):this.#v(t.operand,e)}case"Cast":return this.#v(t.expression,e);case"ArrayAccess":return this.#v(t.index,this.#v(t.array,e));case"NewArray":{let n=e;for(let s of t.dimensions)n=this.#v(s,n);return t.initializer?this.#jn(t.initializer,n):n}case"SwitchExpression":return this.#bi(t,e);case"Binary":{if(t.operator==="&&"||t.operator==="||"){let n=this.#yt(t,e);return Ct(n.whenTrue,n.whenFalse)}return this.#v(t.right,this.#v(t.left,e))}case"Assignment":{let n=Q(t.target);if(n.kind==="Name"&&n.symbol?.kind==="local"){let r=t.operator==="="?e:this.#Dn(n.symbol,n.pos,e);return r=this.#v(t.value,r),this.#Is(n.symbol,n.pos),Pe(r,n.symbol.index)}let s=this.#pn(n);if(s){let r=t.operator==="="?e:this.#yn(s,n.pos,e);return r=this.#v(t.value,r),this.#Os(s,n.pos,r)}return this.#v(t.value,this.#v(t.target,e))}}}#Is(t,e){t.isFinal&&(t.forEach?this.#Pe(e,`variable ${t.name} might already have been assigned`):(t.parameter!==void 0||t.catchParameter)&&this.#Pe(e,`final parameter ${t.name} may not be assigned`))}#Os(t,e,n){if(!Zn(n,t.index)){let s=this.#Z?"might be assigned in loop":"might already have been assigned";this.#Pe(e,`variable ${t.field.name} ${s}`)}return Pe(n,t.index)}};function ce(i,t){return`${i}(${t.map(Je).join(",")})`}function ol(i,t){if(i.tag==="library"&&t.tag==="library"){if(!i.args.length||i.args.some(n=>n.tag==="wildcard"))return!1;let e=Dt(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&at(e,t)}if(i.tag!=="class"||!i.args?.length||i.args.some(e=>e.tag==="wildcard"))return!1;if(t.tag==="library"){let e=Le(i).map(n=>Dt(n,t.symbol)).find(n=>n);return e!=null&&at(e,t)}if(t.tag==="class"){let e=se(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&at(e,t)}return!1}function ts(i,t,e){return`${ce(i,t)}${Je(e)}`}function Be(i){return i.tag==="long"||i.tag==="double"?2:1}function ye(i,t){let e=n=>n.some(s=>ye(s,t));switch(i.kind){case"BreakStatement":return i.target===t;case"Block":return e(i.statements);case"IfStatement":return ye(i.then,t)||i.otherwise!==null&&ye(i.otherwise,t);case"WhileStatement":case"DoStatement":case"ForStatement":case"ForEachStatement":case"LabeledStatement":return ye(i.body,t);case"SwitchStatement":return i.cases.some(n=>e(n.statements)||n.body?.kind==="Block"&&ye(n.body,t));case"TryStatement":return ye(i.block,t)||i.catches.some(n=>ye(n.block,t))||i.finallyBlock!==null&&ye(i.finallyBlock,t);default:return!1}}function wa(i){return i.qualifiedName==="java.lang.String"?"String":i.qualifiedName}function Je(i){switch(i.tag){case"typevar":return i.symbol?Je(W(i)):"Object";case"wildcard":case"object":return"Object";case"string":return"String";case"library":return i.symbol.qualifiedName;case"class":return i.symbol.binaryName;case"array":return Je(i.element)+"[]";default:return $(i)}}function ja(i){return i.tag==="typevar"&&i.symbol?i.symbol.bounds.some(t=>ja(t)||t.tag==="library"&&t.symbol.name==="Comparable"):i.tag==="class"?i.symbol.isEnum||Tn(i.symbol).some(t=>t.symbol.name==="Comparable"):i.tag==="string"||i.tag==="library"&&(i.symbol.box!==void 0||i.symbol.name==="StringBuilder"||i.symbol.name==="StringBuffer"||i.symbol.supertypes.some(t=>t.tag==="library"&&t.symbol.name==="Comparable"))}function ss(i){if(i.kind==="Name")return i.identifier;if(i.kind!=="FieldAccess")return null;let t=ss(i.target);return t===null?null:`${t}.${i.name}`}function nn(i){return`${/^[AEIOU]/i.test(i)?"an":"a"} ${i}`}function ge(i){if(!i)return;let t=i.tag==="wildcard"?i.bound??void 0:i;return t?.tag==="object"?void 0:t}var es={tag:"typevar",name:"?return"};function ue(i,t){switch(i.tag){case"typevar":return t===null?!i.symbol:t.includes(ws(i));case"class":return i.args?.some(e=>ue(e,t))??!1;case"array":return ue(i.element,t);case"wildcard":return i.bound!==null&&ue(i.bound,t);case"library":return i.args.some(e=>ue(e,t));default:return!1}}function Ps(i){if(i.tag!=="library"||!i.symbol.functional)return null;let t=i.symbol.methods.find(n=>n.name===i.symbol.functional&&!n.isStatic);if(!t)return null;let e=i.symbol.typeParams.map((n,s)=>{let r=i.args[s];return r?r.tag==="wildcard"?r.bound??G:r:G});return{params:t.params.map(n=>Xt(n,i.symbol.typeParams,e)),returnType:Xt(t.returnType,i.symbol.typeParams,e)}}function ll(i){let t=0,e=i;for(let n=i;n;n=n.captureOf)t+=n.assignCount??0,e=n;return e.isFinal&&!e.forEach?!0:e.noInitializer?t<=1:t===0}function cl(i){return i.kind==="MethodCall"||i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="NewObject"}function Ee(i){if(i.kind==="Name")return[i.identifier];if(i.kind==="FieldAccess"){let t=Ee(i.target);return t?[...t,i.name]:null}return null}var Da=new Set(["type","symbol","method","constant","libraryCall","ctor","fieldSymbol","captures","functional","caught","finallySlots","lambda","receiver","mathFunction","interfaceSymbol","imported"]);function Js(i,t){if(Array.isArray(i)){for(let n of i)Js(n,t);return}if(i===null||typeof i!="object")return;let e=i;e.kind==="Name"&&typeof e.identifier=="string"&&t(e.identifier,e.pos);for(let[n,s]of Object.entries(e))Da.has(n)||s===null||typeof s!="object"||Js(s,t)}function ul(i,t){for(let n of i.locals)n.slot+=t;i.maxSlots+=t,i.finallySlots!==void 0&&(i.finallySlots+=t);let e=n=>{if(Array.isArray(n)){for(let a of n)e(a);return}if(n===null||typeof n!="object")return;let s=n;if(s.kind==="Lambda"||s.kind==="MethodRef"||s.kind==="ClassDeclaration")return;typeof s.liveSlots=="number"&&(s.liveSlots=s.liveSlots+t);let r=s.finallySlots;r&&typeof r.base=="number"&&(r.base+=t,r.before+=t);for(let[a,o]of Object.entries(s))!Da.has(a)&&o&&typeof o=="object"&&e(o)};e(i.declaration.body)}function bt(i,t,e){if(!t)return;if(i.tag==="typevar"){let s=ws(i);if(e.has(s)||t.tag==="null"||t.tag==="diamond"||t.tag==="lambda"||t.tag==="error"||t.tag==="typevar"&&!t.symbol)return;let r=t.tag==="wildcard"&&t.poly?t.bound:nt(t)?Nr(t):t.tag==="wildcard"?t:qt(t);r&&e.set(s,r);return}if(i.tag==="wildcard"){i.bound&&bt(i.bound,t,e);return}if(i.tag==="array"&&t.tag==="array"){if(i.element.tag==="typevar"&&!nt(t.element))return;bt(i.element,t.element,e);return}let n=s=>s.tag==="wildcard"?s.bound??G:s;if(i.tag==="library"&&(t.tag==="library"||t.tag==="class"||t.tag==="typevar")){let s=t.tag==="library"?Dt(t,i.symbol):t.tag==="class"?Le(t).map(r=>Dt(r,i.symbol)).find(r=>r)??null:null;if(s)i.args.forEach((r,a)=>s.args[a]&&bt(r,r.tag==="typevar"&&!Or(s.args[a])?s.args[a]:n(s.args[a]),e));else if(t.tag==="typevar"&&t.symbol)for(let r of t.symbol.bounds)bt(i,r,e);return}if(i.tag==="class"&&i.args?.length&&(t.tag==="class"||t.tag==="typevar")){let s=se(t,i.symbol);s?.args&&i.args.forEach((r,a)=>s.args[a]&&bt(r,n(s.args[a]),e))}}function Or(i){return i.tag==="wildcard"&&i.poly!==void 0}function hl(i,t){if(i.tag!=="library"||t.tag!=="library")return null;let e=Dt(t,i.symbol);if(!e)return null;for(let[n,s]of e.args.entries()){let r=i.args[n];if(s.tag!=="wildcard"||!s.poly||!r||r.tag==="wildcard"||!s.poly.lows.some(o=>!K(o,r)))continue;let a=s.poly.lows.filter((o,c)=>s.poly.lows.findIndex(u=>at(u,o))===c);return[`inference variable ${s.poly.name} has incompatible bounds`,` equality constraints: ${$(r)}`,` lower bounds: ${[...a].reverse().map($).join(",")}`,...s.poly.where].join(`\n`)}return null}function Nr(i){return i.tag==="library"&&i.args.some(Or)?{...i,args:i.args.map(t=>Or(t)?t.bound:t)}:i}function Ms(i,t,e=!1){let n=new Map;if(t?.tag!=="library")return n;let s=pt(i,i.typeParams.map(o=>({tag:"typevar",name:o}))),r=Dt(s,t.symbol),a=o=>e&&o?.tag==="object"?o:ge(o);return r&&r.args.forEach((o,c)=>a(t.args[c])&&bt(o,a(t.args[c]),n)),n}function Er(i,t){let e=new Map;if(!t)return e;let n=fe(i);if(t.tag==="class"){let s=se(n,t.symbol);s?.args&&t.args&&s.args.forEach((r,a)=>ge(t.args[a])&&bt(r,ge(t.args[a]),e))}else if(t.tag==="library"){let s=Le(n).map(r=>Dt(r,t.symbol)).find(r=>r);s&&s.args.forEach((r,a)=>ge(t.args[a])&&bt(r,ge(t.args[a]),e))}return e}function ka(i,t,e,n,s){t.forEach((r,a)=>{let o=e[a];if(!(!o||o.tag==="null"||o.tag==="lambda"||o.tag==="diamond"||o.tag==="error"))if(r.tag==="typevar"&&r.symbol&&i.includes(r.symbol.key)){let c=nt(o)?Nr(o):qt(o);if(!c)return;let u=s.get(r.symbol.key)??[];u.some(d=>at(d,c))||u.push(c),s.set(r.symbol.key,u)}else bt(r,o,n)})}function Ca(i,t,e){if(!rs([t]).length||!nt(e))return;let n=W(e);n.tag!=="object"&&n.tag!=="null"&&!K(W(t),n)&&(i.genericCast=n)}function dl(i,t){if(t.some(s=>"all"in s))return!0;let e=t.flatMap(s=>"pattern"in s?[s.pattern]:[]),n=t.flatMap(s=>"constantOf"in s?[s]:[]);return $r(i,e,n,new Set)}function $r(i,t,e,n){let s=W(i);if(t.some(o=>o.kind==="TypePattern"&&o.tested&&K(s,W(o.tested))))return!0;let r=i.tag==="typevar"&&i.symbol?fl(i):i;if(r.tag!=="class")return!1;let a=r.symbol;if(n.has(a))return!1;if(a.isEnum){let o=new Set(e.filter(c=>c.constantOf===a).map(c=>c.ordinal));return a.enumConstants.every(c=>o.has(c.enumConstant.ordinal))}if(a.isSealed&&a.permitted){if(!a.isAbstract)return!1;let o=new Set(n).add(a);return a.permitted.every(c=>$r(tt(c),t,e,o))}if(a.isRecord){let o=t.filter(u=>u.kind==="RecordPattern"&&u.tested?.tag==="class"&&u.tested.symbol===a);if(!o.length)return!1;let c=a.components.map(u=>u.type);return Fa(c,o.map(u=>u.components),n)}return!1}function Fa(i,t,e){if(!i.length)return t.length>0;let[n,...s]=i;return _a(n).every(r=>{let a=t.filter(o=>ml(o[0],r,e));return Fa(s,a.map(o=>o.slice(1)),e)})}function _a(i){return i.tag==="class"&&i.symbol.isSealed&&i.symbol.isAbstract&&i.symbol.permitted?i.symbol.permitted.flatMap(t=>_a(tt(t))):[i]}function ml(i,t,e){return i.kind==="TypePattern"?i.unconditional===!0||i.tested!==void 0&&(st(t)?at(t,i.tested):K(W(t),W(i.tested))):t.tag==="class"&&$r(t,[i],[],e)}function fl(i){return i.symbol?.bounds[0]??G}function Lr(i,t=!1){let e=[];for(let n of t?i.members:[...i.members,...i.anonymousClasses??[]])!t&&(n.anonymous||n.local)&&n.hierarchyState!==2||e.push(...Lr(n,t),n);return e}function Ea(i){return i.declaration.params[i.declaration.params.length-1]?.varargs===!0}function Aa(i,t){let e=i.params[i.params.length-1];return!i.varargs||e?.tag!=="array"||t.length===i.params.length&&t[t.length-1].tag==="array"?i.params:[...i.params.slice(0,-1),...t.slice(i.params.length-1).map(()=>e.element)]}function Ia(i,t){if(!i.varargs||i.problem||t.length<i.params.length-1)return null;let e=i.params[i.params.length-1].element;for(let n=i.params.length-1;n<t.length;n++)if(!Ht(e,t[n]))return`varargs mismatch; ${Ue(e,t[n])}`;return null}function Ln(i){switch(i.tag){case"typevar":return!1;case"array":return Ln(i.element);case"library":return i.args.every(t=>t.tag==="wildcard"&&!t.bound);case"class":return(i.args??[]).every(t=>t.tag==="wildcard"&&!t.bound);default:return!0}}function pl(i,t){let e=n=>n.tag!=="wildcard"&&n.tag!=="typevar"&&Ln(n);if(i.tag==="library"&&t.tag==="library"&&i.args.length){let n=Dt(t,i.symbol);return n!==null&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!at(s,i.args[r]))}if(i.tag==="class"&&t.tag==="class"&&i.args?.length){let n=se(t,i.symbol);return n?.args!==void 0&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!at(s,i.args[r]))}return!1}function yl(i){return i.tag==="string"||i.tag==="class"||i.tag==="array"||i.tag==="library"&&i.symbol.box!==void 0}function Oa(i,t,e){if(!t.varargs||t.name!=="of"||!["List","Set"].includes(i.name)||e>10||t.params.length!==1)return t;let n=t.params[0].element;return{...t,varargs:!1,params:Array.from({length:e},()=>n)}}function Ve(i,t,e){let n=[],s=a=>{a.tag==="typevar"&&!a.symbol&&!n.includes(a.name)?n.push(a.name):a.tag==="array"?s(a.element):a.tag==="wildcard"&&a.bound?s(a.bound):a.tag==="library"&&a.args.forEach(s)};if(i.forEach(s),!n.length)return[];let r=[n.length===1?` where ${n[0]} is a type-variable:`:` where ${n.join(",")} are type-variables:`];for(let a of n)if(e?.typeParams?.includes(a)){let o=e.typeParamBounds?.[a],c=e.params.map((u,d)=>e.varargs&&d===e.params.length-1&&u.tag==="array"?`${$(u.element)}...`:$(u));r.push(` ${a} extends ${e.typeParamShown?.[a]??(o?$(o):"Object")} declared in method <${e.typeParams.join(",")}>${e.name}(${c.join(",")})`)}else r.push(` ${a} extends Object declared in ${t.isInterface?"interface":"class"} ${t.name}`);return r}function Re(i,t){if(i.tag==="array"&&t.tag==="array")return nt(i.element)&&Re(i.element,t.element);let e=t.tag==="library"&&t.symbol.typeParams.length>0&&!t.args.length||t.tag==="class"&&(t.symbol.typeParams?.length??0)>0&&!t.args?.length,n=i.tag==="library"?i.args:i.tag==="class"?i.args??[]:[],s=n.length>0&&!n.every(r=>r.tag==="wildcard"&&!r.bound);return e&&s&&K(t,W(i))}function gl(i,t){let e=!1;return Js(i,n=>{n===t&&(e=!0)}),e}function Ar(i,t){if(K(i,t))return t;if(K(t,i))return i;let e=[],n=[i];for(;n.length;){let r=n.shift(),a=r.tag==="class"?Vn(r):r.tag==="library"?Sr(r):[];for(let o of a)e.some(c=>at(c,o))||(e.push(o),n.push(o))}let s=e.filter(r=>K(t,r)&&!at(r,G));return s.find(r=>r.tag==="class"&&!r.symbol.isInterface)??s.find(r=>r.tag==="class")??s.find(r=>r.tag==="library"&&!r.symbol.isInterface)??G}function bl(i){if(i.tag!=="wildcard")return i;if(i.isSuper)return i.bound??G;let t=i.bound??G;return{tag:"typevar",name:"CAP#1",symbol:{kind:"typevar",name:"CAP#1",key:`capture#${++Sl}`,bounds:[t],declaredIn:"",pos:0,ofClass:null,capture:$(i)}}}var Sl=0;function Me(i){return i.tag==="wildcard"?i.isSuper?G:i.bound??G:i}function rs(i,t=[]){let e=n=>{switch(n.tag){case"typevar":n.symbol&&!t.includes(n.symbol)&&t.push(n.symbol);return;case"array":return e(n.element);case"wildcard":n.bound&&e(n.bound);return;case"library":return n.args.forEach(e);case"class":return n.args?.forEach(e)}};return i.forEach(e),t}function Et(i,t=[]){let e=[...t],n=[];for(let r of rs(i)){if(r.capture){n.some(a=>a.name===r.name)||n.push({name:r.name,line:` ${r.name} extends ${r.bounds.map($).join(",")} from capture of ${r.capture}`});continue}e.some(a=>a.name===r.name)||e.push({name:r.name,line:` ${r.name} extends ${r.bounds.length?r.bounds.map($).join(","):"Object"} declared in ${r.declaredIn}`})}let s=(r,a,o)=>{if(!r.length)return[];let c=r.map(u=>u.name);return[c.length===1?` where ${c[0]} is ${a}:`:` where ${c.join(",")} are ${o}:`,...r.map(u=>u.line)]};return[...s(e,"a type-variable","type-variables"),...s(n,"a fresh type-variable","fresh type-variables")]}function La(i,t,e){let n=i.shown??i.params;for(let s=0;s<Math.min(t.length,n.length);s++){let r=n[s],a=r.tag==="typevar"?e.find(c=>c.name===r.name):void 0,o=qt(t[s])??t[s];if(a?.bounds.length&&o.tag!=="null"&&!a.bounds.every(c=>K(o,c)))return{variable:a,lower:o}}return null}function Na(i,t,e){let n=i.method?.typeParams;if(!n?.length||i.problem||!i.shown)return null;let s=n.map(r=>r.name).join(",");if(i.varargs?t.length<i.params.length-1:t.length!==i.params.length)return`cannot infer type-variable(s) ${s}\n${e}(actual and formal argument lists differ in length)`;for(let r=0;r<t.length&&r<i.params.length;r++)if(!(Ht(i.params[r],t[r])||Re(i.params[r],t[r])))return`cannot infer type-variable(s) ${s}\n${e}(argument mismatch; ${$(t[r])} cannot be converted to ${$(i.shown[r])})`;return null}function $a(i,t,e,n){let s=t.method,r=s.typeParams.map(o=>n.label({name:o,decl:t})).join(",");if(!(s.varargs?e.length>=s.params.length-1:e.length===s.params.length))return`cannot infer type-variable(s) ${r}\n (actual and formal argument lists differ in length)`;for(let o=0;o<Math.min(e.length,i.params.length);o++){let c=i.params[o],u=e[o];if(Ht(c,u)||Re(c,u))continue;let d=s.params[Math.min(o,s.params.length-1)];if(d.tag==="array"&&d.element.tag==="typevar"&&s.typeParams.includes(d.element.name)&&u.tag==="array"&&!nt(u.element)){let h={name:d.element.name,decl:t},m=s.typeParamBounds?.[d.element.name];return`inference variable ${n.label(h)} has incompatible bounds\n equality constraints: ${$(u.element)}\n upper bounds: ${m?n.render(m,t):"Object"}`}return`cannot infer type-variable(s) ${r}\n (argument mismatch; ${$(u)} cannot be converted to ${n.render(d,t)})`}return null}function Rs(i){let t=i.method?.owner;if(t?.typeParams?.length){let n=t.typeParams;return{text:`${i.ownerKind??(t.isInterface?"interface":"class")} ${i.owner}<${n.map(s=>s.name).join(",")}>`,where:n.map(s=>({name:s.name,line:` ${s.name} extends ${s.bounds.length?s.bounds.map($).join(","):"Object"} declared in ${s.declaredIn}`}))}}let e=i.library&&It[i.owner]?Wt(i.owner):void 0;if(e){let n=e.isInterface?"interface":"class";return e.typeParams.length?{text:`${n} ${i.owner}<${e.typeParams.join(",")}>`,where:e.typeParams.map(s=>({name:s,line:` ${s} extends Object declared in ${n} ${e.name}`}))}:{text:`${n} ${i.owner}`,where:[]}}return{text:`${i.ownerKind??"class"} ${i.owner}`,where:[]}}function Tl(i,t,e,n){if(at(i,t))return i;if(i.tag==="byte"&&t.tag==="short"||i.tag==="short"&&t.tag==="byte")return xn;let s={byte:[-128,127],short:[-32768,32767],char:[0,65535]},r=(a,o)=>{let c=s[a.tag];return c!==void 0&&o?.kind==="int"&&o.value>=c[0]&&o.value<=c[1]};return r(i,n)?i:r(t,e)?t:ns(i,t)}function Pa(i,t){return at(i,t)?i:i.tag==="null"?t:t.tag==="null"?i:G}function On(i,t){return Rt(t)?ua(i,t.tag)??i:i}function xl(i,t,e){let n=On(t,e);switch(n.kind){case"int":return X(i==="-"?-n.value:i==="~"?~n.value:n.value);case"long":return _t(i==="-"?-n.value:i==="~"?~n.value:n.value);case"double":return ie(i==="-"?-n.value:n.value);case"float":return pe(i==="-"?-n.value:n.value)}}function vl(i,t,e,n){if(i==="+"&&(t.kind==="string"||e.kind==="string"))return vr(zn(t)+zn(e));let s=t.kind==="double"||e.kind==="double"?"double":t.kind==="float"||e.kind==="float"?"float":t.kind==="long"||e.kind==="long"?"long":"int",r=i==="<<"||i===">>"||i===">>>";if(n?.tag==="long"||!r&&s==="long"&&t.kind!=="boolean"){if(r){let d=Cn(t),h=Cn(e);if(d===void 0||h===void 0)return;let m=BigInt(Number(BigInt.asUintN(6,h)));return i==="<<"?_t(d<<m):i===">>"?_t(d>>m):_t(BigInt.asUintN(64,d)>>m)}let c=Cn(t),u=Cn(e);if(c===void 0||u===void 0)return;switch(i){case"+":return _t(c+u);case"-":return _t(c-u);case"*":return _t(c*u);case"/":return u===0n?void 0:_t(c/u);case"%":return u===0n?void 0:_t(c%u);case"&":return _t(c&u);case"|":return _t(c|u);case"^":return _t(c^u);case"<":return Tt(c<u);case">":return Tt(c>u);case"<=":return Tt(c<=u);case">=":return Tt(c>=u);case"==":return Tt(c===u);case"!=":return Tt(c!==u)}return}if((s==="double"||s==="float")&&!r){let c=s==="float",u=c?Is(t):Kn(t),d=c?Is(e):Kn(e);if(u===void 0||d===void 0)return;let h=c?pe:ie;switch(i){case"+":return h(u+d);case"-":return h(u-d);case"*":return h(u*d);case"/":return h(u/d);case"%":return h(u%d);case"<":return Tt(u<d);case">":return Tt(u>d);case"<=":return Tt(u<=d);case">=":return Tt(u>=d);case"==":return Tt(u===d);case"!=":return Tt(u!==d)}return}let a=kn(t),o=t.kind==="long"||e.kind==="long"?e.kind==="long"?Number(BigInt.asIntN(32,e.value)):kn(e):kn(e);if(a!==void 0&&o!==void 0){switch(i){case"+":return X(a+o);case"-":return X(a-o);case"*":return X(Math.imul(a,o));case"/":return o===0?void 0:X(a/o);case"%":return o===0?void 0:X(a%o);case"<<":return X(a<<o);case">>":return X(a>>o);case">>>":return X(a>>>o);case"&":return X(a&o);case"|":return X(a|o);case"^":return X(a^o);case"<":return Tt(a<o);case">":return Tt(a>o);case"<=":return Tt(a<=o);case">=":return Tt(a>=o);case"==":return Tt(a===o);case"!=":return Tt(a!==o)}return}if(t.kind==="boolean"&&e.kind==="boolean"){let c=t.value,u=e.value;switch(i){case"&&":case"&":return Tt(c&&u);case"||":case"|":return Tt(c||u);case"^":case"!=":return Tt(c!==u);case"==":return Tt(c===u)}return}if(t.kind==="string"&&e.kind==="string"&&(i==="=="||i==="!=")){let c=t.value===e.value;return Tt(i==="=="?c:!c)}}var l={ICONST:1,SCONST:2,ACONST_NULL:3,LOAD:4,STORE:5,POP:6,DUP:7,DUP_X1:8,DUP_X2:9,DUP2:24,IADD:10,ISUB:11,IMUL:12,IDIV:13,IREM:14,INEG:15,ISHL:16,ISHR:17,IUSHR:18,IAND:19,IOR:20,IXOR:21,INOT:22,BNOT:23,I2C:25,ICMPEQ:30,ICMPNE:31,ICMPLT:32,ICMPLE:33,ICMPGT:34,ICMPGE:35,ACMPEQ:36,ACMPNE:37,JUMP:40,JUMP_IF_FALSE:41,JUMP_IF_TRUE:42,IINC:43,TOSTRING_INT:50,TOSTRING_BOOL:51,TOSTRING_REF:52,SCONCAT:53,TOSTRING_CHAR:54,PRINT:60,RETURN:70,RETURN_VALUE:71,INVOKE:72,NEWARRAY:80,NEWARRAY_REF:84,ALOAD:81,ASTORE:82,ARRAYLENGTH:83,STR_LENGTH:90,STR_CHARAT:91,STR_EQUALS:92,GETSTATIC:100,PUTSTATIC:101,GETFIELD:102,PUTFIELD:103,NEW:104,VALUEOF:110,OBJ_TOSTRING:111,OBJ_HASHCODE:112,OBJ_EQUALS:113,NCONST:120,LADD:121,LSUB:122,LMUL:123,LDIV:124,LREM:125,LNEG:126,LSHL:127,LSHR:128,LUSHR:129,LAND:130,LOR:131,LXOR:132,DADD:133,DSUB:134,DMUL:135,DDIV:136,DREM:137,DNEG:138,L2I:139,L2D:140,D2I:141,D2L:142,TOSTRING_LONG:143,TOSTRING_DOUBLE:144,NEWMULTI:145,CHECKNULL:146,MATH:147,INVOKE_NATIVE:148,BOX:149,UNBOX:150,STR_TOCHARS:151,LAMBDA:152,STR_COMPARETO:153,HOST_ARG:154,HOST_RESULT:155,INVOKE_VIRTUAL:156,CHECKCAST:157,INSTANCEOF:158,OBJ_SUPER:159,ENUM_VALUEOF:160,ATHROW:161,THROWABLE:162,I2B:163,I2S:164,I2F:165,L2F:166,D2F:167,FADD:168,FSUB:169,FMUL:170,FDIV:171,FREM:172,TOSTRING_FLOAT:173,IF_CMP:180,IF_K:181,IF_LL:182,IF_LK:183,IF_LNULL:184,LOAD2:185,LOADK:186,IADDK:187,IINC_JUMP:188,ALOAD_LL:189,IOPK:190,SET_BASE:191,BASE:192},Ut={FILL_TRACE:0,PRINT_TRACE:1,ADD_SUPPRESSED:2,GET_SUPPRESSED:3,CLASS_NAME:4,PRINT_UNCAUGHT:5,INIT_CAUSE:6},wl=[[1,1],[1,0],[2,0],[1,1],[1,1],[1,0],[2,1]],je={INT:0,LONG:1,DOUBLE:2,CHAR:3,BOOLEAN:4,FLOAT:5,BYTE:6,SHORT:7},Pr=["int","long","double","char","boolean","float","byte","short"],ht={ABS_I:0,ABS_L:1,ABS_D:2,MAX_I:3,MAX_L:4,MAX_D:5,MIN_I:6,MIN_L:7,MIN_D:8,SQRT:9,FLOOR:10,CEIL:11,ROUND:12,ROUND_F:13},kl=[1,1,1,2,2,2,2,2,2,1,1,1,1,1],Ot={NONE:0,INT:1,BOOLEAN:2,STRING:3,CHAR:4,CHAR_ARRAY:5,OBJECT:6,LONG:7,DOUBLE:8,FLOAT:9},Y={INT:0,BOOLEAN:1,CHAR:2,REF:3,LONG:4,DOUBLE:5,BYTE:6,SHORT:7,FLOAT:8},sn={};for(let[i,t]of Object.entries(l))sn[t]={name:i,operands:0,pop:0,push:0};var z=(i,t,e,n)=>Object.assign(sn[i],{operands:t,pop:e,push:n});z(l.ICONST,1,0,1);z(l.SCONST,1,0,1);z(l.ACONST_NULL,0,0,1);z(l.LOAD,1,0,1);z(l.STORE,1,1,0);z(l.POP,0,1,0);z(l.SET_BASE,0,2,0);z(l.BASE,0,1,1);z(l.DUP,0,1,2);z(l.DUP_X1,0,2,3);z(l.DUP_X2,0,3,4);z(l.DUP2,0,2,4);for(let i of[l.IADD,l.ISUB,l.IMUL,l.IDIV,l.IREM,l.ISHL,l.ISHR,l.IUSHR,l.IAND,l.IOR,l.IXOR])z(i,0,2,1);for(let i of[l.ICMPEQ,l.ICMPNE,l.ICMPLT,l.ICMPLE,l.ICMPGT,l.ICMPGE,l.ACMPEQ,l.ACMPNE])z(i,0,2,1);for(let i of[l.INEG,l.INOT,l.BNOT,l.I2C,l.TOSTRING_INT,l.TOSTRING_BOOL,l.TOSTRING_REF,l.TOSTRING_CHAR])z(i,0,1,1);z(l.JUMP,1,0,0);z(l.JUMP_IF_FALSE,1,1,0);z(l.JUMP_IF_TRUE,1,1,0);z(l.IINC,2,0,0);z(l.SCONCAT,0,2,1);z(l.PRINT,3,0,0);z(l.RETURN,0,0,0);z(l.RETURN_VALUE,0,1,0);z(l.INVOKE,2,0,0);z(l.NEWARRAY,1,1,1);z(l.NEWARRAY_REF,1,1,1);z(l.ALOAD,2,2,1);z(l.ASTORE,2,3,0);z(l.ARRAYLENGTH,1,1,1);z(l.STR_LENGTH,1,1,1);z(l.STR_CHARAT,1,2,1);z(l.STR_EQUALS,1,2,1);z(l.GETSTATIC,1,0,1);z(l.PUTSTATIC,1,1,0);z(l.GETFIELD,2,1,1);z(l.PUTFIELD,2,2,0);z(l.NEW,1,0,1);z(l.VALUEOF,0,1,1);z(l.OBJ_TOSTRING,1,1,1);z(l.OBJ_HASHCODE,1,1,1);z(l.OBJ_EQUALS,1,2,1);z(l.NCONST,1,0,1);for(let i of[l.LADD,l.LSUB,l.LMUL,l.LDIV,l.LREM,l.LSHL,l.LSHR,l.LUSHR,l.LAND,l.LOR,l.LXOR])z(i,0,2,1);for(let i of[l.DADD,l.DSUB,l.DMUL,l.DDIV,l.DREM])z(i,0,2,1);for(let i of[l.LNEG,l.DNEG,l.L2I,l.L2D,l.D2I,l.D2L,l.TOSTRING_LONG,l.TOSTRING_DOUBLE])z(i,0,1,1);for(let i of[l.I2B,l.I2S,l.I2F,l.L2F,l.D2F,l.TOSTRING_FLOAT])z(i,0,1,1);for(let i of[l.FADD,l.FSUB,l.FMUL,l.FDIV,l.FREM])z(i,0,2,1);z(l.NEWMULTI,2,0,1);z(l.CHECKNULL,1,1,0);z(l.MATH,1,0,1);z(l.INVOKE_NATIVE,2,0,0);z(l.BOX,1,1,1);z(l.UNBOX,2,1,1);z(l.STR_TOCHARS,1,1,1);z(l.LAMBDA,5,0,1);z(l.STR_COMPARETO,2,2,1);z(l.HOST_ARG,1,0,1);z(l.HOST_RESULT,0,1,0);z(l.INVOKE_VIRTUAL,2,0,0);z(l.CHECKCAST,1,1,1);z(l.INSTANCEOF,1,1,1);z(l.OBJ_SUPER,1,0,1);z(l.ENUM_VALUEOF,1,1,1);z(l.ATHROW,1,1,0);z(l.THROWABLE,1,0,0);z(l.IF_CMP,2,2,0);z(l.IF_K,3,1,0);z(l.IF_LL,4,0,0);z(l.IF_LK,4,0,0);z(l.IF_LNULL,3,0,0);z(l.LOAD2,2,0,2);z(l.LOADK,2,0,2);z(l.IADDK,1,1,1);z(l.IINC_JUMP,3,0,0);z(l.ALOAD_LL,4,0,1);z(l.IOPK,2,1,1);var Mr={[l.IF_CMP]:2,[l.IF_K]:3,[l.IF_LL]:4,[l.IF_LK]:4,[l.IF_LNULL]:3,[l.IINC_JUMP]:3},Cl={[l.IF_LL]:[2,3],[l.IF_LK]:[2],[l.IF_LNULL]:[2],[l.LOAD2]:[1,2],[l.LOADK]:[1],[l.IINC_JUMP]:[1],[l.ALOAD_LL]:[1,2]},Rr=new Set([l.IMUL,l.IDIV,l.IREM,l.IAND,l.IOR,l.IXOR,l.ISHL,l.ISHR,l.IUSHR]),El=new Set([l.IF_CMP,l.IF_K,l.IF_LL,l.IF_LK]),Al=new Set([l.ATHROW,l.ARRAYLENGTH,l.STR_LENGTH,l.STR_CHARAT,l.STR_EQUALS,l.OBJ_TOSTRING,l.OBJ_HASHCODE,l.OBJ_EQUALS,l.CHECKNULL,l.STR_TOCHARS,l.STR_COMPARETO]),Il=new Set([l.ALOAD,l.ASTORE,l.INVOKE,l.INVOKE_VIRTUAL,l.GETFIELD,l.PUTFIELD,l.INVOKE_NATIVE,l.UNBOX,l.STR_COMPARETO]),Ua=new Set(["removeEldestEntry(Entry)"]),ot=class extends Error{constructor(t){super(`invalid bytecode: ${t}`),this.name="BytecodeError"}};function Ba(i,t){let e=t.classes??[],n=Math.max(0,...e.map(d=>d.instanceFieldIsReference.length)),s=i.code,r=new Set;for(let d=0;d<s.length;){let h=sn[s[d]];if(!h)throw new ot(`unknown opcode ${s[d]} at ${d}`);if(r.add(d),d+=1+h.operands,d>s.length)throw new ot("truncated instruction at end")}let a=new Map,o=[[0,0]],c=i.handlers??new Int32Array(0);if(c.length%4!==0)throw new ot("bad handler table");for(let d=0;d<c.length;d+=4){let[h,m,p,k]=[c[d],c[d+1],c[d+2],c[d+3]];if(!r.has(h)||!(r.has(m)||m===s.length)||m<=h||!r.has(p))throw new ot(`bad handler ${d/4}`);if(k<-1||k>=t.strings.length)throw new ot(`bad handler type ${d/4}`);o.push([p,1])}let u=0;for(;o.length;){let[d,h]=o.pop(),m=d,p=h;for(;;){if(!r.has(m))throw new ot(`control reaches non-instruction offset ${m}`);let k=a.get(m);if(k!==void 0){if(k!==p)throw new ot(`stack height ${p} != ${k} at merge ${m}`);break}a.set(m,p);let g=s[m],O=sn[g],T=O.pop,x=O.push;if(g===l.PRINT&&(T=s[m+3]===Ot.NONE?0:1),g===l.NEWMULTI&&(T=s[m+2]),g===l.MATH){let C=kl[s[m+1]];if(C===void 0)throw new ot(`bad Math function at ${m}`);T=C}if(g===l.INVOKE||g===l.INVOKE_VIRTUAL){let C=t.methods[s[m+1]];if(!C)throw new ot(`call to unknown method ${s[m+1]} at ${m}`);T=C.argCount,x=C.returnsValue?1:0}if(g===l.INVOKE_NATIVE){let C=t.natives?.[s[m+1]];if(!C)throw new ot(`call to unknown native ${s[m+1]} at ${m}`);T=C.argCount,x=C.returnsValue?1:0}if((g===l.BOX||g===l.UNBOX)&&(s[m+1]<0||s[m+1]>=Pr.length))throw new ot(`bad box kind at ${m}`);if(g===l.LAMBDA){let C=t.methods[s[m+1]],M=s[m+2];if(!C||M<0||M>C.argCount)throw new ot(`bad lambda method at ${m}`);if(s[m+3]<0||s[m+3]>=t.strings.length||s[m+5]>=t.strings.length)throw new ot(`bad lambda interface at ${m}`);T=M}if(g===l.NEW&&(s[m+1]<0||s[m+1]>=e.length))throw new ot(`bad class index at ${m}`);if(g===l.INVOKE_VIRTUAL&&t.methods[s[m+1]]?.selector===void 0)throw new ot(`virtual call to a method without a selector at ${m}`);if(g===l.THROWABLE){let C=wl[s[m+1]];if(!C)throw new ot(`bad Throwable operation at ${m}`);[T,x]=C}if(g===l.OBJ_SUPER){let C=s[m+1];if(C<0||C>2)throw new ot(`bad Object method at ${m}`);T=C===2?2:1}if((g===l.NEWARRAY_REF||g===l.NEWMULTI||g===l.CHECKCAST||g===l.INSTANCEOF)&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new ot(`bad descriptor index at ${m}`);if(g===l.NEWMULTI&&s[m+2]<2)throw new ot(`NEWMULTI needs two or more lengths at ${m}`);if(g===l.NCONST&&(s[m+1]<0||s[m+1]>=(t.numbers?.length??0)))throw new ot(`bad number index at ${m}`);if(p<T)throw new ot(`stack underflow at ${m} (${O.name})`);if(p=p-T+x,u=Math.max(u,p),g===l.LOAD||g===l.STORE||g===l.IINC){let C=s[m+1];if(C<0||C>=i.maxLocals)throw new ot(`bad local slot ${C} at ${m}`)}for(let C of Cl[g]??[]){let M=s[m+C];if(M<0||M>=i.maxLocals)throw new ot(`bad local slot ${M} at ${m}`)}if(g===l.IOPK&&!Rr.has(s[m+1]))throw new ot(`bad operator at ${m}`);if(g===l.IOPK&&(s[m+1]===l.IDIV||s[m+1]===l.IREM)&&s[m+2]===0)throw new ot(`division by a zero constant at ${m}`);if(El.has(g)&&(s[m+1]<0||s[m+1]>11))throw new ot(`bad condition at ${m}`);if(g===l.ALOAD_LL&&(s[m+4]<-1||s[m+4]>=t.messages.length))throw new ot(`bad message index at ${m}`);if(g===l.SCONST&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new ot(`bad string index at ${m}`);if(g===l.GETSTATIC||g===l.PUTSTATIC||g===l.GETFIELD||g===l.PUTFIELD){let C=g<=l.PUTSTATIC?t.staticFieldIsReference?.length??0:n;if(s[m+1]<0||s[m+1]>=C)throw new ot(`bad field index at ${m}`)}let v=Il.has(g)?s[m+2]:Al.has(g)?s[m+1]:null;if(v!==null&&(v<-1||v>=t.messages.length))throw new ot(`bad message index at ${m}`);if(g===l.RETURN||g===l.RETURN_VALUE){if(g===l.RETURN_VALUE!==i.returnsValue)throw new ot(`wrong return kind at ${m}`);if(p!==0)throw new ot(`return with non-empty stack at ${m}`);break}if(g===l.ATHROW)break;let R=m+1+O.operands,L=Mr[g];if(L!==void 0){let C=s[m+L];if(!r.has(C))throw new ot(`jump to ${C} at ${m}`);if(o.push([C,p]),g===l.IINC_JUMP)break}if(g===l.JUMP||g===l.JUMP_IF_FALSE||g===l.JUMP_IF_TRUE){let C=s[m+1];if(!r.has(C))throw new ot(`jump to ${C} at ${m}`);if(o.push([C,p]),g===l.JUMP)break}if(R>=s.length)throw new ot(`falls off the end at ${m}`);m=R}}return u}function Va(i,t){let e=i.lines,n=0;for(let s=0;s<e.length&&!(e[s]>t);s+=2)n=e[s+1];return n}var Ol=l.ICMPEQ,js=i=>i!==void 0&&i>=l.ICMPEQ&&i<=l.ICMPGE,Ds=(i,t)=>i-Ol+(t===l.JUMP_IF_FALSE?6:0),as=i=>i===l.JUMP_IF_FALSE||i===l.JUMP_IF_TRUE;function Ha(i){let t=i.code,e=[];for(let u=0;u<t.length;u+=1+sn[t[u]].operands)e.push(u);let n=new Set;for(let u of e){let d=t[u];(d===l.JUMP||d===l.JUMP_IF_FALSE||d===l.JUMP_IF_TRUE)&&n.add(t[u+1])}let s=i.handlers??new Int32Array(0);for(let u=0;u<s.length;u+=4)n.add(s[u]).add(s[u+1]).add(s[u+2]);for(let u=0;u<i.lines.length;u+=2)n.add(i.lines[u]);let r=[],a=new Map,o=[];for(let u=0;u<e.length;){let d=x=>e[u+x],h=x=>d(x)===void 0?void 0:t[d(x)],m=(x,v=1)=>t[d(x)+v],p=x=>{for(let v=1;v<x;v++)if(d(v)===void 0||n.has(d(v)))return!1;return!0},k=(x,...v)=>{let R=r.length;for(let C=0;C<x;C++)a.set(d(C),R);r.push(...v);let L=Mr[v[0]];L!==void 0&&o.push(R+L),u+=x},g=h(0);if(g===l.LOAD&&h(1)===l.LOAD&&js(h(2))&&as(h(3))&&p(4)){k(4,l.IF_LL,Ds(h(2),h(3)),m(0),m(1),m(3));continue}if(g===l.LOAD&&h(1)===l.ICONST&&js(h(2))&&as(h(3))&&p(4)){k(4,l.IF_LK,Ds(h(2),h(3)),m(0),m(1),m(3));continue}if(g===l.LOAD&&h(1)===l.ACONST_NULL&&(h(2)===l.ACMPEQ||h(2)===l.ACMPNE)&&as(h(3))&&p(4)){let x=h(2)===l.ACMPEQ==(h(3)===l.JUMP_IF_TRUE);k(4,l.IF_LNULL,x?1:0,m(0),m(3));continue}if(g===l.ICONST&&js(h(1))&&as(h(2))&&p(3)){k(3,l.IF_K,Ds(h(1),h(2)),m(0),m(2));continue}if(js(g)&&as(h(1))&&p(2)){k(2,l.IF_CMP,Ds(g,h(1)),m(1));continue}if(g===l.LOAD&&h(1)===l.LOAD&&h(2)===l.ALOAD&&p(3)){k(3,l.ALOAD_LL,m(0),m(1),m(2),m(2,2));continue}if(g===l.ICONST&&(h(1)===l.IADD||h(1)===l.ISUB)&&p(2)){k(2,l.IADDK,h(1)===l.IADD?m(0):-m(0)|0);continue}if(g===l.ICONST&&Rr.has(h(1))&&p(2)&&!((h(1)===l.IDIV||h(1)===l.IREM)&&m(0)===0)){k(2,l.IOPK,h(1),m(0));continue}if(g===l.IINC&&h(1)===l.JUMP&&p(2)){k(2,l.IINC_JUMP,m(0),m(0,2),m(1));continue}if(g===l.LOAD&&h(1)===l.LOAD&&p(2)){k(2,l.LOAD2,m(0),m(1));continue}if(g===l.LOAD&&h(1)===l.ICONST&&p(2)){k(2,l.LOADK,m(0),m(1));continue}let O=d(0),T=1+sn[g].operands;a.set(O,r.length),(g===l.JUMP||g===l.JUMP_IF_FALSE||g===l.JUMP_IF_TRUE)&&o.push(r.length+1);for(let x=0;x<T;x++)r.push(t[O+x]);u++}if(r.length===t.length)return;a.set(t.length,r.length);let c=u=>{let d=a.get(u);if(d===void 0)throw new Error(`fuse: offset ${u} is not an instruction start`);return d};for(let u of o)r[u]=c(r[u]);i.code=Int32Array.from(r),i.lines=i.lines.map((u,d)=>d%2===0?c(u):u),i.handlers&&(i.handlers=i.handlers.map((u,d)=>d%4===3?u:c(u)))}var Nl=["getMessage","getLocalizedMessage","getCause","toString","fillInStackTrace"];function Fr(i,t){return i.declaration.members.filter(e=>e.kind==="Initializer"&&e.isStatic===t&&e.symbol!==void 0)}function za(i){return Math.max(i.maxSlots,i.finallySlots??0)}function Ur(i,t,e){let n=new _r(t),s=i.classes.find(g=>g.binaryName==="java.lang.Throwable");n.useThrowable(s);let r=new Set(i.failedFiles??[]),a=g=>g.topLevel.file!==void 0&&r.has(g.topLevel.file.name),o=i.methods.map(g=>g.builtin?n.builtin(g):g.isAbstract||a(g.owner)?n.abstractStub(g):g.isConstructor?n.constructorCode(g):n.method(g)),c=new Map;for(let g of i.classes)for(let O of g.bridges??[])c.set(O,O.alias?O.target.index:o.push(n.bridge(g,O))-1);let u=$l(i,c),d=g=>i.selectors.get(g)??-1,h=i.classes.map(g=>{let O=g.fields.filter(j=>j.isStatic&&j.declarator.init&&!j.constant),T=Fr(g,!0),x=!a(g)&&(O.length||g.enumConstants.length||T.length)?o.push(n.staticInitializer(g,O))-1:-1,v=new Array(g.instanceCount).fill(!1);for(let j=g;j;j=j.superclass){j.outerField>=0&&(v[j.outerField]=!0);for(let P of j.fields)P.isStatic||(v[P.index]=ls(P.type));j===s&&v.fill(!0,yt.message,yt.causeSet)}let R=u.get(g),L=j=>d(j)>=0?R[d(j)]:-1,C={};R.forEach(j=>{if(j<0||j>=i.methods.length)return;let P=i.methods[j],B=`${P.name}/${P.params.length}`;(!(B in C)||P.owner===g)&&(C[B]=j)});let M=[];for(let j=g;j;j=j.superclass)M.unshift(j);for(let j of M)for(let P of j.bridges??[])P.library&&(C[`${P.name}/${P.params.length}`]=R[P.selector]);let _={};for(let j of M)for(let[P,B]of j.libraryOverrides??[])_[P]=R[B];return{name:g.binaryName,instanceFieldIsReference:v,clinit:x,toString:L("toString()String"),equals:L("equals(Object)boolean"),hashCode:L("hashCode()int"),superclass:g.superclass?.index??-1,isInterface:g.isInterface,types:Pl(g),vtable:R,virtuals:C,...Object.keys(_).length?{libraryOverrides:_}:{},...g.isEnum?{enumConstants:g.enumConstants.map(j=>j.index),canonicalName:g.binaryName.replace(/\\$/g,".")}:{}}}),m=o.push(e?n.practiceLauncher(e):n.launcher(i))-1,p=o.push(n.uncaughtPrinter(s))-1,k={version:14,classes:h,strings:n.strings,numbers:n.numbers,natives:n.natives,messages:n.messages,methods:o,staticFieldIsReference:i.staticFields.map(g=>ls(g.type)),staticFieldOwner:i.staticFields.map(g=>g.owner.index),entry:m,uncaught:p};for(let g of o)Ha(g),g.maxStack=Ba(g,k);return k}function $l(i,t){let e=i.selectors.size,n=new Map,s=(a,o=[])=>{for(let c of a.interfaces)o.includes(c)||o.push(c),s(c,o);return a.superclass&&s(a.superclass,o),o},r=a=>{let o=n.get(a);if(o)return o;let c=a.superclass?r(a.superclass).slice():new Int32Array(e).fill(-1);for(let u of a.methods)u.selector!==void 0&&(c[u.selector]=u.index);for(let u of s(a))for(let d of u.methods){if(d.selector===void 0||d.isAbstract)continue;let h=c[d.selector];(h<0||i.methods[h].isAbstract)&&(c[d.selector]=d.index)}for(let u of a.bridges??[])c[u.selector]=t.get(u);return n.set(a,c),c};for(let a of i.classes)r(a);return n}function Pl(i){let t=new Set,e=s=>{t.add(s.qualifiedName);for(let r of s.supertypes)r.tag==="library"&&e(r.symbol)},n=s=>{t.add(s.binaryName),s.isEnum&&t.add("java.lang.Enum").add("java.lang.Comparable");for(let r of s.libraryInterfaces)t.add(r.symbol.qualifiedName);s.librarySuperclass&&e(s.librarySuperclass.symbol),s.superclass&&n(s.superclass);for(let r of s.interfaces)n(r)};return n(i),i.isRecord&&t.add("java.lang.Record"),t.add("java.lang.Object"),[...t]}var et=class{pc=-1;uses=[]};function Ge(i){switch(i.tag){case"int":return Y.INT;case"boolean":return Y.BOOLEAN;case"char":return Y.CHAR;case"long":return Y.LONG;case"double":return Y.DOUBLE;case"byte":return Y.BYTE;case"short":return Y.SHORT;case"float":return Y.FLOAT;case"string":case"class":case"array":case"library":case"diamond":case"object":case"typevar":return Y.REF;default:throw new Error(`codegen: array of ${$(i)}`)}}var Ga=["int","byte/boolean","char","object","long","double","byte/boolean","short","float"];function Nn(i){return i.tag==="class"?i.symbol.binaryName:i.tag==="array"?Nn(i.element)+"[]":$(i)}function De(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}function Jr(i){let t=De(i);return t.kind==="Name"&&t.symbol?.kind==="type"||t.kind==="FieldAccess"&&t.typeSymbol!==void 0}function jr(i,t){return i.tag==="double"||t.tag==="double"?ft:i.tag==="float"||t.tag==="float"?kt:i.tag==="long"||t.tag==="long"?Jt:V}var Ml=new Set(["int","byte","short","char","long","float","double"]),os=i=>i!==void 0&&Ml.has(i.tag),Dr=i=>i.tag==="int"||i.tag==="byte"||i.tag==="short"||i.tag==="char",Ae=i=>os(i)||i?.tag==="boolean",ae={int:je.INT,long:je.LONG,double:je.DOUBLE,char:je.CHAR,boolean:je.BOOLEAN,float:je.FLOAT,byte:je.BYTE,short:je.SHORT},Rl={int:"java.lang.Integer.intValue()",long:"java.lang.Long.longValue()",double:"java.lang.Double.doubleValue()",char:"java.lang.Character.charValue()",boolean:"java.lang.Boolean.booleanValue()",float:"java.lang.Float.floatValue()",byte:"java.lang.Byte.byteValue()",short:"java.lang.Short.shortValue()"},Jl={"+":{int:l.IADD,long:l.LADD,double:l.DADD,float:l.FADD},"-":{int:l.ISUB,long:l.LSUB,double:l.DSUB,float:l.FSUB},"*":{int:l.IMUL,long:l.LMUL,double:l.DMUL,float:l.FMUL},"/":{int:l.IDIV,long:l.LDIV,double:l.DDIV,float:l.FDIV},"%":{int:l.IREM,long:l.LREM,double:l.DREM,float:l.FREM},"<<":{int:l.ISHL,long:l.LSHL},">>":{int:l.ISHR,long:l.LSHR},">>>":{int:l.IUSHR,long:l.LUSHR},"&":{int:l.IAND,long:l.LAND},"|":{int:l.IOR,long:l.LOR},"^":{int:l.IXOR,long:l.LXOR}},Fs={"<":l.ICMPLT,"<=":l.ICMPLE,">":l.ICMPGT,">=":l.ICMPGE,"==":l.ICMPEQ,"!=":l.ICMPNE},jl={"abs-int":ht.ABS_I,"abs-long":ht.ABS_L,"abs-double":ht.ABS_D,"max-int":ht.MAX_I,"max-long":ht.MAX_L,"max-double":ht.MAX_D,"min-int":ht.MIN_I,"min-long":ht.MIN_L,"min-double":ht.MIN_D,"abs-float":ht.ABS_D,"max-float":ht.MAX_D,"min-float":ht.MIN_D,"round-float":ht.ROUND_F,sqrt:ht.SQRT,floor:ht.FLOOR,ceil:ht.CEIL,"round-double":ht.ROUND},_s=class{segments=[];start=-1;open(t){this.start<0&&(this.start=t)}close(t){this.start>=0&&t>this.start&&this.segments.push([this.start,t]),this.start=-1}},_r=class{strings=[];numbers=[];natives=[];#d=new Map;messages=[];#z=new Map;#It=new Map;#rt=new Map;#G;get#Ot(){return this.#O?.topLevel?.file??this.#G}#O;#R=[];#bt=[];#m=-1;#C=new Map;#W=V;#V=0;#ut=!1;#X=[];#r=0;#p=0;#s=0;#n=0;#S=[];#l=[];#i=Object.create(null);constructor(t){this.#G=t}#D(t){return`${t.owner.binaryName}.${t.name}(${t.params.map(Nn).join(", ")})`}#kt(t,e){return`${t.qualifier??e.owner.binaryName}.${e.name}(${e.params.map(Nn).join(", ")})`}#E(t,e,n){this.#O=t,this.#R=[],this.#bt=[],this.#m=-1,this.#C=new Map,this.#W=n,this.#V=e,this.#X=[],this.#r=0,this.#p=0,this.#s=0,this.#n=0,this.#S=[],this.#l=[]}useThrowable(t){for(let e of t.methods)Nl.includes(e.name)&&(this.#i[e.name]=e)}#Y(t){if(t.lambda){let s=t.locals.filter(r=>r.parameter!==void 0).sort((r,a)=>r.parameter-a.parameter);return s.some(r=>r.type.tag==="long"||r.type.tag==="double")?Int32Array.from([...t.isStatic?[]:[0],...s.map(r=>r.slot)]):void 0}let e=t.declaration.params;if(!e.some(s=>s.symbol&&(s.symbol.type.tag==="long"||s.symbol.type.tag==="double")))return;let n=(t.isStatic?0:1)+(t.isConstructor&&t.owner.isInner?1:0)+(t.isConstructor&&(t.owner.isEnum||t.owner.enumBody)?2:0);return Int32Array.from([...Array.from({length:n},(s,r)=>r),...e.map(s=>s.symbol.slot)])}#A(t,e){let n={className:t.binaryName,classIndex:t.index,isStatic:e.isStatic,name:e.name,display:e.display,file:this.#Ot.name.replace(/^.*\\//,""),argCount:e.argCount,returnsValue:e.returnsValue,code:Int32Array.from(this.#R),lines:Int32Array.from(this.#bt),maxLocals:Math.max(1,this.#V+this.#n),maxStack:0};return e.hidden&&(n.hidden=!0),this.#S.length&&(n.handlers=Int32Array.from(this.#S)),n}#Q(t){return t.parameter!==void 0?`<parameter${t.parameter}>`:`<local${this.#u(t)}>`}#u(t){let e=t.slot;for(let n of this.#X)t.slot>=n.from&&(e+=n.by);return e}#x(){let t=this.#V+this.#s++;return this.#n=Math.max(this.#n,this.#s),t}#I(){this.#s--}staticInitializer(t,e){this.#E(t,Math.max(1,...Fr(t,!0).map(n=>za(n.symbol))),V);for(let n of t.enumConstants){let{node:s,ordinal:r}=n.enumConstant;this.#f(s.pos),this.#t(l.NEW,s.ctor.owner.index,l.DUP,l.SCONST,this.#g(s.name),l.ICONST,r),this.#et(s.args,s.ctor.params,s.varargs),this.#t(l.INVOKE,s.ctor.index,-1,l.PUTSTATIC,n.index)}return this.#Ct(t,!0,n=>e.includes(n),0),this.#t(l.RETURN),this.#A(t,{name:"<clinit>",display:`${t.binaryName}.<clinit>()`,isStatic:!0,argCount:0,returnsValue:!1})}#Ct(t,e,n,s){for(let r of t.declaration.members)if(r.kind==="FieldDeclaration")for(let a of r.declarators){let o=a.field;o&&o.isStatic===e&&n(o)&&this.#me(o)}else r.kind==="Initializer"&&r.isStatic===e&&r.symbol&&(s&&this.#X.push({from:1,by:s}),this.#L(r.body),s&&this.#X.pop())}#me(t){let e=t.declarator.init;this.#f(t.declarator.pos),t.isStatic||this.#t(l.LOAD,0),e.kind==="ArrayInitializer"?this.#w(e):(this.#h(e,!0),this.#ot(t.type,e)),t.isStatic?this.#t(l.PUTSTATIC,t.index):this.#t(l.PUTFIELD,t.index,-1)}constructorCode(t){let e=t.owner,n=e.isInner?1:e.isEnum||e.enumBody?2:0,s=t.params.length+1+n,r=1+n+t.params.reduce((m,p)=>m+(p.tag==="long"||p.tag==="double"?2:1),0),a=Fr(e,!1).map(m=>r-1+za(m.symbol));this.#E(e,Math.max(s,t.maxSlots,t.finallySlots??0,...a),V);let o=t.declaration.body,c=o.statements,u=c[0];if(u?.kind==="ConstructorCall"&&u.keyword==="this")this.#f(u.start),this.#t(l.LOAD,0),n&&this.#t(l.LOAD,1),n===2&&this.#t(l.LOAD,2),this.#et(u.args,u.target.params,u.varargs),this.#t(l.INVOKE,u.target.index,-1),c=c.slice(1);else{if(e.isInner&&this.#t(l.LOAD,0,l.LOAD,1,l.PUTFIELD,e.outerField,-1),e.isEnum&&this.#t(l.LOAD,0,l.LOAD,1,l.PUTFIELD,0,-1,l.LOAD,0,l.LOAD,2,l.PUTFIELD,1,-1),u?.kind==="ConstructorCall")u.target?(this.#f(u.start),this.#t(l.LOAD,0),this.#et(u.args,u.target.params,u.varargs),this.#t(l.INVOKE,u.target.index,-1)):u.libraryCall&&(this.#f(u.start),this.#t(l.LOAD,0),this.#et(u.args,u.libraryCall.params),this.#t(l.INVOKE_NATIVE,this.#H(u.libraryCall.native,u.args.length,!0,u.libraryCall.unwrap,u.libraryCall.unwrapCalls),-1,l.SET_BASE)),c=c.slice(1);else if(t.forwardsToSuper){if(t.superLibrary){this.#f(o.pos),this.#t(l.LOAD,0);let m=1+n;for(let p of t.params)this.#t(l.LOAD,m),m+=p.tag==="long"||p.tag==="double"?2:1;this.#t(l.INVOKE_NATIVE,this.#H(t.superLibrary.native,t.params.length,!0,t.superLibrary.unwrap,t.superLibrary.unwrapCalls),-1,l.SET_BASE)}else if(t.superConstructor){this.#f(o.pos),this.#t(l.LOAD,0),e.enumBody&&this.#t(l.LOAD,1,l.LOAD,2);let m=1+n;for(let p of t.params)this.#t(l.LOAD,m),m+=p.tag==="long"||p.tag==="double"?2:1;this.#t(l.INVOKE,t.superConstructor.index,-1)}}else t.superConstructor?(this.#f(o.pos),this.#t(l.LOAD,0),this.#et([],t.superConstructor.params,t.superVarargs),this.#t(l.INVOKE,t.superConstructor.index,-1)):t.superLibrary&&(this.#f(o.pos),this.#t(l.LOAD,0,l.INVOKE_NATIVE,this.#H(t.superLibrary.native,0,!0),-1,l.SET_BASE));this.#Ct(e,!1,m=>m.declarator.init!==void 0&&m.declarator.init!==null,r-1)}for(let m of c)this.#L(m);this.#f(o.end-1),t.declaration.compact&&t.declaration.params.forEach((m,p)=>this.#t(l.LOAD,0,l.LOAD,m.symbol.slot,l.PUTFIELD,e.components[p].index,-1)),this.#t(l.RETURN);let d=this.#A(e,{name:"<init>",display:`${e.binaryName}.<init>(${t.params.map(Nn).join(", ")})`,isStatic:!1,argCount:s,returnsValue:!1}),h=this.#Y(t);return h&&(d.argSlots=h),d}launcher(t){let e=t.main,n=t.mainClass;return this.#E(n,1,V),e.isStatic||this.#t(l.NEW,n.index,l.DUP,l.INVOKE,t.mainConstructor.index,-1),e.params.length&&this.#t(l.ICONST,0,l.NEWARRAY,Y.REF),this.#t(l.INVOKE,e.index,-1,l.RETURN),this.#bt=[],this.#A(n,{name:"<launch>",display:"<launch>",isStatic:!0,argCount:0,returnsValue:!1,hidden:!0})}practiceLauncher(t){let{method:e}=t,n=e.owner;return this.#E(n,1,V),e.isStatic||this.#t(l.NEW,n.index,l.DUP,l.INVOKE,t.constructor.index,-1),e.params.forEach((s,r)=>this.#t(l.HOST_ARG,r)),this.#t(l.INVOKE,e.index,-1),e.returnType.tag!=="void"&&this.#t(l.HOST_RESULT),this.#t(l.RETURN),this.#bt=[],this.#A(n,{name:"<practice>",display:"<practice>",isStatic:!0,argCount:0,returnsValue:!1,hidden:!0})}builtin(t){let e=t.owner,n=t.params.length+(t.isStatic?0:1);this.#E(e,Math.max(n,t.maxSlots,t.finallySlots??0),t.returnType),this.#f(e.declaration.keywordPos);let s=a=>this.#t(l.LOAD,0,l.GETFIELD,a.index,-1);switch(t.builtin){case"enum-values":this.#t(l.ICONST,e.enumConstants.length,l.NEWARRAY_REF,this.#g(`[L${e.binaryName};`)),e.enumConstants.forEach((a,o)=>this.#t(l.DUP,l.ICONST,o,l.GETSTATIC,a.index,l.ASTORE,Y.REF,-1)),this.#t(l.RETURN_VALUE);break;case"enum-valueOf":this.#t(l.LOAD,0,l.ENUM_VALUEOF,e.index,l.RETURN_VALUE);break;case"enum-name":case"enum-toString":this.#t(l.LOAD,0,l.GETFIELD,0,-1,l.RETURN_VALUE);break;case"enum-ordinal":this.#t(l.LOAD,0,l.GETFIELD,1,-1,l.RETURN_VALUE);break;case"library-toString":this.#t(l.LOAD,0,l.BASE,l.INVOKE_NATIVE,this.#H("toString()",1,!0),-1,l.RETURN_VALUE);break;case"library-hashCode":this.#t(l.LOAD,0,l.BASE,l.INVOKE_NATIVE,this.#H("hashCode()",1,!0),-1,l.RETURN_VALUE);break;case"library-equals":this.#t(l.LOAD,0,l.BASE,l.LOAD,1,l.INVOKE_NATIVE,this.#H("equals(Object)",2,!0,2,["size()","get(Object)","containsKey(Object)"]),-1,l.RETURN_VALUE);break;case"enum-compareTo":this.#t(l.LOAD,0,l.GETFIELD,1,-1,l.LOAD,1,l.GETFIELD,1,this.#ee(\'Cannot invoke "Object.getClass()" because "other" is null\'),l.ISUB,l.RETURN_VALUE);break;case"record-constructor":{let a=1;for(let o of e.components)this.#t(l.LOAD,0,l.LOAD,a,l.PUTFIELD,o.index,-1),a+=o.type.tag==="long"||o.type.tag==="double"?2:1;this.#t(l.RETURN);break}case"record-accessor":s(e.components[t.component]),this.#t(l.RETURN_VALUE);break;case"record-toString":this.#it(e);break;case"record-hashCode":this.#St(e);break;case"record-equals":this.#$(e);break;case"throwable-constructor":this.#o(t);break;case"throwable-getMessage":this.#t(l.LOAD,0,l.GETFIELD,yt.message,-1,l.RETURN_VALUE);break;case"throwable-getLocalizedMessage":this.#t(l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.getMessage.index,-1,l.RETURN_VALUE);break;case"throwable-getCause":this.#t(l.LOAD,0,l.GETFIELD,yt.cause,-1,l.RETURN_VALUE);break;case"throwable-initCause":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,Ut.INIT_CAUSE,l.RETURN_VALUE);break;case"throwable-toString":{let a=new et,o=this.#x();this.#t(l.LOAD,0,l.THROWABLE,Ut.CLASS_NAME,l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.getLocalizedMessage.index,-1,l.STORE,o),this.#t(l.LOAD,o,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,a),this.#t(l.SCONST,this.#g(": "),l.SCONCAT,l.LOAD,o,l.SCONCAT),this.#P(a),this.#t(l.RETURN_VALUE),this.#I();break}case"throwable-printStackTrace":this.#t(l.LOAD,0,l.THROWABLE,Ut.PRINT_TRACE,l.RETURN);break;case"throwable-addSuppressed":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,Ut.ADD_SUPPRESSED,l.RETURN);break;case"throwable-getSuppressed":this.#t(l.LOAD,0,l.THROWABLE,Ut.GET_SUPPRESSED,l.RETURN_VALUE);break;case"throwable-fillInStackTrace":this.#t(l.LOAD,0,l.THROWABLE,Ut.FILL_TRACE,l.RETURN_VALUE);break}let r=this.#A(e,{name:t.isConstructor?"<init>":t.name,display:t.isConstructor?`${e.binaryName}.<init>(${t.params.map(Nn).join(", ")})`:this.#D(t),isStatic:t.isStatic,argCount:n,returnsValue:t.returnType.tag!=="void"});if(t.selector!==void 0&&(r.selector=t.selector),(t.builtin==="enum-name"||t.builtin==="enum-ordinal"||t.builtin==="enum-compareTo"||t.builtin==="enum-toString"||t.builtin.startsWith("throwable-"))&&(r.hidden=!0),t.builtin==="record-constructor"&&e.components.some(a=>a.type.tag==="long"||a.type.tag==="double")){let a=[0],o=1;for(let c of e.components)a.push(o),o+=c.type.tag==="long"||c.type.tag==="double"?2:1;r.argSlots=Int32Array.from(a)}return r}#o(t){let e=(n,s)=>{this.#t(l.LOAD,0),s(),this.#t(l.PUTFIELD,n,-1)};switch(this.#t(l.LOAD,0,l.INVOKE_VIRTUAL,this.#i.fillInStackTrace.index,-1,l.POP),t.throwableConstructor){case"message":e(yt.message,()=>this.#t(l.LOAD,1));break;case"message-cause":e(yt.message,()=>this.#t(l.LOAD,1)),e(yt.cause,()=>this.#t(l.LOAD,2)),e(yt.causeSet,()=>this.#t(l.ICONST,1));break;case"cause":{let n=new et;this.#t(l.LOAD,1,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,n),e(yt.message,()=>this.#t(l.LOAD,1,l.INVOKE_VIRTUAL,this.#i.toString.index,-1)),this.#P(n),e(yt.cause,()=>this.#t(l.LOAD,1)),e(yt.causeSet,()=>this.#t(l.ICONST,1));break}case"index":e(yt.message,()=>this.#t(l.SCONST,this.#g(t.owner.builtin.indexPrefix),l.LOAD,1,l.TOSTRING_INT,l.SCONCAT));break;case"object":{e(yt.message,()=>this.#t(l.LOAD,1,l.VALUEOF,l.TOSTRING_REF));let n=new et;this.#t(l.LOAD,1,l.INSTANCEOF,this.#g("Ljava.lang.Throwable;")),this.#c(l.JUMP_IF_FALSE,n),e(yt.cause,()=>this.#t(l.LOAD,1)),e(yt.causeSet,()=>this.#t(l.ICONST,1)),this.#P(n);break}}this.#t(l.RETURN)}uncaughtPrinter(t){return this.#E(t,1,V),this.#t(l.LOAD,0,l.THROWABLE,Ut.PRINT_UNCAUGHT,l.RETURN),this.#A(t,{name:"<uncaught>",display:"<uncaught>",isStatic:!0,argCount:1,returnsValue:!1,hidden:!0})}#b(t){this.#t(l.LOAD,0,l.GETFIELD,t.index,-1);let e={int:l.TOSTRING_INT,byte:l.TOSTRING_INT,short:l.TOSTRING_INT,char:l.TOSTRING_CHAR,boolean:l.TOSTRING_BOOL,long:l.TOSTRING_LONG,float:l.TOSTRING_FLOAT,double:l.TOSTRING_DOUBLE}[t.type.tag];e!==void 0?this.#t(e):this.#t(l.VALUEOF,l.TOSTRING_REF)}#it(t){t.components.forEach((e,n)=>{this.#t(l.SCONST,this.#g(`${n===0?`${t.name}[`:", "}${e.name}=`)),n>0&&this.#t(l.SCONCAT),this.#b(e),this.#t(l.SCONCAT)}),this.#t(l.SCONST,this.#g(t.components.length?"]":`${t.name}[]`)),t.components.length&&this.#t(l.SCONCAT),this.#t(l.RETURN_VALUE)}#St(t){this.#t(l.ICONST,0);for(let e of t.components){this.#t(l.ICONST,31,l.IMUL,l.LOAD,0,l.GETFIELD,e.index,-1);let n=ae[e.type.tag];if(n!==void 0)this.#t(l.BOX,n,l.OBJ_HASHCODE,-1);else{let s=new et,r=new et;this.#t(l.DUP,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,s),this.#t(l.OBJ_HASHCODE,-1),this.#c(l.JUMP,r),this.#P(s),this.#t(l.POP,l.ICONST,0),this.#P(r)}this.#t(l.IADD)}this.#t(l.RETURN_VALUE)}#$(t){let e=new et,n=new et;this.#t(l.LOAD,0,l.LOAD,1,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,e),this.#t(l.LOAD,1,l.INSTANCEOF,this.#g(`L${t.binaryName};`)),this.#c(l.JUMP_IF_FALSE,n);for(let s of t.components){let r=a=>this.#t(l.LOAD,a,l.GETFIELD,s.index,-1);if(s.type.tag==="double"||s.type.tag==="float")r(0),this.#t(l.BOX,ae[s.type.tag]),r(1),this.#t(l.BOX,ae[s.type.tag],l.OBJ_EQUALS,-1),this.#c(l.JUMP_IF_FALSE,n);else if(ae[s.type.tag]!==void 0)r(0),r(1),this.#t(l.ICMPEQ),this.#c(l.JUMP_IF_FALSE,n);else{let a=new et;r(0),r(1),this.#t(l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,a),r(0),this.#t(l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,n),r(0),r(1),this.#t(l.OBJ_EQUALS,-1),this.#c(l.JUMP_IF_FALSE,n),this.#P(a)}}this.#P(e),this.#t(l.ICONST,1,l.RETURN_VALUE),this.#P(n),this.#t(l.ICONST,0,l.RETURN_VALUE)}abstractStub(t){let e=t.params.length+(t.isStatic?0:1);this.#E(t.owner,Math.max(1,e),t.returnType),t.returnType.tag==="void"?this.#t(l.RETURN):this.#t(l.ACONST_NULL,l.RETURN_VALUE);let n=this.#A(t.owner,{name:t.name,display:this.#D(t),isStatic:t.isStatic,argCount:e,returnsValue:t.returnType.tag!=="void"});return t.selector!==void 0&&(n.selector=t.selector),n}bridge(t,e){let n=[0],s=1;for(let a of e.params)n.push(s),s+=a.tag==="long"||a.tag==="double"?2:1;this.#E(t,s,e.returnType),this.#f(t.declaration.keywordPos),this.#t(l.LOAD,0),e.params.forEach((a,o)=>{this.#t(l.LOAD,n[o+1]);let c=W(e.target.params[o]);c.tag!=="object"&&Ft(c)!==Ft(a)&&ls(c)&&this.#t(l.CHECKCAST,this.#g(Ft(c)))}),this.#t(l.INVOKE_VIRTUAL,e.target.index,-1,e.returnType.tag==="void"?l.RETURN:l.RETURN_VALUE);let r=this.#A(t,{name:e.name,display:`${t.binaryName}.${e.name}(${e.params.map(Nn).join(", ")})`,isStatic:!1,argCount:e.params.length+1,returnsValue:e.returnType.tag!=="void"});return r.selector=e.selector,s!==e.params.length+1&&(r.argSlots=Int32Array.from(n)),r}method(t){let e=t.params.length+(t.isStatic?0:1);this.#E(t.owner,Math.max(e,t.maxSlots,t.finallySlots??0),t.returnType);let n=t.declaration.body;this.#ut=t.lambda?.reference===!0;for(let a of n.statements)this.#L(a);this.#ut=!1,t.returnType.tag==="void"&&(this.#f(n.end-1),this.#t(l.RETURN));let s=this.#A(t.owner,{name:t.name,display:this.#D(t),isStatic:t.isStatic,argCount:e,returnsValue:t.returnType.tag!=="void"});t.selector!==void 0&&(s.selector=t.selector),t.hidden&&(s.hidden=!0);let r=this.#Y(t);return r&&(s.argSlots=r),s}#t(...t){for(let e of t)this.#R.push(e)}#f(t){let{line:e}=ps(this.#Ot,t);e!==this.#m&&(this.#m=e,this.#bt.push(this.#R.length,e))}#c(t,e){this.#t(t,-1),e.uses.push(this.#R.length-1),e.pc>=0&&(this.#R[this.#R.length-1]=e.pc)}#y(t){t.pc=this.#R.length;for(let e of t.uses)this.#R[e]=t.pc;this.#m=-1}#P(t){t.pc=this.#R.length;for(let e of t.uses)this.#R[e]=t.pc}#g(t){let e=this.#z.get(t);return e===void 0&&(e=this.strings.length,this.strings.push(t),this.#z.set(t,e)),e}#J(t){if(typeof t=="number"&&t===(t|0)&&!Object.is(t,-0)){this.#t(l.ICONST,t);return}let e=typeof t=="bigint"?`L${t}`:Object.is(t,-0)?"-0":String(t),n=this.#It.get(e);n===void 0&&(n=this.numbers.length,this.numbers.push(t),this.#It.set(e,n)),this.#t(l.NCONST,n)}#ht(t){switch(t.kind){case"int":case"byte":case"short":case"char":this.#t(l.ICONST,t.value);return;case"long":this.#J(At(t.value));return;case"double":case"float":this.#J(t.value);return;case"boolean":this.#t(l.ICONST,t.value?1:0);return;case"string":this.#t(l.SCONST,this.#g(t.value));return}}#H(t,e,n,s,r){let a=`${t}/${n}`,o=this.#d.get(a);return o===void 0&&(o=this.natives.length,this.natives.push({name:t,argCount:e,returnsValue:n,...s?{unwrap:s,unwrapCalls:r??[]}:{}}),this.#d.set(a,o)),o}#Lt(t,e,n,s){let r=-1;e&&(this.#h(e,!0),r=this.#st(`Cannot invoke "${t.display}"`,e),t.onBase&&this.#t(l.BASE));let a=n.length;if(t.varargsFrom===void 0)this.#et(n,t.params);else{let c=t.varargsFrom;this.#et(n.slice(0,c),t.params);let u=t.params[c].element,d=n.slice(c);this.#t(l.ICONST,d.length),this.#re(u),d.forEach((h,m)=>{this.#t(l.DUP,l.ICONST,m),this.#h(h,!0),this.#ot(u,h),this.#t(l.ASTORE,Ge(u),-1)}),a=c+1}let o=a+(e?1:0);this.#t(l.INVOKE_NATIVE,this.#H(t.native,o,t.returnsValue,t.unwrap,t.unwrapCalls),r),!s&&t.returnsValue&&this.#t(l.POP)}#gt(t){let e=De(t);switch(e.kind){case"Name":return e.symbol?.kind==="field"?e.outerHops?`${this.#ye(e.outerHops)}.${e.symbol.name}`:this.#Tt(e.symbol):e.symbol?.kind!=="local"?null:this.#Q(e.symbol);case"FieldAccess":{let n=e.fieldSymbol;if(!n)return null;if(n.isStatic)return this.#Tt(n);if(De(e.target).kind==="This")return`this.${n.name}`;let s=this.#gt(e.target);return s===null?null:`${s}.${n.name}`}case"MethodCall":return e.method?this.#kt(e,e.method):e.objectMethod?`${e.qualifier??"Object"}.${Ka[e.objectMethod]}`:e.libraryCall?e.libraryCall.display:null;case"ArrayAccess":{let n=this.#gt(e.array);if(n===null)return null;let s=De(e.index),r=e.index.constant&&(e.index.constant.kind==="int"||e.index.constant.kind==="char")?String(e.index.constant.value):s.kind==="Name"?this.#gt(s)??"...":"...";return`${n}[${r}]`}case"Cast":return this.#gt(e.expression);default:return null}}#Tt(t){return t.isStatic?`${t.owner.binaryName}.${t.name}`:`this.${t.name}`}#ee(t){let e=this.#rt.get(t);return e===void 0&&(e=this.messages.length,this.messages.push(t),this.#rt.set(t,e)),e}#j(t,e){if(this.#ut)return-1;let n=t;if(typeof e=="string")n+=` because "${e}" is null`;else{let r=De(e);if(r.kind==="MethodCall"&&(r.method||r.objectMethod||r.libraryCall))n+=` because the return value of "${this.#gt(r)}" is null`;else{let a=this.#gt(e);a!==null&&(n+=` because "${a}" is null`)}}let s=this.#rt.get(n);return s===void 0&&(s=this.messages.length,this.messages.push(n),this.#rt.set(n,s)),s}#st(t,e){return De(e).kind==="This"?-1:this.#j(t,e)}#L(t){switch(t.kind){case"Block":for(let e of t.statements)this.#L(e);return;case"EmptyStatement":return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init&&(this.#f(e.pos),e.init.kind==="ArrayInitializer"?this.#w(e.init):(this.#h(e.init,!0),this.#ot(e.symbol.type,e.init)),this.#t(l.STORE,this.#u(e.symbol)));return;case"ExpressionStatement":this.#f(t.start),this.#h(t.expression,!1);return;case"IfStatement":{let e=t.condition.constant;if(e&&e.kind==="boolean"){e.value?this.#L(t.then):t.otherwise&&this.#L(t.otherwise);return}this.#f(t.start);let n=new et;if(this.#a(t.condition,n,!1),this.#L(t.then),t.otherwise){let s=new et;this.#c(l.JUMP,s),this.#y(n),this.#L(t.otherwise),this.#y(s)}else this.#y(n);return}case"WhileStatement":this.#M(t,t.start,t.condition,t.body,[]);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#L(t.init);else for(let e of t.init??[])this.#f(e.start),this.#h(e,!1);this.#M(t,t.start,t.condition,t.body,t.update);return;case"DoStatement":{let e=new et,n=new et,s=new et;this.#C.set(t,{breakLabel:s,continueLabel:n,tryDepth:this.#l.length}),this.#y(e),this.#L(t.body),this.#y(n),this.#f(t.condition.start),this.#a(t.condition,e,!0),this.#y(s);return}case"ForEachStatement":this.#Z(t);return;case"LabeledStatement":{let e=new et;this.#C.set(t,{breakLabel:e,tryDepth:this.#l.length}),this.#L(t.body),this.#y(e);return}case"SwitchStatement":this.#e(t,!1);return;case"YieldStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#h(t.value,!0),this.#ot(e.resultType,t.value),this.#c(l.JUMP,e.breakLabel);return}case"BreakStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#K(e.tryDepth??0,t.liveSlots,()=>this.#c(l.JUMP,e.breakLabel));return}case"ContinueStatement":{this.#f(t.start);let e=this.#C.get(t.target);this.#K(e.tryDepth??0,t.liveSlots,()=>this.#c(l.JUMP,e.continueLabel));return}case"ReturnStatement":if(this.#f(t.start),t.value){if(this.#h(t.value,!0),this.#ot(this.#W,t.value),!this.#l.length){this.#t(l.RETURN_VALUE);return}let e=this.#x();this.#t(l.STORE,e),this.#K(0,t.liveSlots,()=>this.#t(l.LOAD,e,l.RETURN_VALUE)),this.#I()}else this.#K(0,t.liveSlots,()=>this.#t(l.RETURN));return;case"ConstructorCall":throw new Error("codegen: this(...) outside a constructor prologue");case"ThrowStatement":this.#f(t.start),this.#h(t.expression,!0),this.#t(l.ATHROW,this.#j("Cannot throw exception",t.expression));return;case"AssertStatement":return;case"LocalClass":return;case"TryStatement":this.#ne(t);return}}#ne(t){let e=t.catches.map(o=>({types:(o.caught??[]).map(c=>Ft(c)),body:()=>{this.#t(l.STORE,this.#u(o.symbol)),this.#L(o.block)}})),n=t.finallyBlock,s=t.resources.length?()=>this.#B(t.resources,0,()=>this.#L(t.block)):()=>this.#L(t.block);if(!e.length&&!n){s();return}let r=t.finallySlots,a=n&&r?{run:(o,c)=>{let u=o??r.base,d=c&&!this.#p;d&&(this.#r=Math.max(this.#r,u+r.extent)),d||this.#p++,this.#X.push({from:r.base,by:u-r.base}),this.#L(n),this.#X.pop(),d||this.#p--},anyAt:()=>Math.max(r.before,this.#r)+1,blockCompletes:t.blockCompletes??!0,handlerCompletes:t.catches.map(o=>o.completes??!0)}:null;this.#Et(s,e,a)}#N(t){return{run:()=>t(),anyAt:()=>0,blockCompletes:!0,handlerCompletes:[]}}#Et(t,e,n){let s=new _s,r=n?new _s:null,a=new et,o={regions:r?[s,r]:[s],finallyBody:n};this.#l.push(o),s.open(this.#R.length),r?.open(this.#R.length),t(),s.close(this.#R.length),r?.close(this.#R.length),this.#l.pop(),n?.run(void 0,n.blockCompletes),this.#c(l.JUMP,a);let c=[];for(let[u,d]of e.entries()){let h=this.#R.length;this.#m=-1,this.#l.push({regions:r?[r]:[],finallyBody:n}),r?.open(this.#R.length),d.body(),r?.close(this.#R.length),this.#l.pop(),n?.run(void 0,n.handlerCompletes[u]??!0),this.#c(l.JUMP,a);for(let m of d.types){let p=m===null?-1:this.#g(m);for(let[k,g]of s.segments)c.push(k,g,h,p)}}if(r&&n){let u=this.#R.length;this.#m=-1;let d=this.#x();this.#t(l.STORE,d),n.run(n.anyAt(),!0),this.#t(l.LOAD,d,l.ATHROW,-1),this.#I();for(let[h,m]of r.segments)c.push(h,m,u,-1)}this.#S.push(...c),this.#y(a)}#B(t,e,n){if(e===t.length){n();return}let s=t[e];this.#f(s.start);let r=s.symbol?this.#u(s.symbol):this.#x();s.kind==="declaration"?(this.#h(s.init,!0),this.#ot(s.symbol.type,s.init)):this.#h(s.expression,!0),this.#t(l.STORE,r);let a=this.#x();this.#t(l.ACONST_NULL,l.STORE,a);let o=()=>this.#dt(s,r);this.#Et(()=>this.#B(t,e+1,n),[{types:[null],body:()=>this.#t(l.DUP,l.STORE,a,l.ATHROW,-1)}],this.#N(()=>{let c=new et,u=new et;this.#t(l.LOAD,r,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c),this.#t(l.LOAD,a,l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,u),this.#Et(o,[{types:[null],body:()=>{let d=this.#x();this.#t(l.STORE,d,l.LOAD,a,l.LOAD,d,l.THROWABLE,Ut.ADD_SUPPRESSED),this.#I()}}],null),this.#c(l.JUMP,c),this.#P(u),o(),this.#P(c)})),s.kind==="declaration"&&!this.#p&&(this.#r=Math.max(this.#r,r+3)),this.#I(),s.symbol||this.#I()}#dt(t,e){this.#t(l.LOAD,e),t.closeMethod?this.#t(l.INVOKE_VIRTUAL,t.closeMethod.index,-1):this.#t(l.INVOKE_NATIVE,this.#H("close()",1,!1),-1)}#K(t,e,n){let s=this.#l.slice(t);if(!s.length){n();return}let r=this.#l;for(let a=s.length-1;a>=0;a--){for(let o of s[a].regions)o.close(this.#R.length);this.#l=r.slice(0,t+a),s[a].finallyBody?.run(e,!0)}this.#l=r,n();for(let a of s)for(let o of a.regions)o.open(this.#R.length)}#M(t,e,n,s,r){let a=n?.constant;if(a&&a.kind==="boolean"&&!a.value)return;let o=new et,c=new et,u=new et;this.#C.set(t,{breakLabel:u,continueLabel:c,tryDepth:this.#l.length}),this.#y(o),this.#f(e),n&&!a&&this.#a(n,u,!1),this.#L(s),this.#y(c);for(let d of r)this.#f(d.start),this.#h(d,!1);this.#c(l.JUMP,o),this.#y(u)}#Z(t){if(t.iterator){this.#F(t);return}let{array:e,length:n,index:s}=t.hidden,r=e.type.element;this.#f(t.start),this.#h(t.iterable,!0),this.#t(l.STORE,this.#u(e),l.LOAD,this.#u(e)),this.#t(l.ARRAYLENGTH,this.#j("Cannot read the array length",this.#Q(e))),this.#t(l.STORE,this.#u(n),l.ICONST,0,l.STORE,this.#u(s));let a=new et,o=new et,c=new et;this.#C.set(t,{breakLabel:c,continueLabel:o,tryDepth:this.#l.length}),this.#y(a),this.#f(t.start),this.#t(l.LOAD,this.#u(s),l.LOAD,this.#u(n),l.ICMPLT),this.#c(l.JUMP_IF_FALSE,c),this.#t(l.LOAD,this.#u(e),l.LOAD,this.#u(s),l.ALOAD,Ge(r),-1),this.#Bt(r,t.symbol.type,{description:`${this.#Q(e)}[${this.#Q(s)}]`}),this.#t(l.STORE,this.#u(t.symbol)),this.#L(t.body),this.#y(o),this.#f(t.start),this.#t(l.IINC,this.#u(s),1),this.#c(l.JUMP,a),this.#y(c)}#F(t){let e=t.iterator,n=t.iterable.type,s=n.tag==="library"||n.tag==="diamond"?n.symbol.qualifiedName:"java.lang.Iterable";this.#f(t.start),this.#h(t.iterable,!0),this.#t(l.INVOKE_NATIVE,this.#H("Iterable.iterator",1,!0),this.#j(`Cannot invoke "${s}.iterator()"`,t.iterable)),this.#t(l.STORE,this.#u(e));let r=new et,a=new et;this.#C.set(t,{breakLabel:a,continueLabel:r,tryDepth:this.#l.length}),this.#y(r),this.#f(t.start),this.#t(l.LOAD,this.#u(e),l.INVOKE_NATIVE,this.#H("Iterator.hasNext",1,!0),-1),this.#c(l.JUMP_IF_FALSE,a),this.#t(l.LOAD,this.#u(e),l.INVOKE_NATIVE,this.#H("Iterator.next",1,!0),-1);let o=t.element??qa(n),c=t.symbol.type,u=Ae(c)?qt(c):W(c);u&&u.tag!=="object"&&(u.tag==="string"||u.tag==="class"||u.tag==="array"||u.tag==="library"&&u.symbol.box)&&this.#t(l.CHECKCAST,this.#g(Ft(u))),this.#Bt(o,t.symbol.type,{returnValue:"java.util.Iterator.next()"}),this.#t(l.STORE,this.#u(t.symbol)),this.#L(t.body),this.#c(l.JUMP,r),this.#y(a)}#e(t,e){if(t.patternSwitch)return this.#at(t,e);this.#f(t.start);let n=t.selector.type?.tag==="string",s=t.selector.type,r=s?.tag==="class"&&s.symbol.isEnum?s.symbol:null;this.#h(t.selector,!0);let a;if(r)this.#t(l.GETFIELD,1,this.#j(`Cannot invoke "${r.binaryName}.ordinal()"`,t.selector)),a=this.#x(),this.#t(l.STORE,a);else if(t.libraryEnum)this.#t(l.INVOKE_NATIVE,this.#H("ordinal()",1,!0),this.#j(`Cannot invoke "${t.libraryEnum}.ordinal()"`,t.selector)),a=this.#x(),this.#t(l.STORE,a);else if(n){let h=t.hidden.copy;a=this.#u(h),this.#t(l.STORE,a,l.LOAD,a),this.#t(l.CHECKNULL,this.#j(\'Cannot invoke "String.hashCode()"\',this.#Q(h)))}else a=this.#x(),this.#t(l.STORE,a);let o=new et,c=e?t.type:void 0;this.#C.set(t,{breakLabel:o,resultType:c,tryDepth:this.#l.length});let u=t.cases.map(()=>new et),d=o;t.cases.forEach((h,m)=>{if(h.isDefault&&(d=u[m]),r||t.libraryEnum){for(let p of h.ordinals??[])this.#t(l.LOAD,a,l.ICONST,p,l.ICMPEQ),this.#c(l.JUMP_IF_TRUE,u[m]);return}for(let p of h.labels)this.#t(l.LOAD,a),this.#ht(p.constant),this.#t(n?l.STR_EQUALS:l.ICMPEQ,...n?[-1]:[]),this.#c(l.JUMP_IF_TRUE,u[m])}),e&&d===o&&u.length&&(d=u[0]),this.#c(l.JUMP,d),t.cases.forEach((h,m)=>{this.#y(u[m]),this.#Jt(h,e,o,c)}),this.#P(o),this.#m=-1,n||this.#I()}#at(t,e){this.#f(t.start);let n=t.selector.type,s=n?.tag==="class"&&n.symbol.isEnum?n.symbol:null;this.#h(t.selector,!0);let r=this.#x();this.#t(l.STORE,r);let a=new et,o=e?t.type:void 0;this.#C.set(t,{breakLabel:a,resultType:o,tryDepth:this.#l.length});let c=t.cases.map(()=>new et),u=t.cases.findIndex(h=>h.nullLabel);this.#t(l.LOAD,r),u>=0?(this.#t(l.ACONST_NULL,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c[u])):this.#t(l.CHECKNULL,-1);let d=null;t.cases.forEach((h,m)=>{if(h.isDefault&&(d=c[m]),s)for(let p of h.ordinals??[])this.#t(l.LOAD,r,l.GETFIELD,1,-1,l.ICONST,p,l.ICMPEQ),this.#c(l.JUMP_IF_TRUE,c[m]);else{let p=n?St(n):null;for(let k of h.enumFields??[])this.#t(l.LOAD,r,l.GETSTATIC,k.index,l.ACMPEQ),this.#c(l.JUMP_IF_TRUE,c[m]);for(let k of h.enumFields?.length?[]:h.labels)this.#t(l.LOAD,r),p&&this.#t(l.UNBOX,ae[p.tag],-1),this.#ht(k.constant),p&&this.#xt(k.type,p),this.#t(p?l.ICMPEQ:l.STR_EQUALS,...p?[]:[-1]),this.#c(l.JUMP_IF_TRUE,c[m])}if(h.pattern){let p=new et,k=this.#At(h.pattern,r,p,!1);h.guard&&this.#a(h.guard,p,!1),this.#c(l.JUMP,c[m]),this.#P(p);for(let g=0;g<k;g++)this.#I()}}),this.#c(l.JUMP,d??(t.exhaustive&&c.length?c[0]:a)),t.cases.forEach((h,m)=>{this.#y(c[m]),this.#Jt(h,e,a,o)}),this.#P(a),this.#m=-1,this.#I()}#At(t,e,n,s){if(t.kind==="TypePattern")return!(s&&t.unconditional)&&!Ae(t.tested)&&(this.#t(l.LOAD,e,l.INSTANCEOF,this.#g(Ft(W(t.tested)))),this.#c(l.JUMP_IF_FALSE,n)),t.symbol&&this.#t(l.LOAD,e,l.STORE,this.#u(t.symbol)),0;this.#t(l.LOAD,e,l.INSTANCEOF,this.#g(Ft(W(t.tested)))),this.#c(l.JUMP_IF_FALSE,n);let r=0;return t.components.forEach((a,o)=>{let c=t.accessors[o],u=this.#x();r++,this.#t(l.LOAD,e,c.selector!==void 0?l.INVOKE_VIRTUAL:l.INVOKE,c.index,-1,l.STORE,u),r+=this.#At(a,u,n,!0)}),r}#Jt(t,e,n,s){if(!t.arrow){for(let a of t.statements)this.#L(a);return}let r=t.body;if(r.kind==="Block"){this.#L(r),e||this.#c(l.JUMP,n);return}this.#f(r.start),e?(this.#h(r,!0),this.#ot(s,r)):this.#h(r,!1),this.#c(l.JUMP,n)}#a(t,e,n){let s=t.constant;if(s&&s.kind==="boolean"){s.value===n&&this.#c(l.JUMP,e);return}if(t.kind==="Parenthesized")return this.#a(t.expression,e,n);if(t.kind==="Unary"&&t.operator==="!")return this.#a(t.operand,e,!n);if(t.kind==="Binary"&&(t.operator==="&&"||t.operator==="||")){if(t.operator==="&&"!==n)this.#a(t.left,e,n),this.#a(t.right,e,n);else{let a=new et;this.#a(t.left,a,!n),this.#a(t.right,e,n),this.#P(a)}return}if(t.kind==="InstanceOf"){this.#Re(t,e,n);return}this.#tt(t,gt),this.#c(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e)}#Re(t,e,n){if(t.recordPattern){let c=this.#x();this.#h(t.expression,!0),this.#t(l.STORE,c);let u=new et,d=this.#At(t.recordPattern,c,n?u:e,!1);n&&this.#c(l.JUMP,e),this.#P(u);for(let h=0;h<=d;h++)this.#I();return}let s=this.#g(Ft(this.#se(t))),r=t.binding?.symbol;if(!r){this.#h(t.expression,!0),this.#t(l.INSTANCEOF,s),this.#c(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e);return}let a=this.#x();this.#h(t.expression,!0),this.#t(l.STORE,a,l.LOAD,a,l.INSTANCEOF,s);let o=new et;this.#c(l.JUMP_IF_FALSE,n?o:e),this.#t(l.LOAD,a,l.STORE,this.#u(r)),n&&this.#c(l.JUMP,e),this.#P(o),this.#I()}#se(t){return t.binding?.symbol?.type??t.testedType}#xt(t,e){t&&(t.tag==="long"&&e.tag==="double"?this.#t(l.L2D):e.tag==="float"&&t.tag==="long"?this.#t(l.L2F):e.tag==="float"&&Dr(t)&&this.#t(l.I2F))}#Ut(t,e){if(!os(t)||!os(e))return;let n=Dr(t)?"int":t.tag;switch(e.tag){case"char":case"byte":case"short":case"int":n==="long"&&this.#t(l.L2I),(n==="double"||n==="float")&&this.#t(l.D2I),e.tag==="char"&&t.tag!=="char"&&this.#t(l.I2C),e.tag==="byte"&&t.tag!=="byte"&&this.#t(l.I2B),e.tag==="short"&&t.tag!=="byte"&&t.tag!=="short"&&this.#t(l.I2S);return;case"long":(n==="double"||n==="float")&&this.#t(l.D2L);return;case"float":n==="double"?this.#t(l.D2F):this.#xt(t,e);return;case"double":n==="long"&&this.#t(l.L2D);return}}#ot(t,e){this.#Bt(e.type,t,e,e.constant!==void 0)}#Bt(t,e,n,s=!1){let r=St(t);if(Ae(e)){if(r&&(this.#t(l.UNBOX,ae[r.tag],this.#Kt(r,n)),t=r),s){this.#xt(t,e);return}e.tag==="char"&&t.tag!=="char"?this.#t(l.I2C):this.#xt(t,e);return}if(Ae(t)){let a=St(e)?.tag??t.tag;!s&&a==="char"&&t.tag==="int"&&this.#t(l.I2C),t.tag==="long"&&a==="double"&&this.#t(l.L2D),this.#t(l.BOX,ae[a])}}#Kt(t,e){let n=`Cannot invoke "${Rl[t.tag]}"`;return"returnValue"in e?this.#ee(`${n} because the return value of "${e.returnValue}" is null`):"description"in e?this.#j(n,e.description):this.#j(n,e)}#et(t,e,n){if(!n){t.forEach((r,a)=>{this.#h(r,!0),this.#ot(e[a],r)});return}this.#et(t.slice(0,n.from),e);let s=t.slice(n.from);this.#t(l.ICONST,s.length),this.#re(n.element),s.forEach((r,a)=>{this.#t(l.DUP,l.ICONST,a),this.#h(r,!0),this.#ot(n.element,r),this.#t(l.ASTORE,Ge(n.element),-1)})}#tt(t,e){if(this.#h(t,!0),t.constant){this.#xt(t.type,e);return}let n=St(t.type);if(n){this.#t(l.UNBOX,ae[n.tag],this.#Kt(n,t)),this.#xt(n,e);return}this.#xt(t.type,e)}#Nt(t,e){let n=Jl[t];return e.tag==="double"?n.double:e.tag==="float"?n.float:e.tag==="long"?n.long:n.int}#h(t,e){if(e&&t.genericCast){let n=t.genericCast;t.genericCast=void 0,this.#h(t,!0),t.genericCast=n,this.#t(l.CHECKCAST,this.#g(Ft(n)));return}if(t.constant){e&&this.#ht(t.constant);return}switch(t.kind){case"Literal":if(t.literalKind!=="null")throw new Error(`codegen: unexpected literal ${t.literalKind}`);e&&this.#t(l.ACONST_NULL);return;case"Name":{if(t.imported){this.#h(t.imported,e);return}if(t.symbol?.kind==="field"){if(!e)return;let n=t.symbol;n.isStatic?this.#t(l.GETSTATIC,n.index):(this.#vt(t.outerHops),this.#t(l.GETFIELD,n.index,-1));return}if(t.symbol?.kind!=="local")throw new Error("codegen: unresolved name");e&&this.#t(l.LOAD,this.#u(t.symbol));return}case"This":e&&this.#vt(t.outerHops);return;case"Super":e&&this.#t(l.LOAD,0);return;case"ClassLiteral":e&&this.#t(l.SCONST,this.#g(t.className),l.ICONST,t.isInterface?1:0,l.INVOKE_NATIVE,this.#H("Class.literal",2,!0),-1);return;case"InstanceOf":{let n=new et,s=new et;this.#Re(t,n,!0),this.#t(l.ICONST,0),this.#c(l.JUMP,s),this.#P(n),this.#t(l.ICONST,1),this.#P(s),e||this.#t(l.POP);return}case"Parenthesized":this.#h(t.expression,e);return;case"Unary":{let n=t.type;this.#tt(t.operand,n),t.operator==="-"?this.#t(n.tag==="double"||n.tag==="float"?l.DNEG:n.tag==="long"?l.LNEG:l.INEG):t.operator==="~"?n.tag==="long"?this.#t(l.ICONST,-1,l.LXOR):this.#t(l.INOT):t.operator==="!"&&this.#t(l.BNOT),e||this.#t(l.POP);return}case"Cast":{let n=t.expression.type;if(t.checked&&Ae(t.type)){this.#h(t.expression,!0),this.#t(l.CHECKCAST,this.#g(Ft(t.checked)));let r=St(t.checked);this.#t(l.UNBOX,ae[r.tag],this.#Kt(r,t.expression)),this.#Ut(r,t.type),e||this.#t(l.POP);return}let s=Ae(t.type)?St(n):null;s?this.#tt(t.expression,s):this.#h(t.expression,!0),Ae(n)&&!Ae(t.type)?this.#Bt(n,t.type,t.expression,t.expression.constant!==void 0):this.#Ut(s??n,t.type),t.checked&&this.#t(l.CHECKCAST,this.#g(Ft(t.checked))),e||this.#t(l.POP);return}case"IncDec":this.#mt(t,e);return;case"Binary":this.#pe(t),e||this.#t(l.POP);return;case"Assignment":this.#jt(t,e);return;case"ArrayAccess":this.#h(t.array,!0),this.#tt(t.index,V),this.#ge(t.type,t.array),e||this.#t(l.POP);return;case"NewArray":this.#ie(t),e||this.#t(l.POP);return;case"FieldAccess":if(t.fieldSymbol){let n=t.fieldSymbol;n.isStatic?(Jr(t.target)||this.#h(t.target,!1),e&&this.#t(l.GETSTATIC,n.index)):(this.#h(t.target,!0),this.#t(l.GETFIELD,n.index,this.#st(`Cannot read field "${n.name}"`,t.target)),e||this.#t(l.POP));return}if(t.field==="System.in"){e&&this.#t(l.INVOKE_NATIVE,this.#H("System.in",0,!0),-1);return}if(t.field==="System.out"||t.field==="System.err"){e&&this.#t(l.INVOKE_NATIVE,this.#H(t.field,0,!0),-1);return}if(t.libraryField?.includes("#")){this.#h(t.target,!0),this.#t(l.INVOKE_NATIVE,this.#H(t.libraryField,1,!0),this.#st(`Cannot read field "${t.name}"`,t.target)),e||this.#t(l.POP);return}if(t.libraryField){e&&this.#t(l.INVOKE_NATIVE,this.#H(t.libraryField,0,!0),-1);return}if(t.field!=="length")throw new Error("codegen: field access used as a value");this.#h(t.target,!0),this.#t(l.ARRAYLENGTH,this.#j("Cannot read the array length",t.target)),e||this.#t(l.POP);return;case"MethodCall":this.#be(t,e);return;case"NewObject":{if(t.libraryCall){this.#Lt(t.libraryCall,null,t.args,e);return}let n=t.ctor;this.#t(l.NEW,n.owner.index,l.DUP);for(let s of n.owner.captures??[]){this.#t(l.DUP);let r=Dl(this.#O,n.owner);r>=0?(this.#vt(r),this.#t(l.GETFIELD,s.field.index,-1)):this.#t(l.LOAD,this.#u(s.local)),this.#t(l.PUTFIELD,s.field.index,-1)}t.outerExpression?(this.#h(t.outerExpression,!0),this.#t(l.DUP,l.CHECKNULL,-1)):t.outer!==void 0&&this.#vt(t.outer),this.#et(t.args,n.params,t.varargs),this.#t(l.INVOKE,n.index,-1),e||this.#t(l.POP);return}case"Conditional":{let n=t.condition.constant;if(n?.kind==="boolean"){let a=n.value?t.whenTrue:t.whenFalse;this.#h(a,e),e&&this.#ot(t.type,a);return}let s=new et,r=new et;this.#a(t.condition,s,!1),this.#h(t.whenTrue,!0),this.#ot(t.type,t.whenTrue),this.#c(l.JUMP,r),this.#P(s),this.#h(t.whenFalse,!0),this.#ot(t.type,t.whenFalse),this.#P(r),e||this.#t(l.POP);return}case"SwitchExpression":this.#e(t,!0),e||this.#t(l.POP);return;case"Lambda":this.#fe(t,null,e);return;case"MethodRef":this.#fe(t.lambda,t.receiver??null,e);return}}#fe(t,e,n){let s=t.method,r=0;s.usesThis&&(this.#t(l.LOAD,0),r++),e&&(this.#h(e,!0),this.#t(l.DUP,l.CHECKNULL,-1),r++);for(let o of t.captures??[])this.#t(l.LOAD,this.#u(o)),r++;let a=t.functional;this.#t(l.LAMBDA,s.index,r,this.#g(a.iface),a.sam?.selector??-1,a.samKey?this.#g(a.samKey):-1),n||this.#t(l.POP)}#pe(t){let e=t.operator;if(e==="&&"||e==="||"){let a=new et,o=new et;this.#a(t,a,!1),this.#t(l.ICONST,1),this.#c(l.JUMP,o),this.#P(a),this.#t(l.ICONST,0),this.#P(o);return}let n=t.left.type,s=t.right.type;if(t.type?.tag==="string"){this.#xe(t.left),this.#xe(t.right),this.#t(l.SCONCAT);return}if(e in Fs){let a=St(n)??n,o=St(s)??s,c=Ae(n)||Ae(s)||e!=="=="&&e!=="!=";if(c&&a.tag==="boolean"&&o.tag==="boolean"){this.#tt(t.left,gt),this.#tt(t.right,gt),this.#t(Fs[e]);return}if(c&&os(a)&&os(o)){let d=jr(a,o);this.#tt(t.left,d),this.#tt(t.right,d),this.#t(Fs[e]);return}this.#h(t.left,!0),this.#h(t.right,!0);let u=ls(n)||ls(s);this.#t(e==="=="?u?l.ACMPEQ:l.ICMPEQ:e==="!="?u?l.ACMPNE:l.ICMPNE:Fs[e]);return}let r=t.type;if(e==="<<"||e===">>"||e===">>>"){this.#tt(t.left,r),this.#h(t.right,!0),s.tag==="long"&&this.#t(l.L2I),this.#t(this.#Nt(e,r));return}this.#tt(t.left,r),this.#tt(t.right,r),this.#t(this.#Nt(e,r.tag==="boolean"?V:r))}#vt(t=0){this.#t(l.LOAD,0);let e=this.#O;for(let n=0;n<t&&e;n++,e=e.outer)this.#t(l.GETFIELD,e.outerField,-1)}#ye(t){let e=r=>{let a=0;for(let o=r.outer;o;o=o.outer)a++;return a},n="this",s=this.#O;for(let r=0;r<t&&s?.outer;r++,s=s.outer)n+=`.this$${e(s)-1}`;return n}#re(t){Ge(t)===Y.REF&&t.tag!=="string"?this.#t(l.NEWARRAY_REF,this.#g("["+Ft(t))):this.#t(l.NEWARRAY,Ge(t))}#ie(t){if(t.initializer){this.#w(t.initializer);return}let e=t.type;for(let n of t.dimensions)this.#tt(n,V);t.dimensions.length===1?this.#re(e.element):this.#t(l.NEWMULTI,this.#g(Ft(e)),t.dimensions.length)}#ge(t,e){let n=Ge(t);this.#t(l.ALOAD,n,this.#j(`Cannot load from ${Ga[n]} array`,e))}#qt(t,e){let n=Ge(t);this.#t(l.ASTORE,n,this.#j(`Cannot store to ${Ga[n]} array`,e))}#w(t){let e=t.elementType,n=Ge(e);this.#t(l.ICONST,t.elements.length),this.#re(e),t.elements.forEach((s,r)=>{this.#t(l.DUP,l.ICONST,r),s.kind==="ArrayInitializer"?this.#w(s):(this.#h(s,!0),this.#ot(e,s)),this.#t(l.ASTORE,n,-1)})}#be(t,e){if(t.print){let s=Ot.NONE;if(t.print.argument!=="none"){let r=t.args[0];this.#h(r,!0),t.print.argument==="object"?(this.#t(l.VALUEOF,l.TOSTRING_REF),s=Ot.STRING):s={int:Ot.INT,char:Ot.CHAR,boolean:Ot.BOOLEAN,long:Ot.LONG,float:Ot.FLOAT,double:Ot.DOUBLE,string:Ot.STRING,"char-array":Ot.CHAR_ARRAY}[t.print.argument]}this.#t(l.PRINT,t.print.stream==="err"?1:0,t.print.newline?1:0,s);return}if(t.libraryCall){let s=t.libraryCall.isStatic?null:t.target??{kind:"This",depth:1,pos:t.pos,start:t.pos,end:t.pos};this.#Lt(t.libraryCall,s,t.args,e);return}if(t.mathFunction){this.#et(t.args,t.mathFunction.params),this.#t(l.MATH,jl[t.mathFunction.fn]),e||this.#t(l.POP);return}let n=t.target?De(t.target):null;if(t.method){let s=t.method,r=-1;s.isStatic?n&&!Jr(n)&&this.#h(n,!1):n?(this.#h(n,!0),r=this.#st(`Cannot invoke "${this.#kt(t,s)}"`,n)):this.#vt(t.outerHops),this.#et(t.args,s.params,t.varargs);let a=s.selector!==void 0&&!t.isSuper;this.#t(a?l.INVOKE_VIRTUAL:l.INVOKE,s.index,r),!e&&s.returnType.tag!=="void"&&this.#t(l.POP);return}if(t.objectMethod){let s=-1;if(n?(this.#h(n,!0),s=this.#st(`Cannot invoke "${t.qualifier??"Object"}.${Ka[t.objectMethod]}"`,n)):this.#vt(),this.#et(t.args,t.args.map(()=>G)),t.isSuper)this.#t(l.OBJ_SUPER,{toString:0,hashCode:1,equals:2}[t.objectMethod]);else{let r={toString:l.OBJ_TOSTRING,hashCode:l.OBJ_HASHCODE,equals:l.OBJ_EQUALS}[t.objectMethod];this.#t(r,s)}e||this.#t(l.POP);return}if(t.stringMethod){this.#h(t.target,!0);for(let s of t.args)this.#h(s,!0);switch(t.stringMethod){case"length":this.#t(l.STR_LENGTH,this.#j(\'Cannot invoke "String.length()"\',t.target));break;case"charAt":this.#t(l.STR_CHARAT,this.#j(\'Cannot invoke "String.charAt(int)"\',t.target));break;case"equals":this.#t(l.STR_EQUALS,this.#j(\'Cannot invoke "String.equals(Object)"\',t.target));break;case"isEmpty":this.#t(l.STR_LENGTH,this.#j(\'Cannot invoke "String.isEmpty()"\',t.target),l.ICONST,0,l.ICMPEQ);break;case"toCharArray":this.#t(l.STR_TOCHARS,this.#j(\'Cannot invoke "String.toCharArray()"\',t.target));break;case"compareTo":this.#t(l.STR_COMPARETO,this.#j(\'Cannot invoke "String.compareTo(String)"\',t.target),this.#ee(\'Cannot read field "value" because "anotherString" is null\'));break}e||this.#t(l.POP);return}throw new Error(`codegen: unresolved call to ${t.name}`)}#Vt(t,e,n){let s=St(t);s&&this.#t(l.UNBOX,ae[s.tag],this.#Kt(s,n));let r=s??t;this.#t(l.ICONST,e,r.tag==="double"?l.DADD:r.tag==="float"?l.FADD:r.tag==="long"?l.LADD:l.IADD),r.tag==="char"&&this.#t(l.I2C),r.tag==="byte"&&this.#t(l.I2B),r.tag==="short"&&this.#t(l.I2S),s&&this.#t(l.BOX,ae[s.tag])}#mt(t,e){let n=De(t.operand),s=t.operator==="++"?1:-1,r=t.type;if(n.kind==="Name"&&n.symbol?.kind==="local"){let o=this.#u(n.symbol);if(r.tag==="int"){e&&!t.prefix&&this.#t(l.LOAD,o),this.#t(l.IINC,o,s),e&&t.prefix&&this.#t(l.LOAD,o);return}this.#t(l.LOAD,o),e&&!t.prefix&&this.#t(l.DUP),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.STORE,o);return}let a=this.#Se(n);if(a){if(a.isStatic)this.#ae(n),this.#t(l.GETSTATIC,a.index),e&&!t.prefix&&this.#t(l.DUP),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.PUTSTATIC,a.index);else{let o=this.#Te(n,a,"read");this.#t(l.DUP,l.GETFIELD,a.index,o),e&&!t.prefix&&this.#t(l.DUP_X1),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,-1)}return}if(n.kind!=="ArrayAccess")throw new Error("codegen: ++/-- target");this.#h(n.array,!0),this.#h(n.index,!0),this.#t(l.DUP2),this.#ge(r,n.array),e&&!t.prefix&&this.#t(l.DUP_X2),this.#Vt(r,s,n),e&&t.prefix&&this.#t(l.DUP_X2),this.#qt(r,n.array)}#jt(t,e){let n=De(t.target),s=t.target.type,r=()=>{if(t.operator==="="){this.#h(t.value,!0),this.#ot(s,t.value);return}if(s.tag==="string"){this.#t(l.TOSTRING_REF),this.#xe(t.value),this.#t(l.SCONCAT);return}let o=t.operator.slice(0,-1),c=t.value.type;if(o==="<<"||o===">>"||o===">>>"){let h=Dr(s)?V:s;this.#h(t.value,!0),c.tag==="long"&&this.#t(l.L2I),this.#t(this.#Nt(o,h)),this.#Ut(h,s);return}if(s.tag==="boolean"){this.#tt(t.value,gt),this.#t(this.#Nt(o,V));return}let u=St(s);if(u){this.#t(l.UNBOX,ae[u.tag],this.#Kt(u,n));let h=jr(u,St(c)??c);this.#xt(u,h),this.#tt(t.value,h),this.#t(this.#Nt(o,h)),this.#Ut(h,u),this.#t(l.BOX,ae[u.tag]);return}let d=jr(s,St(c)??c);this.#xt(s,d),this.#tt(t.value,d),this.#t(this.#Nt(o,d)),this.#Ut(d,s)};if(n.kind==="Name"&&n.symbol?.kind==="local"){t.operator!=="="&&this.#t(l.LOAD,this.#u(n.symbol)),r(),e&&this.#t(l.DUP),this.#t(l.STORE,this.#u(n.symbol));return}let a=this.#Se(n);if(a){if(a.isStatic)this.#ae(n),t.operator!=="="&&this.#t(l.GETSTATIC,a.index),r(),e&&this.#t(l.DUP),this.#t(l.PUTSTATIC,a.index);else if(t.operator==="="){let o=this.#Te(n,a,"assign");r(),e&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,o)}else{let o=this.#Te(n,a,"read");this.#t(l.DUP,l.GETFIELD,a.index,o),r(),e&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,-1)}return}if(n.kind!=="ArrayAccess")throw new Error("codegen: assignment target");this.#h(n.array,!0),this.#h(n.index,!0),t.operator!=="="&&(this.#t(l.DUP2),this.#ge(s,n.array)),r(),e&&this.#t(l.DUP_X2),this.#qt(s,n.array)}#Se(t){if(t.kind==="Name"&&t.symbol?.kind==="field")return t.symbol;if(t.kind==="FieldAccess")return t.fieldSymbol}#Te(t,e,n){if(t.kind==="FieldAccess"){this.#h(t.target,!0);let s=n==="read"?"Cannot read field":"Cannot assign field";return this.#st(`${s} "${e.name}"`,t.target)}return this.#vt(t.kind==="Name"?t.outerHops:0),-1}#ae(t){t.kind==="FieldAccess"&&!Jr(t.target)&&this.#h(t.target,!1)}#xe(t){if(t.constant){this.#t(l.SCONST,this.#g(zn(t.constant)));return}switch(this.#h(t,!0),t.type?.tag){case"int":case"byte":case"short":this.#t(l.TOSTRING_INT);return;case"float":this.#t(l.TOSTRING_FLOAT);return;case"char":this.#t(l.TOSTRING_CHAR);return;case"boolean":this.#t(l.TOSTRING_BOOL);return;case"long":this.#t(l.TOSTRING_LONG);return;case"double":this.#t(l.TOSTRING_DOUBLE);return;case"string":case"null":case"array":this.#t(l.TOSTRING_REF);return;case"class":case"object":case"library":case"diamond":case"typevar":this.#t(l.VALUEOF,l.TOSTRING_REF);return;default:throw new Error(`codegen: string conversion of ${t.type?.tag}`)}}},Ka={toString:"toString()",hashCode:"hashCode()",equals:"equals(Object)"};function Dl(i,t){let e=0;for(let n=i;n;n=n.outer,e++)if(n===t)return e;return-1}function ls(i){return i!==void 0&&["string","null","array","class","object","library","diamond","typevar"].includes(i.tag)}function qa(i){if(i.tag==="class"){let n=Tn(i.symbol).find(s=>s.symbol.name==="Iterable"||s.symbol.supertypes.some(r=>r.tag==="library"&&r.symbol.name==="Iterable"));return n?qa(n):{tag:"object"}}if(i.tag!=="library")return{tag:"object"};let t=i,e=new Set;for(;t&&t.tag==="library"&&t.symbol.name!=="Iterable"&&!e.has(t.symbol);){e.add(t.symbol);let n=t,s=n.symbol.supertypes[0];t=s?Wa(s,n):null}return t&&t.tag==="library"?t.args[0]??{tag:"object"}:{tag:"object"}}function Wa(i,t){if(i.tag==="typevar"){let e=t.symbol.typeParams.indexOf(i.name);return t.args[e]??{tag:"object"}}return i.tag==="library"?{tag:"library",symbol:i.symbol,args:i.args.map(e=>Wa(e,t))}:i}var lt=class{value;constructor(t){this.value=t}},zt=class{kind;data;hash;descriptor;constructor(t,e,n,s=Fl[t]){this.kind=t,this.data=e,this.hash=n,this.descriptor=s}},Bt=class{className;classIndex;fields;hash;base=null;constructor(t,e,n,s){this.className=t,this.classIndex=e,this.fields=n,this.hash=s}},Zt=class{kind;value;constructor(t,e){this.kind=t,this.value=e}},be=class{hash;constructor(t){this.hash=t}},Se=class extends be{className;method;captured;iface;samSelector;samKey;constructor(t,e,n,s=[],r="java.util.Comparator",a=-1,o="compare(T,T)"){super(n),this.className=t,this.method=e,this.captured=s,this.iface=r,this.samSelector=a,this.samKey=o}},Ke=class i{invoke;args;then;resumes;convert;constructor(t,e,n,s=null,r=null){this.invoke=t,this.args=e,this.then=n,this.resumes=s,this.convert=r}*[Symbol.iterator](){let t=this;for(;t instanceof i;)t=t.then(yield t);return t!==null&&typeof t=="object"&&Symbol.iterator in t?yield*t:t}},Fl=["[I","[Z","[C","[Ljava.lang.String;","[J","[D","[B","[S","[F"];function qe(i){return i instanceof zt?Br(i):`${i.className}@${i.hash.toString(16)}`}function Br(i){return`${i.descriptor}@${i.hash.toString(16)}`}var Us=class{#d=new Map;intern(t){let e=this.#d.get(t);return e||(e=new lt(t),this.#d.set(t,e)),e}},Bs=class{#d=625341585;next(){let t=this.#d;return t^=t<<13,t^=t>>>17,t^=t<<5,this.#d=t>>>0,this.#d&2147483647||1}};var Xa=i=>`${i.className}.${i.method}(${i.file}:${i.line})`;var zs=class{className;message;cause;constructor(t,e,n){this.className=t,this.message=e,this.cause=n}},cs=class{message;constructor(t){this.message=t}},an=class{result;constructor(t){this.result=t}},$n=class{thrown;constructor(t){this.thrown=t}},Gs=class{frames;constructor(t){this.frames=t}},Ks=class{message;constructor(t){this.message=t}};function Ul(i,t,e){switch(i){case 12:return Math.imul(t,e);case 13:return t/e|0;case 14:return t%e|0;case 19:return t&e;case 20:return t|e;case 21:return t^e;case 16:return t<<e;case 17:return t>>e;default:return t>>>e|0}}function Vs(i,t,e){switch(i){case 0:return t===e;case 1:return t!==e;case 2:return t<e;case 3:return t<=e;case 4:return t>e;case 5:return t>=e;case 6:return t!==e;case 7:return t===e;case 8:return!(t<e);case 9:return!(t<=e);case 10:return!(t>e);default:return!(t>=e)}}var Bl=Object.getPrototypeOf(Object.getPrototypeOf((function*(){})())),Vr=i=>typeof i=="object"&&i!==null&&Object.getPrototypeOf(Object.getPrototypeOf(i))===Bl;function Hr(i){switch(i.kind){case"double":return de(i.value);case"float":return Fe(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";default:return String(i.value)}}var Qa={className:"",classIndex:-1,isStatic:!0,name:"<native>",display:"<native>",file:"",argCount:0,returnsValue:!1,hidden:!0,code:new Int32Array(0),lines:new Int32Array(0),maxLocals:0,maxStack:0},Vl=0,Hl=1,rn=2,Za=3,Kr="\\0launcher",zl=Array.from({length:5},(i,t)=>`${Kr}${t}`),to=65536;function zr(i,t){switch(i){case Y.INT:return new Int32Array(t);case Y.BOOLEAN:return new Uint8Array(t);case Y.CHAR:return new Uint16Array(t);case Y.LONG:return new Array(t).fill(0);case Y.DOUBLE:return new Float64Array(t);case Y.BYTE:return new Int8Array(t);case Y.SHORT:return new Int16Array(t);case Y.FLOAT:return new Float32Array(t);default:return new Array(t).fill(null)}}var Hs=(i,t)=>`Index ${i} out of bounds for length ${t}`;function Gl(i){switch(i){case"I":return Y.INT;case"Z":return Y.BOOLEAN;case"C":return Y.CHAR;case"J":return Y.LONG;case"D":return Y.DOUBLE;case"B":return Y.BYTE;case"S":return Y.SHORT;case"F":return Y.FLOAT;default:return Y.REF}}function Kl(i){let t="";for(let e=0;e<i.length;e+=8192)t+=String.fromCharCode(...i.subarray(e,e+8192));return t}var eo=["java.lang.String","java.lang.Object","java.lang.Comparable","java.lang.CharSequence"],qr={int:"java.lang.Integer",long:"java.lang.Long",double:"java.lang.Double",char:"java.lang.Character",boolean:"java.lang.Boolean",float:"java.lang.Float",byte:"java.lang.Byte",short:"java.lang.Short"},ql=Object.fromEntries(Object.keys(qr).map(i=>[i,[qr[i],"java.lang.Object","java.lang.Comparable",...i==="char"||i==="boolean"?[]:["java.lang.Number"]]])),Wl=["java.lang.Object","java.lang.Cloneable","java.io.Serializable"],Xl="com.sun.tools.javac.launcher.MemoryClassLoader @6d06d69c";function Yl(i){let t=0;for(let e=0;e<i.length;e++)t=Math.imul(t,31)+i.charCodeAt(e)|0;return t}var Gr=new DataView(new ArrayBuffer(8));function Ql(i){switch(i.kind){case"int":case"char":case"byte":case"short":return i.value;case"float":return Ts(i.value);case"long":{let t=BigInt.asUintN(64,BigInt(i.value));return Number(BigInt.asIntN(32,t^t>>32n))}case"double":return Gr.setFloat64(0,Number.isNaN(i.value)?NaN:i.value),Gr.getInt32(0)^Gr.getInt32(4)|0;case"boolean":return i.value?1231:1237}}function no(i,t,e,n,s,r=""){let a=new Us,o=new Bs,c=i.strings.map(f=>a.intern(f)),u=i.numbers,d=bn(),h=i.natives.map(f=>{let S=d?.natives[f.name];if(!S)throw new Error(`interpreter: the library native ${f.name} is not loaded`);return S}),m=i.messages,p=i.methods,k=globalThis.performance,g=e.maxDurationMs>0?k.now()+e.maxDurationMs:1/0,O=(f,S=-1)=>({method:f,code:f.code,locals:new Array(f.maxLocals).fill(0),stack:new Array(f.maxStack+1).fill(0),sp:0,pc:0,returnPc:0,initClass:S}),T=i.staticFieldIsReference.map(f=>f?null:0),x=i.staticFieldOwner,v=i.classes,R=v.map(f=>f.instanceFieldIsReference.map(S=>S?null:0)),L=new Uint8Array(v.length),C=new Int32Array(v.length).fill(-1),M=(i.loadWarnings??[]).map((f,S)=>{for(let I of f.classes)C[I]=S;return!0}),_=new Map(v.map(f=>[f.name,f.types])),j=new Map(v.map((f,S)=>[f.name,S])),P=f=>f instanceof Bt?v[f.classIndex].types:f instanceof lt?eo:f instanceof Zt?ql[f.kind]:f instanceof zt?Wl:f instanceof Se?_.get(f.iface)??d?.typesOf(f.iface)??[f.iface,"java.lang.Object"]:f instanceof be?d?.typesOf(f.className)??["java.lang.Object"]:["java.lang.Object"],B=(f,S)=>{if(f===S)return!0;let I=f.slice(1),J=S.slice(1);if(J==="Ljava.lang.Object;")return I.startsWith("[")||I.startsWith("L");if(I.startsWith("[")&&J.startsWith("["))return B(I,J);if(I.startsWith("L")&&J.startsWith("L")){let U=I.slice(1,-1);return(_.get(U)??(U==="java.lang.String"?eo:[U,"java.lang.Object"])).includes(J.slice(1,-1))}return!1},N=(f,S)=>f instanceof lt?S==="[Ljava.lang.String;"||q(f,S.slice(1)):f instanceof Bt&&S.length===f.className.length+3&&S.slice(2,-1)===f.className?!0:q(f,S.slice(1)),F=new Map,q=(f,S)=>{if(f===null||typeof f!="object")return!1;if(S.charCodeAt(0)===91)return f instanceof zt&&B(f.descriptor,S);let I=F.get(S);return I===void 0&&F.set(S,I=S.slice(1,-1)),P(f).includes(I)},Z=f=>f instanceof Bt?f.className:f instanceof lt?"java.lang.String":f instanceof Zt?qr[f.kind]:f instanceof zt?f.descriptor:f.className,ne=f=>{let S=f.replace(/^\\[+/,"").replace(/^L(.*);$/,"$1");return _.has(S)&&!S.includes(".")?`unnamed module of loader ${Xl}`:"module java.base of loader \'bootstrap\'"},cn=(f,S)=>{let I=Z(f),J=ne(I),U=ne(S),H=J===U?`${I} and ${S} are in ${J}`:`${I} is in ${J}; ${S} is in ${U}`;return`class ${I} cannot be cast to class ${S} (${H})`},rt=O(p[i.entry]),it=[rt],D=rt.code,vt=rt.locals,b=rt.stack,y=0,E=0,$t=0,Xr=Math.min(to,e.maxInstructions+1),Ws=0,xe=0,Ie=(f,S)=>({outcome:{kind:"resource-limit",limit:f,message:S},instructions:Math.min($t,e.maxInstructions)}),Yr=f=>{rt.pc=E;let S=[],I=f!==void 0;for(let J=it.length-1;J>=0&&S.length<1024;J--){let U=it[J];U.method.hidden||I&&f(U)||(I=!1,S.push({className:U.method.className,method:U.method.name,file:U.method.file,line:Va(U.method,U.pc)}))}return S},Qr=new Map(v.map((f,S)=>[f.name,S])),ds=(f,S,I=null,J)=>{let U=Qr.get(f)??Qr.get("java.lang.RuntimeException"),H=R[U].slice();return H[yt.message]=S===null?null:new lt(S),H[yt.trace]=new Gs(J??Yr()),I&&(H[yt.cause]=I,H[yt.causeSet]=1),new Bt(f,U,H,o.next())},dt=(f,S,I=null)=>{throw new $n(ds(f,S,I))},Zr=[],ko=f=>{let S=Zr[f],I=S.fields[yt.message],J=I===null?S.className:`${S.className}: ${I.value}`,U=S.fields[yt.trace]?.frames??[],H=ds("java.lang.ExceptionInInitializerError",`Exception ${J} [in thread "main"]`,null,U);return dt("java.lang.NoClassDefFoundError",`Could not initialize class ${v[f].name}`,H)},Rn=null,Xs="",ti=()=>({outcome:{kind:"exception",className:Rn.className,text:Xs},instructions:$t,...Qs?{inputExhausted:Qs}:{}}),Co=f=>{let S=f;for(rt.pc=E;it.length;){let J=it[it.length-1],U=J.method.handlers;if(U)for(let H=0;H<U.length;H+=4){if(J.pc<U[H]||J.pc>=U[H+1])continue;let ut=U[H+3];if(!(ut>=0&&!q(S,i.strings[ut])))return rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,b[y++]=S,E=U[H+2],null}it.pop(),J.initClass>=0&&(L[J.initClass]=Za,Zr[J.initClass]=S,!q(S,"Ljava.lang.Error;")&&it.length&&(rt=it[it.length-1],E=rt.pc,S=ds("java.lang.ExceptionInInitializerError",null,S)))}if(Rn)return Xs+=`\nException: ${S.className} thrown from the UncaughtExceptionHandler in thread "main"\n`,ti();Rn=S;let I=O(p[i.uncaught]);return I.locals[0]=S,it.push(I),rt=I,D=I.code,vt=I.locals,b=I.stack,y=0,E=0,null},ei=new Map,ni=new Map,Ys=(f,S)=>{if(!(f==="boolean"||f==="byte"||(f==="int"||f==="long"||f==="short")&&S>=-128&&S<=127||f==="char"&&S<=127))return new Zt(f,S);let J=f+S,U=ni.get(J);return U||ni.set(J,U=new Zt(f,S)),U},Qs=!1,Zs={stdout:!1,stderr:!1},We={hash:()=>o.next(),intern:f=>a.intern(f),fail:(f,S,I)=>{throw new zs(f,S,I)},raise:f=>{throw new $n(f)},limitation:f=>{throw new Ks(f)},charge:f=>{$t+=f},allocate:f=>{if(xe+f>e.maxArrayElements)throw new cs(`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f},print:(f,S)=>{let I=ui(f==="out"?"stdout":"stderr",S);if(I)throw new an(I)},closeStream:f=>{Zs[f==="out"?"stdout":"stderr"]=!0},streamClosed:f=>Zs[f==="out"?"stdout":"stderr"],exit:f=>{throw new an({outcome:{kind:"exit",status:f},instructions:$t})},seed:()=>BigInt(Math.floor(Math.random()*2**32))*2n**16n+BigInt(Math.floor(Math.random()*2**16)),stdin:()=>r,inputExhausted:()=>{Qs=!0},checkString:f=>{if(f>e.maxStringLength)throw new cs(`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`)},methodOf:(f,S,I)=>v[f.classIndex].virtuals[`${S}/${I}`]??-1,overrideOf:(f,S)=>v[f.classIndex].libraryOverrides?.[S]??-1,castMessage:cn,storable:(f,S)=>N(f,S),className:f=>Z(f),toStringMethod:f=>v[f.classIndex].toString,equalsMethod:f=>v[f.classIndex].equals,hashCodeMethod:f=>v[f.classIndex].hashCode,box:Ys,staticMethod:(f,S,I)=>p.findIndex(J=>J.isStatic&&J.className===f&&J.name===S&&J.argCount===I)},ms=f=>f instanceof zs?dt(f.className,f.message,f.cause?ds(f.cause.className,f.cause.message,null):null):f instanceof Ks?{outcome:{kind:"engine-limitation",message:f.message},instructions:$t}:f instanceof cs?Ie("memory",f.message):f instanceof an?f.result:null,tr=(f,S)=>{let I=p[f];if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);let J=li(I,-1),U=I.argSlots;for(let H=0;H<S.length;H++)J.locals[U?U[H]:H]=S[H];return it.push(J),rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,E=0,I.isStatic&&L[I.classIndex]!==rn&&hn(I.classIndex),null},er=[],si=f=>{let S=rt,I;try{let U=S.then;if(U){if(I=U(f),I instanceof Ke)return I.resumes?(S.then=null,S.native=I.resumes,S.convert=I.convert):S.then=I.then,tr(I.invoke,I.args);Vr(I)&&(S.then=null,S.native=I,f=void 0)}if(!S.then){let H=S.native.next(f);if(!H.done)return tr(H.value.invoke,H.value.args);let ut=S.convert;I=ut?ut(H.value):H.value}}catch(U){let H=ms(U);if(H)return H;throw U}it.pop();let J=S.nativeReturns;return S.native=null,S.then=null,S.convert=null,er.length<32&&er.push(S),rt=it[it.length-1],D=rt.code,vt=rt.locals,b=rt.stack,y=rt.sp,E=rt.returnPc,J&&(b[y++]=I??null),null},ri=(f,S)=>{if(rt.pc=E,rt.returnPc=S,rt.sp=y,it.length>e.maxCallDepth)return null;let I=er.pop()??O(Qa);return I.nativeReturns=f,it.push(I),rt=I,I},un=(f,S,I)=>{let J=ri(S,I);return J?(J.native=f,si(void 0)):dt("java.lang.StackOverflowError",null)},ii=(f,S,I)=>{let J=ri(S,I);return J?(f.resumes?(J.native=f.resumes,J.convert=f.convert):J.then=f.then,tr(f.invoke,f.args)):dt("java.lang.StackOverflowError",null)};function*ai(f){let S=yield*d.toString(We,f);return new lt(S)}let oi=(f,S,I)=>{y-=S.length;let J;try{J=d.natives[f](We,S)}catch(U){let H=ms(U);if(H)return H;throw U}return J instanceof Ke?ii(J,!0,I):Vr(J)?un(J,!0,I):(b[y++]=J??null,E=I,null)};for(let f of p)f.freeFrames=[];let li=(f,S)=>{let I=f.freeFrames.pop();if(!I)return O(f,S);let J=I.locals;for(let U=0;U<J.length;U++)J[U]=0;return I.sp=0,I.pc=0,I.returnPc=0,I.initClass=S,I},Eo=f=>{let S=f.method.freeFrames;S&&S.length<32&&S.push(f)},Xe=(f,S,I=-1)=>{rt.pc=E,rt.returnPc=S,y-=f.argCount,rt.sp=y;let J=li(f,I),U=f.argSlots;if(U)for(let H=0;H<f.argCount;H++)J.locals[U[H]]=b[y+H];else for(let H=0;H<f.argCount;H++)J.locals[H]=b[y+H];it.push(J),rt=J,D=J.code,vt=J.locals,b=J.stack,y=0,E=0},hn=f=>{if(L[f]!==Vl)return L[f]===Za&&ko(f),!1;for(let J of v[f].types){let U=j.get(J),H=U===void 0?-1:C[U];if(!(H<0||!M[H])&&(M[H]=!1,t("stderr",i.loadWarnings[H].text),i.loadWarnings[H].fails))throw new an({outcome:{kind:"compile-error"},instructions:$t})}let S=v[f].superclass;if(S>=0&&hn(S))return!0;let I=v[f].clinit;return I<0?(L[f]=rn,!1):(L[f]=Hl,Xe(p[I],E,f),!0)},Lt=f=>dt("java.lang.NullPointerException",f>=0?m[f]:null),ci=(f,S,I)=>{let J=S[I],U=f.slice(1);if(I===S.length-1){let ut=Gl(U);return new zt(ut,zr(ut,J),o.next(),f)}let H=new Array(J);for(let ut=0;ut<J;ut++)H[ut]=ci(U,S,I+1);return new zt(Y.REF,H,o.next(),f)},ui=(f,S)=>{if(Zs[f])return null;if(Rn&&f==="stderr")return Xs+=S,null;if(Ws+S.length>e.maxOutputChars){let I=e.maxOutputChars-Ws;return I>0&&t(f,S.slice(0,I)),Ie("output",`the program printed more than ${e.maxOutputChars.toLocaleString("en-US")} characters`)}return Ws+=S.length,$t+=S.length>>>6,S&&t(f,S),null},hi=[];if(s){let f={string:S=>new lt(S),box:Ys,array:(S,I,J)=>new zt(S,I,o.next(),J),object:S=>{let I=i.classes[S];return new Bt(I.name,S,I.instanceFieldIsReference.map(J=>J?null:0),o.next())},list:S=>{if(!d)throw new Error("interpreter: practice lists need the Java library");return d.newList(We,S)},allocate:S=>We.allocate(S)};try{hi=s.args(f)}catch(S){let I=ms(S);if(I)return I;throw S}}for(;;)try{for(;;){if(++$t>=Xr){if($t>e.maxInstructions)return Ie("instructions",`the program ran more than ${e.maxInstructions.toLocaleString("en-US")} steps`);if(g!==1/0&&k.now()>g)return Ie("time",`the program ran longer than ${e.maxDurationMs} ms`);Xr=Math.min($t+to,e.maxInstructions+1),n?.()}switch(D[E]){case 1:b[y++]=D[E+1],E+=2;break;case 2:b[y++]=c[D[E+1]],E+=2;break;case 3:b[y++]=null,E+=1;break;case 4:b[y++]=vt[D[E+1]],E+=2;break;case 5:vt[D[E+1]]=b[--y],E+=2;break;case 6:y--,E+=1;break;case 7:b[y]=b[y-1],y++,E+=1;break;case 8:{let f=b[y-1];b[y-1]=b[y-2],b[y-2]=f,b[y++]=f,E+=1;break}case 9:{let f=b[y-1];b[y-1]=b[y-2],b[y-2]=b[y-3],b[y-3]=f,b[y++]=f,E+=1;break}case 24:b[y]=b[y-2],b[y+1]=b[y-1],y+=2,E+=1;break;case 10:{let f=b[--y];b[y-1]=b[y-1]+f|0,E+=1;break}case 11:{let f=b[--y];b[y-1]=b[y-1]-f|0,E+=1;break}case 12:{let f=b[--y];b[y-1]=Math.imul(b[y-1],f),E+=1;break}case 13:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=b[y-1]/f|0,E+=1;break}case 14:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=b[y-1]%f|0,E+=1;break}case 15:b[y-1]=-b[y-1]|0,E+=1;break;case 16:{let f=b[--y];b[y-1]=b[y-1]<<f,E+=1;break}case 17:{let f=b[--y];b[y-1]=b[y-1]>>f,E+=1;break}case 18:{let f=b[--y];b[y-1]=b[y-1]>>>f|0,E+=1;break}case 19:{let f=b[--y];b[y-1]=b[y-1]&f,E+=1;break}case 20:{let f=b[--y];b[y-1]=b[y-1]|f,E+=1;break}case 21:{let f=b[--y];b[y-1]=b[y-1]^f,E+=1;break}case 22:b[y-1]=~b[y-1],E+=1;break;case 23:b[y-1]=b[y-1]^1,E+=1;break;case 25:b[y-1]=b[y-1]&65535,E+=1;break;case 163:b[y-1]=b[y-1]<<24>>24,E+=1;break;case 164:b[y-1]=b[y-1]<<16>>16,E+=1;break;case 165:case 167:b[y-1]=Math.fround(b[y-1]),E+=1;break;case 166:b[y-1]=yn(b[y-1]),E+=1;break;case 168:{let f=b[--y];b[y-1]=Math.fround(b[y-1]+f),E+=1;break}case 169:{let f=b[--y];b[y-1]=Math.fround(b[y-1]-f),E+=1;break}case 170:{let f=b[--y];b[y-1]=Math.fround(b[y-1]*f),E+=1;break}case 171:{let f=b[--y];b[y-1]=Math.fround(b[y-1]/f),E+=1;break}case 172:{let f=b[--y];b[y-1]=Math.fround(b[y-1]%f),E+=1;break}case 173:b[y-1]=new lt(Fe(b[y-1])),E+=1;break;case 30:case 36:{let f=b[--y];b[y-1]=b[y-1]===f?1:0,E+=1;break}case 31:case 37:{let f=b[--y];b[y-1]=b[y-1]!==f?1:0,E+=1;break}case 32:{let f=b[--y];b[y-1]=b[y-1]<f?1:0,E+=1;break}case 33:{let f=b[--y];b[y-1]=b[y-1]<=f?1:0,E+=1;break}case 34:{let f=b[--y];b[y-1]=b[y-1]>f?1:0,E+=1;break}case 35:{let f=b[--y];b[y-1]=b[y-1]>=f?1:0,E+=1;break}case 40:E=D[E+1];break;case 41:E=b[--y]===0?D[E+1]:E+2;break;case 180:{let f=b[--y],S=b[--y];E=Vs(D[E+1],S,f)?D[E+2]:E+3;break}case 181:E=Vs(D[E+1],b[--y],D[E+2])?D[E+3]:E+4;break;case 182:E=Vs(D[E+1],vt[D[E+2]],vt[D[E+3]])?D[E+4]:E+5;break;case 183:E=Vs(D[E+1],vt[D[E+2]],D[E+3])?D[E+4]:E+5;break;case 184:E=vt[D[E+2]]===null==(D[E+1]===1)?D[E+3]:E+4;break;case 185:b[y++]=vt[D[E+1]],b[y++]=vt[D[E+2]],E+=3;break;case 186:b[y++]=vt[D[E+1]],b[y++]=D[E+2],E+=3;break;case 187:b[y-1]=b[y-1]+D[E+1]|0,E+=2;break;case 191:{let f=b[--y],S=b[--y];S.base=f,f.owner=S,E+=1;break}case 192:{let f=b[y-1];f instanceof Bt&&f.base!==null&&(b[y-1]=f.base),E+=1;break}case 190:b[y-1]=Ul(D[E+1],b[y-1],D[E+2]),E+=3;break;case 188:{let f=D[E+1];vt[f]=vt[f]+D[E+2]|0,E=D[E+3];break}case 189:{let f=vt[D[E+1]],S=vt[D[E+2]];if(f===null)return Lt(D[E+4]);if(S<0||S>=f.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(S,f.data.length));b[y++]=f.data[S],E+=5;break}case 42:E=b[--y]!==0?D[E+1]:E+2;break;case 43:{let f=D[E+1];vt[f]=vt[f]+D[E+2]|0,E+=3;break}case 50:b[y-1]=new lt(String(b[y-1])),E+=1;break;case 54:b[y-1]=new lt(String.fromCharCode(b[y-1])),E+=1;break;case 143:b[y-1]=new lt(String(b[y-1])),E+=1;break;case 144:b[y-1]=new lt(de(b[y-1])),E+=1;break;case 120:b[y++]=u[D[E+1]],E+=2;break;case 121:{let f=b[--y];b[y-1]=vi(b[y-1],f),E+=1;break}case 122:{let f=b[--y];b[y-1]=wi(b[y-1],f),E+=1;break}case 123:{let f=b[--y];b[y-1]=ki(b[y-1],f),E+=1;break}case 124:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=Ci(b[y-1],f),E+=1;break}case 125:{let f=b[--y];if(f===0)return dt("java.lang.ArithmeticException","/ by zero");b[y-1]=Ei(b[y-1],f),E+=1;break}case 126:b[y-1]=cr(b[y-1]),E+=1;break;case 127:{let f=b[--y];b[y-1]=Ai(b[y-1],f),E+=1;break}case 128:{let f=b[--y];b[y-1]=Ii(b[y-1],f),E+=1;break}case 129:{let f=b[--y];b[y-1]=Oi(b[y-1],f),E+=1;break}case 130:{let f=b[--y];b[y-1]=Li(b[y-1],f),E+=1;break}case 131:{let f=b[--y];b[y-1]=Ni(b[y-1],f),E+=1;break}case 132:{let f=b[--y];b[y-1]=$i(b[y-1],f),E+=1;break}case 133:{let f=b[--y];b[y-1]=b[y-1]+f,E+=1;break}case 134:{let f=b[--y];b[y-1]=b[y-1]-f,E+=1;break}case 135:{let f=b[--y];b[y-1]=b[y-1]*f,E+=1;break}case 136:{let f=b[--y];b[y-1]=b[y-1]/f,E+=1;break}case 137:{let f=b[--y];b[y-1]=b[y-1]%f,E+=1;break}case 138:b[y-1]=-b[y-1],E+=1;break;case 139:b[y-1]=bs(b[y-1]),E+=1;break;case 140:b[y-1]=Ss(b[y-1]),E+=1;break;case 141:b[y-1]=Fn(b[y-1]),E+=1;break;case 142:b[y-1]=Dn(b[y-1]),E+=1;break;case 146:if(b[--y]===null)return Lt(D[E+1]);E+=2;break;case 147:{switch(D[E+1]){case ht.ABS_I:b[y-1]=Math.abs(b[y-1])|0;break;case ht.ABS_L:{let S=b[y-1];b[y-1]=S<0?cr(S):S;break}case ht.ABS_D:b[y-1]=Math.abs(b[y-1]);break;case ht.MAX_I:case ht.MAX_D:{let S=b[--y];b[y-1]=Math.max(b[y-1],S);break}case ht.MIN_I:case ht.MIN_D:{let S=b[--y];b[y-1]=Math.min(b[y-1],S);break}case ht.MAX_L:{let S=b[--y],I=b[y-1];b[y-1]=I>=S?I:S;break}case ht.MIN_L:{let S=b[--y],I=b[y-1];b[y-1]=I<=S?I:S;break}case ht.SQRT:b[y-1]=Math.sqrt(b[y-1]);break;case ht.FLOOR:b[y-1]=Math.floor(b[y-1]);break;case ht.CEIL:b[y-1]=Math.ceil(b[y-1]);break;case ht.ROUND:b[y-1]=Mi(b[y-1]);break;case ht.ROUND_F:b[y-1]=Pi(b[y-1]);break}E+=2;break}case 145:{let f=i.strings[D[E+1]],S=D[E+2],I=b.slice(y-S,y);y-=S;for(let H of I)if(H<0)return dt("java.lang.NegativeArraySizeException",String(H));let J=0,U=1;for(let H of I)U*=H,J+=U;if(xe+J>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=J,$t+=J>>>4,b[y++]=ci(f,I,0),E+=3;break}case 51:b[y-1]=new lt(b[y-1]?"true":"false"),E+=1;break;case 52:{let f=b[y-1];f===null?b[y-1]=new lt("null"):f instanceof Zt?b[y-1]=new lt(Hr(f)):f instanceof lt||(b[y-1]=new lt(qe(f))),E+=1;break}case 53:{let f=b[--y],S=b[y-1],I=S.value.length+f.value.length;if(I>e.maxStringLength)return Ie("memory",`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`);$t+=I>>>6,b[y-1]=new lt(S.value+f.value),E+=1;break}case 60:{let f=D[E+3],S="";if(f!==Ot.NONE){let J=b[--y];switch(f){case Ot.INT:S=String(J);break;case Ot.CHAR:S=String.fromCharCode(J);break;case Ot.BOOLEAN:S=J?"true":"false";break;case Ot.STRING:S=J===null?"null":J.value;break;case Ot.LONG:S=String(J);break;case Ot.DOUBLE:S=de(J);break;case Ot.FLOAT:S=Fe(J);break;case Ot.CHAR_ARRAY:if(J===null)return dt("java.lang.NullPointerException",\'Cannot read the array length because "cbuf" is null\');S=Kl(J.data);break;default:S=J===null?"null":J instanceof lt?J.value:qe(J)}}D[E+2]===1&&(S+=`\n`);let I=ui(D[E+1]===1?"stderr":"stdout",S);if(I)return I;E+=4;break}case 72:{let f=p[D[E+1]];if(f.isStatic&&L[f.classIndex]!==rn&&hn(f.classIndex))break;let S=D[E+2];if(S>=0&&b[y-f.argCount]===null)return Lt(S);if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(f,E+3);break}case 70:case 71:{let f=D[E]===l.RETURN_VALUE?b[--y]:void 0,S=it.pop();if(S.initClass>=0&&(L[S.initClass]=rn),Eo(S),!it.length)return Rn?ti():{outcome:{kind:"completed"},instructions:$t};if(rt=it[it.length-1],rt.method===Qa){let I=si(f);if(I)return I;break}D=rt.code,vt=rt.locals,b=rt.stack,y=rt.sp,E=rt.returnPc,f!==void 0&&(b[y++]=f);break}case 80:{let f=b[y-1];if(f<0)return dt("java.lang.NegativeArraySizeException",String(f));if(xe+f>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f,$t+=f>>>4,b[y-1]=new zt(D[E+1],zr(D[E+1],f),o.next()),E+=2;break}case 84:{let f=b[y-1];if(f<0)return dt("java.lang.NegativeArraySizeException",String(f));if(xe+f>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=f,$t+=f>>>4,b[y-1]=new zt(Y.REF,zr(Y.REF,f),o.next(),i.strings[D[E+1]]),E+=2;break}case 81:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+2]);if(f<0||f>=S.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(f,S.data.length));b[y-1]=S.data[f],E+=3;break}case 82:{let f=b[--y],S=b[--y],I=b[--y];if(I===null)return Lt(D[E+2]);if(S<0||S>=I.data.length)return dt("java.lang.ArrayIndexOutOfBoundsException",Hs(S,I.data.length));if(f!==null&&D[E+1]===Y.REF&&I.descriptor!=="[Ljava.lang.Object;"&&!N(f,I.descriptor))return dt("java.lang.ArrayStoreException",Z(f));I.data[S]=f,E+=3;break}case 83:{let f=b[y-1];if(f===null)return Lt(D[E+1]);b[y-1]=f.data.length,E+=2;break}case 90:{let f=b[y-1];if(f===null)return Lt(D[E+1]);b[y-1]=f.value.length,E+=2;break}case 91:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);if(f<0||f>=S.value.length)return dt("java.lang.StringIndexOutOfBoundsException",Hs(f,S.value.length));b[y-1]=S.value.charCodeAt(f),E+=2;break}case 92:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);b[y-1]=f instanceof lt&&f.value===S.value?1:0,E+=2;break}case 153:{let f=b[--y],S=b[y-1];if(S===null)return Lt(D[E+1]);if(f===null)return Lt(D[E+2]);let I=S.value,J=f.value,U=Math.min(I.length,J.length),H=I.length-J.length;for(let ut=0;ut<U;ut++){let ve=I.charCodeAt(ut)-J.charCodeAt(ut);if(ve!==0){H=ve;break}}$t+=U>>>4,b[y-1]=H,E+=3;break}case 100:{let f=D[E+1],S=x[f];if(L[S]!==rn&&hn(S))break;b[y++]=T[f],E+=2;break}case 101:{let f=D[E+1],S=x[f];if(L[S]!==rn&&hn(S))break;T[f]=b[--y],E+=2;break}case 102:{let f=b[y-1];if(f===null)return Lt(D[E+2]);b[y-1]=f.fields[D[E+1]],E+=3;break}case 103:{let f=b[--y],S=b[--y];if(S===null)return Lt(D[E+2]);S.fields[D[E+1]]=f,E+=3;break}case 104:{let f=D[E+1];if(L[f]!==rn&&hn(f))break;b[y++]=new Bt(v[f].name,f,R[f].slice(),o.next()),E+=2;break}case 110:{let f=b[y-1];if(f instanceof Bt){let S=v[f.classIndex].toString;if(S>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[S],E+1);break}b[y-1]=new lt(qe(f))}else if(f===null)b[y-1]=new lt("null");else if(f instanceof zt)b[y-1]=new lt(Br(f));else if(f instanceof Zt)b[y-1]=new lt(Hr(f));else if(f instanceof be){y--;let S=un(ai(f),!0,E+1);if(S)return S;break}E+=1;break}case 148:{let f=D[E+1],S=i.natives[f],I=D[E+2];if(I>=0&&b[y-S.argCount]===null)return Lt(I);let J=b.slice(y-S.argCount,y);if(y-=S.argCount,S.unwrap)for(let H=0;H<J.length;H++){let ut=J[H];if(!(S.unwrap>>H&1)||!(ut instanceof Bt)||ut.base===null)continue;if(ut.base.opaque)return{outcome:{kind:"engine-limitation",message:`passing a ${ut.className}, an AbstractList subclass, to ${S.name.slice(0,S.name.indexOf("("))}()`},instructions:$t};let ve=S.unwrapCalls,Ye=Object.keys(v[ut.classIndex].libraryOverrides??{}).find(Jn=>!Ua.has(Jn)&&(ve.includes("*")||ve.includes(Jn)));if(Ye!==void 0)return{outcome:{kind:"engine-limitation",message:`passing a ${ut.className}, which overrides ${Ye.slice(0,Ye.indexOf("("))}(), to ${S.name.slice(0,S.name.indexOf("("))}(), which would call it`},instructions:$t};J[H]=ut.base}let U;try{U=h[f](We,J)}catch(H){let ut=ms(H);if(ut)return ut;throw H}if(U instanceof Ke){let H=ii(U,S.returnsValue,E+3);if(H)return H;break}if(Vr(U)){let H=un(U,S.returnsValue,E+3);if(H)return H;break}S.returnsValue&&(b[y++]=U??null),E+=3;break}case 149:b[y-1]=Ys(Pr[D[E+1]],b[y-1]),E+=2;break;case 150:{let f=b[y-1];if(f===null)return Lt(D[E+2]);b[y-1]=f.value,E+=3;break}case 154:b[y++]=hi[D[E+1]],E+=2;break;case 155:s.result(b[--y]),E+=1;break;case 152:{let f=D[E+1],S=D[E+2],I=c[D[E+3]].value,J=D[E+5]>=0?c[D[E+5]].value:null;if(S===0){let U=ei.get(f);U||ei.set(f,U=new Se(`${p[f].className}$$Lambda`,f,o.next(),[],I,D[E+4],J)),b[y++]=U}else{let U=b.slice(y-S,y);y-=S,b[y++]=new Se(`${p[f].className}$$Lambda`,f,o.next(),U,I,D[E+4],J)}E+=6;break}case 151:{let f=b[y-1];if(f===null)return Lt(D[E+1]);let S=new Uint16Array(f.value.length);for(let I=0;I<S.length;I++)S[I]=f.value.charCodeAt(I);if(xe+S.length>e.maxArrayElements)return Ie("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);xe+=S.length,$t+=S.length>>>4,b[y-1]=new zt(Y.CHAR,S,o.next()),E+=2;break}case 111:{let f=b[y-1];if(f===null)return Lt(D[E+1]);if(f instanceof Bt&&v[f.classIndex].toString>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[f.classIndex].toString],E+2);break}if(f instanceof be){y--;let S=un(ai(f),!0,E+2);if(S)return S;break}f instanceof Zt?b[y-1]=new lt(Hr(f)):f instanceof lt||(b[y-1]=new lt(qe(f))),E+=2;break}case 112:{let f=b[y-1];if(f===null)return Lt(D[E+1]);if(f instanceof Bt&&v[f.classIndex].hashCode>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[f.classIndex].hashCode],E+2);break}if(f instanceof be&&!(f instanceof Se)&&d?.natives["hashCode()"]){let S=oi("hashCode()",[f],E+2);if(S)return S;break}b[y-1]=f instanceof lt?Yl(f.value):f instanceof Zt?Ql(f):f.hash,E+=2;break}case 113:{let f=b[y-1],S=b[y-2];if(S===null)return Lt(D[E+1]);if(S instanceof Bt&&v[S.classIndex].equals>=0){if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(p[v[S.classIndex].equals],E+2);break}if(S instanceof be&&!(S instanceof Se)&&d?.natives["equals(Object)"]){let I=oi("equals(Object)",[S,f],E+2);if(I)return I;break}y--,S instanceof lt?b[y-1]=f instanceof lt&&f.value===S.value?1:0:S instanceof Zt?b[y-1]=f instanceof Zt&&f.kind===S.kind&&Object.is(f.value,S.value)?1:0:b[y-1]=S===f?1:0,E+=2;break}case 159:{let f=D[E+1];if(f===2){let S=b[--y];b[y-1]=b[y-1]===S?1:0}else{let S=b[y-1];b[y-1]=f===0?new lt(qe(S)):S.hash}E+=2;break}case 156:{let f=p[D[E+1]],S=D[E+2],I=b[y-f.argCount];if(I===null)return Lt(S);let J=f;if(I instanceof Bt){let U=v[I.classIndex].vtable[f.selector];U>=0&&(J=p[U])}else if(I instanceof Se&&I.samSelector===f.selector){let U=y-f.argCount,H=b.slice(U+1,y);y=U;for(let ut of I.captured)b[y++]=ut;for(let ut of H)b[y++]=ut;J=p[I.method]}if(it.length>e.maxCallDepth)return dt("java.lang.StackOverflowError",null);Xe(J,E+3);break}case 157:{let f=b[y-1],S=i.strings[D[E+1]];if(f!==null&&!q(f,S)){let I=S.startsWith("[")?S:S.slice(1,-1);return dt("java.lang.ClassCastException",cn(f,I))}E+=2;break}case 160:{let f=v[D[E+1]],S=b[y-1];if(S===null)return dt("java.lang.NullPointerException","Name is null");let I=f.enumConstants.find(J=>T[J].fields[0].value===S.value);if(I===void 0)return dt("java.lang.IllegalArgumentException",`No enum constant ${f.canonicalName}.${S.value}`);b[y-1]=T[I],E+=2;break}case 158:b[y-1]=q(b[y-1],i.strings[D[E+1]])?1:0,E+=2;break;case 161:{let f=b[--y];if(f===null)return Lt(D[E+1]);throw new $n(f)}case 162:{let f=D[E+1];if(f===Ut.PRINT_TRACE||f===Ut.PRINT_UNCAUGHT){let S=b[--y],I=un(Io(S,f===Ut.PRINT_UNCAUGHT),!1,E+2);if(I)return I;break}if(f===Ut.FILL_TRACE){let S=b[y-1],I=v[S.classIndex].types,J=U=>(U.method.name==="<init>"||U.method.name==="fillInStackTrace")&&I.includes(U.method.className);S.fields[yt.trace]=new Gs(Yr(J))}else if(f===Ut.ADD_SUPPRESSED){let S=b[--y],I=b[--y];if(S===I)return dt("java.lang.IllegalArgumentException","Self-suppression not permitted",S);if(S===null)return dt("java.lang.NullPointerException","Cannot suppress a null exception.");let J=I.fields[yt.suppressed];J?J.push(S):I.fields[yt.suppressed]=[S]}else if(f===Ut.GET_SUPPRESSED){let S=b[y-1],I=nr(S);We.allocate(I.length),b[y-1]=new zt(Y.REF,I.slice(),o.next(),"[Ljava.lang.Throwable;")}else if(f===Ut.CLASS_NAME)b[y-1]=new lt(b[y-1].className);else if(f===Ut.INIT_CAUSE){let S=b[y-1],I=b[y-2];if(I.fields[yt.causeSet]){y-=2;let J=un(Ao(I,S),!1,E+2);if(J)return J;break}if(S===I)return dt("java.lang.IllegalArgumentException","Self-causation not permitted",I);I.fields[yt.cause]=S,I.fields[yt.causeSet]=1,y--}E+=2;break}default:throw new Error(`interpreter: unknown opcode ${D[E]} at ${E}`)}}}catch(f){if(f instanceof an)return f.result;if(!(f instanceof $n))throw f;let S=Co(f.thrown);if(S)return S}function nr(f){return f.fields[yt.suppressed]??[]}function*fs(f){let S=yield{invoke:v[f.classIndex].toString,args:[f]};return S==null?"null":S.value}function*Ao(f,S){let I=S===null?"a null":yield*fs(S);return dt("java.lang.IllegalStateException",`Can\'t overwrite cause with ${I}`,f)}function*Io(f,S){let I=Nt=>We.print("err",Nt),J=new Set([f]),U=Nt=>(Nt.fields[yt.trace]?.frames??[]).map(Xa),H=Nt=>[...U(Nt),...zl].slice(0,1024);function*ut(Nt){return yield{invoke:v[Nt.classIndex].virtuals["getCause/0"],args:[Nt]}}function*ve(Nt,di,mi,dn){if(J.has(Nt)){I(`${dn}${mi}[CIRCULAR REFERENCE: ${yield*fs(Nt)}]\n`);return}J.add(Nt);let Qe=H(Nt),jn=Qe.length-1;for(let we=di.length-1;jn>=0&&we>=0&&Qe[jn]===di[we];we--)jn--;let fi=Qe.length-1-jn;I(`${dn}${mi}${yield*fs(Nt)}\n`);for(let we=0;we<=jn;we++)Qe[we].startsWith(Kr)||I(`${dn} at ${Qe[we]}\n`);fi&&I(`${dn} ... ${fi} more\n`);for(let we of nr(Nt))yield*ve(we,Qe,"Suppressed: ",dn+" ");let pi=yield*ut(Nt);pi&&(yield*ve(pi,Qe,"Caused by: ",dn))}S&&I(\'Exception in thread "main" \'),I(`${yield*fs(f)}\n`);let Ye=S?U(f):H(f);for(let Nt of Ye)Nt.startsWith(Kr)||I(` at ${Nt}\n`);for(let Nt of nr(f))yield*ve(Nt,Ye,"Suppressed: "," ");let Jn=yield*ut(f);Jn&&(yield*ve(Jn,Ye,"Caused by: ",""))}}var Gt=class extends Error{},Te=class extends Error{},ln=class extends Error{},so=i=>i.replace(/\\s+/g,"");function io(i,t){let e=t.className?i.classes.filter(h=>h.name===t.className||h.displayName===t.className):i.classes;if(t.className&&!e.length)throw new Gt(`no class ${t.className} in the program`);let n=e.flatMap(h=>h.methods.filter(m=>m.name===t.method&&!m.lambda));if(t.params){let h=t.params.map(so);n=n.filter(m=>m.params.length===h.length&&m.params.every((p,k)=>so($(p))===h[k]))}let s=`${t.method}(${(t.params??[]).join(", ")})`;if(!n.length)throw new Gt(`no method ${t.params?s:t.method+"(...)"}${t.className?` in class ${t.className}`:""}`);if(n.length>1)throw new Gt(`${n.length} methods named ${t.method}: list its parameter types in practice.params to choose one`);let r=n[0],a=null;if(!r.isStatic){if(r.owner.isInner)throw new Gt(`${r.name} is an instance method of an inner class; make the class static or the method static`);if(a=r.owner.constructors.find(h=>h.params.length===0)??null,!a)throw new Gt(`${r.owner.displayName} needs a constructor with no parameters, to call its instance method ${r.name}`)}let o=r.params.map((h,m)=>hs(h,t,`parameter ${m+1} of ${r.name}`)),c=t.compare??{kind:"return"},u=null,d=null;if(c.kind==="argument"){if(!Number.isInteger(c.index)||c.index<0||c.index>=o.length)throw new Gt(`compare.index ${c.index} is not a parameter of ${r.name}`);d=c.index}else{if(r.returnType.tag==="void")throw new Gt(`${r.name} returns nothing: compare one of its arguments instead ({ kind: \'argument\', index })`);u=hs(r.returnType,t,`the result of ${r.name}`)}return{target:{method:r,constructor:a},params:o,result:u,compareIndex:d,tolerance:c.tolerance??0,signature:`${r.owner.displayName}.${r.name}(${r.params.map($).join(", ")})`}}function ao(i){switch(i.tag){case"int":return"I";case"long":return"J";case"double":return"D";case"char":return"C";case"boolean":return"Z";case"string":return"Ljava.lang.String;";case"class":return`L${i.symbol.binaryName};`;case"library":return`L${i.symbol.qualifiedName};`;case"array":return`[${ao(i.element)}`;default:return"Ljava.lang.Object;"}}var Zl={int:Y.INT,boolean:Y.BOOLEAN,char:Y.CHAR,long:Y.LONG,double:Y.DOUBLE};function hs(i,t,e){switch(i.tag){case"int":case"long":case"double":case"char":case"boolean":return{kind:i.tag};case"string":return{kind:"string"};case"array":return{kind:"array",element:hs(i.element,t,e),arrayKind:Zl[i.element.tag]??Y.REF,descriptor:ao(i),type:$(i)};case"library":let n=i.symbol.box;if(n&&n!=="float"&&n!=="byte"&&n!=="short")return{kind:"box",box:n};if(["List","ArrayList","Collection"].includes(i.symbol.name)&&i.args[0])return{kind:"list",element:hs(i.args[0],t,e)};break;case"class":return tc(i.symbol,t,e)}throw new Gt(`${e} has type ${$(i)}, which practice cases cannot pass or compare yet`)}function tc(i,t,e){let n=i.fields.filter(k=>!k.isStatic),s=k=>{let g=n.find(O=>O.name===k);if(!g)throw new Gt(`practice.nodes.${i.name}: ${i.name} has no field ${k}`);return g},r=n.filter(k=>k.type.tag==="class"&&k.type.symbol===i),a=n.filter(k=>!r.includes(k)),o=t.nodes?.[i.name],c=o?.kind??(r.length===1&&a.length===1?"list":r.length===2&&a.length===1?"tree":null);if(!c)throw new Gt(`${e} has type ${i.displayName}, which is not a list or tree node; describe it in practice.nodes`);let u=o?.value?s(o.value):a[0];if(!u)throw new Gt(`practice.nodes.${i.name} needs its value field`);let d=hs(u.type,t,`${i.name}.${u.name}`);if(c==="list"){let k=o?.next?s(o.next):r[0];if(!k)throw new Gt(`practice.nodes.${i.name} needs its next field`);return{kind:"linked-list",cls:i,value:u,valueCodec:d,next:k}}let h=k=>r.find(g=>g.name===k),m=o?.left?s(o.left):h("left")??r[0],p=o?.right?s(o.right):h("right")??r.find(k=>k!==m);if(!m||!p)throw new Gt(`practice.nodes.${i.name} needs its left and right fields`);return{kind:"tree",cls:i,value:u,valueCodec:d,left:m,right:p}}var ec=-2147483648,nc=2147483647,sc=-(1n<<63n),rc=(1n<<63n)-1n;function Pn(i){return JSON.stringify(i)??"undefined"}function ro(i,t,e){let n=s=>{throw new Te(`${e}: expected ${s}, got ${Pn(i)}`)};switch(t){case"int":return(typeof i!="number"||!Number.isInteger(i)||i<ec||i>nc)&&n("an int"),i;case"long":{let s;if(typeof i=="string"&&/^-?\\d+$/.test(i))s=BigInt(i);else if(typeof i=="number"&&Number.isSafeInteger(i))s=BigInt(i);else return n("a long, as a decimal string");return(s<sc||s>rc)&&n("a long in range"),At(s)}case"double":return typeof i=="number"?i:i==="NaN"?NaN:i==="Infinity"?1/0:i==="-Infinity"?-1/0:n(\'a double (a number, or "NaN", "Infinity", "-Infinity")\');case"char":return(typeof i!="string"||i.length!==1)&&n("a char, as a one-character string"),i.charCodeAt(0);case"boolean":return typeof i!="boolean"&&n("a boolean"),i?1:0}}function us(i,t,e,n){switch(t.kind){case"int":case"long":case"double":case"char":case"boolean":return ro(i,t.kind,n);case"string":if(i===null)return null;if(typeof i!="string")throw new Te(`${n}: expected a String, got ${Pn(i)}`);return e.string(i);case"box":return i===null?null:e.box(t.box,ro(i,t.box,n));case"array":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected ${t.type}, an array, got ${Pn(i)}`);e.allocate(i.length);let s=i.map((a,o)=>us(a,t.element,e,`${n}[${o}]`)),r;switch(t.arrayKind){case Y.INT:r=Int32Array.from(s);break;case Y.BOOLEAN:r=Uint8Array.from(s);break;case Y.CHAR:r=Uint16Array.from(s);break;case Y.DOUBLE:r=Float64Array.from(s);break;default:r=s}return e.array(t.arrayKind,r,t.descriptor)}case"list":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a List, an array, got ${Pn(i)}`);return e.list(i.map((s,r)=>us(s,t.element,e,`${n}[${r}]`)))}case"linked-list":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a ${t.cls.name} list, an array of values, got ${Pn(i)}`);e.allocate(i.length);let s=null;for(let r=i.length-1;r>=0;r--){let a=e.object(t.cls.index);a.fields[t.value.index]=us(i[r],t.valueCodec,e,`${n}[${r}]`),a.fields[t.next.index]=s,s=a}return s}case"tree":{if(i===null)return null;if(!Array.isArray(i))throw new Te(`${n}: expected a ${t.cls.name} tree, a level-order array, got ${Pn(i)}`);if(!i.length||i[0]===null)return null;e.allocate(i.length);let s=c=>{let u=e.object(t.cls.index);return u.fields[t.value.index]=us(i[c],t.valueCodec,e,`${n}[${c}]`),u},r=s(0),a=[r],o=1;for(let c=0;c<a.length&&o<i.length;c++){let u=a[c];for(let d of[t.left,t.right]){if(o>=i.length)break;if(i[o]!==null){let h=s(o);u.fields[d.index]=h,a.push(h)}o++}}return r}}}var oo=1e5;function on(i,t,e){let n=s=>{if(e.nodes-=s,e.nodes<0)throw new ln(`the result has more than ${oo.toLocaleString("en-US")} elements, or is cyclic`)};switch(t.kind){case"int":return i;case"long":return String(i);case"double":return ic(i);case"char":return String.fromCharCode(i);case"boolean":return i===1;case"string":return i===null?null:i.value;case"box":return i===null?null:on(i.value,{kind:t.box},e);case"array":{if(i===null)return null;let s=i.data;return n(s.length),Array.from(s,r=>on(r,t.element,e))}case"list":{if(i===null)return null;let s=bn()?.listItems(i);if(!s)throw new ln("the result is not an ArrayList");return n(s.length),s.map(r=>on(r,t.element,e))}case"linked-list":{let s=[],r=new Set;for(let a=i;a;a=a.fields[t.next.index]){if(r.has(a))throw new ln(`the ${t.cls.name} list has a cycle`);r.add(a),n(1),s.push(on(a.fields[t.value.index],t.valueCodec,e))}return s}case"tree":{if(i===null)return[];let s=[],r=[i];for(let a=0;a<r.length;a++){let o=r[a];if(n(1),!o){s.push(null);continue}s.push(on(o.fields[t.value.index],t.valueCodec,e)),r.push(o.fields[t.left.index],o.fields[t.right.index])}for(;s.length&&s[s.length-1]===null;)s.pop();return s}}}function ic(i){return Number.isNaN(i)?"NaN":i===1/0?"Infinity":i===-1/0?"-Infinity":i}function qs(i,t,e=0){if(typeof i=="number"&&typeof t=="number")return i===t||Math.abs(i-t)<=e;if(Array.isArray(i)&&Array.isArray(t))return i.length===t.length&&i.every((n,s)=>qs(n,t[s],e));if(i&&t&&typeof i=="object"&&typeof t=="object"&&!Array.isArray(i)&&!Array.isArray(t)){let n=Object.keys(i);return n.length===Object.keys(t).length&&n.every(s=>qs(i[s],t[s],e))}return i===t}function lo(i,t){if(t.length!==i.params.length)throw new Te(`${i.signature} takes ${i.params.length} argument${i.params.length===1?"":"s"}, the case has ${t.length}`);let e=[],n=null;return{host:{args:a=>e=t.map((o,c)=>us(o,i.params[c],a,`argument ${c+1}`)),result:a=>{n=a}},actual:()=>{let a={nodes:oo};return i.compareIndex!==null?on(e[i.compareIndex],i.params[i.compareIndex],a):on(n,i.result,a)}}}function ac(i,t){let e=`${i}(${t.args.map(a=>JSON.stringify(a)).join(", ")})`,n=a=>JSON.stringify(a),s=[];switch(t.status){case"passed":s.push(`\\u2713 ${t.id} ${e} \\u2192 ${n(t.actual)}`);break;case"failed":s.push(`\\u2717 ${t.id} ${e} \\u2192 ${n(t.actual)}, expected ${n(t.expected)}`);break;case"completed":s.push(`\\u2022 ${t.id} ${e} \\u2192 ${n(t.actual)}`);break;case"invalid-case":s.push(`? ${t.id} invalid case: ${t.error}`);break;case"not-run":s.push(`- ${t.id} not run (${t.reason})`);break;default:s.push(`\\u2717 ${t.id} ${e}: ${t.status.replace("-"," ")}`),t.error&&s.push(...t.error.trimEnd().split(`\n`).map(a=>` ${a}`))}let r=t.stdout+t.stderr;return r&&s.push(...r.trimEnd().split(`\n`).map(a=>` | ${a}`)),s}function co(i,t){let e=t.flatMap(r=>ac(i,r)),n=t.filter(r=>r.expected!==void 0).length,s=t.filter(r=>r.status==="passed").length;return e.push(n?`${s} of ${n} passed`:`${t.length} case${t.length===1?"":"s"} run`),e.join(`\n`)+`\n`}var Wr={maxFiles:32,maxSourceChars:5e5,maxTotalSourceChars:1e6,maxNestingDepth:200,maxExpressionDepth:1e3,maxInstructions:2e8,maxOutputChars:1e6,maxStringLength:1e7,maxArrayElements:16e6,maxCallDepth:5e4,maxDurationMs:0},Mn=()=>globalThis.performance.now();function oc(i,t){let e=Object.keys(i);return t||("Main.java"in i?"Main.java":e.find(n=>n.endsWith(".java"))??e[0]??"Main.java")}function ho(i,t={}){return mo(i,t).result}function mo(i,t,e=!0){let n=Mn(),s={...Wr,...t.limits},r=oc(i,t.entry),a=i[r]??"",o=sr(r,a),c=new mn,u=new Map([[r,o]]),d=null,h=v=>({result:{program:v,diagnostics:c.items,entry:r,diagnosticText:c.items.length?rr(c.items,u):"",compileMs:Mn()-n},checked:d,source:o});if(Object.keys(i).length>s.maxFiles)return c.launchError(r,w.limit,`too many files for this engine (limit ${s.maxFiles})`),h(null);if(!(r in i)){let v=c.launchError(r,w.noMain,`could not find or load main class ${r}`);return v.text=`Error: Could not find or load main class ${r}\nCaused by: java.lang.ClassNotFoundException: ${r}`,h(null)}let m=Object.keys(i).filter(v=>v.endsWith(".java")&&v.includes("\\\\"));if(m.length)return c.launchError(r,w.unsupported,`${m.join(", ")}: file names with \\\\ are not supported in this version; separate folders with /`),h(null);let p=new Set(Object.keys(i).filter(v=>v!==r&&v.endsWith(".java"))),k=null,g=new Set,O=[r],T=[],x=0;for(;;){for(let v of O.slice(T.length)){let R=i[v]??"",L=v===r?o:sr(v,R);if(u.set(v,L),R.length>s.maxSourceChars)return c.launchError(v,w.limit,`${v} is too large for this engine (limit ${s.maxSourceChars.toLocaleString("en-US")} characters)`),h(null);if(x+=R.length,x>s.maxTotalSourceChars)return c.launchError(v,w.limit,`the program\'s files are too large for this engine together (limit ${s.maxTotalSourceChars.toLocaleString("en-US")} characters)`),h(null);let C=Ti(R);if(C.errors.some(j=>j.code!=="syntax"||j.token===void 0)){for(let j of C.errors)c.error(L,j.offset,"lex",j.code,j.message);return h(null)}let M=zi(v,C.tokens,s,C.errors),_=M.errors[0];if(_){if(_.code==="no-class")v===r?c.launchError(v,w.noMain,_.message):c.launchError(r,w.unsupported,`${v} declares no class, so the launcher cannot find ${v.replace(/\\.java$/,"")} there`);else for(let j of M.errors)c.error(L,j.offset,"parse",j.code,j.message,j.details);return h(null)}T.push({unit:M.unit,file:L})}if(k===null){let v=T[0].unit.types[0]?.implicit?[]:T[0].unit.package?.names??[],R=r.split("/").slice(0,-1);if(v.length>R.length||v.some((L,C)=>R[R.length-v.length+C]!==L))return c.launchError(r,w.noMain,`end of path to source file does not match its package name ${v.join(".")}: ${r}`),h(null);k=R.slice(0,R.length-v.length).map(L=>`${L}/`).join("")}try{let v=new Set([...p].filter(_=>!O.includes(_)&&_.startsWith(k))),R=Ja(T,c,{launch:e,available:v,root:k,files:Object.keys(i),deferred:g}),L=[...c.items];if(c.items.splice(0,c.items.length,...L.filter(_=>!_.deferred)),!R||c.hasErrors)return h(null);d=R;let C=e?lc(Ur(R,o),R,L,u,r,g):null,M=C&&pr(C.natives);return M?{result:{program:null,diagnostics:[],entry:r,diagnosticText:"",compileMs:Mn()-n,needsLibrary:M},checked:null,source:o}:h(C)}catch(v){if(v instanceof is){O.push(v.fileName),v.header&&e&&g.add(v.fileName),T.length=0,x=0,c=new mn,u=new Map([[r,o]]);continue}if(v instanceof He)return c=new mn,c.launchError(r,w.unsupported,`${v.message}: not supported in this version`),h(null);if(!(v instanceof gn))throw v;return{result:{program:null,diagnostics:[],entry:r,diagnosticText:"",compileMs:Mn()-n,needsLibrary:v.module},checked:null,source:o}}}}function lc(i,t,e,n,s,r){let a=[];for(let o of n.keys()){if(o===s)continue;let c=r.has(o)?e.filter(d=>d.deferred&&d.file===o):e.filter(d=>d.severity==="warning"&&d.file===o);if(!c.length)continue;let u=t.classes.filter(d=>d.topLevel.file?.name===o).map(d=>d.index);a.push({classes:u,text:rr(c,n),...c.some(d=>d.severity==="error")?{fails:!0}:{}})}return a.length&&(i.loadWarnings=a),i}var cc={instructions:"The program ran for a very long time, so it was stopped. Look for a loop whose condition never becomes false.",output:"The program printed more output than this page can show, so it was stopped. Look for a print inside a loop that never ends.",memory:"The program used more memory (a very large array or String) than this in-browser Java engine allows, so it was stopped.",time:"The program ran longer than the time allowed, so it was stopped."},uc="This program reached Java behavior this in-browser engine does not reproduce exactly, so it stopped rather than show something that might differ from a real JVM.";function fo(i,t={}){return po(i,t)}var hc="The program read more input than standard input had (a Scanner found nothing left to read). Type the input in the input box, one value or line for each read, then run again.";function po(i,t,e){let n={...Wr,...t.limits},s="",r="",a=(p,k)=>{p==="stdout"?s+=k:r+=k,t.onOutput?.(p,k)};t.warnings&&a("stderr",t.warnings);let o=Mn(),{outcome:c,instructions:u,inputExhausted:d}=no(i,a,n,t.onCheckpoint,e,t.stdin??""),h=Mn()-o,m={stdout:s,diagnostics:[],instructions:u,compileMs:t.compileMs??0,runMs:h};switch(c.kind){case"completed":return{...m,status:"success",stderr:r,exitCode:0};case"exception":{let p=c.text;return d&&c.className==="java.util.NoSuchElementException"?{...m,status:"runtime-error",stderr:r+p,errorText:p,hint:hc,hintAbout:"stdin",exitCode:1}:{...m,status:"runtime-error",stderr:r+p,errorText:p,exitCode:1}}case"resource-limit":{let p=`Stopped: ${c.message} (limit of this in-browser Java engine).\n`;return{...m,status:"resource-limit",stderr:r+p,errorText:p,hint:cc[c.limit],exitCode:1}}case"engine-limitation":{let p=`Stopped: ${c.message} (limitation of this in-browser Java engine).\n`;return{...m,status:"engine-limitation",stderr:r+p,errorText:p,hint:uc,exitCode:1}}case"exit":return{...m,status:c.status===0?"success":"exited",stderr:r,exitCode:c.status,exited:!0};case"compile-error":return{...m,status:"compile-error",stderr:r,errorText:r,exitCode:2}}}var uo=500;function yo(i,t,e={}){let n={...Wr,...e.limits},s=Array.isArray(t.cases)?t.cases:[],r=g=>s.map((O,T)=>({id:O.id??String(T+1),status:"not-run",args:O.args??[],expected:O.expected,stdout:"",stderr:"",reason:g,instructions:0,durationMs:0})),{result:a,checked:o,source:c}=mo(i,e,!1),u={passed:0,total:s.length,diagnostics:a.diagnostics,diagnosticText:a.diagnosticText,compileMs:a.compileMs},d=g=>({...u,status:"invalid-practice",message:g,cases:r("invalid-practice")});if(!Array.isArray(t.cases)||typeof t.method!="string")return d("practice needs a method name and a list of cases");if(s.length>uo)return d(`too many cases (limit ${uo})`);if(a.needsLibrary)return{...u,status:"compile-error",cases:[],needsLibrary:a.needsLibrary};if(!o)return{...u,status:"compile-error",cases:r("compile-error")};let h;try{h=io(o,t)}catch(g){if(g instanceof Gt)return d(g.message);throw g}let m=Ur(o,c,h.target),p=pr(m.natives);if(p)return{...u,status:"compile-error",cases:[],needsLibrary:p};let k=[];for(let[g,O]of s.entries()){let T=Array.isArray(O.args)?O.args:[],x={id:O.id??String(g+1),status:"not-run",args:T,expected:O.expected,stdout:"",stderr:"",instructions:0,durationMs:0};k.push(x);let v,R;try{let L=lo(h,T);R=L.actual,v=po(m,{limits:n},L.host)}catch(L){if(L instanceof Te){x.status="invalid-case",x.error=L.message;continue}let C=L instanceof Error?L.message:String(L);x.reason="engine-failure";for(let M of r("engine-failure").slice(g+1))k.push(M);return{...u,status:"internal-error",message:`Internal error in the Java engine: ${C}`,cases:k,passed:k.filter(M=>M.status==="passed").length}}if(x.stdout=v.stdout,x.stderr=v.errorText?v.stderr.slice(0,v.stderr.length-v.errorText.length):v.stderr,x.instructions=v.instructions,x.durationMs=Math.round(v.runMs*100)/100,v.exited){x.status="runtime-error",x.error=`System.exit(${v.exitCode}) ended the program before ${t.method}() returned`;continue}if(v.status!=="success"){x.status=v.status==="runtime-error"||v.status==="resource-limit"||v.status==="engine-limitation"?v.status:"runtime-error",x.error=v.errorText,v.hint&&(x.hint=v.hint);continue}try{x.actual=R()}catch(L){if(!(L instanceof ln))throw L;x.status="runtime-error",x.error=`ResultEncodingError: ${L.message}`;continue}x.status=O.expected===void 0?"completed":qs(x.actual,O.expected,h.tolerance)?"passed":"failed"}return{...u,status:"completed",cases:k,passed:k.filter(g=>g.status==="passed").length}}var dc={JString:lt,JArray:zt,JObject:Bt,JBox:Zt,JLibObject:be,JLambda:Se,NativeThen:Ke,doubleToString:de,objectToString:qe,normLong:At,floatToString:Fe,floatToIntBits:Ts,intBitsToFloat:Ji,parseDecimalFloat:ur,parseHexFloating:Fi,l2f:yn};function go(i){qi(i(dc))}function bo(i,t){Wi(i,t)}var So="0.39.0";async function mc(i){let t=globalThis,e=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));try{let n=!1;if(typeof t.importScripts=="function")try{t.importScripts(e),n=!0}catch{}n||await import(e)}finally{URL.revokeObjectURL(e)}}async function fc(i,t,e){await e(t);let n=globalThis;if(i===vs){let r=n[mr];if(typeof r!="function")throw new Error("the library script did not define its factory");go(r);return}let s=n[Gi]?.[i];if(!s)throw new Error(`the script for ${i} did not define its natives`);bo(i,s)}var pc=8192,xo=16;function vo(i,t={}){let e=t.now??(()=>globalThis.performance.now()),n=[],s=0,r=0,a=0,o=null,c=(k,g)=>{o={job:k,module:g},i({type:"module-request",id:k.id,name:g})},u=()=>{if(r=e(),!n.length)return;let k=n;n=[],s=0;for(let g of k)i({type:g.type,id:a,text:g.text})},d=(k,g)=>{let O=n[n.length-1];O&&O.type===k?O.text+=g:n.push({type:k,text:g}),s+=g.length,(s>=pc||e()-r>=xo)&&u()},h=k=>{a=k.id,n=[],s=0,r=e();let g=e(),O=k.entry||"Main.java",T=k.files&&Object.keys(k.files).length?{...k.files}:{},x=Object.keys(T).length>0;!(O in T)&&(!x||k.code)&&(T[O]=k.code??"");try{let v=()=>{n.length&&e()-r>=xo&&u()};if(k.practice){m(k,T,O,g);return}let R=ho(T,{entry:O,limits:t.limits});if(R.needsLibrary){c(k,R.needsLibrary);return}let L=R.program?fo(R.program,{limits:t.limits,stdin:k.stdin??"",onOutput:d,onCheckpoint:v,compileMs:R.compileMs,warnings:R.diagnosticText}):{status:"compile-error",stdout:"",stderr:R.diagnosticText,errorText:R.diagnosticText,diagnostics:R.diagnostics,exitCode:1,instructions:0,compileMs:R.compileMs,runMs:0};u();let C=e()-g;if(L.status==="success"){i({type:"result",id:k.id,durationMs:C,status:"success"});return}if(L.status==="cancelled")return;i({type:"error",id:k.id,message:L.status==="exited"?`Exited with status ${L.exitCode}.`:(L.errorText??"").replace(/\\n$/,""),hint:L.hint,...L.hintAbout?{hintAbout:L.hintAbout}:{},durationMs:C,status:L.status,...L.diagnostics.length?{diagnostics:L.diagnostics}:{}})}catch(v){u();let R=v instanceof Error?v.message:String(v);i({type:"fatal",id:k.id,message:`Internal error in the Java engine: ${R}`})}},m=(k,g,O,T)=>{let x=k.practice,v=yo(g,x,{entry:O,limits:t.limits});if(v.needsLibrary){c(k,v.needsLibrary);return}let R=e()-T;switch(v.status){case"completed":i({type:"stdout",id:k.id,text:co(x.method,v.cases)}),i({type:"result",id:k.id,durationMs:R,status:"success",cases:v.cases,passed:v.passed,total:v.total});return;case"compile-error":i({type:"error",id:k.id,message:v.diagnosticText.replace(/\\n$/,""),durationMs:R,status:"compile-error",cases:v.cases,...v.diagnostics.length?{diagnostics:v.diagnostics}:{}});return;case"invalid-practice":i({type:"error",id:k.id,message:`Practice: ${v.message}`,durationMs:R,status:"invalid-practice",cases:v.cases});return;case"internal-error":i({type:"fatal",id:k.id,message:v.message??"Internal error in the Java engine"});return}},p=async k=>{if(!o||k.name!==o.module)return;let{job:g}=o;o=null;try{if(k.code===void 0)throw new Error(k.error??"the host sent no code");await fc(k.name,k.code,t.evaluate??mc)}catch(O){let T=O instanceof Error?O.message:String(O);i({type:"fatal",id:g.id,message:`Internal error in the Java engine: could not load the Java library (${T})`});return}h(g)};return k=>{switch(k.type){case"init":i({type:"ready",version:"25",interactiveStdin:!1,java:"25",engine:So});return;case"run":h(k);return;case"stdin-response":return;case"module":return p(k)}}}var wo=globalThis,yc=vo(i=>wo.postMessage(i));wo.onmessage=i=>yc(i.data);})();\n',n={"java-library":()=>import(`./java-library.generated-B7ib0gOX.js`),"java-library-time":()=>import(`./java-library-time.generated-Dl0XA7nZ.js`),"java-library-math":()=>import(`./java-library-math.generated-BQwpn8sQ.js`),"java-library-regex":()=>import(`./java-library-regex.generated-ItYSF2aV.js`),"java-library-bitset":()=>import(`./java-library-bitset.generated-C3m-nf8F.js`)},r=new class extends e{id=`java`;supportsPractice=!0;statusDecidesFailure=!0;get source(){return t}async loadModule(e){let t=n[e];if(!t)throw Error(`no module named ${e}`);return(await t()).JAVA_LIBRARY_SOURCE}get label(){return this.version?`Java ${this.version} (subset)`:`Java`}async editorLanguage(){let{java:e}=await import(`@codemirror/lang-java`);return e()}};export{r as javaRuntime};
|