code-playpad 0.6.0 → 0.7.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/JAVA-COMPATIBILITY.md +11 -11
- package/README.md +50 -14
- package/dist/cdn.js +2 -2
- package/dist/{element-9sv2r5Jv.js → element-DaStU7U7.js} +1 -1
- package/dist/element.js +1 -1
- package/dist/index.js +1 -1
- package/dist/java-DIL6bxPF.js +1 -0
- package/dist/java-DxQWnfHu.js +6 -0
- package/dist/java-library-bitset.generated-Duwl7F-b.js +6 -0
- package/dist/java-library-math.generated-DmUvund7.js +6 -0
- package/dist/java-library-regex.generated-a8crcad3.js +6 -0
- package/dist/java-library-time.generated-mFyqZ0pg.js +6 -0
- package/dist/java-library.generated-1yFV284B.js +6 -0
- package/dist/{javascript-BIBG4Etb.js → javascript-CSfl5gbA.js} +1 -1
- package/dist/{pyodide-5mtewJ6F.js → pyodide-CdDlM0du.js} +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/java-library-bitset.generated.d.ts +9 -0
- package/dist/runtime/java-library-math.generated.d.ts +9 -0
- package/dist/runtime/java-library-regex.generated.d.ts +9 -0
- package/dist/runtime/java-library-time.generated.d.ts +9 -0
- package/dist/runtime/java-library.generated.d.ts +3 -3
- package/dist/runtime/java-worker.generated.d.ts +3 -3
- package/dist/standalone.js +1 -1
- package/dist/{worker-runtime-DXqFOKYs.js → worker-runtime-C8pmmgW9.js} +1 -1
- package/package.json +1 -1
- package/dist/java-C08pjr71.js +0 -6
- package/dist/java-library.generated-9nfQ3go0.js +0 -6
- package/dist/java-xCWvYPkx.js +0 -1
package/dist/java-C08pjr71.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* code-playpad — MIT © 2026 Seung Hun Lee
|
|
3
|
-
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
|
-
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
|
-
*/
|
|
6
|
-
import{t as e}from"./worker-runtime-CNPpMRo1.js";var t='"use strict";(()=>{function Ys(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 cs(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 ri(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 v={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"},ln=class{items=[];error(t,e,n,s,r,a){let{line:o,column:c}=cs(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 Qs(i,t){let e=i.filter(o=>o.phase!=="launch"),n=i.filter(o=>o.phase==="launch"),s=[];for(let o of e){s.push(`${o.file}:${o.line}: ${o.severity}: ${o.message}`);let c=t.get(o.file);if(c&&o.line>0){let u=ri(c,o.line);s.push(u);let d="";for(let h=0;h<o.column-1;h++)d+=u[h]===" "?" ":" ";s.push(d+"^")}for(let u of o.details??[])s.push(u)}let r=e.filter(o=>o.severity==="error").length,a=e.filter(o=>o.severity==="warning").length;r&&s.push(r===1?"1 error":`${r} errors`),a&&s.push(a===1?"1 warning":`${a} warnings`),r&&s.push("error: compilation failed");for(let o of n)s.push(o.text??`error: ${o.message}`);return s.join(`\n`)+`\n`}function eo(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function ii(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=eo(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 no=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"]),so=[">>>=","<<=",">>=",">>>","...","->","::","++","--","&&","||","==","!=","<=",">=","+=","-=","*=","/=","&=","|=","^=","%=","<<",">>","(",")","{","}","[","]",";",",",".","@","=",">","<","!","~","?",":","+","-","*","/","&","|","^","%"];function oi(i){return i>=65&&i<=90||i>=97&&i<=122||i===95||i===36}function ai(i){return oi(i)||i>=48&&i<=57}function oe(i){return i>=48&&i<=57}function ro(i){let t=i.charCodeAt(0);return t>=32&&t<127?`\'${i}\'`:`\'\\\\u${t.toString(16).padStart(4,"0")}\'`}function li(i){let t=ii(i),e=t.text,n=t.offsets,s=[],r=t.errors.map(C=>({offset:C.offset,code:"syntax",message:C.message}));if(r.length)return{tokens:[{kind:"eof",text:"",start:i.length,end:i.length}],errors:r};let a=(C,S,w="syntax")=>{r.push({offset:n[C],code:w,message:S})},o=(C,S,w,I)=>{s.push({kind:C,text:e.slice(S,w),start:n[S],end:n[w],...I})},c=e.length;c>0&&e.charCodeAt(c-1)===26&&c--;let u=0;for(;u<c;){let C=e.charCodeAt(u);if(C===32||C===9||C===12||C===10||C===13){u++;continue}if(C===47&&e.charCodeAt(u+1)===47){for(;u<c&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;continue}if(C===47&&e.charCodeAt(u+1)===42){let w=e.indexOf("*/",u+2);if(w===-1||w+2>c){a(u,"unclosed comment"),u=c;break}u=w+2;continue}if(oi(C)){let w=u;for(;u<c&&ai(e.charCodeAt(u));)u++;if(u<c&&e.charCodeAt(u)>127&&/[\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Sc}]/u.test(e[u]))for(a(u,"identifiers containing non-ASCII characters are not supported in this version","unsupported");u<c&&(ai(e.charCodeAt(u))||e.charCodeAt(u)>127);)u++;let I=e.slice(w,u);o(no.has(I)?"keyword":"identifier",w,u);continue}if(oe(C)||C===46&&oe(e.charCodeAt(u+1))){u=d(u);continue}if(C===39){u=m(u);continue}if(C===34){e.startsWith(\'"""\',u)?u=k(u):u=p(u);continue}let S=so.find(w=>e.startsWith(w,u));if(S){o("operator",u,u+S.length),u+=S.length;continue}C>127&&/[\\p{L}\\p{Nl}\\p{Sc}\\p{Pc}]/u.test(e[u])?a(u,"identifiers containing non-ASCII characters are not supported in this version","unsupported"):a(u,`illegal character: ${ro(e[u])}`),u++}return s.push({kind:"eof",text:"",start:n[c],end:n[c]}),{tokens:s,errors:r};function d(C){let S=P=>P<c?e.charCodeAt(P):-1,w=P=>S(P)|32,I=P=>oe(P)||(P|32)>=97&&(P|32)<=102,R=(P,j)=>{let G=P;for(;G<c&&(j(S(G))||S(G)===95);)G++;return G>P&&S(G-1)===95?(a(G-1,"illegal underscore"),null):G},N=(P,j,G)=>{let Z=e.slice(G,P).replace(/_/g,""),be=BigInt((j===16?"0x":j===8?"0o":j===2?"0b":"")+(Z||"0"));return(S(P)|32)===108?(o("long-literal",C,P+1,{integer:{value:be,radix:j}}),P+1):(o("int-literal",C,P,{integer:{value:be,radix:j}}),P)},A=(P,j)=>{if(w(P)!==j)return P;let G=P+1;return(S(G)===43||S(G)===45)&&G++,oe(S(G))?R(G,oe):(a(C,"malformed floating-point literal"),null)},L=P=>{let j=w(P);return j===102?(o("float-literal",C,P+1),P+1):j===100?(o("double-literal",C,P+1),P+1):(o("double-literal",C,P),P)};if(S(C)===48&&w(C+1)===120){let P=C+2;if(S(P)===95)return a(P,"illegal underscore"),P+1;let j=R(P,I);if(j===null)return c;let G=j>P;if(S(j)===46||w(j)===112){if(S(j)===46){let qt=R(j+1,I);if(qt===null)return c;if(!G&&qt===j+1)return a(C,"hexadecimal numbers must contain at least one hexadecimal digit"),qt;j=qt}if(w(j)!==112)return a(C,"malformed floating-point literal"),j;let Z=A(j,112);return Z===null?c:L(Z)}return G?N(j,16,P):(a(C,"hexadecimal numbers must contain at least one hexadecimal digit"),j)}if(S(C)===48&&w(C+1)===98){let P=C+2;if(S(P)===95)return a(P,"illegal underscore"),P+1;let j=R(P,oe);return j===null?c:j===P?(a(C,"binary numbers must contain at least one binary digit"),j):/[2-9]/.test(e.slice(P,j))?(a(C,"illegal digit in a binary literal"),j):N(j,2,P)}let J=C;if(oe(S(C))&&(J=R(C,oe),J===null))return c;if(S(J)===46&&(J>C||oe(S(J+1)))||w(J)===101||w(J)===102||w(J)===100)return S(J)===46&&(J=oe(S(J+1))?R(J+1,oe):J+1,J===null)?c:(J=A(J,101),J===null?c:L(J));if(S(C)===48&&J>C+1){for(let P=C+1;P<J;P++)if(S(P)===56||S(P)===57)return a(P,"illegal digit in an octal literal"),J;return N(J,8,C+1)}return N(J,10,C)}function h(C){let S=e[C+1];switch(S){case"b":return["\\b",C+2];case"s":return[" ",C+2];case"t":return[" ",C+2];case"n":return[`\n`,C+2];case"f":return["\\f",C+2];case"r":return["\\r",C+2];case\'"\':return[\'"\',C+2];case"\'":return["\'",C+2];case"\\\\":return["\\\\",C+2]}if(S!==void 0&&S>="0"&&S<="7"){let w=S<="3"?3:2,I=C+1,R="";for(;R.length<w&&I<c&&e[I]>="0"&&e[I]<="7";)R+=e[I++];return[String.fromCharCode(parseInt(R,8)),I]}return null}function m(C){let S=C+1,w="";for(;S<c;){let I=e.charCodeAt(S);if(I===39)break;if(I===10||I===13)return a(C,"unclosed character literal"),S;if(I===92){let R=h(S);if(!R)return a(S+1,"illegal escape character"),T(S);w+=R[0],S=R[1];continue}w+=e[S],S++}return S>=c?(a(C,"unclosed character literal"),S):w.length===0?(a(C,"empty character literal"),S+1):w.length>1?(a(C,"unclosed character literal"),S+1):(o("char-literal",C,S+1,{stringValue:w}),S+1)}function p(C){let S=C+1,w="";for(;S<c;){let I=e.charCodeAt(S);if(I===34)return o("string-literal",C,S+1,{stringValue:w}),S+1;if(I===10||I===13)break;if(I===92){let R=h(S);if(!R)return a(S+1,"illegal escape character"),T(S);w+=R[0],S=R[1];continue}w+=e[S],S++}return a(C,"unclosed string literal"),S}function k(C){let S=C+3;for(;S<c&&(e[S]===" "||e[S]===" "||e[S]==="\\f");)S++;if(S<c&&e[S]!==`\n`&&e[S]!=="\\r")return a(S,"illegal text block open delimiter sequence, missing line terminator"),S;if(S>=c)return a(C,"unclosed text block"),c;S+=e[S]==="\\r"&&e[S+1]===`\n`?2:1;let w=S;for(;S<c;){if(e.charCodeAt(S)===92){let R=e[S+1];if(R===`\n`||R==="\\r"){S+=R==="\\r"&&e[S+2]===`\n`?3:2;continue}let N=h(S);if(!N){a(S+1,"illegal escape character"),S+=2;continue}S=N[1];continue}if(e.startsWith(\'"""\',S))return o("text-block",C,S+3,{stringValue:io(e.slice(w,S))}),S+3;S++}return a(C,"unclosed text block"),c}function T(C){for(;C<c&&e.charCodeAt(C)!==10&&e.charCodeAt(C)!==13;)C++;return C}}var Zs=/[\\t\\x0b\\f\\x1c-\\x20\\u1680\\u2000-\\u2006\\u2008-\\u200a\\u2028\\u2029\\u205f\\u3000]/;function io(i){let t=i.replace(/\\r\\n?/g,`\n`).split(`\n`),e=a=>[...a].every(o=>Zs.test(o)),n=a=>{let o=0;for(;o<a.length&&Zs.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&&Zs.test(a[o-1]);)o--;return a.slice(s,o)});return ao(r.join(`\n`))}function ao(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 cn=Number.MAX_SAFE_INTEGER,er=9223372036854775807n,nr=-9223372036854775808n,ci=9223372036854776e3;function wt(i){let t=BigInt.asIntN(64,i);return t>=-9007199254740991n&&t<=9007199254740991n?Number(t):t}var It=i=>typeof i=="bigint"?i:BigInt(i),un=i=>i===0?0:i;function ui(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i+t;if(e<=cn&&e>=-cn)return e}return wt(It(i)+It(t))}function hi(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i-t;if(e<=cn&&e>=-cn)return e}return wt(It(i)-It(t))}function di(i,t){if(typeof i=="number"&&typeof t=="number"){let e=i*t;if(e<=cn&&e>=-cn)return un(e)}return wt(It(i)*It(t))}function mi(i,t){return typeof i=="number"&&typeof t=="number"?un(Math.trunc(i/t)):wt(It(i)/It(t))}function fi(i,t){return typeof i=="number"&&typeof t=="number"?un(i%t):wt(It(i)%It(t))}function sr(i){return typeof i=="number"?un(-i):wt(-i)}function pi(i,t){return wt(It(i)<<BigInt(t&63))}function yi(i,t){return wt(It(i)>>BigInt(t&63))}function gi(i,t){return wt(BigInt.asUintN(64,It(i))>>BigInt(t&63))}function bi(i,t){return wt(It(i)&It(t))}function Si(i,t){return wt(It(i)|It(t))}function Ti(i,t){return wt(It(i)^It(t))}function ds(i){return typeof i=="number"?i|0:Number(BigInt.asIntN(32,i))}function ms(i){return Number(i)}function hn(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 Nn(i){if(Number.isNaN(i))return 0;if(i>=ci)return er;if(i<=-ci)return nr;let t=Math.trunc(i);return Number.isSafeInteger(t)?un(t):BigInt(t)}function $n(i){return Number.isNaN(i)?0:i>=2147483647?2147483647:i<=-2147483648?-2147483648:un(Math.trunc(i))}function xi(i){return Number.isNaN(i)?0:$n(Math.abs(i)>=8388608?i:Math.floor(i+.5))}function vi(i){return Nn(Math.round(i))}function oo(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 us=new DataView(new ArrayBuffer(4));function wi(i){return us.setFloat32(0,i),us.getInt32(0)}function fs(i){return Number.isNaN(i)?2143289344:wi(i)}function ki(i){return us.setInt32(0,i),us.getFloat32(0)}var hs=i=>10n**BigInt(i);function Re(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=wi(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=(N,A)=>A>=0?N<<BigInt(A):N>>BigInt(-A),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=N=>N<0?{A:hs(-N),B:m}:{A:1n,B:hs(N)*m},k=N=>{let{A,B:L}=p(N),J=d*A,D=u*A,P=(J+L-1n)/L;!h&&P*L===J&&P++;let j=D/L;return!h&&j*L===D&&j--,{dLo:P,dHi:j,A,B:L}},T=N=>{let{dLo:A,dHi:L,A:J,B:D}=k(N);if(A>L)return null;let P=c*J,j=P/D,G=2n*P,Z=(2n*j+1n)*D;return(G>Z||G===Z&&(j&1n)===1n)&&j++,j<A&&(j=A),j>L&&(j=L),j},C=Math.floor(Math.log10(Math.abs(i)))+2,S=T(C);for(;S===null;)S=T(--C);S<10n&&(C--,S=T(C));let w=S.toString(),I=C+w.length-1,R=Math.abs(i);return oo(i<0?"-":"",w,I,R>=.001&&R<1e7)}function lo(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*hs(t):i,a=t>=0?1n:hs(-t);return n(tr(r,a))}function tr(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 Ci(i,t){return i===0n?0:t>=0?tr(i<<BigInt(t),1n):tr(i,1n<<BigInt(-t))}function Ei(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=Ci(o,Number(s[3])-4*a.length)}else e=rr(t),n=/[1-9]/.test(t.replace(/[eE].*$/,""));return e===1/0?{error:"too-large"}:e===0&&n?{error:"too-small"}:{value:e}}function Ai(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?Ci(s,r):Oi(s,r);return e[1]==="-"?-a:a}function rr(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 lo(s,r,t[1]==="-")}function le(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 Ii(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=Oi(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 Oi(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 ir(i){return i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="MethodCall"||i.kind==="NewObject"}var _t=class extends Error{info;constructor(t){super(t.message),this.info=t}},Ge=new Set(["int","boolean","byte","short","long","char","float","double"]),Li=new Set(["public","protected","private","static","final","abstract","native","synchronized","transient","volatile","strictfp","default"]),co={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"<":7,">":7,"<=":7,">=":7,instanceof:7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Ni=new Set(["=","+=","-=","*=","/=","%=","&=","|=","^=","<<=",">>=",">>>="]),uo={synchronized:"\'synchronized\' statements"},ho=new Set(["(","!","~","this","super","new","true","false","null","switch"]);function $i(i,t,e){let n=new ar(i,t,e);try{return{unit:n.compilationUnit(),error:null}}catch(s){if(s instanceof _t)return{unit:null,error:s.info};throw s}}var ar=class{#O;#dt;#Mt=[];#D;#j=0;#W=!1;#z=0;constructor(t,e,n){this.#O=t,this.#dt=[...e],this.#D=n}#r(t=0){return this.#dt[Math.min(this.#j+t,this.#dt.length-1)]}#y(){return this.#dt[Math.max(this.#j-1,0)]}#s(){let t=this.#r();return this.#j<this.#dt.length-1&&this.#j++,t}#n(t,e=0){let n=this.#r(e);return(n.kind==="operator"||n.kind==="keyword")&&n.text===t}#g(t=0,e){let n=this.#r(t);return n.kind==="identifier"&&(e===void 0||n.text===e)}#h(t){return this.#n(t)?(this.#s(),!0):!1}#i(t){if(this.#n(t))return this.#s();throw this.#r().kind==="eof"&&t==="}"&&this.#H(),this.#c(this.#y().end,`\'${t}\' expected`)}#w(){let t=this.#r();if(t.kind==="identifier")return this.#s();throw t.kind==="keyword"&&t.text==="_"?this.#C(t.start,"the unnamed variable \'_\'",!0):(t.kind==="eof"&&this.#H(),this.#c(t.kind==="keyword"?t.start:this.#y().end,"<identifier> expected"))}#H(){throw this.#c(this.#y().end,"reached end of file while parsing")}#c(t,e){return new _t({offset:t,code:"syntax",message:e})}#C(t,e,n=!1){return new _t({offset:t,code:"unsupported",message:`${e} ${n?"is":"are"} not supported in this version`})}#L(){return{i:this.#j,splits:this.#Mt.length}}#F(t){for(;this.#Mt.length>t.splits;){let e=this.#Mt.pop();this.#dt.splice(e.index,2,e.token)}this.#j=t.i}#K(){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.#Mt.push({index:this.#j,token:t}),this.#dt.splice(this.#j,1,e,n),this.#s();return}throw t.kind==="eof"&&this.#H(),this.#c(t.start,"\'>\' expected")}#mt(){this.#i("<");let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#C(e.start,"annotations");let n=this.#w(),s=[];if(this.#h("extends"))do s.push(this.#m());while(this.#h("&"));t.push({name:n.text,pos:n.start,bounds:s})}while(this.#h(","));return this.#K(),t}#bt(){if(this.#i("<"),this.#h(">"))return"diamond";let t=[];do{let e=this.#r();if(e.kind==="operator"&&e.text==="@")throw this.#C(e.start,"annotations");if(this.#h("?")){let n=null,s=!1;this.#h("extends")?n=this.#m():this.#h("super")&&(s=!0,n=this.#m()),t.push({kind:"WildcardType",bound:n,isSuper:s,pos:e.start,start:e.start,end:this.#y().end})}else t.push(this.#m())}while(this.#h(","));return this.#K(),t}#it(){if(++this.#z>this.#D.maxNestingDepth)throw new _t({offset:this.#r().start,code:"limit",message:`code is nested too deeply for this engine (limit ${this.#D.maxNestingDepth})`})}#$(){this.#z--}#N(t,...e){let n=0;for(let s of e)n=Math.max(n,s.depth);if(t.depth=n+1,t.depth>this.#D.maxExpressionDepth)throw new _t({offset:t.start,code:"limit",message:`expression is nested too deeply for this engine (limit ${this.#D.maxExpressionDepth})`});return t}compilationUnit(){let t={file:this.#O,imports:[],types:[]},e=[];if(this.#n("package"))throw this.#C(this.#r().start,"package declarations");for(;this.#n("import");)t.imports.push(this.#gt());for(;this.#r().kind!=="eof";){if(this.#h(";"))continue;let n=this.#r().start;if(this.#n("import"))throw this.#a(t,e);let s=this.#E();if(this.#n("class")||this.#n("interface")){t.types.push(this.#Bt(s,n));continue}if(this.#n("enum")){t.types.push(this.#k(s,n));continue}if(this.#n("@")&&this.#n("interface",1))throw this.#C(this.#r().start,"annotation interface declarations");if(this.#g(0,"record")&&this.#g(1)&&(this.#n("(",2)||this.#n("<",2))){t.types.push(this.#P(s,n));continue}if(this.#l()){e.push(this.#t(s,n,null));continue}throw this.#a(t,e)}if(e.length){let n=[...e,...t.types].sort((a,o)=>a.start-o.start),s=n[0],r=this.#O.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}#gt(){let t=this.#i("import"),e=this.#n("static");e&&this.#s();let n=[this.#w().text],s=t.start,r=[],a=!1,o=this.#y().start;for(;this.#n(".");){if(s=this.#s().start,r.push(s),this.#n("*")){o=this.#s().start,a=!0;break}let u=this.#w();n.push(u.text),o=u.start}let c=this.#i(";");return{names:n,onDemand:a,lastDotPos:s,dots:r,...e?{isStatic:!0}:{},pos:o,start:t.start,end:c.end}}#a(t,e){let n=this.#dt.some(s=>s.kind==="keyword"&&(s.text==="class"||s.text==="interface"||s.text==="enum"));return!t.types.length&&!e.length&&!n?new _t({offset:0,code:"no-class",message:"no class declared in source file"}):this.#c(this.#r().start,"class, interface, annotation type, enum, record, method or field expected")}#l(){let t=this.#L();try{if(this.#n("<"))try{this.#mt()}catch{return!1}if(this.#n("void"))this.#s();else if(!this.#T())return!1;return this.#g()?(this.#s(),this.#n("(")||this.#n("=")||this.#n(";")||this.#n(",")):!1}finally{this.#F(t)}}#E(){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.#et());continue}if(e.kind==="keyword"&&Li.has(e.text)){if(t.keywords.some(n=>n.name===e.text))throw this.#c(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.#g(a,"sealed")||this.#g(a,"non")||this.#n("abstract",a)||this.#r(a).kind==="keyword"&&Li.has(this.#r(a).text),s=e.text==="sealed"&&n(1),r=e.text==="non"&&this.#n("-",1)&&this.#g(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";if(t.keywords.some(o=>o.name===a))throw this.#c(e.start,"repeated modifier");t.keywords.push({name:a,pos:e.start}),this.#s(),r&&(this.#s(),this.#s());continue}}return t}}#et(){let t=this.#i("@"),e=this.#w(),n=[e.text];for(;this.#n(".")&&this.#g(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.#h("(")){let r=[];for(;!this.#n(")");){let a=this.#r().start,o=null;if(this.#g()&&this.#n("=",1)&&(o=this.#s().text,this.#s()),r.push({name:o,value:this.#Xt(),pos:a}),!this.#h(","))break}this.#i(")"),s.args=r}return s}#Xt(){if(this.#n("@"))throw this.#C(this.#r().start,"nested annotations");if(!this.#n("{"))return this.#f();let t=this.#s(),e=[];for(;!this.#n("}")&&(e.push(this.#Xt()),!!this.#h(",")););return this.#i("}"),{kind:"ElementArray",elements:e,pos:t.start}}#_(t,e){for(;!this.#n("}");)this.#r().kind==="eof"&&this.#H(),!this.#h(";")&&t.members.push(this.#R(t.name,e));t.end=this.#i("}").end}#M(t){if(this.#h("implements"))do t.implementsTypes.push(this.#m());while(this.#h(","))}#k(t,e){let n=this.#i("enum"),s=this.#w(),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.#C(this.#r().start,"generic enums");if(this.#n("extends"))throw this.#c(this.#y().end,"\'{\' expected");for(this.#M(r),this.#i("{");this.#g()||this.#n("@");){if(this.#n("@"))throw this.#C(this.#r().start,"annotations");let a=this.#s(),o=this.#n("(")?this.#Dt():[],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.#_(c)}if(r.enumConstants.push({name:a.text,args:o,...c?{body:c}:{},pos:a.start,start:a.start,end:this.#y().end}),!this.#h(","))break}if(!this.#n("}")&&!this.#h(";"))throw this.#c(this.#y().end,"\',\', \'}\', or \';\' expected");return this.#_(r),r}#P(t,e){let n=this.#s(),s=this.#w(),r=this.#n("<")?this.#mt():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.#J();if(o.varargs)throw this.#C(o.pos,"variable-arity record components");a.components.push(o)}while(this.#h(","));if(this.#i(")"),this.#n("extends"))throw this.#c(this.#y().end,"\'{\' expected");return this.#M(a),this.#i("{"),this.#_(a,a.name),a}#Bt(t,e){let n=this.#n("interface"),s=this.#s(),r=this.#w(),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.#mt()),this.#h("extends"))do a.extendsTypes.push(this.#m());while(n&&this.#h(","));if(this.#n("implements")){if(n)throw this.#c(this.#r().start,"\'{\' expected");this.#s();do a.implementsTypes.push(this.#m());while(this.#h(","))}if(this.#g(0,"permits")){this.#s(),a.permits=[];do a.permits.push(this.#m());while(this.#h(","))}for(this.#i("{");!this.#n("}");)this.#r().kind==="eof"&&this.#H(),!this.#h(";")&&a.members.push(this.#R(a.name));return a.end=this.#i("}").end,a}#R(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.#ft();return{kind:"Initializer",modifiers:r,isStatic:r.keywords.length>0,body:a,pos:n,start:n,end:a.end}}let s=this.#E();if(this.#n("class")||this.#n("interface"))return this.#Bt(s,n);if(this.#n("enum"))return this.#k(s,n);if(this.#g(0,"record")&&this.#g(1)&&(this.#n("(",2)||this.#n("<",2)))return this.#P(s,n);if(e!==void 0&&this.#g(0,e)&&this.#n("{",1)){let r=this.#s(),a=this.#ft();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.#t(s,n,t)}#t(t,e,n){if(this.#n("<")){let a=this.#mt(),o=this.#t(t,e,n);if(o.kind!=="MethodDeclaration")throw this.#c(o.pos,"<identifier> expected");return o.typeParams=a,o}if(n!==null&&this.#g()&&this.#n("(",1)){let a=this.#r();if(a.text!==n)throw this.#c(a.start,"invalid method declaration; return type required");this.#s();let o={kind:"VoidType",pos:a.start,start:a.start,end:a.start},c=this.#d(t,o,a,e);return c.isConstructor=!0,c}let s;if(this.#n("void")){let a=this.#s();s={kind:"VoidType",pos:a.start,start:a.start,end:a.end}}else s=this.#m();let r=this.#w();if(!this.#n("(")){if(s.kind!=="VoidType"&&(this.#n("=")||this.#n(";")||this.#n(",")||this.#n("[")))return this.#p(t,s,r,e);throw this.#c(this.#y().end,"\'(\' expected")}return this.#d(t,s,r,e)}#p(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.#h("=")&&(u=this.#n("{")?this.#st():this.#f()),r.push({name:a.text,extraDims:c,init:u,pos:a.start,start:a.start,end:this.#y().end}),!this.#h(","))break;a=this.#w()}let o=this.#i(";");return{kind:"FieldDeclaration",modifiers:t,type:e,declarators:r,pos:n.start,start:s,end:o.end}}#d(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(")"))do{let a=r.params[r.params.length-1];if(a?.varargs)throw this.#c(a.pos,"varargs parameter must be the last parameter");r.params.push(this.#J())}while(this.#h(","));if(this.#i(")"),this.#n("["))throw this.#C(this.#r().start,"array dimensions after a parameter list");if(this.#h("throws")){r.throwsTypes=[];do r.throwsTypes.push(this.#m());while(this.#h(","))}if(this.#h(";"))return r.end=this.#y().end,r;if(!this.#n("{"))throw this.#c(this.#y().end,"\'{\' expected");return r.body=this.#ft(),r.end=r.body.end,r.closeBracePos=r.body.end-1,r}#J(){let t=this.#r().start,e=this.#E(),n=this.#m(),s=!1;this.#h("...")&&(s=!0);let r=this.#w();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.#y().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}}#m(){let t=this.#r(),e;if(t.kind==="keyword"&&Ge.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.#bt();if(u==="diamond")throw this.#c(this.#y().start,"illegal start of type");a=u,s=!0}if(this.#n(".")&&this.#g(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.#y().end}}else if(t.kind==="eof")this.#H();else throw this.#c(t.start,"<identifier> expected");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}#T(){let t=this.#L();try{return this.#m(),!0}catch(e){if(!(e instanceof _t))throw e;return this.#F(t),!1}}#ft(){let t=this.#i("{");this.#it();let e=[];for(;!this.#n("}");)this.#r().kind==="eof"&&this.#H(),e.push(this.#Pt());let n=this.#i("}");return this.#$(),{kind:"Block",statements:e,pos:t.start,start:t.start,end:n.end}}#Pt(){if(this.#I())return this.#Y();if(this.#n("static")&&(this.#n("class",1)||this.#n("interface",1)))throw this.#c(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.#g(0,"record")&&this.#g(1)&&(this.#n("(",2)||this.#n("<",2));if(t||e){let n=this.#r().start,s=this.#E(),r=this.#n("enum")?this.#k(s,n):e?this.#P(s,n):this.#Bt(s,n);return{kind:"LocalClass",declaration:r,pos:r.keywordPos,start:n,end:r.end}}return this.#A()?this.#Et():this.#Y()}#A(){if(this.#n("final")||this.#n("@")&&!this.#n("interface",1))return!0;let t=this.#r();if(t.kind==="keyword"&&Ge.has(t.text))return!this.#n(".",1);if(t.kind!=="identifier")return!1;let e=this.#L();try{if(!this.#T())return!1;let n=this.#r();return n.kind==="identifier"||n.kind==="keyword"&&n.text==="_"}finally{this.#F(e)}}#Et(){let t=this.#r().start,e=this.#E();for(let a of e.keywords)if(a.name!=="final")throw this.#c(a.pos,"illegal start of expression");let n=this.#m();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.#w(),o=0;for(;this.#n("[")&&this.#n("]",1);)this.#s(),this.#s(),o++;let c=null;this.#h("=")&&(c=this.#n("{")?this.#st():this.#f()),s.push({name:a.text,extraDims:o,init:c,pos:a.start,start:a.start,end:this.#y().end})}while(this.#h(","));let r=this.#i(";");return{kind:"LocalVariableDeclaration",modifiers:e,type:n,declarators:s,pos:t,start:t,end:r.end}}#Y(){this.#it();try{let t=this.#r();if(t.kind==="operator"&&t.text==="{")return this.#ft();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.#Rt();if(t.text==="if")return this.#Vt();if(t.text==="while")return this.#At();if(t.text==="do")return this.#U();if(t.text==="switch")return this.#tt();if(t.text==="for")return this.#o();if(t.text==="return")return this.#ae();if(t.text==="break"||t.text==="continue")return this.#zt();if(t.text==="throw")return this.#oe();if(t.text==="try")return this.#we();if(t.text==="assert")return this.#lt();let e=uo[t.text];if(e)throw this.#C(t.start,e);if(t.text==="else")throw this.#c(t.start,"\'else\' without \'if\'")}if(t.kind==="identifier"){if(this.#n(":",1))return this.#x();if(this.#I())return this.#X()}if(this.#A()){let e=this.#Et();throw this.#c(e.declarators[0].pos,"variable declaration not allowed here")}return this.#It()}finally{this.#$()}}#Rt(){let t=this.#s(),e=this.#r().start,n=this.#Dt(),s=this.#i(";");return{kind:"ConstructorCall",keyword:t.text,thisPos:t.start,args:n,pos:e,start:t.start,end:s.end}}#Vt(){let t=this.#i("if");this.#i("(");let e=this.#f();this.#i(")");let n=this.#Y(),s=null;this.#h("else")&&(s=this.#Y());let r=(s??n).end;return{kind:"IfStatement",condition:e,then:n,otherwise:s,pos:t.start,start:t.start,end:r}}#I(){if(!this.#g(0,"yield"))return!1;let t=this.#r(1);return t.kind==="eof"?!1:t.kind!=="operator"?!0:Ni.has(t.text)?!1:![".","(","[","++","--",";",":",")",","].includes(t.text)}#X(){let t=this.#s(),e=this.#f(),n=this.#i(";");return{kind:"YieldStatement",value:e,pos:t.start,start:t.start,end:n.end}}#x(){let t=this.#s();this.#i(":");let e=this.#Y();return{kind:"LabeledStatement",label:t.text,body:e,pos:t.start,start:t.start,end:e.end}}#U(){let t=this.#i("do"),e=this.#Y();this.#i("while"),this.#i("(");let n=this.#f();this.#i(")");let s=this.#i(";");return{kind:"DoStatement",body:e,condition:n,pos:t.start,start:t.start,end:s.end}}#tt(){let t=this.#i("switch"),e=this.#r().start,n=this.#Q(),{cases:s,end:r}=this.#e(!1);return{kind:"SwitchStatement",selector:n,selectorPos:e,cases:s,pos:t.start,start:t.start,end:r}}#Q(){this.#i("(");let t=this.#f();return this.#i(")"),t}#e(t){this.#i("{"),this.#it();let e=[];for(;!this.#n("}");){this.#r().kind==="eof"&&this.#H();let s=this.#r(),r=[],a=!1,o={};if(this.#h("default"))a=!0;else if(this.#h("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.#nt()){if(u||r.length)throw this.#C(this.#r().start,"several patterns in one case label");if(u=this.#pt(!0),this.#g(0,"when")){this.#s(),this.#W=!0;try{d=this.#f()}finally{this.#W=!1}}continue}if(this.#g()&&(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.#Ot())}while(this.#h(","));if(u&&(r.length||h))throw this.#C(u.pos,"a pattern combined with other case labels");o={...u?{pattern:u}:{},...d?{guard:d}:{},...h?{nullLabel:h}:{}}}else throw this.#c(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.#h("->"))if(c.arrow=!0,this.#n("{"))c.body=this.#ft();else if(this.#n("throw")){let u=this.#oe();c.body={kind:"Block",statements:[u],pos:u.pos,start:u.start,end:u.end}}else{let u=this.#f();if(!t&&!ir(u))throw this.#c(u.pos,"not a statement");this.#i(";"),c.body=u}else{if(!this.#n(":"))throw this.#c(this.#y().end,"\':\' or \'->\' expected");for(this.#s();!this.#n("case")&&!this.#n("default")&&!this.#n("}");)this.#r().kind==="eof"&&this.#H(),c.statements.push(this.#Pt())}c.end=this.#y().end,e.push(c)}let n=this.#i("}");return this.#$(),{cases:e,end:n.end}}#nt(){let t=this.#L();try{this.#h("final");let e=this.#r();return!(e.kind==="identifier"||e.kind==="keyword"&&Ge.has(e.text))||!this.#T()?!1:this.#g()||this.#n("(")||this.#n("_")}finally{this.#F(t)}}#pt(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.#h("final"),s;if(!t&&this.#g(0,"var")&&(this.#g(1)||this.#n("_",1))?(this.#s(),s=null):s=this.#m(),s&&this.#n("(")){if(n)throw this.#c(e,"illegal start of expression");this.#s();let a=[];if(!this.#n(")"))do a.push(this.#pt(!1));while(this.#h(","));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.#g())throw this.#c(this.#y().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}}#At(){let t=this.#i("while");this.#i("(");let e=this.#f();this.#i(")");let n=this.#Y();return{kind:"WhileStatement",condition:e,body:n,pos:t.start,start:t.start,end:n.end}}#o(){let t=this.#i("for");if(this.#i("("),this.#Ht())return this.#$e(t);let e=null;this.#A()?e=this.#Et():(this.#n(";")||(e=this.#ve()),this.#i(";"));let n=this.#n(";")?null:this.#f();this.#i(";");let s=this.#n(")")?[]:this.#ve();this.#i(")");let r=this.#Y();return{kind:"ForStatement",init:e,condition:n,update:s,body:r,pos:t.start,start:t.start,end:r.end}}#$e(t){let e=this.#E();for(let o of e.keywords)if(o.name!=="final")throw this.#c(o.pos,"illegal start of expression");let n=this.#m();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.#w();this.#i(":");let r=this.#f();this.#i(")");let a=this.#Y();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}}#Ht(){let t=this.#L();try{return this.#E(),!this.#T()||!this.#g()?!1:(this.#s(),this.#n(":"))}catch(e){if(e instanceof _t)return!1;throw e}finally{this.#F(t)}}#ve(){let t=[];do{let e=this.#f();if(!ir(e))throw this.#c(e.pos,"not a statement");t.push(e)}while(this.#h(","));return t}#ae(){let t=this.#i("return"),e=this.#n(";")?null:this.#f(),n=this.#i(";");return{kind:"ReturnStatement",value:e,pos:t.start,start:t.start,end:n.end}}#oe(){let t=this.#i("throw"),e=this.#f(),n=this.#i(";");return{kind:"ThrowStatement",expression:e,pos:t.start,start:t.start,end:n.end}}#lt(){let t=this.#i("assert"),e=this.#f(),n=this.#h(":")?this.#f():null,s=this.#i(";");return{kind:"AssertStatement",condition:e,message:n,pos:t.start,start:t.start,end:s.end}}#we(){let t=this.#i("try"),e=[];if(this.#h("(")){for(;!this.#n(")");){let o=this.#r().start;if(this.#g()&&(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.#E();let c=this.#m();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.#w();this.#i("=");let d=this.#f();e.push({kind:"declaration",type:c,name:u.text,namePos:u.start,init:d,pos:u.start,start:o,end:d.end})}if(!this.#h(";"))break}this.#i(")")}let n=this.#ft(),s=[];for(;this.#n("catch");){let o=this.#s();this.#i("(");let c=this.#E(),u=[this.#m()];for(;this.#h("|");)u.push(this.#m());let d=this.#w();this.#i(")");let h=this.#ft();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.#h("finally")?this.#ft():null;if(!s.length&&!r&&!e.length)throw this.#c(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}}#zt(){let t=this.#s(),e=this.#g()?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}}#st(){let t=this.#i("{");this.#it();let e=[];for(;!this.#n("}")&&(e.push(this.#n("{")?this.#st():this.#f()),!!this.#h(",")););let n=this.#i("}");return this.#$(),{kind:"ArrayInitializer",elements:e,pos:t.start,start:t.start,end:n.end}}#It(){let t=this.#f();if(!ir(t))throw this.#c(t.pos,"not a statement");let e=this.#i(";");return{kind:"ExpressionStatement",expression:t,pos:t.pos,start:t.start,end:e.end}}#f(){this.#it();try{let t=this.#Ot(),e=this.#r();if(e.kind==="operator"&&Ni.has(e.text)){this.#s();let n=this.#f();return this.#N({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.#$()}}#Ot(){let t=this.#Lt(1);if(!this.#n("?"))return t;let e=this.#s(),n=this.#f();this.#i(":");let s=this.#Ot();return this.#N({kind:"Conditional",condition:t,whenTrue:n,whenFalse:s,depth:0,pos:e.start,start:t.start,end:s.end},t,n,s)}#Lt(t){let e=this.#G();for(;;){let n=this.#r();if(n.kind!=="operator"&&!(n.kind==="keyword"&&n.text==="instanceof"))break;let s=co[n.text];if(s===void 0||s<t)break;if(n.text==="instanceof"){e=this.#at(e);continue}this.#s();let r=this.#Lt(s+1);e=this.#N({kind:"Binary",operator:n.text,left:e,right:r,depth:0,pos:n.start,start:e.start,end:r.end},e,r)}return e}#at(t){let e=this.#s(),n=!1;this.#n("final")&&(this.#s(),n=!0);let s=this.#m(),r,a;if(this.#n("(")){this.#s();let c=[];if(!this.#n(")"))do c.push(this.#pt(!1));while(this.#h(","));let u=this.#i(")");a={kind:"RecordPattern",type:s,components:c,pos:s.pos,start:s.start,end:u.end}}else if(this.#g()){let c=this.#s();r={name:c.text,pos:c.start,isFinal:n}}else if(n)throw this.#c(this.#y().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.#y().end};return this.#N(o,t)}#G(){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.#Yt(!0):t.text==="-"&&e.kind==="long-literal"&&e.integer?.radix===10&&e.integer.value===9223372036854775808n?this.#Gt(!0):this.#G();return this.#N({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.#G();return this.#N({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.#G();return this.#N({kind:"IncDec",operator:t.text,prefix:!0,operand:e,depth:0,pos:t.start,start:t.start,end:e.end},e)}case"(":if(this.#Jt()){this.#s();let e=this.#m();this.#i(")");let n=this.#G();return this.#N({kind:"Cast",targetType:e,expression:n,depth:0,pos:t.start,start:t.start,end:n.end},n)}break}return this.#u(this.#Qt())}finally{this.#$()}}#Jt(){if(this.#Zt())return!1;let t=this.#r(1);if(t.kind==="keyword"&&Ge.has(t.text))return this.#n(")",2)||this.#n("[",2)&&this.#n("]",3);if(t.kind!=="identifier")return!1;let e=this.#L();try{if(this.#s(),!this.#T()||!this.#h(")"))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")&&ho.has(n.text)}finally{this.#F(e)}}#u(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.#bt();if(o==="diamond")throw this.#c(this.#r().start,"illegal start of type");if(s=o,!this.#g()||!this.#n("(",1))throw this.#c(this.#r().start,"<identifier> expected")}let r=this.#r();if(r.kind==="keyword"&&r.text==="class"){this.#s(),e=this.#N({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.#c(r.start,"<identifier> expected");o.unshift(c.name)}e=this.#N({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.#c(r.start,"<identifier> expected");o.unshift(c.name),c=c.target}this.#s(),e=this.#N({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.#ce();if(o.kind!=="NewObject"||o.classType.kind!=="ClassType"||o.classType.names.length!==1)throw this.#c(r.start,"\'(\' expected");if(o.body)throw this.#C(r.start,"\'.new\' with an anonymous class body",!0);o.outerExpression=e,o.start=e.start,e=this.#N(o,e);continue}if(r.kind==="keyword"&&["this","super"].includes(r.text))throw this.#C(r.start,`\'.${r.text}\' expressions`);let a=this.#w();if(this.#n("(")){let o=this.#r().start,c=this.#Dt();e=this.#N({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.#y().end},e,...c)}else e=this.#N({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.#Me()){let s=this.#St(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.#ct(null,s,e.start)}if(n.text==="["){this.#s();let s=this.#f(),r=this.#i("]");e=this.#N({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.#ct(e,void 0,e.start);if(n.text==="<"&&(e.kind==="Name"||e.kind==="FieldAccess")&&this.#le())throw this.#C(n.start,"method references on a parameterized type (write a lambda)");if(n.text==="++"||n.text==="--"){this.#s(),e=this.#N({kind:"IncDec",operator:n.text,prefix:!1,operand:e,depth:0,pos:n.start,start:e.start,end:n.end},e);continue}return e}}#le(){let t=this.#L();try{return this.#bt()!=="diamond"&&this.#n("::")}catch(e){if(!(e instanceof _t))throw e;return!1}finally{this.#F(t)}}#Me(){let t=0;for(;this.#n("[",t)&&this.#n("]",t+1);)t+=2;return t>0&&this.#n("::",t)}#St(t){let e=[],n=t;for(;n.kind==="FieldAccess";)e.unshift(n.name),n=n.target;if(n.kind!=="Name")throw this.#c(t.pos,"<identifier> expected");return e.unshift(n.identifier),{kind:"ClassType",names:e,hasTypeArguments:!1,pos:t.pos,start:t.start,end:t.end}}#ct(t,e,n){let s=this.#i("::"),r=this.#r();if(r.kind==="operator"&&r.text==="<")throw this.#C(r.start,"explicit type arguments in method references");if(!(r.kind==="identifier"||r.kind==="keyword"&&r.text==="new"))throw this.#c(r.start,"<identifier> expected");if(this.#s(),e&&r.text!=="new")throw this.#c(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}}#Nt(t){let e=this.#W;this.#W=!1;try{return t()}finally{this.#W=e}}#Dt(){this.#i("(");let t=[];if(!this.#n(")"))do t.push(this.#Nt(()=>this.#f()));while(this.#h(","));return this.#i(")"),t}#Yt(t){let e=this.#s(),{value:n,radix:s}=e.integer,r;if(s===10){if(n>2147483648n||n===2147483648n&&!t)throw new _t({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 _t({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}}#Gt(t){let e=this.#s(),{value:n,radix:s}=e.integer;if(s===10?n>9223372036854775808n||n===9223372036854775808n&&!t:n>0xffffffffffffffffn)throw new _t({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}}#Qt(){let t=this.#r(),e=(n,s)=>(this.#s(),{kind:"Literal",literalKind:n,value:s,depth:1,pos:t.start,start:t.start,end:t.end});switch(t.kind){case"int-literal":return this.#Yt(!1);case"long-literal":return this.#Gt(!1);case"float-literal":case"double-literal":{let n=t.kind==="float-literal",s=n?Ei(t.text):Ii(t.text);if("error"in s)throw new _t({offset:t.start,code:"fp-number-out-of-range",message:s.error==="too-large"?"floating-point number too large":"floating-point number too small"});return this.#s(),{kind:"Literal",literalKind:n?"float":"double",value:s.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.#W)return this.#s(),this.#jt(t.start,[{name:t.text,pos:t.start,type:null}]);if(this.#s(),this.#n("(")){let n=this.#r().start,s=this.#Dt();return this.#N({kind:"MethodCall",target:null,name:t.text,namePos:t.start,selectPos:t.start,args:s,depth:0,pos:n,start:t.start,end:this.#y().end},...s)}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.#C(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.#C(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.#ce();case"switch":{this.#s();let n=this.#r().start,s=this.#Q(),{cases:r,end:a}=this.#e(!0);return this.#N({kind:"SwitchExpression",selector:s,selectorPos:n,cases:r,depth:0,pos:t.start,start:t.start,end:a},s)}}if(Ge.has(t.text)&&this.#n("[",1)&&this.#n("]",2)){this.#s();let n={kind:"PrimitiveType",name:t.text,pos:t.start,start:t.start,end:t.end};for(;this.#n("[")&&this.#n("]",1);){this.#s();let s=this.#i("]");n={kind:"ArrayType",element:n,pos:n.pos,start:n.start,end:s.end}}if(this.#n("::"))return this.#ct(null,n,t.start)}if(Ge.has(t.text)||t.text==="void")throw this.#C(t.start,"class literals");break;case"operator":if(t.text==="("){if(!this.#W&&this.#Zt())return this.#Tt();this.#s();let n=this.#Nt(()=>this.#f()),s=this.#i(")");return this.#N({kind:"Parenthesized",expression:n,depth:0,pos:t.start,start:t.start,end:s.end},n)}break;case"eof":this.#H()}throw this.#c(t.start,"illegal start of expression")}#ce(){let t=this.#i("new"),e=this.#r(),n;if(e.kind==="keyword"&&Ge.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.#g(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.#bt();if(h==="diamond"?u=!0:c=h,!this.#n("(")&&u)throw this.#C(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.#y().end},this.#n("(")){let h=this.#Dt(),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.#_(m),this.#$()}return this.#N({kind:"NewObject",classType:n,args:h,...m?{body:m}:{},depth:0,pos:t.start,start:t.start,end:this.#y().end},...h)}}else throw this.#c(e.start,"<identifier> expected");if(!this.#n("["))throw this.#c(this.#y().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.#c(this.#y().end,"array dimension missing");let o=this.#st();return this.#N({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.#c(this.#r().start,"\']\' expected");this.#s(),s.push(this.#f()),this.#i("]")}if(this.#n("{"))throw this.#c(this.#r().start,"\';\' expected");return this.#N({kind:"NewArray",elementType:n,dimensions:s,extraDims:r,initializer:null,depth:0,pos:t.start,start:t.start,end:this.#y().end},...s)}#Tt(){let t=this.#i("("),e=[];if(!this.#n(")"))do{if(this.#g()&&(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.#g(0,"var")&&this.#g(1)){this.#s();let d=this.#w();if(this.#n("["))throw this.#c(d.start,"\'var\' is not allowed as an element type of an array");e.push({name:d.text,pos:d.start,type:null,isVar:!0,...o?{modifiers:o}:{}});continue}let c=this.#m(),u=this.#w();e.push({name:u.text,pos:u.start,type:c,...o?{modifiers:o}:{}})}while(this.#h(","));this.#i(")");let n=e.filter(r=>r.isVar).length;if(n&&n<e.length){let r=e.some(a=>a.type);throw new _t({offset:t.start,code:"syntax",message:"invalid lambda parameter declaration",details:[r?" (cannot mix \'var\' and explicitly-typed parameters)":" (cannot mix \'var\' and implicitly-typed parameters)"]})}let s=e.filter(r=>r.type).length;if(s&&s<e.length-n)throw new _t({offset:t.start,code:"syntax",message:"invalid lambda parameter declaration",details:[" (cannot mix implicitly-typed and explicitly-typed parameters)"]});return this.#jt(t.start,e)}#jt(t,e){if(this.#i("->"),this.#n("{")){let s=this.#ft();return{kind:"Lambda",params:e,body:s,depth:1,pos:t,start:t,end:s.end}}let n=this.#f();return this.#N({kind:"Lambda",params:e,body:n,depth:0,pos:t,start:t,end:n.end},n)}#Zt(){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}}}};function ps(i){if(i.kind==="MethodRef")return rt(i);let t=i.kind==="Lambda"?Pi(i):rt(i);return t.length>=20?`${t.slice(0,10)}[...]${t.slice(-5)}`:t}function Pi(i){let t=i.params.every(n=>!n.type)?i.params.map(n=>n.name).join(","):i.params.map(n=>`${se(n.type)} ${n.name}`).join(", "),e=i.body.kind==="Block"?Ri(i.body.statements):rt(i.body);return`(${t})->${e}`}function se(i){switch(i.kind){case"PrimitiveType":return i.name;case"ClassType":return i.names.join(".")+(i.typeArguments?`<${i.typeArguments.map(se).join(",")}>`:i.diamond?"<>":"");case"ArrayType":return`${se(i.element)}[]`;case"WildcardType":return i.bound?`? ${i.isSuper?"super":"extends"} ${se(i.bound)}`:"?";case"VoidType":return"void";case"VarType":return"var"}}function Mi(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 rt(i){switch(i.kind){case"Literal":switch(i.literalKind){case"long":return`${i.value}L`;case"double":return le(i.value);case"float":return`${le(parseFloat(String(i.value)))}F`;case"char":return Mi(i.value,"\'");case"string":case"text-block":return Mi(i.value,\'"\');default:return String(i.value)}case"Name":return i.identifier;case"FieldAccess":return`${rt(i.target)}.${i.name}`;case"MethodCall":return`${i.target?rt(i.target)+".":""}${i.name}(${i.args.map(rt).join(", ")})`;case"Unary":return i.operator+rt(i.operand);case"IncDec":return i.prefix?i.operator+rt(i.operand):rt(i.operand)+i.operator;case"Binary":return`${rt(i.left)} ${i.operator} ${rt(i.right)}`;case"Assignment":return`${rt(i.target)} ${i.operator} ${rt(i.value)}`;case"Parenthesized":return`(${rt(i.expression)})`;case"ArrayAccess":return`${rt(i.array)}[${rt(i.index)}]`;case"NewArray":{let t=i.dimensions.map(e=>`[${rt(e)}]`).join("")+"[]".repeat(i.extraDims);return i.initializer?`new ${se(i.elementType)}${"[]".repeat(Math.max(1,i.extraDims))}{${i.initializer.elements.map(e=>e.kind==="ArrayInitializer"?"{...}":rt(e)).join(", ")}}`:`new ${se(i.elementType)}${t}`}case"Cast":return`(${se(i.targetType)})${rt(i.expression)}`;case"This":return"this";case"NewObject":return`${i.outerExpression?`${rt(i.outerExpression)}.`:""}new ${se(i.classType)}(${i.args.map(rt).join(", ")})`;case"Conditional":return`${rt(i.condition)} ? ${rt(i.whenTrue)} : ${rt(i.whenFalse)}`;case"SwitchExpression":return`switch (${rt(i.selector)}) {...}`;case"Lambda":return Pi(i);case"MethodRef":return`${i.arrayType?se(i.arrayType):i.target?rt(i.target):""}::${i.name}`;case"InstanceOf":return`${rt(i.expression)} instanceof ${se(i.targetType)}${i.binding?` ${i.binding.name}`:""}`;case"Super":return"super";case"ClassLiteral":return`${rt(i.target)}.class`}}function Ri(i){return i.length?`{ ${i.map(Ke).join(" ")} }`:"{ }"}function Ke(i){switch(i.kind){case"Block":return Ri(i.statements);case"ReturnStatement":return i.value?`return ${rt(i.value)};`:"return;";case"ExpressionStatement":return`${rt(i.expression)};`;case"LocalVariableDeclaration":return`${se(i.type)} ${i.declarators.map(t=>t.init&&t.init.kind!=="ArrayInitializer"?`${t.name} = ${rt(t.init)}`:t.name).join(", ")};`;case"IfStatement":return`if (${rt(i.condition)}) ${Ke(i.then)}${i.otherwise?` else ${Ke(i.otherwise)}`:""}`;case"WhileStatement":return`while (${rt(i.condition)}) ${Ke(i.body)}`;case"DoStatement":return`do ${Ke(i.body)} while (${rt(i.condition)});`;case"ForStatement":return`for (...) ${Ke(i.body)}`;case"ForEachStatement":return`for (${se(i.type)} ${i.name} : ${rt(i.iterable)}) ${Ke(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 ${rt(i.value)};`;default:return"..."}}var $t={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",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"},dn=class extends Error{constructor(){super("the Java library chunk is needed"),this.name="NeedsLibrary"}},mn=null;function Ji(i){mn=i}function fn(){return mn}function ce(i){if(i in $t){if(!mn)throw new dn;return mn.classes.get(i)}}function Wt(i){if(!mn)throw new dn;return mn.classes.get(i)}var U={tag:"int"},Mn={tag:"byte"},gn={tag:"short"},we={tag:"char"},ft={tag:"boolean"},Lt={tag:"long"},xt={tag:"float"},ht={tag:"double"},St={tag:"void"},cr={tag:"null"},ut={tag:"string"},H={tag:"object"},Fi={tag:"printstream"},E={tag:"error"};function Yt(i){return{tag:"array",element:i}}function X(i,t){return t?.length?{tag:"class",name:i.displayName,symbol:i,args:t}:{tag:"class",name:i.displayName,symbol:i}}function ke(i){return{tag:"typevar",name:i.name,symbol:i}}function ue(i){return X(i,i.typeParams?.map(ke))}function ys(i){return i.symbol?.key??i.name}function lr(i){return i.symbol?.bounds[0]??H}function Ht(i,t){if(!t.size)return i;switch(i.tag){case"typevar":return t.get(ys(i))??i;case"array":return Yt(Ht(i.element,t));case"library":return i.args.length?dt(i.symbol,i.args.map(e=>Ht(e,t))):i;case"class":return i.args?.length?X(i.symbol,i.args.map(e=>Ht(e,t))):i;case"wildcard":return i.bound?{...i,bound:Ht(i.bound,t)}:i;default:return i}}function Pn(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 Rn(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(lr(i)):H;case"wildcard":return H;case"array":return Yt(W(i.element));case"library":return i.args.length?dt(i.symbol):i;case"class":return i.args?.length?X(i.symbol):i;default:return i}}function Jn(i){let t=i.symbol,e=[];if(t.superType?e.push(t.superType):t.superclass?e.push(X(t.superclass)):t.librarySuperclass&&e.push(t.librarySuperclass),t.interfaceTypes?e.push(...t.interfaceTypes):e.push(...t.interfaces.map(s=>X(s))),e.push(...t.libraryInterfaces),!t.typeParams?.length)return e;if(!i.args?.length)return e.map(W);let n=Pn(i);return e.map(s=>Ht(s,n))}function Zt(i,t){if(i.tag==="typevar"&&i.symbol){for(let e of i.symbol.bounds){let n=Zt(e,t);if(n)return n}return null}if(i.tag!=="class")return null;if(i.symbol===t)return i;for(let e of Jn(i)){let n=Zt(e,t);if(n)return n}return null}function Ae(i,t=new Set){if(t.has(i.symbol))return[];t.add(i.symbol);let e=[];for(let n of Jn(i))n.tag==="library"?e.push(n):n.tag==="class"&&e.push(...Ae(n,t));return e}function Ie(i,t,e){if(!t.typeParams?.length)return e;let n=Zt(i,t);return n?n.args?.length?Ht(e,Pn(n)):W(e):e}function dt(i,t=[]){return{tag:"library",symbol:i,args:t}}function Tt(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]:H}case"array":return Yt(Tt(i.element,t,e));case"library":return i.args.length?dt(i.symbol,i.args.map(n=>Tt(n,t,e))):i;case"wildcard":return i.bound?{...i,bound:Tt(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 Yt(Xt(i.element,t,e));case"library":return i.args.length?dt(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 ur(i){return i.symbol.supertypes.map(t=>Tt(t,i.symbol.typeParams,i.args))}function Pt(i,t){if(i.tag!=="library")return null;if(i.symbol===t)return i;for(let e of ur(i)){let n=Pt(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?fn()?.classes.get(t):void 0;return e?dt(e):null}function yt(i){return i.tag!=="library"||!i.symbol.box?null:{int:U,long:Lt,double:ht,char:we,boolean:ft,float:xt,byte:Mn,short:gn}[i.symbol.box]}function M(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 M(i.element)+"[]";case"class":return i.args?.length?`${i.name}<${i.args.map(M).join(",")}>`:i.name;case"library":return i.args.length?`${i.symbol.name}<${i.args.map(M).join(",")}>`:i.symbol.name;case"diamond":return`${i.symbol.name}<>`;case"typevar":return i.name;case"wildcard":return i.poly&&i.bound?M(i.bound):i.bound?`? ${i.isSuper?"super":"extends"} ${M(i.bound)}`:"?";case"lambda":return i.text;case"error":return"<any>"}}function et(i,t){if(i.tag!==t.tag)return!1;if(i.tag==="array"&&t.tag==="array")return et(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)=>et(s,n[r]))}return i.tag==="wildcard"&&t.tag==="wildcard"?i.isSuper===t.isSuper&&(i.bound===null?t.bound===null:t.bound!==null&&et(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)=>et(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 tt(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 Q(i){return["int","byte","short","char","boolean","long","float","double"].includes(i.tag)}function Ot(i){return["int","byte","short","char","long","float","double"].includes(i.tag)}var Di={byte:0,short:1,char:1,int:2,long:3,float:4,double:5};function mo(i,t){return!Ot(i)||!Ot(t)||i.tag==="char"||t.tag==="char"&&i.tag==="short"?!1:Di[t.tag]<Di[i.tag]}function pn(i,t){return i===t||i.superclass&&pn(i.superclass,t)?!0:i.interfaces.some(e=>pn(e,t))}function yn(i,t=new Set){if(t.has(i))return[];t.add(i);let e=[...i.libraryInterfaces];i.superclass&&e.push(...yn(i.superclass,t));for(let n of i.interfaces)e.push(...yn(n,t));return e}var Dn={tag:"typevar",name:"?open"};function or(i,t){let e=t.args??[];return!i.args?.length&&e.length?!1:(i.args??[]).every((n,s)=>{let r=e[s];if(n===Dn||!r)return!0;let a=n.tag==="wildcard"&&n.poly&&n.bound?n.bound:n;return a!==n&&r.tag!=="wildcard"?z(a,r):r.tag==="wildcard"?r.bound?a.tag==="wildcard"?r.isSuper?a.isSuper===!0&&a.bound!==null&&z(r.bound,a.bound):a.isSuper?r.bound.tag==="object":z(a.bound??H,r.bound):r.isSuper?z(r.bound,a):z(a,r.bound):!0:et(a,r)})}function z(i,t){if(et(i,t))return!0;if(i.tag==="null")return tt(t);if(t.tag==="object")return tt(i);if(i.tag==="array"&&t.tag==="array")return tt(i.element)&&tt(t.element)&&z(i.element,t.element);if(i.tag==="typevar"&&i.symbol)return i.symbol.bounds.some(s=>z(s,t));if(i.tag==="class"&&t.tag==="class"){let s=Zt(i,t.symbol);return s?t.args?.length?(s.args?.length??0)>0&&or(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||et(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?z(s.bound,i):z(i,s.bound)))}if(i.tag==="class"&&t.tag==="library")return Ae(i).some(s=>{let r=Pt(s,t.symbol);return r!==null&&or(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||et(s,i)||s.tag==="wildcard"&&(!s.bound||(s.isSuper?z(s.bound,i):z(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 Pt(dt(i.symbol,i.symbol.typeParams.map(()=>H)),t.symbol)!==null;let n=Pt(i,t.symbol);return n?or(n,t):!1}function fo(i){return i.box!==void 0||i.name==="StringBuilder"||i.name==="StringBuffer"||i.name==="StringJoiner"||i.name==="Scanner"}function ji(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&&fo(i.symbol)};case"string":return{interface:!1,final:!0};default:return null}}function ve(i,t){if(z(t,i)||z(i,t))return!0;if(i.tag==="typevar"&&i.symbol)return ve(lr(i),t);if(t.tag==="typevar"&&t.symbol)return ve(i,lr(t));if(i.tag==="array"&&t.tag==="array")return tt(i.element)&&tt(t.element)?ve(i.element,t.element):et(i.element,t.element);let e=ji(i),n=ji(t);return!e||!n?!1:e.interface&&n.interface?!0:e.interface?!n.final:n.interface?!e.final:!1}function qe(i,t){return i.tag==="error"||t.tag==="error"?!0:t.tag==="lambda"?Ui(i,t)===null:et(i,t)||mo(i,t)?!0:tt(i)&&z(t,i)}function he(i,t){if(qe(i,t))return!0;if(Q(t)&&tt(i)){if(i.tag==="object")return!0;let n=Qt(t);return n!==null&&z(n,i)}let e=yt(t);return e!==null&&Q(i)&&qe(i,e)}var po={byte:[-128,127],short:[-32768,32767],char:[0,65535]};function te(i,t,e){if(he(i,t))return!0;let n=i.tag==="library"?i.symbol.box:i.tag,s=n?po[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 yo(i){if(i.tag==="class"&&i.symbol.isInterface&&!i.symbol.isSealed){let n=gs(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??H:r:H});return{params:t.params.map(n=>Tt(n,i.symbol.typeParams,e)),returnType:Tt(t.returnType,i.symbol.typeParams,e)}}function _i(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 _i(i.element)+"[]";default:return i.tag}}function gs(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(_i).join(",")})`;t.has(o)||(t.add(o),a.isAbstract&&e.push(a))}n.push(...r.interfaces)}return e}function Ui(i,t){if(i.tag==="error")return null;let e=yo(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:M(i)} is not a functional interface`}function Je(i,t){return t.tag==="lambda"?Ui(i,t)??"":Ot(i)&&Ot(t)?`possible lossy conversion from ${M(t)} to ${M(i)}`:`${M(t)} cannot be converted to ${M(i)}`}function Rt(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"["+Rt(i.element);case"typevar":return Rt(W(i));default:throw new Error(`codegen: descriptor of ${M(i)}`)}}function jn(i){switch(i.kind){case"int":case"byte":case"short":case"long":return String(i.value);case"double":return le(i.value);case"float":return Re(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";case"string":return i.value}}function K(i){return{kind:"int",value:i|0}}function Fn(i){return{kind:"char",value:i&65535}}function Jt(i){return{kind:"long",value:BigInt.asIntN(64,i)}}function bs(i){return{kind:"byte",value:i<<24>>24}}function Ss(i){return{kind:"short",value:i<<16>>16}}function de(i){return{kind:"float",value:Math.fround(i)}}function ee(i){return{kind:"double",value:i}}function gt(i){return{kind:"boolean",value:i}}function hr(i){return{kind:"string",value:i}}var dr=new Set(["int","byte","short","char"]);function bn(i){return dr.has(i.kind)?i.value:void 0}function Sn(i){if(i.kind==="long")return i.value;if(dr.has(i.kind))return BigInt(i.value)}function _n(i){if(i.kind==="double"||i.kind==="float")return i.value;if(i.kind==="long")return ms(wt(i.value));if(dr.has(i.kind))return i.value}function Ts(i){if(i.kind==="long")return hn(wt(i.value));let t=_n(i);return t===void 0?void 0:Math.fround(t)}function Bi(i,t){if(i.kind==="boolean"||i.kind==="string")return;let e=()=>i.kind==="double"||i.kind==="float"?$n(i.value):i.kind==="long"?ds(wt(i.value)):i.value;switch(t){case"double":return ee(_n(i));case"float":return de(Ts(i));case"long":return i.kind==="double"||i.kind==="float"?Jt(BigInt(Nn(i.value))):Jt(Sn(i));case"int":return K(e());case"byte":return bs(e());case"short":return Ss(e());case"char":return Fn(e())}}function Un(i){return i!==void 0&&i.kind==="boolean"&&i.value}function xs(i){return i!==void 0&&i.kind==="boolean"&&!i.value}var re=["none","message","message-cause","cause"],zt=["none","message"],go=[["java.lang.Throwable",null,re],["java.lang.Exception","java.lang.Throwable",re],["java.lang.Error","java.lang.Throwable",re],["java.lang.RuntimeException","java.lang.Exception",re],["java.lang.ArithmeticException","java.lang.RuntimeException",zt],["java.lang.ArrayStoreException","java.lang.RuntimeException",zt],["java.lang.ClassCastException","java.lang.RuntimeException",zt],["java.lang.IllegalArgumentException","java.lang.RuntimeException",re],["java.lang.IllegalStateException","java.lang.RuntimeException",re],["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",zt],["java.lang.NullPointerException","java.lang.RuntimeException",zt],["java.lang.NumberFormatException","java.lang.IllegalArgumentException",zt],["java.lang.UnsupportedOperationException","java.lang.RuntimeException",re],["java.lang.CloneNotSupportedException","java.lang.Exception",zt],["java.lang.InterruptedException","java.lang.Exception",zt],["java.lang.ReflectiveOperationException","java.lang.Exception",re],["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",zt],["java.lang.NoClassDefFoundError","java.lang.LinkageError",zt],["java.lang.VirtualMachineError","java.lang.Error",re],["java.lang.StackOverflowError","java.lang.VirtualMachineError",zt],["java.lang.OutOfMemoryError","java.lang.VirtualMachineError",zt],["java.util.NoSuchElementException","java.lang.RuntimeException",re],["java.util.InputMismatchException","java.util.NoSuchElementException",zt],["java.util.ConcurrentModificationException","java.lang.RuntimeException",re],["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",re],["java.io.FileNotFoundException","java.io.IOException",zt],["java.io.EOFException","java.io.IOException",zt],["java.io.UncheckedIOException","java.lang.RuntimeException",["message-cause","cause"]]],Tn=go.map(([i,t,e,n])=>({name:i,superclass:t,constructors:e,...n?{indexPrefix:n}:{}})),mt={message:0,cause:1,trace:2,suppressed:3,causeSet:4},Vi=5;function Hi(i){let t=i.lastIndexOf(".");return{pkg:i.slice(0,t),simple:i.slice(t+1)}}var Bn=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"]),bo=new Set(["printf","format","flush","write","append","close","checkError","writeBytes","charset"]),zi=new Set(["currentTimeMillis","nanoTime","exit","arraycopy","getProperty","getProperties","setProperty","clearProperty","lineSeparator","identityHashCode","getenv","gc","setOut","setErr","setIn","console","inheritedChannel","getLogger","load","loadLibrary","mapLibraryName","runFinalization"]),So=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"]),To=new Set(["name","ordinal","compareTo","equals","hashCode","getDeclaringClass"]),xo=new Set(["clone","getClass","hashCode","equals","toString","wait","notify","notifyAll"]),vs={Pattern:{UNIX_LINES:{type:U,constant:K(1)},CASE_INSENSITIVE:{type:U,constant:K(2)},COMMENTS:{type:U,constant:K(4)},MULTILINE:{type:U,constant:K(8)},LITERAL:{type:U,constant:K(16)},DOTALL:{type:U,constant:K(32)},UNICODE_CASE:{type:U,constant:K(64)},CANON_EQ:{type:U,constant:K(128)},UNICODE_CHARACTER_CLASS:{type:U,constant:K(256)}},Integer:{MAX_VALUE:{type:U,constant:K(2147483647)},MIN_VALUE:{type:U,constant:K(-2147483648)},SIZE:{type:U,constant:K(32)},BYTES:{type:U,constant:K(4)}},Long:{MAX_VALUE:{type:Lt,constant:Jt(er)},MIN_VALUE:{type:Lt,constant:Jt(nr)},SIZE:{type:U,constant:K(64)},BYTES:{type:U,constant:K(8)}},Double:{MAX_VALUE:{type:ht,constant:ee(Number.MAX_VALUE)},MIN_VALUE:{type:ht,constant:ee(Number.MIN_VALUE)},MIN_NORMAL:{type:ht,constant:ee(22250738585072014e-324)},POSITIVE_INFINITY:{type:ht,constant:ee(1/0)},NEGATIVE_INFINITY:{type:ht,constant:ee(-1/0)},NaN:{type:ht,constant:ee(NaN)},SIZE:{type:U,constant:K(64)},BYTES:{type:U,constant:K(8)}},Float:{MAX_VALUE:{type:xt,constant:de(34028234663852886e22)},MIN_VALUE:{type:xt,constant:de(1401298464324817e-60)},MIN_NORMAL:{type:xt,constant:de(11754943508222875e-54)},POSITIVE_INFINITY:{type:xt,constant:de(1/0)},NEGATIVE_INFINITY:{type:xt,constant:de(-1/0)},NaN:{type:xt,constant:de(NaN)},MAX_EXPONENT:{type:U,constant:K(127)},MIN_EXPONENT:{type:U,constant:K(-126)},SIZE:{type:U,constant:K(32)},BYTES:{type:U,constant:K(4)}},Byte:{MAX_VALUE:{type:Mn,constant:bs(127)},MIN_VALUE:{type:Mn,constant:bs(-128)},SIZE:{type:U,constant:K(8)},BYTES:{type:U,constant:K(1)}},Short:{MAX_VALUE:{type:gn,constant:Ss(32767)},MIN_VALUE:{type:gn,constant:Ss(-32768)},SIZE:{type:U,constant:K(16)},BYTES:{type:U,constant:K(2)}},Character:{MAX_VALUE:{type:we,constant:Fn(65535)},MIN_VALUE:{type:we,constant:Fn(0)},MIN_RADIX:{type:U,constant:K(2)},MAX_RADIX:{type:U,constant:K(36)},SIZE:{type:U,constant:K(16)},BYTES:{type:U,constant:K(2)}},Math:{PI:{type:ht,constant:ee(Math.PI)},E:{type:ht,constant:ee(Math.E)}},StreamTokenizer:{TT_EOF:{type:U,constant:K(-1)},TT_EOL:{type:U,constant:K(10)},TT_NUMBER:{type:U,constant:K(-2)},TT_WORD:{type:U,constant:K(-3)}}},Vn={abs:[{params:[U],returnType:U,fn:"abs-int"},{params:[Lt],returnType:Lt,fn:"abs-long"},{params:[xt],returnType:xt,fn:"abs-float"},{params:[ht],returnType:ht,fn:"abs-double"}],max:[{params:[U,U],returnType:U,fn:"max-int"},{params:[Lt,Lt],returnType:Lt,fn:"max-long"},{params:[xt,xt],returnType:xt,fn:"max-float"},{params:[ht,ht],returnType:ht,fn:"max-double"}],min:[{params:[U,U],returnType:U,fn:"min-int"},{params:[Lt,Lt],returnType:Lt,fn:"min-long"},{params:[xt,xt],returnType:xt,fn:"min-float"},{params:[ht,ht],returnType:ht,fn:"min-double"}],sqrt:[{params:[ht],returnType:ht,fn:"sqrt"}],floor:[{params:[ht],returnType:ht,fn:"floor"}],ceil:[{params:[ht],returnType:ht,fn:"ceil"}],round:[{params:[xt],returnType:U,fn:"round-float"},{params:[ht],returnType:Lt,fn:"round-double"}]},Gi=i=>i.target?.kind==="Name"&&i.target.staticOwner===!0,Hn=i=>i.tag==="int"||i.tag==="char"||i.tag==="long"||i.tag==="byte"||i.tag==="short",Ki=i=>i.tag==="char"||i.tag==="byte"||i.tag==="short"?U:i;function Wn(i,t){return i.tag==="double"||t.tag==="double"?ht:i.tag==="float"||t.tag==="float"?xt:i.tag==="long"||t.tag==="long"?Lt:U}var ws=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"]),la=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"]),ks={"java.util":[...la].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":["LocalTime","LocalDateTime","ZonedDateTime","Instant","Duration","Year","YearMonth","ZoneId","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"]},qi={private:0,package:1,protected:2,public:3},vo={Comparable:["compareTo"],Comparator:["compare"],Iterable:["iterator"],Iterator:["hasNext","next"]},Wi=new Set(["ArrayList","LinkedList","HashMap","LinkedHashMap","TreeMap","HashSet","LinkedHashSet","TreeSet","ArrayDeque","PriorityQueue","AbstractList"]),wo={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)"]},ko={"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(String,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)"]},Co=["size()","get(int)","get(Object)","containsKey(Object)"],Eo={"java.util.regex.PatternSyntaxException":["getDescription","getIndex","getPattern"],"java.time.format.DateTimeParseException":["getParsedString","getErrorIndex"]},Xi=new Set(["toString()","equals(Object)","hashCode()"]),Ao=new Set(["Comparable","Comparator","Iterable","Iterator"]);function Yi(i){return Ao.has(i.name)||i.functional!==void 0}var Cs=new Set(["getClass","wait","notify","notifyAll","clone","finalize"]),Qi=[ft,we,U,Lt,xt,ht,Yt(we),ut,H];function Io(i){return(i==="println"?[[],...Qi.map(e=>[e])]:Qi.map(e=>[e])).map(e=>({owner:"PrintStream",name:i,params:e,returnType:St}))}var zn={length:{owner:"String",name:"length",params:[],returnType:U},charAt:{owner:"String",name:"charAt",params:[U],returnType:we},equals:{owner:"String",name:"equals",params:[H],returnType:ft},isEmpty:{owner:"String",name:"isEmpty",params:[],returnType:ft},toCharArray:{owner:"String",name:"toCharArray",params:[],returnType:Yt(we)},compareTo:{owner:"String",name:"compareTo",params:[ut],returnType:U}},Oe={toString:{owner:"Object",name:"toString",params:[],returnType:ut,objectMethod:"toString"},hashCode:{owner:"Object",name:"hashCode",params:[],returnType:U,objectMethod:"hashCode"},equals:{owner:"Object",name:"equals",params:[H],returnType:ft,objectMethod:"equals"}},mr=()=>({all:!1,vars:new Set,unassigned:new Set}),Gt=()=>({all:!0,vars:new Set,unassigned:new Set}),je=i=>({all:i.all,vars:new Set(i.vars),unassigned:new Set(i.unassigned)});function vt(i,...t){let e=i;for(let n of t){if(e.all){e=je(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 Oo(i,t){if(i.all||t.all)return i.all?je(t.all?i:t):je(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 xn(i,t){return i.all||i.vars.has(t)}function Gn(i,t){return i.all||i.unassigned.has(t)}function Le(i,t){if(i.all)return i;let e=je(i);return e.vars.add(t),e.unassigned.delete(t),e}function Lo(i,t){if(i.all)return i;let e=je(i);return e.vars.delete(t),e}function Zi(i){return i.kind==="LocalVariableDeclaration"?i.declarators[0].pos:i.start}function it(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}var Vt=(i,t)=>i.keywords.some(e=>e.name===t),Yn=class extends Error{fileName;constructor(t){super(`needs ${t}`),this.fileName=t}},Ze=class extends Error{};function ca(i,t,e={}){return new yr(i[0].file,t,e.available??new Set).checkUnits(i,e.launch??!0)}var ta=(i,t,e)=>({file:i,launch:t,compact:e,imported:new Set,onDemand:new Set,staticSingle:new Map,staticOnDemand:[],unsupportedStaticSingle:new Map,unsupportedStaticOnDemand:[],unsupportedImports:new Map}),yr=class{#O;#dt=new WeakMap;#Mt;#D;#j=[];#W=[];#z=[];get#r(){return this.#O.file}get#y(){return this.#O.imported}get#s(){return this.#O.onDemand}get#n(){return this.#O.staticSingle}get#g(){return this.#O.staticOnDemand}get#h(){return this.#O.unsupportedStaticSingle}get#i(){return this.#O.unsupportedStaticOnDemand}get#w(){return this.#O.unsupportedImports}#H=[];#c=new Map;#C=new Map;#L=[];#F=!1;#K=0;#mt=!1;#bt=null;#it;#$=[];#N=new Map;#gt;get#a(){return this.#gt}set#a(t){this.#gt=t;let e=t?this.#dt.get(t.topLevel):void 0;e&&(this.#O=e)}#l=null;#E=null;#et=null;#Xt=new Map;#_=!0;#M=[];#k=0;#P=[];#Bt=!1;#R=!1;#t=null;#p="";#d=new Map;#J=[];#m=[];#T=[];#ft=new Map;#Pt=[];#A=new Set;#Et=new WeakMap;#Y=[];#Rt=new Map;#Vt=new Map;#I=[];#X=[];#x=new Map;#U=new Map;#tt=0;#Q=[];constructor(t,e,n){this.#O=ta(t,!0,!1),this.#Mt=n,this.#D=e}#e(t,e,n,s){this.#D.error(this.#r,t,"type",e,n,s)}#nt(t,e,n,s){let r=a=>a!==void 0&&a.has(e);for(let a=this.#a??null;a;a=a.outer)if(r(a.suppressed))return;r(this.#it)||this.#$.some(r)||this.#D.warning(this.#r,t,e,`[${e}] ${n}`,s)}#pt(t,e){let n=this.#N.get(t);if(n)return n;let s=new Set;this.#N.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.#me(o.name):o.names.join(".")===`java.lang.${o.name}`))){o.names.length===1&&!this.#me(o.name)&&!Bn.has(o.name)&&!this.#w.has(o.name)?this.#e(o.namePos,v.cantResolve,"cannot find symbol",[` symbol: class ${o.name}`,` location: class ${this.#a.displayName}`]):this.#o(o.pos,`the annotation @${o.names.join(".")}`,!0);continue}if(r.has(o.name)){this.#e(o.pos,v.syntax,`${o.name} is not a repeatable annotation interface`);continue}if(r.add(o.name),!a[o.name].includes(e)){this.#e(o.pos,v.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.#o(o.pos,"elements of @SuppressWarnings other than value"):this.#e(o.pos,v.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,v.incompatibleTypes,`incompatible types: ${h.literalKind} cannot be converted to String`):this.#o(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.#o(o.pos,"these elements of @Deprecated"):u.length&&this.#o(o.pos,`elements of @${o.name}`)}return s}#At(t,e){return t.annotations?.find(n=>n.name===e)}#o(t,e,n=!1){this.#e(t,v.unsupported,`${e} ${n?"is":"are"} not supported in this version`)}checkUnits(t,e=!0){if(!t[0].unit.types.length)return this.#D.launchError(this.#r.name,v.noMain,"no class declared in source file"),null;let s=this.#O,r=[];t.forEach(({unit:c,file:u},d)=>{let h=c.types[0]?.implicit===!0,m=d===0?s:ta(u,!1,h);m.compact=h,this.#O=m,d>0&&h&&r.push({declaration:c.types[0],file:u});for(let k of c.imports)this.#oe(k);if(h)for(let k of Object.keys(ks))this.#St(k);let p=this.#W.length;for(let k of c.types)this.#Nt(k,null);for(let k of this.#W.slice(p))k.file=u,this.#dt.set(k,m);if(d>0&&!h){let k=u.name.replace(/\\.java$/,"");if(!this.#W.slice(p).some(T=>T.name===k))throw new Ze(`${u.name} does not declare class ${k}, so the launcher cannot find that class there`)}}),this.#O=s,this.#Qt();for(let c of this.#j)!c.typeParams||c.local||(this.#a=c,this.#F=!1,this.#cn(c.typeParams,c.declaration.typeParams));let a=c=>c.anonymous===!0||c.local===!0||c.outer!==null&&a(c.outer);for(let c of this.#j)a(c)||this.#ue(c);this.#Pe(this.#j.filter(c=>!a(c)));for(let c of this.#j)a(c)||this.#Je(c);this.#ze();let o=this.#W[0];for(let{declaration:c,file:u}of r){let d=c.symbol;if(this.#a=d,!this.#Ht(d))return this.#e(c.members[0].start,v.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;throw new Ze(`${u.name} is a compact source file; only the launched file may be one`)}if(o&&(this.#a=o),o?.declaration.implicit&&!this.#Ht(o))return this.#e(o.declaration.members[0].start,v.noMain,"compact source file does not have main method in the form of void main() or void main(String[] args)"),null;for(let c of this.#W)this.#De(c),this.#D.hasErrors||this.#Fr(c);return this.#D.hasErrors||!o?null:e?this.#$e(o):{classes:this.#j,mainClass:o,methods:this.#z,staticFields:this.#H,selectors:this.#C,main:null,mainConstructor:null}}#$e(t){let e=this.#r.name.replace(/^.*[\\\\/]/,"").replace(/\\.java$/,""),n=this.#Ht(t)?t:this.#W.find(a=>a.name===e&&a.file===t.file);if(!n)return this.#D.launchError(this.#r.name,v.noMain,`can\'t find class: ${e}`),null;let s=this.#Ht(n);if(!s)return this.#D.launchError(this.#r.name,v.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.#D.launchError(this.#r.name,v.noMain,`can\'t find no argument constructor in class: ${n.name}`),null):{classes:this.#j,mainClass:n,methods:this.#z,staticFields:this.#H,selectors:this.#C,main:s,mainConstructor:r}}#Ht(t){let e=t.methods.filter(n=>this.#ve(n.declaration));return e.find(n=>n.params.length===1)??e.find(n=>n.params.length===0)??null}#ve(t){if(t.isConstructor||t.name!=="main"||t.returnType.kind!=="VoidType"||Vt(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.#ae(e.element)}#ae(t){if(t.kind!=="ClassType"||t.hasTypeArguments)return!1;let e=t.names.join(".");return e==="String"||e==="java.lang.String"}#oe(t){if(t.isStatic)return this.#lt(t);let e=t.names,n=t.onDemand?e.join("."):e.slice(0,-1).join("."),s=e[e.length-1],r=t.onDemand?e[e.length-1]:e[e.length-2],a=e.slice(0,t.onDemand?-1:-2).join(".");if($t[r]===a&&!Mt[r]){for(let[o,c]of Object.entries(Mt))c===r&&(t.onDemand||o===s)&&this.#y.add(o);if(t.onDemand||Mt[s]===r)return}if(!ws.has(n)){this.#e(t.lastDotPos,v.cantResolve,`package ${n} does not exist`);return}if(t.onDemand){this.#s.add(n),this.#St(n);return}if($t[s]===n&&!Mt[s]||Tn.some(o=>o.name===`${n}.${s}`)){this.#y.add(s);return}if(n==="java.util"&&!la.has(s)){this.#e(t.lastDotPos,v.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: package ${n}`]);return}this.#w.set(s,`${n}.${s}`)}#lt(t){let e=t.names,n=t.onDemand?e:e.slice(0,-1),s=this.#we(t,n);if(typeof s=="object"&&s!==null){t.onDemand?this.#i.push(s.unsupported):this.#h.set(e[e.length-1],s.unsupported);return}if(s===null){t.onDemand||this.#e(t.start,v.cantResolve,"static import only from classes and interfaces");return}if(t.onDemand){this.#g.includes(s)||this.#g.push(s);for(let[o,c]of Object.entries(Mt))c===s&&this.#y.add(o);return}let r=e[e.length-1],a=Mt[r]===s;if(a&&this.#y.add(r),this.#st(s,r)||this.#It(s,r)){let o=this.#n.get(r)??[];o.includes(s)||o.push(s),this.#n.set(r,o)}else if(!a){let o=this.#zt(s)?.isInterface?"interface":"class";this.#e(t.start,v.cantResolve,"cannot find symbol",[` symbol: static ${r}`,` location: ${o} ${s}`])}}#we(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&&$t[a]===e.slice(0,-2).join(".")||s==="java.lang"&&(n==="Math"||n==="System"||n==="String")||$t[n]===s&&!Mt[n]?n:ws.has(s)&&((s==="java.lang"?Bn.has(n):(ks[s]??[]).includes(n))||Tn.some(c=>c.name===`${s}.${n}`))?{unsupported:`${s}.${n}`}:(ws.has(s)||[...ws].some(o=>o.startsWith(`${s}.`))?this.#e(r,v.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: package ${s}`]):this.#e(r,v.cantResolve,`package ${s} does not exist`),null)}#zt(t){return t==="Math"||t==="String"||t==="System"?Wt(t):ce(t)??null}#st(t,e){if(t==="Math"&&Object.hasOwn(Vn,e))return!0;if(t==="System")return zi.has(e);let n=this.#zt(t);return n?n.methods.some(s=>s.isStatic&&s.name===e)||t!=="String"&&n.unsupported.has(e):!1}#It(t,e){if(t==="System")return e==="out"||e==="err"||e==="in";if(Object.hasOwn(vs,t)&&Object.hasOwn(vs[t],e))return!0;if(t==="Math"||t==="String")return!1;let n=this.#zt(t)?.staticFields;return n!==void 0&&Object.hasOwn(n,e)}#f(t,e){let n=(this.#n.get(t)??[]).filter(s=>e.call(this,s,t));return n.length?n:this.#g.filter(s=>e.call(this,s,t))}#Ot(t,e){let n=this.#h.get(t)??this.#i[0];return n?(this.#o(e,`the class ${n}`,!0),!0):!1}#Lt(t){for(let e=this.#a;e;e=e.outer)if(this.#kt(e,t).length)return!0;return Object.hasOwn(Oe,t)||Cs.has(t)}#at(t,e){return{kind:"Name",identifier:t,depth:1,pos:e.pos,start:e.start,end:e.end,staticOwner:!0}}#G(t,e){if(this.#Lt(t.name))return!0;let n=this.#f(t.name,this.#st);if(n.length>1){let s=this.#Jt(t,n,e);if(!s)return!1;n=[s]}return n.length===1&&(t.target=this.#at(n[0],{pos:t.selectPos,start:t.start,end:t.start})),!0}#Jt(t,e,n){let s=e.flatMap(d=>this.#u(d,t.name).map(h=>({owner:d,...h}))),r=s.filter(d=>this.#le(d,n,!0)),a=r.length?r:s.filter(d=>this.#le(d,n,!1));if(!a.length)return e.find(d=>this.#u(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)=>qe(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(M).join(",")}) in ${p.owner}`;return this.#e(t.selectPos,v.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${m(d)} and ${m(h)} match`]),null}return this.#o(t.selectPos,`a call of ${t.name}(), which more than one static import could mean`,!0),null}#u(t,e){let n=[];if(t==="Math"&&Object.hasOwn(Vn,e))for(let r of Vn[e])n.push({params:r.params,varargs:!1});let s=t==="System"?null:this.#zt(t);for(let r of s?.methods??[])r.isStatic&&r.name===e&&n.push({params:r.params,varargs:r.varargs===!0});return n}#le(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?qe(W(u),o):he(W(u),o)})}#Me(t){let e=this.#f(t.identifier,this.#It);return e.length?e.length>1?(this.#e(t.pos,v.cantResolve,`reference to ${t.identifier} is ambiguous`,[` both variable ${t.identifier} in ${e[1]} and variable ${t.identifier} in ${e[0]} match`]),"error"):{kind:"FieldAccess",target:this.#at(e[0],t),name:t.identifier,namePos:t.pos,depth:2,pos:t.pos,start:t.start,end:t.end}:null}#St(t){for(let e of ks[t]??[])$t[e]||Tn.some(n=>n.name===`${t}.${e}`)||this.#w.has(e)||this.#w.set(e,`${t}.${e}`)}#ct(t){let e;if(t.length===1){e=t[0];let n=$t[e];if(!n||!(Mt[e]?this.#y.has(e):n==="java.lang"||this.#y.has(e)||this.#s.has(n)||this.#O.compact))return null}else if(t.length>=3&&t[0]==="java"&&$t[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.#ct([t[0]]))e=t[1];else if(t.length===4&&t[0]==="java"&&Mt[t[3]]===t[2]&&$t[t[2]]===`java.${t[1]}`)e=t[3];else return null;return ce(e)??null}#Nt(t,e){let n=t.modifiers,s=t.keyword==="interface",r=t.keyword==="enum",a=t.keyword==="record";for(let c of n.keywords)if(c.name!=="public"&&!(c.name==="abstract"&&!r&&!a)&&!(c.name==="final"&&!s&&!r)){if(c.name==="sealed"||c.name==="non-sealed"){if(!r&&!a)continue;this.#e(c.pos,v.syntax,`\'${c.name}\' is not allowed here`);continue}e&&["private","protected","static"].includes(c.name)||(c.name==="strictfp"?this.#o(c.pos,`\'strictfp\' ${s?"interfaces":"classes"}`):this.#e(t.keywordPos,v.syntax,`modifier ${c.name} not allowed here`))}if(e){if(e.membersByName.has(t.name)){this.#e(t.keywordPos,v.alreadyDefined,`class ${t.name} is already defined in class ${e.displayName}`);return}}else if(this.#W.some(c=>c.name===t.name)){this.#e(t.keywordPos,v.alreadyDefined,`duplicate class: ${t.name}`);return}let o={kind:"class",name:t.name,binaryName:e?`${e.binaryName}$${t.name}`:t.name,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&&!Vt(n,"static"),isPrivate:Vt(n,"private"),isInterface:s,isAbstract:s||Vt(n,"abstract"),isFinal:r&&!t.enumConstants?.some(c=>c.body)||a||Vt(n,"final"),...Vt(n,"sealed")?{isSealed:!0}:{},...Vt(n,"non-sealed")?{isNonSealed:!0}:{},isEnum:r,isRecord:a,enumConstants:[],components:[],superclass:null,interfaces:[],libraryInterfaces:[],hierarchyState:0,index:this.#j.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1};if(o.topLevel=e?e.topLevel:o,t.typeParams?.length){let c=a?"record":s?"interface":"class";o.typeParams=this.#ln(t.typeParams,`${c} ${o.displayName}`,o)}t.symbol=o,this.#j.push(o),e?(e.members.push(o),e.membersByName.set(o.name,o)):this.#W.push(o);for(let c of t.members)c.kind==="ClassDeclaration"&&this.#Nt(c,o);this.#Dt(o)}#Dt(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.#Gt(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.#Yt(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.#Gt(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=Vt(a.modifiers,"static")||t.isInterface&&a.kind==="FieldDeclaration";r(a,o)}e.length&&(t.anonymousClasses=e)}#Yt(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,v.syntax,`modifier ${c.name} not allowed here`);let a=this.#Gt(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"||Vt(e.modifiers,"abstract"),isFinal:r==="enum"||r==="record"||Vt(e.modifiers,"final")}),e.typeParams?.length&&(a.typeParams=this.#ln(e.typeParams,`${r==="record"?"record":r==="interface"?"interface":"class"} ${e.name}`,a)),a}#Gt(t,e,n,s){let r=`${t.binaryName}$${n}`,a={kind:"class",name:"",binaryName:r,displayName:`<anonymous ${r}>`,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.#j.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:0,outerField:-1,anonymous:!0};e.symbol=a,this.#j.push(a);for(let o of e.members)o.kind==="ClassDeclaration"&&this.#Nt(o,a);return this.#Dt(a),a}#Qt(){let t=(o,c)=>{let{pkg:u,simple:d}=Hi(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,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.#j.length,fields:[],fieldsByName:new Map,methods:[],methodsByName:new Map,constructors:[],members:[],membersByName:new Map,instanceCount:c?0:Vi,outerField:-1,membersEntered:!0,builtin:{pkg:u}};return m.topLevel=m,h.symbol=m,this.#j.push(m),this.#c.set(o,m),m};for(let o of Tn){let c=t(o.name,!1);c.superclass=o.superclass?this.#c.get(o.superclass):null,o.indexPrefix&&(c.builtin.indexPrefix=o.indexPrefix)}let e=this.#c.get("java.lang.Throwable"),n=X(e);this.#B(e,"getMessage",[],ut,"throwable-getMessage"),this.#B(e,"getLocalizedMessage",[],ut,"throwable-getLocalizedMessage"),this.#B(e,"getCause",[],n,"throwable-getCause"),this.#B(e,"initCause",[n],n,"throwable-initCause"),this.#B(e,"toString",[],ut,"throwable-toString"),this.#B(e,"printStackTrace",[],St,"throwable-printStackTrace"),this.#B(e,"addSuppressed",[n],St,"throwable-addSuppressed",{isFinal:!0}),this.#B(e,"getSuppressed",[],Yt(n),"throwable-getSuppressed",{isFinal:!0}),this.#B(e,"fillInStackTrace",[],n,"throwable-fillInStackTrace");let s={none:[],message:[ut],"message-cause":[ut,n],cause:[n],index:[U],object:[H]};for(let o of Tn){let c=this.#c.get(o.name);for(let u of o.constructors){let d=this.#B(c,c.name,s[u],St,"throwable-constructor",{isConstructor:!0});d.throwableConstructor=u}}let r=t("java.lang.AutoCloseable",!0),a=this.#B(r,"close",[],St,void 0,{throws:[X(this.#c.get("java.lang.Exception"))]});a.isAbstract=!0,delete a.builtin}#ce(t){if(t.length>1)return this.#c.get(t.join("."))??null;for(let e of this.#c.values()){if(e.name!==t[0])continue;let n=e.builtin.pkg;return n==="java.lang"||this.#y.has(e.name)||this.#s.has(n)||this.#O.compact?e:null}return null}#Tt(){return X(this.#c.get("java.lang.Throwable"))}#jt(t){return t.tag==="null"||z(t,this.#Tt())}#Zt(t){return t.tag==="class"&&this.#jt(t)&&!z(t,X(this.#c.get("java.lang.RuntimeException")))&&!z(t,X(this.#c.get("java.lang.Error")))}#ue(t){if(t.hierarchyState!==0)return;t.hierarchyState=1;let e=this.#a;this.#a=t,this.#F=!1,this.#L=[];let n=t.declaration,s=t.isInterface?[]:n.extendsTypes.slice(0,1);for(let a of s){let o=this.#En(a);if(!o||o.tag==="object")continue;if(o.tag==="string"){this.#e(a.pos,v.syntax,"cannot inherit from final String");continue}if(o.tag==="library"){o.symbol.isInterface?this.#e(a.pos,v.syntax,"no interface expected here"):Wi.has(o.symbol.name)?t.librarySuperclass=o:this.#o(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,v.syntax,"no interface expected here");continue}if(c.hierarchyState===1||c===t){this.#e(this.#te(t).declaration.keywordPos,v.syntax,`cyclic inheritance involving ${this.#te(t).displayName}`);continue}if(this.#ue(c),c.isFinal){this.#e(a.pos,v.syntax,`cannot inherit from final ${c.displayName}`);continue}if(c.isInner){this.#o(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.#En(a);if(!o)continue;if(o.tag==="library"){o.symbol.isInterface?Yi(o.symbol)?t.libraryInterfaces.push(o):this.#o(a.pos,`implementing the library interface ${o.symbol.name}`,!0):this.#e(a.pos,v.syntax,"interface expected here");continue}if(o.tag!=="class"||!o.symbol.isInterface){o.tag!=="error"&&this.#e(a.pos,v.syntax,"interface expected here");continue}let c=o.symbol;if(c.hierarchyState===1||c===t){this.#e(this.#te(t).declaration.keywordPos,v.syntax,`cyclic inheritance involving ${this.#te(t).displayName}`);continue}this.#ue(c),t.interfaces.includes(c)||(t.interfaces.push(c),(t.interfaceTypes??=[]).push(o))}this.#a=e,t.hierarchyState=2}#Pe(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,v.syntax,"illegal combination of modifiers: final and sealed");continue}if(r.isSealed&&r.isNonSealed){this.#e(a.keywordPos,v.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,v.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.#a=r.outer??r;for(let u of o){let d=this.#V(u);if(d.tag!=="class")continue;let h=d.symbol;if(c.includes(h)){this.#e(u.pos,v.syntax,"invalid permits clause",[` (must not contain duplicates: ${M(d)})`]);continue}c.push(h),s(h).includes(r)||this.#e(u.pos,v.syntax,"invalid permits clause",[` (${n(h)} ${M(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,v.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,v.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,v.syntax,"sealed, non-sealed or final modifiers expected")}}#Re(t){[...t.superclass?[t.superclass]:[],...t.interfaces].some(n=>n.isSealed)&&this.#e(t.declaration.keywordPos,v.syntax,`${t.anonymous?"anonymous":"local"} classes must not extend sealed classes`)}#te(t){return this.#j.filter(n=>n.hierarchyState===1).reduce((n,s)=>n.declaration.keywordPos<=s.declaration.keywordPos?n:s,t)}#En(t){if(t.kind!=="ClassType")return this.#e(t.pos,v.syntax,"unexpected type"),null;let e=this.#V(t);return e.tag==="error"?null:e}#Je(t){if(t.membersEntered)return;t.membersEntered=!0,t.superclass&&this.#Je(t.superclass);let e=this.#a;this.#a=t,t.instanceCount=t.superclass?.instanceCount??0,t.isInner&&(t.outerField=t.instanceCount++),t.isEnum&&(t.instanceCount=2,this.#hs(t)),t.isRecord&&this.#ds(t);for(let a of t.declaration.members)a.kind==="FieldDeclaration"?this.#ys(t,a):a.kind==="MethodDeclaration"&&this.#gs(t,a);t.isRecord?t.constructors.some(a=>this.#An(t,a))||this.#B(t,t.name,t.components.map(a=>a.type),St,"record-constructor",{isConstructor:!0}):!t.isInterface&&!t.anonymous&&!t.declaration.members.some(a=>a.kind==="MethodDeclaration"&&a.isConstructor)&&this.#bs(t),t.isEnum&&this.#ms(t),t.isRecord&&this.#ps(t),t.librarySuperclass&&this.#fs(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.#a=e}#hs(t){let e=X(t);(t.declaration.enumConstants??[]).forEach((s,r)=>{if(t.fieldsByName.has(s.name)){this.#e(s.pos,v.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,index:this.#H.length,order:t.fields.length,state:"done",declaration:o,declarator:a,enumConstant:{node:s,ordinal:r}};this.#H.push(c),s.field=c,t.fields.push(c),t.fieldsByName.set(c.name,c),t.enumConstants.push(c)})}#ds(t){for(let e of t.declaration.components??[]){let n=this.#V(e.type);if(n.tag==="error")continue;if(t.fieldsByName.has(e.name)){this.#e(e.pos,v.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,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)}}#An(t,e){return e.isConstructor&&(e.declaration.compact===!0||e.params.length===t.components.length&&e.params.every((n,s)=>et(n,t.components[s].type)))}#B(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.#z.length,declaration:c,locals:[],maxSlots:(a.isStatic?0:1)+n.reduce((d,h)=>d+De(h),0),builtin:r,throws:a.throws??[]};return a.component!==void 0&&(u.component=a.component),c.symbol=u,this.#z.push(u),u.isConstructor?t.constructors.push(u):(t.methods.push(u),t.methodsByName.set(e,[...t.methodsByName.get(e)??[],u])),u}#xt(t,e,n){return(t.methodsByName.get(e)??[]).some(s=>s.params.length===n.length&&s.params.every((r,a)=>et(r,n[a])))}#ms(t){let e=X(t);this.#xt(t,"values",[])||this.#B(t,"values",[],Yt(e),"enum-values",{isStatic:!0}),this.#xt(t,"valueOf",[ut])||this.#B(t,"valueOf",[ut],e,"enum-valueOf",{isStatic:!0}),this.#xt(t,"name",[])||this.#B(t,"name",[],ut,"enum-name",{isFinal:!0}),this.#xt(t,"ordinal",[])||this.#B(t,"ordinal",[],U,"enum-ordinal",{isFinal:!0}),this.#xt(t,"compareTo",[e])||this.#B(t,"compareTo",[e],U,"enum-compareTo",{isFinal:!0}),this.#xt(t,"toString",[])||this.#B(t,"toString",[],ut,"enum-toString")}#fs(t){this.#xt(t,"toString",[])||this.#B(t,"toString",[],ut,"library-toString"),this.#xt(t,"hashCode",[])||this.#B(t,"hashCode",[],U,"library-hashCode"),this.#xt(t,"equals",[H])||this.#B(t,"equals",[H],ft,"library-equals")}#ps(t){t.components.forEach((e,n)=>{(t.methodsByName.get(e.name)??[]).find(r=>r.params.length===0)||this.#B(t,e.name,[],e.type,"record-accessor",{component:n})}),this.#xt(t,"toString",[])||this.#B(t,"toString",[],ut,"record-toString"),this.#xt(t,"hashCode",[])||this.#B(t,"hashCode",[],U,"record-hashCode"),this.#xt(t,"equals",[H])||this.#B(t,"equals",[H],ft,"record-equals")}#ze(t=this.#z){for(let e of t)e.selector===void 0&&(e.isStatic||e.isConstructor||e.isPrivate||e.lambda||(e.selector=this.#In(Kn(e.name,e.params,e.returnType))))}#In(t){let e=this.#C.get(t);return e===void 0&&this.#C.set(t,e=this.#C.size),e}#ys(t,e){let n=e.modifiers.keywords.map(d=>d.name),s=this.#pt(e.modifiers,"field");for(let d of e.modifiers.keywords){if(d.name==="transient"||d.name==="volatile"){this.#o(d.pos,`\'${d.name}\' fields`);return}if(["abstract","synchronized","native","strictfp","default"].includes(d.name)){this.#e(e.declarators[0].pos,v.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.#me("var")){this.#e(r.pos,v.syntax,"\'var\' is not allowed here");return}if(t.isInterface&&(n.includes("private")||n.includes("protected"))){this.#e(e.declarators[0].pos,v.syntax,`modifier ${n.includes("private")?"private":"protected"} not allowed here`);return}if(t.isRecord&&!n.includes("static")){this.#e(e.declarators[0].pos,v.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,v.syntax,"= expected");return}let c=this.#L;this.#F=a,t.anonymous||(this.#L=[]);let u=this.#V(e.type);this.#F=!1,this.#L=c;for(let d of e.declarators){let h=u;for(let p=0;p<d.extraDims&&h.tag!=="error";p++)h=Yt(h);if(h.tag==="error")continue;if(t.fieldsByName.has(d.name)){this.#e(d.pos,v.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"),index:a?this.#H.length:t.instanceCount++,order:t.fields.length,state:"pending",declaration:e,declarator:d,...s.size?{suppressed:s}:{}};a&&this.#H.push(m),d.field=m,t.fields.push(m),t.fieldsByName.set(m.name,m)}}#gs(t,e){let n=e.isConstructor===!0;for(let I of e.modifiers.keywords){if(n&&["static","final","abstract","native","synchronized","strictfp","default","transient","volatile"].includes(I.name)){this.#e(e.namePos,v.syntax,`modifier ${I.name} not allowed here`);return}if(["strictfp","native"].includes(I.name)){this.#o(I.pos,`\'${I.name}\' methods`);return}if(I.name==="default"&&!t.isInterface||I.name==="synchronized"&&t.isInterface||I.name==="transient"||I.name==="volatile"){this.#e(e.namePos,v.syntax,`modifier ${I.name} not allowed here`);return}if(t.isInterface&&(I.name==="protected"||I.name==="final")){this.#e(e.namePos,v.syntax,`modifier ${I.name} not allowed here`);return}}let s=this.#pt(e.modifiers,n?"constructor":"method");if(e.compact){if(!t.isRecord){this.#e(e.namePos,v.syntax,"invalid method declaration; return type required");return}e.params=(t.declaration.components??[]).map(I=>({...I,symbol:void 0}))}if(n&&e.typeParams?.length){this.#o(e.typeParams[0].pos,"generic constructors");return}let r=this.#L;this.#F=Vt(e.modifiers,"static");let a=e.typeParams?.length?this.#ln(e.typeParams,"",null):void 0;a&&this.#cn(a,e.typeParams),this.#L=a?[...r,a]:r;let o=e.params.map(I=>this.#V(I.type)),c=e.returnType.kind==="VoidType"?St:this.#V(e.returnType),u=[],d=!0;for(let I of e.throwsTypes??[]){let R=this.#V(I);if(R.tag==="error"){d=!1;break}if(!this.#jt(R)){this.#q(I,R,this.#Tt()),d=!1;break}u.push(R)}if(this.#L=r,this.#F=!1,o.some(I=>I.tag==="error")||c.tag==="error"||!d)return;if(a){let I=e.params.map((R,N)=>R.varargs?`${M(o[N].element)}...`:M(o[N]));for(let R of a)R.declaredIn=`method <${a.map(N=>N.name).join(",")}>${e.name}(${I.join(",")})`}let h=n?t.constructors:t.methodsByName.get(e.name)??[];if(h.some(I=>I.params.length===o.length&&I.params.every((R,N)=>et(R,o[N])))){let I=n?"constructor":"method";this.#e(e.namePos,v.alreadyDefined,`${I} ${e.name}(${o.map(M).join(",")}) is already defined in class ${t.displayName}`);return}let m=h.find(I=>ie(I.name,I.params)===ie(e.name,o));if(m){let I=(R,N)=>`${R}(${N.map(M).join(",")})`;this.#e(e.namePos,v.alreadyDefined,`name clash: ${I(e.name,o)} and ${I(m.name,m.params)} have the same erasure`,Dt([...o,...m.params]));return}if(n&&t.isInterface){this.#e(e.namePos,v.syntax,"invalid method declaration; return type required");return}if(n&&t.isEnum){let I=e.modifiers.keywords.find(R=>R.name==="public"||R.name==="protected");I&&this.#e(e.namePos,v.syntax,`modifier ${I.name} not allowed here`)}let p=I=>Vt(e.modifiers,I),k=p("abstract")||t.isInterface&&!p("default")&&!p("static")&&!p("private");if(k&&(p("private")||p("static")||p("final")||p("synchronized"))){let I=p("private")?"private":p("static")?"static":p("final")?"final":"synchronized";this.#e(e.namePos,v.syntax,`illegal combination of modifiers: abstract and ${I}`);return}if(k&&e.body){let I=t.isInterface&&!p("abstract");this.#e(I?e.body.pos:e.namePos,v.syntax,I?"interface abstract methods cannot have body":"abstract methods cannot have a body");return}if(!k&&!e.body){this.#e(e.namePos,v.syntax,"missing method body, or declare abstract");return}let T=p("private")?"private":p("public")||t.isInterface?"public":p("protected")?"protected":"package",C={kind:"method",name:e.name,owner:t,isStatic:p("static"),isConstructor:n,isPrivate:p("private"),isAbstract:k,isFinal:p("final"),access:T,params:o,returnType:c,index:this.#z.length,...a?{typeParams:a}:{},declaration:e,locals:[],maxSlots:0,throws:u,...s.size?{suppressed:s}:{}},S=this.#At(e.modifiers,"SafeVarargs");if(S&&!e.params.some(I=>I.varargs))this.#e(e.namePos,v.syntax,`Invalid SafeVarargs annotation. ${n?"Constructor":"Method"} ${e.name}(${o.map(M).join(",")}) is not a varargs method.`);else if(S&&!n&&!C.isStatic&&!C.isFinal&&!C.isPrivate){let I=a?`<${a.map(R=>R.name).join(",")}>`:"";this.#e(e.namePos,v.syntax,`Invalid SafeVarargs annotation. Instance method ${I}${this.#Ft(C)} is neither final nor private.`,Dt(o))}e.symbol=C,this.#z.push(C),n?t.constructors.push(C):(t.methods.push(C),t.methodsByName.set(e.name,[...h,C]));let w=t.isRecord&&!n&&!C.isStatic&&o.length===0?t.components.find(I=>I.name===e.name):void 0;w&&(et(c,w.type)?T!=="public"&&this.#e(e.namePos,v.syntax,`invalid accessor method in record ${t.displayName}`,[" (accessor method must be public)"]):this.#e(e.namePos,v.syntax,`invalid accessor method in record ${t.displayName}`,[` (return type of accessor method ${e.name}() must match the type of record component ${e.name})`]))}#bs(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":"package",params:[],returnType:St,index:this.#z.length,declaration:n,locals:[],maxSlots:0,throws:[]};n.symbol=s,this.#z.push(s),t.constructors.push(s)}#Ft(t){let e=t.declaration.params.map((n,s)=>n.varargs?`${M(t.params[s].element)}...`:M(t.params[s]));return`${t.name}(${e.join(",")})`}#he(){return{method:this.#l,field:this.#E,isStatic:this.#_,scopes:this.#M,nextSlot:this.#k,jumps:this.#P,typeScopes:this.#L,typeStatic:this.#F,memberSuppressed:this.#it,localSuppressed:this.#$}}#de(t){this.#l=t.method,this.#E=t.field,this.#_=t.isStatic,this.#M=t.scopes,this.#k=t.nextSlot,this.#P=t.jumps,this.#L=t.typeScopes,this.#F=t.typeStatic,this.#it=t.memberSuppressed,this.#$=t.localSuppressed}#De(t){this.#a=t;let e=this.#pt(t.declaration.modifiers,"type");e.size&&(t.suppressed=e);let n=this.#At(t.declaration.modifiers,"FunctionalInterface");if(n){let s=t.isInterface?gs(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,v.syntax,"Unexpected @FunctionalInterface annotation",r)}}this.#Cs(t),t.isEnum&&this.#xs(t);for(let s of t.declaration.members)if(this.#a=t,s.kind==="FieldDeclaration")for(let r of s.declarators)r.field&&this.#$n(r.field);else s.kind==="MethodDeclaration"?s.symbol&&this.#vs(s.symbol):s.kind==="Initializer"?this.#Ss(t,s):s.symbol&&this.#De(s.symbol);this.#a=t,this.#Es(t)}#Ss(t,e){if(t.isInterface){this.#e(e.body.pos,v.syntax,"initializers not allowed in interfaces");return}if(t.isRecord&&!e.isStatic){this.#e(e.body.pos,v.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:St,index:-1,declaration:s,locals:[],maxSlots:0,throws:[],initializer:e.isStatic?"static":"instance"};e.symbol=r;let a=this.#he(),o=this.#et,c=t.fields.find(u=>!u.enumConstant&&!u.capturedLocal&&u.declarator.pos>e.start);this.#et={owner:t,isStatic:e.isStatic,order:c?c.order:t.fields.length},this.#a=t,this.#l=r,this.#E=null,this.#_=e.isStatic,this.#F=e.isStatic,this.#L=[],this.#it=void 0,this.#$=[],this.#M=[],this.#k=e.isStatic?0:1,r.maxSlots=this.#k,this.#P=[],this.#vt();for(let u of e.body.statements)this.#ne(u);this.#wt(),this.#de(a),this.#et=o,this.#a=t}#Ts(t,e,n){t.superclass=e,t.superType=X(e),t.hierarchyState=2;let s=this.#he(),r=this.#t,a=this.#R;this.#Je(t);let o=this.#zn(t,n);return this.#ze([...t.methods,...t.constructors]),this.#Rt.set(t,{scopes:[]}),this.#t=null,this.#R=!1,this.#De(t),this.#de(s),this.#t=r,this.#R=a,this.#a=e,o}#xs(t){for(let e of t.enumConstants){let n=e.enumConstant.node,s=this.#he();this.#l=null,this.#E=e,this.#_=!0,this.#M=[{names:new Map,nextSlot:0}],this.#k=0,this.#P=[];let r=this.#se(n.args);if(!r.some(a=>a.tag==="error")){let a=this.#rt({pos:n.pos,name:t.name},this.#Be(t),r,"constructor");if(a&&!n.body&&t.enumAbstract)this.#e(n.pos,v.syntax,`${t.displayName} is abstract; cannot be instantiated`);else if(a){this.#ie(n.args,a.params),n.ctor=n.body?.symbol?this.#Ts(n.body.symbol,t,a):a.method;let o=this.#Ie(a,n.pos);o&&(n.varargs=o)}this.#Ae(n.args)}this.#de(s),this.#a=t}}#vs(t){if(t.builtin)return;this.#a=t.owner,this.#l=t,this.#E=null,this.#_=t.isStatic,this.#F=t.isStatic,this.#L=t.typeParams?[t.typeParams]:[],this.#it=t.suppressed,this.#$=[],this.#M=[];let e=t.isConstructor&&t.owner.isInner?1:t.isConstructor&&t.owner.isEnum?2:0;this.#k=(t.isStatic?0:1)+e,t.maxSlots=this.#k,this.#P=[],this.#ws(t);let n=t.declaration.params[t.declaration.params.length-1];if(n?.varargs&&!wn(t.params[t.params.length-1])&&!this.#At(t.declaration.modifiers,"SafeVarargs")){let a=t.params[t.params.length-1].element;this.#nt(n.pos,"unchecked",`Possible heap pollution from parameterized vararg type ${M(a)}`,Dt([a]))}if(t.isAbstract){this.#l=null;return}this.#vt(),t.declaration.params.forEach((a,o)=>{this.#pt(a.modifiers,"parameter");let c=this.#_t(a.name,t.params[o],a.pos,Vt(a.modifiers,"final"));c.parameter=o+1+e,a.symbol=c});let s=t.declaration.body.statements;t.isConstructor&&t.owner.isRecord&&!this.#An(t.owner,t)&&!(s[0]?.kind==="ConstructorCall"&&s[0].keyword==="this")&&this.#e(t.declaration.namePos,v.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,v.syntax,"call to super not allowed in enum constructor");let r=s.some(a=>a.kind==="ConstructorCall");t.isConstructor&&!r&&!t.forwardsToSuper&&this.#On(t),s.forEach((a,o)=>{a.kind==="ConstructorCall"?this.#Nn(a,o===0):this.#ne(a)}),this.#wt(),this.#l=null}#On(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.#gn(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.#rt({pos:s,name:e.name},this.#Be(e,t.owner.superType),[],"constructor");if(!r||!this.#ye(r.method,s,`${e.name}()`))return;t.superConstructor=r.method;let a=this.#Ie(r,s);a&&(t.superVarargs=a)}#ws(t){let e=t.declaration,n=this.#At(e.modifiers,"Override");if(t.isConstructor)return;let s=t.isPrivate?[]:this.#ks(t);if(!s.length){n&&this.#e(n.pos,v.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&&!Xi.has(r.native)&&!(wo[r.libraryClass]??[]).includes(r.native)){this.#o(e.namePos,`overriding ${r.libraryClass}.${r.name}(${r.library.params.map($e).join(", ")})`,!0);return}let a=r.fromInterface&&!t.owner.isInterface&&!t.isStatic?"implement":"override",o=`${this.#Ft(t)} in ${t.owner.displayName} cannot ${a} ${r.signature} in ${r.ownerName}`;if(t.isStatic&&!r.isStatic){this.#e(e.namePos,v.syntax,o,[" overriding method is static"]);return}if(!t.isStatic&&r.isStatic){this.#e(e.namePos,v.syntax,o,[" overridden method is static"]);return}if(t.isStatic)continue;if(r.isFinal){this.#e(e.namePos,v.syntax,o,[" overridden method is final"]);return}if(qi[t.access]<qi[r.access]){this.#e(e.namePos,v.syntax,o,[` attempting to assign weaker access privileges; was ${r.access}`]);return}let c=t.returnType;if(!(Q(r.returnType)||r.returnType.tag==="void"?et(c,r.returnType):z(c,r.returnType))){this.#e(e.namePos,v.incompatibleTypes,o,[` return type ${M(c)} is not compatible with ${M(r.returnType)}`]);return}let d=t.throws.find(h=>this.#Zt(h)&&!(r.throws??[]).some(m=>z(h,m)));if(d){this.#e(e.namePos,v.syntax,o,[` overridden method does not throw ${M(d)}`]);return}}}#ks(t){let e=[],n=ie(t.name,t.params);for(let s of this.#Ln(t.owner))s.name===t.name&&ie(s.name,s.params)===n&&e.push(s);return e}#Ln(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&&To.has(p.name))continue;let k=C=>p.isStatic?C:Ie(m,h,C),T=p.params.map(k);e.push({name:p.name,params:T,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.#Ft(p),fromInterface:h.isInterface,interfaceSymbol:h.isInterface?h:void 0,throws:p.throws,method:p})}},r=ue(t),a=h=>Jn(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(Zt(r,h)??X(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 Ae(r)){if(!h.symbol.isInterface){for(let m of h.symbol.methods){if(m.isStatic||!m.native)continue;let p=m.params.map(k=>Tt(k,h.symbol.typeParams,h.args));e.push({name:m.name,params:p,returnType:Tt(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(M).join(",")})`,fromInterface:!1,library:{params:m.params,returnType:m.returnType},libraryClass:h.symbol.name,native:m.native})}continue}for(let m of vo[h.symbol.name]??(h.symbol.functional?[h.symbol.functional]:[])){let p=h.symbol.methods.find(T=>T.name===m),k=p.params.map(T=>Tt(T,h.symbol.typeParams,h.args));e.push({name:m,params:k,returnType:Tt(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(M).join(",")})`,fromInterface:!0,library:{params:p.params,returnType:p.returnType}})}}let d=t.isEnum?t:t.enumBody?t.superclass:null;if(d){let h=X(d),m=(p,k,T)=>({name:p,params:k,returnType:T,isStatic:!1,isFinal:!0,isAbstract:!1,isDefault:!1,access:"public",ownerName:"Enum",signature:`${p}(${k.map(M).join(",")})`,fromInterface:!1});e.push(m("name",[],ut),m("ordinal",[],U),m("compareTo",[h],U),m("equals",[H],ft),m("hashCode",[],U))}for(let h of Object.values(Oe))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(M).join(",")})`,fromInterface:!1,isObject:!0});return e}#Cs(t){if(t.isInterface)return;for(let d of t.constructors)d.declaration.synthetic&&!d.forwardsToSuper&&this.#On(d);let e=new Set,n=new Map,s=ue(t);for(let d=t;d;d=d.superclass){let h=Zt(s,d)??X(d);for(let m of d.methods){if(m.isAbstract||m.isStatic||m.lambda)continue;let p=ie(m.name,m.params.map(k=>Ie(h,d,k)));e.add(p),!m.isPrivate&&!n.has(p)&&n.set(p,m)}}for(let d of Object.values(Oe))e.add(ie(d.name,d.params));let r=this.#Ln(t),a=new Set(t.methods.filter(d=>!d.isStatic&&!d.isConstructor).map(d=>Kn(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(ie(d.name,d.params));if(!m||m===d.method||m.selector===void 0)continue;let p=Kn(d.name,h.params,h.returnType);if(p===Kn(m.name,m.params,m.returnType)||a.has(p)||m.owner!==t&&o(p))continue;let k=t.bridges??=[];k.some(T=>T.key===p)||k.push({key:p,name:d.name,params:h.params.map(W),returnType:W(h.returnType),target:m,selector:this.#In(p),library:!d.method,...m.builtin?{alias:!0}:{}})}for(let d of r){if(!d.libraryClass||Xi.has(d.native))continue;let h=n.get(ie(d.name,d.params));if(!h||h.builtin||h.selector===void 0)continue;let m=t.bridges?.find(p=>p.key===Kn(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=ie(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.#Ft(h),fromInterface:!1}));for(let h of[...d,...r]){if(!h.isAbstract)continue;let m=ie(h.name,h.params);if(!(e.has(m)||c.has(m))){if(u){t.enumAbstract=!0;break}this.#e(t.declaration.keywordPos,v.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&&(pn(m.interfaceSymbol,p.interfaceSymbol)||pn(p.interfaceSymbol,m.interfaceSymbol))||m.interfaceSymbol===p.interfaceSymbol)){this.#e(t.declaration.keywordPos,v.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}}}#Nn(t,e){let n=this.#l;if(!n?.isConstructor){this.#e(t.pos,v.syntax,"explicit constructor invocation may only appear within a constructor body");return}if(!e){this.#o(t.thisPos,`statements before \'${t.keyword}(...)\' in a constructor`);return}this.#R=!0;let s=this.#se(t.args);if(this.#R=!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.#gn(a,s,t.thisPos);if(!d)return;this.#R=!0,this.#ie(t.args,d.candidate.params),this.#Ae(t.args),this.#R=!1,t.libraryCall=d.call;return}if(!r){s.length&&this.#e(t.thisPos,v.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${s.map(M).join(",")}`," reason: actual and formal argument lists differ in length"]);return}if(this.#fn(r,s.length,t.thisPos))return;let o=t.keyword==="this"?ue(r):n.owner.superType,c=this.#rt({pos:t.thisPos,name:r.name},this.#Be(r,o),s,"constructor");if(!c||!this.#ye(c.method,t.thisPos,`${r.name}(${c.params.map(M).join(",")})`))return;this.#R=!0,this.#ie(t.args,c.params),this.#Ae(t.args),this.#R=!1,t.target=c.method;let u=this.#Ie(c,t.thisPos);u&&(t.varargs=u)}#Es(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,v.syntax,"recursive constructor invocation"),e.delete(a);break}a=c}for(let o of r)n.add(o)}}#$n(t){if(t.state!=="pending")return;t.state="attributing";let e=this.#he(),n=this.#a;this.#a=t.owner,this.#l=null,this.#E=t,this.#_=t.isStatic,this.#F=t.isStatic,this.#L=[],this.#it=t.suppressed,this.#$=[],this.#M=[{names:new Map,nextSlot:0}],this.#k=0,this.#P=[];let s=t.declarator.init;if(s)if(s.kind==="ArrayInitializer")this.#Ce(s,t.type);else{let r=this.#v(s,t.type);this.#We(t.type,r,s)?t.isFinal&&s.constant&&(Q(t.type)||t.type.tag==="string")&&(t.constant=vn(s.constant,t.type)):this.#q(s,r,t.type)}this.#de(e),this.#a=n,t.state="done"}#vt(){this.#M.push({names:new Map,nextSlot:this.#k})}#wt(){let t=this.#M.pop();this.#k=t.nextSlot}#yt(t){for(let e=this.#M.length-1;e>=0;e--){let n=this.#M[e].names.get(t);if(n)return n}}#_t(t,e,n,s,r=!1){let a=this.#l,o=this.#yt(t)||r?null:this.#Tn(t),c=o?.method??a;!r&&(this.#yt(t)||o&&c)&&this.#e(n,v.alreadyDefined,`variable ${t} is already defined in ${c.isConstructor?"constructor":"method"} ${this.#Ft(c)}`);let u={kind:"local",name:t,type:e,index:a.locals.length,slot:this.#k,isFinal:s,declPos:n};return this.#k+=De(e),a.maxSlots=Math.max(a.maxSlots,this.#k),a.locals.push(u),this.#M[this.#M.length-1].names.set(t,u),u}#ee(t){let e=0;for(let n=this.#a;n;n=n.outer,e++){let s=this.#je(n,t);if(s&&!(n.enumBody&&s.isPrivate&&s.owner!==n))return{field:s,hops:e};let r=n.anonymous||n.local?this.#ir(n,t):null;if(r)return{field:r,hops:e}}return null}#je(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.#je(t.superclass,e,n);if(r)return r}for(let r of t.interfaces){let a=this.#je(r,e,n);if(a)return a}return null}#kt(t,e){let n=[],s=new Set,r=new Set,a=ue(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=ie(d.name,d.isStatic?d.params:d.params.map(m=>Ie(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}#Ge(t){let e=this.#a;for(let n=0;n<t;n++,e=e.outer)if(!e?.isInner)return!1;return!0}#As(t){let e=this.#a;for(let n=0;n<t&&e;n++)e=e.outer;return e}#Is(t,e){for(let n=e;n;n=n.outer)if(n===t)return!0;return!1}#Os(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}#me(t){let e=r=>{for(let a=r.length-1;a>=0;a--){let o=r[a].classes?.get(t);if(o)return o}return null},n=e(this.#M);if(n)return n;for(let r=this.#t;r;r=r.outer){let a=e(r.scopes);if(a)return a}for(let r=this.#a;r;r=r.outer){let a=r.membersByName.get(t);if(a)return a;if(r.name===t&&!r.declaration.implicit)return r;let o=r.anonymous||r.local?this.#Rt.get(r):void 0,c=o?e(o.scopes):null;if(c)return c}let s=this.#W.find(r=>r.name===t&&!r.declaration.implicit);if(s){let r=this.#dt.get(s);if(r&&!r.launch&&r!==this.#O&&`${t}.java`!==r.file.name)throw new Ze(`class ${t} is declared in ${r.file.name}, a file not named after it, and used from another file`);return s}if(this.#Mt.has(`${t}.java`))throw new Yn(`${t}.java`);return null}#Fe(t){this.#vt();for(let e of t.statements)this.#ne(e);this.#wt()}#ne(t){let e=this.#k,n=this.#Pt.length;this.#Ls(t);let s=this.#Pt.slice(n);if(t.kind==="LocalVariableDeclaration")for(let r of t.declarators)r.symbol&&s.push(r.symbol);this.#k=Math.max(e,...s.map(r=>r.slot+De(r.type)))}#Ls(t){switch(t.kind){case"Block":this.#Fe(t);return;case"LocalVariableDeclaration":this.#Jn(t);return;case"ExpressionStatement":this.#v(t.expression);return;case"IfStatement":{this.#fe(t.condition);let e=this.#ot(t.condition,!0),n=this.#ot(t.condition,!1);this.#Kt(e,()=>this.#an(t.then)),t.otherwise&&this.#Kt(n,()=>this.#an(t.otherwise)),n.length&&!this.#on(t.then)&&this.#Ue(n),e.length&&t.otherwise&&!this.#on(t.otherwise)&&this.#Ue(e);return}case"WhileStatement":this.#fe(t.condition),this.#Kt(this.#ot(t.condition,!0),()=>this.#Ke(t,t.body)),me(t.body,t)||this.#Ue(this.#ot(t.condition,!1));return;case"DoStatement":this.#Ke(t,t.body),this.#fe(t.condition),me(t.body,t)||this.#Ue(this.#ot(t.condition,!1));return;case"ForStatement":this.#Rs(t);return;case"ForEachStatement":this.#Js(t);return;case"LabeledStatement":this.#Ds(t);return;case"SwitchStatement":this.#Mn(t,void 0);return;case"YieldStatement":this.#_s(t);return;case"BreakStatement":t.liveSlots=this.#k,this.#js(t);return;case"ContinueStatement":t.liveSlots=this.#k,this.#Fs(t);return;case"ReturnStatement":if(this.#l?.initializer){this.#e(t.pos,v.syntax,"return outside method");return}t.liveSlots=this.#k+(t.value&&this.#l?De(this.#l.returnType):0),this.#Vs(t);return;case"EmptyStatement":return;case"ConstructorCall":this.#Nn(t,!1);return;case"ThrowStatement":{let e=this.#Z(t.expression);e.tag!=="error"&&!this.#jt(e)&&this.#e(t.pos,v.incompatibleTypes,`incompatible types: ${Je(this.#Tt(),e)}`);return}case"TryStatement":this.#$s(t);return;case"AssertStatement":this.#fe(t.condition),t.message&&this.#Z(t.message);return;case"LocalClass":this.#Ns(t.declaration);return}}#Ns(t){let e=t.symbol;if(!e)return;let n=this.#M[this.#M.length-1];if(this.#M.some(h=>h.classes?.has(e.name))&&this.#l){this.#e(t.keywordPos,v.alreadyDefined,`class ${e.name} is already defined in ${this.#l.isConstructor?"constructor":"method"} ${this.#Ft(this.#l)}`);return}(n.classes??=new Map).set(e.name,e);let r=this.#he(),a=this.#a,o=this.#t,c=this.#p,u=this.#R;e.declaration.keyword==="class"&&this.#Rt.set(e,{scopes:r.scopes});let d=[e,...br(e,!0)];for(let h of d)h.typeParams&&(this.#a=h,this.#cn(h.typeParams,h.declaration.typeParams));for(let h of d)this.#ue(h);this.#Re(e);for(let h of d)this.#Je(h);for(let h of d)this.#ze([...h.methods,...h.constructors]);this.#t=null,this.#R=!1,this.#De(e),this.#de(r),this.#a=a,this.#t=o,this.#p=c,this.#R=u}#$s(t){this.#vt();for(let n of t.resources)this.#Ms(n);this.#Fe(t.block),this.#wt();let e=[];for(let n of t.catches){let s=[];for(let o of n.types){let c=this.#V(o);if(c.tag==="error")continue;if(!this.#jt(c)){this.#q(o,c,this.#Tt());continue}let u=s.find(d=>z(c,d)||z(d,c));if(u){let[d,h]=z(c,u)?[c,u]:[u,c];this.#e(o.pos,v.syntax,"Alternatives in a multi-catch statement cannot be related by subclassing",[` Alternative ${M(d)} is a subclass of alternative ${M(h)}`]);continue}if(e.some(d=>z(c,d))){this.#e(n.types.length===1?n.pos:o.pos,v.syntax,`exception ${M(c)} has already been caught`);continue}s.push(c)}e.push(...s),n.caught=s,this.#vt();let r=s.length===1?s[0]:s.length?this.#Ps(s):E,a=this.#_t(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.#Fe(n.block),this.#wt()}if(t.finallyBlock){let n=this.#l,s=n.maxSlots,r=this.#k,a=n.locals.length;this.#Fe(t.finallyBlock);let o=Math.max(0,...n.locals.slice(a).map(c=>c.slot+De(c.type)-r));t.finallySlots={base:r,extent:o,before:s},n.finallySlots=Math.max(n.finallySlots??0,n.maxSlots)+3+2*o}}#Ms(t){if(t.kind==="variable"){let r=this.#v(t.expression),a=it(t.expression);a.kind==="Name"&&a.symbol?.kind==="local"&&(t.symbol=a.symbol),r.tag!=="error"&&!this.#rn(r)?this.#in(t.expression,r):t.closeMethod=this.#sn(r);return}if(t.type.kind==="VarType"){let r=this.#v(t.init),a=r.tag==="null"||r.tag==="void"?E:r;if(a.tag==="error"&&r.tag!=="error"&&this.#e(t.namePos,v.cantResolve,`cannot infer type for local variable ${t.name}`,[` (variable initializer is \'${r.tag}\')`]),t.symbol=this.#_t(t.name,a,t.namePos,!0),a.tag==="error")return;this.#rn(a)?t.closeMethod=this.#sn(a):this.#in(t.init,a);return}let e=this.#V(t.type),n=this.#_t(t.name,e,t.namePos,!0);t.symbol=n;let s=this.#v(t.init,e);if(!(e.tag==="error"||s.tag==="error")){if(!te(e,s,t.init.constant)){this.#q(t.init,s,e);return}this.#rn(e)?t.closeMethod=this.#sn(e):this.#in(t.type,e)}}#sn(t){if(t.tag==="class")return this.#kt(t.symbol,"close").find(e=>e.params.length===0)}#rn(t){return t.tag==="library"?t.symbol.closeable===!0:z(t,X(this.#c.get("java.lang.AutoCloseable")))}#in(t,e){this.#e(t.pos,v.incompatibleTypes,"incompatible types: try-with-resources not applicable to variable type",[` (${M(e)} cannot be converted to AutoCloseable)`])}#Ps(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"&&z(a,X(r))));return s?X(s):this.#Tt()}#an(t){this.#vt(),this.#ne(t),this.#wt()}#Rs(t){if(this.#vt(),t.init&&!Array.isArray(t.init))this.#Jn(t.init);else for(let s of t.init??[])this.#v(s);t.condition&&this.#fe(t.condition);let e=t.condition?this.#ot(t.condition,!0):[];this.#Kt(e,()=>{for(let s of t.update)this.#v(s);this.#Ke(t,t.body)});let n=t.condition?this.#ot(t.condition,!1):[];this.#wt(),me(t.body,t)||this.#Ue(n)}#on(t){let e=[this.#I,this.#X,this.#x,this.#tt,this.#Q,this.#U];this.#I=[],this.#X=[],this.#x=new Map,this.#tt=0,this.#Q=[],this.#U=new Map;let n=this.#Ct(t,Gt(),!0).completes;return[this.#I,this.#X,this.#x,this.#tt,this.#Q,this.#U]=e,n}#Ke(t,e){this.#P.push({kind:"loop",node:t}),this.#an(e),this.#P.pop()}#Js(t){let e=this.#v(t.iterable);this.#vt();let n=E,s=c=>c.tag==="library"?[c]:c.tag==="diamond"?[this.#yn(c)]:c.tag==="class"?Ae(c):c.tag==="typevar"&&c.symbol?c.symbol.bounds.flatMap(s):[],r=s(e).map(c=>Pt(c,ce("Iterable"))).find(c=>c!==null)??null;e.tag==="array"?(n=e.element,t.hidden={array:this.#ke(e),length:this.#ke(U),index:this.#ke(U)}):r?(n=Ne(r.args[0]??H),t.element=n,t.iterator=this.#ke(H)):e.tag!=="error"&&this.#e(t.iterable.pos,v.incompatibleTypes,"for-each not applicable to expression type",[" required: array or java.lang.Iterable",` found: ${M(e)}`]),this.#pt(t.modifiers,"local");let a=t.type.kind==="VarType"?n:this.#V(t.type),o=this.#_t(t.name,a,t.namePos,Vt(t.modifiers,"final"));o.forEach=!0,t.symbol=o,n.tag!=="error"&&a.tag!=="error"&&!te(a,n)&&this.#q(t.iterable,n,a),this.#Ke(t,t.body),this.#wt()}#Ds(t){this.#P.some(s=>s.kind==="label"&&s.label===t.label)&&this.#e(t.pos,v.syntax,`label ${t.label} already in use`);let e=t.body,n=["WhileStatement","DoStatement","ForStatement","ForEachStatement"].includes(e.kind);this.#P.push({kind:"label",node:t,label:t.label,loop:n?e:void 0}),this.#ne(e),this.#P.pop()}#js(t){for(let e=this.#P.length-1;e>=0;e--){let n=this.#P[e];if(n.kind==="switch-expression"){this.#e(t.pos,v.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,v.syntax,`undefined label: ${t.label}`):this.#e(t.pos,v.syntax,"break outside switch or loop")}#Fs(t){for(let e=this.#P.length-1;e>=0;e--){let n=this.#P[e];if(n.kind==="switch-expression"){this.#e(t.pos,v.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,v.syntax,`not a loop label: ${t.label}`);return}}t.label!==void 0?this.#e(t.pos,v.syntax,`undefined label: ${t.label}`):this.#e(t.pos,v.syntax,"continue outside of loop")}#_s(t){let e=[...this.#P].reverse().find(s=>s.kind==="switch-expression");if(!e){this.#e(t.pos,v.syntax,"yield outside of switch expression"),this.#v(t.value);return}t.target=e.node;let n=this.#Z(t.value,e.target);e.results.push({expression:t.value,type:n})}#ke(t){let e=this.#l;if(!e)throw new Error("checker: hidden local outside a method");let n={kind:"local",name:"",type:t,index:e.locals.length,slot:this.#k,isFinal:!1,declPos:-1};return this.#k+=De(t),e.maxSlots=Math.max(e.maxSlots,this.#k),e.locals.push(n),n}#Mn(t,e){let n=t.kind==="SwitchExpression",s=this.#v(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)||yt(s)!==null;if(r&&(t.cases.some(k=>k.pattern||k.nullLabel)||!c&&tt(s)))return this.#Us(t,s,e);r&&!a&&!o&&!["int","byte","short","char","string"].includes(s.tag)&&(r=!1,yt(s)?this.#o(t.selectorPos,`switching on ${We(M(s))}`,!0):Q(s)?this.#e(t.selectorPos,v.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#o(t.selectorPos,`switching on ${We(M(s))}`,!0)),this.#vt(),r&&s.tag==="string"&&(this.#l?t.hidden={copy:this.#ke(ut),index:this.#ke(U)}:(this.#o(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.#P.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,v.syntax,"different case kinds used in the switch")),k.isDefault&&++h>1&&this.#e(k.pos,v.syntax,"duplicate default label"),o){k.ordinals=[];for(let T of k.labels){let C=this.#Bs(T,o);C!==null&&(d.has(`e:${C}`)&&this.#e(T.pos,v.syntax,"duplicate case label"),d.add(`e:${C}`),k.ordinals.push(C))}this.#qe(k,n,u);continue}if(a){k.ordinals=[];for(let T of k.labels){let C=this.#Pn(T,a);C!==null&&(d.has(`e:${C}`)&&this.#e(T.pos,v.syntax,"duplicate case label"),d.add(`e:${C}`),k.ordinals.push(C))}this.#qe(k,n,u);continue}for(let T of k.labels){let C=this.#v(T,r?s:void 0);if(!r||C.tag==="error")continue;if(!T.constant){this.#e(T.pos,v.syntax,"constant expression required");continue}if(!te(s,C,T.constant)){this.#q(T,C,s);continue}let S=T.constant.kind==="string"?`s:${T.constant.value}`:`n:${bn(T.constant)}`;d.has(S)&&this.#e(k.pos,v.syntax,"duplicate case label"),d.add(S)}this.#qe(k,n,u)}return this.#P.pop(),this.#wt(),a&&(t.coversAllConstants=a.enumConstants.every(k=>d.has(`e:${k.enumConstant.ordinal}`))),o&&(t.libraryEnum=ea(o),t.coversAllConstants=o.enumConstants.every((k,T)=>d.has(`e:${T}`))),n?this.#Rn(t,u.results,e):St}#Us(t,e,n){let s=t.kind==="SwitchExpression";t.patternSwitch=!0;let r=e.tag==="class"&&e.symbol.isEnum?e.symbol:null;this.#vt();let a=s?{kind:"switch-expression",node:t,results:[],target:n}:{kind:"switch",node:t};this.#P.push(a);let o=!1,c=0,u=!1,d=t.cases[0]?.arrow??!1,h=[],m=new Set,p=null,k=[],T=!1,C=yt(e);t.cases.forEach((w,I)=>{w.arrow!==d&&!o&&(o=!0,this.#e(w.pos,v.syntax,"different case kinds used in the switch")),w.isDefault&&++c>1&&this.#e(w.pos,v.syntax,"duplicate default label");let R=[];w.nullLabel&&Q(e)&&this.#q({pos:w.pos},cr,e);for(let N of w.labels){if(r){let L=this.#Pn(N,r);if(L===null)continue;m.has(`e:${L}`)&&this.#e(N.pos,v.syntax,"duplicate case label"),m.add(`e:${L}`),(w.ordinals??=[]).push(L),k.push({constantOf:r,ordinal:L})}else{let L=this.#v(N,C??e);if(L.tag==="error")continue;let J=N.kind==="FieldAccess"?N.fieldSymbol:void 0;if(L.tag==="class"&&L.symbol.isEnum&&J?.enumConstant&&z(L,e)){(w.enumFields??=[]).push(J),k.push({constantOf:L.symbol,ordinal:J.enumConstant.ordinal}),h.some(j=>z(L,j))&&this.#e(N.pos,v.syntax,"this case label is dominated by a preceding case label");continue}if(!(e.tag==="string"?L.tag==="string":C!==null&&Q(L)&&N.constant!==void 0&&te(C,L,N.constant))){C&&N.constant?this.#q(N,L,C):this.#o(N.pos,`constant labels in a switch on ${We(M(e))}`,!0);continue}if(!N.constant){this.#e(N.pos,v.syntax,"constant expression required");continue}let P=N.constant.kind==="string"?`s:${N.constant.value}`:`n:${bn(N.constant)}`;m.has(P)&&this.#e(w.pos,v.syntax,"duplicate case label"),m.add(P)}let A=r||C?e:ut;h.some(L=>z(A,L))&&this.#e(N.pos,v.syntax,"this case label is dominated by a preceding case label")}if(w.pattern){let N=w.pattern;if(!this.#un(N,e,!0,R))T=!0;else{let L=N.tested;(u||h.some(D=>z(W(L),W(D))))&&this.#e(N.pos,v.syntax,"this case label is dominated by a preceding case label");let J=w.guard!==void 0;N.kind==="TypePattern"&&!J&&(h.push(L),N.unconditional&&(p=w)),(!w.guard||Un(w.guard.constant))&&k.push({pattern:N})}let A=t.cases[I-1];!w.arrow&&A&&!A.arrow&&A.statements.length&&R.length&&this.#on({kind:"Block",statements:A.statements,pos:A.pos,start:A.start,end:A.end})&&this.#e(N.pos,v.syntax,"illegal fall-through to a pattern",[" (the previous case label is missing a break)"])}w.isDefault&&(u=!0,k.push({all:!0})),this.#Kt(R,()=>{let N=[];w.guard&&(this.#fe(w.guard),xs(w.guard.constant)&&this.#e(w.guard.pos,v.syntax,"this case label has a guard that is a constant expression with value \'false\'"),N=this.#ot(w.guard,!0)),this.#Kt(N,()=>this.#qe(w,s,a))})});let S=t.cases.find(w=>w.isDefault&&!w.nullLabel)??t.cases.find(w=>w.isDefault);return p&&S&&this.#e(S.pos,v.syntax,"switch has both an unconditional pattern and a default label"),this.#P.pop(),this.#wt(),t.exhaustive=Do(e,k),!t.exhaustive&&!T&&this.#e(t.pos,v.syntax,`the switch ${s?"expression":"statement"} does not cover all possible input values`),s?this.#Rn(t,a.results,n):St}#Bs(t,e){let n=it(t),s=e.enumConstants,r=n.kind==="Name"?n.identifier:n.kind==="FieldAccess"&&Is(n.target)?.split(".").pop()===e.name?n.name:null,a=r===null?-1:s.indexOf(r);return a>=0?(t.type=dt(e),a):n.kind==="Name"?(this.#e(n.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#a.displayName}`]),null):(this.#v(t).tag!=="error"&&this.#e(t.pos,v.syntax,"constant expression required"),null)}#Pn(t,e){let n=it(t);if(n.kind==="Name"){let a=e.fieldsByName.get(n.identifier);return a?.enumConstant?(n.symbol=a,t.type=X(e),a.enumConstant.ordinal):(this.#e(n.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${n.identifier}`,` location: class ${this.#a.displayName}`]),null)}let s=this.#v(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:(te(X(e),s)?this.#e(t.pos,v.syntax,"constant expression required"):this.#q(t,s,X(e)),null)}#qe(t,e,n){if(!t.arrow){for(let r of t.statements)this.#ne(r);return}let s=t.body;s.kind==="Block"?this.#Fe(s):e?n.results.push({expression:s,type:this.#Z(s,n.target)}):this.#v(s)}#Rn(t,e,n){if(e.some(r=>r.type.tag==="error"))return E;if(n&&n.tag!=="error"){let r=!0;for(let{expression:a,type:o}of e)te(n,o,a.constant)||(this.#e(a.pos,v.incompatibleTypes,"incompatible types: bad type in switch expression",[` ${Je(n,o)}`]),r=!1);return r?n:E}let s=e.map(r=>r.type);return s.length?s.every(r=>r.tag==="boolean")?ft:s.every(r=>Ot(r))?s.every(r=>et(r,s[0]))?s[0]:s.reduce((r,a)=>Wn(r,a)):s.every(r=>tt(r))?s.reduce((r,a)=>oa(r,a)):(this.#o(t.pos,"switch expressions that need boxing"),E):E}#Vs(t){let e=this.#l.returnType;if(this.#l.lambda&&this.#l.returnType===qn){if(!t.value)return;let s=this.#v(t.value);s.tag!=="error"&&(this.#l.returnType=Qt(s)??(s.tag==="null"?H:s));return}if(this.#l.lambda){let s=`incompatible types: bad return type in ${this.#l.lambda.reference?"method reference":"lambda expression"}`;if(!t.value){e.tag!=="void"&&this.#e(t.pos,v.incompatibleTypes,s,[" missing return value"]);return}if(e.tag==="void"){this.#v(t.value),this.#e(t.value.pos,v.incompatibleTypes,"incompatible types: unexpected return value");return}let r=this.#v(t.value,e);r.tag!=="error"&&!te(e,r,t.value.constant)&&this.#e(t.value.pos,v.incompatibleTypes,s,[` ${Je(e,r)}`]);return}if(!t.value){e.tag!=="void"&&this.#e(t.pos,v.incompatibleTypes,"incompatible types: missing return value");return}let n=this.#v(t.value,e.tag==="void"?void 0:e);if(e.tag==="void"){n.tag!=="error"&&this.#e(t.value.pos,v.incompatibleTypes,"incompatible types: unexpected return value");return}this.#We(e,n,t.value)||this.#q(t.value,n,e)}#fe(t){let e=this.#v(t);e.tag!=="error"&&(yt(e)??e).tag!=="boolean"&&this.#q(t,e,ft)}#Jn(t){let e=Vt(t.modifiers,"final"),n=this.#pt(t.modifiers,"local");if(this.#$=[...this.#$,n],this.#At(t.modifiers,"Deprecated"))for(let s of t.declarators)this.#nt(s.pos,"deprecation","@Deprecated annotation has no effect on this variable declaration");t.type.kind==="VarType"?this.#zs(t,e):this.#Hs(t,e),this.#$=this.#$.slice(0,-1)}#Hs(t,e){let n=this.#V(t.type);for(let s of t.declarators){let r=n;for(let u=0;u<s.extraDims&&r.tag!=="error";u++)r=Yt(r);let a=this.#_t(s.name,r,s.pos,e);s.symbol=a;let o=s.init;if(o||(a.noInitializer=!0),!o){e&&this.#o(s.pos,"final local variables without an initializer");continue}if(o.kind==="ArrayInitializer"){this.#Ce(o,r);continue}let c=this.#v(o,r);this.#We(r,c,o)?e&&o.constant&&(Q(r)||r.tag==="string")&&(a.constant=vn(o.constant,r)):this.#q(o,c,r)}}#zs(t,e){let n=t.type.pos;if(t.declarators.length>1){this.#e(n,v.syntax,"\'var\' is not allowed in a compound declaration");return}let s=t.declarators[0];if(s.extraDims){this.#e(n,v.syntax,"\'var\' is not allowed as an element type of an array");return}let r=d=>this.#e(s.pos,v.cantResolve,`cannot infer type for local variable ${s.name}`,[` (${d})`]),a=s.init,o=a&&a.kind!=="ArrayInitializer"?it(a):null,c=E;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(Vo(a,s.name))r("cannot use \'var\' on self-referencing variable");else{let d=this.#v(a);d.tag==="null"?r("variable initializer is \'null\'"):d.tag==="void"?r("variable initializer is \'void\'"):c=d.tag==="diamond"?this.#yn(d):d,c.tag==="class"&&c.args?.includes(Dn)&&(c=E)}let u=this.#_t(s.name,c,s.pos,e);s.symbol=u,a||(u.noInitializer=!0),a&&a.kind!=="ArrayInitializer"&&e&&a.constant&&(Q(c)||c.tag==="string")&&(u.constant=vn(a.constant,c))}#We(t,e,n){return W(t).tag==="object"&&delete it(n).genericCast,te(t,e,n.constant)?!0:Qe(t,e)?(this.#nt(n.pos,"unchecked","unchecked conversion",[` required: ${M(t)}`,` found: ${M(e)}`,...Dt([t,e])]),!0):!1}#Ce(t,e){if(e.tag==="error"){for(let n of t.elements)n.kind==="ArrayInitializer"?this.#Ce(n,E):this.#v(n);return}if(e.tag!=="array"){this.#e(t.pos,v.incompatibleTypes,`illegal initializer for ${M(e)}`);return}t.elementType=e.element;for(let n of t.elements){if(n.kind==="ArrayInitializer"){this.#Ce(n,e.element);continue}let s=this.#v(n,e.element);te(e.element,s,n.constant)||this.#q(n,s,e.element)}}#ln(t,e,n){let s=[];for(let r of t){if(s.some(a=>a.name===r.name)){this.#e(r.pos,v.alreadyDefined,`type variable ${r.name} is already defined in ${e}`);continue}s.push({kind:"typevar",name:r.name,key:`${r.name}#${this.#K++}`,bounds:[],declaredIn:e,pos:r.pos,ofClass:n})}return s}#cn(t,e){this.#L=[...this.#L,t.filter(s=>!s.ofClass)];let n=this.#mt;this.#mt=!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.#V(a);if(o.tag!=="error"){if(!tt(o)||o.tag==="array"){this.#e(a.pos,v.incompatibleTypes,"unexpected type",[" required: class",` found: ${M(o)}`]);continue}o.tag==="object"&&r.bounds.length===1||s.bounds.push(o)}}}this.#mt=n,this.#L=this.#L.slice(0,-1)}#Gs(t,e){for(let s=this.#L.length-1;s>=0;s--){let r=this.#L[s].find(a=>a.name===t);if(r)return ke(r)}let n=this.#F;for(let s=this.#a??null;s;s=s.outer){let r=s.typeParams?.find(a=>a.name===t);if(r)return n?(this.#e(e,v.syntax,`non-static type variable ${t} cannot be referenced from a static context`),E):ke(r);s.isInner||(n=!0)}return null}#_e(t){if(t.kind==="WildcardType"){if(!t.bound)return{tag:"wildcard",bound:null};let e=this.#_e(t.bound);return e.tag==="error"||e.tag==="wildcard"?E:{tag:"wildcard",bound:e,isSuper:t.isSuper}}return t.kind==="PrimitiveType"?(this.#e(t.pos,v.incompatibleTypes,"unexpected type",[" required: reference",` found: ${t.name}`]),E):this.#V(t)}#Ks(t,e){let n=t.typeParams??[];if(e.diamond)return X(t);if(!n.length)return this.#e(e.typeArgumentsPos??e.pos,v.syntax,`type ${t.displayName} does not take parameters`),E;let s=e.typeArguments??[];if(s.length!==n.length)return this.#e(e.typeArgumentsPos??e.pos,v.syntax,`wrong number of type arguments; required ${n.length}`),E;let r=[];for(let o of s){let c=this.#_e(o);if(c.tag==="error")return E;r.push(c)}let a=X(t,r);if(!this.#mt){let o=Pn(a);for(let c=0;c<n.length;c++){let u=r[c];if(u.tag==="wildcard")continue;if(!n[c].bounds.every(h=>z(u,Ht(h,o))))return this.#e(s[c].pos,v.incompatibleTypes,`type argument ${M(u)} is not within bounds of type-variable ${n[c].name}`,Dt([ke(n[c])])),E}}return a}#V(t,e=!1){switch(t.kind){case"PrimitiveType":return t.name==="int"?U:t.name==="boolean"?ft:t.name==="char"?we:t.name==="long"?Lt:t.name==="double"?ht:t.name==="float"?xt:t.name==="byte"?Mn:gn;case"VarType":return this.#o(t.pos,"\'var\' declarations"),E;case"WildcardType":return this.#o(t.pos,"wildcard types"),E;case"VoidType":return this.#e(t.pos,v.syntax,"\'void\' type not allowed here"),E;case"ArrayType":{let n=this.#V(t.element);return n.tag==="error"?E:Yt(n)}case"ClassType":{let n=t.names.join(".");if((n==="Object"||n==="java.lang.Object")&&!this.#pe(t.names))return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,v.syntax,"type Object does not take parameters"),E):H;if(n==="String"||n==="java.lang.String")return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,v.syntax,"type String does not take parameters"),E):ut;if(t.names.length===1){let o=this.#Gs(n,t.pos);if(o)return t.hasTypeArguments?(this.#e(t.typeArgumentsPos??t.pos,v.syntax,`type ${n} does not take parameters`),E):o}let s=this.#pe(t.names)??this.#ce(t.names);if(s)return t.hasTypeArguments?this.#Ks(s,t):X(s);let r=this.#ct(t.names);if(r)return this.#qs(r,t,e);let a=t.names.length===1?this.#w.get(n):void 0;return a?(this.#o(t.pos,`the class ${a}`,!0),E):t.names.length===1&&(Bn.has(n)||n===this.#Ws())?(this.#o(t.pos,`the type ${n}`,!0),E):t.names.length>1&&(t.names[0]==="java"||t.names[0]==="javax")?(this.#o(t.pos,`the type ${n}`,!0),E):t.names.length>1?(this.#e(t.lastDotPos??t.pos,v.cantResolve,`package ${t.names.slice(0,-1).join(".")} does not exist`),E):(this.#e(t.pos,v.cantResolve,"cannot find symbol",[` symbol: class ${n}`,` location: class ${this.#a.displayName}`]),E)}}}#qs(t,e,n=!1){let s=t.typeParams;if(t.name==="Class"&&e.typeArguments)return this.#o(e.typeArgumentsPos??e.pos,"Class<...> types (declare the variable as Class)"),E;if(!e.typeArguments)return e.diamond?{tag:"diamond",symbol:t,fromArgs:null}:dt(t);if(e.typeArguments.length!==s.length)return this.#e(e.typeArgumentsPos??e.pos,v.syntax,s.length?`wrong number of type arguments; required ${s.length}`:`type ${t.name} does not take parameters`),E;let r=[];for(let a of e.typeArguments){let o=this.#_e(a);if(o.tag==="error")return E;r.push(o)}return dt(t,r)}#pe(t){let e=this.#me(t[0]);for(let n of t.slice(1))e=e?.membersByName.get(n)??null;return e}#Ws(){return this.#W.find(t=>t.declaration.implicit)?.name}#q(t,e,n){e.tag==="error"||n.tag==="error"||this.#e(t.pos,v.incompatibleTypes,`incompatible types: ${Je(n,e)}`,Dt([e,n]))}#v(t,e){let n=this.#Xs(t,e);return t.type=n,n}#Z(t,e){let n=this.#v(t,e);return n.tag==="void"?(this.#e(t.pos,v.incompatibleTypes,"\'void\' type not allowed here"),E):n}#Xs(t,e){switch(t.kind){case"Literal":switch(t.literalKind){case"int":return t.constant=K(t.value),U;case"char":return t.constant=Fn(t.value.charCodeAt(0)),we;case"boolean":return t.constant=gt(t.value),ft;case"long":return t.constant=Jt(t.value),Lt;case"double":return t.constant=ee(t.value),ht;case"float":return t.constant=de(t.value),xt;case"string":return t.constant=hr(t.value),ut;case"null":return cr;default:return this.#o(t.pos,`\'${t.literalKind}\' literals`),E}case"Name":return this.#ar(t);case"Parenthesized":{let n=this.#v(t.expression,e);return t.expression.constant&&(t.constant=t.expression.constant),n}case"FieldAccess":return this.#_n(t);case"MethodCall":{let n=this.#mr(t,e);return this.#Ae(t.args),n}case"Unary":return this.#Nr(t);case"IncDec":return this.#Mr(t);case"Binary":return this.#Pr(t);case"Assignment":return this.#Rr(t);case"ArrayAccess":return this.#Jr(t);case"NewArray":return this.#Dr(t);case"Cast":return this.#jr(t);case"This":return this.#sr(t);case"NewObject":{let n=this.#Sr(t,e);return this.#Ae(t.args),n}case"Conditional":return this.#kr(t,e);case"SwitchExpression":return this.#Mn(t,e);case"Lambda":return this.#Sn(t,e);case"MethodRef":return t.lambda?.method?e??E:this.#Kn(t,e);case"InstanceOf":return this.#tr(t);case"Super":return this.#jn(t);case"ClassLiteral":return this.#Ys(t)}}#Ys(t){let e=this.#Xe(t.target);if(!("kind"in e))return e.tag!=="error"&&this.#e(t.target.pos,v.cantResolve,"cannot find symbol",[` symbol: class ${Is(t.target)??"?"}`,` location: class ${this.#a.displayName}`]),E;let n=s=>dt(ce("Class"),[s]);if(e.symbol)return t.className=e.symbol.binaryName,t.isInterface=e.symbol.isInterface,n(X(e.symbol));if(e.name==="String")return t.className="java.lang.String",n(ut);if($t[e.name]){let s=ce(e.name);return t.className=s.qualifiedName,t.isInterface=s.isInterface,n(dt(s))}return e.name==="Object"||e.name==="System"||e.name==="Math"?(t.className=`java.lang.${e.name}`,dt(ce("Class"))):(this.#o(t.pos,`the class literal ${e.name}.class`,!0),E)}#Dn(t,e){if(!e&&(this.#_||this.#R))return this.#Wt(t.selectPos,"non-static method getClass() cannot be referenced from a static context"),E;if(e||this.#qt(),e&&Q(e))return this.#e(t.selectPos,v.cantResolve,`${M(e)} cannot be dereferenced`),E;let n=ce("Class");return t.libraryCall={native:"Object.getClass",isStatic:!1,params:[],returnsValue:!0,display:"Object.getClass()"},dt(n)}#jn(t){return t.qualifier?this.#Qs(t,t.qualifier):this.#_?(this.#Wt(t.pos,"non-static variable super cannot be referenced from a static context"),E):(this.#qt(),this.#R?(this.#o(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),E):this.#a.isInterface?(this.#o(t.pos,"\'super\' in an interface",!0),E):this.#a.superType??(this.#a.superclass?X(this.#a.superclass):this.#a.librarySuperclass??H))}#Qs(t,e){let n=t.dotPos??t.pos,s=e.length===1?this.#me(e[0]):this.#mn(this.#Zs(e,t.qualifierPos??t.pos));if(!s){let a=e[e.length-1];return $t[a]||Bn.has(a)||this.#w.has(a)?(this.#o(t.qualifierPos??t.pos,`\'${a}.super\' of a library type`,!0),E):(this.#e(t.qualifierPos??t.pos,v.cantResolve,"cannot find symbol",[` symbol: class ${a}`,` location: class ${this.#a.displayName}`]),E)}let r=()=>(this.#e(n,v.cantResolve,`not an enclosing class: ${s.displayName}`),E);if(s.isInterface){if(this.#_||!this.#a.interfaces.includes(s))return r();let a=this.#a.interfaces.find(o=>o!==s&&pn(o,s));return a?(this.#e(n,v.cantResolve,`bad type qualifier ${s.displayName} in default super call`,[` redundant interface ${s.displayName} is extended by ${a.displayName}`]),E):(this.#qt(),this.#R?(this.#o(t.pos,"using \'super\' in the arguments of \'this(...)\' or \'super(...)\'",!0),E):(t.interfaceSymbol=s,X(s)))}if(s===this.#a){let a={...t};return delete a.qualifier,this.#jn(a)}for(let a=this.#a.outer;a;a=a.outer)if(a===s)return this.#o(t.qualifierPos??t.pos,`\'${s.displayName}.super\' of an enclosing class`,!0),E;return r()}#Zs(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.#Z(t.expression);if(r.tag==="error")return E;if(!this.#l)return this.#o(t.recordPattern.pos,"pattern variables in field initializers"),E;let a=[];return this.#un(t.recordPattern,r,!0,a)?(t.testedType=t.recordPattern.tested,t.patternBindings=a,ft):E}let e=this.#Z(t.expression),n=t.targetType.kind==="ClassType"&&!t.targetType.hasTypeArguments?this.#ct(t.targetType.names):null,s=n&&n.typeParams.length?dt(n):this.#V(t.targetType);if(e.tag==="error"||s.tag==="error")return E;if(Q(e)||Q(s))return Q(s)?this.#e(t.targetType.pos,v.syntax,"primitive patterns are a preview feature and are disabled by default.",[" (use --enable-preview to enable primitive patterns)"]):this.#e(t.expression.pos,v.incompatibleTypes,"unexpected type",[" required: reference",` found: ${M(e)}`]),E;if(s.tag==="library"&&s.args.some(r=>r.tag!=="wildcard"||r.bound!==null))return this.#o(t.targetType.pos,"instanceof with a generic type",!0),E;if(!ve(s,e))return this.#q(t.expression,e,s),E;if(t.testedType=s,t.binding){if(!this.#l)return this.#o(t.binding.pos,"pattern variables in field initializers"),E;t.binding.symbol=this.#hn(t.binding.name,s,t.binding.pos,t.binding.isFinal)}return ft}#un(t,e,n,s){let r=this.#er(t,e,n,s);return r||this.#Fn(t,s),r}#Fn(t,e){if(t.kind==="RecordPattern")return t.components.forEach(n=>this.#Fn(n,e));t.symbol||t.name==="_"||(t.symbol=this.#hn(t.name,E,t.namePos,t.isFinal),e.push(t.symbol))}#er(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.#ct(t.type.names):null;if(h=m&&m.typeParams.length?dt(m):this.#V(t.type,!0),h.tag==="error")return!1;if(n&&(Q(e)||Q(h))||!n&&Q(h)!==Q(e)||Q(h)&&!et(h,e))return this.#e(t.pos,v.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.#o(t.pos,"patterns of a parameterized type",!0),!1;if(!Q(h)&&!ve(h,e))return this.#q(t,e,h),!1}return t.tested=h,t.unconditional=Q(h)||z(W(e),W(h)),t.name!=="_"&&(t.symbol=this.#hn(t.name,h,t.namePos,t.isFinal),s.push(t.symbol)),!0}let r=this.#V(t.type,!0);if(r.tag==="error")return!1;if(r.tag!=="class"||!r.symbol.isRecord)return this.#e(t.pos,v.syntax,`deconstruction patterns can only be applied to records, ${M(r)} is not a record`),!1;let a=r.symbol,o=r;if(a.typeParams?.length&&!r.args?.length){let h=e.tag==="class"?Zt(e,a):null;o=h?.args?.length?h:r}if(!ve(o,e))return this.#q(t,e,o),!1;let c=a.components,u=c.map(h=>Ne(Ie(o,a,h.type)));if(c.length!==t.components.length){let h=t.components.map(m=>m.kind==="TypePattern"&&m.type===null?"var":M(this.#nr(m)));return this.#e(t.pos,v.syntax,"incorrect number of nested patterns",[` required: ${u.map(M).join(",")}`,` found: ${h.join(",")}`]),!1}t.tested=o,t.accessors=c.map(h=>this.#kt(a,h.name).find(m=>!m.isStatic&&m.params.length===0));let d=!0;return t.components.forEach((h,m)=>{this.#un(h,u[m],!1,s)||(d=!1)}),d}#nr(t){return t.type?this.#Wn(t.type):H}#hn(t,e,n,s){let r=this.#l;(this.#yt(t)||this.#Tn(t))&&this.#e(n,v.alreadyDefined,`variable ${t} is already defined in ${r.isConstructor?"constructor":"method"} ${this.#Ft(r)}`);let a={kind:"local",name:t,type:e,index:r.locals.length,slot:this.#k,isFinal:s,declPos:n,binding:!0};return this.#k+=De(e),r.maxSlots=Math.max(r.maxSlots,this.#k),r.locals.push(a),a}#ot(t,e){switch(t.kind){case"Parenthesized":return this.#ot(t.expression,e);case"Unary":return t.operator==="!"?this.#ot(t.operand,!e):[];case"InstanceOf":return e?t.binding?.symbol?[t.binding.symbol]:t.patternBindings??[]:[];case"Binary":return t.operator==="&&"&&e?[...this.#ot(t.left,!0),...this.#ot(t.right,!0)]:t.operator==="||"&&!e?[...this.#ot(t.left,!1),...this.#ot(t.right,!1)]:[];default:return[]}}#Kt(t,e){if(!t.length)return e();this.#vt();let n=this.#M[this.#M.length-1];for(let a of t)n.names.set(a.name,a);let s=e(),r=this.#k;return this.#wt(),this.#k=r,s}#Ue(t){let e=this.#M[this.#M.length-1];for(let n of t)e.names.has(n.name)||this.#yt(n.name)||(e.names.set(n.name,n),this.#Pt.push(n))}#sr(t){return t.qualifier?this.#rr(t,t.qualifier):this.#_?(this.#Wt(t.pos,"non-static variable this cannot be referenced from a static context"),E):(this.#qt(),this.#R?(this.#o(t.pos,"using \'this\' in the arguments of \'this(...)\'",!0),E):ue(this.#a))}#rr(t,e){let n=this.#pe(e),s=0,r=this.#a;for(;r&&r!==n;)r=r.outer,s++;return!n||!r?(this.#e(t.pos,v.syntax,`not an enclosing class: ${e[e.length-1]}`),E):this.#_||!this.#Ge(s)?(this.#Wt(t.pos,"non-static variable this cannot be referenced from a static context"),E):(this.#qt(),s&&(t.outerHops=s),ue(n))}#ir(t,e){let n=t.captures?.find(d=>d.local.name===e);if(n)return n.field;let s=this.#Rt.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,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}#ar(t){let e=this.#yt(t.identifier);if(e)return e.captureOf&&this.#Y.push({local:e,pos:t.pos,top:this.#a.topLevel}),t.symbol=e,e.constant&&(t.constant=e.constant),e.type;let n=this.#ee(t.identifier);if(n){let{field:r,hops:a}=n,o=this.#a;for(let u=0;u<a;u++)o=o.outer;if(r.isPrivate&&r.owner!==o&&!this.#Is(r.owner,o))return this.#e(t.pos,v.cantResolve,`${r.name} has private access in ${r.owner.displayName}`),E;if(!r.isStatic){if(this.#_||!this.#Ge(a))return this.#Wt(t.pos,`non-static variable ${r.name} cannot be referenced from a static context`),E;if(this.#qt(),this.#R&&a===0)return this.#o(t.pos,"using the object\'s fields in the arguments of \'this(...)\'"),E}let c=this.#E??this.#et;return a===0&&c&&!this.#Bt&&!r.capturedLocal&&r.owner===c.owner&&r.isStatic===c.isStatic&&r.order>=c.order?(this.#e(t.pos,v.syntax,r===c?"self-reference in initializer":"illegal forward reference"),E):(t.symbol=r,a>0&&!r.isStatic&&(t.outerHops=a),r.capturedLocal&&this.#Y.push({local:r.capturedLocal,pos:t.pos,top:this.#a.topLevel,inner:!0}),this.#dn(t,r,r.isStatic?void 0:ue(o)))}let s=this.#Me(t);if(s==="error")return E;if(s){t.imported=s;let r=this.#_n(s);return s.type=r,s.constant&&(t.constant=s.constant),r}return this.#Ot(t.identifier,t.pos)?E:(this.#e(t.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${t.identifier}`,` location: class ${this.#a.displayName}`]),E)}#dn(t,e,n){if(e.isFinal&&e.state==="pending"&&this.#$n(e),e.constant&&(t.constant=e.constant),!n)return e.type;let s=Ne(Ie(n,e.owner,e.type));return sa(t,e.type,s),s}#Xe(t){if(t.kind==="Name"&&t.staticOwner)return t.symbol={kind:"type",name:t.identifier},{kind:"type",name:t.identifier,qualified:!0};if(t.kind==="Name"&&!this.#yt(t.identifier)&&!this.#ee(t.identifier)&&this.#f(t.identifier,this.#It).length)return this.#v(t);if(t.kind==="Name"&&!this.#yt(t.identifier)&&!this.#ee(t.identifier)){let e=t.identifier,n=this.#me(e);if(n)return t.symbol={kind:"type",name:e,symbol:n},{kind:"type",name:e,symbol:n};let s=this.#ce([e]);if(s)return t.symbol={kind:"type",name:e,symbol:s},{kind:"type",name:e,symbol:s};if(e==="System"||e==="String"||Bn.has(e)||$t[e]&&this.#Ye(e))return t.symbol={kind:"type",name:e},{kind:"type",name:e};if(this.#w.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.#yt(t.target.identifier)&&this.#Ye(t.target.identifier))return{kind:"type",name:t.name,qualified:!0};let e=Is(t.target);if(e?.startsWith("java.")&&!this.#yt("java")&&!this.#ee("java")){if($t[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 a=e.slice(e.lastIndexOf(".")+1);if(Mt[t.name]===a&&$t[a]===e.slice(0,e.lastIndexOf(".")))return{kind:"type",name:t.name,qualified:!0};if((ks[e]??[]).includes(t.name))return this.#o(t.target.pos,`the class ${e}.${t.name}`,!0),E}let n=this.#mn(t.target),s=n?.membersByName.get(t.name);if(n&&s&&!n.fieldsByName.has(t.name))return t.typeSymbol=s,{kind:"type",name:s.name,symbol:s}}return this.#v(t)}#Ye(t){let e=$t[t];return Mt[t]?this.#y.has(t):e==="java.lang"||this.#y.has(t)||e!==void 0&&this.#s.has(e)||this.#O.compact}#mn(t){if(t.kind==="Name"&&!this.#yt(t.identifier)&&!this.#ee(t.identifier)){let e=this.#me(t.identifier);return e&&(t.symbol={kind:"type",name:t.identifier,symbol:e}),e}if(t.kind==="FieldAccess"){let e=this.#mn(t.target),n=e?.membersByName.get(t.name);if(e&&n&&!e.fieldsByName.has(t.name))return t.typeSymbol=n,n}return null}#Ee(t,e){if(!t)return` location: class ${this.#a.displayName}`;let n=it(t);return n.kind==="Name"&&n.symbol?.kind==="local"?` location: variable ${n.identifier} of type ${M(e)}`:n.kind==="Name"&&n.symbol?.kind==="field"?` location: variable ${n.identifier} of type ${M(e)}`:n.kind==="FieldAccess"&&(n.field&&n.field!=="length"||n.fieldSymbol)?` location: variable ${n.name} of type ${M(e)}`:` location: class ${M(e)}`}#ye(t,e,n){return!t.isPrivate||t.owner.topLevel===this.#a.topLevel?!0:(this.#e(e,v.cantResolve,`${n} has private access in ${t.owner.displayName}`),!1)}#_n(t){let e=it(t.target);if(e.kind==="Super"&&e.qualifier){if(this.#v(e).tag==="error")return E;if(e.interfaceSymbol)return this.#e(e.dotPos??e.pos,v.cantResolve,`not an enclosing class: ${e.interfaceSymbol.displayName}`),E}let n=this.#Xe(t.target);if("kind"in n&&n.kind==="type"){if(n.symbol){let d=n.symbol,h=this.#je(d,t.name);return h?h.isPrivate&&h.owner!==d?(this.#e(t.pos,v.cantResolve,`${h.name} has private access in ${h.owner.displayName}`),E):h.isStatic?this.#ye(h,t.pos,h.name)?(t.fieldSymbol=h,this.#dn(t,h)):E:(this.#Wt(t.pos,`non-static variable ${h.name} cannot be referenced from a static context`),E):(this.#e(t.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,` location: class ${d.displayName}`]),E)}if(n.name==="System")return t.name==="out"||t.name==="err"?(t.field=t.name==="out"?"System.out":"System.err",Fi):t.name==="in"?(t.field="System.in",dt(Wt("InputStream"))):(this.#e(t.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`," location: class System"]),E);let a=Object.hasOwn(vs,n.name)?vs[n.name]:{},o=Object.hasOwn(a,t.name)?a[t.name]:void 0;if(o)return t.constant=o.constant,o.type;let c=$t[n.name]?this.#ct([n.name]):n.name==="String"&&!n.symbol?Wt("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.#o(t.pos,`the field ${n.name}.${t.name}`,!0),E)}let s=n,r=s.tag==="typevar"&&s.symbol?s.symbol.bounds.find(a=>a.tag==="class")??H:s;switch(r.tag){case"error":return E;case"class":{let a=this.#je(r.symbol,t.name);if(a)return a.isPrivate&&a.owner!==r.symbol?(this.#e(t.pos,v.cantResolve,`${a.name} has private access in ${a.owner.displayName}`),E):this.#ye(a,t.pos,a.name)?(t.fieldSymbol=a,this.#dn(t,a,a.isStatic?void 0:s)):E;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,v.cantResolve,"<null> cannot be dereferenced"),E;case"array":if(t.name==="length")return t.field="length",U;break;default:if(Q(s)||s.tag==="void")return this.#e(t.pos,v.cantResolve,`${M(s)} cannot be dereferenced`),E}return this.#e(t.pos,v.cantResolve,"cannot find symbol",[` symbol: variable ${t.name}`,this.#Ee(t.target,s),...Dt([s])]),E}#se(t){return t.map(e=>{let n=it(e);if(n.kind==="MethodRef")return{tag:"lambda",arity:this.#Ve(n)?.params.length??-1,text:ps(n)};if(n.kind==="Lambda")return{tag:"lambda",arity:n.params.length,text:ps(n)};let s=this.#Un(e);if(s)return this.#A.add(e),{tag:"diamond",symbol:s,fromArgs:null};let r=n.kind==="NewObject"&&n.body&&n.classType.kind==="ClassType"&&n.classType.diamond?this.#ct(n.classType.names):null;if(r)return this.#A.add(e),{tag:"diamond",symbol:r,fromArgs:null};this.#bt=e;let a=this.#Z(e),o=this.#Et.get(n);if(!o||a.tag!=="library"||n.kind!=="MethodCall")return a;let c=new Map;return this.#re(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=Xe([h],o.symbol,aa(o.symbol,o.method,o.types.length));return{tag:"wildcard",bound:u,poly:{name:h.name,lows:c.get(h.name)??[],where:m}}})}})}#Un(t){if(t.kind!=="MethodCall")return null;let e;if(t.target){let a=Ye(t.target);if(!a||this.#yt(a[0])||this.#ee(a[0]))return null;e=a.length===2&&Mt[a[1]]===a[0]&&this.#Ye(a[0])?ce(a[1])??null:this.#ct(a)}else{let a=this.#n.size||this.#g.length?this.#f(t.name,this.#st):[];if(a.length!==1||this.#Lt(t.name))return null;e=this.#zt(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=it(a);return o.kind==="Lambda"&&o.params.some(c=>!c.type)||o.kind==="MethodRef"&&(!this.#Ve(o)||this.#pn(o))||this.#Un(o)!==null})?s.symbol:null}#Ae(t){for(let e of t)this.#A.has(e)&&(this.#A.delete(e),e.type=this.#v(e))}#Ut(t,e){return`${t}(${e.map(M).join(",")})`}#or(t,e,n=ue(t)){let s=this.#kt(t,e).map(a=>{let o=c=>a.isStatic?c:Ne(Ie(n,a.owner,c));return{owner:a.owner.displayName,name:a.name,params:a.params.map(o),returnType:o(a.returnType),method:a,...ra(a)?{varargs:!0}:{}}}),r=Oe[e];return r&&Object.hasOwn(Oe,e)&&!s.some(a=>a.params.length===r.params.length&&a.params.every((o,c)=>et(o,r.params[c])))&&s.push(r),s}#fn(t,e,n){return!t.builtin||t.constructors.some(s=>s.params.length===e)?!1:(this.#o(n,`this ${t.name} constructor`,!0),!0)}#lr(t,e){if(!this.#jt(X(t)))return null;let n=this.#kt(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":Eo[t.binaryName]?.includes(e.name)&&!n.length?`the method ${t.name}.${e.name}()`:null}#Be(t,e){let n=t.isEnum?"enum":t.isRecord?"record":"class",s=e?.tag==="class"?Pn(e):new Map,r=e!==void 0&&Rn(e);return t.constructors.map(a=>({owner:t.displayName,ownerKind:n,name:t.name,params:a.params.map(o=>r?W(o):Ht(o,s)),returnType:St,method:a,...ra(a)?{varargs:!0}:{}}))}#Ie(t,e){if(!t.expanded||!t.method)return;let n=t.params[t.params.length-1],s=n.element;return!wn(n)&&!this.#At(t.method.declaration.modifiers,"SafeVarargs")&&this.#nt(e,"unchecked",`unchecked generic array creation for varargs parameter of type ${M(n)}`,Dt([n])),{from:t.params.length-1,element:s}}#cr(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{na(c,ia(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(pr));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===Dn||k.tag==="wildcard"||k.tag==="typevar"&&!k.symbol||d.get(p).every(T=>z(T,k))&&u.set(p,k)}}r.forEach((m,p)=>{let k=it(m),T=k.kind==="MethodRef"&&t.params[p]?Es(Ht(t.params[p],u)):null;if(!T||k.kind!=="MethodRef")return;let C=this.#Ve(k,T.params[0]&&!ae(T.params[0],c)?T.params[0]:void 0);C&&(C.params.forEach((S,w)=>T.params[w]&&bt(T.params[w],Qt(S)??S,u)),C.returnType.tag!=="void"&&bt(T.returnType,Qt(C.returnType)??C.returnType,u))}),a&&o.some(m=>!u.has(m.key))&&this.#ur(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(S=>z(p,Ht(S,u))))continue;let k=d.get(m.key)??[p],T=`inference variable ${m.name} has incompatible bounds`,C=k.length>1&&m.bounds.some(S=>ae(S,[m.key]))?[T,` equality constraints: ${k.map(M).join(",")}`,` lower bounds: ${[...k].reverse().map(M).join(",")}`]:[T,` upper bounds: ${m.bounds.map(M).join(",")}`,` lower bounds: ${k.map(M).join(",")}`];return{...t,shown:t.params,problem:{reason:C.join(`\n`)}}}}for(let h of o)u.has(h.key)||u.set(h.key,W(ke(h)));return{...t,shown:t.params,params:t.params.map(h=>Ht(h,u)),returnType:Ht(t.returnType,u)}}#ur(t,e,n,s){let r=a=>ae(a,s.filter(o=>!n.has(o)));e.forEach((a,o)=>{let c=it(a);if(c.kind!=="Lambda"||c.method||!t[o])return;let u=Ht(t[o],n),d=this.#bn(u);if("problem"in d||d.params.some(r)||!r(d.returnType))return;this.#Sn(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)})}#hr(t){let e=0;for(let n=this.#a;n;n=n.outer,e++)if(this.#kt(n,t).length||Object.hasOwn(Oe,t))return{owner:n,hops:e};return{owner:this.#a,hops:0}}#dr(t,e){return t.tag!=="class"?null:Ae(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.#se(t.args):null;if(s&&(this.#n.size||this.#g.length)&&!s.some(m=>m.tag==="error")&&!this.#G(t,s))return E;t.target&&(n=this.#Xe(t.target));let r=s??this.#se(t.args);if(r.some(m=>m.tag==="error")||n&&"tag"in n&&n.tag==="error")return E;let a=t.typeArguments?t.typeArguments.map(m=>this.#_e(m)):null;if(a?.some(m=>m.tag==="error"))return E;let o=n;if(n&&"tag"in n&&n.tag==="typevar"&&n.symbol){let m=k=>k.tag==="class"&&this.#kt(k.symbol,t.name).length>0||k.tag==="library"&&k.symbol.methods.some(T=>T.name===t.name),p=n.symbol.bounds.find(m)??(Object.hasOwn(Oe,t.name)?H:null);if(!p)return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`,this.#Ee(t.target,n),...Dt([n,...r])]),E;n=p}if(t.name==="getClass"&&!r.length&&(n===null||"tag"in n)&&!(n===null&&this.#kt(this.#a,"getClass").length))return this.#Dn(t,n);let c=n===null?this.#a.isEnum:"tag"in n&&n.tag==="class"&&n.symbol.isEnum;if(t.name==="getDeclaringClass"&&!r.length&&c){let m=this.#Dn(t,n);return t.libraryCall&&(t.libraryCall.native="Enum.getDeclaringClass",t.libraryCall.display=`${n?.symbol.binaryName??this.#a.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.#hr(t.name),Cs.has(t.name)&&!this.#kt(m,t.name).length)return this.#o(t.selectPos,`the method Object.${t.name}()`,!0),E;let k=this.#lr(m,t);if(k)return this.#o(t.selectPos,k,!0),E;let T=d?o:ue(m),C=this.#or(m,t.name,T),S=C.map(P=>this.#cr(P,r,a,e,t.args,C.length===1)),w=t.target?it(t.target):null,I=w?.kind==="Super"?w.interfaceSymbol:void 0;if(!S.length&&I)return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`]),E;let R=P=>P.params.length===r.length&&P.params.every((j,G)=>he(j,r[G])||Qe(j,r[G]))||P.varargs===!0&&r.length>=P.params.length-1,N=!u&&!I&&!S.some(R)?this.#dr(T,t.name):null;if(N){if(!n){if(p>0)return this.#o(t.selectPos,"calling an enclosing class\'s library methods by simple name",!0),E;if(this.#_)return this.#Wt(t.selectPos,`non-static method ${t.name}(${N.symbol.methods.find(j=>j.name===t.name).params.map(M).join(",")}) cannot be referenced from a static context`),E;let P={kind:"This",depth:0,pos:t.pos,start:t.pos,end:t.pos};this.#v(P),t.target=P}return this.#Oe(t,N.symbol,N,r,e)}if(!S.length){let P=this.#Os(m,t.name);if(P)return this.#e(t.selectPos,v.cantResolve,`${t.name}(${P.params.map(M).join(",")}) has private access in ${P.owner.displayName}`),E;if(!n&&this.#Ot(t.name,t.selectPos))return E;let j=u?` location: class ${m.displayName}`:n?this.#Ee(t.target,n):` location: class ${this.#a.displayName}`;return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`,j,...Dt([...d?[n]:[],...r])]),E}let A=this.#rt({pos:t.selectPos,name:t.name},S,r,"method");if(!A)return E;let L=A.method?A.method.isStatic:!1;if(I&&L)return this.#e(t.pos,v.cantResolve,"illegal static interface method call",[` the receiver expression should be replaced with the type qualifier \'${I.displayName}\'`]),E;let J=u||!n&&(this.#_||!this.#Ge(p));if(!L&&J)return this.#Wt(t.selectPos,`non-static method ${t.name}(${A.params.map(M).join(",")}) cannot be referenced from a static context`),E;if(!L&&!n&&this.#qt(),!L&&!n&&this.#R&&p===0)return this.#o(t.selectPos,"calling the object\'s methods in the arguments of \'this(...)\'"),E;let D=t.target!==null&&it(t.target).kind==="Super";if(A.method){if(!this.#ye(A.method,t.selectPos,`${t.name}(${A.params.map(M).join(",")})`))return E;if(D&&A.method.isAbstract)return this.#e(t.selectPos,v.syntax,`abstract method ${this.#Ft(A.method)} in ${A.method.owner.displayName} cannot be accessed directly`),E;if(u&&A.method.isStatic&&A.method.owner.isInterface&&A.method.owner!==m)return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`,` location: class ${m.displayName}`]),E;this.#ie(t.args,A.params),t.method=A.method;let P=this.#Ie(A,t.pos);P&&(t.varargs=P);let j=A.method.params;d&&Rn(o)&&j.some(G=>Xn([G]).some(Z=>Z.ofClass))&&this.#nt(t.pos,"unchecked",`unchecked call to ${this.#Ft(A.method)} as a member of the raw type ${M(o)}`,Dt(j)),this.#Bn(t.pos,`method ${t.name} in ${m.isInterface?"interface":"class"} ${m.displayName}`,j,A.params,r,t.args,Dt),this.#Qe(t.args,j.map(W)),t.qualifier=A.method.isStatic?A.method.owner.binaryName:m.binaryName}else t.objectMethod=A.objectMethod,t.qualifier=m.isInterface&&!D?m.binaryName:"Object";return D&&(t.isSuper=!0),!n&&p>0&&!L&&(t.outerHops=p),A.method&&sa(t,A.method.returnType,A.returnType),A.returnType}if("kind"in n&&n.name==="IO")return this.#Er(t,r);if("kind"in n&&n.name==="Math"&&Object.hasOwn(Vn,t.name))return this.#Cr(t,r);if("kind"in n&&!n.symbol&&(n.name==="Math"||n.name==="String"))return this.#Oe(t,Wt(n.name),null,r,e);if("kind"in n&&this.#w.has(n.name))return this.#o(t.target.pos,`the class ${this.#w.get(n.name)}`,!0),E;if("kind"in n&&$t[n.name]&&(n.qualified||this.#Ye(n.name)))return this.#Oe(t,ce(n.name),null,r,e);if("kind"in n)return n.name==="System"&&!n.symbol?zi.has(t.name)?this.#Oe(t,Wt("System"),null,r,e):(this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`," location: class System"]),E):(this.#o(t.selectPos,`${n.name}.${t.name}()`,!0),E);let h=n.tag==="diamond"?this.#yn(n):n;switch(h.tag){case"null":return this.#e(t.selectPos,v.cantResolve,"<null> cannot be dereferenced"),E;case"printstream":return this.#Lr(t,h,r);case"library":return this.#Oe(t,h.symbol,h,r,e);case"string":{let m=Object.hasOwn(zn,t.name)?zn[t.name]:void 0;if(m){let p=this.#rt({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.stringMethod=t.name,p.returnType):E}if(So.has(t.name)){let p=Wt("String");return this.#Oe(t,p,dt(p),r,e)}break}case"object":case"array":{let m=Object.hasOwn(Oe,t.name)?Oe[t.name]:void 0;if(m){let p=this.#rt({pos:t.selectPos,name:t.name},[m],r,"method");return p?(t.objectMethod=p.objectMethod,t.qualifier="Object",it(t.target).kind==="Super"&&(t.isSuper=!0),p.returnType):E}if(h.tag==="array"&&t.name==="clone"&&!r.length)return Wt("String"),t.libraryCall={native:"Array.clone()",isStatic:!1,params:[],returnsValue:!0,display:`${Rt(h)}.clone()`},h;if(Cs.has(t.name)||h.tag==="array"&&xo.has(t.name))return this.#o(t.selectPos,h.tag==="array"?`the array method ${t.name}()`:`the method Object.${t.name}()`,!0),E;break}default:if(Q(h)||h.tag==="void")return this.#e(t.selectPos,v.cantResolve,`${M(h)} cannot be dereferenced`),E}return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,r)}`,this.#Ee(t.target,h)]),E}#Oe(t,e,n,s,r){let a=n?n.args:[],o=n!==null&&!n.args.length&&e.typeParams.length>0,c=e.methods.filter(D=>D.name===t.name);if(!c.length&&(e.unsupported.has(t.name)||Cs.has(t.name)))return this.#o(t.selectPos,`the ${e.name} method ${t.name}()`,!0),E;if(!c.length){let D=n?this.#Ee(t.target,n):` location: class ${e.name}`;return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,s)}`,D]),E}let u=t.typeArguments?t.typeArguments.map(D=>this.#_e(D)):null,d=D=>u!==null&&u.length===(D.typeParams?.length??0)&&u.length>0,h=c.map(D=>{let P=[...D.isStatic?[]:e.typeParams,...D.typeParams??[]],j=u&&u.length===(D.typeParams?.length??0)?u:this.#pr(D,s),G=[...D.isStatic?[]:a.map(Ho),...j],Z=[...D.isStatic?[]:a.map(Ne),...j],qt=o&&!D.isStatic;return{owner:D.owner,name:D.name,params:D.params.map(be=>qt?W(be):Tt(be,P,G)),returnType:qt?W(D.returnType):Tt(D.returnType,P,Z),library:D,...D.varargs?{varargs:!0}:{}}}),m=this.#rt({pos:t.selectPos,name:t.name,imported:Gi(t)},h,s,"method");if(!m)return E;let p=m.library,k=this.#re(p,s),T=!o&&s.some((D,P)=>p.params[P]!==void 0&&Qe(p.params[P],D));if(p.comparableParams&&!T&&p.comparableParams.some(D=>k.has(D)&&!ua(k.get(D))))return this.#o(t.selectPos,`${e.name}.${t.name}() of elements that are not Comparable`,!0),E;if(!p.native)return this.#o(t.selectPos,`${e.name}.${t.name}(${p.params.map($e).join(", ")})`,!0),E;if(!p.isStatic&&!n)return this.#e(t.selectPos,v.cantResolve,`non-static method ${t.name}(${m.params.map(M).join(",")}) cannot be referenced from a static context`),E;let C=!o&&p.typeParams?.length&&!d(p)&&t.args.some(D=>["Lambda","MethodRef"].includes(it(D).kind)||this.#A.has(D)),S=t.args.filter(D=>this.#A.has(D)),w=C?this.#fr(p,e,a,t.args,s,r,m.params):null,I=!C&&p.isStatic&&p.typeParams?.length&&!d(p)&&r?this.#Vn(t,e,p,s,r):null;if(!C&&!r&&p.isStatic&&p.typeParams?.length&&!d(p)&&p.returnType.tag==="library"){let D=new Map;this.#re(p,s,D);let P=p.returnType.args.map(j=>j.tag==="typevar"&&!j.symbol&&D.has(j.name));P.some(Boolean)&&this.#Et.set(t,{flags:P,symbol:e,method:p,types:s})}if(I==="error")return E;let R=I?p.typeParams.map(D=>I.get(D)??H):[];I&&(m.params=m.params.map((D,P)=>Tt(p.params[Math.min(P,p.params.length-1)],p.typeParams,R))),this.#ie(t.args,w?w.params:m.params);let N=t.target?it(t.target).kind:null;if(p.isProtected&&!(N==="This"||N==="Super"))return this.#e(t.selectPos,v.cantResolve,`${p.name}(${p.params.map(M).join(",")}) has protected access in ${e.name}`,Xe(p.params,e,p)),E;t.libraryCall=this.#He(p,n??dt(e),m.params),u||(t.libraryMethod={method:p,symbol:e,classArgs:a}),m.expanded&&(t.libraryCall.varargsFrom=m.params.length-1),N==="Super"&&(t.libraryCall.onBase=!0);let A=D=>Xe(D,e,p);if(o&&!p.isStatic&&p.params.some(D=>ae(D,null))&&this.#nt(t.pos,"unchecked",`unchecked call to ${p.name}(${p.params.map(M).join(",")}) as a member of the raw type ${e.name}`,A(p.params)),this.#Bn(t.pos,`method ${p.name} in ${e.isInterface?"interface":"class"} ${e.name}`,p.params,m.params,s,t.args,A),this.#Qe(t.args,p.params.map(W)),o)return Ne(m.returnType);if(T)return W(p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a));let L=d(p)?m.returnType:I?Tt(p.returnType,p.typeParams,R):w?.returnType??this.#Hn(p,e,a,s,r)??m.returnType;if(p.typeParams?.length&&S.length&&!d(p)){let D=new Map(w?.bound??this.#re(p,s)),P=p.isStatic?p.returnType:Xt(p.returnType,e.typeParams,a);if(r?.tag==="library"&&P.tag==="library"){let j=Pt(P,r.symbol);j&&j.args.forEach((G,Z)=>fe(r.args[Z])&&bt(G,fe(r.args[Z]),D))}t.args.forEach((j,G)=>S.includes(j)&&j.type&&bt(p.params[Math.min(G,p.params.length-1)],j.type,D)),L=this.#Hn(p,e,a,s,r,D)??L}let J=L.tag==="typevar"&&!L.symbol?H:Ne(L);return p.returnType.tag==="typevar"&&Bo(J)&&(t.genericCast=W(J)),J}#Bn(t,e,n,s,r,a,o){let c=r.map((u,d)=>s[d]!==void 0&&(!he(s[d],u)||n[d]!==void 0)&&Qe(n[d]??s[d],u));c.some(Boolean)&&(this.#nt(t,"unchecked",`unchecked method invocation: ${e} is applied to given types`,[` required: ${n.map(M).join(",")}`,` found: ${r.map(M).join(",")}`,...o([...n,...r])]),c.forEach((u,d)=>{u&&this.#nt(a[d].pos,"unchecked","unchecked conversion",[` required: ${M(n[d])}`,` found: ${M(r[d])}`,...o([n[d],r[d]])])}))}#Qe(t,e){t.forEach((n,s)=>{e[Math.min(s,e.length-1)]?.tag==="object"&&delete it(n).genericCast})}#fr(t,e,n,s,r,a,o){let c=t.typeParams,u=A=>t.isStatic?A:Xt(A,e.typeParams,n),d=A=>u(t.params[Math.min(A,t.params.length-1)]),h=this.#re(t,r),m=A=>ae(A,c.filter(L=>!h.has(L))),p=(A,L)=>{let J=L.params[0]&&!m(L.params[0])?L.params[0]:void 0;if(!J&&this.#pn(A))return!1;let D=this.#Ve(A,J);return D&&(D.params.forEach((P,j)=>L.params[j]&&bt(L.params[j],P,h)),D.returnType.tag!=="void"&&bt(L.returnType,Qt(D.returnType)??D.returnType,h)),!0},k=[];s.forEach((A,L)=>{let J=it(A),D=Es(d(L));D&&(J.kind==="MethodRef"?p(J,D)||k.push(L):J.kind==="Lambda"&&J.params.length&&J.params.every(P=>P.type)&&J.params.forEach((P,j)=>{let G=this.#V(P.type);G.tag!=="error"&&D.params[j]&&bt(D.params[j],G,h)}))});let T=u(t.returnType);if(a?.tag==="library"&&T.tag==="library"){let A=Pt(T,a.symbol);A&&A.args.forEach((L,J)=>fe(a.args[J])&&bt(L,fe(a.args[J]),h))}for(let A of k){let L=c.filter(D=>h.has(D)),J=Es(Xt(d(A),L,L.map(D=>h.get(D))));J&&p(it(s[A]),J)}let C=()=>c.filter(A=>h.has(A)),S=A=>Xt(d(A),C(),C().map(L=>h.get(L)));s.forEach((A,L)=>{this.#A.has(A)&&(this.#A.delete(A),A.type=this.#v(A,S(L)),A.type.tag!=="error"&&bt(d(L),A.type,h))});let w=new Map;s.forEach((A,L)=>{let J=it(A);if(J.kind==="Lambda"?J.method:J.kind!=="MethodRef"||J.lambda)return;let D=S(L),P=Es(D);if(!P||P.params.some(m)||!m(P.returnType))return;let j;J.kind==="Lambda"?(this.#Sn(J,D,!0),j=J.method?.returnType):J.kind==="MethodRef"&&(this.#Kn(J,D,!0),j=J.lambda?.method?.returnType),j?.tag==="diamond"&&P.returnType.tag==="typevar"?w.set(P.returnType.name,j):j&&j.tag!=="error"&&j.tag!=="void"&&bt(P.returnType,Qt(j)??j,h)});for(let[A,L]of w){if(h.has(A))continue;let J=t.typeParamBounds?.[A],D=c.filter(G=>h.has(G)),P=J?Xt(u(J),D,D.map(G=>h.get(G))):void 0,j=As(L.symbol,P);h.set(A,dt(L.symbol,L.symbol.typeParams.map(G=>j.get(G)??H)))}let I=c.map(A=>h.get(A)??H),R=A=>Tt(u(A),c,I);return{params:o.map((A,L)=>R(t.params[Math.min(L,t.params.length-1)])),returnType:R(t.returnType),bound:h}}#pn(t){if(!t.target||t.name==="new"||t.arrayType)return!1;let e=Ye(t.target);if(!e||this.#yt(e[0])||this.#ee(e[0]))return!1;let n=this.#pe(e);return n!==null&&(n.typeParams?.length??0)>0&&this.#kt(n,t.name).some(s=>!s.isStatic)}#Ve(t,e){if(t.arrayType){let c=this.#V(t.arrayType);return c.tag==="error"?null:{params:[U],returnType:c}}if(!t.target||t.name==="new")return null;let n=Ye(t.target);if(!n||this.#yt(n[0])||this.#ee(n[0]))return null;let s=this.#pe(n);if(s){let c=this.#kt(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=Zt(e,s);if(!d?.args?.length)return null;let h=m=>Ne(Ie(d,u.owner,m));return{params:[d,...u.params.map(h)],returnType:h(u.returnType)}}return{params:[X(s),...u.params],returnType:u.returnType}}if(n.length===1&&n[0]==="String"){if(Object.hasOwn(zn,t.name))return{params:[ut,...zn[t.name].params],returnType:zn[t.name].returnType};let c=Wt("String").methods.filter(u=>u.name===t.name);return c.length!==1||c[0].varargs?null:{params:c[0].isStatic?c[0].params:[ut,...c[0].params],returnType:c[0].returnType}}let r=this.#ct(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:[dt(r),...o.params],returnType:o.returnType}}#re(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=tt(d)?Sr(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"&&tt(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(pr)),n?.set(u,d));return s}#Vn(t,e,n,s,r,a=!1){let o=n.returnType;if(r.tag!=="library"||o.tag!=="library")return null;let c=Pt(o,r.symbol);if(!c)return null;let u=new Map,d=this.#re(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 T=u.get(p.name);if(T.some(C=>!z(C,k))){if(a)return null;let C=T.filter((S,w)=>T.findIndex(I=>et(I,S))===w);return this.#e(t.pos,v.incompatibleTypes,`incompatible types: inference variable ${p.name} has incompatible bounds`,[` equality constraints: ${M(k)}`,` lower bounds: ${[...C].reverse().map(M).join(",")}`,...Xe([p],e,aa(e,n,s.length))]),"error"}et(d.get(p.name),k)||(d.set(p.name,k),h=!0)}return h?d:null}#pr(t,e){if(!t.typeParams)return[];let n=this.#re(t,e);return t.typeParams.map(s=>n.get(s)??H)}#Hn(t,e,n,s,r,a){if(!t.typeParams)return null;let o=a??this.#re(t,s),c=t.isStatic?t.returnType:Xt(t.returnType,e.typeParams,n);if(t.typeParams.every(m=>o.has(m)))return a?Tt(c,t.typeParams,t.typeParams.map(m=>o.get(m))):null;if(r?.tag==="library"&&c.tag==="library"){let m=Pt(c,r.symbol);m&&m.args.forEach((p,k)=>fe(r.args[k])&&bt(p,fe(r.args[k]),o))}r&&c.tag==="typevar"&&!c.symbol&&t.typeParams.includes(c.name)&&!o.has(c.name)&&tt(r)&&o.set(c.name,r);let u=t.typeParams.map(m=>o.get(m)??H),d=Tt(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}#He(t,e,n){let s=e.tag==="library"?ea(e.symbol):M(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:ko[t.native]??Co}:{},native:t.native,isStatic:t.isStatic,params:n,returnsValue:t.name==="<init>"||t.returnType.tag!=="void",display:`${s}.${r}(${t.params.map($e).join(", ")})`,...t.throws?{throws:t.throws}:{}}}#yn(t){return dt(t.symbol,t.fromArgs??t.symbol.typeParams.map(()=>H))}#ie(t,e){t.forEach((n,s)=>{let r=it(n),a=r.kind==="MethodCall"?this.#Et.get(r):void 0;if(a&&r.kind==="MethodCall"){this.#Et.delete(r);let d=e[Math.min(s,e.length-1)],h=d?this.#Vn(r,a.symbol,a.method,a.types,d,!0):null;if(h&&h!=="error"){let m=a.method.typeParams.map(k=>h.get(k)??H),p=Tt(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,T)=>Tt(a.method.params[Math.min(T,a.method.params.length-1)],a.method.typeParams,m)))}return}if(this.#A.has(n)){this.#A.delete(n),n.type=this.#v(n,e[Math.min(s,e.length-1)]);return}let o=it(n).kind;if(o==="Lambda"||o==="MethodRef"){this.#v(n,e[s]);return}if(n.kind==="NewObject"&&n.openDiamond){let{symbol:d,bound:h}=n.openDiamond;delete n.openDiamond;let m=fr(d,e[Math.min(s,e.length-1)]);n.type=X(d,d.typeParams.map(p=>h.get(p.key)??m.get(p.key)??W(ke(p))));return}let c=n.type;if(c?.tag!=="diamond")return;let u=As(c.symbol,e[s]);n.type=dt(c.symbol,c.symbol.typeParams.map((d,h)=>u.get(d)??c.fromArgs?.[h]??H))})}#gn(t,e,n){let s=t.symbol,r=s.constructors.map(c=>({owner:s.name,name:s.name,params:c.params.map(u=>Tt(u,s.typeParams,t.args)),returnType:St,library:c,...c.varargs?{varargs:!0}:{}})),a=this.#rt({pos:n,name:s.name},r,e,"constructor");if(!a)return null;let o=a.library;return o.native?a.expanded?(this.#o(n,`a variable-arity constructor of ${s.name} as a superclass constructor`,!0),null):{candidate:a,call:this.#He({...o,name:"<init>"},dt(s),a.params)}:(this.#o(n,`the constructor ${s.name}(${o.params.map($e).join(", ")})`,!0),null)}#yr(t,e,n){let s=e.tag==="library"||e.tag==="diamond"?e.symbol:null;if(!s)return E;let r=this.#se(t.args);if(r.some(T=>T.tag==="error"))return E;if(s.isInterface||s.isAbstract||s.name==="Number")return this.#e(t.pos,v.cantResolve,`${s.name} is abstract; cannot be instantiated`),E;if(!s.constructors.length)return this.#o(t.pos,`creating ${We(s.name)} with \'new\'`,!0),E;let a=e.tag==="diamond";n===qn&&(n=void 0);let o=a&&n?As(s,n,!0):new Map,c=T=>{if(!a)return e.args.slice();let C=new Map(o);return T.params.forEach((S,w)=>bt(S,r[w],C)),s.typeParams.map(S=>C.get(S)??H)},u=e.tag==="library"&&!e.args.length&&s.typeParams.length>0,d=s.constructors.map(T=>{let C=c(T);return{owner:s.name,name:s.name,params:T.params.map(S=>u?W(S):Tt(S,s.typeParams,C)),returnType:St,library:T,...T.varargs?{varargs:!0}:{}}}),h=this.#rt({pos:t.pos,name:s.name},d,r,"constructor");if(!h)return E;let m=h.library;if(!m.native)return this.#o(t.pos,`the constructor ${s.name}(${m.params.map($e).join(", ")})`,!0),E;u&&m.params.some(T=>ae(T,null))&&this.#nt(t.pos,"unchecked",`unchecked call to ${s.name}(${m.params.map(M).join(",")}) as a member of the raw type ${s.name}`,Xe(m.params,s)),s.box&&this.#nt(t.pos,"deprecation",`${s.name}(${m.params.map(M).join(",")}) in ${s.name} has been deprecated`),this.#ie(t.args,h.params);let p=a&&r.some((T,C)=>m.params[C]!==void 0&&Qe(m.params[C],T));p&&this.#nt(t.pos,"unchecked",`unchecked method invocation: constructor <init> in class ${s.name} is applied to given types`,[` required: ${m.params.map(M).join(",")}`,` found: ${r.map(M).join(",")}`,...Xe([...m.params,...r],s)]);let k;if(p)k=dt(s);else if(!a)k=e;else{let T=new Map(o);m.params.forEach((w,I)=>bt(w,r[I],T));let C=s.typeParams.every(w=>T.has(w)),S=s.typeParams.map(w=>T.get(w)??H);k=C||n?dt(s,S):{tag:"diamond",symbol:s,fromArgs:s.typeParams.some(w=>T.has(w))?S:null}}return t.libraryCall=this.#He({...m,name:"<init>"},dt(s),h.params),h.expanded&&(t.libraryCall.varargsFrom=h.params.length-1),k}#gr(t,e){if(e.length)return this.#e(t.pos,v.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${e.map(M).join(",")}`," reason: actual and formal argument lists differ in length"]),E;Wt("String");let n={name:"<init>",params:[],returnType:H,isStatic:!0,native:"Object.<init>()",owner:"Object"};return t.libraryCall=this.#He(n,H,[]),H}#br(t){let e=this.#se(t.args);if(e.some(a=>a.tag==="error"))return E;let s=Wt("String").constructors.map(a=>({owner:"String",name:"String",params:a.params,returnType:St,library:a})),r=this.#rt({pos:t.pos,name:"String"},s,e,"constructor");return r?(t.libraryCall=this.#He({...r.library,name:"<init>"},ut,r.params),ut):E}#Sr(t,e){if(t.body)return this.#Tr(t,t.body,e);let n=this.#bt===t;this.#bt=null;let s=t.outerExpression?this.#xr(t):this.#V(t.classType);if(s.tag==="library"||s.tag==="diamond")return this.#yr(t,s,e);if(s.tag==="string")return this.#br(t);let r=this.#se(t.args);if(s.tag==="error"||r.some(m=>m.tag==="error"))return E;if(s.tag==="typevar")return this.#e(t.classType.pos,v.incompatibleTypes,"unexpected type",[" required: class",` found: type parameter ${s.name}`,...Dt([s])]),E;if(s.tag==="object")return this.#gr(t,r);if(s.tag!=="class")return this.#o(t.pos,`creating ${We(M(s))} with \'new\'`,!0),E;let a=s.symbol;if(a.isEnum)return this.#e(t.pos,v.syntax,"enum classes may not be instantiated"),E;if(a.isAbstract)return this.#e(t.pos,v.cantResolve,`${a.displayName} is abstract; cannot be instantiated`),E;if(this.#fn(a,r.length,t.pos))return E;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,v.cantResolve,`cannot infer type arguments for ${a.displayName}`,[` reason: cannot use \'<>\' with non-generic class ${a.displayName}`]),E;let u=this.#Be(a,c?void 0:s),d=s;if(c){let m=a.typeParams,p=m.map(N=>N.key),k=fr(a,e),T=new Map;u=u.map(N=>{let A=new Map(k),L=new Map;na(p,ia(N,r),r,A,L);for(let D of m){let P=L.get(D.key);if(!P)continue;let j=k.get(D.key);if(j&&P.some(G=>!z(G,j))){let G=[`inference variable ${D.name} has incompatible bounds`,` equality constraints: ${M(j)}`,` lower bounds: ${P.map(M).join(",")}`];return{...N,shown:N.params,problem:{reason:G.join(`\n`),diamond:!0}}}A.has(D.key)||A.set(D.key,P.reduce(pr))}let J={...N,shown:N.params,params:N.params.map(D=>Ht(D,A))};return T.set(J,A),J});let C=u.filter(N=>N.params.length===r.length),S=C.length===1&&C[0].problem?.diamond?C[0]:null;if(S){let[N,...A]=S.problem.reason.split(`\n`);return this.#e(o.typeArgumentsPos??t.pos,v.incompatibleTypes,`incompatible types: cannot infer type arguments for ${a.displayName}<>`,[` reason: ${N}`,...A.map(L=>` ${L}`),...Dt(m.map(ke))]),E}let w=this.#rt({pos:t.pos,name:a.name},u,r,"constructor");if(!w)return E;let I=T.get(u.find(N=>N.method===w.method))??new Map;return m.filter(N=>!I.has(N.key)).length&&n&&!e?(t.openDiamond={symbol:a,bound:I},d=X(a,m.map(N=>I.get(N.key)??Dn))):d=X(a,m.map(N=>I.get(N.key)??W(ke(N)))),this.#Gn(t,a,w,d)}let h=this.#rt({pos:t.pos,name:a.name},u,r,"constructor");return h?(Rn(s)&&h.method.params.some(m=>Xn([m]).length)&&this.#nt(t.pos,"unchecked",`unchecked call to ${this.#Ft(h.method).replace(/^[^(]*/,a.name)} as a member of the raw type ${a.displayName}`,Dt(h.method.params)),this.#Qe(t.args,h.method.params.map(W)),this.#Gn(t,a,h,d)):E}#Tr(t,e,n){this.#bt=null;let s=e.symbol,r=this.#V(t.classType),a=this.#se(t.args);if(r.tag==="error"||a.some(w=>w.tag==="error"))return E;if(r.tag==="diamond"){let w=As(r.symbol,n);r=dt(r.symbol,r.symbol.typeParams.map(I=>w.get(I)??H))}else if(r.tag==="class"&&t.classType.kind==="ClassType"&&t.classType.diamond&&r.symbol.typeParams?.length){let w=fr(r.symbol,n);r=X(r.symbol,r.symbol.typeParams.map(I=>w.get(I.key)??W(ke(I))))}if((r.tag==="library"||r.tag==="class")&&r.symbol.isInterface&&t.args.length)return this.#e(t.args[0].pos,v.syntax,"anonymous class implements interface; cannot have arguments"),E;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,v.syntax,`cannot inherit from final ${c}`),E;if(r.tag==="library"&&!r.symbol.isInterface){if(!Wi.has(r.symbol.name))return this.#o(t.classType.pos,`extending the library class ${r.symbol.name}`,!0),E;s.librarySuperclass=r}else if(r.tag==="library"){if(!Yi(r.symbol))return this.#o(t.classType.pos,`implementing the library interface ${r.symbol.name}`,!0),E;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.#o(t.classType.pos,"extending an inner (non-static) class",!0),E;s.superclass=r.symbol,s.superType=r}else if(r.tag!=="object")return this.#o(t.pos,`creating ${We(M(r))} with \'new\'`,!0),E;if(r.tag==="class"&&r.symbol.isSealed)return this.#Re(s),E;let u=null,d=null;if(s.librarySuperclass){let w=this.#gn(s.librarySuperclass,a,t.pos);if(!w)return E;u=w.candidate,d=w.call}else if(s.superclass){if(this.#fn(s.superclass,a.length,t.pos))return E;if(u=this.#rt({pos:t.pos,name:s.superclass.name},this.#Be(s.superclass,s.superType),a,"constructor"),!u)return E;if(!this.#ye(u.method,t.pos,`${s.superclass.name}(${u.method.params.map(M).join(",")})`))return E}else if(a.length)return this.#e(t.pos,v.cantResolve,"constructor Object in class Object cannot be applied to given types;",[" required: no arguments",` found: ${a.map(M).join(",")}`," reason: actual and formal argument lists differ in length"]),E;s.hierarchyState=2;let h=this.#he(),m=this.#a,p=this.#t,k=this.#p,T=this.#R;this.#Je(s);let C=this.#zn(s,u);d&&(C.superLibrary=d),this.#ze([...s.methods,...s.constructors]),this.#Rt.set(s,{scopes:h.scopes}),this.#t=null,this.#R=!1,this.#De(s),this.#de(h),this.#a=m,this.#t=p,this.#p=k,this.#R=T,u&&this.#ie(t.args,u.params),this.#Ae(t.args);let S=u?this.#Ie(u,t.pos):void 0;return S&&(t.varargs=S),s.isInner&&(t.outer=0,this.#qt()),t.ctor=C,X(s)}#zn(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:St,index:this.#z.length,declaration:r,locals:[],maxSlots:1+(t.isInner?1:t.enumBody?2:0)+s.reduce((o,c)=>o+De(c),0),throws:e?.method?.throws??[],forwardsToSuper:!0,...e?.method?{superConstructor:e.method}:{}};return r.symbol=a,this.#z.push(a),t.constructors.push(a),a}#xr(t){let e=this.#Z(t.outerExpression);if(e.tag==="error")return E;let n=t.classType,s=n.names[0];if(e.tag!=="class")return this.#o(t.pos,`\'.new\' on ${We(M(e))}`,!0),E;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.#o(t.pos,"\'.new\' of a generic class, or of a generic class\'s inner class",!0),E):X(r):(this.#e(t.start,v.syntax,"qualified new of static class"),E):(this.#e(n.pos,v.cantResolve,"cannot find symbol",[` symbol: class ${s}`,` location: class ${e.symbol.displayName}`]),E)}#Gn(t,e,n,s){let r=n.method,a=this.#Ie(n,t.pos);if(a&&(t.varargs=a),!this.#ye(r,t.pos,`${e.name}(${r.params.map(M).join(",")})`))return E;if(this.#ie(t.args,n.params),e.isInner&&!t.outerExpression){let o=0;for(let u=this.#a;u&&u!==e.outer;u=u.outer)o++;let c=this.#a===e.outer||o>0&&this.#Ge(o)&&this.#As(o)===e.outer;if(!this.#_&&!this.#R&&c&&(t.outer=o),t.outer!==void 0)this.#qt();else return this.#Wt(t.pos,"non-static variable this cannot be referenced from a static context"),E}return t.ctor=r,s}#bn(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??H:d:H}),o=c=>Tt(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=gs(t.symbol),r=t.symbol.displayName;if(s.length===1&&!t.symbol.isSealed){let o=s[0],c=X(t.symbol,t.args?.map(d=>Ne(d))),u=d=>Ie(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:M(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}}#Sn(t,e,n=!1){if(t.method)return e??E;if(!e)return this.#e(t.pos,v.incompatibleTypes,"lambda expression not expected here"),E;if(e.tag==="error")return E;if(e.tag==="library"&&e.symbol.name==="Iterable")return this.#o(t.pos,"lambda expressions that implement Iterable"),E;let s=this.#bn(e);if("problem"in s)return this.#e(t.pos,v.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),E;if(s.params.length!==t.params.length)return this.#e(t.pos,v.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),E;for(let[a,o]of t.params.entries()){if(!o.type)continue;let c=this.#V(o.type);if(c.tag==="error")return E;if(!et(c,s.params[a]))return this.#e(t.pos,v.incompatibleTypes,"incompatible types: incompatible parameter types in lambda expression"),E}if(s.returnType.tag==="void"&&t.body.kind!=="Block"&&!Po(t.body))return this.#e(t.body.pos,v.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)"]),E;n&&ae(s.returnType,Array.isArray(n)?n:null)&&(s.returnType=qn);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.#ge(t,s,r,[],()=>{for(let a of r.statements)this.#ne(a)}),e}#ge(t,e,n,s,r){let a=t.reference===!0,o,c=this.#p;if(a)o=`lambda$ref$${this.#z.length}`;else{c=this.#t?this.#p:this.#l?this.#l.isConstructor?"new":this.#l.name:this.#_?"static":"new";let A=this.#d.get(this.#a)??new Map;this.#d.set(this.#a,A);let L=A.get(c)??0;A.set(c,L+1),o=`lambda$${c}$${L}`}let u=[],d=new Set(t.params.map(A=>A.name));Os(n,(A,L)=>{if(d.has(A))return;let J=this.#yt(A)??this.#Tn(A)?.local;J&&!u.some(D=>D.outer===J)&&u.push({outer:J,pos:L})});let h={keywords:[],annotations:[]},m={kind:"VoidType",pos:t.pos,start:t.pos,end:t.pos},p=t.params.map(A=>({modifiers:A.modifiers??h,type:A.type??m,name:A.name,varargs:!1,pos:A.pos,start:A.pos,end:A.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},T={kind:"method",name:o,owner:this.#a,isStatic:!0,isConstructor:!1,isPrivate:!0,isAbstract:!1,isFinal:!1,access:"private",params:[...s.map(A=>A.type),...u.map(A=>A.outer.type),...e.params],returnType:e.returnType,index:this.#z.length,declaration:k,locals:[],maxSlots:0,lambda:t,throws:[],...a?{hidden:!0}:{}};k.symbol=T,this.#z.push(T),!this.#l&&!this.#t&&this.#Vt.set(this.#a,[...this.#Vt.get(this.#a)??[],T]),t.method=T,t.captures=u.map(A=>A.outer),t.capturedAt=u.map(A=>A.pos),t.functional={iface:e.iface,...e.samKey?{samKey:e.samKey}:{},...e.sam?{sam:e.sam}:{}};let C=this.#he(),S=this.#t,w=this.#p,I=this.#_;this.#t={scopes:this.#M,method:this.#l,isStatic:I,outer:this.#t},this.#p=c,this.#l=T,this.#E=null,this.#_=I,this.#M=[],this.#k=0,this.#P=[];let R=this.#D.items.length;this.#vt();let N=0;for(let A of s){let L=this.#_t(A.name,A.type,t.pos,!0,!0);L.parameter=++N}for(let A of u){let L=this.#_t(A.outer.name,A.outer.type,A.pos,!1,!0);L.parameter=++N,L.captureOf=A.outer}return p.forEach((A,L)=>{let J=this.#_t(A.name,e.params[L],A.pos,t.params[L]?.modifiers?Vt(t.params[L].modifiers,"final"):!1);J.parameter=++N,A.symbol=J}),r(),this.#wt(),t.body.kind==="Block"&&e.returnType.tag!=="void"&&this.#D.items.length===R&&this.#wr(T)&&this.#e(t.pos,v.incompatibleTypes,"incompatible types: bad return type in lambda expression",[" missing return value"]),T.usesThis&&(T.isStatic=!1,Ro(T,1)),this.#de(C),this.#t=S,this.#p=w,T}#qt(){let t=this.#l;for(let e=this.#t;t?.lambda&&e;e=e.outer)t.usesThis=!0,t=e.method}#Kn(t,e,n=!1){if(!e)return this.#e(t.start,v.incompatibleTypes,"method reference not expected here"),E;if(e.tag==="error")return E;let s=this.#bn(e);if("problem"in s)return this.#e(t.start,v.incompatibleTypes,`incompatible types: ${s.problem}`,s.details),E;n&&ae(s.returnType,null)&&(s.returnType=qn);let r=s.params.length,a={kind:"Lambda",params:Array.from({length:r},(S,w)=>({name:`$${w}`,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=S=>({kind:"Name",identifier:`$${S}`,depth:1,pos:t.start,start:t.start,end:t.end}),c=S=>Array.from({length:r-S},(w,I)=>o(S+I)),u={depth:2,pos:t.start,start:t.start,end:t.end},d=(S,w)=>({kind:"MethodCall",target:S,name:t.name,namePos:t.namePos,selectPos:t.start,args:c(w),plainNpe:!0,...u}),h=S=>s.returnType.tag==="void"?{kind:"ExpressionStatement",expression:S,...u}:{kind:"ReturnStatement",value:S,...u},m=a.body;if(t.arrayType){let w={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(w)),this.#ge(a,s,m,[],()=>this.#be(m)),e}let p=t.target;if(p.kind==="Super"||p.kind==="This")return m.statements.push(h(d(p,0))),this.#ge(a,s,m,[],()=>this.#be(m)),e;if(p.kind==="FieldAccess"&&p.target.kind==="Name"&&p.target.identifier==="System"&&(p.name==="out"||p.name==="err")&&!this.#yt("System"))return m.statements.push(h(d(p,0))),this.#ge(a,s,m,[],()=>this.#be(m)),e;if(t.name==="new"){let S=this.#vr(p)?this.#qn(p):null;if(!S)return this.#e(t.start,v.cantResolve,"cannot find symbol",[` symbol: class ${this.#Xn(p)}`,` location: class ${this.#a.displayName}`]),E;let w={kind:"NewObject",classType:S,args:c(0),...u};return m.statements.push(h(w)),this.#ge(a,s,m,[],()=>this.#be(m)),e}let k=this.#Xe(p);if("tag"in k){if(k.tag==="error")return E;t.receiver=p;let S={kind:"Name",identifier:"$recv",depth:1,pos:t.start,start:t.start,end:t.end},w=d(S,0);return m.statements.push(h(w)),this.#ge(a,s,m,[{name:"$recv",type:k}],()=>this.#be(m)),e}let T=this.#Xn(p),C=S=>h(S?d(o(0),1):d(p,0));return this.#ge(a,s,m,[],()=>{let S=D=>{let P=C(D),j=this.#D.items.length;m.statements=[P],this.#be(m);let G=this.#D.items.splice(j),Z=P.kind==="ReturnStatement"?P.value:P.expression,qt=Z.method!==void 0||Z.libraryCall!==void 0||Z.stringMethod!==void 0||Z.mathFunction!==void 0||Z.objectMethod!==void 0,be=Z.method?Z.method.isStatic:Z.libraryCall?Z.libraryCall.isStatic:Z.mathFunction!==void 0,An=Z.method?`method ${Z.method.name}(${Z.method.params.map(M).join(",")}) in ${Z.method.owner.displayName}`:Z.libraryCall?`method ${t.name}(${Z.libraryCall.params.map(M).join(",")}) in ${T}`:void 0;return{ok:qt&&be!==D,...An?{found:An}:{},...G[0]?{message:G[0].message}:{}}},w=S(!1),I=this.#qn(p),R=I?this.#Wn(I):null,N=R?.tag==="diamond"?dt(R.symbol):R,A=s.params[0],L=!N||N.tag==="error"||A===void 0||A===qn||z(Qt(A)??A,N)||A.tag==="typevar",J=r>0&&L?S(!0):{ok:!1};if(w.ok&&J.ok){this.#e(t.start,v.incompatibleTypes,"incompatible types: invalid method reference",[` reference to ${t.name} is ambiguous`,` both ${w.found} and ${J.found} match`]);return}if(!w.ok&&!J.ok){let D=/^non-static method (.*) cannot be referenced from a static context$/.exec(w.message??"");if(D){this.#e(t.start,v.incompatibleTypes,"incompatible types: invalid method reference",[` unexpected instance method ${D[1]} found in unbound lookup`]);return}this.#e(t.start,v.cantResolve,"invalid method reference",[" cannot find symbol",` symbol: method ${t.name}(${s.params.map(M).join(",")})`,` location: class ${T}`]);return}m.statements=[C(!w.ok)],this.#be(m)}),e}#be(t){for(let e of t.statements)this.#ne(e)}#vr(t){let e=Ye(t);return e!==null&&(this.#pe(e)!==null||this.#ct(e)!==null||e.join(".")==="String")}#qn(t){let e=Ye(t);if(!e)return null;let n=this.#pe(e)?null:this.#ct(e);return{kind:"ClassType",names:e,hasTypeArguments:!1,...n&&n.typeParams.length?{diamond:!0}:{},pos:t.pos,start:t.start,end:t.end}}#Wn(t){let e=this.#D.items.length,n=this.#V(t,!0);return this.#D.items.splice(e),n}#Xn(t){return Ye(t)?.join(".")??ps(t)}#wr(t){let e=this.#I,n=this.#X,s=[this.#x,this.#tt,this.#Q,this.#U];this.#I=[],this.#X=[];let r=this.#xe(t.declaration.body.statements,Gt(),!0).completes;return this.#I=e,this.#X=n,[this.#x,this.#tt,this.#Q,this.#U]=s,r}#Tn(t){for(let e=this.#t;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}#Wt(t,e){this.#e(t,v.cantResolve,e)}#kr(t,e){this.#fe(t.condition);let n=t.condition.type??E,s=e!==void 0&&e.tag!=="error"?e:void 0,r=this.#Kt(this.#ot(t.condition,!0),()=>this.#Z(t.whenTrue,s)),a=this.#Kt(this.#ot(t.condition,!1),()=>this.#Z(t.whenFalse,s));if(n.tag!=="boolean"||r.tag==="error"||a.tag==="error")return E;let o,c=yt(r)??r,u=yt(a)??a;if(Q(c)&&Q(u)&&!(tt(r)&&tt(a)&&s&&tt(s)))if(c.tag==="boolean"&&u.tag==="boolean")o=ft;else if(Ot(c)&&Ot(u))o=zo(c,u,t.whenTrue.constant,t.whenFalse.constant);else return this.#o(t.pos,"conditional expressions mixing boolean and numeric operands"),E;else if(Q(r)&&a.tag==="null"||Q(a)&&r.tag==="null"){let h=Q(r)?r:a,m=this.#Yn(h);if(!m)return E;if(o=s&&tt(s)?s:m,s&&!te(s,m))return this.#q(Q(r)?t.whenTrue:t.whenFalse,h,s),E}else{if(s){let h=!0;for(let[m,p]of[[t.whenTrue,r],[t.whenFalse,a]])te(s,p,m.constant)||(this.#e(m.pos,v.incompatibleTypes,"incompatible types: bad type in conditional expression",[` ${Je(s,p)}`]),h=!1);if(!h)return E}if(Q(r)||Q(a))return this.#o(t.pos,"conditional expressions that need boxing"),E;o=s&&tt(s)?s:oa(r,a)}let d=t.condition.constant;return d?.kind==="boolean"&&t.whenTrue.constant&&t.whenFalse.constant&&(t.constant=vn(d.value?t.whenTrue.constant:t.whenFalse.constant,o)),o}#Cr(t,e){let n=Vn[t.name],s=n.map(o=>({owner:"Math",name:t.name,params:o.params,returnType:o.returnType})),r=this.#rt({pos:t.selectPos,name:t.name,imported:Gi(t)},s,e,"method");if(!r)return E;let a=n[s.indexOf(r)];return a.fn?(t.mathFunction={fn:a.fn,params:a.params},r.returnType):(this.#o(t.selectPos,`Math.${t.name}(${r.params.map(M).join(",")})`,!0),E)}#Yn(t){let e={int:"Integer",long:"Long",double:"Double",char:"Character",boolean:"Boolean",float:"Float",byte:"Byte",short:"Short"}[t.tag],n=e?ce(e):void 0;return n?dt(n):null}#Er(t,e){if(t.name==="readln"){Wt("System");let o=[{owner:"IO",name:"readln",params:[],returnType:ut},{owner:"IO",name:"readln",params:[ut],returnType:ut}],c=this.#rt({pos:t.selectPos,name:t.name},o,e,"method");if(!c)return E;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}`},ut}if(t.name!=="print"&&t.name!=="println")return this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,e)}`," location: class IO"]),E;let n=t.name==="println"?[{owner:"IO",name:"println",params:[H],returnType:St},{owner:"IO",name:"println",params:[],returnType:St}]:[{owner:"IO",name:"print",params:[H],returnType:St}];if(!this.#rt({pos:t.selectPos,name:t.name},n,e,"method"))return E;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},St}#Ar(t){let e=it(t);if(e.kind==="FieldAccess")return e.field;if(e.kind==="Name"&&e.imported)return e.imported.field}#Ir(t,e,n){Wt("System");let s={owner:"PrintStream",name:t.name,params:[ut,Yt(H)],returnType:St,varargs:!0},r=this.#rt({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),St):E}#Or(t,e){let n=this.#Qn(t.args[0]);if(!n)return!1;let{name:s,method:r,symbol:a}=n,o=r.typeParamBounds?.[s],c=!o||o.tag==="object",u=c||o.tag==="library"&&o.symbol.isInterface,d={tag:"typevar",name:s};return c&&u?(this.#e(t.selectPos,v.cantResolve,`reference to ${t.name} is ambiguous`,[` both method ${t.name}(char[]) in PrintStream and method ${t.name}(String) in PrintStream match`]),e.tag!=="array"&&this.#e(t.pos,v.cantResolve,`method ${t.name} in class PrintStream cannot be applied to given types;`,[" required: char[]",` found: ${M(e)}`,` reason: argument mismatch; inference variable ${s} has incompatible bounds`,` upper bounds: char[],${o?M(o):"Object"}`,` lower bounds: ${M(e)}`,...Xe([d,...r.params],a,r)]),!0):u&&e.tag!=="string"?(this.#e(t.pos,v.cantResolve,`method ${t.name} in class PrintStream cannot be applied to given types;`,[" required: String",` found: ${M(e)}`,` reason: argument mismatch; inference variable ${s} has incompatible bounds`]),!0):!1}#Qn(t){let e=it(t);if(e.kind!=="MethodCall"||!e.libraryMethod)return null;let{method:n,symbol:s,classArgs:r}=e.libraryMethod,a=n.typeParams??[],o=n.returnType,c=o.tag==="typevar"&&a.includes(o.name)?o.name:null,u=o.tag==="library"?o.args[o.args.length-1]:void 0,d=u?.tag==="typevar"&&a.includes(u.name)?u.name:null;if(!c&&!d)return null;let h=C=>{let S=it(C);return S.kind==="Lambda"&&S.params.some(w=>!w.type)||S.kind==="MethodRef"&&(!this.#Ve(S)||this.#pn(S))},m=n.params.map(C=>n.isStatic?C:Xt(C,s.typeParams,r)),p=new Set,k=null;e.args.forEach((C,S)=>{let w=m[Math.min(S,m.length-1)];if(!w||h(C))return;let I=this.#Qn(C),R=$o(w,a);if(I){k??=I;return}for(let N of R)p.add(N)});let T=C=>!p.has(C);return c?T(c)?k??{name:c,method:n,symbol:s}:null:T(d)?k??{name:d,method:n,symbol:s}:null}#Lr(t,e,n){let s=this.#Ar(t.target)==="System.err"?"err":"out";if(t.name==="printf"||t.name==="format")return this.#Ir(t,s,n);if((t.name==="flush"||t.name==="close"||t.name==="checkError")&&!n.length)return Wt("System"),t.libraryCall={native:`PrintStream.${s}.${t.name}()`,isStatic:!0,params:[],returnsValue:t.name==="checkError",display:`java.io.PrintStream.${t.name}()`},t.name==="checkError"?ft:St;if(t.name!=="print"&&t.name!=="println")return bo.has(t.name)?this.#o(t.selectPos,`PrintStream.${t.name}()`,!0):this.#e(t.selectPos,v.cantResolve,"cannot find symbol",[` symbol: method ${this.#Ut(t.name,n)}`,this.#Ee(t.target,e)]),E;if(n.length===1&&this.#Or(t,n[0]))return E;let r=this.#rt({pos:t.selectPos,name:t.name},Io(t.name),n,"method");if(!r)return E;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.#Qe(t.args,[H]);break;case"long":o="long";break;case"double":o="double";break;case"float":o="float";break;default:throw new Error(`checker: unexpected print overload ${M(a)}`)}return t.print={stream:s,newline:t.name==="println",argument:o},St}#rt(t,e,n,s){let r=(T,C)=>{if(T.params.length!==n.length)return"actual and formal argument lists differ in length";if(T.problem)return T.problem.reason;for(let S=0;S<n.length;S++)if(!C(T.params[S],n[S]))return`argument mismatch; ${Jo(T.params[S],n[S])??Je(T.params[S],n[S])}`;return null},a=T=>r(T,(C,S)=>he(C,S)||Qe(C,S)),o=e.filter(T=>r(T,qe)===null);if(o.length||(o=e.filter(T=>a(T)===null)),!o.length)for(let T of e){if(!T.varargs||n.length<T.params.length-1)continue;let C=T.params[T.params.length-1].element;if([...T.params.slice(0,-1),...n.slice(T.params.length-1).map(()=>C)].every((w,I)=>he(w,n[I])))return{...T,expanded:!0}}let c=T=>T.length?T.map(M).join(","):"no arguments";if(!o.length){if(e.length===1){let w=e[0],I=w.shown??w.params,R=(_o(w,n)??a(w)).split(`\n`),N=w.problem?.alone?[` reason: ${R[0]}`]:[` required: ${c(I)}`,` found: ${c(n)}`,` reason: ${R[0]}`,...R.slice(1)];return this.#e(t.pos,v.cantResolve,`${s} ${t.name} in ${w.ownerKind??"class"} ${w.owner} cannot be applied to given types;`,[...N,...w.problem?.alone?[]:Dt([...I,...n])]),null}let T=[],C=[];for(let w of t.imported?[...e].reverse():e){let I=w.shown??w.params,R=w.method?.typeParams;C.push(...I),T.push(` ${s} ${w.owner}.${R?`<${R.map(A=>A.name).join(",")}>`:""}${w.name}(${I.map(M).join(",")}) is not applicable`);let N=a(w).split(`\n`);T.push(` (${N[0]}${N.length>1?"":")"}`,...N.slice(1).map((A,L,J)=>` ${A}${L===J.length-1?")":""}`))}let S=n.length?this.#Ut(t.name,n):`${t.name}(no arguments)`;return this.#e(t.pos,v.cantResolve,`no suitable ${s} found for ${S}`,[...T,...Dt([...C,...n])]),null}let u=(T,C)=>T.params.every((S,w)=>qe(C.params[w],S)),d=o.filter(T=>o.every(C=>T===C||u(T,C)));if(d.length===1)return d[0];let h=o.filter(T=>!o.some(C=>C!==T&&u(C,T)&&!u(T,C))),[m,p]=h,k=T=>`${s} ${T.name}(${T.params.map(M).join(",")}) in ${T.owner}`;return this.#e(t.pos,v.cantResolve,`reference to ${t.name} is ambiguous`,[` both ${k(m)} and ${k(p)} match`]),null}#Nr(t){let e=this.#Z(t.operand);if(e.tag==="error")return E;let n=yt(e)??e;if(t.operator==="!")return n.tag!=="boolean"?this.#xn(t,n):(t.operand.constant?.kind==="boolean"&&(t.constant=gt(!t.operand.constant.value)),ft);if(!Ot(n)||t.operator==="~"&&!Hn(n))return this.#xn(t,n);let s=Ki(n),r=t.operand.constant;return r&&(t.constant=Go(t.operator,r,s)),s}#xn(t,e){return this.#e(t.pos,v.badOperands,`bad operand type ${M(e)} for unary operator \'${t.operator}\'`),E}#Zn(t){let e=it(t);this.#Bt=e.kind==="Name";let n=this.#v(e);if(this.#Bt=!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,v.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,v.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.#$r(e,s)?(this.#e(e.pos,v.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,v.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,v.finalAssign,`cannot assign a value to ${r}`),null}return this.#e(e.pos,v.incompatibleTypes,"unexpected type",[" required: variable"," found: value"]),null}#$r(t,e){if(e.declarator.init)return!1;let n=this.#l?.initializer;return n&&this.#l.owner===e.owner&&n==="static"===e.isStatic?t.kind==="Name"?!t.outerHops:!e.isStatic&&t.kind==="FieldAccess"&&it(t.target).kind==="This":e.isStatic||!this.#l?.isConstructor||this.#l.owner!==e.owner||this.#l.declaration.compact?!1:t.kind==="Name"?!t.outerHops:t.kind==="FieldAccess"&&it(t.target).kind==="This"}#Mr(t){if(!this.#Zn(t.operand))return E;let n=t.operand.type;return Ot(yt(n)??n)?n:this.#xn(t,n)}#ts(t,e,n,s){return this.#e(t.pos,v.badOperands,`bad operand types for binary operator \'${e}\'`,[` first type: ${M(n)}`,` second type: ${M(s)}`]),E}#es(t,e,n){if(t==="+"&&(e.tag==="string"||n.tag==="string"))return ut;if((t==="=="||t==="!=")&&tt(e)&&tt(n))return ve(e,n)?ft:null;let s=yt(e)??e,r=yt(n)??n,a=Ot(s)&&Ot(r);switch(t){case"+":return s.tag==="string"||r.tag==="string"?ut:a?Wn(s,r):null;case"-":case"*":case"/":case"%":return a?Wn(s,r):null;case"<<":case">>":case">>>":return Hn(s)&&Hn(r)?Ki(s):null;case"<":case">":case"<=":case">=":return a?ft:null;case"==":case"!=":return a?ft:s.tag==="boolean"&&r.tag==="boolean"?ft:tt(s)&&tt(r)&&(z(s,r)||z(r,s))?ft:null;case"&":case"|":case"^":return Hn(s)&&Hn(r)?Wn(s,r):s.tag==="boolean"&&r.tag==="boolean"?ft:null;case"&&":case"||":return s.tag==="boolean"&&r.tag==="boolean"?ft:null}return null}#Pr(t){let e=this.#Z(t.left),n=t.operator==="&&"||t.operator==="||"?this.#Kt(this.#ot(t.left,t.operator==="&&"),()=>this.#Z(t.right)):this.#Z(t.right);if(e.tag==="error"||n.tag==="error")return E;let s=this.#es(t.operator,e,n);if(!s){let o=c=>Q(c)||tt(c);return(t.operator==="=="||t.operator==="!=")&&o(e)&&o(n)&&Q(e)===Q(n)?(this.#e(t.pos,v.badOperands,`incomparable types: ${M(e)} and ${M(n)}`),E):this.#ts(t,t.operator,e,n)}let r=t.left.constant,a=t.right.constant;if(r&&a){let o=Ko(t.operator,r,a,s);o&&(t.constant=o)}return s}#Rr(t){let e=this.#Zn(t.target),n=t.target.type??E,s=this.#Z(t.value,t.operator==="="?n:void 0);if(!e||n.tag==="error"||s.tag==="error")return e?n:E;if(t.operator==="="){if(!this.#We(n,s,t.value))return this.#q(t.value,s,n),E;let u=it(t.target);return u.kind==="FieldAccess"&&u.fieldSymbol&&u.target.type&&Rn(u.target.type)&&Xn([u.fieldSymbol.type]).length&&this.#nt(u.pos,"unchecked",`unchecked assignment to variable ${u.name} as member of raw type ${M(u.target.type)}`),n}let r=t.operator.slice(0,-1),a=this.#es(r,n,s);if(!a)return this.#ts(t,r,n,s);let o=yt(n);return(o?et(o,a):Ot(a)&&Ot(n)||et(a,n))?n:(this.#e(t.value.pos,v.incompatibleTypes,`incompatible types: ${M(a)} cannot be converted to ${M(n)}`),E)}#Jr(t){let e=this.#Z(t.array),n=this.#Z(t.index);return e.tag==="error"||n.tag==="error"?E:e.tag!=="array"?(this.#e(t.pos,v.incompatibleTypes,`array required, but ${M(e)} found`),E):he(U,n)?e.element:(this.#q(t.index,n,U),E)}#Dr(t){let e=this.#V(t.elementType,!0);if(e.tag!=="error"&&!wn(e)){this.#e(t.pos,v.syntax,"generic array creation");for(let s of t.dimensions)this.#Z(s);return E}for(let s of t.dimensions){let r=this.#Z(s);r.tag!=="error"&&!he(U,r)&&this.#q(s,r,U)}if(e.tag==="error")return t.initializer&&this.#Ce(t.initializer,E),E;let n=e;for(let s=0;s<t.dimensions.length+t.extraDims;s++)n=Yt(n);return t.initializer&&this.#Ce(t.initializer,n),n}#jr(t){let e=this.#V(t.targetType),n=this.#Z(t.expression);if(e.tag==="error"||n.tag==="error")return E;let s=yt(n),r=Ot(e)&&Ot(n)||e.tag==="boolean"&&n.tag==="boolean"||tt(e)&&tt(n)&&ve(e,n)||tt(e)&&Q(n)&&te(e,n)||Q(e)&&s!==null&&(et(s,e)||Ot(s)&&Ot(e)&&he(e,s));if(!r&&Q(e)&&tt(n)&&!s){let o=this.#Yn(e);o&&ve(o,n)&&(t.checked=o,r=!0)}if(!r)return this.#q(t.expression,n,e),E;if(Uo(e,n))return this.#q(t.expression,n,e),E;if(tt(e)&&tt(n)&&!wn(e)&&!z(n,e)&&!No(e,n)){this.#nt(t.expression.pos,"unchecked","unchecked cast",[` required: ${M(e)}`,` found: ${M(n)}`,...Dt([e,n])]);let o=W(e);!z(n,o)&&o.tag!=="object"&&(t.checked=o)}else tt(e)&&tt(n)&&!z(n,e)&&(t.checked=e);let a=t.expression.constant;return a&&(Q(e)||e.tag==="string")&&(t.constant=vn(a,e)),e}#Se(t,e,n){!this.#tt&&!this.#I.some(([s])=>s===t)&&this.#I.push([t,e,n])}#Te(t,e){this.#X.some(([n])=>n===t)||this.#X.push([t,e])}#Fr(t){this.#I=[],this.#X=[];let e=br(t);for(let n of e)this.#rs(n);this.#rs(t);for(let[n,s,r]of this.#I)this.#e(n,s==="missing return statement"?v.missingReturn:v.unreachable,s,r);for(let[n,s]of this.#X)this.#e(n,v.uninitialized,s);this.#J=[];for(let n of e)this.#ns(n);this.#ns(t);for(let[n,s,r]of this.#J)this.#e(n,v.unreported,s,r);for(let n of this.#Y)n.top!==t||Mo(n.local)||this.#e(n.pos,v.notEffectivelyFinal,`local variables referenced from ${n.inner?"an inner class":"a lambda expression"} must be final or effectively final`)}#ns(t){this.#a=t;for(let e of t.fields){let n=e.declarator.init;n&&this.#Le([],()=>n.kind==="ArrayInitializer"?this.#Ze(n):this.#b(n));let s=e.enumConstant?.node;s&&this.#Le([],()=>{for(let r of s.args)this.#b(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.#Le(e.isStatic?[]:this.#_r(t),()=>{for(let s of e.body.statements)this.#ut(s)});continue}if(e.kind!=="MethodDeclaration"||!e.symbol||e.symbol.isAbstract||e.symbol.builtin)continue;let n=e.symbol;this.#Le(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.#ut(s)})}for(let e of t.constructors)!e.declaration.synthetic||e.builtin||!e.superConstructor||e.forwardsToSuper||this.#Le([],()=>{for(let n of e.superConstructor.throws)this.#$t(n,t.declaration.keywordPos)})}#_r(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=>z(n,r)))):[]}#Le(t,e){let n=[this.#m,this.#T];this.#m=t,this.#T=[],e(),[this.#m,this.#T]=n}#$t(t,e,n){if(this.#Zt(t)){for(let s=this.#T.length-1;s>=0;s--){let r=this.#T[s];if(r.thrown.push(t),r.caught.some(a=>z(t,a)))return}this.#m.some(s=>z(t,s))||this.#J.some(([s])=>s===e)||this.#J.push([e,`unreported exception ${M(t)}; must be caught or declared to be thrown`,n])}}#ut(t){switch(t.kind){case"Block":for(let e of t.statements)this.#ut(e);return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init?.kind==="ArrayInitializer"?this.#Ze(e.init):e.init&&this.#b(e.init);return;case"ExpressionStatement":this.#b(t.expression);return;case"IfStatement":this.#b(t.condition),this.#ut(t.then),t.otherwise&&this.#ut(t.otherwise);return;case"WhileStatement":case"DoStatement":this.#b(t.condition),this.#ut(t.body);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#ut(t.init);else for(let e of t.init??[])this.#b(e);t.condition&&this.#b(t.condition);for(let e of t.update)this.#b(e);this.#ut(t.body);return;case"ForEachStatement":this.#b(t.iterable),this.#ut(t.body);return;case"LabeledStatement":this.#ut(t.body);return;case"SwitchStatement":this.#ss(t);return;case"YieldStatement":this.#b(t.value);return;case"ReturnStatement":t.value&&this.#b(t.value);return;case"ConstructorCall":for(let e of t.args)this.#b(e);if(t.target)for(let e of t.target.throws)this.#$t(e,t.thisPos);return;case"AssertStatement":this.#b(t.condition),t.message&&this.#b(t.message);return;case"LocalClass":return;case"ThrowStatement":{this.#b(t.expression);let e=it(t.expression),n=e.kind==="Name"&&e.symbol?.kind==="local"&&!e.symbol.reassigned?this.#ft.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.#Ur(t);return;case"BreakStatement":case"ContinueStatement":case"EmptyStatement":return}}#ss(t){this.#b(t.selector);for(let e of t.cases){for(let n of e.statements)this.#ut(n);e.body?.kind==="Block"?this.#ut(e.body):e.body&&this.#b(e.body)}}#Ur(t){let n={caught:t.catches.flatMap(r=>r.caught??[]),thrown:[]};this.#T.push(n);for(let r of t.resources)r.kind==="declaration"?this.#b(r.init):this.#b(r.expression);this.#ut(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.#Br(a))this.#$t(c,r.pos,[` exception thrown from implicit call to close() on resource variable \'${o}\'`])}this.#T.pop();let s=[];for(let r of t.catches){if(r.types.forEach((a,o)=>{let c=r.caught?.[o];if(!c||!this.#Zt(c))return;let u=c.tag==="class"?c.symbol.binaryName:"";u==="java.lang.Exception"||u==="java.lang.Throwable"||n.thrown.some(d=>z(d,c)||z(c,d))||this.#J.push([r.types.length===1?r.pos:a.pos,`exception ${M(c)} is never thrown in body of corresponding try statement`,void 0])}),r.symbol){let a=r.caught??[];this.#ft.set(r.symbol,n.thrown.filter(o=>a.some(c=>z(o,c))&&!s.some(c=>z(o,c))))}s.push(...r.caught??[]),this.#ut(r.block)}t.finallyBlock&&this.#ut(t.finallyBlock)}#Br(t){return t?.tag==="library"?this.#vn(t.symbol.methods.find(n=>n.name==="close"&&!n.params.length)?.throws):!t||t.tag!=="class"?[]:this.#kt(t.symbol,"close").find(n=>n.params.length===0)?.throws??[]}#vn(t){return(t??[]).map(e=>X(this.#c.get(e)))}#Ze(t){for(let e of t.elements)e.kind==="ArrayInitializer"?this.#Ze(e):this.#b(e)}#b(t){switch(t.kind){case"MethodCall":t.target&&this.#b(t.target);for(let e of t.args)this.#b(e);if(t.method)for(let e of t.method.throws)this.#$t(e,t.pos);for(let e of this.#vn(t.libraryCall?.throws))this.#$t(e,t.pos);return;case"NewObject":t.outerExpression&&this.#b(t.outerExpression);for(let e of t.args)this.#b(e);if(t.ctor)for(let e of t.ctor.throws)this.#$t(e,t.pos);for(let e of this.#vn(t.libraryCall?.throws))this.#$t(e,t.pos);return;case"MethodRef":t.receiver&&this.#b(t.receiver),t.lambda&&this.#b(t.lambda);return;case"Lambda":if(t.method){let e=t.method.declaration.body;this.#Le([],()=>{for(let n of e.statements)this.#ut(n)})}return;case"SwitchExpression":this.#ss(t);return;case"FieldAccess":this.#b(t.target);return;case"Unary":case"IncDec":this.#b(t.operand);return;case"Binary":this.#b(t.left),this.#b(t.right);return;case"Assignment":this.#b(t.target),this.#b(t.value);return;case"Parenthesized":this.#b(t.expression);return;case"ArrayAccess":this.#b(t.array),this.#b(t.index);return;case"NewArray":for(let e of t.dimensions)this.#b(e);t.initializer&&this.#Ze(t.initializer);return;case"Cast":this.#b(t.expression);return;case"Conditional":this.#b(t.condition),this.#b(t.whenTrue),this.#b(t.whenFalse);return;case"InstanceOf":this.#b(t.expression);return;case"ClassLiteral":case"Literal":case"Name":case"This":case"Super":return}}#rs(t){this.#a=t;let e=t.constructors.some(r=>!r.declaration.synthetic),n=this.#is(t,!0),s=this.#is(t,!1);this.#Xt.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.#X.push([r.declarator.pos,`variable ${r.name} might not have been initialized`]):!e&&!t.isRecord&&!s.get(r)?.assigned&&this.#X.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.#tn(r.symbol);for(let r of this.#Vt.get(t)??[])this.#tn(r)}#is(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=mr();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.#x=new Map,this.#tt=0,this.#Q=[],this.#U=n;let o=this.#xe(a.body.statements,s,!0);o.completes||this.#Se(a.pos,"initializer must be able to complete normally");let c=mr();for(let u of n.values())xn(o.after,u)&&c.vars.add(u),Gn(o.after,u)&&c.unassigned.add(u);s=c}this.#U=new Map;let r=new Map;for(let[a,o]of n)r.set(a,{assigned:xn(s,o),unassigned:Gn(s,o)});return r}#tn(t){let e=mr();for(let o of t.declaration.params)o.symbol&&(e=Le(e,o.symbol.index));for(let o of t.locals)o.parameter!==void 0&&(e=Le(e,o.index));this.#x=new Map,this.#tt=0,this.#Q=[],this.#U=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.#Xt.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.#U.size;this.#U.set(c,u);let d=o?.get(c);d?.assigned&&e.vars.add(u),(!d||d.unassigned)&&e.unassigned.add(u)}}let a=this.#xe(n.statements,e,!0);if(a.completes&&!a.recovery&&t.returnType.tag!=="void"&&!t.lambda&&this.#Se(t.declaration.closeBracePos??n.end-1,"missing return statement"),r){for(let[o,c]of this.#U)xn(a.after,c)||this.#Te(t.declaration.closeBracePos??n.end-1,`variable ${o.name} might not have been initialized`);for(let o of this.#Q)for(let[c,u]of this.#U)xn(o.state,u)||this.#Te(o.pos,`variable ${c.name} might not have been initialized`)}this.#U=new Map}#xe(t,e,n){let s=e,r=n,a=!1;for(let o of t){r||(this.#Se(Zi(o),"unreachable statement"),r=!0,a=!0,s=Gt());let c=this.#Ct(o,s,r);s=c.after,r=c.completes,c.recovery&&(a=!0)}return{after:s,completes:r,...a&&r?{recovery:!0}:{}}}#Ct(t,e,n){switch(t.kind){case"Block":return this.#xe(t.statements,e,n);case"LocalVariableDeclaration":return{after:this.#ls(t,e),completes:n};case"ExpressionStatement":return{after:this.#S(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.#S(r,s);return{after:s,completes:n}}case"IfStatement":{let s=this.#ht(t.condition,e),r=this.#Ct(t.then,s.whenTrue,n);if(!t.otherwise)return{after:vt(r.after,s.whenFalse),completes:n};let a=this.#Ct(t.otherwise,s.whenFalse,n);return{after:vt(r.after,a.after),completes:r.completes||a.completes}}case"WhileStatement":return this.#as(t,t.condition,t.body,[],e,n);case"ForStatement":{let s=e;if(t.init&&!Array.isArray(t.init))s=this.#ls(t.init,s);else for(let r of t.init??[])s=this.#S(r,s);return this.#as(t,t.condition,t.body,t.update,s,n)}case"DoStatement":return this.#Hr(t,e,n);case"ForEachStatement":return this.#zr(t,e,n);case"LabeledStatement":{let s=this.#Ne(t),r=this.#Ct(t.body,e,n);return{after:vt(r.after,...s.breaks),completes:r.completes||s.breaks.length>0}}case"SwitchStatement":return this.#Gr(t,e,n);case"YieldStatement":{let s=this.#S(t.value,e);return t.target&&this.#x.get(t.target)?.yields.push(s),{after:Gt(),completes:!1}}case"BreakStatement":return t.target&&this.#x.get(t.target)?.breaks.push(e),{after:Gt(),completes:!1};case"ContinueStatement":return t.target&&this.#x.get(t.target)?.continues.push(e),{after:Gt(),completes:!1};case"ReturnStatement":{let s=t.value?this.#S(t.value,e):e;return this.#U.size&&this.#Q.push({pos:t.pos,state:s}),{after:Gt(),completes:!1}}case"ThrowStatement":return this.#S(t.expression,e),{after:Gt(),completes:!1};case"AssertStatement":{let s=this.#ht(t.condition,e);return t.message&&this.#S(t.message,s.whenFalse),{after:e,completes:n}}case"TryStatement":return this.#Vr(t,e,n);case"LocalClass":return{after:e,completes:n}}}#Vr(t,e,n){let s=e;for(let h of t.resources)h.kind==="declaration"?(s=this.#S(h.init,s),h.symbol&&(s=Le(s,h.symbol.index))):s=this.#S(h.expression,s);let r=this.#Ct(t.block,s,n);t.blockCompletes=r.completes;let a=[r],o=h=>{let m=je(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=Le(m,h.symbol.index));let p=this.#Ct(h.block,m,n);h.completes=p.completes,a.push(p)}let c=a.filter(h=>h.completes),u=c.length?vt(c[0].after,...c.slice(1).map(h=>h.after)):Gt();if(!t.finallyBlock)return{after:u,completes:c.length>0};let d=this.#Ct(t.finallyBlock,o(vt(r.after,...a.map(h=>h.after))),n);return{after:Oo(u,d.after),completes:c.length>0&&d.completes}}#Ne(t){let e={breaks:[],continues:[],yields:[]};return this.#x.set(t,e),e}#wn(t,e){let n=e(t,!0),s=[...t.unassigned].some(o=>!Gn(n.backEdge,o));if(!this.#U.size||t.all||!s)return n.result;let r=je(t);for(let o of[...r.unassigned])Gn(n.backEdge,o)||r.unassigned.delete(o);this.#tt++;let a=e(r,!1);return this.#tt--,a.result}#as(t,e,n,s,r,a){return this.#wn(r,(o,c)=>{let u=e?this.#ht(e,o):{whenTrue:o,whenFalse:Gt()},d=e?e.constant:gt(!0),h=a&&!xs(d);c&&a&&!h&&this.#Se(Zi(n),"unreachable statement");let m=this.#Ne(t),p=this.#Ct(n,h?u.whenTrue:Gt(),!0),k=vt(p.after,...m.continues);for(let T of s)k=this.#S(T,k);return{backEdge:k,result:{after:vt(u.whenFalse,...m.breaks),completes:a&&(!Un(d)||m.breaks.length>0)}}})}#Hr(t,e,n){return this.#wn(e,s=>{let r=this.#Ne(t),a=this.#Ct(t.body,s,n),o=vt(a.after,...r.continues),c=this.#ht(t.condition,o),u=a.completes||r.continues.length>0;return{backEdge:c.whenTrue,result:{after:vt(c.whenFalse,...r.breaks),completes:n&&(u&&!Un(t.condition.constant)||r.breaks.length>0)}}})}#zr(t,e,n){let s=this.#S(t.iterable,e);return this.#wn(s,r=>{let a=this.#Ne(t),o=t.symbol?Le(r,t.symbol.index):r,c=this.#Ct(t.body,o,n);return{backEdge:vt(c.after,...a.continues),result:{after:vt(r,...a.breaks),completes:n}}})}#Gr(t,e,n){let s=this.#os(t,this.#S(t.selector,e)),r=this.#Ne(t),a=[],o=!1;if(t.cases[0]?.arrow)for(let c of t.cases){let u=c.body,d=u.kind==="Block"?this.#Ct(u,s,n):{after:this.#S(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?vt(s,c.after):s;c=this.#xe(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?vt(a[0],...a.slice(1)):Gt(),completes:n&&o}}#os(t,e){let n=e;for(let s of t.cases)s.guard&&(n=vt(n,this.#S(s.guard,n)));return n}#Kr(t,e){let n=this.#os(t,this.#S(t.selector,e)),s=this.#Ne(t),r=[];if(t.cases[0]?.arrow)for(let a of t.cases){let o=a.body;if(o.kind!=="Block"){r.push(this.#S(o,n));continue}this.#xe(o.statements,n,!0).completes&&this.#Se(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?vt(n,a.after):n;a=this.#xe(o.statements,c,!0)}a?.completes&&this.#Se(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.#Se(t.pos,"the switch expression does not cover all possible input values"),r.push(...s.yields),r.length?vt(r[0],...r.slice(1)):Gt()}#kn(t,e){let n=e;for(let s of t.elements)n=s.kind==="ArrayInitializer"?this.#kn(s,n):this.#S(s,n);return n}#ls(t,e){let n=e;for(let s of t.declarators){let r=s.symbol;r&&(n=Lo(n,r.index));let a=s.init;a&&(n=a.kind==="ArrayInitializer"?this.#kn(a,n):this.#S(a,n),r&&(n=Le(n,r.index)))}return n}#ht(t,e){if(Un(t.constant))return{whenTrue:e,whenFalse:Gt()};if(xs(t.constant))return{whenTrue:Gt(),whenFalse:e};if(t.kind==="Parenthesized")return this.#ht(t.expression,e);if(t.kind==="Unary"&&t.operator==="!"){let s=this.#ht(t.operand,e);return{whenTrue:s.whenFalse,whenFalse:s.whenTrue}}if(t.kind==="Binary"&&t.operator==="&&"){let s=this.#ht(t.left,e),r=this.#ht(t.right,s.whenTrue);return{whenTrue:r.whenTrue,whenFalse:vt(s.whenFalse,r.whenFalse)}}if(t.kind==="Binary"&&t.operator==="||"){let s=this.#ht(t.left,e),r=this.#ht(t.right,s.whenFalse);return{whenTrue:vt(s.whenTrue,r.whenTrue),whenFalse:r.whenFalse}}if(t.kind==="Conditional"&&t.type?.tag==="boolean"){let s=this.#ht(t.condition,e),r=this.#ht(t.whenTrue,s.whenTrue),a=this.#ht(t.whenFalse,s.whenFalse);return{whenTrue:vt(r.whenTrue,a.whenTrue),whenFalse:vt(r.whenFalse,a.whenFalse)}}let n=this.#S(t,e);return{whenTrue:n,whenFalse:n}}#Cn(t,e,n){return t.binding||xn(n,t.index)?n:(this.#Te(e,`variable ${t.name} might not have been initialized`),Le(n,t.index))}#en(t){if(!this.#U.size)return null;let e;t.kind==="Name"&&t.symbol?.kind==="field"&&!t.outerHops?e=t.symbol:t.kind==="FieldAccess"&&t.fieldSymbol&&it(t.target).kind==="This"&&(e=t.fieldSymbol);let n=e&&this.#U.get(e);return e&&n!==void 0?{field:e,index:n}:null}#nn(t,e,n){if(xn(n,t.index))return n;this.#Te(e,`variable ${t.field.name} might not have been initialized`);let s=je(n);return s.vars.add(t.index),s}#S(t,e){switch(t.kind){case"Literal":case"This":case"Super":return e;case"InstanceOf":return this.#S(t.expression,e);case"ClassLiteral":return e;case"Lambda":{let n=e;t.captures?.forEach((r,a)=>n=this.#Cn(r,t.capturedAt[a],n));let s=[this.#x,this.#tt,this.#Q,this.#U];return t.method&&this.#tn(t.method),[this.#x,this.#tt,this.#Q,this.#U]=s,n}case"MethodRef":{let n=t.receiver?this.#S(t.receiver,e):e,s=[this.#x,this.#tt,this.#Q,this.#U];return t.lambda?.method&&this.#tn(t.lambda.method),[this.#x,this.#tt,this.#Q,this.#U]=s,n}case"Name":{if(t.symbol?.kind==="local"&&!t.constant)return this.#Cn(t.symbol,t.pos,e);let n=this.#en(t);return n?this.#nn(n,t.pos,e):e}case"Parenthesized":return this.#S(t.expression,e);case"FieldAccess":{let n=this.#en(t);return n?this.#nn(n,t.pos,e):this.#S(t.target,e)}case"MethodCall":{let n=t.target?this.#S(t.target,e):e;for(let s of t.args)n=this.#S(s,n);return n}case"NewObject":{let n=t.outerExpression?this.#S(t.outerExpression,e):e;for(let s of t.args)n=this.#S(s,n);return n}case"Conditional":{let n=this.#ht(t.condition,e);return vt(this.#S(t.whenTrue,n.whenTrue),this.#S(t.whenFalse,n.whenFalse))}case"Unary":if(t.operator==="!"){let n=this.#ht(t,e);return vt(n.whenTrue,n.whenFalse)}return this.#S(t.operand,e);case"IncDec":{let n=it(t.operand);n.kind==="Name"&&n.symbol?.kind==="local"&&this.#cs(n.symbol,n.pos);let s=this.#en(it(t.operand));return s?this.#us(s,it(t.operand).pos,this.#nn(s,it(t.operand).pos,e)):this.#S(t.operand,e)}case"Cast":return this.#S(t.expression,e);case"ArrayAccess":return this.#S(t.index,this.#S(t.array,e));case"NewArray":{let n=e;for(let s of t.dimensions)n=this.#S(s,n);return t.initializer?this.#kn(t.initializer,n):n}case"SwitchExpression":return this.#Kr(t,e);case"Binary":{if(t.operator==="&&"||t.operator==="||"){let n=this.#ht(t,e);return vt(n.whenTrue,n.whenFalse)}return this.#S(t.right,this.#S(t.left,e))}case"Assignment":{let n=it(t.target);if(n.kind==="Name"&&n.symbol?.kind==="local"){let r=t.operator==="="?e:this.#Cn(n.symbol,n.pos,e);return r=this.#S(t.value,r),this.#cs(n.symbol,n.pos),Le(r,n.symbol.index)}let s=this.#en(n);if(s){let r=t.operator==="="?e:this.#nn(s,n.pos,e);return r=this.#S(t.value,r),this.#us(s,n.pos,r)}return this.#S(t.value,this.#S(t.target,e))}}}#cs(t,e){t.isFinal&&(t.forEach?this.#Te(e,`variable ${t.name} might already have been assigned`):(t.parameter!==void 0||t.catchParameter)&&this.#Te(e,`final parameter ${t.name} may not be assigned`))}#us(t,e,n){if(!Gn(n,t.index)){let s=this.#tt?"might be assigned in loop":"might already have been assigned";this.#Te(e,`variable ${t.field.name} ${s}`)}return Le(n,t.index)}};function ie(i,t){return`${i}(${t.map($e).join(",")})`}function No(i,t){if(i.tag==="library"&&t.tag==="library"){if(!i.args.length||i.args.some(n=>n.tag==="wildcard"))return!1;let e=Pt(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&et(e,t)}if(i.tag!=="class"||!i.args?.length||i.args.some(e=>e.tag==="wildcard"))return!1;if(t.tag==="library"){let e=Ae(i).map(n=>Pt(n,t.symbol)).find(n=>n);return e!=null&&et(e,t)}if(t.tag==="class"){let e=Zt(i,t.symbol);return e!==null&&e.symbol!==i.symbol&&et(e,t)}return!1}function $o(i,t){let e=[],n=s=>{s.tag==="typevar"&&!s.symbol&&t.includes(s.name)?e.push(s.name):s.tag==="array"?n(s.element):s.tag==="wildcard"&&s.bound?n(s.bound):s.tag==="library"&&s.args.forEach(n)};return n(i),e}function Kn(i,t,e){return`${ie(i,t)}${$e(e)}`}function De(i){return i.tag==="long"||i.tag==="double"?2:1}function me(i,t){let e=n=>n.some(s=>me(s,t));switch(i.kind){case"BreakStatement":return i.target===t;case"Block":return e(i.statements);case"IfStatement":return me(i.then,t)||i.otherwise!==null&&me(i.otherwise,t);case"WhileStatement":case"DoStatement":case"ForStatement":case"ForEachStatement":case"LabeledStatement":return me(i.body,t);case"SwitchStatement":return i.cases.some(n=>e(n.statements)||n.body?.kind==="Block"&&me(n.body,t));case"TryStatement":return me(i.block,t)||i.catches.some(n=>me(n.block,t))||i.finallyBlock!==null&&me(i.finallyBlock,t);default:return!1}}function ea(i){return i.qualifiedName==="java.lang.String"?"String":i.qualifiedName}function $e(i){switch(i.tag){case"typevar":return i.symbol?$e(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 $e(i.element)+"[]";default:return M(i)}}function ua(i){return i.tag==="typevar"&&i.symbol?i.symbol.bounds.some(t=>ua(t)||t.tag==="library"&&t.symbol.name==="Comparable"):i.tag==="class"?i.symbol.isEnum||yn(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 Is(i){if(i.kind==="Name")return i.identifier;if(i.kind!=="FieldAccess")return null;let t=Is(i.target);return t===null?null:`${t}.${i.name}`}function We(i){return`${/^[AEIOU]/i.test(i)?"an":"a"} ${i}`}function fe(i){if(!i)return;let t=i.tag==="wildcard"?i.bound??void 0:i;return t?.tag==="object"?void 0:t}var qn={tag:"typevar",name:"?return"};function ae(i,t){switch(i.tag){case"typevar":return t===null?!i.symbol:t.includes(ys(i));case"class":return i.args?.some(e=>ae(e,t))??!1;case"array":return ae(i.element,t);case"wildcard":return i.bound!==null&&ae(i.bound,t);case"library":return i.args.some(e=>ae(e,t));default:return!1}}function Es(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??H:r:H});return{params:t.params.map(n=>Xt(n,i.symbol.typeParams,e)),returnType:Xt(t.returnType,i.symbol.typeParams,e)}}function Mo(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 Po(i){return i.kind==="MethodCall"||i.kind==="Assignment"||i.kind==="IncDec"||i.kind==="NewObject"}function Ye(i){if(i.kind==="Name")return[i.identifier];if(i.kind==="FieldAccess"){let t=Ye(i.target);return t?[...t,i.name]:null}return null}var ha=new Set(["type","symbol","method","constant","libraryCall","ctor","fieldSymbol","captures","functional","caught","finallySlots","lambda","receiver","mathFunction","interfaceSymbol","imported"]);function Os(i,t){if(Array.isArray(i)){for(let n of i)Os(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))ha.has(n)||s===null||typeof s!="object"||Os(s,t)}function Ro(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))!ha.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=ys(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:tt(t)?Sr(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"&&!tt(t.element))return;bt(i.element,t.element,e);return}let n=s=>s.tag==="wildcard"?s.bound??H:s;if(i.tag==="library"&&(t.tag==="library"||t.tag==="class"||t.tag==="typevar")){let s=t.tag==="library"?Pt(t,i.symbol):t.tag==="class"?Ae(t).map(r=>Pt(r,i.symbol)).find(r=>r)??null:null;if(s)i.args.forEach((r,a)=>s.args[a]&&bt(r,r.tag==="typevar"&&!gr(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=Zt(t,i.symbol);s?.args&&i.args.forEach((r,a)=>s.args[a]&&bt(r,n(s.args[a]),e))}}function gr(i){return i.tag==="wildcard"&&i.poly!==void 0}function Jo(i,t){if(i.tag!=="library"||t.tag!=="library")return null;let e=Pt(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=>!z(o,r)))continue;let a=s.poly.lows.filter((o,c)=>s.poly.lows.findIndex(u=>et(u,o))===c);return[`inference variable ${s.poly.name} has incompatible bounds`,` equality constraints: ${M(r)}`,` lower bounds: ${[...a].reverse().map(M).join(",")}`,...s.poly.where].join(`\n`)}return null}function Sr(i){return i.tag==="library"&&i.args.some(gr)?{...i,args:i.args.map(t=>gr(t)?t.bound:t)}:i}function As(i,t,e=!1){let n=new Map;if(t?.tag!=="library")return n;let s=dt(i,i.typeParams.map(o=>({tag:"typevar",name:o}))),r=Pt(s,t.symbol),a=o=>e&&o?.tag==="object"?o:fe(o);return r&&r.args.forEach((o,c)=>a(t.args[c])&&bt(o,a(t.args[c]),n)),n}function fr(i,t){let e=new Map;if(!t)return e;let n=ue(i);if(t.tag==="class"){let s=Zt(n,t.symbol);s?.args&&t.args&&s.args.forEach((r,a)=>fe(t.args[a])&&bt(r,fe(t.args[a]),e))}else if(t.tag==="library"){let s=Ae(n).map(r=>Pt(r,t.symbol)).find(r=>r);s&&s.args.forEach((r,a)=>fe(t.args[a])&&bt(r,fe(t.args[a]),e))}return e}function na(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=tt(o)?Sr(o):Qt(o);if(!c)return;let u=s.get(r.symbol.key)??[];u.some(d=>et(d,c))||u.push(c),s.set(r.symbol.key,u)}else bt(r,o,n)})}function sa(i,t,e){if(!Xn([t]).length||!tt(e))return;let n=W(e);n.tag!=="object"&&n.tag!=="null"&&!z(W(t),n)&&(i.genericCast=n)}function Do(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 Tr(i,e,n,new Set)}function Tr(i,t,e,n){let s=W(i);if(t.some(o=>o.kind==="TypePattern"&&o.tested&&z(s,W(o.tested))))return!0;let r=i.tag==="typevar"&&i.symbol?Fo(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=>Tr(X(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 da(c,o.map(u=>u.components),n)}return!1}function da(i,t,e){if(!i.length)return t.length>0;let[n,...s]=i;return ma(n).every(r=>{let a=t.filter(o=>jo(o[0],r,e));return da(s,a.map(o=>o.slice(1)),e)})}function ma(i){return i.tag==="class"&&i.symbol.isSealed&&i.symbol.isAbstract&&i.symbol.permitted?i.symbol.permitted.flatMap(t=>ma(X(t))):[i]}function jo(i,t,e){return i.kind==="TypePattern"?i.unconditional===!0||i.tested!==void 0&&(Q(t)?et(t,i.tested):z(W(t),W(i.tested))):t.tag==="class"&&Tr(t,[i],[],e)}function Fo(i){return i.symbol?.bounds[0]??H}function br(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(...br(n,t),n);return e}function ra(i){return i.declaration.params[i.declaration.params.length-1]?.varargs===!0}function ia(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 _o(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(!he(e,t[n]))return`varargs mismatch; ${Je(e,t[n])}`;return null}function wn(i){switch(i.tag){case"typevar":return!1;case"array":return wn(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 Uo(i,t){let e=n=>n.tag!=="wildcard"&&n.tag!=="typevar"&&wn(n);if(i.tag==="library"&&t.tag==="library"&&i.args.length){let n=Pt(t,i.symbol);return n!==null&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!et(s,i.args[r]))}if(i.tag==="class"&&t.tag==="class"&&i.args?.length){let n=Zt(t,i.symbol);return n?.args!==void 0&&n.args.some((s,r)=>e(s)&&e(i.args[r])&&!et(s,i.args[r]))}return!1}function Bo(i){return i.tag==="string"||i.tag==="class"||i.tag==="array"||i.tag==="library"&&i.symbol.box!==void 0}function aa(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 Xe(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"?`${M(u.element)}...`:M(u));r.push(` ${a} extends ${e.typeParamShown?.[a]??(o?M(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 Qe(i,t){if(i.tag==="array"&&t.tag==="array")return tt(i.element)&&Qe(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&&z(t,W(i))}function Vo(i,t){let e=!1;return Os(i,n=>{n===t&&(e=!0)}),e}function pr(i,t){if(z(i,t))return t;if(z(t,i))return i;let e=[],n=[i];for(;n.length;){let r=n.shift(),a=r.tag==="class"?Jn(r):r.tag==="library"?ur(r):[];for(let o of a)e.some(c=>et(c,o))||(e.push(o),n.push(o))}let s=e.filter(r=>z(t,r)&&!et(r,H));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)??H}function Ho(i){return i.tag==="wildcard"?i.bound??H:i}function Ne(i){return i.tag==="wildcard"?i.isSuper?H:i.bound??H:i}function Xn(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 Dt(i){let t=Xn(i);if(!t.length)return[];let e=[t.length===1?` where ${t[0].name} is a type-variable:`:` where ${t.map(n=>n.name).join(",")} are type-variables:`];for(let n of t)e.push(` ${n.name} extends ${n.bounds.length?n.bounds.map(M).join(","):"Object"} declared in ${n.declaredIn}`);return e}function zo(i,t,e,n){if(et(i,t))return i;if(i.tag==="byte"&&t.tag==="short"||i.tag==="short"&&t.tag==="byte")return gn;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:Wn(i,t)}function oa(i,t){return et(i,t)?i:i.tag==="null"?t:t.tag==="null"?i:H}function vn(i,t){return Ot(t)?Bi(i,t.tag)??i:i}function Go(i,t,e){let n=vn(t,e);switch(n.kind){case"int":return K(i==="-"?-n.value:i==="~"?~n.value:n.value);case"long":return Jt(i==="-"?-n.value:i==="~"?~n.value:n.value);case"double":return ee(i==="-"?-n.value:n.value);case"float":return de(i==="-"?-n.value:n.value)}}function Ko(i,t,e,n){if(i==="+"&&(t.kind==="string"||e.kind==="string"))return hr(jn(t)+jn(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=Sn(t),h=Sn(e);if(d===void 0||h===void 0)return;let m=BigInt(Number(BigInt.asUintN(6,h)));return i==="<<"?Jt(d<<m):i===">>"?Jt(d>>m):Jt(BigInt.asUintN(64,d)>>m)}let c=Sn(t),u=Sn(e);if(c===void 0||u===void 0)return;switch(i){case"+":return Jt(c+u);case"-":return Jt(c-u);case"*":return Jt(c*u);case"/":return u===0n?void 0:Jt(c/u);case"%":return u===0n?void 0:Jt(c%u);case"&":return Jt(c&u);case"|":return Jt(c|u);case"^":return Jt(c^u);case"<":return gt(c<u);case">":return gt(c>u);case"<=":return gt(c<=u);case">=":return gt(c>=u);case"==":return gt(c===u);case"!=":return gt(c!==u)}return}if((s==="double"||s==="float")&&!r){let c=s==="float",u=c?Ts(t):_n(t),d=c?Ts(e):_n(e);if(u===void 0||d===void 0)return;let h=c?de:ee;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 gt(u<d);case">":return gt(u>d);case"<=":return gt(u<=d);case">=":return gt(u>=d);case"==":return gt(u===d);case"!=":return gt(u!==d)}return}let a=bn(t),o=t.kind==="long"||e.kind==="long"?e.kind==="long"?Number(BigInt.asIntN(32,e.value)):bn(e):bn(e);if(a!==void 0&&o!==void 0){switch(i){case"+":return K(a+o);case"-":return K(a-o);case"*":return K(Math.imul(a,o));case"/":return o===0?void 0:K(a/o);case"%":return o===0?void 0:K(a%o);case"<<":return K(a<<o);case">>":return K(a>>o);case">>>":return K(a>>>o);case"&":return K(a&o);case"|":return K(a|o);case"^":return K(a^o);case"<":return gt(a<o);case">":return gt(a>o);case"<=":return gt(a<=o);case">=":return gt(a>=o);case"==":return gt(a===o);case"!=":return gt(a!==o)}return}if(t.kind==="boolean"&&e.kind==="boolean"){let c=t.value,u=e.value;switch(i){case"&&":case"&":return gt(c&&u);case"||":case"|":return gt(c||u);case"^":case"!=":return gt(c!==u);case"==":return gt(c===u)}return}if(t.kind==="string"&&e.kind==="string"&&(i==="=="||i==="!=")){let c=t.value===e.value;return gt(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},jt={FILL_TRACE:0,PRINT_TRACE:1,ADD_SUPPRESSED:2,GET_SUPPRESSED:3,CLASS_NAME:4,PRINT_UNCAUGHT:5,INIT_CAUSE:6},qo=[[1,1],[1,0],[2,0],[1,1],[1,1],[1,0],[2,1]],Me={INT:0,LONG:1,DOUBLE:2,CHAR:3,BOOLEAN:4,FLOAT:5,BYTE:6,SHORT:7},xr=["int","long","double","char","boolean","float","byte","short"],lt={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},Wo=[1,1,1,2,2,2,2,2,2,1,1,1,1,1],kt={NONE:0,INT:1,BOOLEAN:2,STRING:3,CHAR:4,CHAR_ARRAY:5,OBJECT:6,LONG:7,DOUBLE:8,FLOAT:9},q={INT:0,BOOLEAN:1,CHAR:2,REF:3,LONG:4,DOUBLE:5,BYTE:6,SHORT:7,FLOAT:8},tn={};for(let[i,t]of Object.entries(l))tn[t]={name:i,operands:0,pop:0,push:0};var V=(i,t,e,n)=>Object.assign(tn[i],{operands:t,pop:e,push:n});V(l.ICONST,1,0,1);V(l.SCONST,1,0,1);V(l.ACONST_NULL,0,0,1);V(l.LOAD,1,0,1);V(l.STORE,1,1,0);V(l.POP,0,1,0);V(l.SET_BASE,0,2,0);V(l.BASE,0,1,1);V(l.DUP,0,1,2);V(l.DUP_X1,0,2,3);V(l.DUP_X2,0,3,4);V(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])V(i,0,2,1);for(let i of[l.ICMPEQ,l.ICMPNE,l.ICMPLT,l.ICMPLE,l.ICMPGT,l.ICMPGE,l.ACMPEQ,l.ACMPNE])V(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])V(i,0,1,1);V(l.JUMP,1,0,0);V(l.JUMP_IF_FALSE,1,1,0);V(l.JUMP_IF_TRUE,1,1,0);V(l.IINC,2,0,0);V(l.SCONCAT,0,2,1);V(l.PRINT,3,0,0);V(l.RETURN,0,0,0);V(l.RETURN_VALUE,0,1,0);V(l.INVOKE,2,0,0);V(l.NEWARRAY,1,1,1);V(l.NEWARRAY_REF,1,1,1);V(l.ALOAD,2,2,1);V(l.ASTORE,2,3,0);V(l.ARRAYLENGTH,1,1,1);V(l.STR_LENGTH,1,1,1);V(l.STR_CHARAT,1,2,1);V(l.STR_EQUALS,1,2,1);V(l.GETSTATIC,1,0,1);V(l.PUTSTATIC,1,1,0);V(l.GETFIELD,2,1,1);V(l.PUTFIELD,2,2,0);V(l.NEW,1,0,1);V(l.VALUEOF,0,1,1);V(l.OBJ_TOSTRING,1,1,1);V(l.OBJ_HASHCODE,1,1,1);V(l.OBJ_EQUALS,1,2,1);V(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])V(i,0,2,1);for(let i of[l.DADD,l.DSUB,l.DMUL,l.DDIV,l.DREM])V(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])V(i,0,1,1);for(let i of[l.I2B,l.I2S,l.I2F,l.L2F,l.D2F,l.TOSTRING_FLOAT])V(i,0,1,1);for(let i of[l.FADD,l.FSUB,l.FMUL,l.FDIV,l.FREM])V(i,0,2,1);V(l.NEWMULTI,2,0,1);V(l.CHECKNULL,1,1,0);V(l.MATH,1,0,1);V(l.INVOKE_NATIVE,2,0,0);V(l.BOX,1,1,1);V(l.UNBOX,2,1,1);V(l.STR_TOCHARS,1,1,1);V(l.LAMBDA,5,0,1);V(l.STR_COMPARETO,2,2,1);V(l.HOST_ARG,1,0,1);V(l.HOST_RESULT,0,1,0);V(l.INVOKE_VIRTUAL,2,0,0);V(l.CHECKCAST,1,1,1);V(l.INSTANCEOF,1,1,1);V(l.OBJ_SUPER,1,0,1);V(l.ENUM_VALUEOF,1,1,1);V(l.ATHROW,1,1,0);V(l.THROWABLE,1,0,0);V(l.IF_CMP,2,2,0);V(l.IF_K,3,1,0);V(l.IF_LL,4,0,0);V(l.IF_LK,4,0,0);V(l.IF_LNULL,3,0,0);V(l.LOAD2,2,0,2);V(l.LOADK,2,0,2);V(l.IADDK,1,1,1);V(l.IINC_JUMP,3,0,0);V(l.ALOAD_LL,4,0,1);V(l.IOPK,2,1,1);var vr={[l.IF_CMP]:2,[l.IF_K]:3,[l.IF_LL]:4,[l.IF_LK]:4,[l.IF_LNULL]:3,[l.IINC_JUMP]:3},Xo={[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]},wr=new Set([l.IMUL,l.IDIV,l.IREM,l.IAND,l.IOR,l.IXOR,l.ISHL,l.ISHR,l.IUSHR]),Yo=new Set([l.IF_CMP,l.IF_K,l.IF_LL,l.IF_LK]),Qo=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]),Zo=new Set([l.ALOAD,l.ASTORE,l.INVOKE,l.INVOKE_VIRTUAL,l.GETFIELD,l.PUTFIELD,l.INVOKE_NATIVE,l.UNBOX,l.STR_COMPARETO]),fa=new Set(["removeEldestEntry(Entry)"]),nt=class extends Error{constructor(t){super(`invalid bytecode: ${t}`),this.name="BytecodeError"}};function pa(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=tn[s[d]];if(!h)throw new nt(`unknown opcode ${s[d]} at ${d}`);if(r.add(d),d+=1+h.operands,d>s.length)throw new nt("truncated instruction at end")}let a=new Map,o=[[0,0]],c=i.handlers??new Int32Array(0);if(c.length%4!==0)throw new nt("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 nt(`bad handler ${d/4}`);if(k<-1||k>=t.strings.length)throw new nt(`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 nt(`control reaches non-instruction offset ${m}`);let k=a.get(m);if(k!==void 0){if(k!==p)throw new nt(`stack height ${p} != ${k} at merge ${m}`);break}a.set(m,p);let T=s[m],C=tn[T],S=C.pop,w=C.push;if(T===l.PRINT&&(S=s[m+3]===kt.NONE?0:1),T===l.NEWMULTI&&(S=s[m+2]),T===l.MATH){let A=Wo[s[m+1]];if(A===void 0)throw new nt(`bad Math function at ${m}`);S=A}if(T===l.INVOKE||T===l.INVOKE_VIRTUAL){let A=t.methods[s[m+1]];if(!A)throw new nt(`call to unknown method ${s[m+1]} at ${m}`);S=A.argCount,w=A.returnsValue?1:0}if(T===l.INVOKE_NATIVE){let A=t.natives?.[s[m+1]];if(!A)throw new nt(`call to unknown native ${s[m+1]} at ${m}`);S=A.argCount,w=A.returnsValue?1:0}if((T===l.BOX||T===l.UNBOX)&&(s[m+1]<0||s[m+1]>=xr.length))throw new nt(`bad box kind at ${m}`);if(T===l.LAMBDA){let A=t.methods[s[m+1]],L=s[m+2];if(!A||L<0||L>A.argCount)throw new nt(`bad lambda method at ${m}`);if(s[m+3]<0||s[m+3]>=t.strings.length||s[m+5]>=t.strings.length)throw new nt(`bad lambda interface at ${m}`);S=L}if(T===l.NEW&&(s[m+1]<0||s[m+1]>=e.length))throw new nt(`bad class index at ${m}`);if(T===l.INVOKE_VIRTUAL&&t.methods[s[m+1]]?.selector===void 0)throw new nt(`virtual call to a method without a selector at ${m}`);if(T===l.THROWABLE){let A=qo[s[m+1]];if(!A)throw new nt(`bad Throwable operation at ${m}`);[S,w]=A}if(T===l.OBJ_SUPER){let A=s[m+1];if(A<0||A>2)throw new nt(`bad Object method at ${m}`);S=A===2?2:1}if((T===l.NEWARRAY_REF||T===l.NEWMULTI||T===l.CHECKCAST||T===l.INSTANCEOF)&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new nt(`bad descriptor index at ${m}`);if(T===l.NEWMULTI&&s[m+2]<2)throw new nt(`NEWMULTI needs two or more lengths at ${m}`);if(T===l.NCONST&&(s[m+1]<0||s[m+1]>=(t.numbers?.length??0)))throw new nt(`bad number index at ${m}`);if(p<S)throw new nt(`stack underflow at ${m} (${C.name})`);if(p=p-S+w,u=Math.max(u,p),T===l.LOAD||T===l.STORE||T===l.IINC){let A=s[m+1];if(A<0||A>=i.maxLocals)throw new nt(`bad local slot ${A} at ${m}`)}for(let A of Xo[T]??[]){let L=s[m+A];if(L<0||L>=i.maxLocals)throw new nt(`bad local slot ${L} at ${m}`)}if(T===l.IOPK&&!wr.has(s[m+1]))throw new nt(`bad operator at ${m}`);if(T===l.IOPK&&(s[m+1]===l.IDIV||s[m+1]===l.IREM)&&s[m+2]===0)throw new nt(`division by a zero constant at ${m}`);if(Yo.has(T)&&(s[m+1]<0||s[m+1]>11))throw new nt(`bad condition at ${m}`);if(T===l.ALOAD_LL&&(s[m+4]<-1||s[m+4]>=t.messages.length))throw new nt(`bad message index at ${m}`);if(T===l.SCONST&&(s[m+1]<0||s[m+1]>=t.strings.length))throw new nt(`bad string index at ${m}`);if(T===l.GETSTATIC||T===l.PUTSTATIC||T===l.GETFIELD||T===l.PUTFIELD){let A=T<=l.PUTSTATIC?t.staticFieldIsReference?.length??0:n;if(s[m+1]<0||s[m+1]>=A)throw new nt(`bad field index at ${m}`)}let I=Zo.has(T)?s[m+2]:Qo.has(T)?s[m+1]:null;if(I!==null&&(I<-1||I>=t.messages.length))throw new nt(`bad message index at ${m}`);if(T===l.RETURN||T===l.RETURN_VALUE){if(T===l.RETURN_VALUE!==i.returnsValue)throw new nt(`wrong return kind at ${m}`);if(p!==0)throw new nt(`return with non-empty stack at ${m}`);break}if(T===l.ATHROW)break;let R=m+1+C.operands,N=vr[T];if(N!==void 0){let A=s[m+N];if(!r.has(A))throw new nt(`jump to ${A} at ${m}`);if(o.push([A,p]),T===l.IINC_JUMP)break}if(T===l.JUMP||T===l.JUMP_IF_FALSE||T===l.JUMP_IF_TRUE){let A=s[m+1];if(!r.has(A))throw new nt(`jump to ${A} at ${m}`);if(o.push([A,p]),T===l.JUMP)break}if(R>=s.length)throw new nt(`falls off the end at ${m}`);m=R}}return u}function ya(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 tl=l.ICMPEQ,Ls=i=>i!==void 0&&i>=l.ICMPEQ&&i<=l.ICMPGE,Ns=(i,t)=>i-tl+(t===l.JUMP_IF_FALSE?6:0),Qn=i=>i===l.JUMP_IF_FALSE||i===l.JUMP_IF_TRUE;function ga(i){let t=i.code,e=[];for(let u=0;u<t.length;u+=1+tn[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=w=>e[u+w],h=w=>d(w)===void 0?void 0:t[d(w)],m=(w,I=1)=>t[d(w)+I],p=w=>{for(let I=1;I<w;I++)if(d(I)===void 0||n.has(d(I)))return!1;return!0},k=(w,...I)=>{let R=r.length;for(let A=0;A<w;A++)a.set(d(A),R);r.push(...I);let N=vr[I[0]];N!==void 0&&o.push(R+N),u+=w},T=h(0);if(T===l.LOAD&&h(1)===l.LOAD&&Ls(h(2))&&Qn(h(3))&&p(4)){k(4,l.IF_LL,Ns(h(2),h(3)),m(0),m(1),m(3));continue}if(T===l.LOAD&&h(1)===l.ICONST&&Ls(h(2))&&Qn(h(3))&&p(4)){k(4,l.IF_LK,Ns(h(2),h(3)),m(0),m(1),m(3));continue}if(T===l.LOAD&&h(1)===l.ACONST_NULL&&(h(2)===l.ACMPEQ||h(2)===l.ACMPNE)&&Qn(h(3))&&p(4)){let w=h(2)===l.ACMPEQ==(h(3)===l.JUMP_IF_TRUE);k(4,l.IF_LNULL,w?1:0,m(0),m(3));continue}if(T===l.ICONST&&Ls(h(1))&&Qn(h(2))&&p(3)){k(3,l.IF_K,Ns(h(1),h(2)),m(0),m(2));continue}if(Ls(T)&&Qn(h(1))&&p(2)){k(2,l.IF_CMP,Ns(T,h(1)),m(1));continue}if(T===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(T===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(T===l.ICONST&&wr.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(T===l.IINC&&h(1)===l.JUMP&&p(2)){k(2,l.IINC_JUMP,m(0),m(0,2),m(1));continue}if(T===l.LOAD&&h(1)===l.LOAD&&p(2)){k(2,l.LOAD2,m(0),m(1));continue}if(T===l.LOAD&&h(1)===l.ICONST&&p(2)){k(2,l.LOADK,m(0),m(1));continue}let C=d(0),S=1+tn[T].operands;a.set(C,r.length),(T===l.JUMP||T===l.JUMP_IF_FALSE||T===l.JUMP_IF_TRUE)&&o.push(r.length+1);for(let w=0;w<S;w++)r.push(t[C+w]);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 Ar(i,t){return i.declaration.members.filter(e=>e.kind==="Initializer"&&e.isStatic===t&&e.symbol!==void 0)}function ba(i){return Math.max(i.maxSlots,i.finallySlots??0)}function Or(i,t,e){let n=new Ir(t),s=i.classes.find(p=>p.binaryName==="java.lang.Throwable");n.useThrowable(s);let r=i.methods.map(p=>p.builtin?n.builtin(p):p.isAbstract?n.abstractStub(p):p.isConstructor?n.constructorCode(p):n.method(p)),a=new Map;for(let p of i.classes)for(let k of p.bridges??[])a.set(k,k.alias?k.target.index:r.push(n.bridge(p,k))-1);let o=sl(i,a),c=p=>i.selectors.get(p)??-1,u=i.classes.map(p=>{let k=p.fields.filter(L=>L.isStatic&&L.declarator.init&&!L.constant),T=Ar(p,!0),C=k.length||p.enumConstants.length||T.length?r.push(n.staticInitializer(p,k))-1:-1,S=new Array(p.instanceCount).fill(!1);for(let L=p;L;L=L.superclass){L.outerField>=0&&(S[L.outerField]=!0);for(let J of L.fields)J.isStatic||(S[J.index]=ts(J.type));L===s&&S.fill(!0,mt.message,mt.causeSet)}let w=o.get(p),I=L=>c(L)>=0?w[c(L)]:-1,R={};w.forEach(L=>{if(L<0||L>=i.methods.length)return;let J=i.methods[L],D=`${J.name}/${J.params.length}`;(!(D in R)||J.owner===p)&&(R[D]=L)});let N=[];for(let L=p;L;L=L.superclass)N.unshift(L);for(let L of N)for(let J of L.bridges??[])J.library&&(R[`${J.name}/${J.params.length}`]=w[J.selector]);let A={};for(let L of N)for(let[J,D]of L.libraryOverrides??[])A[J]=w[D];return{name:p.binaryName,instanceFieldIsReference:S,clinit:C,toString:I("toString()String"),equals:I("equals(Object)boolean"),hashCode:I("hashCode()int"),superclass:p.superclass?.index??-1,isInterface:p.isInterface,types:rl(p),vtable:w,virtuals:R,...Object.keys(A).length?{libraryOverrides:A}:{},...p.isEnum?{enumConstants:p.enumConstants.map(L=>L.index),canonicalName:p.binaryName.replace(/\\$/g,".")}:{}}}),d=r.push(e?n.practiceLauncher(e):n.launcher(i))-1,h=r.push(n.uncaughtPrinter(s))-1,m={version:14,classes:u,strings:n.strings,numbers:n.numbers,natives:n.natives,messages:n.messages,methods:r,staticFieldIsReference:i.staticFields.map(p=>ts(p.type)),staticFieldOwner:i.staticFields.map(p=>p.owner.index),entry:d,uncaught:h};for(let p of r)ga(p),p.maxStack=pa(p,m);return m}function sl(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 rl(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 Y=class{pc=-1;uses=[]};function Fe(i){switch(i.tag){case"int":return q.INT;case"boolean":return q.BOOLEAN;case"char":return q.CHAR;case"long":return q.LONG;case"double":return q.DOUBLE;case"byte":return q.BYTE;case"short":return q.SHORT;case"float":return q.FLOAT;case"string":case"class":case"array":case"library":case"diamond":case"object":case"typevar":return q.REF;default:throw new Error(`codegen: array of ${M(i)}`)}}var Sa=["int","byte/boolean","char","object","long","double","byte/boolean","short","float"];function kn(i){return i.tag==="class"?i.symbol.binaryName:i.tag==="array"?kn(i.element)+"[]":M(i)}function Pe(i){let t=i;for(;t.kind==="Parenthesized";)t=t.expression;return t}function kr(i){let t=Pe(i);return t.kind==="Name"&&t.symbol?.kind==="type"||t.kind==="FieldAccess"&&t.typeSymbol!==void 0}function Cr(i,t){return i.tag==="double"||t.tag==="double"?ht:i.tag==="float"||t.tag==="float"?xt:i.tag==="long"||t.tag==="long"?Lt:U}var il=new Set(["int","byte","short","char","long","float","double"]),Zn=i=>i!==void 0&&il.has(i.tag),Er=i=>i.tag==="int"||i.tag==="byte"||i.tag==="short"||i.tag==="char",Ce=i=>Zn(i)||i?.tag==="boolean",ne={int:Me.INT,long:Me.LONG,double:Me.DOUBLE,char:Me.CHAR,boolean:Me.BOOLEAN,float:Me.FLOAT,byte:Me.BYTE,short:Me.SHORT},al={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()"},ol={"+":{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}},$s={"<":l.ICMPLT,"<=":l.ICMPLE,">":l.ICMPGT,">=":l.ICMPGE,"==":l.ICMPEQ,"!=":l.ICMPNE},ll={"abs-int":lt.ABS_I,"abs-long":lt.ABS_L,"abs-double":lt.ABS_D,"max-int":lt.MAX_I,"max-long":lt.MAX_L,"max-double":lt.MAX_D,"min-int":lt.MIN_I,"min-long":lt.MIN_L,"min-double":lt.MIN_D,"abs-float":lt.ABS_D,"max-float":lt.MAX_D,"min-float":lt.MIN_D,"round-float":lt.ROUND_F,sqrt:lt.SQRT,floor:lt.FLOOR,ceil:lt.CEIL,"round-double":lt.ROUND},Ms=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}},Ir=class{strings=[];numbers=[];natives=[];#O=new Map;messages=[];#dt=new Map;#Mt=new Map;#D=new Map;#j;get#W(){return this.#z?.topLevel?.file??this.#j}#z;#r=[];#y=[];#s=-1;#n=new Map;#g=U;#h=0;#i=!1;#w=[];#H=0;#c=0;#C=0;#L=0;#F=[];#K=[];#mt=Object.create(null);constructor(t){this.#j=t}#bt(t){return`${t.owner.binaryName}.${t.name}(${t.params.map(kn).join(", ")})`}#it(t,e){return`${t.qualifier??e.owner.binaryName}.${e.name}(${e.params.map(kn).join(", ")})`}#$(t,e,n){this.#z=t,this.#r=[],this.#y=[],this.#s=-1,this.#n=new Map,this.#g=n,this.#h=e,this.#w=[],this.#H=0,this.#c=0,this.#C=0,this.#L=0,this.#F=[],this.#K=[]}useThrowable(t){for(let e of t.methods)nl.includes(e.name)&&(this.#mt[e.name]=e)}#N(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)])}#gt(t,e){let n={className:t.binaryName,classIndex:t.index,isStatic:e.isStatic,name:e.name,display:e.display,file:this.#W.name,argCount:e.argCount,returnsValue:e.returnsValue,code:Int32Array.from(this.#r),lines:Int32Array.from(this.#y),maxLocals:Math.max(1,this.#h+this.#L),maxStack:0};return e.hidden&&(n.hidden=!0),this.#F.length&&(n.handlers=Int32Array.from(this.#F)),n}#a(t){return t.parameter!==void 0?`<parameter${t.parameter}>`:`<local${this.#l(t)}>`}#l(t){let e=t.slot;for(let n of this.#w)t.slot>=n.from&&(e+=n.by);return e}#E(){let t=this.#h+this.#C++;return this.#L=Math.max(this.#L,this.#C),t}#et(){this.#C--}staticInitializer(t,e){this.#$(t,Math.max(1,...Ar(t,!0).map(n=>ba(n.symbol))),U);for(let n of t.enumConstants){let{node:s,ordinal:r}=n.enumConstant;this.#p(s.pos),this.#t(l.NEW,s.ctor.owner.index,l.DUP,l.SCONST,this.#T(s.name),l.ICONST,r),this.#at(s.args,s.ctor.params,s.varargs),this.#t(l.INVOKE,s.ctor.index,-1,l.PUTSTATIC,n.index)}return this.#Xt(t,!0,n=>e.includes(n),0),this.#t(l.RETURN),this.#gt(t,{name:"<clinit>",display:`${t.binaryName}.<clinit>()`,isStatic:!0,argCount:0,returnsValue:!1})}#Xt(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.#_(o)}else r.kind==="Initializer"&&r.isStatic===e&&r.symbol&&(s&&this.#w.push({from:1,by:s}),this.#x(r.body),s&&this.#w.pop())}#_(t){let e=t.declarator.init;this.#p(t.declarator.pos),t.isStatic||this.#t(l.LOAD,0),e.kind==="ArrayInitializer"?this.#Qt(e):(this.#u(e,!0),this.#f(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=Ar(e,!1).map(m=>r-1+ba(m.symbol));this.#$(e,Math.max(s,t.maxSlots,t.finallySlots??0,...a),U);let o=t.declaration.body,c=o.statements,u=c[0];if(u?.kind==="ConstructorCall"&&u.keyword==="this")this.#p(u.start),this.#t(l.LOAD,0),n&&this.#t(l.LOAD,1),n===2&&this.#t(l.LOAD,2),this.#at(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.#p(u.start),this.#t(l.LOAD,0),this.#at(u.args,u.target.params,u.varargs),this.#t(l.INVOKE,u.target.index,-1)):u.libraryCall&&(this.#p(u.start),this.#t(l.LOAD,0),this.#at(u.args,u.libraryCall.params),this.#t(l.INVOKE_NATIVE,this.#A(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.#p(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.#A(t.superLibrary.native,t.params.length,!0,t.superLibrary.unwrap,t.superLibrary.unwrapCalls),-1,l.SET_BASE)}else if(t.superConstructor){this.#p(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.#p(o.pos),this.#t(l.LOAD,0),this.#at([],t.superConstructor.params,t.superVarargs),this.#t(l.INVOKE,t.superConstructor.index,-1)):t.superLibrary&&(this.#p(o.pos),this.#t(l.LOAD,0,l.INVOKE_NATIVE,this.#A(t.superLibrary.native,0,!0),-1,l.SET_BASE));this.#Xt(e,!1,m=>m.declarator.init!==void 0&&m.declarator.init!==null,r-1)}for(let m of c)this.#x(m);this.#p(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.#gt(e,{name:"<init>",display:`${e.binaryName}.<init>(${t.params.map(kn).join(", ")})`,isStatic:!1,argCount:s,returnsValue:!1}),h=this.#N(t);return h&&(d.argSlots=h),d}launcher(t){let e=t.main,n=t.mainClass;return this.#$(n,1,U),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,q.REF),this.#t(l.INVOKE,e.index,-1,l.RETURN),this.#y=[],this.#gt(n,{name:"<launch>",display:"<launch>",isStatic:!0,argCount:0,returnsValue:!1,hidden:!0})}practiceLauncher(t){let{method:e}=t,n=e.owner;return this.#$(n,1,U),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.#y=[],this.#gt(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,Math.max(n,t.maxSlots,t.finallySlots??0),t.returnType),this.#p(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.#T(`[L${e.binaryName};`)),e.enumConstants.forEach((a,o)=>this.#t(l.DUP,l.ICONST,o,l.GETSTATIC,a.index,l.ASTORE,q.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.#A("toString()",1,!0),-1,l.RETURN_VALUE);break;case"library-hashCode":this.#t(l.LOAD,0,l.BASE,l.INVOKE_NATIVE,this.#A("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.#A("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.#Vt(\'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.#P(e);break;case"record-hashCode":this.#Bt(e);break;case"record-equals":this.#R(e);break;case"throwable-constructor":this.#M(t);break;case"throwable-getMessage":this.#t(l.LOAD,0,l.GETFIELD,mt.message,-1,l.RETURN_VALUE);break;case"throwable-getLocalizedMessage":this.#t(l.LOAD,0,l.INVOKE_VIRTUAL,this.#mt.getMessage.index,-1,l.RETURN_VALUE);break;case"throwable-getCause":this.#t(l.LOAD,0,l.GETFIELD,mt.cause,-1,l.RETURN_VALUE);break;case"throwable-initCause":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,jt.INIT_CAUSE,l.RETURN_VALUE);break;case"throwable-toString":{let a=new Y,o=this.#E();this.#t(l.LOAD,0,l.THROWABLE,jt.CLASS_NAME,l.LOAD,0,l.INVOKE_VIRTUAL,this.#mt.getLocalizedMessage.index,-1,l.STORE,o),this.#t(l.LOAD,o,l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,a),this.#t(l.SCONST,this.#T(": "),l.SCONCAT,l.LOAD,o,l.SCONCAT),this.#m(a),this.#t(l.RETURN_VALUE),this.#et();break}case"throwable-printStackTrace":this.#t(l.LOAD,0,l.THROWABLE,jt.PRINT_TRACE,l.RETURN);break;case"throwable-addSuppressed":this.#t(l.LOAD,0,l.LOAD,1,l.THROWABLE,jt.ADD_SUPPRESSED,l.RETURN);break;case"throwable-getSuppressed":this.#t(l.LOAD,0,l.THROWABLE,jt.GET_SUPPRESSED,l.RETURN_VALUE);break;case"throwable-fillInStackTrace":this.#t(l.LOAD,0,l.THROWABLE,jt.FILL_TRACE,l.RETURN_VALUE);break}let r=this.#gt(e,{name:t.isConstructor?"<init>":t.name,display:t.isConstructor?`${e.binaryName}.<init>(${t.params.map(kn).join(", ")})`:this.#bt(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}#M(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.#mt.fillInStackTrace.index,-1,l.POP),t.throwableConstructor){case"message":e(mt.message,()=>this.#t(l.LOAD,1));break;case"message-cause":e(mt.message,()=>this.#t(l.LOAD,1)),e(mt.cause,()=>this.#t(l.LOAD,2)),e(mt.causeSet,()=>this.#t(l.ICONST,1));break;case"cause":{let n=new Y;this.#t(l.LOAD,1,l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,n),e(mt.message,()=>this.#t(l.LOAD,1,l.INVOKE_VIRTUAL,this.#mt.toString.index,-1)),this.#m(n),e(mt.cause,()=>this.#t(l.LOAD,1)),e(mt.causeSet,()=>this.#t(l.ICONST,1));break}case"index":e(mt.message,()=>this.#t(l.SCONST,this.#T(t.owner.builtin.indexPrefix),l.LOAD,1,l.TOSTRING_INT,l.SCONCAT));break;case"object":{e(mt.message,()=>this.#t(l.LOAD,1,l.VALUEOF,l.TOSTRING_REF));let n=new Y;this.#t(l.LOAD,1,l.INSTANCEOF,this.#T("Ljava.lang.Throwable;")),this.#d(l.JUMP_IF_FALSE,n),e(mt.cause,()=>this.#t(l.LOAD,1)),e(mt.causeSet,()=>this.#t(l.ICONST,1)),this.#m(n);break}}this.#t(l.RETURN)}uncaughtPrinter(t){return this.#$(t,1,U),this.#t(l.LOAD,0,l.THROWABLE,jt.PRINT_UNCAUGHT,l.RETURN),this.#gt(t,{name:"<uncaught>",display:"<uncaught>",isStatic:!0,argCount:1,returnsValue:!1,hidden:!0})}#k(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)}#P(t){t.components.forEach((e,n)=>{this.#t(l.SCONST,this.#T(`${n===0?`${t.name}[`:", "}${e.name}=`)),n>0&&this.#t(l.SCONCAT),this.#k(e),this.#t(l.SCONCAT)}),this.#t(l.SCONST,this.#T(t.components.length?"]":`${t.name}[]`)),t.components.length&&this.#t(l.SCONCAT),this.#t(l.RETURN_VALUE)}#Bt(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=ne[e.type.tag];if(n!==void 0)this.#t(l.BOX,n,l.OBJ_HASHCODE,-1);else{let s=new Y,r=new Y;this.#t(l.DUP,l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,s),this.#t(l.OBJ_HASHCODE,-1),this.#d(l.JUMP,r),this.#m(s),this.#t(l.POP,l.ICONST,0),this.#m(r)}this.#t(l.IADD)}this.#t(l.RETURN_VALUE)}#R(t){let e=new Y,n=new Y;this.#t(l.LOAD,0,l.LOAD,1,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,e),this.#t(l.LOAD,1,l.INSTANCEOF,this.#T(`L${t.binaryName};`)),this.#d(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,ne[s.type.tag]),r(1),this.#t(l.BOX,ne[s.type.tag],l.OBJ_EQUALS,-1),this.#d(l.JUMP_IF_FALSE,n);else if(ne[s.type.tag]!==void 0)r(0),r(1),this.#t(l.ICMPEQ),this.#d(l.JUMP_IF_FALSE,n);else{let a=new Y;r(0),r(1),this.#t(l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,a),r(0),this.#t(l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,n),r(0),r(1),this.#t(l.OBJ_EQUALS,-1),this.#d(l.JUMP_IF_FALSE,n),this.#m(a)}}this.#m(e),this.#t(l.ICONST,1,l.RETURN_VALUE),this.#m(n),this.#t(l.ICONST,0,l.RETURN_VALUE)}abstractStub(t){let e=t.params.length+(t.isStatic?0:1);this.#$(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.#gt(t.owner,{name:t.name,display:this.#bt(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.#$(t,s,e.returnType),this.#p(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"&&Rt(c)!==Rt(a)&&ts(c)&&this.#t(l.CHECKCAST,this.#T(Rt(c)))}),this.#t(l.INVOKE_VIRTUAL,e.target.index,-1,e.returnType.tag==="void"?l.RETURN:l.RETURN_VALUE);let r=this.#gt(t,{name:e.name,display:`${t.binaryName}.${e.name}(${e.params.map(kn).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.#$(t.owner,Math.max(e,t.maxSlots,t.finallySlots??0),t.returnType);let n=t.declaration.body;this.#i=t.lambda?.reference===!0;for(let a of n.statements)this.#x(a);this.#i=!1,t.returnType.tag==="void"&&(this.#p(n.end-1),this.#t(l.RETURN));let s=this.#gt(t.owner,{name:t.name,display:this.#bt(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.#N(t);return r&&(s.argSlots=r),s}#t(...t){for(let e of t)this.#r.push(e)}#p(t){let{line:e}=cs(this.#W,t);e!==this.#s&&(this.#s=e,this.#y.push(this.#r.length,e))}#d(t,e){this.#t(t,-1),e.uses.push(this.#r.length-1),e.pc>=0&&(this.#r[this.#r.length-1]=e.pc)}#J(t){t.pc=this.#r.length;for(let e of t.uses)this.#r[e]=t.pc;this.#s=-1}#m(t){t.pc=this.#r.length;for(let e of t.uses)this.#r[e]=t.pc}#T(t){let e=this.#dt.get(t);return e===void 0&&(e=this.strings.length,this.strings.push(t),this.#dt.set(t,e)),e}#ft(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.#Mt.get(e);n===void 0&&(n=this.numbers.length,this.numbers.push(t),this.#Mt.set(e,n)),this.#t(l.NCONST,n)}#Pt(t){switch(t.kind){case"int":case"byte":case"short":case"char":this.#t(l.ICONST,t.value);return;case"long":this.#ft(wt(t.value));return;case"double":case"float":this.#ft(t.value);return;case"boolean":this.#t(l.ICONST,t.value?1:0);return;case"string":this.#t(l.SCONST,this.#T(t.value));return}}#A(t,e,n,s,r){let a=`${t}/${n}`,o=this.#O.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.#O.set(a,o)),o}#Et(t,e,n,s){let r=-1;e&&(this.#u(e,!0),r=this.#X(`Cannot invoke "${t.display}"`,e),t.onBase&&this.#t(l.BASE));let a=n.length;if(t.varargsFrom===void 0)this.#at(n,t.params);else{let c=t.varargsFrom;this.#at(n.slice(0,c),t.params);let u=t.params[c].element,d=n.slice(c);this.#t(l.ICONST,d.length),this.#Nt(u),d.forEach((h,m)=>{this.#t(l.DUP,l.ICONST,m),this.#u(h,!0),this.#f(u,h),this.#t(l.ASTORE,Fe(u),-1)}),a=c+1}let o=a+(e?1:0);this.#t(l.INVOKE_NATIVE,this.#A(t.native,o,t.returnsValue,t.unwrap,t.unwrapCalls),r),!s&&t.returnsValue&&this.#t(l.POP)}#Y(t){let e=Pe(t);switch(e.kind){case"Name":return e.symbol?.kind==="field"?e.outerHops?`${this.#ct(e.outerHops)}.${e.symbol.name}`:this.#Rt(e.symbol):e.symbol?.kind!=="local"?null:this.#a(e.symbol);case"FieldAccess":{let n=e.fieldSymbol;if(!n)return null;if(n.isStatic)return this.#Rt(n);if(Pe(e.target).kind==="This")return`this.${n.name}`;let s=this.#Y(e.target);return s===null?null:`${s}.${n.name}`}case"MethodCall":return e.method?this.#it(e,e.method):e.objectMethod?`${e.qualifier??"Object"}.${Ta[e.objectMethod]}`:e.libraryCall?e.libraryCall.display:null;case"ArrayAccess":{let n=this.#Y(e.array);if(n===null)return null;let s=Pe(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.#Y(s)??"...":"...";return`${n}[${r}]`}case"Cast":return this.#Y(e.expression);default:return null}}#Rt(t){return t.isStatic?`${t.owner.binaryName}.${t.name}`:`this.${t.name}`}#Vt(t){let e=this.#D.get(t);return e===void 0&&(e=this.messages.length,this.messages.push(t),this.#D.set(t,e)),e}#I(t,e){if(this.#i)return-1;let n=t;if(typeof e=="string")n+=` because "${e}" is null`;else{let r=Pe(e);if(r.kind==="MethodCall"&&(r.method||r.objectMethod||r.libraryCall))n+=` because the return value of "${this.#Y(r)}" is null`;else{let a=this.#Y(e);a!==null&&(n+=` because "${a}" is null`)}}let s=this.#D.get(n);return s===void 0&&(s=this.messages.length,this.messages.push(n),this.#D.set(n,s)),s}#X(t,e){return Pe(e).kind==="This"?-1:this.#I(t,e)}#x(t){switch(t.kind){case"Block":for(let e of t.statements)this.#x(e);return;case"EmptyStatement":return;case"LocalVariableDeclaration":for(let e of t.declarators)e.init&&(this.#p(e.pos),e.init.kind==="ArrayInitializer"?this.#Qt(e.init):(this.#u(e.init,!0),this.#f(e.symbol.type,e.init)),this.#t(l.STORE,this.#l(e.symbol)));return;case"ExpressionStatement":this.#p(t.start),this.#u(t.expression,!1);return;case"IfStatement":{let e=t.condition.constant;if(e&&e.kind==="boolean"){e.value?this.#x(t.then):t.otherwise&&this.#x(t.otherwise);return}this.#p(t.start);let n=new Y;if(this.#lt(t.condition,n,!1),this.#x(t.then),t.otherwise){let s=new Y;this.#d(l.JUMP,s),this.#J(n),this.#x(t.otherwise),this.#J(s)}else this.#J(n);return}case"WhileStatement":this.#At(t,t.start,t.condition,t.body,[]);return;case"ForStatement":if(t.init&&!Array.isArray(t.init))this.#x(t.init);else for(let e of t.init??[])this.#p(e.start),this.#u(e,!1);this.#At(t,t.start,t.condition,t.body,t.update);return;case"DoStatement":{let e=new Y,n=new Y,s=new Y;this.#n.set(t,{breakLabel:s,continueLabel:n,tryDepth:this.#K.length}),this.#J(e),this.#x(t.body),this.#J(n),this.#p(t.condition.start),this.#lt(t.condition,e,!0),this.#J(s);return}case"ForEachStatement":this.#o(t);return;case"LabeledStatement":{let e=new Y;this.#n.set(t,{breakLabel:e,tryDepth:this.#K.length}),this.#x(t.body),this.#J(e);return}case"SwitchStatement":this.#Ht(t,!1);return;case"YieldStatement":{this.#p(t.start);let e=this.#n.get(t.target);this.#u(t.value,!0),this.#f(e.resultType,t.value),this.#d(l.JUMP,e.breakLabel);return}case"BreakStatement":{this.#p(t.start);let e=this.#n.get(t.target);this.#pt(e.tryDepth??0,t.liveSlots,()=>this.#d(l.JUMP,e.breakLabel));return}case"ContinueStatement":{this.#p(t.start);let e=this.#n.get(t.target);this.#pt(e.tryDepth??0,t.liveSlots,()=>this.#d(l.JUMP,e.continueLabel));return}case"ReturnStatement":if(this.#p(t.start),t.value){if(this.#u(t.value,!0),this.#f(this.#g,t.value),!this.#K.length){this.#t(l.RETURN_VALUE);return}let e=this.#E();this.#t(l.STORE,e),this.#pt(0,t.liveSlots,()=>this.#t(l.LOAD,e,l.RETURN_VALUE)),this.#et()}else this.#pt(0,t.liveSlots,()=>this.#t(l.RETURN));return;case"ConstructorCall":throw new Error("codegen: this(...) outside a constructor prologue");case"ThrowStatement":this.#p(t.start),this.#u(t.expression,!0),this.#t(l.ATHROW,this.#I("Cannot throw exception",t.expression));return;case"AssertStatement":return;case"LocalClass":return;case"TryStatement":this.#U(t);return}}#U(t){let e=t.catches.map(o=>({types:(o.caught??[]).map(c=>Rt(c)),body:()=>{this.#t(l.STORE,this.#l(o.symbol)),this.#x(o.block)}})),n=t.finallyBlock,s=t.resources.length?()=>this.#e(t.resources,0,()=>this.#x(t.block)):()=>this.#x(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.#c;d&&(this.#H=Math.max(this.#H,u+r.extent)),d||this.#c++,this.#w.push({from:r.base,by:u-r.base}),this.#x(n),this.#w.pop(),d||this.#c--},anyAt:()=>Math.max(r.before,this.#H)+1,blockCompletes:t.blockCompletes??!0,handlerCompletes:t.catches.map(o=>o.completes??!0)}:null;this.#Q(s,e,a)}#tt(t){return{run:()=>t(),anyAt:()=>0,blockCompletes:!0,handlerCompletes:[]}}#Q(t,e,n){let s=new Ms,r=n?new Ms:null,a=new Y,o={regions:r?[s,r]:[s],finallyBody:n};this.#K.push(o),s.open(this.#r.length),r?.open(this.#r.length),t(),s.close(this.#r.length),r?.close(this.#r.length),this.#K.pop(),n?.run(void 0,n.blockCompletes),this.#d(l.JUMP,a);let c=[];for(let[u,d]of e.entries()){let h=this.#r.length;this.#s=-1,this.#K.push({regions:r?[r]:[],finallyBody:n}),r?.open(this.#r.length),d.body(),r?.close(this.#r.length),this.#K.pop(),n?.run(void 0,n.handlerCompletes[u]??!0),this.#d(l.JUMP,a);for(let m of d.types){let p=m===null?-1:this.#T(m);for(let[k,T]of s.segments)c.push(k,T,h,p)}}if(r&&n){let u=this.#r.length;this.#s=-1;let d=this.#E();this.#t(l.STORE,d),n.run(n.anyAt(),!0),this.#t(l.LOAD,d,l.ATHROW,-1),this.#et();for(let[h,m]of r.segments)c.push(h,m,u,-1)}this.#F.push(...c),this.#J(a)}#e(t,e,n){if(e===t.length){n();return}let s=t[e];this.#p(s.start);let r=s.symbol?this.#l(s.symbol):this.#E();s.kind==="declaration"?(this.#u(s.init,!0),this.#f(s.symbol.type,s.init)):this.#u(s.expression,!0),this.#t(l.STORE,r);let a=this.#E();this.#t(l.ACONST_NULL,l.STORE,a);let o=()=>this.#nt(s,r);this.#Q(()=>this.#e(t,e+1,n),[{types:[null],body:()=>this.#t(l.DUP,l.STORE,a,l.ATHROW,-1)}],this.#tt(()=>{let c=new Y,u=new Y;this.#t(l.LOAD,r,l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,c),this.#t(l.LOAD,a,l.ACONST_NULL,l.ACMPEQ),this.#d(l.JUMP_IF_TRUE,u),this.#Q(o,[{types:[null],body:()=>{let d=this.#E();this.#t(l.STORE,d,l.LOAD,a,l.LOAD,d,l.THROWABLE,jt.ADD_SUPPRESSED),this.#et()}}],null),this.#d(l.JUMP,c),this.#m(u),o(),this.#m(c)})),s.kind==="declaration"&&!this.#c&&(this.#H=Math.max(this.#H,r+3)),this.#et(),s.symbol||this.#et()}#nt(t,e){this.#t(l.LOAD,e),t.closeMethod?this.#t(l.INVOKE_VIRTUAL,t.closeMethod.index,-1):this.#t(l.INVOKE_NATIVE,this.#A("close()",1,!1),-1)}#pt(t,e,n){let s=this.#K.slice(t);if(!s.length){n();return}let r=this.#K;for(let a=s.length-1;a>=0;a--){for(let o of s[a].regions)o.close(this.#r.length);this.#K=r.slice(0,t+a),s[a].finallyBody?.run(e,!0)}this.#K=r,n();for(let a of s)for(let o of a.regions)o.open(this.#r.length)}#At(t,e,n,s,r){let a=n?.constant;if(a&&a.kind==="boolean"&&!a.value)return;let o=new Y,c=new Y,u=new Y;this.#n.set(t,{breakLabel:u,continueLabel:c,tryDepth:this.#K.length}),this.#J(o),this.#p(e),n&&!a&&this.#lt(n,u,!1),this.#x(s),this.#J(c);for(let d of r)this.#p(d.start),this.#u(d,!1);this.#d(l.JUMP,o),this.#J(u)}#o(t){if(t.iterator){this.#$e(t);return}let{array:e,length:n,index:s}=t.hidden,r=e.type.element;this.#p(t.start),this.#u(t.iterable,!0),this.#t(l.STORE,this.#l(e),l.LOAD,this.#l(e)),this.#t(l.ARRAYLENGTH,this.#I("Cannot read the array length",this.#a(e))),this.#t(l.STORE,this.#l(n),l.ICONST,0,l.STORE,this.#l(s));let a=new Y,o=new Y,c=new Y;this.#n.set(t,{breakLabel:c,continueLabel:o,tryDepth:this.#K.length}),this.#J(a),this.#p(t.start),this.#t(l.LOAD,this.#l(s),l.LOAD,this.#l(n),l.ICMPLT),this.#d(l.JUMP_IF_FALSE,c),this.#t(l.LOAD,this.#l(e),l.LOAD,this.#l(s),l.ALOAD,Fe(r),-1),this.#Ot(r,t.symbol.type,{description:`${this.#a(e)}[${this.#a(s)}]`}),this.#t(l.STORE,this.#l(t.symbol)),this.#x(t.body),this.#J(o),this.#p(t.start),this.#t(l.IINC,this.#l(s),1),this.#d(l.JUMP,a),this.#J(c)}#$e(t){let e=t.iterator,n=t.iterable.type,s=n.tag==="library"||n.tag==="diamond"?n.symbol.qualifiedName:"java.lang.Iterable";this.#p(t.start),this.#u(t.iterable,!0),this.#t(l.INVOKE_NATIVE,this.#A("Iterable.iterator",1,!0),this.#I(`Cannot invoke "${s}.iterator()"`,t.iterable)),this.#t(l.STORE,this.#l(e));let r=new Y,a=new Y;this.#n.set(t,{breakLabel:a,continueLabel:r,tryDepth:this.#K.length}),this.#J(r),this.#p(t.start),this.#t(l.LOAD,this.#l(e),l.INVOKE_NATIVE,this.#A("Iterator.hasNext",1,!0),-1),this.#d(l.JUMP_IF_FALSE,a),this.#t(l.LOAD,this.#l(e),l.INVOKE_NATIVE,this.#A("Iterator.next",1,!0),-1);let o=t.element??xa(n),c=t.symbol.type,u=Ce(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.#T(Rt(u))),this.#Ot(o,t.symbol.type,{returnValue:"java.util.Iterator.next()"}),this.#t(l.STORE,this.#l(t.symbol)),this.#x(t.body),this.#d(l.JUMP,r),this.#J(a)}#Ht(t,e){if(t.patternSwitch)return this.#ve(t,e);this.#p(t.start);let n=t.selector.type?.tag==="string",s=t.selector.type,r=s?.tag==="class"&&s.symbol.isEnum?s.symbol:null;this.#u(t.selector,!0);let a;if(r)this.#t(l.GETFIELD,1,this.#I(`Cannot invoke "${r.binaryName}.ordinal()"`,t.selector)),a=this.#E(),this.#t(l.STORE,a);else if(t.libraryEnum)this.#t(l.INVOKE_NATIVE,this.#A("ordinal()",1,!0),this.#I(`Cannot invoke "${t.libraryEnum}.ordinal()"`,t.selector)),a=this.#E(),this.#t(l.STORE,a);else if(n){let h=t.hidden.copy;a=this.#l(h),this.#t(l.STORE,a,l.LOAD,a),this.#t(l.CHECKNULL,this.#I(\'Cannot invoke "String.hashCode()"\',this.#a(h)))}else a=this.#E(),this.#t(l.STORE,a);let o=new Y,c=e?t.type:void 0;this.#n.set(t,{breakLabel:o,resultType:c,tryDepth:this.#K.length});let u=t.cases.map(()=>new Y),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.#d(l.JUMP_IF_TRUE,u[m]);return}for(let p of h.labels)this.#t(l.LOAD,a),this.#Pt(p.constant),this.#t(n?l.STR_EQUALS:l.ICMPEQ,...n?[-1]:[]),this.#d(l.JUMP_IF_TRUE,u[m])}),e&&d===o&&u.length&&(d=u[0]),this.#d(l.JUMP,d),t.cases.forEach((h,m)=>{this.#J(u[m]),this.#oe(h,e,o,c)}),this.#m(o),this.#s=-1,n||this.#et()}#ve(t,e){this.#p(t.start);let n=t.selector.type,s=n?.tag==="class"&&n.symbol.isEnum?n.symbol:null;this.#u(t.selector,!0);let r=this.#E();this.#t(l.STORE,r);let a=new Y,o=e?t.type:void 0;this.#n.set(t,{breakLabel:a,resultType:o,tryDepth:this.#K.length});let c=t.cases.map(()=>new Y),u=t.cases.findIndex(h=>h.nullLabel);this.#t(l.LOAD,r),u>=0?(this.#t(l.ACONST_NULL,l.ACMPEQ),this.#d(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.#d(l.JUMP_IF_TRUE,c[m]);else{let p=n?yt(n):null;for(let k of h.enumFields??[])this.#t(l.LOAD,r,l.GETSTATIC,k.index,l.ACMPEQ),this.#d(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,ne[p.tag],-1),this.#Pt(k.constant),p&&this.#st(k.type,p),this.#t(p?l.ICMPEQ:l.STR_EQUALS,...p?[]:[-1]),this.#d(l.JUMP_IF_TRUE,c[m])}if(h.pattern){let p=new Y,k=this.#ae(h.pattern,r,p,!1);h.guard&&this.#lt(h.guard,p,!1),this.#d(l.JUMP,c[m]),this.#m(p);for(let T=0;T<k;T++)this.#et()}}),this.#d(l.JUMP,d??(t.exhaustive&&c.length?c[0]:a)),t.cases.forEach((h,m)=>{this.#J(c[m]),this.#oe(h,e,a,o)}),this.#m(a),this.#s=-1,this.#et()}#ae(t,e,n,s){if(t.kind==="TypePattern")return!(s&&t.unconditional)&&!Ce(t.tested)&&(this.#t(l.LOAD,e,l.INSTANCEOF,this.#T(Rt(W(t.tested)))),this.#d(l.JUMP_IF_FALSE,n)),t.symbol&&this.#t(l.LOAD,e,l.STORE,this.#l(t.symbol)),0;this.#t(l.LOAD,e,l.INSTANCEOF,this.#T(Rt(W(t.tested)))),this.#d(l.JUMP_IF_FALSE,n);let r=0;return t.components.forEach((a,o)=>{let c=t.accessors[o],u=this.#E();r++,this.#t(l.LOAD,e,c.selector!==void 0?l.INVOKE_VIRTUAL:l.INVOKE,c.index,-1,l.STORE,u),r+=this.#ae(a,u,n,!0)}),r}#oe(t,e,n,s){if(!t.arrow){for(let a of t.statements)this.#x(a);return}let r=t.body;if(r.kind==="Block"){this.#x(r),e||this.#d(l.JUMP,n);return}this.#p(r.start),e?(this.#u(r,!0),this.#f(s,r)):this.#u(r,!1),this.#d(l.JUMP,n)}#lt(t,e,n){let s=t.constant;if(s&&s.kind==="boolean"){s.value===n&&this.#d(l.JUMP,e);return}if(t.kind==="Parenthesized")return this.#lt(t.expression,e,n);if(t.kind==="Unary"&&t.operator==="!")return this.#lt(t.operand,e,!n);if(t.kind==="Binary"&&(t.operator==="&&"||t.operator==="||")){if(t.operator==="&&"!==n)this.#lt(t.left,e,n),this.#lt(t.right,e,n);else{let a=new Y;this.#lt(t.left,a,!n),this.#lt(t.right,e,n),this.#m(a)}return}if(t.kind==="InstanceOf"){this.#we(t,e,n);return}this.#G(t,ft),this.#d(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e)}#we(t,e,n){if(t.recordPattern){let c=this.#E();this.#u(t.expression,!0),this.#t(l.STORE,c);let u=new Y,d=this.#ae(t.recordPattern,c,n?u:e,!1);n&&this.#d(l.JUMP,e),this.#m(u);for(let h=0;h<=d;h++)this.#et();return}let s=this.#T(Rt(this.#zt(t))),r=t.binding?.symbol;if(!r){this.#u(t.expression,!0),this.#t(l.INSTANCEOF,s),this.#d(n?l.JUMP_IF_TRUE:l.JUMP_IF_FALSE,e);return}let a=this.#E();this.#u(t.expression,!0),this.#t(l.STORE,a,l.LOAD,a,l.INSTANCEOF,s);let o=new Y;this.#d(l.JUMP_IF_FALSE,n?o:e),this.#t(l.LOAD,a,l.STORE,this.#l(r)),n&&this.#d(l.JUMP,e),this.#m(o),this.#et()}#zt(t){return t.binding?.symbol?.type??t.testedType}#st(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"&&Er(t)&&this.#t(l.I2F))}#It(t,e){if(!Zn(t)||!Zn(e))return;let n=Er(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.#st(t,e);return;case"double":n==="long"&&this.#t(l.L2D);return}}#f(t,e){this.#Ot(e.type,t,e,e.constant!==void 0)}#Ot(t,e,n,s=!1){let r=yt(t);if(Ce(e)){if(r&&(this.#t(l.UNBOX,ne[r.tag],this.#Lt(r,n)),t=r),s){this.#st(t,e);return}e.tag==="char"&&t.tag!=="char"?this.#t(l.I2C):this.#st(t,e);return}if(Ce(t)){let a=yt(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,ne[a])}}#Lt(t,e){let n=`Cannot invoke "${al[t.tag]}"`;return"returnValue"in e?this.#Vt(`${n} because the return value of "${e.returnValue}" is null`):"description"in e?this.#I(n,e.description):this.#I(n,e)}#at(t,e,n){if(!n){t.forEach((r,a)=>{this.#u(r,!0),this.#f(e[a],r)});return}this.#at(t.slice(0,n.from),e);let s=t.slice(n.from);this.#t(l.ICONST,s.length),this.#Nt(n.element),s.forEach((r,a)=>{this.#t(l.DUP,l.ICONST,a),this.#u(r,!0),this.#f(n.element,r),this.#t(l.ASTORE,Fe(n.element),-1)})}#G(t,e){if(this.#u(t,!0),t.constant){this.#st(t.type,e);return}let n=yt(t.type);if(n){this.#t(l.UNBOX,ne[n.tag],this.#Lt(n,t)),this.#st(n,e);return}this.#st(t.type,e)}#Jt(t,e){let n=ol[t];return e.tag==="double"?n.double:e.tag==="float"?n.float:e.tag==="long"?n.long:n.int}#u(t,e){if(e&&t.genericCast){let n=t.genericCast;t.genericCast=void 0,this.#u(t,!0),t.genericCast=n,this.#t(l.CHECKCAST,this.#T(Rt(n)));return}if(t.constant){e&&this.#Pt(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.#u(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.#St(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.#l(t.symbol));return}case"This":e&&this.#St(t.outerHops);return;case"Super":e&&this.#t(l.LOAD,0);return;case"ClassLiteral":e&&this.#t(l.SCONST,this.#T(t.className),l.ICONST,t.isInterface?1:0,l.INVOKE_NATIVE,this.#A("Class.literal",2,!0),-1);return;case"InstanceOf":{let n=new Y,s=new Y;this.#we(t,n,!0),this.#t(l.ICONST,0),this.#d(l.JUMP,s),this.#m(n),this.#t(l.ICONST,1),this.#m(s),e||this.#t(l.POP);return}case"Parenthesized":this.#u(t.expression,e);return;case"Unary":{let n=t.type;this.#G(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&&Ce(t.type)){this.#u(t.expression,!0),this.#t(l.CHECKCAST,this.#T(Rt(t.checked)));let r=yt(t.checked);this.#t(l.UNBOX,ne[r.tag],this.#Lt(r,t.expression)),this.#It(r,t.type),e||this.#t(l.POP);return}let s=Ce(t.type)?yt(n):null;s?this.#G(t.expression,s):this.#u(t.expression,!0),Ce(n)&&!Ce(t.type)?this.#Ot(n,t.type,t.expression,t.expression.constant!==void 0):this.#It(s??n,t.type),t.checked&&this.#t(l.CHECKCAST,this.#T(Rt(t.checked))),e||this.#t(l.POP);return}case"IncDec":this.#jt(t,e);return;case"Binary":this.#Me(t),e||this.#t(l.POP);return;case"Assignment":this.#Zt(t,e);return;case"ArrayAccess":this.#u(t.array,!0),this.#G(t.index,U),this.#Yt(t.type,t.array),e||this.#t(l.POP);return;case"NewArray":this.#Dt(t),e||this.#t(l.POP);return;case"FieldAccess":if(t.fieldSymbol){let n=t.fieldSymbol;n.isStatic?(kr(t.target)||this.#u(t.target,!1),e&&this.#t(l.GETSTATIC,n.index)):(this.#u(t.target,!0),this.#t(l.GETFIELD,n.index,this.#X(`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.#A("System.in",0,!0),-1);return}if(t.field==="System.out"||t.field==="System.err"){e&&this.#t(l.INVOKE_NATIVE,this.#A(t.field,0,!0),-1);return}if(t.libraryField?.includes("#")){this.#u(t.target,!0),this.#t(l.INVOKE_NATIVE,this.#A(t.libraryField,1,!0),this.#X(`Cannot read field "${t.name}"`,t.target)),e||this.#t(l.POP);return}if(t.libraryField){e&&this.#t(l.INVOKE_NATIVE,this.#A(t.libraryField,0,!0),-1);return}if(t.field!=="length")throw new Error("codegen: field access used as a value");this.#u(t.target,!0),this.#t(l.ARRAYLENGTH,this.#I("Cannot read the array length",t.target)),e||this.#t(l.POP);return;case"MethodCall":this.#ce(t,e);return;case"NewObject":{if(t.libraryCall){this.#Et(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=cl(this.#z,n.owner);r>=0?(this.#St(r),this.#t(l.GETFIELD,s.field.index,-1)):this.#t(l.LOAD,this.#l(s.local)),this.#t(l.PUTFIELD,s.field.index,-1)}t.outerExpression?(this.#u(t.outerExpression,!0),this.#t(l.DUP,l.CHECKNULL,-1)):t.outer!==void 0&&this.#St(t.outer),this.#at(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.#u(a,e),e&&this.#f(t.type,a);return}let s=new Y,r=new Y;this.#lt(t.condition,s,!1),this.#u(t.whenTrue,!0),this.#f(t.type,t.whenTrue),this.#d(l.JUMP,r),this.#m(s),this.#u(t.whenFalse,!0),this.#f(t.type,t.whenFalse),this.#m(r),e||this.#t(l.POP);return}case"SwitchExpression":this.#Ht(t,!0),e||this.#t(l.POP);return;case"Lambda":this.#le(t,null,e);return;case"MethodRef":this.#le(t.lambda,t.receiver??null,e);return}}#le(t,e,n){let s=t.method,r=0;s.usesThis&&(this.#t(l.LOAD,0),r++),e&&(this.#u(e,!0),this.#t(l.DUP,l.CHECKNULL,-1),r++);for(let o of t.captures??[])this.#t(l.LOAD,this.#l(o)),r++;let a=t.functional;this.#t(l.LAMBDA,s.index,r,this.#T(a.iface),a.sam?.selector??-1,a.samKey?this.#T(a.samKey):-1),n||this.#t(l.POP)}#Me(t){let e=t.operator;if(e==="&&"||e==="||"){let a=new Y,o=new Y;this.#lt(t,a,!1),this.#t(l.ICONST,1),this.#d(l.JUMP,o),this.#m(a),this.#t(l.ICONST,0),this.#m(o);return}let n=t.left.type,s=t.right.type;if(t.type?.tag==="string"){this.#te(t.left),this.#te(t.right),this.#t(l.SCONCAT);return}if(e in $s){let a=yt(n)??n,o=yt(s)??s,c=Ce(n)||Ce(s)||e!=="=="&&e!=="!=";if(c&&a.tag==="boolean"&&o.tag==="boolean"){this.#G(t.left,ft),this.#G(t.right,ft),this.#t($s[e]);return}if(c&&Zn(a)&&Zn(o)){let d=Cr(a,o);this.#G(t.left,d),this.#G(t.right,d),this.#t($s[e]);return}this.#u(t.left,!0),this.#u(t.right,!0);let u=ts(n)||ts(s);this.#t(e==="=="?u?l.ACMPEQ:l.ICMPEQ:e==="!="?u?l.ACMPNE:l.ICMPNE:$s[e]);return}let r=t.type;if(e==="<<"||e===">>"||e===">>>"){this.#G(t.left,r),this.#u(t.right,!0),s.tag==="long"&&this.#t(l.L2I),this.#t(this.#Jt(e,r));return}this.#G(t.left,r),this.#G(t.right,r),this.#t(this.#Jt(e,r.tag==="boolean"?U:r))}#St(t=0){this.#t(l.LOAD,0);let e=this.#z;for(let n=0;n<t&&e;n++,e=e.outer)this.#t(l.GETFIELD,e.outerField,-1)}#ct(t){let e=r=>{let a=0;for(let o=r.outer;o;o=o.outer)a++;return a},n="this",s=this.#z;for(let r=0;r<t&&s?.outer;r++,s=s.outer)n+=`.this$${e(s)-1}`;return n}#Nt(t){Fe(t)===q.REF&&t.tag!=="string"?this.#t(l.NEWARRAY_REF,this.#T("["+Rt(t))):this.#t(l.NEWARRAY,Fe(t))}#Dt(t){if(t.initializer){this.#Qt(t.initializer);return}let e=t.type;for(let n of t.dimensions)this.#G(n,U);t.dimensions.length===1?this.#Nt(e.element):this.#t(l.NEWMULTI,this.#T(Rt(e)),t.dimensions.length)}#Yt(t,e){let n=Fe(t);this.#t(l.ALOAD,n,this.#I(`Cannot load from ${Sa[n]} array`,e))}#Gt(t,e){let n=Fe(t);this.#t(l.ASTORE,n,this.#I(`Cannot store to ${Sa[n]} array`,e))}#Qt(t){let e=t.elementType,n=Fe(e);this.#t(l.ICONST,t.elements.length),this.#Nt(e),t.elements.forEach((s,r)=>{this.#t(l.DUP,l.ICONST,r),s.kind==="ArrayInitializer"?this.#Qt(s):(this.#u(s,!0),this.#f(e,s)),this.#t(l.ASTORE,n,-1)})}#ce(t,e){if(t.print){let s=kt.NONE;if(t.print.argument!=="none"){let r=t.args[0];this.#u(r,!0),t.print.argument==="object"?(this.#t(l.VALUEOF,l.TOSTRING_REF),s=kt.STRING):s={int:kt.INT,char:kt.CHAR,boolean:kt.BOOLEAN,long:kt.LONG,float:kt.FLOAT,double:kt.DOUBLE,string:kt.STRING,"char-array":kt.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.#Et(t.libraryCall,s,t.args,e);return}if(t.mathFunction){this.#at(t.args,t.mathFunction.params),this.#t(l.MATH,ll[t.mathFunction.fn]),e||this.#t(l.POP);return}let n=t.target?Pe(t.target):null;if(t.method){let s=t.method,r=-1;s.isStatic?n&&!kr(n)&&this.#u(n,!1):n?(this.#u(n,!0),r=this.#X(`Cannot invoke "${this.#it(t,s)}"`,n)):this.#St(t.outerHops),this.#at(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.#u(n,!0),s=this.#X(`Cannot invoke "${t.qualifier??"Object"}.${Ta[t.objectMethod]}"`,n)):this.#St(),this.#at(t.args,t.args.map(()=>H)),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.#u(t.target,!0);for(let s of t.args)this.#u(s,!0);switch(t.stringMethod){case"length":this.#t(l.STR_LENGTH,this.#I(\'Cannot invoke "String.length()"\',t.target));break;case"charAt":this.#t(l.STR_CHARAT,this.#I(\'Cannot invoke "String.charAt(int)"\',t.target));break;case"equals":this.#t(l.STR_EQUALS,this.#I(\'Cannot invoke "String.equals(Object)"\',t.target));break;case"isEmpty":this.#t(l.STR_LENGTH,this.#I(\'Cannot invoke "String.isEmpty()"\',t.target),l.ICONST,0,l.ICMPEQ);break;case"toCharArray":this.#t(l.STR_TOCHARS,this.#I(\'Cannot invoke "String.toCharArray()"\',t.target));break;case"compareTo":this.#t(l.STR_COMPARETO,this.#I(\'Cannot invoke "String.compareTo(String)"\',t.target),this.#Vt(\'Cannot read field "value" because "anotherString" is null\'));break}e||this.#t(l.POP);return}throw new Error(`codegen: unresolved call to ${t.name}`)}#Tt(t,e,n){let s=yt(t);s&&this.#t(l.UNBOX,ne[s.tag],this.#Lt(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,ne[s.tag])}#jt(t,e){let n=Pe(t.operand),s=t.operator==="++"?1:-1,r=t.type;if(n.kind==="Name"&&n.symbol?.kind==="local"){let o=this.#l(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.#Tt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.STORE,o);return}let a=this.#ue(n);if(a){if(a.isStatic)this.#Re(n),this.#t(l.GETSTATIC,a.index),e&&!t.prefix&&this.#t(l.DUP),this.#Tt(r,s,n),e&&t.prefix&&this.#t(l.DUP),this.#t(l.PUTSTATIC,a.index);else{let o=this.#Pe(n,a,"read");this.#t(l.DUP,l.GETFIELD,a.index,o),e&&!t.prefix&&this.#t(l.DUP_X1),this.#Tt(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.#u(n.array,!0),this.#u(n.index,!0),this.#t(l.DUP2),this.#Yt(r,n.array),e&&!t.prefix&&this.#t(l.DUP_X2),this.#Tt(r,s,n),e&&t.prefix&&this.#t(l.DUP_X2),this.#Gt(r,n.array)}#Zt(t,e){let n=Pe(t.target),s=t.target.type,r=()=>{if(t.operator==="="){this.#u(t.value,!0),this.#f(s,t.value);return}if(s.tag==="string"){this.#t(l.TOSTRING_REF),this.#te(t.value),this.#t(l.SCONCAT);return}let o=t.operator.slice(0,-1),c=t.value.type;if(o==="<<"||o===">>"||o===">>>"){let h=Er(s)?U:s;this.#u(t.value,!0),c.tag==="long"&&this.#t(l.L2I),this.#t(this.#Jt(o,h)),this.#It(h,s);return}if(s.tag==="boolean"){this.#G(t.value,ft),this.#t(this.#Jt(o,U));return}let u=yt(s);if(u){this.#t(l.UNBOX,ne[u.tag],this.#Lt(u,n));let h=Cr(u,yt(c)??c);this.#st(u,h),this.#G(t.value,h),this.#t(this.#Jt(o,h)),this.#It(h,u),this.#t(l.BOX,ne[u.tag]);return}let d=Cr(s,yt(c)??c);this.#st(s,d),this.#G(t.value,d),this.#t(this.#Jt(o,d)),this.#It(d,s)};if(n.kind==="Name"&&n.symbol?.kind==="local"){t.operator!=="="&&this.#t(l.LOAD,this.#l(n.symbol)),r(),e&&this.#t(l.DUP),this.#t(l.STORE,this.#l(n.symbol));return}let a=this.#ue(n);if(a){if(a.isStatic)this.#Re(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.#Pe(n,a,"assign");r(),e&&this.#t(l.DUP_X1),this.#t(l.PUTFIELD,a.index,o)}else{let o=this.#Pe(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.#u(n.array,!0),this.#u(n.index,!0),t.operator!=="="&&(this.#t(l.DUP2),this.#Yt(s,n.array)),r(),e&&this.#t(l.DUP_X2),this.#Gt(s,n.array)}#ue(t){if(t.kind==="Name"&&t.symbol?.kind==="field")return t.symbol;if(t.kind==="FieldAccess")return t.fieldSymbol}#Pe(t,e,n){if(t.kind==="FieldAccess"){this.#u(t.target,!0);let s=n==="read"?"Cannot read field":"Cannot assign field";return this.#X(`${s} "${e.name}"`,t.target)}return this.#St(t.kind==="Name"?t.outerHops:0),-1}#Re(t){t.kind==="FieldAccess"&&!kr(t.target)&&this.#u(t.target,!1)}#te(t){if(t.constant){this.#t(l.SCONST,this.#T(jn(t.constant)));return}switch(this.#u(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}`)}}},Ta={toString:"toString()",hashCode:"hashCode()",equals:"equals(Object)"};function cl(i,t){let e=0;for(let n=i;n;n=n.outer,e++)if(n===t)return e;return-1}function ts(i){return i!==void 0&&["string","null","array","class","object","library","diamond","typevar"].includes(i.tag)}function xa(i){if(i.tag==="class"){let n=yn(i.symbol).find(s=>s.symbol.name==="Iterable"||s.symbol.supertypes.some(r=>r.tag==="library"&&r.symbol.name==="Iterable"));return n?xa(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?va(s,n):null}return t&&t.tag==="library"?t.args[0]??{tag:"object"}:{tag:"object"}}function va(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=>va(e,t))}:i}var st=class{value;constructor(t){this.value=t}},Ut=class{kind;data;hash;descriptor;constructor(t,e,n,s=ul[t]){this.kind=t,this.data=e,this.hash=n,this.descriptor=s}},Ft=class{className;classIndex;fields;hash;base=null;constructor(t,e,n,s){this.className=t,this.classIndex=e,this.fields=n,this.hash=s}},Kt=class{kind;value;constructor(t,e){this.kind=t,this.value=e}},pe=class{hash;constructor(t){this.hash=t}},ye=class extends pe{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}},_e=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}},ul=["[I","[Z","[C","[Ljava.lang.String;","[J","[D","[B","[S","[F"];function Ue(i){return i instanceof Ut?Lr(i):`${i.className}@${i.hash.toString(16)}`}function Lr(i){return`${i.descriptor}@${i.hash.toString(16)}`}var Ps=class{#O=new Map;intern(t){let e=this.#O.get(t);return e||(e=new st(t),this.#O.set(t,e)),e}},Rs=class{#O=625341585;next(){let t=this.#O;return t^=t<<13,t^=t>>>17,t^=t<<5,this.#O=t>>>0,this.#O&2147483647||1}};var wa=i=>`${i.className}.${i.method}(${i.file}:${i.line})`;var js=class{className;message;cause;constructor(t,e,n){this.className=t,this.message=e,this.cause=n}},es=class{message;constructor(t){this.message=t}},ns=class{result;constructor(t){this.result=t}},Cn=class{thrown;constructor(t){this.thrown=t}},Fs=class{frames;constructor(t){this.frames=t}},_s=class{message;constructor(t){this.message=t}};function dl(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 Js(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 ml=Object.getPrototypeOf(Object.getPrototypeOf((function*(){})())),Nr=i=>typeof i=="object"&&i!==null&&Object.getPrototypeOf(Object.getPrototypeOf(i))===ml;function $r(i){switch(i.kind){case"double":return le(i.value);case"float":return Re(i.value);case"char":return String.fromCharCode(i.value);case"boolean":return i.value?"true":"false";default:return String(i.value)}}var Ca={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},fl=0,pl=1,en=2,Ea=3,Rr="\\0launcher",yl=Array.from({length:5},(i,t)=>`${Rr}${t}`),Aa=65536;function Mr(i,t){switch(i){case q.INT:return new Int32Array(t);case q.BOOLEAN:return new Uint8Array(t);case q.CHAR:return new Uint16Array(t);case q.LONG:return new Array(t).fill(0);case q.DOUBLE:return new Float64Array(t);case q.BYTE:return new Int8Array(t);case q.SHORT:return new Int16Array(t);case q.FLOAT:return new Float32Array(t);default:return new Array(t).fill(null)}}var Ds=(i,t)=>`Index ${i} out of bounds for length ${t}`;function gl(i){switch(i){case"I":return q.INT;case"Z":return q.BOOLEAN;case"C":return q.CHAR;case"J":return q.LONG;case"D":return q.DOUBLE;case"B":return q.BYTE;case"S":return q.SHORT;case"F":return q.FLOAT;default:return q.REF}}function bl(i){let t="";for(let e=0;e<i.length;e+=8192)t+=String.fromCharCode(...i.subarray(e,e+8192));return t}var Ia=["java.lang.String","java.lang.Object","java.lang.Comparable","java.lang.CharSequence"],Jr={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"},Sl=Object.fromEntries(Object.keys(Jr).map(i=>[i,[Jr[i],"java.lang.Object","java.lang.Comparable",...i==="char"||i==="boolean"?[]:["java.lang.Number"]]])),Tl=["java.lang.Object","java.lang.Cloneable","java.io.Serializable"],xl="com.sun.tools.javac.launcher.MemoryClassLoader @6d06d69c";function vl(i){let t=0;for(let e=0;e<i.length;e++)t=Math.imul(t,31)+i.charCodeAt(e)|0;return t}var Pr=new DataView(new ArrayBuffer(8));function wl(i){switch(i.kind){case"int":case"char":case"byte":case"short":return i.value;case"float":return fs(i.value);case"long":{let t=BigInt.asUintN(64,BigInt(i.value));return Number(BigInt.asIntN(32,t^t>>32n))}case"double":return Pr.setFloat64(0,Number.isNaN(i.value)?NaN:i.value),Pr.getInt32(0)^Pr.getInt32(4)|0;case"boolean":return i.value?1231:1237}}function Oa(i,t,e,n,s,r=""){let a=new Ps,o=new Rs,c=i.strings.map(f=>a.intern(f)),u=i.numbers,d=fn(),h=i.natives.map(f=>{let b=d?.natives[f.name];if(!b)throw new Error(`interpreter: the library native ${f.name} is not loaded`);return b}),m=i.messages,p=i.methods,k=globalThis.performance,T=e.maxDurationMs>0?k.now()+e.maxDurationMs:1/0,C=(f,b=-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:b}),S=i.staticFieldIsReference.map(f=>f?null:0),w=i.staticFieldOwner,I=i.classes,R=I.map(f=>f.instanceFieldIsReference.map(b=>b?null:0)),N=new Uint8Array(I.length),A=new Int32Array(I.length).fill(-1),L=(i.loadWarnings??[]).map((f,b)=>{for(let O of f.classes)A[O]=b;return!0}),J=new Map(I.map(f=>[f.name,f.types])),D=f=>f instanceof Ft?I[f.classIndex].types:f instanceof st?Ia:f instanceof Kt?Sl[f.kind]:f instanceof Ut?Tl:f instanceof ye?J.get(f.iface)??d?.typesOf(f.iface)??[f.iface,"java.lang.Object"]:f instanceof pe?d?.typesOf(f.className)??["java.lang.Object"]:["java.lang.Object"],P=(f,b)=>{if(f===b)return!0;let O=f.slice(1),$=b.slice(1);if($==="Ljava.lang.Object;")return O.startsWith("[")||O.startsWith("L");if(O.startsWith("[")&&$.startsWith("["))return P(O,$);if(O.startsWith("L")&&$.startsWith("L")){let _=O.slice(1,-1);return(J.get(_)??(_==="java.lang.String"?Ia:[_,"java.lang.Object"])).includes($.slice(1,-1))}return!1},j=(f,b)=>f instanceof st?b==="[Ljava.lang.String;"||Z(f,b.slice(1)):f instanceof Ft&&b.length===f.className.length+3&&b.slice(2,-1)===f.className?!0:Z(f,b.slice(1)),G=new Map,Z=(f,b)=>{if(f===null||typeof f!="object")return!1;if(b.charCodeAt(0)===91)return f instanceof Ut&&P(f.descriptor,b);let O=G.get(b);return O===void 0&&G.set(b,O=b.slice(1,-1)),D(f).includes(O)},qt=f=>f instanceof Ft?f.className:f instanceof st?"java.lang.String":f instanceof Kt?Jr[f.kind]:f instanceof Ut?f.descriptor:f.className,be=f=>{let b=f.replace(/^\\[+/,"").replace(/^L(.*);$/,"$1");return J.has(b)&&!b.includes(".")?`unnamed module of loader ${xl}`:"module java.base of loader \'bootstrap\'"},An=(f,b)=>{let O=qt(f),$=be(O),_=be(b),B=$===_?`${O} and ${b} are in ${$}`:`${O} is in ${$}; ${b} is in ${_}`;return`class ${O} cannot be cast to class ${b} (${B})`},ot=C(p[i.entry]),pt=[ot],F=ot.code,Ct=ot.locals,g=ot.stack,y=0,x=0,Nt=0,jr=Math.min(Aa,e.maxInstructions+1),Vs=0,Se=0,Ee=(f,b)=>({outcome:{kind:"resource-limit",limit:f,message:b},instructions:Math.min(Nt,e.maxInstructions)}),Fr=f=>{ot.pc=x;let b=[],O=f!==void 0;for(let $=pt.length-1;$>=0&&b.length<1024;$--){let _=pt[$];_.method.hidden||O&&f(_)||(O=!1,b.push({className:_.method.className,method:_.method.name,file:_.method.file,line:ya(_.method,_.pc)}))}return b},_r=new Map(I.map((f,b)=>[f.name,b])),as=(f,b,O=null,$)=>{let _=_r.get(f)??_r.get("java.lang.RuntimeException"),B=R[_].slice();return B[mt.message]=b===null?null:new st(b),B[mt.trace]=new Fs($??Fr()),O&&(B[mt.cause]=O,B[mt.causeSet]=1),new Ft(f,_,B,o.next())},ct=(f,b,O=null)=>{throw new Cn(as(f,b,O))},Ur=[],Xa=f=>{let b=Ur[f],O=b.fields[mt.message],$=O===null?b.className:`${b.className}: ${O.value}`,_=b.fields[mt.trace]?.frames??[],B=as("java.lang.ExceptionInInitializerError",`Exception ${$} [in thread "main"]`,null,_);return ct("java.lang.NoClassDefFoundError",`Could not initialize class ${I[f].name}`,B)},In=null,Hs="",Br=()=>({outcome:{kind:"exception",className:In.className,text:Hs},instructions:Nt,...Gs?{inputExhausted:Gs}:{}}),Ya=f=>{let b=f;for(ot.pc=x;pt.length;){let $=pt[pt.length-1],_=$.method.handlers;if(_)for(let B=0;B<_.length;B+=4){if($.pc<_[B]||$.pc>=_[B+1])continue;let at=_[B+3];if(!(at>=0&&!Z(b,i.strings[at])))return ot=$,F=$.code,Ct=$.locals,g=$.stack,y=0,g[y++]=b,x=_[B+2],null}pt.pop(),$.initClass>=0&&(N[$.initClass]=Ea,Ur[$.initClass]=b,!Z(b,"Ljava.lang.Error;")&&pt.length&&(ot=pt[pt.length-1],x=ot.pc,b=as("java.lang.ExceptionInInitializerError",null,b)))}if(In)return Hs+=`\nException: ${b.className} thrown from the UncaughtExceptionHandler in thread "main"\n`,Br();In=b;let O=C(p[i.uncaught]);return O.locals[0]=b,pt.push(O),ot=O,F=O.code,Ct=O.locals,g=O.stack,y=0,x=0,null},Vr=new Map,Hr=new Map,zs=(f,b)=>{if(!(f==="boolean"||f==="byte"||(f==="int"||f==="long"||f==="short")&&b>=-128&&b<=127||f==="char"&&b<=127))return new Kt(f,b);let $=f+b,_=Hr.get($);return _||Hr.set($,_=new Kt(f,b)),_},Gs=!1,Ks={stdout:!1,stderr:!1},Be={hash:()=>o.next(),intern:f=>a.intern(f),fail:(f,b,O)=>{throw new js(f,b,O)},raise:f=>{throw new Cn(f)},limitation:f=>{throw new _s(f)},charge:f=>{Nt+=f},allocate:f=>{if(Se+f>e.maxArrayElements)throw new es(`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);Se+=f},print:(f,b)=>{let O=Qr(f==="out"?"stdout":"stderr",b);if(O)throw new ns(O)},closeStream:f=>{Ks[f==="out"?"stdout":"stderr"]=!0},streamClosed:f=>Ks[f==="out"?"stdout":"stderr"],exit:f=>{throw new ns({outcome:{kind:"exit",status:f},instructions:Nt})},seed:()=>BigInt(Math.floor(Math.random()*2**32))*2n**16n+BigInt(Math.floor(Math.random()*2**16)),stdin:()=>r,inputExhausted:()=>{Gs=!0},checkString:f=>{if(f>e.maxStringLength)throw new es(`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`)},methodOf:(f,b,O)=>I[f.classIndex].virtuals[`${b}/${O}`]??-1,overrideOf:(f,b)=>I[f.classIndex].libraryOverrides?.[b]??-1,castMessage:An,storable:(f,b)=>j(f,b),className:f=>qt(f),toStringMethod:f=>I[f.classIndex].toString,equalsMethod:f=>I[f.classIndex].equals,hashCodeMethod:f=>I[f.classIndex].hashCode,box:zs,staticMethod:(f,b,O)=>p.findIndex($=>$.isStatic&&$.className===f&&$.name===b&&$.argCount===O)},os=f=>f instanceof js?ct(f.className,f.message,f.cause?as(f.cause.className,f.cause.message,null):null):f instanceof _s?{outcome:{kind:"engine-limitation",message:f.message},instructions:Nt}:f instanceof es?Ee("memory",f.message):f instanceof ns?f.result:null,qs=(f,b)=>{let O=p[f];if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);let $=Xr(O,-1),_=O.argSlots;for(let B=0;B<b.length;B++)$.locals[_?_[B]:B]=b[B];return pt.push($),ot=$,F=$.code,Ct=$.locals,g=$.stack,y=0,x=0,O.isStatic&&N[O.classIndex]!==en&&an(O.classIndex),null},Ws=[],zr=f=>{let b=ot,O;try{let _=b.then;if(_){if(O=_(f),O instanceof _e)return O.resumes?(b.then=null,b.native=O.resumes,b.convert=O.convert):b.then=O.then,qs(O.invoke,O.args);Nr(O)&&(b.then=null,b.native=O,f=void 0)}if(!b.then){let B=b.native.next(f);if(!B.done)return qs(B.value.invoke,B.value.args);let at=b.convert;O=at?at(B.value):B.value}}catch(_){let B=os(_);if(B)return B;throw _}pt.pop();let $=b.nativeReturns;return b.native=null,b.then=null,b.convert=null,Ws.length<32&&Ws.push(b),ot=pt[pt.length-1],F=ot.code,Ct=ot.locals,g=ot.stack,y=ot.sp,x=ot.returnPc,$&&(g[y++]=O??null),null},Gr=(f,b)=>{if(ot.pc=x,ot.returnPc=b,ot.sp=y,pt.length>e.maxCallDepth)return null;let O=Ws.pop()??C(Ca);return O.nativeReturns=f,pt.push(O),ot=O,O},rn=(f,b,O)=>{let $=Gr(b,O);return $?($.native=f,zr(void 0)):ct("java.lang.StackOverflowError",null)},Kr=(f,b,O)=>{let $=Gr(b,O);return $?(f.resumes?($.native=f.resumes,$.convert=f.convert):$.then=f.then,qs(f.invoke,f.args)):ct("java.lang.StackOverflowError",null)};function*qr(f){let b=yield*d.toString(Be,f);return new st(b)}let Wr=(f,b,O)=>{y-=b.length;let $;try{$=d.natives[f](Be,b)}catch(_){let B=os(_);if(B)return B;throw _}return $ instanceof _e?Kr($,!0,O):Nr($)?rn($,!0,O):(g[y++]=$??null,x=O,null)};for(let f of p)f.freeFrames=[];let Xr=(f,b)=>{let O=f.freeFrames.pop();if(!O)return C(f,b);let $=O.locals;for(let _=0;_<$.length;_++)$[_]=0;return O.sp=0,O.pc=0,O.returnPc=0,O.initClass=b,O},Qa=f=>{let b=f.method.freeFrames;b&&b.length<32&&b.push(f)},Ve=(f,b,O=-1)=>{ot.pc=x,ot.returnPc=b,y-=f.argCount,ot.sp=y;let $=Xr(f,O),_=f.argSlots;if(_)for(let B=0;B<f.argCount;B++)$.locals[_[B]]=g[y+B];else for(let B=0;B<f.argCount;B++)$.locals[B]=g[y+B];pt.push($),ot=$,F=$.code,Ct=$.locals,g=$.stack,y=0,x=0},an=f=>{if(N[f]!==fl)return N[f]===Ea&&Xa(f),!1;let b=A[f];b>=0&&L[b]&&(L[b]=!1,t("stderr",i.loadWarnings[b].text));let O=I[f].superclass;if(O>=0&&an(O))return!0;let $=I[f].clinit;return $<0?(N[f]=en,!1):(N[f]=pl,Ve(p[$],x,f),!0)},Et=f=>ct("java.lang.NullPointerException",f>=0?m[f]:null),Yr=(f,b,O)=>{let $=b[O],_=f.slice(1);if(O===b.length-1){let at=gl(_);return new Ut(at,Mr(at,$),o.next(),f)}let B=new Array($);for(let at=0;at<$;at++)B[at]=Yr(_,b,O+1);return new Ut(q.REF,B,o.next(),f)},Qr=(f,b)=>{if(Ks[f])return null;if(In&&f==="stderr")return Hs+=b,null;if(Vs+b.length>e.maxOutputChars){let O=e.maxOutputChars-Vs;return O>0&&t(f,b.slice(0,O)),Ee("output",`the program printed more than ${e.maxOutputChars.toLocaleString("en-US")} characters`)}return Vs+=b.length,Nt+=b.length>>>6,b&&t(f,b),null},Zr=[];if(s){let f={string:b=>new st(b),box:zs,array:(b,O,$)=>new Ut(b,O,o.next(),$),object:b=>{let O=i.classes[b];return new Ft(O.name,b,O.instanceFieldIsReference.map($=>$?null:0),o.next())},list:b=>{if(!d)throw new Error("interpreter: practice lists need the Java library");return d.newList(Be,b)},allocate:b=>Be.allocate(b)};try{Zr=s.args(f)}catch(b){let O=os(b);if(O)return O;throw b}}for(;;)try{for(;;){if(++Nt>=jr){if(Nt>e.maxInstructions)return Ee("instructions",`the program ran more than ${e.maxInstructions.toLocaleString("en-US")} steps`);if(T!==1/0&&k.now()>T)return Ee("time",`the program ran longer than ${e.maxDurationMs} ms`);jr=Math.min(Nt+Aa,e.maxInstructions+1),n?.()}switch(F[x]){case 1:g[y++]=F[x+1],x+=2;break;case 2:g[y++]=c[F[x+1]],x+=2;break;case 3:g[y++]=null,x+=1;break;case 4:g[y++]=Ct[F[x+1]],x+=2;break;case 5:Ct[F[x+1]]=g[--y],x+=2;break;case 6:y--,x+=1;break;case 7:g[y]=g[y-1],y++,x+=1;break;case 8:{let f=g[y-1];g[y-1]=g[y-2],g[y-2]=f,g[y++]=f,x+=1;break}case 9:{let f=g[y-1];g[y-1]=g[y-2],g[y-2]=g[y-3],g[y-3]=f,g[y++]=f,x+=1;break}case 24:g[y]=g[y-2],g[y+1]=g[y-1],y+=2,x+=1;break;case 10:{let f=g[--y];g[y-1]=g[y-1]+f|0,x+=1;break}case 11:{let f=g[--y];g[y-1]=g[y-1]-f|0,x+=1;break}case 12:{let f=g[--y];g[y-1]=Math.imul(g[y-1],f),x+=1;break}case 13:{let f=g[--y];if(f===0)return ct("java.lang.ArithmeticException","/ by zero");g[y-1]=g[y-1]/f|0,x+=1;break}case 14:{let f=g[--y];if(f===0)return ct("java.lang.ArithmeticException","/ by zero");g[y-1]=g[y-1]%f|0,x+=1;break}case 15:g[y-1]=-g[y-1]|0,x+=1;break;case 16:{let f=g[--y];g[y-1]=g[y-1]<<f,x+=1;break}case 17:{let f=g[--y];g[y-1]=g[y-1]>>f,x+=1;break}case 18:{let f=g[--y];g[y-1]=g[y-1]>>>f|0,x+=1;break}case 19:{let f=g[--y];g[y-1]=g[y-1]&f,x+=1;break}case 20:{let f=g[--y];g[y-1]=g[y-1]|f,x+=1;break}case 21:{let f=g[--y];g[y-1]=g[y-1]^f,x+=1;break}case 22:g[y-1]=~g[y-1],x+=1;break;case 23:g[y-1]=g[y-1]^1,x+=1;break;case 25:g[y-1]=g[y-1]&65535,x+=1;break;case 163:g[y-1]=g[y-1]<<24>>24,x+=1;break;case 164:g[y-1]=g[y-1]<<16>>16,x+=1;break;case 165:case 167:g[y-1]=Math.fround(g[y-1]),x+=1;break;case 166:g[y-1]=hn(g[y-1]),x+=1;break;case 168:{let f=g[--y];g[y-1]=Math.fround(g[y-1]+f),x+=1;break}case 169:{let f=g[--y];g[y-1]=Math.fround(g[y-1]-f),x+=1;break}case 170:{let f=g[--y];g[y-1]=Math.fround(g[y-1]*f),x+=1;break}case 171:{let f=g[--y];g[y-1]=Math.fround(g[y-1]/f),x+=1;break}case 172:{let f=g[--y];g[y-1]=Math.fround(g[y-1]%f),x+=1;break}case 173:g[y-1]=new st(Re(g[y-1])),x+=1;break;case 30:case 36:{let f=g[--y];g[y-1]=g[y-1]===f?1:0,x+=1;break}case 31:case 37:{let f=g[--y];g[y-1]=g[y-1]!==f?1:0,x+=1;break}case 32:{let f=g[--y];g[y-1]=g[y-1]<f?1:0,x+=1;break}case 33:{let f=g[--y];g[y-1]=g[y-1]<=f?1:0,x+=1;break}case 34:{let f=g[--y];g[y-1]=g[y-1]>f?1:0,x+=1;break}case 35:{let f=g[--y];g[y-1]=g[y-1]>=f?1:0,x+=1;break}case 40:x=F[x+1];break;case 41:x=g[--y]===0?F[x+1]:x+2;break;case 180:{let f=g[--y],b=g[--y];x=Js(F[x+1],b,f)?F[x+2]:x+3;break}case 181:x=Js(F[x+1],g[--y],F[x+2])?F[x+3]:x+4;break;case 182:x=Js(F[x+1],Ct[F[x+2]],Ct[F[x+3]])?F[x+4]:x+5;break;case 183:x=Js(F[x+1],Ct[F[x+2]],F[x+3])?F[x+4]:x+5;break;case 184:x=Ct[F[x+2]]===null==(F[x+1]===1)?F[x+3]:x+4;break;case 185:g[y++]=Ct[F[x+1]],g[y++]=Ct[F[x+2]],x+=3;break;case 186:g[y++]=Ct[F[x+1]],g[y++]=F[x+2],x+=3;break;case 187:g[y-1]=g[y-1]+F[x+1]|0,x+=2;break;case 191:{let f=g[--y],b=g[--y];b.base=f,f.owner=b,x+=1;break}case 192:{let f=g[y-1];f instanceof Ft&&f.base!==null&&(g[y-1]=f.base),x+=1;break}case 190:g[y-1]=dl(F[x+1],g[y-1],F[x+2]),x+=3;break;case 188:{let f=F[x+1];Ct[f]=Ct[f]+F[x+2]|0,x=F[x+3];break}case 189:{let f=Ct[F[x+1]],b=Ct[F[x+2]];if(f===null)return Et(F[x+4]);if(b<0||b>=f.data.length)return ct("java.lang.ArrayIndexOutOfBoundsException",Ds(b,f.data.length));g[y++]=f.data[b],x+=5;break}case 42:x=g[--y]!==0?F[x+1]:x+2;break;case 43:{let f=F[x+1];Ct[f]=Ct[f]+F[x+2]|0,x+=3;break}case 50:g[y-1]=new st(String(g[y-1])),x+=1;break;case 54:g[y-1]=new st(String.fromCharCode(g[y-1])),x+=1;break;case 143:g[y-1]=new st(String(g[y-1])),x+=1;break;case 144:g[y-1]=new st(le(g[y-1])),x+=1;break;case 120:g[y++]=u[F[x+1]],x+=2;break;case 121:{let f=g[--y];g[y-1]=ui(g[y-1],f),x+=1;break}case 122:{let f=g[--y];g[y-1]=hi(g[y-1],f),x+=1;break}case 123:{let f=g[--y];g[y-1]=di(g[y-1],f),x+=1;break}case 124:{let f=g[--y];if(f===0)return ct("java.lang.ArithmeticException","/ by zero");g[y-1]=mi(g[y-1],f),x+=1;break}case 125:{let f=g[--y];if(f===0)return ct("java.lang.ArithmeticException","/ by zero");g[y-1]=fi(g[y-1],f),x+=1;break}case 126:g[y-1]=sr(g[y-1]),x+=1;break;case 127:{let f=g[--y];g[y-1]=pi(g[y-1],f),x+=1;break}case 128:{let f=g[--y];g[y-1]=yi(g[y-1],f),x+=1;break}case 129:{let f=g[--y];g[y-1]=gi(g[y-1],f),x+=1;break}case 130:{let f=g[--y];g[y-1]=bi(g[y-1],f),x+=1;break}case 131:{let f=g[--y];g[y-1]=Si(g[y-1],f),x+=1;break}case 132:{let f=g[--y];g[y-1]=Ti(g[y-1],f),x+=1;break}case 133:{let f=g[--y];g[y-1]=g[y-1]+f,x+=1;break}case 134:{let f=g[--y];g[y-1]=g[y-1]-f,x+=1;break}case 135:{let f=g[--y];g[y-1]=g[y-1]*f,x+=1;break}case 136:{let f=g[--y];g[y-1]=g[y-1]/f,x+=1;break}case 137:{let f=g[--y];g[y-1]=g[y-1]%f,x+=1;break}case 138:g[y-1]=-g[y-1],x+=1;break;case 139:g[y-1]=ds(g[y-1]),x+=1;break;case 140:g[y-1]=ms(g[y-1]),x+=1;break;case 141:g[y-1]=$n(g[y-1]),x+=1;break;case 142:g[y-1]=Nn(g[y-1]),x+=1;break;case 146:if(g[--y]===null)return Et(F[x+1]);x+=2;break;case 147:{switch(F[x+1]){case lt.ABS_I:g[y-1]=Math.abs(g[y-1])|0;break;case lt.ABS_L:{let b=g[y-1];g[y-1]=b<0?sr(b):b;break}case lt.ABS_D:g[y-1]=Math.abs(g[y-1]);break;case lt.MAX_I:case lt.MAX_D:{let b=g[--y];g[y-1]=Math.max(g[y-1],b);break}case lt.MIN_I:case lt.MIN_D:{let b=g[--y];g[y-1]=Math.min(g[y-1],b);break}case lt.MAX_L:{let b=g[--y],O=g[y-1];g[y-1]=O>=b?O:b;break}case lt.MIN_L:{let b=g[--y],O=g[y-1];g[y-1]=O<=b?O:b;break}case lt.SQRT:g[y-1]=Math.sqrt(g[y-1]);break;case lt.FLOOR:g[y-1]=Math.floor(g[y-1]);break;case lt.CEIL:g[y-1]=Math.ceil(g[y-1]);break;case lt.ROUND:g[y-1]=vi(g[y-1]);break;case lt.ROUND_F:g[y-1]=xi(g[y-1]);break}x+=2;break}case 145:{let f=i.strings[F[x+1]],b=F[x+2],O=g.slice(y-b,y);y-=b;for(let B of O)if(B<0)return ct("java.lang.NegativeArraySizeException",String(B));let $=0,_=1;for(let B of O)_*=B,$+=_;if(Se+$>e.maxArrayElements)return Ee("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);Se+=$,Nt+=$>>>4,g[y++]=Yr(f,O,0),x+=3;break}case 51:g[y-1]=new st(g[y-1]?"true":"false"),x+=1;break;case 52:{let f=g[y-1];f===null?g[y-1]=new st("null"):f instanceof Kt?g[y-1]=new st($r(f)):f instanceof st||(g[y-1]=new st(Ue(f))),x+=1;break}case 53:{let f=g[--y],b=g[y-1],O=b.value.length+f.value.length;if(O>e.maxStringLength)return Ee("memory",`the program built a String longer than ${e.maxStringLength.toLocaleString("en-US")} characters`);Nt+=O>>>6,g[y-1]=new st(b.value+f.value),x+=1;break}case 60:{let f=F[x+3],b="";if(f!==kt.NONE){let $=g[--y];switch(f){case kt.INT:b=String($);break;case kt.CHAR:b=String.fromCharCode($);break;case kt.BOOLEAN:b=$?"true":"false";break;case kt.STRING:b=$===null?"null":$.value;break;case kt.LONG:b=String($);break;case kt.DOUBLE:b=le($);break;case kt.FLOAT:b=Re($);break;case kt.CHAR_ARRAY:if($===null)return ct("java.lang.NullPointerException",\'Cannot read the array length because "cbuf" is null\');b=bl($.data);break;default:b=$===null?"null":$ instanceof st?$.value:Ue($)}}F[x+2]===1&&(b+=`\n`);let O=Qr(F[x+1]===1?"stderr":"stdout",b);if(O)return O;x+=4;break}case 72:{let f=p[F[x+1]];if(f.isStatic&&N[f.classIndex]!==en&&an(f.classIndex))break;let b=F[x+2];if(b>=0&&g[y-f.argCount]===null)return Et(b);if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve(f,x+3);break}case 70:case 71:{let f=F[x]===l.RETURN_VALUE?g[--y]:void 0,b=pt.pop();if(b.initClass>=0&&(N[b.initClass]=en),Qa(b),!pt.length)return In?Br():{outcome:{kind:"completed"},instructions:Nt};if(ot=pt[pt.length-1],ot.method===Ca){let O=zr(f);if(O)return O;break}F=ot.code,Ct=ot.locals,g=ot.stack,y=ot.sp,x=ot.returnPc,f!==void 0&&(g[y++]=f);break}case 80:{let f=g[y-1];if(f<0)return ct("java.lang.NegativeArraySizeException",String(f));if(Se+f>e.maxArrayElements)return Ee("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);Se+=f,Nt+=f>>>4,g[y-1]=new Ut(F[x+1],Mr(F[x+1],f),o.next()),x+=2;break}case 84:{let f=g[y-1];if(f<0)return ct("java.lang.NegativeArraySizeException",String(f));if(Se+f>e.maxArrayElements)return Ee("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);Se+=f,Nt+=f>>>4,g[y-1]=new Ut(q.REF,Mr(q.REF,f),o.next(),i.strings[F[x+1]]),x+=2;break}case 81:{let f=g[--y],b=g[y-1];if(b===null)return Et(F[x+2]);if(f<0||f>=b.data.length)return ct("java.lang.ArrayIndexOutOfBoundsException",Ds(f,b.data.length));g[y-1]=b.data[f],x+=3;break}case 82:{let f=g[--y],b=g[--y],O=g[--y];if(O===null)return Et(F[x+2]);if(b<0||b>=O.data.length)return ct("java.lang.ArrayIndexOutOfBoundsException",Ds(b,O.data.length));if(f!==null&&F[x+1]===q.REF&&O.descriptor!=="[Ljava.lang.Object;"&&!j(f,O.descriptor))return ct("java.lang.ArrayStoreException",qt(f));O.data[b]=f,x+=3;break}case 83:{let f=g[y-1];if(f===null)return Et(F[x+1]);g[y-1]=f.data.length,x+=2;break}case 90:{let f=g[y-1];if(f===null)return Et(F[x+1]);g[y-1]=f.value.length,x+=2;break}case 91:{let f=g[--y],b=g[y-1];if(b===null)return Et(F[x+1]);if(f<0||f>=b.value.length)return ct("java.lang.StringIndexOutOfBoundsException",Ds(f,b.value.length));g[y-1]=b.value.charCodeAt(f),x+=2;break}case 92:{let f=g[--y],b=g[y-1];if(b===null)return Et(F[x+1]);g[y-1]=f instanceof st&&f.value===b.value?1:0,x+=2;break}case 153:{let f=g[--y],b=g[y-1];if(b===null)return Et(F[x+1]);if(f===null)return Et(F[x+2]);let O=b.value,$=f.value,_=Math.min(O.length,$.length),B=O.length-$.length;for(let at=0;at<_;at++){let Te=O.charCodeAt(at)-$.charCodeAt(at);if(Te!==0){B=Te;break}}Nt+=_>>>4,g[y-1]=B,x+=3;break}case 100:{let f=F[x+1],b=w[f];if(N[b]!==en&&an(b))break;g[y++]=S[f],x+=2;break}case 101:{let f=F[x+1],b=w[f];if(N[b]!==en&&an(b))break;S[f]=g[--y],x+=2;break}case 102:{let f=g[y-1];if(f===null)return Et(F[x+2]);g[y-1]=f.fields[F[x+1]],x+=3;break}case 103:{let f=g[--y],b=g[--y];if(b===null)return Et(F[x+2]);b.fields[F[x+1]]=f,x+=3;break}case 104:{let f=F[x+1];if(N[f]!==en&&an(f))break;g[y++]=new Ft(I[f].name,f,R[f].slice(),o.next()),x+=2;break}case 110:{let f=g[y-1];if(f instanceof Ft){let b=I[f.classIndex].toString;if(b>=0){if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve(p[b],x+1);break}g[y-1]=new st(Ue(f))}else if(f===null)g[y-1]=new st("null");else if(f instanceof Ut)g[y-1]=new st(Lr(f));else if(f instanceof Kt)g[y-1]=new st($r(f));else if(f instanceof pe){y--;let b=rn(qr(f),!0,x+1);if(b)return b;break}x+=1;break}case 148:{let f=F[x+1],b=i.natives[f],O=F[x+2];if(O>=0&&g[y-b.argCount]===null)return Et(O);let $=g.slice(y-b.argCount,y);if(y-=b.argCount,b.unwrap)for(let B=0;B<$.length;B++){let at=$[B];if(!(b.unwrap>>B&1)||!(at instanceof Ft)||at.base===null)continue;if(at.base.opaque)return{outcome:{kind:"engine-limitation",message:`passing a ${at.className}, an AbstractList subclass, to ${b.name.slice(0,b.name.indexOf("("))}()`},instructions:Nt};let Te=b.unwrapCalls,He=Object.keys(I[at.classIndex].libraryOverrides??{}).find(On=>!fa.has(On)&&(Te.includes("*")||Te.includes(On)));if(He!==void 0)return{outcome:{kind:"engine-limitation",message:`passing a ${at.className}, which overrides ${He.slice(0,He.indexOf("("))}(), to ${b.name.slice(0,b.name.indexOf("("))}(), which would call it`},instructions:Nt};$[B]=at.base}let _;try{_=h[f](Be,$)}catch(B){let at=os(B);if(at)return at;throw B}if(_ instanceof _e){let B=Kr(_,b.returnsValue,x+3);if(B)return B;break}if(Nr(_)){let B=rn(_,b.returnsValue,x+3);if(B)return B;break}b.returnsValue&&(g[y++]=_??null),x+=3;break}case 149:g[y-1]=zs(xr[F[x+1]],g[y-1]),x+=2;break;case 150:{let f=g[y-1];if(f===null)return Et(F[x+2]);g[y-1]=f.value,x+=3;break}case 154:g[y++]=Zr[F[x+1]],x+=2;break;case 155:s.result(g[--y]),x+=1;break;case 152:{let f=F[x+1],b=F[x+2],O=c[F[x+3]].value,$=F[x+5]>=0?c[F[x+5]].value:null;if(b===0){let _=Vr.get(f);_||Vr.set(f,_=new ye(`${p[f].className}$$Lambda`,f,o.next(),[],O,F[x+4],$)),g[y++]=_}else{let _=g.slice(y-b,y);y-=b,g[y++]=new ye(`${p[f].className}$$Lambda`,f,o.next(),_,O,F[x+4],$)}x+=6;break}case 151:{let f=g[y-1];if(f===null)return Et(F[x+1]);let b=new Uint16Array(f.value.length);for(let O=0;O<b.length;O++)b[O]=f.value.charCodeAt(O);if(Se+b.length>e.maxArrayElements)return Ee("memory",`the program allocated more than ${e.maxArrayElements.toLocaleString("en-US")} array elements`);Se+=b.length,Nt+=b.length>>>4,g[y-1]=new Ut(q.CHAR,b,o.next()),x+=2;break}case 111:{let f=g[y-1];if(f===null)return Et(F[x+1]);if(f instanceof Ft&&I[f.classIndex].toString>=0){if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve(p[I[f.classIndex].toString],x+2);break}if(f instanceof pe){y--;let b=rn(qr(f),!0,x+2);if(b)return b;break}f instanceof Kt?g[y-1]=new st($r(f)):f instanceof st||(g[y-1]=new st(Ue(f))),x+=2;break}case 112:{let f=g[y-1];if(f===null)return Et(F[x+1]);if(f instanceof Ft&&I[f.classIndex].hashCode>=0){if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve(p[I[f.classIndex].hashCode],x+2);break}if(f instanceof pe&&!(f instanceof ye)&&d?.natives["hashCode()"]){let b=Wr("hashCode()",[f],x+2);if(b)return b;break}g[y-1]=f instanceof st?vl(f.value):f instanceof Kt?wl(f):f.hash,x+=2;break}case 113:{let f=g[y-1],b=g[y-2];if(b===null)return Et(F[x+1]);if(b instanceof Ft&&I[b.classIndex].equals>=0){if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve(p[I[b.classIndex].equals],x+2);break}if(b instanceof pe&&!(b instanceof ye)&&d?.natives["equals(Object)"]){let O=Wr("equals(Object)",[b,f],x+2);if(O)return O;break}y--,b instanceof st?g[y-1]=f instanceof st&&f.value===b.value?1:0:b instanceof Kt?g[y-1]=f instanceof Kt&&f.kind===b.kind&&Object.is(f.value,b.value)?1:0:g[y-1]=b===f?1:0,x+=2;break}case 159:{let f=F[x+1];if(f===2){let b=g[--y];g[y-1]=g[y-1]===b?1:0}else{let b=g[y-1];g[y-1]=f===0?new st(Ue(b)):b.hash}x+=2;break}case 156:{let f=p[F[x+1]],b=F[x+2],O=g[y-f.argCount];if(O===null)return Et(b);let $=f;if(O instanceof Ft){let _=I[O.classIndex].vtable[f.selector];_>=0&&($=p[_])}else if(O instanceof ye&&O.samSelector===f.selector){let _=y-f.argCount,B=g.slice(_+1,y);y=_;for(let at of O.captured)g[y++]=at;for(let at of B)g[y++]=at;$=p[O.method]}if(pt.length>e.maxCallDepth)return ct("java.lang.StackOverflowError",null);Ve($,x+3);break}case 157:{let f=g[y-1],b=i.strings[F[x+1]];if(f!==null&&!Z(f,b)){let O=b.startsWith("[")?b:b.slice(1,-1);return ct("java.lang.ClassCastException",An(f,O))}x+=2;break}case 160:{let f=I[F[x+1]],b=g[y-1];if(b===null)return ct("java.lang.NullPointerException","Name is null");let O=f.enumConstants.find($=>S[$].fields[0].value===b.value);if(O===void 0)return ct("java.lang.IllegalArgumentException",`No enum constant ${f.canonicalName}.${b.value}`);g[y-1]=S[O],x+=2;break}case 158:g[y-1]=Z(g[y-1],i.strings[F[x+1]])?1:0,x+=2;break;case 161:{let f=g[--y];if(f===null)return Et(F[x+1]);throw new Cn(f)}case 162:{let f=F[x+1];if(f===jt.PRINT_TRACE||f===jt.PRINT_UNCAUGHT){let b=g[--y],O=rn(to(b,f===jt.PRINT_UNCAUGHT),!1,x+2);if(O)return O;break}if(f===jt.FILL_TRACE){let b=g[y-1],O=I[b.classIndex].types,$=_=>(_.method.name==="<init>"||_.method.name==="fillInStackTrace")&&O.includes(_.method.className);b.fields[mt.trace]=new Fs(Fr($))}else if(f===jt.ADD_SUPPRESSED){let b=g[--y],O=g[--y];if(b===O)return ct("java.lang.IllegalArgumentException","Self-suppression not permitted",b);if(b===null)return ct("java.lang.NullPointerException","Cannot suppress a null exception.");let $=O.fields[mt.suppressed];$?$.push(b):O.fields[mt.suppressed]=[b]}else if(f===jt.GET_SUPPRESSED){let b=g[y-1],O=Xs(b);Be.allocate(O.length),g[y-1]=new Ut(q.REF,O.slice(),o.next(),"[Ljava.lang.Throwable;")}else if(f===jt.CLASS_NAME)g[y-1]=new st(g[y-1].className);else if(f===jt.INIT_CAUSE){let b=g[y-1],O=g[y-2];if(O.fields[mt.causeSet]){y-=2;let $=rn(Za(O,b),!1,x+2);if($)return $;break}if(b===O)return ct("java.lang.IllegalArgumentException","Self-causation not permitted",O);O.fields[mt.cause]=b,O.fields[mt.causeSet]=1,y--}x+=2;break}default:throw new Error(`interpreter: unknown opcode ${F[x]} at ${x}`)}}}catch(f){if(!(f instanceof Cn))throw f;let b=Ya(f.thrown);if(b)return b}function Xs(f){return f.fields[mt.suppressed]??[]}function*ls(f){let b=yield{invoke:I[f.classIndex].toString,args:[f]};return b==null?"null":b.value}function*Za(f,b){let O=b===null?"a null":yield*ls(b);return ct("java.lang.IllegalStateException",`Can\'t overwrite cause with ${O}`,f)}function*to(f,b){let O=At=>Be.print("err",At),$=new Set([f]),_=At=>(At.fields[mt.trace]?.frames??[]).map(wa),B=At=>[..._(At),...yl].slice(0,1024);function*at(At){return yield{invoke:I[At.classIndex].virtuals["getCause/0"],args:[At]}}function*Te(At,ti,ei,on){if($.has(At)){O(`${on}${ei}[CIRCULAR REFERENCE: ${yield*ls(At)}]\n`);return}$.add(At);let ze=B(At),Ln=ze.length-1;for(let xe=ti.length-1;Ln>=0&&xe>=0&&ze[Ln]===ti[xe];xe--)Ln--;let ni=ze.length-1-Ln;O(`${on}${ei}${yield*ls(At)}\n`);for(let xe=0;xe<=Ln;xe++)ze[xe].startsWith(Rr)||O(`${on} at ${ze[xe]}\n`);ni&&O(`${on} ... ${ni} more\n`);for(let xe of Xs(At))yield*Te(xe,ze,"Suppressed: ",on+" ");let si=yield*at(At);si&&(yield*Te(si,ze,"Caused by: ",on))}b&&O(\'Exception in thread "main" \'),O(`${yield*ls(f)}\n`);let He=b?_(f):B(f);for(let At of He)At.startsWith(Rr)||O(` at ${At}\n`);for(let At of Xs(f))yield*Te(At,He,"Suppressed: "," ");let On=yield*at(f);On&&(yield*Te(On,He,"Caused by: ",""))}}var Bt=class extends Error{},ge=class extends Error{},sn=class extends Error{},La=i=>i.replace(/\\s+/g,"");function $a(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 Bt(`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(La);n=n.filter(m=>m.params.length===h.length&&m.params.every((p,k)=>La(M(p))===h[k]))}let s=`${t.method}(${(t.params??[]).join(", ")})`;if(!n.length)throw new Bt(`no method ${t.params?s:t.method+"(...)"}${t.className?` in class ${t.className}`:""}`);if(n.length>1)throw new Bt(`${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 Bt(`${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 Bt(`${r.owner.displayName} needs a constructor with no parameters, to call its instance method ${r.name}`)}let o=r.params.map((h,m)=>rs(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 Bt(`compare.index ${c.index} is not a parameter of ${r.name}`);d=c.index}else{if(r.returnType.tag==="void")throw new Bt(`${r.name} returns nothing: compare one of its arguments instead ({ kind: \'argument\', index })`);u=rs(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(M).join(", ")})`}}function Ma(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`[${Ma(i.element)}`;default:return"Ljava.lang.Object;"}}var kl={int:q.INT,boolean:q.BOOLEAN,char:q.CHAR,long:q.LONG,double:q.DOUBLE};function rs(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:rs(i.element,t,e),arrayKind:kl[i.element.tag]??q.REF,descriptor:Ma(i),type:M(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:rs(i.args[0],t,e)};break;case"class":return Cl(i.symbol,t,e)}throw new Bt(`${e} has type ${M(i)}, which practice cases cannot pass or compare yet`)}function Cl(i,t,e){let n=i.fields.filter(k=>!k.isStatic),s=k=>{let T=n.find(C=>C.name===k);if(!T)throw new Bt(`practice.nodes.${i.name}: ${i.name} has no field ${k}`);return T},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 Bt(`${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 Bt(`practice.nodes.${i.name} needs its value field`);let d=rs(u.type,t,`${i.name}.${u.name}`);if(c==="list"){let k=o?.next?s(o.next):r[0];if(!k)throw new Bt(`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(T=>T.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 Bt(`practice.nodes.${i.name} needs its left and right fields`);return{kind:"tree",cls:i,value:u,valueCodec:d,left:m,right:p}}var El=-2147483648,Al=2147483647,Il=-(1n<<63n),Ol=(1n<<63n)-1n;function En(i){return JSON.stringify(i)??"undefined"}function Na(i,t,e){let n=s=>{throw new ge(`${e}: expected ${s}, got ${En(i)}`)};switch(t){case"int":return(typeof i!="number"||!Number.isInteger(i)||i<El||i>Al)&&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<Il||s>Ol)&&n("a long in range"),wt(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 ss(i,t,e,n){switch(t.kind){case"int":case"long":case"double":case"char":case"boolean":return Na(i,t.kind,n);case"string":if(i===null)return null;if(typeof i!="string")throw new ge(`${n}: expected a String, got ${En(i)}`);return e.string(i);case"box":return i===null?null:e.box(t.box,Na(i,t.box,n));case"array":{if(i===null)return null;if(!Array.isArray(i))throw new ge(`${n}: expected ${t.type}, an array, got ${En(i)}`);e.allocate(i.length);let s=i.map((a,o)=>ss(a,t.element,e,`${n}[${o}]`)),r;switch(t.arrayKind){case q.INT:r=Int32Array.from(s);break;case q.BOOLEAN:r=Uint8Array.from(s);break;case q.CHAR:r=Uint16Array.from(s);break;case q.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 ge(`${n}: expected a List, an array, got ${En(i)}`);return e.list(i.map((s,r)=>ss(s,t.element,e,`${n}[${r}]`)))}case"linked-list":{if(i===null)return null;if(!Array.isArray(i))throw new ge(`${n}: expected a ${t.cls.name} list, an array of values, got ${En(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]=ss(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 ge(`${n}: expected a ${t.cls.name} tree, a level-order array, got ${En(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]=ss(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 Pa=1e5;function nn(i,t,e){let n=s=>{if(e.nodes-=s,e.nodes<0)throw new sn(`the result has more than ${Pa.toLocaleString("en-US")} elements, or is cyclic`)};switch(t.kind){case"int":return i;case"long":return String(i);case"double":return Ll(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:nn(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=>nn(r,t.element,e))}case"list":{if(i===null)return null;let s=fn()?.listItems(i);if(!s)throw new sn("the result is not an ArrayList");return n(s.length),s.map(r=>nn(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 sn(`the ${t.cls.name} list has a cycle`);r.add(a),n(1),s.push(nn(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(nn(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 Ll(i){return Number.isNaN(i)?"NaN":i===1/0?"Infinity":i===-1/0?"-Infinity":i}function Us(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)=>Us(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=>Us(i[s],t[s],e))}return i===t}function Ra(i,t){if(t.length!==i.params.length)throw new ge(`${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)=>ss(o,i.params[c],a,`argument ${c+1}`)),result:a=>{n=a}},actual:()=>{let a={nodes:Pa};return i.compareIndex!==null?nn(e[i.compareIndex],i.params[i.compareIndex],a):nn(n,i.result,a)}}}function Nl(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 Ja(i,t){let e=t.flatMap(r=>Nl(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 Dr={maxFiles:32,maxSourceChars:5e5,maxTotalSourceChars:1e6,maxNestingDepth:200,maxExpressionDepth:1e3,maxInstructions:2e8,maxOutputChars:1e6,maxStringLength:1e7,maxArrayElements:16e6,maxCallDepth:5e4,maxDurationMs:0},is=()=>globalThis.performance.now();function $l(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 ja(i,t={}){return Fa(i,t).result}function Fa(i,t,e=!0){let n=is(),s={...Dr,...t.limits},r=$l(i,t.entry),a=i[r]??"",o=Ys(r,a),c=new ln,u=new Map([[r,o]]),d=null,h=S=>({result:{program:S,diagnostics:c.items,entry:r,diagnosticText:c.items.length?Qs(c.items,u):"",compileMs:is()-n},checked:d,source:o});if(Object.keys(i).length>s.maxFiles)return c.launchError(r,v.limit,`too many files for this engine (limit ${s.maxFiles})`),h(null);if(!(r in i)){let S=c.launchError(r,v.noMain,`could not find or load main class ${r}`);return S.text=`Error: Could not find or load main class ${r}\nCaused by: java.lang.ClassNotFoundException: ${r}`,h(null)}let m=Object.keys(i).filter(S=>S.endsWith(".java")&&/[\\\\/]/.test(S));if(m.length){let S=m[0].replace(/^.*[\\\\/]/,"");return c.launchError(r,v.unsupported,`${m.join(", ")}: Java files in folders are not supported in this version; put each class in a file of its own at the top level, such as ${S}`),h(null)}let p=new Set(Object.keys(i).filter(S=>S!==r&&S.endsWith(".java"))),k=[r],T=[],C=0;for(;;){for(let S of k.slice(T.length)){let w=i[S]??"",I=S===r?o:Ys(S,w);if(u.set(S,I),w.length>s.maxSourceChars)return c.launchError(S,v.limit,`${S} is too large for this engine (limit ${s.maxSourceChars.toLocaleString("en-US")} characters)`),h(null);if(C+=w.length,C>s.maxTotalSourceChars)return c.launchError(S,v.limit,`the program\'s files are too large for this engine together (limit ${s.maxTotalSourceChars.toLocaleString("en-US")} characters)`),h(null);let R=li(w);if(R.errors.length){for(let A of R.errors)c.error(I,A.offset,"lex",A.code,A.message);return h(null)}let N=$i(S,R.tokens,s);if(N.error)return N.error.code==="no-class"?S===r?c.launchError(S,v.noMain,N.error.message):c.launchError(r,v.unsupported,`${S} declares no class, so the launcher cannot find ${S.replace(/\\.java$/,"")} there`):c.error(I,N.error.offset,"parse",N.error.code,N.error.message,N.error.details),h(null);T.push({unit:N.unit,file:I})}try{let S=new Set([...p].filter(I=>!k.includes(I))),w=ca(T,c,{launch:e,available:S});return!w||c.hasErrors?h(null):(d=w,h(e?Ml(Or(w,o),w,c.items,u,r):null))}catch(S){if(S instanceof Yn){k.push(S.fileName),T.length=0,C=0,c=new ln,u=new Map([[r,o]]);continue}if(S instanceof Ze)return c=new ln,c.launchError(r,v.unsupported,`${S.message}: not supported in this version`),h(null);if(!(S instanceof dn))throw S;return{result:{program:null,diagnostics:[],entry:r,diagnosticText:"",compileMs:is()-n,needsLibrary:!0},checked:null,source:o}}}}function Ml(i,t,e,n,s){let r=[];for(let a of n.keys()){if(a===s)continue;let o=e.filter(u=>u.severity==="warning"&&u.file===a);if(!o.length)continue;let c=t.classes.filter(u=>u.topLevel.file?.name===a).map(u=>u.index);r.push({classes:c,text:Qs(o,n)})}return r.length&&(i.loadWarnings=r),i}var Pl={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."},Rl="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 _a(i,t={}){return Ua(i,t)}var Jl="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 Ua(i,t,e){let n={...Dr,...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=is(),{outcome:c,instructions:u,inputExhausted:d}=Oa(i,a,n,t.onCheckpoint,e,t.stdin??""),h=is()-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:Jl,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:Pl[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:Rl,exitCode:1}}case"exit":return{...m,status:c.status===0?"success":"exited",stderr:r,exitCode:c.status,exited:!0}}}var Da=500;function Ba(i,t,e={}){let n={...Dr,...e.limits},s=Array.isArray(t.cases)?t.cases:[],r=k=>s.map((T,C)=>({id:T.id??String(C+1),status:"not-run",args:T.args??[],expected:T.expected,stdout:"",stderr:"",reason:k,instructions:0,durationMs:0})),{result:a,checked:o,source:c}=Fa(i,e,!1),u={passed:0,total:s.length,diagnostics:a.diagnostics,diagnosticText:a.diagnosticText,compileMs:a.compileMs},d=k=>({...u,status:"invalid-practice",message:k,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>Da)return d(`too many cases (limit ${Da})`);if(a.needsLibrary)return{...u,status:"compile-error",cases:[],needsLibrary:!0};if(!o)return{...u,status:"compile-error",cases:r("compile-error")};let h;try{h=$a(o,t)}catch(k){if(k instanceof Bt)return d(k.message);throw k}let m=Or(o,c,h.target),p=[];for(let[k,T]of s.entries()){let C=Array.isArray(T.args)?T.args:[],S={id:T.id??String(k+1),status:"not-run",args:C,expected:T.expected,stdout:"",stderr:"",instructions:0,durationMs:0};p.push(S);let w,I;try{let R=Ra(h,C);I=R.actual,w=Ua(m,{limits:n},R.host)}catch(R){if(R instanceof ge){S.status="invalid-case",S.error=R.message;continue}let N=R instanceof Error?R.message:String(R);S.reason="engine-failure";for(let A of r("engine-failure").slice(k+1))p.push(A);return{...u,status:"internal-error",message:`Internal error in the Java engine: ${N}`,cases:p,passed:p.filter(A=>A.status==="passed").length}}if(S.stdout=w.stdout,S.stderr=w.errorText?w.stderr.slice(0,w.stderr.length-w.errorText.length):w.stderr,S.instructions=w.instructions,S.durationMs=Math.round(w.runMs*100)/100,w.exited){S.status="runtime-error",S.error=`System.exit(${w.exitCode}) ended the program before ${t.method}() returned`;continue}if(w.status!=="success"){S.status=w.status==="runtime-error"||w.status==="resource-limit"||w.status==="engine-limitation"?w.status:"runtime-error",S.error=w.errorText,w.hint&&(S.hint=w.hint);continue}try{S.actual=I()}catch(R){if(!(R instanceof sn))throw R;S.status="runtime-error",S.error=`ResultEncodingError: ${R.message}`;continue}S.status=T.expected===void 0?"completed":Us(S.actual,T.expected,h.tolerance)?"passed":"failed"}return{...u,status:"completed",cases:p,passed:p.filter(k=>k.status==="passed").length}}var Dl={JString:st,JArray:Ut,JObject:Ft,JBox:Kt,JLibObject:pe,JLambda:ye,NativeThen:_e,doubleToString:le,objectToString:Ue,normLong:wt,floatToString:Re,floatToIntBits:fs,intBitsToFloat:ki,parseDecimalFloat:rr,parseHexFloating:Ai,l2f:hn};function Va(i){Ji(i(Dl))}var Ha="javaOnlineCompilerLibrary";var za="0.31.0";var Bs="java-library";async function jl(i){let t=globalThis,e=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));try{let s=!1;if(typeof t.importScripts=="function")try{t.importScripts(e),s=!0}catch{}s||await import(e)}finally{URL.revokeObjectURL(e)}let n=t[Ha];if(typeof n!="function")throw new Error("the library script did not define its factory");return n}var Fl=8192,Ka=16;function qa(i,t={}){let e=t.now??(()=>globalThis.performance.now()),n=[],s=0,r=0,a=0,o=null,c=()=>{if(r=e(),!n.length)return;let p=n;n=[],s=0;for(let k of p)i({type:k.type,id:a,text:k.text})},u=(p,k)=>{let T=n[n.length-1];T&&T.type===p?T.text+=k:n.push({type:p,text:k}),s+=k.length,(s>=Fl||e()-r>=Ka)&&c()},d=p=>{a=p.id,n=[],s=0,r=e();let k=e(),T=p.entry||"Main.java",C=p.files&&Object.keys(p.files).length?{...p.files}:{},S=Object.keys(C).length>0;!(T in C)&&(!S||p.code)&&(C[T]=p.code??"");try{let w=()=>{n.length&&e()-r>=Ka&&c()};if(p.practice){h(p,C,T,k);return}let I=ja(C,{entry:T,limits:t.limits});if(I.needsLibrary){o=p,i({type:"module-request",id:p.id,name:Bs});return}let R=I.program?_a(I.program,{limits:t.limits,stdin:p.stdin??"",onOutput:u,onCheckpoint:w,compileMs:I.compileMs,warnings:I.diagnosticText}):{status:"compile-error",stdout:"",stderr:I.diagnosticText,errorText:I.diagnosticText,diagnostics:I.diagnostics,exitCode:1,instructions:0,compileMs:I.compileMs,runMs:0};c();let N=e()-k;if(R.status==="success"){i({type:"result",id:p.id,durationMs:N,status:"success"});return}if(R.status==="cancelled")return;i({type:"error",id:p.id,message:R.status==="exited"?`Exited with status ${R.exitCode}.`:(R.errorText??"").replace(/\\n$/,""),hint:R.hint,...R.hintAbout?{hintAbout:R.hintAbout}:{},durationMs:N,status:R.status,...R.diagnostics.length?{diagnostics:R.diagnostics}:{}})}catch(w){c();let I=w instanceof Error?w.message:String(w);i({type:"fatal",id:p.id,message:`Internal error in the Java engine: ${I}`})}},h=(p,k,T,C)=>{let S=p.practice,w=Ba(k,S,{entry:T,limits:t.limits});if(w.needsLibrary){o=p,i({type:"module-request",id:p.id,name:Bs});return}let I=e()-C;switch(w.status){case"completed":i({type:"stdout",id:p.id,text:Ja(S.method,w.cases)}),i({type:"result",id:p.id,durationMs:I,status:"success",cases:w.cases,passed:w.passed,total:w.total});return;case"compile-error":i({type:"error",id:p.id,message:w.diagnosticText.replace(/\\n$/,""),durationMs:I,status:"compile-error",cases:w.cases,...w.diagnostics.length?{diagnostics:w.diagnostics}:{}});return;case"invalid-practice":i({type:"error",id:p.id,message:`Practice: ${w.message}`,durationMs:I,status:"invalid-practice",cases:w.cases});return;case"internal-error":i({type:"fatal",id:p.id,message:w.message??"Internal error in the Java engine"});return}},m=async p=>{let k=o;if(!(!k||p.name!==Bs)){o=null;try{if(p.code===void 0)throw new Error(p.error??"the host sent no code");Va(await(t.evaluateLibrary??jl)(p.code))}catch(T){let C=T instanceof Error?T.message:String(T);i({type:"fatal",id:k.id,message:`Internal error in the Java engine: could not load the Java library (${C})`});return}d(k)}};return p=>{switch(p.type){case"init":i({type:"ready",version:"25",interactiveStdin:!1,java:"25",engine:za});return;case"run":d(p);return;case"stdin-response":return;case"module":return m(p)}}}var Wa=globalThis,_l=qa(i=>Wa.postMessage(i));Wa.onmessage=i=>_l(i.data);})();\n',n=new class extends e{id=`java`;supportsPractice=!0;statusDecidesFailure=!0;get source(){return t}async loadModule(e){if(e!==`java-library`)throw Error(`no module named ${e}`);let{JAVA_LIBRARY_SOURCE:t}=await import(`./java-library.generated-9nfQ3go0.js`);return t}get label(){return this.version?`Java ${this.version} (subset)`:`Java`}async editorLanguage(){let{java:e}=await import(`./dist-BKRQwpg6.js`);return e()}};export{n as javaRuntime};
|