@oddington/cli 0.1.79 → 0.1.80

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.
Files changed (2) hide show
  1. package/dist/os.js +3 -3
  2. package/package.json +2 -2
package/dist/os.js CHANGED
@@ -349,7 +349,7 @@ For more details, run:
349
349
  os files storage connect dropbox --help`);if(J==="select"&&!(Y!==void 0&&/^dropbox\/[a-z0-9][a-z0-9-]{0,62}$/.test(Y)&&B===void 0||B==="os"&&Y===void 0)||J==="connect"&&(!H||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(H)))throw Error(S3);let K=await(Z.workspaceContext??I3)();if(G!==void 0&&G!==K.workspace.slug)throw Error(`The active workspace is ${K.workspace.slug}. Run os login to choose another workspace.`);let z=K.workspace.slug,V=Z.request??K.request;if(J==="connect"){let N=await s7(z,H,V,Z.credentialsInput,Z.authorizationPrompt,{access:"app_folder"});$(W?JSON.stringify({connection:N}):`Dropbox storage authorized as dropbox/${N.name}.
350
350
  Select it for new remote Files:
351
351
  os files storage select --connection dropbox/${N.name}`);return}let _;try{_=await V(`/workspaces/${z}/files/storage`,{method:J==="inspect"?"GET":"PUT",redirect:"error",headers:{"content-type":"application/json"},...J==="select"?{body:JSON.stringify({provider:Y?"dropbox":"os",connection:Y??null})}:{}})}catch(N){if(N instanceof VD)throw N;throw Error("Could not reach OS file storage management.")}if(_.status===401)throw new VD;if(await P1(_),!_.ok)throw Error("File storage operation failed. Check workspace membership, connection access and OS configuration.");try{let N=EH(await _.json()),F=N.storage.remote;if(J==="select"&&(!N.available||F.provider!==(Y?"dropbox":"os")||F.provider==="dropbox"&&F.connection!==Y))throw Error();$(W?JSON.stringify(N):`Remote storage: ${F.provider==="os"?"OS":`${F.connection} (folder: /)`}
352
- ${N.available?"Available":"Unavailable"}`)}catch{throw Error("OS returned an invalid storage response.")}}eD();eD();import{isDeepStrictEqual as IF}from"node:util";eD();import{constants as n7}from"node:fs";import{createHash as i7}from"node:crypto";import{link as Pj,lstat as p2,mkdir as yH,open as g6,readdir as f6,realpath as Oj,rename as E9,rm as Z0}from"node:fs/promises";import{dirname as c2,isAbsolute as zX,join as UD,relative as a7,resolve as uH}from"node:path";import{isDeepStrictEqual as y6}from"node:util";eD();eD();var z0=16777216;var S9=4096;var O1=4;async function k6(D){let Z=await crypto.subtle.digest("SHA-256",D);return Array.from(new Uint8Array(Z),($)=>$.toString(16).padStart(2,"0")).join("")}async function bH(D,Z,$){if(!o8(D))throw new v("invalid_input",400);if(Z.byteLength>z0)throw new v("request_too_large",413);let J="application/octet-stream",Q=D.split(".").at(-1)?.toLowerCase();if(D.includes(".")&&["txt","md","json"].includes(Q))try{let X=new TextDecoder("utf-8",{fatal:!0}).decode(Z);if(Q==="json")JSON.parse(X),J="application/json";else if(!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/.test(X))J=Q==="md"?"text/markdown":"text/plain"}catch{}return{mediaType:J,size:Z.byteLength,sha256:await k6(Z)}}eD();class V0{signal;#$=new AbortController;#Z;#D;expired;#J=new Set;constructor(D,Z){if(this.#D=D===void 0?1/0:Date.now()+D,this.signal=Z?AbortSignal.any([Z,this.#$.signal]):this.#$.signal,this.expired=new Promise(($,J)=>{let Q=()=>J(new v("unavailable",503,!0));if(this.signal.addEventListener("abort",Q,{once:!0}),this.signal.aborted)Q()}),this.expired.catch(()=>{}),D!==void 0)this.#Z=setTimeout(()=>this.#$.abort(),D)}check(){if(Date.now()>=this.#D)this.#$.abort();if(this.signal.aborted)throw new v("unavailable",503,!0)}close(){clearTimeout(this.#Z)}track(D){return this.#J.add(D),D.finally(()=>this.#J.delete(D)).catch(()=>{}),D}async settle(){await Promise.allSettled(this.#J)}}var kH=262144,Fj=()=>new v("unavailable",503,!0),Lj=()=>new v("integrity",503);class Nj{maximum;#$=0;constructor(D){this.maximum=D}run(D){if(this.#$>=this.maximum)throw new v("capacity",429,!0);this.#$++;try{return D().finally(()=>{this.#$--})}catch(Z){throw this.#$--,Z}}}class _j{#$;#Z;#D;#J=!1;constructor(D){let Z;try{Z=D.getReader({mode:"byob"})}catch{}this.#Z=Boolean(Z),this.#$=Z??D.getReader()}async read(D,Z){if(D.check(),this.#J)throw Fj();let $=()=>this.#Z?this.#$.read(new Uint8Array(kH)):this.#$.read(),J=D.track(Z?Z.run($):$());this.#D=J;try{let Q=await Promise.race([J,D.expired]);if(D.check(),Q.value!==void 0&&(!(Q.value instanceof Uint8Array)||Q.value.buffer.byteLength>kH))throw Lj();return Q}finally{J.finally(()=>{if(this.#D===J)this.#D=void 0}).catch(()=>{})}}close(D=!1){if(this.#J)return;if(this.#J=!0,D)this.#$.cancel().catch(()=>{});let Z=()=>this.#$.releaseLock();if(this.#D)this.#D.then(Z,Z).catch(()=>{});else Z()}}async function c0(D,Z,$,J="request_too_large"){if($.check(),!D)return new Uint8Array;let Q=D.getReader(),X=new Uint8Array(Z),W=0,G;try{while(!0){let Y=$.track(Q.read());G=Y;let{done:B,value:H}=await Promise.race([Y,$.expired]);if(G=void 0,$.check(),B)break;if(!(H instanceof Uint8Array))throw new v("invalid_input",400,!1,{reason:"invalid_bytes"});if(W+=H.byteLength,W>Z)throw new v(J,J==="request_too_large"?413:503,!1,{reason:"size_limit",limitBytes:Z,receivedBytes:W,receivedAtLeast:!0});X.set(H,W-H.byteLength)}return X.slice(0,W)}catch(Y){throw Q.cancel().catch(()=>{}),Y}finally{if(G)G.finally(()=>Q.releaseLock()).catch(()=>{});else Q.releaseLock()}}T1();var ID=()=>new v("integrity",503),dH=()=>new v("access_denied",403),H2=(D)=>D.code==="ENOENT";function w9(D){let Z=D.lastIndexOf(".");return Z>0&&/^\.[a-z0-9]{1,16}$/i.test(D.slice(Z))?{stem:D.slice(0,Z),extension:D.slice(Z)}:{stem:D,extension:""}}function o7(D){let Z="";for(let $ of D){if(Buffer.byteLength(Z+$,"utf8")>200)break;Z+=$}return Z}function r7(D,Z){return D.id===Z.id&&D.name===Z.name&&D.path===Z.path&&D.mediaType===Z.mediaType&&D.size===Z.size&&D.sha256===Z.sha256}function hH(D){if(!D)return!1;if(typeof D.dev==="string")return/^(0|[1-9][0-9]{0,19})$/.test(D.dev)&&typeof D.ino==="string"&&/^(0|[1-9][0-9]{0,19})$/.test(D.ino)&&"birthtimeNs"in D&&typeof D.birthtimeNs==="string"&&/^-?(0|[1-9][0-9]{0,29})$/.test(D.birthtimeNs);return Number.isSafeInteger(D.dev)&&Number.isSafeInteger(D.ino)&&"birthtimeMs"in D&&Number.isFinite(D.birthtimeMs)}function mH(D){if(!D||!lD.test(D.workspaceId)||D.creator&&(!["member","routine"].includes(D.creator.kind)||!lD.test(D.creator.id))||D.runId!==void 0&&!lD.test(D.runId))throw dH();return structuredClone(D)}function Tj(D){let{details:Z,...$}=D;return J2($)}function pH(D){return JSON.stringify({name:D.name,path:D.path,mediaType:D.mediaType,storage:"local",size:D.size,sha256:D.sha256})}function vH(D,Z){let $=JSON.parse(D);if(!$||typeof $!=="object"||Array.isArray($))throw ID();if(!Object.hasOwn($,"csv")&&!Object.hasOwn($,"inputMediaType"))return D;if(Object.keys($).some((J)=>!["name","path","csv","storage","size","sha256","inputMediaType"].includes(J))||$.name!==Z.name||$.path!==Z.path||$.storage!=="local"||$.size!==Z.size||$.sha256!==Z.sha256)throw ID();return pH(Z)}async function cH(D,Z){if(!zX(D)||!lD.test(Z))throw new v("invalid_input",400);let $=UD(uH(D),".os","files"),J=[];for(let Q=$;Q!==c2(Q);Q=c2(Q))J.unshift(Q);for(let Q of J){let X=await p2(Q).catch((W)=>{if(H2(W))return;throw W});if(!X||!X.isDirectory()||X.isSymbolicLink())return!1}for(let Q of[`${Z}.json`,`${Z}.pending.json`])if(await p2(UD($,Q)).catch((X)=>{if(H2(X))return;throw X}))return!0;return!1}async function VX(D,Z,$){let J=mH({workspaceId:Z.workspaceId}),Q=".os",X=(A)=>A.workspaceId;if(!zX(D))throw new v("invalid_input",400);let W=uH(D),G=async(A,I=!1,b=!1)=>{let k=a7(W,A);if(k===".."||k.startsWith(`..${process.platform==="win32"?"\\":"/"}`)||zX(k))throw ID();let l=[];for(let i=A;i!==c2(i);i=c2(i))l.unshift(i);for(let i of l){let o=await p2(i).catch((HD)=>{if(H2(HD))return;throw HD});if(!o&&b)await yH(i,{mode:448}).catch((HD)=>{if(HD.code!=="EEXIST")throw HD}),o=await p2(i);if(!o)throw ID();if(o.isSymbolicLink()||(i!==A||I)&&!o.isDirectory())throw ID()}if(await Oj(I?A:c2(A))!==(I?A:c2(A)))throw ID();return A},Y=async()=>{await G(W,!0)},B=async(A,I)=>{await p2(A),await G(A);let b=await g6(A,n7.O_RDONLY|(n7.O_NOFOLLOW??0));try{let k=await b.stat();if(!k.isFile()||k.size>I||k.nlink!==1&&!(c2(A)===UD(W,".os","locks")&&k.nlink===2))throw ID();let l=new Uint8Array(k.size+1),i=0;while(i<l.length){let o=await b.read(l,i,l.length-i,i);if(!o.bytesRead)break;i+=o.bytesRead}if(i!==k.size)throw ID();return l.slice(0,i)}finally{await b.close()}},H=async(A,I=65536)=>JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(await B(A,I))),K=async(A,I)=>{await G(A);let b=await g6(A,n7.O_RDONLY|(n7.O_NOFOLLOW??0));try{let k=await b.stat();if(!k.isFile()||k.size!==I||k.nlink!==1)throw ID();return b}catch(k){throw await b.close(),k}},z=async(A,I)=>{let b=i7("sha256"),k=new Uint8Array(262144),l=0;for(;;){let{bytesRead:i}=await A.read(k,0,k.length,l);if(!i)break;if(l+=i,l>I.size)throw ID();b.update(k.subarray(0,i))}if(l!==I.size||b.digest("hex")!==I.sha256)throw ID()},V=async(A,I)=>{let b=await K(A,I.size);try{await z(b,I)}finally{await b.close()}},_=async(A,I)=>{let b=await K(A.bundle?UD(W,A.location,E(A)):UD(W,A.location),A.descriptor.size),k;try{await G(c2(I),!0),k=await g6(I,"wx",384);let l=new Uint8Array(262144),i=0;for(;;){let{bytesRead:o}=await b.read(l,0,l.length,i);if(!o)break;if(i+=o,i>A.descriptor.size)throw ID();await k.writeFile(l.subarray(0,o))}if(i!==A.descriptor.size)throw ID();await k.sync()}finally{await b.close(),await k?.close()}},N=async(A,I)=>{await G(c2(A),!0);let b=await g6(A,"wx",384);try{await b.writeFile(I),await b.sync()}finally{await b.close()}},F=async(A)=>{if(process.platform==="win32")return;let I=await g6(A,"r");try{await I.sync()}finally{await I.close()}},U=async(A,I)=>{let b=`${A}.${crypto.randomUUID()}.tmp`;if(await N(b,JSON.stringify(I)),await G(c2(A),!0),(await p2(A).catch((l)=>{if(H2(l))return;throw l}))?.isSymbolicLink())throw ID();await E9(b,A),await F(c2(A))};await G(W,!0,!0);for(let A=W;;A=c2(A)){if(await p2(UD(A,".git")).catch((b)=>{if(H2(b))return;throw b})){if((await b0(A,["ls-files","-z","--",a7(A,W)||"."],void 0,{localObjectsOnly:!0})).length)throw new v("unavailable",503,!1,{reason:"local_storage_tracked"});break}if(A===c2(A))break}let M=await f6(W);if(M.includes(".oddington-files"))throw new v("unavailable",503,!1,{reason:M.includes(".os")?"local_storage_ambiguous":"local_storage_legacy"});let L=UD(W,".os");if(!M.includes(".os")){if(M.length)throw new v("unavailable",503,!1,{reason:"local_storage_unrecognized"});await yH(L,{mode:448}),await N(UD(L,"owner.json"),JSON.stringify({format:1,owner:"oddington-files"}))}await G(L,!0);let C=await H(UD(L,"owner.json"));if(C.format!==1||C.owner!=="oddington-files")throw ID();for(let A of["files","requests","locks","staging"])await G(UD(L,A),!0,!0);await Y();let P=new Set;for(let A of await f6(UD(L,"files")))if(A.endsWith(".pending.json")){let I=await H(UD(L,"files",A)).catch((b)=>{if(H2(b))return;throw b});if(!I)continue;P.add(I.stage),P.add(I.backup)}for(let A of await f6(UD(L,"staging")))if(/^[0-9a-f-]{36}\.owner\.json$/.test(A)){let I=UD(L,"staging",A),b=await H(I).catch((k)=>{if(H2(k))return;throw k});if(!b||!Number.isSafeInteger(b.pid)||b.pid<=0)continue;try{process.kill(b.pid,0)}catch(k){if(k.code!=="ESRCH")continue;let l=A.slice(0,-11);if(!P.has(`staging/${l}`))await Z0(UD(L,"staging",l),{recursive:!0,force:!0});await Z0(I,{force:!0})}}let j=async(A)=>{await N(`${A}.owner.json`,JSON.stringify({pid:process.pid}))},q=async(A)=>{let I=!1;for(let b of await f6(UD(L,"files")))if(b.endsWith(".pending.json")){let k=await H(UD(L,"files",b)).catch((l)=>{if(H2(l))return;throw l});if(!k)continue;if(k.stage===a7(L,A).replaceAll("\\","/"))I=!0}if(!I)await Z0(A,{recursive:!0,force:!0});await Z0(`${A}.owner.json`,{force:!0})},O=async(A,I)=>{if(A!=="allocation"&&!lD.test(A)&&!/^request-[0-9a-f]{64}$/.test(A))throw new v("invalid_input",400);let b=UD(L,"locks",`${A}.json`),k=UD(L,"locks",`${A}.${crypto.randomUUID()}.lease`),l=new V0(30000);try{await N(k,JSON.stringify({pid:process.pid}));for(;;){l.check(),await G(c2(b),!0);try{await Pj(k,b)}catch(i){if(i.code!=="EEXIST")throw i;let o=await H(b).catch(()=>{return});if(o&&Number.isSafeInteger(o.pid)&&o.pid>0)try{process.kill(o.pid,0)}catch(HD){if(HD.code==="ESRCH"){await Z0(b);continue}}await new Promise((HD)=>setTimeout(HD,10));continue}await Z0(k);try{return await Y(),await I()}finally{await Z0(b)}}}finally{l.close(),await Z0(k,{force:!0})}},T=(A)=>UD(L,"files",`${A}.json`),R=(A)=>{let I=A;if(!I||![1,2].includes(I.format)||!R7(I.location)||typeof I.bundle!=="boolean"||!/^[2-9A-HJ-NP-Z]{8,32}$/.test(I.suffix)||typeof I.material!=="string"||I.uploading!==void 0&&typeof I.uploading!=="boolean"||I.placement!==void 0&&I.placement!=="remote")throw ID();if(I.descriptor=Tj(I.descriptor),mH(I.authority),I.material=vH(I.material,I.descriptor),I.descriptor.size>b2)throw ID();let b=w9(I.descriptor.name),k=`${o7(b.stem)} [${I.suffix}]`;if(I.location!==`${I.descriptor.path}/${k}${I.bundle?"":b.extension}`)throw ID();if(I.cache){let l=R({format:I.format,authority:I.authority,material:I.material,...I.cache});if(!r7(l.descriptor,I.descriptor))throw ID();I.cache={...I.cache,descriptor:l.descriptor}}if(I.objects&&(!hH(I.objects.home)||!I.objects.representations||!y6(Object.keys(I.objects.representations).sort(),Object.keys(y(I)).sort())||Object.values(I.objects.representations).some((l)=>!hH(l))))throw ID();return I.format=2,I},g=(A)=>{if(X(A.authority)!==X(J))throw dH()},E=(A)=>`original${w9(A.descriptor.name).extension}`,y=(A)=>({[E(A)]:A.descriptor,...A.descriptor.enrichments}),d=(A)=>({dev:String(A.dev),ino:String(A.ino),birthtimeNs:String(A.birthtimeNs)}),u=(A,I)=>{if(!I)return!1;if(typeof I.dev==="string")return y6(d(A),I);let b=Number(A.birthtimeNs/1000000000n)*1000+Number(A.birthtimeNs%1000000000n)/1e6;return"birthtimeMs"in I&&A.dev===BigInt(I.dev)&&A.ino===BigInt(I.ino)&&b===I.birthtimeMs},S=async(A,I,b)=>{let k=await K(A,I.size);try{let l=await k.stat({bigint:!0});if(b&&!u(l,b))throw ID();await z(k,I);let i=await k.stat({bigint:!0});if(!u(i,d(l))||l.size!==i.size||l.mtimeNs!==i.mtimeNs||l.ctimeNs!==i.ctimeNs)throw ID();return d(i)}finally{await k.close()}},w=async(A,I=UD(W,A.location))=>{if(A.bundle){await G(I,!0);let b=new Set([E(A),...Object.keys(A.descriptor.enrichments)]);if((await f6(I)).some((k)=>!b.has(k)))throw ID()}await V(A.bundle?UD(I,E(A)):I,A.descriptor).catch((b)=>{if(H2(b))throw ID();throw b});for(let[b,k]of Object.entries(A.descriptor.enrichments)){let l=await B(UD(I,b),z0).catch((i)=>{if(H2(i))throw ID();throw i});if(l.length!==k.size||await k6(l)!==k.sha256)throw ID()}if(A.objects){if(!u(await p2(I,{bigint:!0}),A.objects.home))throw ID();for(let[b,k]of Object.entries(y(A)))await S(A.bundle?UD(I,b):I,k,A.objects.representations[b])}},h=async(A)=>{let I=UD(L,"files",`${A}.pending.json`),b=await H(I).catch((LD)=>{if(H2(LD))return;throw LD});if(!b)return;let k=R(b.next);if(g(k),k.descriptor.id!==A||b.previous&&R(b.previous).descriptor.id!==A||!/^staging\/[0-9a-f-]{36}$/.test(b.stage)||!/^staging\/[0-9a-f-]{36}$/.test(b.backup))throw ID();let l=UD(L,b.stage),i=UD(L,b.backup),o=await p2(l).catch((LD)=>{if(H2(LD))return;throw LD});if(k.registration){if(o&&b.previous&&!b.previous.bundle){let wD=UD(l,E(k));if(!await p2(wD).catch((aD)=>{if(H2(aD))return;throw aD})){await w(b.previous);for(let[aD,L2]of Object.entries(k.descriptor.enrichments))await V(UD(l,aD),L2)}else await w(k,l)}else if(o)await w(k,l);else await w(k);let LD=k.registration,ND="create"in LD?await $.registry.create(k.descriptor,{...LD.create,storage:"local"},null,{},k.suffix):await $.registry.enrich(LD.expected,LD.enrichment.name,k.descriptor.enrichments[LD.enrichment.name],{},LD.enrichment.replace);if("create"in LD&&ND.descriptor.id!==k.descriptor.id){if(!o||b.previous||!r7({...k.descriptor,id:ND.descriptor.id},ND.descriptor))throw ID();let wD=await k6(new TextEncoder().encode(`${X(J)}/${LD.create.requestKey}`));return await U(UD(L,"requests",`${wD}.json`),{id:ND.descriptor.id,material:k.material}),await Z0(l,{recursive:!0}),await Z0(I),await F(c2(I)),structuredClone(ND.descriptor)}if(!y6(ND.descriptor,k.descriptor)||ND.placement!=="local")throw ID();if(ND.filenameIdentifier!==k.suffix){if(!o||b.previous)throw ID();k.suffix=ND.filenameIdentifier;let wD=w9(k.descriptor.name);k.location=`${k.descriptor.path}/${o7(wD.stem)} [${k.suffix}]${k.bundle?"":wD.extension}`,await U(I,{...b,next:k})}}let HD=UD(W,k.location);if(o){if(b.previous&&!b.previous.bundle){let ND=UD(l,E(k));if(!await p2(ND).catch((wD)=>{if(H2(wD))return;throw wD}))await w(b.previous),await E9(UD(W,b.previous.location),ND),await F(l)}if(await w(k,l),await Y(),b.previous&&b.previous.location===k.location){g(b.previous);let ND=UD(W,b.previous.location);if(!await p2(i).catch((aD)=>{if(H2(aD))return;throw aD}))await w(b.previous),await G(ND),await E9(ND,i)}if(await p2(HD).catch((ND)=>{if(H2(ND))return;throw ND}))throw ID();await G(c2(HD),!0);try{await E9(l,HD)}catch(ND){if(b.previous?.location===k.location)await E9(i,HD);throw ND}await F(c2(HD)),await $.afterPlacement?.()}await w(k);let uD=UD(W,k.location),_D={},MD=d(await p2(uD,{bigint:!0}));for(let[LD,ND]of Object.entries(y(k)))_D[LD]=await S(k.bundle?UD(uD,LD):uD,ND);if(!u(await p2(uD,{bigint:!0}),MD))throw ID();if(await Y(),await U(T(A),{...k,registration:void 0,objects:{home:MD,representations:_D}}),b.previous&&b.previous.location!==k.location){let LD=UD(W,b.previous.location);if(await p2(LD).catch((wD)=>{if(H2(wD))return;throw wD}))await w(b.previous),await Z0(LD)}await Z0(i,{recursive:!0,force:!0}),await Z0(I),await F(c2(I))},s=async(A)=>{if(!lD.test(A))throw new v("invalid_input",400);await Y();let I=await H(T(A)).catch((i)=>{if(H2(i))return;throw i});if(!I){let i=await H(UD(L,"files",`${A}.pending.json`)).catch((o)=>{if(H2(o))return;throw o});if(!i)throw new v("local_only",409);I=i.next}g(R(I)),await h(A);let b=await H(T(A)),k=JSON.stringify(b),l=R(b);if(l.descriptor.id!==A)throw ID();{let i=await $.registry.get(A);if(!r7(i.descriptor,l.descriptor))throw ID();if(i.placement==="remote")return{...l,descriptor:i.descriptor,placement:"remote"};if(!y6(i.descriptor,l.descriptor))throw ID()}if(JSON.stringify(l)!==k)await Y(),await U(T(A),l);return l},a=async(A,I,b,k)=>{try{if(b&&!b.bundle){await w(b);for(let[l,i]of Object.entries(A.descriptor.enrichments))await V(UD(I,l),i)}else await w(A,I);if(await $.beforeActivation?.(),await Y(),k?.aborted)throw new v("unavailable",503,!0)}catch(l){throw await Z0(I,{recursive:!0,force:!0}),l}await U(UD(L,"files",`${A.descriptor.id}.pending.json`),{next:A,...b?{previous:b}:{},stage:a7(L,I).replaceAll("\\","/"),backup:`staging/${crypto.randomUUID()}`});try{return await h(A.descriptor.id)}catch(l){if(l instanceof v&&l.status>=400&&l.status<500)await Z0(UD(L,"files",`${A.descriptor.id}.pending.json`)),await Z0(I,{recursive:!0,force:!0});throw l}},x=async(A)=>{if(A.placement!=="remote")await w(A);return await Y(),structuredClone(A.descriptor)},p=async(A)=>{if(!lD.test(A))throw new v("invalid_input",400);return await Y(),!!(await p2(T(A)).catch((k)=>{if(H2(k))return;throw k})??await p2(UD(L,"files",`${A}.pending.json`)).catch((k)=>{if(H2(k))return;throw k}))},f=async(A,I,b)=>{let k=UD(L,"staging",crypto.randomUUID()),l=0,i=(I instanceof Uint8Array?new ReadableStream({pull(_D){if(l===I.byteLength){_D.close();return}let MD=Math.min(l+262144,I.byteLength);_D.enqueue(I.subarray(l,MD)),l=MD}},{highWaterMark:0}):I).getReader(),o,HD=!1,uD=!1;try{await j(k),o=await g6(k,"wx",384);let _D=i7("sha256"),MD=0,LD=Date.now();for(;;){let ND=new V0(Math.max(1,30000-(Date.now()-LD)),b),wD;try{wD=await Promise.race([ND.track(i.read()),ND.expired]),ND.check()}finally{ND.close()}if(wD.done)break;if(!(wD.value instanceof Uint8Array))throw new v("invalid_input",400,!1,{reason:"invalid_bytes"});if(!wD.value.byteLength)continue;if(MD+wD.value.byteLength>A.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:A.size,receivedBytes:MD+wD.value.byteLength,receivedAtLeast:!0});for(let aD=0;aD<wD.value.byteLength;aD+=262144){if(b?.aborted)throw new v("unavailable",503,!0);let L2=wD.value.subarray(aD,aD+262144);_D.update(L2),MD+=L2.byteLength,await o.writeFile(L2)}LD=Date.now()}if(HD=!0,MD!==A.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:A.size,receivedBytes:MD});return await o.sync(),uD=!0,{stage:k,original:{size:MD,sha256:_D.digest("hex"),mediaType:A.mediaType}}}finally{if(!HD)await i.cancel().catch(()=>{});if(i.releaseLock(),await o?.close(),!uD)await q(k)}},c=async(A)=>{let I=UD(L,"requests",`${A}.json`),b=await H(I).catch((l)=>{if(H2(l))return;throw l});if(!b)return;if(!lD.test(b.id)||typeof b.material!=="string")throw ID();let k=JSON.parse(b.material);if(k&&(Object.hasOwn(k,"csv")||Object.hasOwn(k,"inputMediaType")))b.material=await O(b.id,async()=>{let l=await H(T(b.id)).catch((o)=>{if(H2(o))return;throw o})??(await H(UD(L,"files",`${b.id}.pending.json`)).catch((o)=>{if(H2(o))return;throw o}))?.next;if(!l)throw new v("conflict",409);let i=R(l);if(g(i),i.descriptor.id!==b.id)throw ID();return vH(b.material,i.descriptor)}),await Y(),await U(I,b);return b};return{has:p,async lookup(A){let I=await k6(new TextEncoder().encode(`${X(J)}/${A}`));return O(`request-${I}`,async()=>{let b=await c(I);if(!b||!await p(b.id))return;return O(b.id,async()=>x(await s(b.id)))})},async create(A,I,b){let k=O0(A,b2);if(k.storage==="remote")throw new v("unsupported_context",400);if(k.path.split("/").some((i)=>Buffer.byteLength(i,"utf8")>255))throw new v("invalid_input",400);if(new TextEncoder().encode(JSON.stringify(k)).length>S9)throw new v("invalid_input",400);if(!(I instanceof Uint8Array)&&!(I instanceof ReadableStream)||I instanceof Uint8Array&&I.byteLength!==k.size)throw new v("invalid_input",400);let l=await k6(new TextEncoder().encode(`${X(J)}/${k.requestKey}`));return O(`request-${l}`,async()=>{await Y();let i=await c(l);if(i&&!lD.test(i.id))throw ID();let{stage:o,original:HD}=await f(k,I,b);try{let uD=pH({...k,...HD});{let ND=await $.registry.creationReplay?.({...k,storage:"local"},HD.sha256);if(ND)return structuredClone(ND.descriptor)}let _D=UD(L,"requests",`${l}.json`),MD=await H(_D).catch((ND)=>{if(H2(ND))return;throw ND});if(MD){if(MD.material!==uD||!lD.test(MD.id))throw new v("conflict",409);if(await p(MD.id))return await O(MD.id,async()=>x(await s(MD.id)))}let LD=MD?.id??crypto.randomUUID();if(!MD&&await p(LD))throw new v("conflict",409);if(!MD)await U(_D,{id:LD,material:uD});return await O("allocation",async()=>O(LD,async()=>{let ND=UD(W,k.path);await G(ND,!0,!0);let wD=w9(k.name),aD=o7(wD.stem),L2=LD.replaceAll("-","").toUpperCase().replaceAll("0","G").replaceAll("1","H"),ZD=new Set((await f6(ND)).map((GD)=>GD.toLowerCase())),t=L2.slice(0,8);for(let GD=8;GD<=L2.length;GD++){let $2=L2.slice(0,GD);if(ZD.has(`${aD} [${$2}]${wD.extension}`.toLowerCase())||ZD.has(`${aD} [${$2}]`.toLowerCase())){if(GD===L2.length)throw new v("conflict",409);t=L2.slice(0,GD+1)}}let QD={format:2,authority:J,descriptor:{id:LD,name:k.name,path:k.path,...HD,enrichments:{}},material:uD,bundle:!1,suffix:t,location:`${k.path}/${aD} [${t}]${wD.extension}`};return QD.registration={create:k},await a(QD,o,void 0,b)??x(await s(LD))}))}finally{await q(o)}})},async get(A){return O(A,async()=>{return await h(A),structuredClone((await $.registry.get(A)).descriptor)})},async placement(A){return O(A,async()=>{return await h(A),(await $.registry.get(A)).placement})},async preflightUpload(A){return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="local")await w(await s(A))})},async upload(A,I){return O(A,async()=>{{await h(A);let MD=await $.registry.get(A);if(MD.placement==="remote")return structuredClone(MD.descriptor)}let b=await s(A);if(!$.remote)throw new v("unsupported_context",400);await w(b),await Y();let k=await K(b.bundle?UD(W,b.location,E(b)):UD(W,b.location),b.descriptor.size),l=0,i=!1,o=async()=>{if(!i)i=!0,await k.close()},HD=i7("sha256"),uD=new ReadableStream({async pull(MD){try{if(I?.aborted)throw new v("unavailable",503,!0);let LD=new Uint8Array(262144),{bytesRead:ND}=await k.read(LD,0,LD.length,l);if(!ND){if(l!==b.descriptor.size||HD.digest("hex")!==b.descriptor.sha256)throw ID();await o(),MD.close()}else{if(l+=ND,l>b.descriptor.size)throw ID();HD.update(LD.subarray(0,ND)),MD.enqueue(LD.subarray(0,ND))}}catch(LD){await o(),MD.error(LD)}},cancel:o},{highWaterMark:0}),_D;try{await U(T(A),{...b,uploading:!0,cache:{descriptor:b.descriptor,location:b.location,bundle:b.bundle,suffix:b.suffix,objects:b.objects}}),_D=await $.remote.transfer(b.descriptor,uD,async(MD)=>{if(await Y(),!Object.hasOwn(b.descriptor.enrichments,MD))throw ID();return B(UD(W,b.location,MD),z0)},async()=>{if(await w(b),await Y(),!y6((await $.registry.get(A)).descriptor,b.descriptor))throw new v("conflict",409)},I)}finally{await uD.cancel().catch(()=>{}),await o()}if(!r7(_D,b.descriptor))throw ID();{let MD=await $.registry.get(A);if(MD.placement!=="remote"||!y6(MD.descriptor,_D))throw ID()}return await Y(),await U(T(A),{...b,descriptor:_D,placement:"remote",uploading:!1,objects:void 0,cache:{descriptor:b.descriptor,location:b.location,bundle:b.bundle,suffix:b.suffix,objects:b.objects}}),structuredClone(_D)})},async read(A,I){if(I!==void 0&&!_6(I))throw new v("invalid_input",400);return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="remote"){if(!$.remote)throw new v("unavailable",503,!0);return $.remote.read(A,I)}let b=await s(A);if(b.placement==="remote"){let LD=await $.remote.read(A,I);return await Y(),LD}await w(b);let k=I===void 0?b.descriptor:Object.hasOwn(b.descriptor.enrichments,I)?b.descriptor.enrichments[I]:void 0;if(!k)throw new v("invalid_input",400);let l=UD(W,b.location),i=await K(I===void 0?b.bundle?UD(l,E(b)):l:UD(l,I),k.size);try{await z(i,k),await Y()}catch(LD){throw await i.close(),LD}let o=0,HD=!1,uD=i7("sha256"),_D=async()=>{if(!HD)HD=!0,await i.close()},MD=new ReadableStream({async pull(LD){try{let ND=new Uint8Array(262144),{bytesRead:wD}=await i.read(ND,0,ND.length,o);if(!wD){if(o!==k.size||uD.digest("hex")!==k.sha256)throw ID();await _D(),LD.close()}else{if(o+=wD,o>k.size)throw ID();uD.update(ND.subarray(0,wD)),LD.enqueue(ND.subarray(0,wD))}}catch(ND){await _D(),LD.error(ND)}},cancel:_D},{highWaterMark:0});return new Response(MD,{headers:{"content-type":k.mediaType,"content-length":String(k.size),"content-disposition":`attachment; filename*=UTF-8''${encodeURIComponent(I??b.descriptor.name)}`,"cache-control":"no-store","x-content-type-options":"nosniff"}})})},async enrich(A,I,b){let k=L1(I,z0),l=b.slice();if(l.length!==k.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:k.size,receivedBytes:l.length});let i=await bH(k.name,l,k.mediaType);return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="remote"){if(!$.remote)throw new v("unavailable",503,!0);return $.remote.enrich(A,k,l)}let o=await s(A);if(o.placement==="remote"){let MD=await $.remote.enrich(A,k,l);return await Y(),MD}await w(o);let HD=Object.hasOwn(o.descriptor.enrichments,k.name)?o.descriptor.enrichments[k.name]:void 0;if(HD?.sha256===i.sha256&&HD.size===i.size)return await Y(),{name:k.name,...HD};if(k.replace===void 0?HD!==void 0:!HD||HD.sha256!==k.replace)throw new v("conflict",409);if(Object.keys(o.descriptor.enrichments).some((MD)=>MD!==k.name&&MD.toLowerCase()===k.name.toLowerCase()))throw new v("conflict",409);let uD={...o,bundle:!0,objects:void 0,location:`${o.descriptor.path}/${o7(w9(o.descriptor.name).stem)} [${o.suffix}]`,descriptor:{...o.descriptor,enrichments:{...o.descriptor.enrichments,[k.name]:i}}};uD.registration={expected:o.descriptor,enrichment:k},J2(uD.descriptor);let _D=UD(L,"staging",crypto.randomUUID());await j(_D);try{if(await G(_D,!0,!0),o.bundle)await _(o,UD(_D,E(o)));for(let MD of Object.keys(o.descriptor.enrichments))if(MD!==k.name)await N(UD(_D,MD),await B(UD(W,o.location,MD),z0));return await N(UD(_D,k.name),l),await F(_D),await a(uD,_D,o),await x(await s(A)),{name:k.name,...i}}finally{await q(_D)}})}}}X8();import{randomBytes as ck}from"node:crypto";import{constants as FF}from"node:fs";import{createServer as lk}from"node:http";import{Readable as sk}from"node:stream";import{chmod as nk,lstat as ik,mkdtemp as ak,open as UG,realpath as _4,rename as ok,rm as _F}from"node:fs/promises";import{basename as rk,dirname as tk,join as FG}from"node:path";import{tmpdir as ek}from"node:os";import{setTimeout as Dg}from"node:timers/promises";T8();function UX(D,Z){let $=(J)=>({...J,repositories:J.repositories.map(({published:Q,...X})=>X)});return JSON.stringify($(D))===JSON.stringify($(Z))}function S8(D){let Z=D,$=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;if(!Z||typeof Z!=="object"||Array.isArray(Z)||Object.keys(Z).sort().join(",")!=="deploymentId,repositories,routine,routineId,version,workspace,workspaceId"||typeof Z.workspace!=="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(Z.workspace)||typeof Z.routine!=="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(Z.routine)||![Z.workspaceId,Z.routineId].every((Q)=>typeof Q==="string"&&$.test(Q))||!(Z.deploymentId===null?typeof Z.version==="string"&&/^local:[0-9a-f]{64}$/.test(Z.version):typeof Z.deploymentId==="string"&&$.test(Z.deploymentId)&&typeof Z.version==="string"&&/^[0-9a-f]{40}$/.test(Z.version))||!Array.isArray(Z.repositories)||Z.repositories.length>64)throw Error("Invalid preparation authority");let J=Z.repositories.map((Q)=>{if(!Q||!["canWrite,target","canWrite,published,target"].includes(Object.keys(Q).sort().join(","))||typeof Q.canWrite!=="boolean")throw Error("Invalid preparation grant");let X=L9(Q.target);if(!N9(X)||X.workspaceId!==Z.workspaceId)throw Error("Invalid preparation target");if(Object.hasOwn(Q,"published")&&(!Q.published||Object.keys(Q.published).sort().join(",")!=="sourceVersion,version"||typeof Q.published.sourceVersion!=="string"||!/^[0-9a-f]{40}$/.test(Q.published.sourceVersion)||!u0(Q.published.version)))throw Error("Invalid preparation publication");return{target:X,canWrite:Q.canWrite,...Q.published?{published:{...Q.published}}:{}}});if(new Set(J.map((Q)=>Q.target.repository)).size!==J.length)throw Error("Ambiguous preparation repositories");return{workspace:Z.workspace,workspaceId:Z.workspaceId,routine:Z.routine,routineId:Z.routineId,deploymentId:Z.deploymentId,version:Z.version,repositories:J}}T1();import{createHash as Lk,randomBytes as $F,randomUUID as Nk}from"node:crypto";import{constants as GG}from"node:fs";import{link as _k,lstat as XZ,mkdir as Mk,open as aU,readdir as Ck,rename as Pk,unlink as oU}from"node:fs/promises";import{dirname as rU,join as j0,posix as J3}from"node:path";j8();function j1(D){if(!Array.isArray(D)||D.length<1||D.length>100)throw new r("invalid_query");let Z=j3(D);if(!Z.every(($)=>X2($)&&!/[\r\n]/.test($))||new Set(Z).size!==Z.length)throw new r("invalid_query");return Z}function lH(D){if(D===void 0)return{};try{u2(D)}catch{throw new r("invalid_query")}if(!D||typeof D!=="object"||Array.isArray(D)||![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).length)throw new r("invalid_query");return{}}T8();fW();W4();k0();k0();class e6 extends JD{component;constructor(D){super("Missing filing component");this.component=D}}var yW=(D)=>/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(D),Fb=(D)=>[...D.matchAll(/<([^>]+)>/g)].map((Z)=>Z[1]),w8=()=>{throw new JD("Unsupported or ambiguous creation identity")};function hW(D,Z,$,J=2){let Q=D.split(/(<[^>]+>)/).filter(Boolean),X=[],W=0,G=(Y,B,H)=>{if(++W>1e4)return w8();if(X.length>=J)return;if(Y===Q.length){if(B===Z.length)X.push(H);return}let K=Q[Y];if(!K.startsWith("<")){if(Z.startsWith(K,B))G(Y+1,B+K.length,H);return}let z=K.slice(1,-1),V=$[z];if(V!==void 0){if(Z.startsWith(V,B))G(Y+1,B+V.length,{...H,[z]:V});return}for(let _=B+1;_<=Z.length&&X.length<J;_++){let N=Z.slice(B,_);if(!yW(N))break;G(Y+1,_,{...H,[z]:N})}};return G(0,0,{}),X}function G4(D,Z){let $=Z.filter(({schema:J})=>{let Q=J.naming?J.ref:J.ref.replace("{id}","<id>");return hW(Q,D,{},1).length>0});if($.length!==1)return w8();return $[0]}function WU(D,Z){let $=G4(D.ref,Z),J=$.schema;if(l2(D.fields,J.fields),!J.naming&&J.path!=="{id}.md")return w8();let Q=J.naming?J.ref:J.ref.replace("{id}","<id>"),X=J.naming?Fb(`${J.naming.folder}/${J.naming.filename}`):["id"];if(X.some((z)=>z.length>128))return w8();let W={};for(let z of X){let V=J.fields.find((_)=>_.name===z);if(Z3(V)){let _=String(D.fields[z]);if(!yW(_))return w8();W[z]=_}else if(V&&V.kind!=="link")return w8()}let G=hW(Q,D.ref,W);if(!G.length)return w8();if(G.length===1)Object.assign(W,G[0]);for(let[z,V]of Object.entries(D.filing??{})){if(!X.includes(z)||Object.hasOwn(W,z)||!yW(V))return w8();W[z]=V}let Y=hW(Q,D.ref,W);if(Y.length!==1)return w8();Object.assign(W,Y[0]);for(let z of X)if(!Object.hasOwn(W,z))throw new e6(z);let B=(z)=>z.replace(/<([^>]+)>/g,(V,_)=>W[_]),H=J.naming?`${B(J.naming.folder.slice(J.naming.collection.length+1))}${J.naming.folder===J.naming.collection?"":"/"}${B(J.naming.filename)}.md`:`${W.id}.md`;if(p$(J,H,D.fields)!==D.ref)return w8();let K=`${J.naming?.collection??$.name}/${H}`;return{ref:D.ref,path:K,fields:D.fields,schema:J,...D.body===void 0?{}:{body:D.body}}}Y0();b9();import{createHash as Lb}from"node:crypto";function f1(D){return typeof D==="string"&&D===new TextDecoder("utf-8",{ignoreBOM:!0}).decode(new TextEncoder().encode(D))}var GU=8388608;k0();var y1=4;function l$(D){if(typeof D!=="string")return;let Z=/^records-index-v3:([0-9a-f]{64})$/.exec(D);if(Z)return{format:"records-index-v3",hash:Z[1]};let $=/^records-index:4:([0-9a-f]{64})$/.exec(D);return $?{format:y1,hash:$[1]}:void 0}function Nb(D,Z){if(!/^[0-9a-f]{64}$/.test(Z))return g0();return`${D===y1?`records-index:${D}`:D}:${Z}`}var D5=41943040;var _b=/^[0-9a-f]{40}$/;var Y4=(D,Z)=>D<Z?-1:D>Z?1:0,g0=()=>{throw new JD("Invalid or incompatible index artifact")};function Mb(D,Z){return Nb(Z,Lb("sha256").update(D).digest("hex"))}function B4(D){if(!D||typeof D!=="object"||Array.isArray(D))return g0();return D}function mW(D,Z){if(Object.keys(D).sort(Y4).join(",")!==Z.sort(Y4).join(","))g0()}function Cb(D){let Z=B4(D);if(mW(Z,["workspaceId","repository"]),typeof Z.workspaceId!=="string"||!/^[a-zA-Z0-9_-]{1,128}$/.test(Z.workspaceId)||!Q2(Z.repository))g0()}function YU(D,Z){Cb(Z.binding);let $=l$(Z.identity);if(D.byteLength>D5||!_b.test(Z.sourceVersion)||!$||Mb(D,$.format)!==Z.identity)return g0();let J;try{J=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(D))}catch{return g0()}let Q=B4(J);mW(Q,$.format===y1?["formatVersion","binding","sourceVersion","collections"]:["format","binding","sourceVersion","collections"]);let X=B4(Q.binding);if(mW(X,["workspaceId","repository"]),($.format===y1?Q.formatVersion:Q.format)!==$.format||Q.sourceVersion!==Z.sourceVersion||X.workspaceId!==Z.binding.workspaceId||X.repository!==Z.binding.repository||!Array.isArray(Q.collections)||!Q.collections.length)return g0();return J}function uW(D){if(D.naming)return D.naming.collection;if(!D.ref.endsWith("/{id}"))return g0();return D.ref.slice(0,-5)}function vW(D,Z,$){if(D===null)return null;if(Z.many){if(!Array.isArray(D))return g0();return D.map((J)=>vW(J,{...Z,many:!1},$))}if(Z.kind==="link"){if(typeof D!=="string")return g0();if($){if(!q1(D))return g0();return`[[${D}]]`}if(!x9(D))return g0();return D.slice(2,-2)}if(Z.kind==="object")return $5(B4(D),Z.fields,$);if(Z.kind==="map")return Object.fromEntries(Object.entries(B4(D)).map(([J,Q])=>[J,vW(Q,Z.value,$)]));return D}function $5(D,Z,$){let J=new Map(Z.map((Q)=>[Q.name,Q]));return Object.fromEntries(Object.entries(D).map(([Q,X])=>{let W=J.get(Q);if(!W)throw new y2("unknown",Q);try{return[Q,vW(X,W,$)]}catch(G){if(G instanceof JD&&!(G instanceof y2))throw new y2("invalid",Q,o6(W));throw G}}))}function Pb(D,Z){let $=new Set([D.$ref.toLowerCase()]),J=(Q,X)=>{if(Q===null)return;if(X.many)for(let W of Q)J(W,{...X,many:!1});else if(X.kind==="object"){for(let W of X.fields)if(Object.hasOwn(Q,W.name))J(Q[W.name],W)}else if(X.kind==="map")for(let[W,G]of Object.entries(Q))J(X.key.kind==="integer"?Number(W):W,X.key),J(G,X.value);else $.add(String(Q).toLowerCase())};for(let Q of Z.fields)if(Object.hasOwn(D,Q.name))J(D[Q.name],Q);return[...$].sort(Y4)}function s$(D,Z,$,J=y1){let Q=new Map,X=new Set,W=[...D.schemas].map(([B,H])=>{let K=uW(H);if(X.has(K))throw new JD(`Duplicate logical collection name: ${K}`);X.add(K);let z=[];return Q.set(B,z),{name:K,schema:H,records:z}}).sort((B,H)=>Y4(B.name,H.name));for(let B of D.records.values()){let H=Q.get(B.collectionPath);if(!H)return g0();H.push({...$5(B.fields,B.schema.fields,!1),$ref:B.ref,$version:B.version,$body:B.body,...J===y1?{$path:B.path}:{}})}for(let{records:B}of W)B.sort((H,K)=>Y4(H.$ref,K.$ref));let G={binding:Z,sourceVersion:$,collections:W.map((B)=>({...B,searchValues:B.records.map((H)=>Pb(H,B.schema))}))};return J===y1?{formatVersion:J,...G}:{format:J,...G}}k0();function dW(D,Z=new Set,$=0){if(D===null||typeof D==="string"||typeof D==="boolean"||typeof D==="number"&&Number.isFinite(D))return D;if(!D||typeof D!=="object"||Z.has(D)||$>32)throw new r("invalid_query");Z.add(D);try{if(Array.isArray(D))return j3(D).map((J)=>dW(J,Z,$+1));return Object.fromEntries(Object.entries(u2(D)).map(([J,Q])=>[J,dW(Q.value,Z,$+1)]))}finally{Z.delete(D)}}function n$(D,Z){let $=()=>{throw new r("invalid_query")};try{let J=u2(Z),Q=J.maxRecords?.value;if(Object.keys(J).join(",")!=="maxRecords"||!Number.isSafeInteger(Q)||Q<1)return $();let X=dW(D),W=u2(X);if(Object.keys(W).length<1||Object.keys(W).length>16)return $();for(let G of Object.values(W)){let Y=u2(G.value);if(Y.$&&Object.hasOwn(u2(Y.$.value),"after"))return $()}return{query:X,maxRecords:Q}}catch{return $()}}b9();k0();b9();var BU=["$gt","$gte","$lt","$lte"],pW=(D,Z)=>D<Z?-1:D>Z?1:0,V2=(D)=>{throw new JD(`Invalid Records query: ${D}`)};function m3(D){if(!D||typeof D!=="object"||Array.isArray(D)||![Object.prototype,null].includes(Object.getPrototypeOf(D)))return V2("expected a mapping");return D}function cW(D){let{optional:Z,style:$,...J}=D;if(J.kind==="object")return{...J,fields:J.fields.map(K4)};if(J.kind==="map")return{...J,key:cW(J.key),value:cW(J.value)};return structuredClone(J)}function K4(D){return{...cW(D),name:D.name}}function H4({name:D,schema:Z}){return{name:D,type:Z.type,...Z.description===void 0?{}:{description:Z.description}}}function KU(D,Z){if(D==="$ref")return{name:D,kind:"string",nullable:!1,many:!1};let $=Z.fields.find((J)=>J.name===D);if(!$||$.many||$.kind==="object"||$.kind==="map")return V2(`ineligible scalar field: ${D}`);return $}function HU(D,Z){if(Z.kind==="link"||Z.name==="$ref"){if(D!==null&&!(Z.kind==="link"?q1(D):X2(D)))return V2(`invalid reference: ${Z.name}`)}return l2({[Z.name]:Z.kind==="link"&&typeof D==="string"?`[[${D}]]`:D},[{...Z,optional:!1}]),D}function Ob(D){let Z=Object.entries(m3(D));return Tb(Z),Z}function Tb(D){if(D.length<1||D.length>16)return V2("expected 1–16 collections");let Z=0,$=(J,Q)=>{if(++Z>256)return V2("too many selection nodes");let X=m3(J);for(let[W,G]of Object.entries(X)){if(W==="$")continue;if(Q>=4)return V2("too many link levels");$(G,Q+1)}};for(let[,J]of D)$(J,0)}function zU(D,Z,$,J=0,Q=!1){let X=m3(D),W=Object.hasOwn(X,"$")?m3(X.$):{},G=J===0?["where","fields","order","limit","count","after"]:Q?["where","fields","order","limit"]:["where","fields"];if(Object.keys(W).some((V)=>!G.includes(V)))return V2("unsupported option");let Y=Object.hasOwn(W,"fields")?W.fields:Z.fields.map((V)=>V.name);if(!Array.isArray(Y)||Y.some((V)=>typeof V!=="string"||!["$ref","$version"].includes(V)&&!Z.fields.some((_)=>_.name===V))||new Set(Y).size!==Y.length)return V2("invalid projection");let B=[];if(Object.hasOwn(W,"where"))for(let[V,_]of Object.entries(m3(W.where))){let N=KU(V,Z),F=[_];if(_!==null&&typeof _==="object"){let M=m3(_);if(!Object.hasOwn(M,"$in")){let L=Object.keys(M);if(L.length===0||L.some((P)=>!BU.includes(P))||Object.hasOwn(M,"$gt")&&Object.hasOwn(M,"$gte")||Object.hasOwn(M,"$lt")&&Object.hasOwn(M,"$lte"))return V2("invalid bounds");if(N.name==="$ref"||!["integer","number","date","datetime"].includes(N.kind))return V2(`ineligible range field: ${V}`);let C=BU.filter((P)=>Object.hasOwn(M,P)).map((P)=>{let j=M[P];if(j===null)return V2("null bound");return[P,HU(j,N)]});B.push([V,{bounds:C}]);continue}if(Object.keys(M).length!==1||!Object.hasOwn(M,"$in")||!Array.isArray(M.$in)||M.$in.length<1||M.$in.length>100)return V2("invalid $in");F=M.$in}let U=F.map((M)=>HU(M,N));if(new Set(U).size!==U.length)return V2("duplicate $in value");B.push([V,U])}let H={field:"$ref",direction:"asc"};if(Object.hasOwn(W,"order")){let V=Object.entries(m3(W.order));if(V.length!==1)return V2("order requires one field");let[_,N]=V[0];if(KU(_,Z),N!=="asc"&&N!=="desc")return V2("invalid order direction");H={field:_,direction:N}}let K=Object.hasOwn(W,"limit")?W.limit:100;if(typeof K!=="number"||!Number.isInteger(K)||K<1||K>(J===0?500:100))return V2("invalid limit");if(Object.hasOwn(W,"count")&&typeof W.count!=="boolean")return V2("invalid count");if(Object.hasOwn(W,"after")&&(typeof W.after!=="string"||W.after.length===0))return V2("invalid cursor");let z=[];for(let[V,_]of Object.entries(X)){if(V==="$")continue;let N=Z.fields.find((U)=>U.name===V);if(!N||N.kind!=="link")return V2(`ineligible link field: ${V}`);if(J>=4)return V2("too many link levels");let F=new Map(N.to.flatMap((U)=>{return($.get(U)??V2(`unknown link target type: ${U}`)).map((L)=>[L.name,zU(_,L.schema,$,J+1,N.many)])}));z.push({name:V,many:N.many,targets:F})}return{fields:Y,conditions:B,order:H,limit:K,count:W.count===!0,...Object.hasOwn(W,"after")?{after:W.after}:{},explicitOrder:Object.hasOwn(W,"order"),explicitLimit:Object.hasOwn(W,"limit"),links:z}}function VU(D,Z=!0,$=!1){return{fields:D.fields,conditions:[...D.conditions].sort(([J],[Q])=>pW(J,Q)),order:Z||$&&D.explicitOrder?D.order:null,limit:Z||$&&D.explicitLimit?D.limit:null,count:D.count,links:[...D.links].sort((J,Q)=>pW(J.name,Q.name)).map((J)=>({name:J.name,many:J.many,targets:[...J.targets].sort(([Q],[X])=>pW(Q,X)).map(([Q,X])=>[Q,VU(X,!1,J.many)])}))}}function i$(D,Z){let $=Ob(D),J=new Map(Z.map((X)=>[X.name,X])),Q=new Map;for(let X of Z){let W=Q.get(X.schema.type)??[];W.push(X),Q.set(X.schema.type,W)}return $.map(([X,W])=>{let G=J.get(X)??V2(`unknown collection: ${X}`);return{name:X,selection:zU(W,G.schema,Q)}})}function UU(D,Z,$){return JSON.stringify({...D,collection:Z,selection:VU($)})}function FU(D,Z,$){let J;try{J=m3(D)}catch{return V2("invalid cursor")}let{position:Q,ref:X}=J;if(Object.keys(J).length!==4||J.format!==1||J.binding!==Z||typeof Q!=="number"||!Number.isSafeInteger(Q)||Q<=0||Q%$!==0||typeof X!=="string"||!X2(X))return V2("incompatible cursor");return{position:Q,ref:X}}var h1=()=>{throw new r("invalid_query")};function z4(D,Z){if(!W8(D))return h1();let $=[...D.trim()].length;if($<1||$>256)return h1();if(Z===void 0)return{query:D};let J=u2(Z);if(Object.keys(J).some((X)=>!["collections","limit"].includes(X)))return h1();let Q={};if(Object.hasOwn(J,"collections")){let X=J.collections.value;if(!Array.isArray(X)||X.length<1||X.length>16||Reflect.ownKeys(X).length!==X.length+1)return h1();let W=[];for(let G=0;G<X.length;G++){let Y=Object.getOwnPropertyDescriptor(X,String(G));if(!Y?.enumerable||!Object.hasOwn(Y,"value")||!W8(Y.value))return h1();W.push(Y.value)}if(new Set(W).size!==W.length)return h1();Q.collections=W}if(Object.hasOwn(J,"limit")){let X=J.limit.value;if(!Number.isInteger(X)||X<1||X>100)return h1();Q.limit=X}return{query:D,options:Q}}var jb=()=>{throw new r("invalid_query")};function a$(D,Z,$){let J=z4(D,Z),Q=J.query.trim(),X=$.map((Y)=>Y.name),W=X,G=20;if(J.options?.collections){if(J.options.collections.some((Y)=>!X.includes(Y)))return jb();W=J.options.collections}return G=J.options?.limit??G,{terms:[...new Set(Q.toLowerCase().split(/\s+/u))],collections:W,limit:G}}function LU(D,Z,$){if(D.collections.some((Q)=>!Q.searchValues||Q.searchValues.length!==Q.records.length))throw new r("unavailable",!0);let J=D.collections.filter((Q)=>$.collections.includes(Q.name)).flatMap((Q)=>Q.records.flatMap((X,W)=>{let G=Q.searchValues[W];if(!$.terms.every((Y)=>G.some((B)=>B.includes(Y))))return[];return[{collection:Q.name,record:X,score:$.terms.filter((Y)=>G.includes(Y)).length}]}));return J.sort((Q,X)=>X.score-Q.score||(Q.record.$ref<X.record.$ref?-1:Q.record.$ref>X.record.$ref?1:0)),{$meta:{version:Z},matches:J.slice(0,$.limit).map(({collection:Q,record:{$body:X,$path:W,...G}})=>({collection:Q,record:structuredClone(G)}))}}var o$=(D,Z)=>D<Z?-1:D>Z?1:0,n0=(D)=>{throw new JD(`Invalid Records query: ${D}`)};function qb(D,Z,$,J){let{position:Q,ref:X}=FU(D,Z,J);if(Q>=$.length||X!==$[Q-1]?.$ref)return n0("incompatible cursor");return Q}function lW(D,Z){return Z.conditions.every(([$,J])=>{if(!Object.hasOwn(D,$))return!1;let Q=D[$];if(Array.isArray(J))return J.some((X)=>X===Q);if(Q===null)return!1;return J.bounds.every(([X,W])=>{let G=typeof Q==="number"&&typeof W==="number"?Q-W:o$(Q,W);switch(X){case"$gt":return G>0;case"$gte":return G>=0;case"$lt":return G<0;case"$lte":return G<=0}})})}function NU(D,Z,{field:$,direction:J}){let Q=D[$],X=Z[$],W=Q===null||Q===void 0,G=X===null||X===void 0,Y=0;if(W!==G)return W?1:-1;if(!W&&!G){if(Y=typeof Q==="number"&&typeof X==="number"?Q-X:typeof Q==="boolean"&&typeof X==="boolean"?Number(Q)-Number(X):o$(Q,X),J==="desc")Y=-Y}return Y||o$(D.$ref,Z.$ref)}function _U(D){return sW(D.artifact).withContext(D)}function sW(D){let{workspaceId:Z,repository:$}=D.binding,J=new Map(D.collections.map((X)=>[X.name,X])),Q=new Map;for(let X of J.values())for(let W of X.records)Q.set(W.$ref,{record:W,collection:X.name});return{withContext(X){return Ab(X,{workspaceId:Z,repository:$},J,Q,D)}}}function Ab({version:D,identity:Z,cursorCodec:$},{workspaceId:J,repository:Q},X,W,G){let Y=(K)=>X.get(K)??n0(`unknown collection: ${K}`);function*B(K,z){let V=i$(K,[...X.values()]);if(z!==void 0){if(V.reduce((L,{name:C,selection:P})=>L+X.get(C).records.filter((j)=>lW(j,P)).length,0)>z)throw new r("capacity",!1,void 0,void 0,{code:"record_limit_exceeded",maxRecords:z,collections:V.map((L)=>L.name)})}let _=0,N=(M,L,C)=>{if(++_>2000)return n0("too many returned Record occurrences");let P=Object.fromEntries(["$ref","$version",...L.fields.filter((j)=>!["$ref","$version"].includes(j))].filter((j)=>Object.hasOwn(M,j)).map((j)=>[j,structuredClone(M[j])]));if(C!==void 0)P.$fragment=C;for(let j of L.links){if(!Object.hasOwn(M,j.name))continue;let q=M[j.name],O;if(q===null)O=null;else{let R=(j.many?q:[q]).map((y)=>{let{ref:d,fragment:u}=q1(y)??n0("invalid stored link"),S=W.get(d)??n0("unresolved stored link"),w=j.targets.get(S.collection)??n0("incompatible stored link");return{...S,selection:w,fragment:u}}).filter(({record:y,selection:d})=>lW(y,d)),g=j.targets.values().next().value;if(g.explicitOrder)R.sort((y,d)=>NU(y.record,d.record,g.order));if(j.many&&!g.explicitLimit&&R.length>100)return n0("too many matching linked Records");if(g.explicitLimit)R=R.slice(0,g.limit);let E=R.map(({record:y,selection:d,fragment:u})=>N(y,d,u));O=j.many?E:E[0]??null}Object.defineProperty(P,j.name,{value:O,enumerable:!0,writable:!0,configurable:!0})}return P},F={version:D,collections:{}},U=[];for(let{name:M,selection:L}of V){let C=X.get(M).records.filter((R)=>lW(R,L)).sort((R,g)=>NU(R,g,L.order)),P=UU({workspaceId:J,repository:Q,identity:Z,version:D},M,L),j=L.after===void 0?0:qb(yield{operation:"open",token:L.after},P,C,L.limit),q=z===void 0?Math.min(j+L.limit,C.length):C.length,O=C.slice(j,q).map((R,g)=>{if(z!==void 0&&g%L.limit===0)_=0;return N(R,L)}),T=L.count?{count:C.length}:{};if(z===void 0&&q<C.length){let R=yield{operation:"seal",payload:{format:1,binding:P,position:q,ref:C[q-1].$ref}};if(typeof R!=="string"||R.length===0)return n0("invalid sealed cursor");T.next=R}if(Object.keys(T).length)Object.defineProperty(F.collections,M,{value:T,enumerable:!0,writable:!0,configurable:!0});U.push([M,O])}return{...Object.fromEntries(U),$meta:F}}let H=(K,z=$)=>{try{return K.operation==="open"?z.open(K.token):z.seal(K.payload)}catch{return n0("invalid cursor")}};return{collections:{list(){return[...X.values()].sort((K,z)=>o$(K.name,z.name)).map(H4)},schema(K){let z=Y(K);return{...H4(z),fields:z.schema.fields.map(K4)}}},records:{read(K,z){let V=j1(K),_={$meta:{version:D},records:V.map((N)=>{let F=W.get(N);if(!F)return null;if(z?.body&&typeof F.record.$body!=="string")throw new r("unavailable",!0);let{$body:U,$path:M,...L}=F.record;return structuredClone(z?.body?{...L,$body:U}:L)})};if(z?.body&&new TextEncoder().encode(JSON.stringify(_)).byteLength>GU)throw new r("request_too_large");return _},search(K,z){return LU(G,D,a$(K,z,[...X.values()]))},all(K,z){let V=n$(K,z),_=B(V.query,V.maxRecords).next();if(!_.done)return n0("all cannot continue a cursor");return _.value},query(K){let z=B(K),V=z.next();while(!V.done){let _=H(V.value);if(_ instanceof Promise)return n0("asynchronous cursor codec requires asynchronous selection");V=z.next(_)}return V.value},async queryAsync(K,z=$){let V=B(K),_=V.next();while(!_.done){let N;try{N=await H(_.value,z)}catch{return n0("invalid cursor")}_=V.next(N)}return _.value}}}}var v3=()=>Error("Invalid Records cursor");function nW(D){let Z="";for(let $ of D)Z+=String.fromCharCode($);return btoa(Z).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function MU(D){if(!/^[A-Za-z0-9_-]+$/.test(D))throw v3();let Z=Uint8Array.from(atob(D.replace(/-/g,"+").replace(/_/g,"/")),($)=>$.charCodeAt(0));if(nW(Z)!==D)throw v3();return Z}function CU(D){return Ib("records-cursor-v1",D)}function Ib(D,Z){let $=Z.active,J=new Map(Z.keys),Q=(X,W)=>{let G=J.get(X);if(!/^[A-Za-z0-9_-]{1,64}$/.test(X)||!G||G.type!=="secret"||G.algorithm.name!=="AES-GCM"||G.algorithm.length!==256||!G.usages.includes(W))throw v3();return G};return Q($,"encrypt"),Q($,"decrypt"),{async seal(X){try{let W=crypto.getRandomValues(new Uint8Array(12)),G=`${D}.${$}`,Y=new TextEncoder().encode(JSON.stringify(X)),B=await crypto.subtle.encrypt({name:"AES-GCM",iv:W,additionalData:new TextEncoder().encode(G),tagLength:128},Q($,"encrypt"),Y);return`${G}.${nW(W)}.${nW(new Uint8Array(B))}`}catch{throw v3()}},async open(X){try{if(typeof X!=="string")throw v3();let W=X.split(".");if(W.length!==4||W[0]!==D)throw v3();let G=W[1],Y=MU(W[2]),B=MU(W[3]);if(Y.byteLength!==12||B.byteLength<16)throw v3();let H=await crypto.subtle.decrypt({name:"AES-GCM",iv:Y,additionalData:new TextEncoder().encode(`${D}.${G}`),tagLength:128},Q(G,"decrypt"),B);return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(H))}catch{throw v3()}}}}import{isDeepStrictEqual as Eb}from"node:util";j8();Y0();T3();var PU=262144,V4=33554432,s2=()=>{throw new r("invalid_change",!1,"unapplied")};function x8(D){try{return u2(D),D}catch{return s2()}}function r$(D,Z=new Set,$=0){if(D===null||typeof D==="string"||typeof D==="boolean"||typeof D==="number"&&Number.isFinite(D))return D;if(!D||typeof D!=="object"||Z.has(D)||$>32)return s2();Z.add(D);try{if(Array.isArray(D)){if(D.length>1e5||Object.keys(D).length!==D.length||Object.getOwnPropertySymbols(D).length)return s2();return Array.from(D,(J)=>r$(J,Z,$+1))}return Object.fromEntries(Object.entries(x8(D)).map(([J,Q])=>{if(["__proto__","constructor","prototype"].includes(J))return s2();return[J,r$(Q,Z,$+1)]}))}finally{Z.delete(D)}}function OU(D){let Z=x8(D);if(!X2(Z.$ref)||typeof Z.$version!=="string"||!Z.$version.length||Z.$version.length>512)return s2();return{ref:Z.$ref,expectedVersion:Z.$version}}function Sb(D,Z){let $=OU(D),J=x8(Z),{$body:Q,...X}=J,W=Object.hasOwn(J,"$body");if(W&&!f1(Q)||!Object.keys(X).length&&!W||Object.keys(X).some((G)=>G.startsWith("$")||["id","type"].includes(G)))return s2();return{...$,set:r$(X),...W?{body:Q}:{}}}function TU(D,Z,$=!0){if(!Array.isArray(D)||!$&&!D.length||D.length>1e4)return s2();let J=D.map((Q)=>{let X=x8(Q);if(Object.keys(X).filter((G)=>!Z||G!=="body").sort().join(",")!==(Z?"expectedVersion,ref,set":"expectedVersion,ref"))return s2();let W={$ref:X.ref,$version:X.expectedVersion};if(Z&&Object.keys(x8(X.set)).some((G)=>G.startsWith("$")))return s2();return Z?Sb(W,{...x8(X.set),...Object.hasOwn(X,"body")?{$body:X.body}:{}}):OU(W)});if(new Set(J.map((Q)=>Q.ref)).size!==J.length)return s2();return J}function iW(D,Z=!1){return TU(D,!0,Z)}function Rb(D){let Z=x8(D);if(!X2(Z.$ref)||Object.keys(Z).some((Y)=>Y.startsWith("$")&&!["$ref","$filing","$body"].includes(Y)))return s2();let{$ref:$,$filing:J,$body:Q,...X}=Z,W=Object.hasOwn(Z,"$body");if(W&&!f1(Q))return s2();let G;if(J!==void 0){let Y=x8(J);if(Object.entries(Y).some(([B,H])=>!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(B)||["constructor","prototype"].includes(B)||typeof H!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(H)))return s2();G={...Y}}return{ref:$,fields:r$(X),...G?{filing:G}:{},...W?{body:Q}:{}}}function aW(D,Z=[],$=[]){let J=iW(D,!0);if(!Array.isArray(Z)||Z.length>1e4)return s2();let Q=Z.map((G)=>{let Y=x8(G);if(Object.keys(Y).some((H)=>!["ref","fields","filing","body"].includes(H))||!Object.hasOwn(Y,"ref")||!Object.hasOwn(Y,"fields"))return s2();let B=x8(Y.fields);if(Object.keys(B).some((H)=>H.startsWith("$")))return s2();return Rb({...B,$ref:Y.ref,...Object.hasOwn(Y,"filing")?{$filing:Y.filing}:{},...Object.hasOwn(Y,"body")?{$body:Y.body}:{}})}),X=TU($,!1),W=[...J,...Q,...X].map((G)=>G.ref);if(!W.length||W.length>1e4||new Set(W).size!==W.length)return s2();return{updates:J,creates:Q,deletes:X}}function t$(D,Z=PU){if(new TextEncoder().encode(JSON.stringify(D)).byteLength>Z)throw new r("request_too_large",!1,"unapplied")}function oW(D,Z){let $={400:["invalid_query","invalid_change"],401:["unauthenticated"],403:["access_denied"],409:["conflict","apply_pending"],413:["request_too_large"],429:["capacity"],503:["unavailable","apply_pending"]},J=Z&&typeof Z==="object"&&"error"in Z?Z.error:void 0,Q=J&&typeof J==="object"?J:void 0,X=$[D]?.find((Y)=>Y===Q?.code)??"unavailable",W=["unapplied","uncertain","applied"].includes(String(Q?.effect))?Q.effect:void 0,G;try{G=Q?.detail===void 0?void 0:C9(Q.detail)}catch{}if(G&&"reason"in G&&X!=="invalid_change")G=void 0;return A6(new r(X,typeof Q?.retryable==="boolean"?Q.retryable:["capacity","unavailable","apply_pending"].includes(X),X==="conflict"?"unapplied":W,X==="invalid_change"&&typeof Q?.component==="string"&&/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(Q.component)?Q.component:void 0,G),Q?.message,Q?.detail)}function Z5(D,Z="hosted"){if(!D||typeof D!=="object"||Array.isArray(D))throw new r("invalid_query");let $=D;if($.operation==="records.all"){if(Object.keys($).sort().join(",")!=="maxRecords,operation,query,repository"||!Q2($.repository))throw new r("invalid_query");let X=n$($.query,{maxRecords:$.maxRecords});return{repository:$.repository,operation:$.operation,...X}}if($.operation==="records.read"){let X=u2(D);if(Object.keys(X).filter((B)=>B!=="options").sort().join(",")!=="operation,refs,repository"||!Q2($.repository))throw new r("invalid_query");let W=j1($.refs);if(Object.hasOwn($,"options")&&$.options===void 0)throw new r("invalid_query");let G=lH($.options),Y={repository:$.repository,operation:$.operation,refs:W,...$.options===void 0?{}:{options:G}};return t$(Y),Y}if($.operation==="history.list"||$.operation==="history.at"||$.operation==="history.changes"){let X=$.operation==="history.at"?["repository","operation","instant"]:["repository","operation","options"];if(![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).some((W)=>typeof W!=="string"||!X.includes(W)||!Object.getOwnPropertyDescriptor(D,W)?.enumerable||!Object.hasOwn(Object.getOwnPropertyDescriptor(D,W),"value"))||!["repository","operation"].every((W)=>Object.hasOwn(D,W))||!Q2($.repository))throw new r("invalid_query");if($.operation==="history.changes"){if(Object.hasOwn(D,"options")&&$.options===void 0)throw new r("invalid_query");return{repository:$.repository,operation:$.operation,options:HH($.options)}}return $.operation==="history.list"?{repository:$.repository,operation:$.operation,options:KH($.options)}:{repository:$.repository,operation:$.operation,instant:f7($.instant)}}if($.operation==="records.search"){if(![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).some((X)=>typeof X!=="string"||!["repository","operation","query","options"].includes(X)||!Object.getOwnPropertyDescriptor(D,X)?.enumerable||!Object.hasOwn(Object.getOwnPropertyDescriptor(D,X),"value"))||!["repository","operation","query"].every((X)=>Object.hasOwn(D,X))||!Q2($.repository))throw new r("invalid_query");return{repository:$.repository,operation:$.operation,...z4($.query,$.options)}}let J=$.operation==="collections.list"?"operation,repository":$.operation==="collections.schema"?"name,operation,repository":$.operation==="records.query"?"operation,query,repository":$.operation==="changes.validate"?"operation,repository,updates":$.operation==="changes.apply"?"applyId,operation,repository,updates":"",Q=Object.keys($).filter((X)=>!["creates","deletes"].includes(X)||!["changes.validate","changes.apply"].includes($.operation)).sort().join(",");if(!J||Q!==J||!Q2($.repository)||$.operation==="collections.schema"&&(typeof $.name!=="string"||$.name.length>128||!$.name.length))throw new r("invalid_query");if($.operation==="changes.validate"||$.operation==="changes.apply"){if($.operation==="changes.apply"&&(typeof $.applyId!=="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test($.applyId)))return s2();t$($,Z==="local"?V4:PU);let X=aW($.updates,$.creates===void 0?[]:$.creates,$.deletes===void 0?[]:$.deletes);return{...$,updates:X.updates,...$.creates!==void 0?{creates:X.creates}:{},...$.deletes!==void 0?{deletes:X.deletes}:{}}}return $}X8();j8();Y0();function jU(D){let Z=Q8(D);if(!Z||Array.isArray(Z)||typeof Z!=="object"||Object.keys(Z).sort().join(",")!=="records,repository"||!Q2(Z.repository)||!Array.isArray(Z.records)||!Z.records.length||Z.records.length>1e4||new Set(Z.records.map(($)=>$?.ref)).size!==Z.records.length)throw new O3("Invalid record deletion batch");for(let $ of Z.records)if(!$||Array.isArray($)||typeof $!=="object"||Object.keys($).sort().join(",")!=="expectedVersion,ref"||!X2($.ref)||typeof $.expectedVersion!=="string"||!/^record-v1:[0-9a-f]{64}$/.test($.expectedVersion))throw new O3("Invalid record deletion");return structuredClone(Z)}k0();function rW(D,Z){return D&&Z?.naming?`${D}/${Z.naming.collection}/_schema.yaml`:void 0}function qU(D,Z,$){if(D.type!=="source"||D.fields.some((Q)=>Q.name==="media_type"))return!1;let J=(Q)=>$&&Object.hasOwn($,Q)?$[Q]:Z[Q];return J("type")==="source"&&J("kind")==="file"&&(Object.hasOwn(Z,"media_type")||!!$&&Object.hasOwn($,"media_type"))}function tW(D,Z,$,J=!1){try{return Z()}catch(Q){throw Q instanceof y2?Q.atRecord(D,$,J):Q}}function wb(D,Z){if(!D.length)return[];jU({repository:"general",records:D});let $=new Set(D.map((X)=>X.ref)),J=D.map((X)=>{let W=Z.records.get(X.ref);if(!W||!Z.types.has(X.ref))throw new JD("Record is missing or outside repository scope");if(W.version!==X.expectedVersion)throw new JD("Reviewed record version is stale");return W});if((Z.incomingReferences??[...Z.records.values()].flatMap((X)=>$.has(X.ref)?[]:r6(X.fields,X.schema.fields).filter((W)=>$.has(W)).map((W)=>({from:X.ref,to:W})))).length)throw new JD("Record is referenced outside the deletion batch");return J}function xb(D,Z,$=!1){if(!D.length||D.length>1e4||new Set(D.map((J)=>J.ref)).size!==D.length)throw new JD("Invalid record update batch");return D.map((J)=>{let Q=Z.records.get(J.ref);return tW(J.ref,()=>{if(!Q||!Z.types.has(J.ref))throw new JD("Record is missing or outside repository scope");if(Q.version!==J.expectedVersion)throw new JD("Reviewed record version is stale");if(Object.hasOwn(J,"body")&&!f1(J.body))throw new JD("Invalid Record body");let X=Q.schema.naming?[...`${Q.schema.naming.folder}/${Q.schema.naming.filename}`.matchAll(/<([^>]+)>/g)].map((B)=>B[1]).filter((B)=>Z3(Q.schema.fields.find((H)=>H.name===B))):[],W=Object.keys(J.set).find((B)=>!Q.schema.fields.some((H)=>H.name===B));if(W)throw new y2("unknown",W);if(!Object.keys(J.set).length&&!Object.hasOwn(J,"body")||Object.keys(J.set).some((B)=>B.startsWith("$"))||"id"in J.set||"type"in J.set||X.some((B)=>Object.hasOwn(J.set,B)&&!Eb(J.set[B],Q.fields[B])))throw new JD("Unknown or immutable record field");let G=$?$5(J.set,Q.schema.fields,!0):structuredClone(J.set),Y={...Q.fields,...G};return l2(Y,Q.schema.fields,(B)=>Z.types.get(B)),{record:Q,set:G,fields:Y,...Object.hasOwn(J,"body")?{body:J.body}:{}}},rW(Z.repository,Q?.schema),!!Q&&qU(Q.schema,Q.fields,J.set))})}function bb(D){let Z=new Map,$=new Map;for(let J of D.collections)for(let Q of J.records){let{$ref:X,$version:W,$body:G,$path:Y,...B}=Q;Z.set(X,{ref:X,version:W,schema:J.schema,fields:$5(B,J.schema.fields,!0)}),$.set(X,J.schema.type)}return{records:Z,types:$,repository:D.binding.repository}}function AU(D,Z,$=[],J=[],Q={}){let X=!Z.length&&!$.length&&J.length?{updates:iW(Z,!0),creates:[]}:aW(Z,$),W=[...X.updates,...X.creates,...J].map((z)=>z.ref);if(W.length>1e4||new Set(W).size!==W.length)throw new JD("Invalid record change batch");let G=bb(D),Y=new Map(Q.types??G.types),B={records:G.records,types:Y,repository:G.repository,...Q.incomingReferences===void 0?{}:{incomingReferences:Q.incomingReferences}},H=wb(J,B);for(let z of H)Y.delete(z.ref);return{creates:kb(X.creates,D.collections,Y,D.binding.repository),updates:X.updates.length?xb(X.updates,{...B,types:Y},!0):[],deletes:H}}function kb(D,Z,$,J){if(new Set(D.map((W)=>W.ref)).size!==D.length)throw new JD("Duplicate creation ref");let Q=new Set,X=D.map((W)=>{if($.has(W.ref))throw new JD("Record already exists");let G=G4(W.ref,Z).schema;return tW(W.ref,()=>{let Y=WU({...W,fields:$5(W.fields,G.fields,!0)},Z);if(Q.has(Y.path))throw new JD("Duplicate creation path");return Q.add(Y.path),$.set(Y.ref,Y.schema.type),Y},rW(J,G),qU(G,W.fields))});for(let W of X)tW(W.ref,()=>l2(W.fields,W.schema.fields,(G)=>$.get(G)),rW(J,W.schema));return X}RW();k0();import{posix as eW}from"node:path";import{isDeepStrictEqual as DG}from"node:util";function SU(D,Z,$){let J=Z.flatMap((G)=>{let Y=G==="."?D.path:eW.join(G,D.path),B=[...$.schemas].filter(([H])=>Y.startsWith(`${H}/`)).sort(([H],[K])=>K.length-H.length);return B[0]?[{path:Y,collection:B[0][0],schema:B[0][1]}]:[]});if(J.length!==1)throw new JD("Record creation path does not identify one managed collection");let Q=J[0];if([...$.paths.values()].includes(Q.path))throw new JD("Record creation path already exists");let X=Buffer.concat([gb(D.fields,Q.schema.fields),Buffer.from(D.body??"")]),W=g1(X.toString("utf8"),Q.schema,eW.relative(Q.collection,Q.path));if(W.ref!==D.ref||!DG(W.fields,D.fields)||W.body!==(D.body??""))throw new JD("Created record identity or fields do not match its request");return{ref:D.ref,path:Q.path,fields:D.fields,bytes:X,schema:Q.schema}}function IU(D,Z){if(a6(D)&&a6(Z)){if(D.comment=Z.comment,D.commentBefore=Z.commentBefore,D.spaceBefore=Z.spaceBefore,h3(D)&&h3(Z)&&typeof D.value===typeof Z.value)D.type=Z.type}}function e$(D,Z,$){if(IU(D,$),Z.many&&k1(D)){D.flow=k1($)?$.flow:Z.style==="inline";for(let[J,Q]of D.items.entries())e$(Q,{...Z,many:!1},k1($)?$.items[J]:void 0)}else if(b1(D)){if(b1($))D.flow=$.flow;let J=new Map(b1($)?$.items.map((Q)=>[h3(Q.key)?String(Q.key.value):void 0,Q]):[]);for(let Q of D.items){let X=h3(Q.key)?String(Q.key.value):void 0,W=J.get(X);if(Z.kind==="map"&&Z.key.kind==="integer"&&W)Q.key=W.key;IU(Q.key,W?.key);let G=Z.kind==="object"?Z.fields.find((Y)=>Y.name===X):Z.kind==="map"?Z.value:void 0;if(G)e$(Q.value,G,W?.value)}}}function gb(D,Z){let $=new AW(D);for(let Q of Z)e$($.get(Q.name,!0),Q);let J=$.toString({nullStr:"~",lineWidth:0}).trimEnd();return Buffer.from(`---
352
+ ${N.available?"Available":"Unavailable"}`)}catch{throw Error("OS returned an invalid storage response.")}}eD();eD();import{isDeepStrictEqual as IF}from"node:util";eD();import{constants as n7}from"node:fs";import{createHash as i7}from"node:crypto";import{link as Pj,lstat as p2,mkdir as yH,open as g6,readdir as f6,realpath as Oj,rename as E9,rm as Z0}from"node:fs/promises";import{dirname as c2,isAbsolute as zX,join as UD,relative as a7,resolve as uH}from"node:path";import{isDeepStrictEqual as y6}from"node:util";eD();eD();var z0=16777216;var S9=4096;var O1=4;async function k6(D){let Z=await crypto.subtle.digest("SHA-256",D);return Array.from(new Uint8Array(Z),($)=>$.toString(16).padStart(2,"0")).join("")}async function bH(D,Z,$){if(!o8(D))throw new v("invalid_input",400);if(Z.byteLength>z0)throw new v("request_too_large",413);let J="application/octet-stream",Q=D.split(".").at(-1)?.toLowerCase();if(D.includes(".")&&["txt","md","json"].includes(Q))try{let X=new TextDecoder("utf-8",{fatal:!0}).decode(Z);if(Q==="json")JSON.parse(X),J="application/json";else if(!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/.test(X))J=Q==="md"?"text/markdown":"text/plain"}catch{}return{mediaType:J,size:Z.byteLength,sha256:await k6(Z)}}eD();class V0{signal;#$=new AbortController;#Z;#D;expired;#J=new Set;constructor(D,Z){if(this.#D=D===void 0?1/0:Date.now()+D,this.signal=Z?AbortSignal.any([Z,this.#$.signal]):this.#$.signal,this.expired=new Promise(($,J)=>{let Q=()=>J(new v("unavailable",503,!0));if(this.signal.addEventListener("abort",Q,{once:!0}),this.signal.aborted)Q()}),this.expired.catch(()=>{}),D!==void 0)this.#Z=setTimeout(()=>this.#$.abort(),D)}check(){if(Date.now()>=this.#D)this.#$.abort();if(this.signal.aborted)throw new v("unavailable",503,!0)}close(){clearTimeout(this.#Z)}track(D){return this.#J.add(D),D.finally(()=>this.#J.delete(D)).catch(()=>{}),D}async settle(){await Promise.allSettled(this.#J)}}var kH=262144,Fj=()=>new v("unavailable",503,!0),Lj=()=>new v("integrity",503);class Nj{maximum;#$=0;constructor(D){this.maximum=D}run(D){if(this.#$>=this.maximum)throw new v("capacity",429,!0);this.#$++;try{return D().finally(()=>{this.#$--})}catch(Z){throw this.#$--,Z}}}class _j{#$;#Z;#D;#J=!1;constructor(D){let Z;try{Z=D.getReader({mode:"byob"})}catch{}this.#Z=Boolean(Z),this.#$=Z??D.getReader()}async read(D,Z){if(D.check(),this.#J)throw Fj();let $=()=>this.#Z?this.#$.read(new Uint8Array(kH)):this.#$.read(),J=D.track(Z?Z.run($):$());this.#D=J;try{let Q=await Promise.race([J,D.expired]);if(D.check(),Q.value!==void 0&&(!(Q.value instanceof Uint8Array)||Q.value.buffer.byteLength>kH))throw Lj();return Q}finally{J.finally(()=>{if(this.#D===J)this.#D=void 0}).catch(()=>{})}}close(D=!1){if(this.#J)return;if(this.#J=!0,D)this.#$.cancel().catch(()=>{});let Z=()=>this.#$.releaseLock();if(this.#D)this.#D.then(Z,Z).catch(()=>{});else Z()}}async function c0(D,Z,$,J="request_too_large"){if($.check(),!D)return new Uint8Array;let Q=D.getReader(),X=new Uint8Array(Z),W=0,G;try{while(!0){let Y=$.track(Q.read());G=Y;let{done:B,value:H}=await Promise.race([Y,$.expired]);if(G=void 0,$.check(),B)break;if(!(H instanceof Uint8Array))throw new v("invalid_input",400,!1,{reason:"invalid_bytes"});if(W+=H.byteLength,W>Z)throw new v(J,J==="request_too_large"?413:503,!1,{reason:"size_limit",limitBytes:Z,receivedBytes:W,receivedAtLeast:!0});X.set(H,W-H.byteLength)}return X.slice(0,W)}catch(Y){throw Q.cancel().catch(()=>{}),Y}finally{if(G)G.finally(()=>Q.releaseLock()).catch(()=>{});else Q.releaseLock()}}T1();var ID=()=>new v("integrity",503),dH=()=>new v("access_denied",403),H2=(D)=>D.code==="ENOENT";function w9(D){let Z=D.lastIndexOf(".");return Z>0&&/^\.[a-z0-9]{1,16}$/i.test(D.slice(Z))?{stem:D.slice(0,Z),extension:D.slice(Z)}:{stem:D,extension:""}}function o7(D){let Z="";for(let $ of D){if(Buffer.byteLength(Z+$,"utf8")>200)break;Z+=$}return Z}function r7(D,Z){return D.id===Z.id&&D.name===Z.name&&D.path===Z.path&&D.mediaType===Z.mediaType&&D.size===Z.size&&D.sha256===Z.sha256}function hH(D){if(!D)return!1;if(typeof D.dev==="string")return/^(0|[1-9][0-9]{0,19})$/.test(D.dev)&&typeof D.ino==="string"&&/^(0|[1-9][0-9]{0,19})$/.test(D.ino)&&"birthtimeNs"in D&&typeof D.birthtimeNs==="string"&&/^-?(0|[1-9][0-9]{0,29})$/.test(D.birthtimeNs);return Number.isSafeInteger(D.dev)&&Number.isSafeInteger(D.ino)&&"birthtimeMs"in D&&Number.isFinite(D.birthtimeMs)}function mH(D){if(!D||!lD.test(D.workspaceId)||D.creator&&(!["member","routine"].includes(D.creator.kind)||!lD.test(D.creator.id))||D.runId!==void 0&&!lD.test(D.runId))throw dH();return structuredClone(D)}function Tj(D){let{details:Z,...$}=D;return J2($)}function pH(D){return JSON.stringify({name:D.name,path:D.path,mediaType:D.mediaType,storage:"local",size:D.size,sha256:D.sha256})}function vH(D,Z){let $=JSON.parse(D);if(!$||typeof $!=="object"||Array.isArray($))throw ID();if(!Object.hasOwn($,"csv")&&!Object.hasOwn($,"inputMediaType"))return D;if(Object.keys($).some((J)=>!["name","path","csv","storage","size","sha256","inputMediaType"].includes(J))||$.name!==Z.name||$.path!==Z.path||$.storage!=="local"||$.size!==Z.size||$.sha256!==Z.sha256)throw ID();return pH(Z)}async function cH(D,Z){if(!zX(D)||!lD.test(Z))throw new v("invalid_input",400);let $=UD(uH(D),".os","files"),J=[];for(let Q=$;Q!==c2(Q);Q=c2(Q))J.unshift(Q);for(let Q of J){let X=await p2(Q).catch((W)=>{if(H2(W))return;throw W});if(!X||!X.isDirectory()||X.isSymbolicLink())return!1}for(let Q of[`${Z}.json`,`${Z}.pending.json`])if(await p2(UD($,Q)).catch((X)=>{if(H2(X))return;throw X}))return!0;return!1}async function VX(D,Z,$){let J=mH({workspaceId:Z.workspaceId}),Q=".os",X=(A)=>A.workspaceId;if(!zX(D))throw new v("invalid_input",400);let W=uH(D),G=async(A,I=!1,b=!1)=>{let k=a7(W,A);if(k===".."||k.startsWith(`..${process.platform==="win32"?"\\":"/"}`)||zX(k))throw ID();let l=[];for(let i=A;i!==c2(i);i=c2(i))l.unshift(i);for(let i of l){let o=await p2(i).catch((HD)=>{if(H2(HD))return;throw HD});if(!o&&b)await yH(i,{mode:448}).catch((HD)=>{if(HD.code!=="EEXIST")throw HD}),o=await p2(i);if(!o)throw ID();if(o.isSymbolicLink()||(i!==A||I)&&!o.isDirectory())throw ID()}if(await Oj(I?A:c2(A))!==(I?A:c2(A)))throw ID();return A},Y=async()=>{await G(W,!0)},B=async(A,I)=>{await p2(A),await G(A);let b=await g6(A,n7.O_RDONLY|(n7.O_NOFOLLOW??0));try{let k=await b.stat();if(!k.isFile()||k.size>I||k.nlink!==1&&!(c2(A)===UD(W,".os","locks")&&k.nlink===2))throw ID();let l=new Uint8Array(k.size+1),i=0;while(i<l.length){let o=await b.read(l,i,l.length-i,i);if(!o.bytesRead)break;i+=o.bytesRead}if(i!==k.size)throw ID();return l.slice(0,i)}finally{await b.close()}},H=async(A,I=65536)=>JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(await B(A,I))),K=async(A,I)=>{await G(A);let b=await g6(A,n7.O_RDONLY|(n7.O_NOFOLLOW??0));try{let k=await b.stat();if(!k.isFile()||k.size!==I||k.nlink!==1)throw ID();return b}catch(k){throw await b.close(),k}},z=async(A,I)=>{let b=i7("sha256"),k=new Uint8Array(262144),l=0;for(;;){let{bytesRead:i}=await A.read(k,0,k.length,l);if(!i)break;if(l+=i,l>I.size)throw ID();b.update(k.subarray(0,i))}if(l!==I.size||b.digest("hex")!==I.sha256)throw ID()},V=async(A,I)=>{let b=await K(A,I.size);try{await z(b,I)}finally{await b.close()}},_=async(A,I)=>{let b=await K(A.bundle?UD(W,A.location,E(A)):UD(W,A.location),A.descriptor.size),k;try{await G(c2(I),!0),k=await g6(I,"wx",384);let l=new Uint8Array(262144),i=0;for(;;){let{bytesRead:o}=await b.read(l,0,l.length,i);if(!o)break;if(i+=o,i>A.descriptor.size)throw ID();await k.writeFile(l.subarray(0,o))}if(i!==A.descriptor.size)throw ID();await k.sync()}finally{await b.close(),await k?.close()}},N=async(A,I)=>{await G(c2(A),!0);let b=await g6(A,"wx",384);try{await b.writeFile(I),await b.sync()}finally{await b.close()}},F=async(A)=>{if(process.platform==="win32")return;let I=await g6(A,"r");try{await I.sync()}finally{await I.close()}},U=async(A,I)=>{let b=`${A}.${crypto.randomUUID()}.tmp`;if(await N(b,JSON.stringify(I)),await G(c2(A),!0),(await p2(A).catch((l)=>{if(H2(l))return;throw l}))?.isSymbolicLink())throw ID();await E9(b,A),await F(c2(A))};await G(W,!0,!0);for(let A=W;;A=c2(A)){if(await p2(UD(A,".git")).catch((b)=>{if(H2(b))return;throw b})){if((await b0(A,["ls-files","-z","--",a7(A,W)||"."],void 0,{localObjectsOnly:!0})).length)throw new v("unavailable",503,!1,{reason:"local_storage_tracked"});break}if(A===c2(A))break}let M=await f6(W);if(M.includes(".oddington-files"))throw new v("unavailable",503,!1,{reason:M.includes(".os")?"local_storage_ambiguous":"local_storage_legacy"});let L=UD(W,".os");if(!M.includes(".os")){if(M.length)throw new v("unavailable",503,!1,{reason:"local_storage_unrecognized"});await yH(L,{mode:448}),await N(UD(L,"owner.json"),JSON.stringify({format:1,owner:"oddington-files"}))}await G(L,!0);let C=await H(UD(L,"owner.json"));if(C.format!==1||C.owner!=="oddington-files")throw ID();for(let A of["files","requests","locks","staging"])await G(UD(L,A),!0,!0);await Y();let P=new Set;for(let A of await f6(UD(L,"files")))if(A.endsWith(".pending.json")){let I=await H(UD(L,"files",A)).catch((b)=>{if(H2(b))return;throw b});if(!I)continue;P.add(I.stage),P.add(I.backup)}for(let A of await f6(UD(L,"staging")))if(/^[0-9a-f-]{36}\.owner\.json$/.test(A)){let I=UD(L,"staging",A),b=await H(I).catch((k)=>{if(H2(k))return;throw k});if(!b||!Number.isSafeInteger(b.pid)||b.pid<=0)continue;try{process.kill(b.pid,0)}catch(k){if(k.code!=="ESRCH")continue;let l=A.slice(0,-11);if(!P.has(`staging/${l}`))await Z0(UD(L,"staging",l),{recursive:!0,force:!0});await Z0(I,{force:!0})}}let j=async(A)=>{await N(`${A}.owner.json`,JSON.stringify({pid:process.pid}))},q=async(A)=>{let I=!1;for(let b of await f6(UD(L,"files")))if(b.endsWith(".pending.json")){let k=await H(UD(L,"files",b)).catch((l)=>{if(H2(l))return;throw l});if(!k)continue;if(k.stage===a7(L,A).replaceAll("\\","/"))I=!0}if(!I)await Z0(A,{recursive:!0,force:!0});await Z0(`${A}.owner.json`,{force:!0})},O=async(A,I)=>{if(A!=="allocation"&&!lD.test(A)&&!/^request-[0-9a-f]{64}$/.test(A))throw new v("invalid_input",400);let b=UD(L,"locks",`${A}.json`),k=UD(L,"locks",`${A}.${crypto.randomUUID()}.lease`),l=new V0(30000);try{await N(k,JSON.stringify({pid:process.pid}));for(;;){l.check(),await G(c2(b),!0);try{await Pj(k,b)}catch(i){if(i.code!=="EEXIST")throw i;let o=await H(b).catch(()=>{return});if(o&&Number.isSafeInteger(o.pid)&&o.pid>0)try{process.kill(o.pid,0)}catch(HD){if(HD.code==="ESRCH"){await Z0(b);continue}}await new Promise((HD)=>setTimeout(HD,10));continue}await Z0(k);try{return await Y(),await I()}finally{await Z0(b)}}}finally{l.close(),await Z0(k,{force:!0})}},T=(A)=>UD(L,"files",`${A}.json`),R=(A)=>{let I=A;if(!I||![1,2].includes(I.format)||!R7(I.location)||typeof I.bundle!=="boolean"||!/^[2-9A-HJ-NP-Z]{8,32}$/.test(I.suffix)||typeof I.material!=="string"||I.uploading!==void 0&&typeof I.uploading!=="boolean"||I.placement!==void 0&&I.placement!=="remote")throw ID();if(I.descriptor=Tj(I.descriptor),mH(I.authority),I.material=vH(I.material,I.descriptor),I.descriptor.size>b2)throw ID();let b=w9(I.descriptor.name),k=`${o7(b.stem)} [${I.suffix}]`;if(I.location!==`${I.descriptor.path}/${k}${I.bundle?"":b.extension}`)throw ID();if(I.cache){let l=R({format:I.format,authority:I.authority,material:I.material,...I.cache});if(!r7(l.descriptor,I.descriptor))throw ID();I.cache={...I.cache,descriptor:l.descriptor}}if(I.objects&&(!hH(I.objects.home)||!I.objects.representations||!y6(Object.keys(I.objects.representations).sort(),Object.keys(y(I)).sort())||Object.values(I.objects.representations).some((l)=>!hH(l))))throw ID();return I.format=2,I},g=(A)=>{if(X(A.authority)!==X(J))throw dH()},E=(A)=>`original${w9(A.descriptor.name).extension}`,y=(A)=>({[E(A)]:A.descriptor,...A.descriptor.enrichments}),d=(A)=>({dev:String(A.dev),ino:String(A.ino),birthtimeNs:String(A.birthtimeNs)}),u=(A,I)=>{if(!I)return!1;if(typeof I.dev==="string")return y6(d(A),I);let b=Number(A.birthtimeNs/1000000000n)*1000+Number(A.birthtimeNs%1000000000n)/1e6;return"birthtimeMs"in I&&A.dev===BigInt(I.dev)&&A.ino===BigInt(I.ino)&&b===I.birthtimeMs},S=async(A,I,b)=>{let k=await K(A,I.size);try{let l=await k.stat({bigint:!0});if(b&&!u(l,b))throw ID();await z(k,I);let i=await k.stat({bigint:!0});if(!u(i,d(l))||l.size!==i.size||l.mtimeNs!==i.mtimeNs||l.ctimeNs!==i.ctimeNs)throw ID();return d(i)}finally{await k.close()}},w=async(A,I=UD(W,A.location))=>{if(A.bundle){await G(I,!0);let b=new Set([E(A),...Object.keys(A.descriptor.enrichments)]);if((await f6(I)).some((k)=>!b.has(k)))throw ID()}await V(A.bundle?UD(I,E(A)):I,A.descriptor).catch((b)=>{if(H2(b))throw ID();throw b});for(let[b,k]of Object.entries(A.descriptor.enrichments)){let l=await B(UD(I,b),z0).catch((i)=>{if(H2(i))throw ID();throw i});if(l.length!==k.size||await k6(l)!==k.sha256)throw ID()}if(A.objects){if(!u(await p2(I,{bigint:!0}),A.objects.home))throw ID();for(let[b,k]of Object.entries(y(A)))await S(A.bundle?UD(I,b):I,k,A.objects.representations[b])}},h=async(A)=>{let I=UD(L,"files",`${A}.pending.json`),b=await H(I).catch((LD)=>{if(H2(LD))return;throw LD});if(!b)return;let k=R(b.next);if(g(k),k.descriptor.id!==A||b.previous&&R(b.previous).descriptor.id!==A||!/^staging\/[0-9a-f-]{36}$/.test(b.stage)||!/^staging\/[0-9a-f-]{36}$/.test(b.backup))throw ID();let l=UD(L,b.stage),i=UD(L,b.backup),o=await p2(l).catch((LD)=>{if(H2(LD))return;throw LD});if(k.registration){if(o&&b.previous&&!b.previous.bundle){let wD=UD(l,E(k));if(!await p2(wD).catch((aD)=>{if(H2(aD))return;throw aD})){await w(b.previous);for(let[aD,L2]of Object.entries(k.descriptor.enrichments))await V(UD(l,aD),L2)}else await w(k,l)}else if(o)await w(k,l);else await w(k);let LD=k.registration,ND="create"in LD?await $.registry.create(k.descriptor,{...LD.create,storage:"local"},null,{},k.suffix):await $.registry.enrich(LD.expected,LD.enrichment.name,k.descriptor.enrichments[LD.enrichment.name],{},LD.enrichment.replace);if("create"in LD&&ND.descriptor.id!==k.descriptor.id){if(!o||b.previous||!r7({...k.descriptor,id:ND.descriptor.id},ND.descriptor))throw ID();let wD=await k6(new TextEncoder().encode(`${X(J)}/${LD.create.requestKey}`));return await U(UD(L,"requests",`${wD}.json`),{id:ND.descriptor.id,material:k.material}),await Z0(l,{recursive:!0}),await Z0(I),await F(c2(I)),structuredClone(ND.descriptor)}if(!y6(ND.descriptor,k.descriptor)||ND.placement!=="local")throw ID();if(ND.filenameIdentifier!==k.suffix){if(!o||b.previous)throw ID();k.suffix=ND.filenameIdentifier;let wD=w9(k.descriptor.name);k.location=`${k.descriptor.path}/${o7(wD.stem)} [${k.suffix}]${k.bundle?"":wD.extension}`,await U(I,{...b,next:k})}}let HD=UD(W,k.location);if(o){if(b.previous&&!b.previous.bundle){let ND=UD(l,E(k));if(!await p2(ND).catch((wD)=>{if(H2(wD))return;throw wD}))await w(b.previous),await E9(UD(W,b.previous.location),ND),await F(l)}if(await w(k,l),await Y(),b.previous&&b.previous.location===k.location){g(b.previous);let ND=UD(W,b.previous.location);if(!await p2(i).catch((aD)=>{if(H2(aD))return;throw aD}))await w(b.previous),await G(ND),await E9(ND,i)}if(await p2(HD).catch((ND)=>{if(H2(ND))return;throw ND}))throw ID();await G(c2(HD),!0);try{await E9(l,HD)}catch(ND){if(b.previous?.location===k.location)await E9(i,HD);throw ND}await F(c2(HD)),await $.afterPlacement?.()}await w(k);let uD=UD(W,k.location),_D={},MD=d(await p2(uD,{bigint:!0}));for(let[LD,ND]of Object.entries(y(k)))_D[LD]=await S(k.bundle?UD(uD,LD):uD,ND);if(!u(await p2(uD,{bigint:!0}),MD))throw ID();if(await Y(),await U(T(A),{...k,registration:void 0,objects:{home:MD,representations:_D}}),b.previous&&b.previous.location!==k.location){let LD=UD(W,b.previous.location);if(await p2(LD).catch((wD)=>{if(H2(wD))return;throw wD}))await w(b.previous),await Z0(LD)}await Z0(i,{recursive:!0,force:!0}),await Z0(I),await F(c2(I))},s=async(A)=>{if(!lD.test(A))throw new v("invalid_input",400);await Y();let I=await H(T(A)).catch((i)=>{if(H2(i))return;throw i});if(!I){let i=await H(UD(L,"files",`${A}.pending.json`)).catch((o)=>{if(H2(o))return;throw o});if(!i)throw new v("local_only",409);I=i.next}g(R(I)),await h(A);let b=await H(T(A)),k=JSON.stringify(b),l=R(b);if(l.descriptor.id!==A)throw ID();{let i=await $.registry.get(A);if(!r7(i.descriptor,l.descriptor))throw ID();if(i.placement==="remote")return{...l,descriptor:i.descriptor,placement:"remote"};if(!y6(i.descriptor,l.descriptor))throw ID()}if(JSON.stringify(l)!==k)await Y(),await U(T(A),l);return l},a=async(A,I,b,k)=>{try{if(b&&!b.bundle){await w(b);for(let[l,i]of Object.entries(A.descriptor.enrichments))await V(UD(I,l),i)}else await w(A,I);if(await $.beforeActivation?.(),await Y(),k?.aborted)throw new v("unavailable",503,!0)}catch(l){throw await Z0(I,{recursive:!0,force:!0}),l}await U(UD(L,"files",`${A.descriptor.id}.pending.json`),{next:A,...b?{previous:b}:{},stage:a7(L,I).replaceAll("\\","/"),backup:`staging/${crypto.randomUUID()}`});try{return await h(A.descriptor.id)}catch(l){if(l instanceof v&&l.status>=400&&l.status<500)await Z0(UD(L,"files",`${A.descriptor.id}.pending.json`)),await Z0(I,{recursive:!0,force:!0});throw l}},x=async(A)=>{if(A.placement!=="remote")await w(A);return await Y(),structuredClone(A.descriptor)},p=async(A)=>{if(!lD.test(A))throw new v("invalid_input",400);return await Y(),!!(await p2(T(A)).catch((k)=>{if(H2(k))return;throw k})??await p2(UD(L,"files",`${A}.pending.json`)).catch((k)=>{if(H2(k))return;throw k}))},f=async(A,I,b)=>{let k=UD(L,"staging",crypto.randomUUID()),l=0,i=(I instanceof Uint8Array?new ReadableStream({pull(_D){if(l===I.byteLength){_D.close();return}let MD=Math.min(l+262144,I.byteLength);_D.enqueue(I.subarray(l,MD)),l=MD}},{highWaterMark:0}):I).getReader(),o,HD=!1,uD=!1;try{await j(k),o=await g6(k,"wx",384);let _D=i7("sha256"),MD=0,LD=Date.now();for(;;){let ND=new V0(Math.max(1,30000-(Date.now()-LD)),b),wD;try{wD=await Promise.race([ND.track(i.read()),ND.expired]),ND.check()}finally{ND.close()}if(wD.done)break;if(!(wD.value instanceof Uint8Array))throw new v("invalid_input",400,!1,{reason:"invalid_bytes"});if(!wD.value.byteLength)continue;if(MD+wD.value.byteLength>A.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:A.size,receivedBytes:MD+wD.value.byteLength,receivedAtLeast:!0});for(let aD=0;aD<wD.value.byteLength;aD+=262144){if(b?.aborted)throw new v("unavailable",503,!0);let L2=wD.value.subarray(aD,aD+262144);_D.update(L2),MD+=L2.byteLength,await o.writeFile(L2)}LD=Date.now()}if(HD=!0,MD!==A.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:A.size,receivedBytes:MD});return await o.sync(),uD=!0,{stage:k,original:{size:MD,sha256:_D.digest("hex"),mediaType:A.mediaType}}}finally{if(!HD)await i.cancel().catch(()=>{});if(i.releaseLock(),await o?.close(),!uD)await q(k)}},c=async(A)=>{let I=UD(L,"requests",`${A}.json`),b=await H(I).catch((l)=>{if(H2(l))return;throw l});if(!b)return;if(!lD.test(b.id)||typeof b.material!=="string")throw ID();let k=JSON.parse(b.material);if(k&&(Object.hasOwn(k,"csv")||Object.hasOwn(k,"inputMediaType")))b.material=await O(b.id,async()=>{let l=await H(T(b.id)).catch((o)=>{if(H2(o))return;throw o})??(await H(UD(L,"files",`${b.id}.pending.json`)).catch((o)=>{if(H2(o))return;throw o}))?.next;if(!l)throw new v("conflict",409);let i=R(l);if(g(i),i.descriptor.id!==b.id)throw ID();return vH(b.material,i.descriptor)}),await Y(),await U(I,b);return b};return{has:p,async lookup(A){let I=await k6(new TextEncoder().encode(`${X(J)}/${A}`));return O(`request-${I}`,async()=>{let b=await c(I);if(!b||!await p(b.id))return;return O(b.id,async()=>x(await s(b.id)))})},async create(A,I,b){let k=O0(A,b2);if(k.storage==="remote")throw new v("unsupported_context",400);if(k.path.split("/").some((i)=>Buffer.byteLength(i,"utf8")>255))throw new v("invalid_input",400);if(new TextEncoder().encode(JSON.stringify(k)).length>S9)throw new v("invalid_input",400);if(!(I instanceof Uint8Array)&&!(I instanceof ReadableStream)||I instanceof Uint8Array&&I.byteLength!==k.size)throw new v("invalid_input",400);let l=await k6(new TextEncoder().encode(`${X(J)}/${k.requestKey}`));return O(`request-${l}`,async()=>{await Y();let i=await c(l);if(i&&!lD.test(i.id))throw ID();let{stage:o,original:HD}=await f(k,I,b);try{let uD=pH({...k,...HD});{let ND=await $.registry.creationReplay?.({...k,storage:"local"},HD.sha256);if(ND)return structuredClone(ND.descriptor)}let _D=UD(L,"requests",`${l}.json`),MD=await H(_D).catch((ND)=>{if(H2(ND))return;throw ND});if(MD){if(MD.material!==uD||!lD.test(MD.id))throw new v("conflict",409);if(await p(MD.id))return await O(MD.id,async()=>x(await s(MD.id)))}let LD=MD?.id??crypto.randomUUID();if(!MD&&await p(LD))throw new v("conflict",409);if(!MD)await U(_D,{id:LD,material:uD});return await O("allocation",async()=>O(LD,async()=>{let ND=UD(W,k.path);await G(ND,!0,!0);let wD=w9(k.name),aD=o7(wD.stem),L2=LD.replaceAll("-","").toUpperCase().replaceAll("0","G").replaceAll("1","H"),ZD=new Set((await f6(ND)).map((GD)=>GD.toLowerCase())),t=L2.slice(0,8);for(let GD=8;GD<=L2.length;GD++){let $2=L2.slice(0,GD);if(ZD.has(`${aD} [${$2}]${wD.extension}`.toLowerCase())||ZD.has(`${aD} [${$2}]`.toLowerCase())){if(GD===L2.length)throw new v("conflict",409);t=L2.slice(0,GD+1)}}let QD={format:2,authority:J,descriptor:{id:LD,name:k.name,path:k.path,...HD,enrichments:{}},material:uD,bundle:!1,suffix:t,location:`${k.path}/${aD} [${t}]${wD.extension}`};return QD.registration={create:k},await a(QD,o,void 0,b)??x(await s(LD))}))}finally{await q(o)}})},async get(A){return O(A,async()=>{return await h(A),structuredClone((await $.registry.get(A)).descriptor)})},async placement(A){return O(A,async()=>{return await h(A),(await $.registry.get(A)).placement})},async preflightUpload(A){return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="local")await w(await s(A))})},async upload(A,I){return O(A,async()=>{{await h(A);let MD=await $.registry.get(A);if(MD.placement==="remote")return structuredClone(MD.descriptor)}let b=await s(A);if(!$.remote)throw new v("unsupported_context",400);await w(b),await Y();let k=await K(b.bundle?UD(W,b.location,E(b)):UD(W,b.location),b.descriptor.size),l=0,i=!1,o=async()=>{if(!i)i=!0,await k.close()},HD=i7("sha256"),uD=new ReadableStream({async pull(MD){try{if(I?.aborted)throw new v("unavailable",503,!0);let LD=new Uint8Array(262144),{bytesRead:ND}=await k.read(LD,0,LD.length,l);if(!ND){if(l!==b.descriptor.size||HD.digest("hex")!==b.descriptor.sha256)throw ID();await o(),MD.close()}else{if(l+=ND,l>b.descriptor.size)throw ID();HD.update(LD.subarray(0,ND)),MD.enqueue(LD.subarray(0,ND))}}catch(LD){await o(),MD.error(LD)}},cancel:o},{highWaterMark:0}),_D;try{await U(T(A),{...b,uploading:!0,cache:{descriptor:b.descriptor,location:b.location,bundle:b.bundle,suffix:b.suffix,objects:b.objects}}),_D=await $.remote.transfer(b.descriptor,uD,async(MD)=>{if(await Y(),!Object.hasOwn(b.descriptor.enrichments,MD))throw ID();return B(UD(W,b.location,MD),z0)},async()=>{if(await w(b),await Y(),!y6((await $.registry.get(A)).descriptor,b.descriptor))throw new v("conflict",409)},I)}finally{await uD.cancel().catch(()=>{}),await o()}if(!r7(_D,b.descriptor))throw ID();{let MD=await $.registry.get(A);if(MD.placement!=="remote"||!y6(MD.descriptor,_D))throw ID()}return await Y(),await U(T(A),{...b,descriptor:_D,placement:"remote",uploading:!1,objects:void 0,cache:{descriptor:b.descriptor,location:b.location,bundle:b.bundle,suffix:b.suffix,objects:b.objects}}),structuredClone(_D)})},async read(A,I){if(I!==void 0&&!_6(I))throw new v("invalid_input",400);return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="remote"){if(!$.remote)throw new v("unavailable",503,!0);return $.remote.read(A,I)}let b=await s(A);if(b.placement==="remote"){let LD=await $.remote.read(A,I);return await Y(),LD}await w(b);let k=I===void 0?b.descriptor:Object.hasOwn(b.descriptor.enrichments,I)?b.descriptor.enrichments[I]:void 0;if(!k)throw new v("invalid_input",400);let l=UD(W,b.location),i=await K(I===void 0?b.bundle?UD(l,E(b)):l:UD(l,I),k.size);try{await z(i,k),await Y()}catch(LD){throw await i.close(),LD}let o=0,HD=!1,uD=i7("sha256"),_D=async()=>{if(!HD)HD=!0,await i.close()},MD=new ReadableStream({async pull(LD){try{let ND=new Uint8Array(262144),{bytesRead:wD}=await i.read(ND,0,ND.length,o);if(!wD){if(o!==k.size||uD.digest("hex")!==k.sha256)throw ID();await _D(),LD.close()}else{if(o+=wD,o>k.size)throw ID();uD.update(ND.subarray(0,wD)),LD.enqueue(ND.subarray(0,wD))}}catch(ND){await _D(),LD.error(ND)}},cancel:_D},{highWaterMark:0});return new Response(MD,{headers:{"content-type":k.mediaType,"content-length":String(k.size),"content-disposition":`attachment; filename*=UTF-8''${encodeURIComponent(I??b.descriptor.name)}`,"cache-control":"no-store","x-content-type-options":"nosniff"}})})},async enrich(A,I,b){let k=L1(I,z0),l=b.slice();if(l.length!==k.size)throw new v("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:k.size,receivedBytes:l.length});let i=await bH(k.name,l,k.mediaType);return O(A,async()=>{if(await h(A),(await $.registry.get(A)).placement==="remote"){if(!$.remote)throw new v("unavailable",503,!0);return $.remote.enrich(A,k,l)}let o=await s(A);if(o.placement==="remote"){let MD=await $.remote.enrich(A,k,l);return await Y(),MD}await w(o);let HD=Object.hasOwn(o.descriptor.enrichments,k.name)?o.descriptor.enrichments[k.name]:void 0;if(HD?.sha256===i.sha256&&HD.size===i.size)return await Y(),{name:k.name,...HD};if(k.replace===void 0?HD!==void 0:!HD||HD.sha256!==k.replace)throw new v("conflict",409);if(Object.keys(o.descriptor.enrichments).some((MD)=>MD!==k.name&&MD.toLowerCase()===k.name.toLowerCase()))throw new v("conflict",409);let uD={...o,bundle:!0,objects:void 0,location:`${o.descriptor.path}/${o7(w9(o.descriptor.name).stem)} [${o.suffix}]`,descriptor:{...o.descriptor,enrichments:{...o.descriptor.enrichments,[k.name]:i}}};uD.registration={expected:o.descriptor,enrichment:k},J2(uD.descriptor);let _D=UD(L,"staging",crypto.randomUUID());await j(_D);try{if(await G(_D,!0,!0),o.bundle)await _(o,UD(_D,E(o)));for(let MD of Object.keys(o.descriptor.enrichments))if(MD!==k.name)await N(UD(_D,MD),await B(UD(W,o.location,MD),z0));return await N(UD(_D,k.name),l),await F(_D),await a(uD,_D,o),await x(await s(A)),{name:k.name,...i}}finally{await q(_D)}})}}}X8();import{randomBytes as ck}from"node:crypto";import{constants as FF}from"node:fs";import{createServer as lk}from"node:http";import{Readable as sk}from"node:stream";import{chmod as nk,lstat as ik,mkdtemp as ak,open as UG,realpath as _4,rename as ok,rm as _F}from"node:fs/promises";import{basename as rk,dirname as tk,join as FG}from"node:path";import{tmpdir as ek}from"node:os";import{setTimeout as Dg}from"node:timers/promises";T8();function UX(D,Z){let $=(J)=>({...J,repositories:J.repositories.map(({published:Q,...X})=>X)});return JSON.stringify($(D))===JSON.stringify($(Z))}function S8(D){let Z=D,$=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;if(!Z||typeof Z!=="object"||Array.isArray(Z)||Object.keys(Z).sort().join(",")!=="deploymentId,repositories,routine,routineId,version,workspace,workspaceId"||typeof Z.workspace!=="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(Z.workspace)||typeof Z.routine!=="string"||!/^[a-z0-9][a-z0-9-]{0,62}$/.test(Z.routine)||![Z.workspaceId,Z.routineId].every((Q)=>typeof Q==="string"&&$.test(Q))||!(Z.deploymentId===null?typeof Z.version==="string"&&/^local:[0-9a-f]{64}$/.test(Z.version):typeof Z.deploymentId==="string"&&$.test(Z.deploymentId)&&typeof Z.version==="string"&&/^[0-9a-f]{40}$/.test(Z.version))||!Array.isArray(Z.repositories)||Z.repositories.length>64)throw Error("Invalid preparation authority");let J=Z.repositories.map((Q)=>{if(!Q||!["canWrite,target","canWrite,published,target"].includes(Object.keys(Q).sort().join(","))||typeof Q.canWrite!=="boolean")throw Error("Invalid preparation grant");let X=L9(Q.target);if(!N9(X)||X.workspaceId!==Z.workspaceId)throw Error("Invalid preparation target");if(Object.hasOwn(Q,"published")&&(!Q.published||Object.keys(Q.published).sort().join(",")!=="sourceVersion,version"||typeof Q.published.sourceVersion!=="string"||!/^[0-9a-f]{40}$/.test(Q.published.sourceVersion)||!u0(Q.published.version)))throw Error("Invalid preparation publication");return{target:X,canWrite:Q.canWrite,...Q.published?{published:{...Q.published}}:{}}});if(new Set(J.map((Q)=>Q.target.repository)).size!==J.length)throw Error("Ambiguous preparation repositories");return{workspace:Z.workspace,workspaceId:Z.workspaceId,routine:Z.routine,routineId:Z.routineId,deploymentId:Z.deploymentId,version:Z.version,repositories:J}}T1();import{createHash as Lk,randomBytes as $F,randomUUID as Nk}from"node:crypto";import{constants as GG}from"node:fs";import{link as _k,lstat as XZ,mkdir as Mk,open as aU,readdir as Ck,rename as Pk,unlink as oU}from"node:fs/promises";import{dirname as rU,join as j0,posix as J3}from"node:path";j8();function j1(D){if(!Array.isArray(D)||D.length<1||D.length>100)throw new r("invalid_query");let Z=j3(D);if(!Z.every(($)=>X2($)&&!/[\r\n]/.test($))||new Set(Z).size!==Z.length)throw new r("invalid_query");return Z}function lH(D){if(D===void 0)return{};try{u2(D)}catch{throw new r("invalid_query")}if(!D||typeof D!=="object"||Array.isArray(D)||![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).some((Z)=>Z!=="body")||Object.hasOwn(D,"body")&&D.body!==!0)throw new r("invalid_query");return Object.hasOwn(D,"body")?{body:!0}:{}}T8();fW();W4();k0();k0();class e6 extends JD{component;constructor(D){super("Missing filing component");this.component=D}}var yW=(D)=>/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(D),Fb=(D)=>[...D.matchAll(/<([^>]+)>/g)].map((Z)=>Z[1]),w8=()=>{throw new JD("Unsupported or ambiguous creation identity")};function hW(D,Z,$,J=2){let Q=D.split(/(<[^>]+>)/).filter(Boolean),X=[],W=0,G=(Y,B,H)=>{if(++W>1e4)return w8();if(X.length>=J)return;if(Y===Q.length){if(B===Z.length)X.push(H);return}let K=Q[Y];if(!K.startsWith("<")){if(Z.startsWith(K,B))G(Y+1,B+K.length,H);return}let z=K.slice(1,-1),V=$[z];if(V!==void 0){if(Z.startsWith(V,B))G(Y+1,B+V.length,{...H,[z]:V});return}for(let _=B+1;_<=Z.length&&X.length<J;_++){let N=Z.slice(B,_);if(!yW(N))break;G(Y+1,_,{...H,[z]:N})}};return G(0,0,{}),X}function G4(D,Z){let $=Z.filter(({schema:J})=>{let Q=J.naming?J.ref:J.ref.replace("{id}","<id>");return hW(Q,D,{},1).length>0});if($.length!==1)return w8();return $[0]}function WU(D,Z){let $=G4(D.ref,Z),J=$.schema;if(l2(D.fields,J.fields),!J.naming&&J.path!=="{id}.md")return w8();let Q=J.naming?J.ref:J.ref.replace("{id}","<id>"),X=J.naming?Fb(`${J.naming.folder}/${J.naming.filename}`):["id"];if(X.some((z)=>z.length>128))return w8();let W={};for(let z of X){let V=J.fields.find((_)=>_.name===z);if(Z3(V)){let _=String(D.fields[z]);if(!yW(_))return w8();W[z]=_}else if(V&&V.kind!=="link")return w8()}let G=hW(Q,D.ref,W);if(!G.length)return w8();if(G.length===1)Object.assign(W,G[0]);for(let[z,V]of Object.entries(D.filing??{})){if(!X.includes(z)||Object.hasOwn(W,z)||!yW(V))return w8();W[z]=V}let Y=hW(Q,D.ref,W);if(Y.length!==1)return w8();Object.assign(W,Y[0]);for(let z of X)if(!Object.hasOwn(W,z))throw new e6(z);let B=(z)=>z.replace(/<([^>]+)>/g,(V,_)=>W[_]),H=J.naming?`${B(J.naming.folder.slice(J.naming.collection.length+1))}${J.naming.folder===J.naming.collection?"":"/"}${B(J.naming.filename)}.md`:`${W.id}.md`;if(p$(J,H,D.fields)!==D.ref)return w8();let K=`${J.naming?.collection??$.name}/${H}`;return{ref:D.ref,path:K,fields:D.fields,schema:J,...D.body===void 0?{}:{body:D.body}}}Y0();b9();import{createHash as Lb}from"node:crypto";function f1(D){return typeof D==="string"&&D===new TextDecoder("utf-8",{ignoreBOM:!0}).decode(new TextEncoder().encode(D))}var GU=8388608;k0();var y1=4;function l$(D){if(typeof D!=="string")return;let Z=/^records-index-v3:([0-9a-f]{64})$/.exec(D);if(Z)return{format:"records-index-v3",hash:Z[1]};let $=/^records-index:4:([0-9a-f]{64})$/.exec(D);return $?{format:y1,hash:$[1]}:void 0}function Nb(D,Z){if(!/^[0-9a-f]{64}$/.test(Z))return g0();return`${D===y1?`records-index:${D}`:D}:${Z}`}var D5=41943040;var _b=/^[0-9a-f]{40}$/;var Y4=(D,Z)=>D<Z?-1:D>Z?1:0,g0=()=>{throw new JD("Invalid or incompatible index artifact")};function Mb(D,Z){return Nb(Z,Lb("sha256").update(D).digest("hex"))}function B4(D){if(!D||typeof D!=="object"||Array.isArray(D))return g0();return D}function mW(D,Z){if(Object.keys(D).sort(Y4).join(",")!==Z.sort(Y4).join(","))g0()}function Cb(D){let Z=B4(D);if(mW(Z,["workspaceId","repository"]),typeof Z.workspaceId!=="string"||!/^[a-zA-Z0-9_-]{1,128}$/.test(Z.workspaceId)||!Q2(Z.repository))g0()}function YU(D,Z){Cb(Z.binding);let $=l$(Z.identity);if(D.byteLength>D5||!_b.test(Z.sourceVersion)||!$||Mb(D,$.format)!==Z.identity)return g0();let J;try{J=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(D))}catch{return g0()}let Q=B4(J);mW(Q,$.format===y1?["formatVersion","binding","sourceVersion","collections"]:["format","binding","sourceVersion","collections"]);let X=B4(Q.binding);if(mW(X,["workspaceId","repository"]),($.format===y1?Q.formatVersion:Q.format)!==$.format||Q.sourceVersion!==Z.sourceVersion||X.workspaceId!==Z.binding.workspaceId||X.repository!==Z.binding.repository||!Array.isArray(Q.collections)||!Q.collections.length)return g0();return J}function uW(D){if(D.naming)return D.naming.collection;if(!D.ref.endsWith("/{id}"))return g0();return D.ref.slice(0,-5)}function vW(D,Z,$){if(D===null)return null;if(Z.many){if(!Array.isArray(D))return g0();return D.map((J)=>vW(J,{...Z,many:!1},$))}if(Z.kind==="link"){if(typeof D!=="string")return g0();if($){if(!q1(D))return g0();return`[[${D}]]`}if(!x9(D))return g0();return D.slice(2,-2)}if(Z.kind==="object")return $5(B4(D),Z.fields,$);if(Z.kind==="map")return Object.fromEntries(Object.entries(B4(D)).map(([J,Q])=>[J,vW(Q,Z.value,$)]));return D}function $5(D,Z,$){let J=new Map(Z.map((Q)=>[Q.name,Q]));return Object.fromEntries(Object.entries(D).map(([Q,X])=>{let W=J.get(Q);if(!W)throw new y2("unknown",Q);try{return[Q,vW(X,W,$)]}catch(G){if(G instanceof JD&&!(G instanceof y2))throw new y2("invalid",Q,o6(W));throw G}}))}function Pb(D,Z){let $=new Set([D.$ref.toLowerCase()]),J=(Q,X)=>{if(Q===null)return;if(X.many)for(let W of Q)J(W,{...X,many:!1});else if(X.kind==="object"){for(let W of X.fields)if(Object.hasOwn(Q,W.name))J(Q[W.name],W)}else if(X.kind==="map")for(let[W,G]of Object.entries(Q))J(X.key.kind==="integer"?Number(W):W,X.key),J(G,X.value);else $.add(String(Q).toLowerCase())};for(let Q of Z.fields)if(Object.hasOwn(D,Q.name))J(D[Q.name],Q);return[...$].sort(Y4)}function s$(D,Z,$,J=y1){let Q=new Map,X=new Set,W=[...D.schemas].map(([B,H])=>{let K=uW(H);if(X.has(K))throw new JD(`Duplicate logical collection name: ${K}`);X.add(K);let z=[];return Q.set(B,z),{name:K,schema:H,records:z}}).sort((B,H)=>Y4(B.name,H.name));for(let B of D.records.values()){let H=Q.get(B.collectionPath);if(!H)return g0();H.push({...$5(B.fields,B.schema.fields,!1),$ref:B.ref,$version:B.version,$body:B.body,...J===y1?{$path:B.path}:{}})}for(let{records:B}of W)B.sort((H,K)=>Y4(H.$ref,K.$ref));let G={binding:Z,sourceVersion:$,collections:W.map((B)=>({...B,searchValues:B.records.map((H)=>Pb(H,B.schema))}))};return J===y1?{formatVersion:J,...G}:{format:J,...G}}k0();function dW(D,Z=new Set,$=0){if(D===null||typeof D==="string"||typeof D==="boolean"||typeof D==="number"&&Number.isFinite(D))return D;if(!D||typeof D!=="object"||Z.has(D)||$>32)throw new r("invalid_query");Z.add(D);try{if(Array.isArray(D))return j3(D).map((J)=>dW(J,Z,$+1));return Object.fromEntries(Object.entries(u2(D)).map(([J,Q])=>[J,dW(Q.value,Z,$+1)]))}finally{Z.delete(D)}}function n$(D,Z){let $=()=>{throw new r("invalid_query")};try{let J=u2(Z),Q=J.maxRecords?.value;if(Object.keys(J).join(",")!=="maxRecords"||!Number.isSafeInteger(Q)||Q<1)return $();let X=dW(D),W=u2(X);if(Object.keys(W).length<1||Object.keys(W).length>16)return $();for(let G of Object.values(W)){let Y=u2(G.value);if(Y.$&&Object.hasOwn(u2(Y.$.value),"after"))return $()}return{query:X,maxRecords:Q}}catch{return $()}}b9();k0();b9();var BU=["$gt","$gte","$lt","$lte"],pW=(D,Z)=>D<Z?-1:D>Z?1:0,V2=(D)=>{throw new JD(`Invalid Records query: ${D}`)};function m3(D){if(!D||typeof D!=="object"||Array.isArray(D)||![Object.prototype,null].includes(Object.getPrototypeOf(D)))return V2("expected a mapping");return D}function cW(D){let{optional:Z,style:$,...J}=D;if(J.kind==="object")return{...J,fields:J.fields.map(K4)};if(J.kind==="map")return{...J,key:cW(J.key),value:cW(J.value)};return structuredClone(J)}function K4(D){return{...cW(D),name:D.name}}function H4({name:D,schema:Z}){return{name:D,type:Z.type,...Z.description===void 0?{}:{description:Z.description}}}function KU(D,Z){if(D==="$ref")return{name:D,kind:"string",nullable:!1,many:!1};let $=Z.fields.find((J)=>J.name===D);if(!$||$.many||$.kind==="object"||$.kind==="map")return V2(`ineligible scalar field: ${D}`);return $}function HU(D,Z){if(Z.kind==="link"||Z.name==="$ref"){if(D!==null&&!(Z.kind==="link"?q1(D):X2(D)))return V2(`invalid reference: ${Z.name}`)}return l2({[Z.name]:Z.kind==="link"&&typeof D==="string"?`[[${D}]]`:D},[{...Z,optional:!1}]),D}function Ob(D){let Z=Object.entries(m3(D));return Tb(Z),Z}function Tb(D){if(D.length<1||D.length>16)return V2("expected 1–16 collections");let Z=0,$=(J,Q)=>{if(++Z>256)return V2("too many selection nodes");let X=m3(J);for(let[W,G]of Object.entries(X)){if(W==="$")continue;if(Q>=4)return V2("too many link levels");$(G,Q+1)}};for(let[,J]of D)$(J,0)}function zU(D,Z,$,J=0,Q=!1){let X=m3(D),W=Object.hasOwn(X,"$")?m3(X.$):{},G=J===0?["where","fields","order","limit","count","after"]:Q?["where","fields","order","limit"]:["where","fields"];if(Object.keys(W).some((V)=>!G.includes(V)))return V2("unsupported option");let Y=Object.hasOwn(W,"fields")?W.fields:Z.fields.map((V)=>V.name);if(!Array.isArray(Y)||Y.some((V)=>typeof V!=="string"||!["$ref","$version"].includes(V)&&!Z.fields.some((_)=>_.name===V))||new Set(Y).size!==Y.length)return V2("invalid projection");let B=[];if(Object.hasOwn(W,"where"))for(let[V,_]of Object.entries(m3(W.where))){let N=KU(V,Z),F=[_];if(_!==null&&typeof _==="object"){let M=m3(_);if(!Object.hasOwn(M,"$in")){let L=Object.keys(M);if(L.length===0||L.some((P)=>!BU.includes(P))||Object.hasOwn(M,"$gt")&&Object.hasOwn(M,"$gte")||Object.hasOwn(M,"$lt")&&Object.hasOwn(M,"$lte"))return V2("invalid bounds");if(N.name==="$ref"||!["integer","number","date","datetime"].includes(N.kind))return V2(`ineligible range field: ${V}`);let C=BU.filter((P)=>Object.hasOwn(M,P)).map((P)=>{let j=M[P];if(j===null)return V2("null bound");return[P,HU(j,N)]});B.push([V,{bounds:C}]);continue}if(Object.keys(M).length!==1||!Object.hasOwn(M,"$in")||!Array.isArray(M.$in)||M.$in.length<1||M.$in.length>100)return V2("invalid $in");F=M.$in}let U=F.map((M)=>HU(M,N));if(new Set(U).size!==U.length)return V2("duplicate $in value");B.push([V,U])}let H={field:"$ref",direction:"asc"};if(Object.hasOwn(W,"order")){let V=Object.entries(m3(W.order));if(V.length!==1)return V2("order requires one field");let[_,N]=V[0];if(KU(_,Z),N!=="asc"&&N!=="desc")return V2("invalid order direction");H={field:_,direction:N}}let K=Object.hasOwn(W,"limit")?W.limit:100;if(typeof K!=="number"||!Number.isInteger(K)||K<1||K>(J===0?500:100))return V2("invalid limit");if(Object.hasOwn(W,"count")&&typeof W.count!=="boolean")return V2("invalid count");if(Object.hasOwn(W,"after")&&(typeof W.after!=="string"||W.after.length===0))return V2("invalid cursor");let z=[];for(let[V,_]of Object.entries(X)){if(V==="$")continue;let N=Z.fields.find((U)=>U.name===V);if(!N||N.kind!=="link")return V2(`ineligible link field: ${V}`);if(J>=4)return V2("too many link levels");let F=new Map(N.to.flatMap((U)=>{return($.get(U)??V2(`unknown link target type: ${U}`)).map((L)=>[L.name,zU(_,L.schema,$,J+1,N.many)])}));z.push({name:V,many:N.many,targets:F})}return{fields:Y,conditions:B,order:H,limit:K,count:W.count===!0,...Object.hasOwn(W,"after")?{after:W.after}:{},explicitOrder:Object.hasOwn(W,"order"),explicitLimit:Object.hasOwn(W,"limit"),links:z}}function VU(D,Z=!0,$=!1){return{fields:D.fields,conditions:[...D.conditions].sort(([J],[Q])=>pW(J,Q)),order:Z||$&&D.explicitOrder?D.order:null,limit:Z||$&&D.explicitLimit?D.limit:null,count:D.count,links:[...D.links].sort((J,Q)=>pW(J.name,Q.name)).map((J)=>({name:J.name,many:J.many,targets:[...J.targets].sort(([Q],[X])=>pW(Q,X)).map(([Q,X])=>[Q,VU(X,!1,J.many)])}))}}function i$(D,Z){let $=Ob(D),J=new Map(Z.map((X)=>[X.name,X])),Q=new Map;for(let X of Z){let W=Q.get(X.schema.type)??[];W.push(X),Q.set(X.schema.type,W)}return $.map(([X,W])=>{let G=J.get(X)??V2(`unknown collection: ${X}`);return{name:X,selection:zU(W,G.schema,Q)}})}function UU(D,Z,$){return JSON.stringify({...D,collection:Z,selection:VU($)})}function FU(D,Z,$){let J;try{J=m3(D)}catch{return V2("invalid cursor")}let{position:Q,ref:X}=J;if(Object.keys(J).length!==4||J.format!==1||J.binding!==Z||typeof Q!=="number"||!Number.isSafeInteger(Q)||Q<=0||Q%$!==0||typeof X!=="string"||!X2(X))return V2("incompatible cursor");return{position:Q,ref:X}}var h1=()=>{throw new r("invalid_query")};function z4(D,Z){if(!W8(D))return h1();let $=[...D.trim()].length;if($<1||$>256)return h1();if(Z===void 0)return{query:D};let J=u2(Z);if(Object.keys(J).some((X)=>!["collections","limit"].includes(X)))return h1();let Q={};if(Object.hasOwn(J,"collections")){let X=J.collections.value;if(!Array.isArray(X)||X.length<1||X.length>16||Reflect.ownKeys(X).length!==X.length+1)return h1();let W=[];for(let G=0;G<X.length;G++){let Y=Object.getOwnPropertyDescriptor(X,String(G));if(!Y?.enumerable||!Object.hasOwn(Y,"value")||!W8(Y.value))return h1();W.push(Y.value)}if(new Set(W).size!==W.length)return h1();Q.collections=W}if(Object.hasOwn(J,"limit")){let X=J.limit.value;if(!Number.isInteger(X)||X<1||X>100)return h1();Q.limit=X}return{query:D,options:Q}}var jb=()=>{throw new r("invalid_query")};function a$(D,Z,$){let J=z4(D,Z),Q=J.query.trim(),X=$.map((Y)=>Y.name),W=X,G=20;if(J.options?.collections){if(J.options.collections.some((Y)=>!X.includes(Y)))return jb();W=J.options.collections}return G=J.options?.limit??G,{terms:[...new Set(Q.toLowerCase().split(/\s+/u))],collections:W,limit:G}}function LU(D,Z,$){if(D.collections.some((Q)=>!Q.searchValues||Q.searchValues.length!==Q.records.length))throw new r("unavailable",!0);let J=D.collections.filter((Q)=>$.collections.includes(Q.name)).flatMap((Q)=>Q.records.flatMap((X,W)=>{let G=Q.searchValues[W];if(!$.terms.every((Y)=>G.some((B)=>B.includes(Y))))return[];return[{collection:Q.name,record:X,score:$.terms.filter((Y)=>G.includes(Y)).length}]}));return J.sort((Q,X)=>X.score-Q.score||(Q.record.$ref<X.record.$ref?-1:Q.record.$ref>X.record.$ref?1:0)),{$meta:{version:Z},matches:J.slice(0,$.limit).map(({collection:Q,record:{$body:X,$path:W,...G}})=>({collection:Q,record:structuredClone(G)}))}}var o$=(D,Z)=>D<Z?-1:D>Z?1:0,n0=(D)=>{throw new JD(`Invalid Records query: ${D}`)};function qb(D,Z,$,J){let{position:Q,ref:X}=FU(D,Z,J);if(Q>=$.length||X!==$[Q-1]?.$ref)return n0("incompatible cursor");return Q}function lW(D,Z){return Z.conditions.every(([$,J])=>{if(!Object.hasOwn(D,$))return!1;let Q=D[$];if(Array.isArray(J))return J.some((X)=>X===Q);if(Q===null)return!1;return J.bounds.every(([X,W])=>{let G=typeof Q==="number"&&typeof W==="number"?Q-W:o$(Q,W);switch(X){case"$gt":return G>0;case"$gte":return G>=0;case"$lt":return G<0;case"$lte":return G<=0}})})}function NU(D,Z,{field:$,direction:J}){let Q=D[$],X=Z[$],W=Q===null||Q===void 0,G=X===null||X===void 0,Y=0;if(W!==G)return W?1:-1;if(!W&&!G){if(Y=typeof Q==="number"&&typeof X==="number"?Q-X:typeof Q==="boolean"&&typeof X==="boolean"?Number(Q)-Number(X):o$(Q,X),J==="desc")Y=-Y}return Y||o$(D.$ref,Z.$ref)}function _U(D){return sW(D.artifact).withContext(D)}function sW(D){let{workspaceId:Z,repository:$}=D.binding,J=new Map(D.collections.map((X)=>[X.name,X])),Q=new Map;for(let X of J.values())for(let W of X.records)Q.set(W.$ref,{record:W,collection:X.name});return{withContext(X){return Ab(X,{workspaceId:Z,repository:$},J,Q,D)}}}function Ab({version:D,identity:Z,cursorCodec:$},{workspaceId:J,repository:Q},X,W,G){let Y=(K)=>X.get(K)??n0(`unknown collection: ${K}`);function*B(K,z){let V=i$(K,[...X.values()]);if(z!==void 0){if(V.reduce((L,{name:C,selection:P})=>L+X.get(C).records.filter((j)=>lW(j,P)).length,0)>z)throw new r("capacity",!1,void 0,void 0,{code:"record_limit_exceeded",maxRecords:z,collections:V.map((L)=>L.name)})}let _=0,N=(M,L,C)=>{if(++_>2000)return n0("too many returned Record occurrences");let P=Object.fromEntries(["$ref","$version",...L.fields.filter((j)=>!["$ref","$version"].includes(j))].filter((j)=>Object.hasOwn(M,j)).map((j)=>[j,structuredClone(M[j])]));if(C!==void 0)P.$fragment=C;for(let j of L.links){if(!Object.hasOwn(M,j.name))continue;let q=M[j.name],O;if(q===null)O=null;else{let R=(j.many?q:[q]).map((y)=>{let{ref:d,fragment:u}=q1(y)??n0("invalid stored link"),S=W.get(d)??n0("unresolved stored link"),w=j.targets.get(S.collection)??n0("incompatible stored link");return{...S,selection:w,fragment:u}}).filter(({record:y,selection:d})=>lW(y,d)),g=j.targets.values().next().value;if(g.explicitOrder)R.sort((y,d)=>NU(y.record,d.record,g.order));if(j.many&&!g.explicitLimit&&R.length>100)return n0("too many matching linked Records");if(g.explicitLimit)R=R.slice(0,g.limit);let E=R.map(({record:y,selection:d,fragment:u})=>N(y,d,u));O=j.many?E:E[0]??null}Object.defineProperty(P,j.name,{value:O,enumerable:!0,writable:!0,configurable:!0})}return P},F={version:D,collections:{}},U=[];for(let{name:M,selection:L}of V){let C=X.get(M).records.filter((R)=>lW(R,L)).sort((R,g)=>NU(R,g,L.order)),P=UU({workspaceId:J,repository:Q,identity:Z,version:D},M,L),j=L.after===void 0?0:qb(yield{operation:"open",token:L.after},P,C,L.limit),q=z===void 0?Math.min(j+L.limit,C.length):C.length,O=C.slice(j,q).map((R,g)=>{if(z!==void 0&&g%L.limit===0)_=0;return N(R,L)}),T=L.count?{count:C.length}:{};if(z===void 0&&q<C.length){let R=yield{operation:"seal",payload:{format:1,binding:P,position:q,ref:C[q-1].$ref}};if(typeof R!=="string"||R.length===0)return n0("invalid sealed cursor");T.next=R}if(Object.keys(T).length)Object.defineProperty(F.collections,M,{value:T,enumerable:!0,writable:!0,configurable:!0});U.push([M,O])}return{...Object.fromEntries(U),$meta:F}}let H=(K,z=$)=>{try{return K.operation==="open"?z.open(K.token):z.seal(K.payload)}catch{return n0("invalid cursor")}};return{collections:{list(){return[...X.values()].sort((K,z)=>o$(K.name,z.name)).map(H4)},schema(K){let z=Y(K);return{...H4(z),fields:z.schema.fields.map(K4)}}},records:{read(K,z){let V=j1(K),_={$meta:{version:D},records:V.map((N)=>{let F=W.get(N);if(!F)return null;if(z?.body&&typeof F.record.$body!=="string")throw new r("unavailable",!0);let{$body:U,$path:M,...L}=F.record;return structuredClone(z?.body?{...L,$body:U}:L)})};if(z?.body&&new TextEncoder().encode(JSON.stringify(_)).byteLength>GU)throw new r("request_too_large");return _},search(K,z){return LU(G,D,a$(K,z,[...X.values()]))},all(K,z){let V=n$(K,z),_=B(V.query,V.maxRecords).next();if(!_.done)return n0("all cannot continue a cursor");return _.value},query(K){let z=B(K),V=z.next();while(!V.done){let _=H(V.value);if(_ instanceof Promise)return n0("asynchronous cursor codec requires asynchronous selection");V=z.next(_)}return V.value},async queryAsync(K,z=$){let V=B(K),_=V.next();while(!_.done){let N;try{N=await H(_.value,z)}catch{return n0("invalid cursor")}_=V.next(N)}return _.value}}}}var v3=()=>Error("Invalid Records cursor");function nW(D){let Z="";for(let $ of D)Z+=String.fromCharCode($);return btoa(Z).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function MU(D){if(!/^[A-Za-z0-9_-]+$/.test(D))throw v3();let Z=Uint8Array.from(atob(D.replace(/-/g,"+").replace(/_/g,"/")),($)=>$.charCodeAt(0));if(nW(Z)!==D)throw v3();return Z}function CU(D){return Ib("records-cursor-v1",D)}function Ib(D,Z){let $=Z.active,J=new Map(Z.keys),Q=(X,W)=>{let G=J.get(X);if(!/^[A-Za-z0-9_-]{1,64}$/.test(X)||!G||G.type!=="secret"||G.algorithm.name!=="AES-GCM"||G.algorithm.length!==256||!G.usages.includes(W))throw v3();return G};return Q($,"encrypt"),Q($,"decrypt"),{async seal(X){try{let W=crypto.getRandomValues(new Uint8Array(12)),G=`${D}.${$}`,Y=new TextEncoder().encode(JSON.stringify(X)),B=await crypto.subtle.encrypt({name:"AES-GCM",iv:W,additionalData:new TextEncoder().encode(G),tagLength:128},Q($,"encrypt"),Y);return`${G}.${nW(W)}.${nW(new Uint8Array(B))}`}catch{throw v3()}},async open(X){try{if(typeof X!=="string")throw v3();let W=X.split(".");if(W.length!==4||W[0]!==D)throw v3();let G=W[1],Y=MU(W[2]),B=MU(W[3]);if(Y.byteLength!==12||B.byteLength<16)throw v3();let H=await crypto.subtle.decrypt({name:"AES-GCM",iv:Y,additionalData:new TextEncoder().encode(`${D}.${G}`),tagLength:128},Q(G,"decrypt"),B);return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(H))}catch{throw v3()}}}}import{isDeepStrictEqual as Eb}from"node:util";j8();Y0();T3();var PU=262144,V4=33554432,s2=()=>{throw new r("invalid_change",!1,"unapplied")};function x8(D){try{return u2(D),D}catch{return s2()}}function r$(D,Z=new Set,$=0){if(D===null||typeof D==="string"||typeof D==="boolean"||typeof D==="number"&&Number.isFinite(D))return D;if(!D||typeof D!=="object"||Z.has(D)||$>32)return s2();Z.add(D);try{if(Array.isArray(D)){if(D.length>1e5||Object.keys(D).length!==D.length||Object.getOwnPropertySymbols(D).length)return s2();return Array.from(D,(J)=>r$(J,Z,$+1))}return Object.fromEntries(Object.entries(x8(D)).map(([J,Q])=>{if(["__proto__","constructor","prototype"].includes(J))return s2();return[J,r$(Q,Z,$+1)]}))}finally{Z.delete(D)}}function OU(D){let Z=x8(D);if(!X2(Z.$ref)||typeof Z.$version!=="string"||!Z.$version.length||Z.$version.length>512)return s2();return{ref:Z.$ref,expectedVersion:Z.$version}}function Sb(D,Z){let $=OU(D),J=x8(Z),{$body:Q,...X}=J,W=Object.hasOwn(J,"$body");if(W&&!f1(Q)||!Object.keys(X).length&&!W||Object.keys(X).some((G)=>G.startsWith("$")||["id","type"].includes(G)))return s2();return{...$,set:r$(X),...W?{body:Q}:{}}}function TU(D,Z,$=!0){if(!Array.isArray(D)||!$&&!D.length||D.length>1e4)return s2();let J=D.map((Q)=>{let X=x8(Q);if(Object.keys(X).filter((G)=>!Z||G!=="body").sort().join(",")!==(Z?"expectedVersion,ref,set":"expectedVersion,ref"))return s2();let W={$ref:X.ref,$version:X.expectedVersion};if(Z&&Object.keys(x8(X.set)).some((G)=>G.startsWith("$")))return s2();return Z?Sb(W,{...x8(X.set),...Object.hasOwn(X,"body")?{$body:X.body}:{}}):OU(W)});if(new Set(J.map((Q)=>Q.ref)).size!==J.length)return s2();return J}function iW(D,Z=!1){return TU(D,!0,Z)}function Rb(D){let Z=x8(D);if(!X2(Z.$ref)||Object.keys(Z).some((Y)=>Y.startsWith("$")&&!["$ref","$filing","$body"].includes(Y)))return s2();let{$ref:$,$filing:J,$body:Q,...X}=Z,W=Object.hasOwn(Z,"$body");if(W&&!f1(Q))return s2();let G;if(J!==void 0){let Y=x8(J);if(Object.entries(Y).some(([B,H])=>!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(B)||["constructor","prototype"].includes(B)||typeof H!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(H)))return s2();G={...Y}}return{ref:$,fields:r$(X),...G?{filing:G}:{},...W?{body:Q}:{}}}function aW(D,Z=[],$=[]){let J=iW(D,!0);if(!Array.isArray(Z)||Z.length>1e4)return s2();let Q=Z.map((G)=>{let Y=x8(G);if(Object.keys(Y).some((H)=>!["ref","fields","filing","body"].includes(H))||!Object.hasOwn(Y,"ref")||!Object.hasOwn(Y,"fields"))return s2();let B=x8(Y.fields);if(Object.keys(B).some((H)=>H.startsWith("$")))return s2();return Rb({...B,$ref:Y.ref,...Object.hasOwn(Y,"filing")?{$filing:Y.filing}:{},...Object.hasOwn(Y,"body")?{$body:Y.body}:{}})}),X=TU($,!1),W=[...J,...Q,...X].map((G)=>G.ref);if(!W.length||W.length>1e4||new Set(W).size!==W.length)return s2();return{updates:J,creates:Q,deletes:X}}function t$(D,Z=PU){if(new TextEncoder().encode(JSON.stringify(D)).byteLength>Z)throw new r("request_too_large",!1,"unapplied")}function oW(D,Z){let $={400:["invalid_query","invalid_change"],401:["unauthenticated"],403:["access_denied"],409:["conflict","apply_pending"],413:["request_too_large"],429:["capacity"],503:["unavailable","apply_pending"]},J=Z&&typeof Z==="object"&&"error"in Z?Z.error:void 0,Q=J&&typeof J==="object"?J:void 0,X=$[D]?.find((Y)=>Y===Q?.code)??"unavailable",W=["unapplied","uncertain","applied"].includes(String(Q?.effect))?Q.effect:void 0,G;try{G=Q?.detail===void 0?void 0:C9(Q.detail)}catch{}if(G&&"reason"in G&&X!=="invalid_change")G=void 0;return A6(new r(X,typeof Q?.retryable==="boolean"?Q.retryable:["capacity","unavailable","apply_pending"].includes(X),X==="conflict"?"unapplied":W,X==="invalid_change"&&typeof Q?.component==="string"&&/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(Q.component)?Q.component:void 0,G),Q?.message,Q?.detail)}function Z5(D,Z="hosted"){if(!D||typeof D!=="object"||Array.isArray(D))throw new r("invalid_query");let $=D;if($.operation==="records.all"){if(Object.keys($).sort().join(",")!=="maxRecords,operation,query,repository"||!Q2($.repository))throw new r("invalid_query");let X=n$($.query,{maxRecords:$.maxRecords});return{repository:$.repository,operation:$.operation,...X}}if($.operation==="records.read"){let X=u2(D);if(Object.keys(X).filter((B)=>B!=="options").sort().join(",")!=="operation,refs,repository"||!Q2($.repository))throw new r("invalid_query");let W=j1($.refs);if(Object.hasOwn($,"options")&&$.options===void 0)throw new r("invalid_query");let G=lH($.options),Y={repository:$.repository,operation:$.operation,refs:W,...$.options===void 0?{}:{options:G}};return t$(Y),Y}if($.operation==="history.list"||$.operation==="history.at"||$.operation==="history.changes"){let X=$.operation==="history.at"?["repository","operation","instant"]:["repository","operation","options"];if(![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).some((W)=>typeof W!=="string"||!X.includes(W)||!Object.getOwnPropertyDescriptor(D,W)?.enumerable||!Object.hasOwn(Object.getOwnPropertyDescriptor(D,W),"value"))||!["repository","operation"].every((W)=>Object.hasOwn(D,W))||!Q2($.repository))throw new r("invalid_query");if($.operation==="history.changes"){if(Object.hasOwn(D,"options")&&$.options===void 0)throw new r("invalid_query");return{repository:$.repository,operation:$.operation,options:HH($.options)}}return $.operation==="history.list"?{repository:$.repository,operation:$.operation,options:KH($.options)}:{repository:$.repository,operation:$.operation,instant:f7($.instant)}}if($.operation==="records.search"){if(![Object.prototype,null].includes(Object.getPrototypeOf(D))||Reflect.ownKeys(D).some((X)=>typeof X!=="string"||!["repository","operation","query","options"].includes(X)||!Object.getOwnPropertyDescriptor(D,X)?.enumerable||!Object.hasOwn(Object.getOwnPropertyDescriptor(D,X),"value"))||!["repository","operation","query"].every((X)=>Object.hasOwn(D,X))||!Q2($.repository))throw new r("invalid_query");return{repository:$.repository,operation:$.operation,...z4($.query,$.options)}}let J=$.operation==="collections.list"?"operation,repository":$.operation==="collections.schema"?"name,operation,repository":$.operation==="records.query"?"operation,query,repository":$.operation==="changes.validate"?"operation,repository,updates":$.operation==="changes.apply"?"applyId,operation,repository,updates":"",Q=Object.keys($).filter((X)=>!["creates","deletes"].includes(X)||!["changes.validate","changes.apply"].includes($.operation)).sort().join(",");if(!J||Q!==J||!Q2($.repository)||$.operation==="collections.schema"&&(typeof $.name!=="string"||$.name.length>128||!$.name.length))throw new r("invalid_query");if($.operation==="changes.validate"||$.operation==="changes.apply"){if($.operation==="changes.apply"&&(typeof $.applyId!=="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test($.applyId)))return s2();t$($,Z==="local"?V4:PU);let X=aW($.updates,$.creates===void 0?[]:$.creates,$.deletes===void 0?[]:$.deletes);return{...$,updates:X.updates,...$.creates!==void 0?{creates:X.creates}:{},...$.deletes!==void 0?{deletes:X.deletes}:{}}}return $}X8();j8();Y0();function jU(D){let Z=Q8(D);if(!Z||Array.isArray(Z)||typeof Z!=="object"||Object.keys(Z).sort().join(",")!=="records,repository"||!Q2(Z.repository)||!Array.isArray(Z.records)||!Z.records.length||Z.records.length>1e4||new Set(Z.records.map(($)=>$?.ref)).size!==Z.records.length)throw new O3("Invalid record deletion batch");for(let $ of Z.records)if(!$||Array.isArray($)||typeof $!=="object"||Object.keys($).sort().join(",")!=="expectedVersion,ref"||!X2($.ref)||typeof $.expectedVersion!=="string"||!/^record-v1:[0-9a-f]{64}$/.test($.expectedVersion))throw new O3("Invalid record deletion");return structuredClone(Z)}k0();function rW(D,Z){return D&&Z?.naming?`${D}/${Z.naming.collection}/_schema.yaml`:void 0}function qU(D,Z,$){if(D.type!=="source"||D.fields.some((Q)=>Q.name==="media_type"))return!1;let J=(Q)=>$&&Object.hasOwn($,Q)?$[Q]:Z[Q];return J("type")==="source"&&J("kind")==="file"&&(Object.hasOwn(Z,"media_type")||!!$&&Object.hasOwn($,"media_type"))}function tW(D,Z,$,J=!1){try{return Z()}catch(Q){throw Q instanceof y2?Q.atRecord(D,$,J):Q}}function wb(D,Z){if(!D.length)return[];jU({repository:"general",records:D});let $=new Set(D.map((X)=>X.ref)),J=D.map((X)=>{let W=Z.records.get(X.ref);if(!W||!Z.types.has(X.ref))throw new JD("Record is missing or outside repository scope");if(W.version!==X.expectedVersion)throw new JD("Reviewed record version is stale");return W});if((Z.incomingReferences??[...Z.records.values()].flatMap((X)=>$.has(X.ref)?[]:r6(X.fields,X.schema.fields).filter((W)=>$.has(W)).map((W)=>({from:X.ref,to:W})))).length)throw new JD("Record is referenced outside the deletion batch");return J}function xb(D,Z,$=!1){if(!D.length||D.length>1e4||new Set(D.map((J)=>J.ref)).size!==D.length)throw new JD("Invalid record update batch");return D.map((J)=>{let Q=Z.records.get(J.ref);return tW(J.ref,()=>{if(!Q||!Z.types.has(J.ref))throw new JD("Record is missing or outside repository scope");if(Q.version!==J.expectedVersion)throw new JD("Reviewed record version is stale");if(Object.hasOwn(J,"body")&&!f1(J.body))throw new JD("Invalid Record body");let X=Q.schema.naming?[...`${Q.schema.naming.folder}/${Q.schema.naming.filename}`.matchAll(/<([^>]+)>/g)].map((B)=>B[1]).filter((B)=>Z3(Q.schema.fields.find((H)=>H.name===B))):[],W=Object.keys(J.set).find((B)=>!Q.schema.fields.some((H)=>H.name===B));if(W)throw new y2("unknown",W);if(!Object.keys(J.set).length&&!Object.hasOwn(J,"body")||Object.keys(J.set).some((B)=>B.startsWith("$"))||"id"in J.set||"type"in J.set||X.some((B)=>Object.hasOwn(J.set,B)&&!Eb(J.set[B],Q.fields[B])))throw new JD("Unknown or immutable record field");let G=$?$5(J.set,Q.schema.fields,!0):structuredClone(J.set),Y={...Q.fields,...G};return l2(Y,Q.schema.fields,(B)=>Z.types.get(B)),{record:Q,set:G,fields:Y,...Object.hasOwn(J,"body")?{body:J.body}:{}}},rW(Z.repository,Q?.schema),!!Q&&qU(Q.schema,Q.fields,J.set))})}function bb(D){let Z=new Map,$=new Map;for(let J of D.collections)for(let Q of J.records){let{$ref:X,$version:W,$body:G,$path:Y,...B}=Q;Z.set(X,{ref:X,version:W,schema:J.schema,fields:$5(B,J.schema.fields,!0)}),$.set(X,J.schema.type)}return{records:Z,types:$,repository:D.binding.repository}}function AU(D,Z,$=[],J=[],Q={}){let X=!Z.length&&!$.length&&J.length?{updates:iW(Z,!0),creates:[]}:aW(Z,$),W=[...X.updates,...X.creates,...J].map((z)=>z.ref);if(W.length>1e4||new Set(W).size!==W.length)throw new JD("Invalid record change batch");let G=bb(D),Y=new Map(Q.types??G.types),B={records:G.records,types:Y,repository:G.repository,...Q.incomingReferences===void 0?{}:{incomingReferences:Q.incomingReferences}},H=wb(J,B);for(let z of H)Y.delete(z.ref);return{creates:kb(X.creates,D.collections,Y,D.binding.repository),updates:X.updates.length?xb(X.updates,{...B,types:Y},!0):[],deletes:H}}function kb(D,Z,$,J){if(new Set(D.map((W)=>W.ref)).size!==D.length)throw new JD("Duplicate creation ref");let Q=new Set,X=D.map((W)=>{if($.has(W.ref))throw new JD("Record already exists");let G=G4(W.ref,Z).schema;return tW(W.ref,()=>{let Y=WU({...W,fields:$5(W.fields,G.fields,!0)},Z);if(Q.has(Y.path))throw new JD("Duplicate creation path");return Q.add(Y.path),$.set(Y.ref,Y.schema.type),Y},rW(J,G),qU(G,W.fields))});for(let W of X)tW(W.ref,()=>l2(W.fields,W.schema.fields,(G)=>$.get(G)),rW(J,W.schema));return X}RW();k0();import{posix as eW}from"node:path";import{isDeepStrictEqual as DG}from"node:util";function SU(D,Z,$){let J=Z.flatMap((G)=>{let Y=G==="."?D.path:eW.join(G,D.path),B=[...$.schemas].filter(([H])=>Y.startsWith(`${H}/`)).sort(([H],[K])=>K.length-H.length);return B[0]?[{path:Y,collection:B[0][0],schema:B[0][1]}]:[]});if(J.length!==1)throw new JD("Record creation path does not identify one managed collection");let Q=J[0];if([...$.paths.values()].includes(Q.path))throw new JD("Record creation path already exists");let X=Buffer.concat([gb(D.fields,Q.schema.fields),Buffer.from(D.body??"")]),W=g1(X.toString("utf8"),Q.schema,eW.relative(Q.collection,Q.path));if(W.ref!==D.ref||!DG(W.fields,D.fields)||W.body!==(D.body??""))throw new JD("Created record identity or fields do not match its request");return{ref:D.ref,path:Q.path,fields:D.fields,bytes:X,schema:Q.schema}}function IU(D,Z){if(a6(D)&&a6(Z)){if(D.comment=Z.comment,D.commentBefore=Z.commentBefore,D.spaceBefore=Z.spaceBefore,h3(D)&&h3(Z)&&typeof D.value===typeof Z.value)D.type=Z.type}}function e$(D,Z,$){if(IU(D,$),Z.many&&k1(D)){D.flow=k1($)?$.flow:Z.style==="inline";for(let[J,Q]of D.items.entries())e$(Q,{...Z,many:!1},k1($)?$.items[J]:void 0)}else if(b1(D)){if(b1($))D.flow=$.flow;let J=new Map(b1($)?$.items.map((Q)=>[h3(Q.key)?String(Q.key.value):void 0,Q]):[]);for(let Q of D.items){let X=h3(Q.key)?String(Q.key.value):void 0,W=J.get(X);if(Z.kind==="map"&&Z.key.kind==="integer"&&W)Q.key=W.key;IU(Q.key,W?.key);let G=Z.kind==="object"?Z.fields.find((Y)=>Y.name===X):Z.kind==="map"?Z.value:void 0;if(G)e$(Q.value,G,W?.value)}}}function gb(D,Z){let $=new AW(D);for(let Q of Z)e$($.get(Q.name,!0),Q);let J=$.toString({nullStr:"~",lineWidth:0}).trimEnd();return Buffer.from(`---
353
353
  ${J}
354
354
  ---
355
355
  `)}function RU(D,Z,$){let J=D.bytes.toString("utf8"),Q=/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))([\s\S]*)$/.exec(J),X=J4(Q[2],{version:"1.2"}),W=!1;for(let[K,z]of Object.entries(Z)){if(DG(D.fields[K],z))continue;let V=X.createNode(z),_=D.schema.fields.find((N)=>N.name===K);e$(V,_,X.get(K,!0)),X.set(K,V),W=!0}if(!W&&($===void 0||$===D.body))return D.bytes;let G=X.toString({lineWidth:0}).replace(/\n$/,""),Y=W?Q[1]+(Q[1].endsWith(`\r
@@ -487,7 +487,7 @@ For more details, run:
487
487
  `;else Q=String.fromCharCode(J);return++this.state.curLine,this.state.lineStart=this.state.pos,Q}jsxReadString($){let J="",Q=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(m.UnterminatedString,this.state.startLoc);let X=this.input.charCodeAt(this.state.pos);if(X===$)break;if(X===38)J+=this.input.slice(Q,this.state.pos),J+=this.jsxReadEntity(),Q=this.state.pos;else if(N5(X))J+=this.input.slice(Q,this.state.pos),J+=this.jsxReadNewLine(!1),Q=this.state.pos;else++this.state.pos}J+=this.input.slice(Q,this.state.pos++),this.finishToken(130,J)}jsxReadEntity(){let $=++this.state.pos;if(this.codePointAtPos(this.state.pos)===35){++this.state.pos;let J=10;if(this.codePointAtPos(this.state.pos)===120)J=16,++this.state.pos;let Q=this.readInt(J,void 0,!1,"bail");if(Q!==null&&Q<=1114111&&this.codePointAtPos(this.state.pos)===59)return++this.state.pos,String.fromCodePoint(Q)}else{let J=0,Q=!1;while(J++<10&&this.state.pos<this.length&&!(Q=this.codePointAtPos(this.state.pos)===59))++this.state.pos;if(Q){let X=this.input.slice($,this.state.pos),W=Nm[X];if(++this.state.pos,W)return W}}return this.state.pos=$,"&"}jsxReadWord(){let $,J=this.state.pos;do $=this.input.charCodeAt(++this.state.pos);while(i1($)||$===45);this.finishToken(136,this.input.slice(J,this.state.pos))}jsxParseIdentifier(){let $=this.startNode();if(this.match(136))$.name=this.state.value;else if($Y(this.state.type))$.name=a3(this.state.type);else this.unexpected();return this.next(),this.finishNode($,"JSXIdentifier")}jsxParseNamespacedName(){let $=this.state.startLoc,J=this.jsxParseIdentifier();if(!this.eat(10))return J;let Q=this.startNodeAt($);return Q.namespace=J,Q.name=this.jsxParseIdentifier(),this.finishNode(Q,"JSXNamespacedName")}jsxParseElementName(){let $=this.state.startLoc,J=this.jsxParseNamespacedName();if(J.type==="JSXNamespacedName")return J;while(this.eat(12)){let Q=this.startNodeAt($);Q.object=J,Q.property=this.jsxParseIdentifier(),J=this.finishNode(Q,"JSXMemberExpression")}return J}jsxParseAttributeValue(){let $;switch(this.state.type){case 2:if($=this.startNode(),this.setContext(Y2.brace),this.next(),$=this.jsxParseExpressionContainer($,Y2.j_oTag),$.expression.type==="JSXEmptyExpression")this.raise(W3.AttributeIsEmpty,$);return $;case 138:case 130:return this.parseExprAtom();default:throw this.raise(W3.UnsupportedJsxValue,this.state.startLoc)}}jsxParseEmptyExpression(){let $=this.startNodeAt(this.state.lastTokEndLoc);return this.finishNodeAt($,"JSXEmptyExpression",this.state.startLoc)}jsxParseSpreadChild($){return this.next(),$.expression=this.parseExpression(),this.setContext(Y2.j_expr),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode($,"JSXSpreadChild")}jsxParseExpressionContainer($,J){if(this.match(4))$.expression=this.jsxParseEmptyExpression();else{let Q=this.parseExpression();if(Q.type==="SequenceExpression"&&!Q.extra?.parenthesized)this.raise(W3.UnexpectedSequenceExpression,Q.expressions[1]);$.expression=Q}return this.setContext(J),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode($,"JSXExpressionContainer")}jsxParseAttribute(){if(this.match(2)){let J=this.startNode();return this.setContext(Y2.brace),this.next(),this.expect(17),J.argument=this.parseMaybeAssignAllowIn(),this.setContext(Y2.j_oTag),this.state.canStartJSXElement=!0,this.expect(4),this.finishNode(J,"JSXSpreadAttribute")}let $=this.startNode();return $.name=this.jsxParseNamespacedName(),$.value=this.eat(25)?this.jsxParseAttributeValue():null,this.finishNode($,"JSXAttribute")}jsxParseOpeningElementAt($){if(this.eat(139)){let Q=this.startNodeAt($);return this.finishNode(Q,"JSXOpeningFragment")}let J=this.startNodeAt($);return J.name=this.jsxParseElementName(),this.jsxParseOpeningElementAfterName(J)}jsxParseOpeningElementAfterName($){let J=[];while(!this.match(52)&&!this.match(139))J.push(this.jsxParseAttribute());return $.attributes=J,$.selfClosing=this.eat(52),this.expect(139),this.finishNode($,"JSXOpeningElement")}jsxParseClosingElementAt($){if(this.eat(139)){let Q=this.startNodeAt($);return this.finishNode(Q,"JSXClosingFragment")}let J=this.startNodeAt($);return J.name=this.jsxParseElementName(),this.expect(139),this.finishNode(J,"JSXClosingElement")}jsxParseElementAt($){let J=this.startNodeAt($),Q=[],X=this.jsxParseOpeningElementAt($),W=null;if(!X.selfClosing){D:for(;;)switch(this.state.type){case 138:if($=this.state.startLoc,this.next(),this.eat(52)){this.setLoc($),W=this.jsxParseClosingElementAt($);break D}Q.push(this.jsxParseElementAt($));break;case 137:Q.push(this.parseLiteral(this.state.value,"JSXText"));break;case 2:{let G=this.startNode();if(this.setContext(Y2.brace),this.next(),this.match(17))Q.push(this.jsxParseSpreadChild(G));else Q.push(this.jsxParseExpressionContainer(G,Y2.j_expr));break}default:this.unexpected()}if(n3(X)&&!n3(W)&&W!==null)this.raise(W3.MissingClosingTagFragment,W);else if(!n3(X)&&n3(W))this.raise(W3.MissingClosingTagElement,W,{openingTagName:F5(X.name)});else if(!n3(X)&&!n3(W)){if(F5(W.name)!==F5(X.name))this.raise(W3.MissingClosingTagElement,W,{openingTagName:F5(X.name)})}}if(n3(X))J.openingFragment=X,J.closingFragment=W;else J.openingElement=X,J.closingElement=W;if(J.children=Q,this.match(43))throw this.raise(W3.UnwrappedAdjacentJSXElements,this.state.startLoc);return n3(X)?this.finishNode(J,"JSXFragment"):this.finishNode(J,"JSXElement")}jsxParseElement(){let $=this.state.startLoc;return this.next(),this.jsxParseElementAt($)}setContext($){let{context:J}=this.state;J[J.length-1]=$}parseExprAtom($){if(this.match(138))return this.jsxParseElement();else if(this.match(43)&&this.input.charCodeAt(this.state.pos)!==33)return this.replaceToken(138),this.jsxParseElement();else return super.parseExprAtom($)}skipSpace(){if(!this.curContext().preserveSpace)super.skipSpace()}getTokenFromCode($){let J=this.curContext();if(J===Y2.j_expr){this.jsxReadToken();return}if(J===Y2.j_oTag||J===Y2.j_cTag){if(h8($)){this.jsxReadWord();return}if($===62){++this.state.pos,this.finishToken(139);return}if(($===34||$===39)&&J===Y2.j_oTag){this.jsxReadString($);return}}if($===60&&this.state.canStartJSXElement&&this.input.charCodeAt(this.state.pos+1)!==33){++this.state.pos,this.finishToken(138);return}super.getTokenFromCode($)}updateContext($){let{context:J,type:Q}=this.state;if(Q===52&&$===138)J.splice(-2,2,Y2.j_cTag),this.state.canStartJSXElement=!1;else if(Q===138)J.push(Y2.j_oTag);else if(Q===139){let X=J[J.length-1];if(X===Y2.j_oTag&&$===52||X===Y2.j_cTag)J.pop(),this.state.canStartJSXElement=J[J.length-1]===Y2.j_expr;else this.setContext(Y2.j_expr),this.state.canStartJSXElement=!0}else this.state.canStartJSXElement=ih(Q)}};class Q_ extends pZ{tsNames=new Map}class X_ extends cZ{get inTSNamespace(){let D=this.scopeStack;return D.length>=2&&D[D.length-1].flags===0&&(D[D.length-2].flags&2048)>0}importsStack=[];createScope(D){return this.importsStack.push(new Set),new Q_(D)}enter(D){if(D&3072)this.importsStack.push(new Set);super.enter(D)}exit(){let D=super.exit();if(D&3072)this.importsStack.pop();return D}hasImport(D,Z){let $=this.importsStack.length;if(this.importsStack[$-1].has(D))return!0;if(!Z&&$>1){for(let J=0;J<$-1;J++)if(this.importsStack[J].has(D))return!0}return!1}declareName(D,Z,$){if(Z&4096){if(this.hasImport(D,!0))this.parser.raise(m.VarRedeclaration,$,{identifierName:D});this.importsStack[this.importsStack.length-1].add(D);return}let J=this.currentScope(),Q=J.tsNames.get(D)||0;if(Z&1024){this.maybeExportDefined(J,D),J.tsNames.set(D,Q|16);return}if(super.declareName(D,Z,$),Z&2){if(!(Z&1))this.checkRedeclarationInScope(J,D,Z,$),this.maybeExportDefined(J,D);Q=Q|1}if(Z&256)Q=Q|2;if(Z&512)Q=Q|4;if(Z&128)Q=Q|8;if(Q)J.tsNames.set(D,Q)}isRedeclaredInScope(D,Z,$){let J=D.tsNames.get(Z);if((J&2)>0){if($&256){let Q=($&512)>0,X=(J&4)>0;return Q!==X}return!0}if($&128&&(J&8)>0)if(D.names.get(Z)&2)return!!($&1);else return!1;if($&2&&(J&1)>0)return!0;return super.isRedeclaredInScope(D,Z,$)}checkLocalExport(D){let{name:Z}=D;if(this.hasImport(Z))return;let $=this.scopeStack.length;for(let J=$-1;J>=0;J--){let X=this.scopeStack[J].tsNames.get(Z);if((X&1)>0||(X&16)>0)return}super.checkLocalExport(D)}}class W_{sawUnambiguousESM=!1;ambiguousScriptDifferentAst=!1;sourceToOffsetPos(D){return D+this.startIndex}offsetToSourcePos(D){return D-this.startIndex}hasPlugin(D){if(typeof D==="string")return this.plugins.has(D);else{let[Z,$]=D;if(!this.hasPlugin(Z))return!1;let J=this.plugins.get(Z);for(let Q of Object.keys($))if(J?.[Q]!==$[Q])return!1;return!0}}getPluginOption(D,Z){return this.plugins.get(D)?.[Z]}}function G_(D,Z){if(D.trailingComments===void 0)D.trailingComments=Z;else D.trailingComments.unshift(...Z)}function Pm(D,Z){if(D.leadingComments===void 0)D.leadingComments=Z;else D.leadingComments.unshift(...Z)}function y4(D,Z){if(D.innerComments===void 0)D.innerComments=Z;else D.innerComments.unshift(...Z)}function i3(D,Z,$){let J=null,Q=Z.length;while(J===null&&Q>0)J=Z[--Q];if(J===null||J.start>$.start)y4(D,$.comments);else G_(J,$.comments)}class Y_ extends W_{addComment(D){if(this.filename)D.loc.filename=this.filename;let{commentsLen:Z}=this.state;if(this.comments.length!==Z)this.comments.length=Z;this.comments.push(D),this.state.commentsLen++}processComment(D){let{commentStack:Z}=this.state,$=Z.length;if($===0)return;let J=$-1,Q=Z[J];if(Q.start===D.end)Q.leadingNode=D,J--;let X=D.start;for(;J>=0;J--){let W=Z[J],G=W.end;if(G>X)W.containingNode=D,this.finalizeComment(W),Z.splice(J,1);else{if(G===X)W.trailingNode=D;break}}}finalizeComment(D){let{comments:Z}=D;if(D.leadingNode!==null||D.trailingNode!==null){if(D.leadingNode!==null)G_(D.leadingNode,Z);if(D.trailingNode!==null)Pm(D.trailingNode,Z)}else{let{containingNode:$,start:J}=D;if(this.input.charCodeAt(this.offsetToSourcePos(J)-1)===44)switch($.type){case"ObjectExpression":case"ObjectPattern":i3($,$.properties,D);break;case"CallExpression":case"NewExpression":case"OptionalCallExpression":i3($,$.arguments,D);break;case"ImportExpression":i3($,[$.source,$.options??null],D);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":case"TSTypeParameterDeclaration":i3($,$.params,D);break;case"ArrayExpression":case"ArrayPattern":i3($,$.elements,D);break;case"ExportNamedDeclaration":case"ImportDeclaration":i3($,$.specifiers,D);break;case"TSEnumBody":i3($,$.members,D);break;case"TSInterfaceBody":i3($,$.body,D);break;default:y4($,Z)}else y4($,Z)}}finalizeRemainingComments(){let{commentStack:D}=this.state;for(let Z=D.length-1;Z>=0;Z--)this.finalizeComment(D[Z]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(D){let{commentStack:Z}=this.state,{length:$}=Z;if($===0)return;let J=Z[$-1];if(J.leadingNode===D)J.leadingNode=null}takeSurroundingComments(D,Z,$){let{commentStack:J}=this.state,Q=J.length;if(Q===0)return;let X=Q-1;for(;X>=0;X--){let W=J[X],G=W.end;if(W.start===$)W.leadingNode=D;else if(G===Z)W.trailingNode=D;else if(G<Z)break}}}class JY{flags=2048;get strict(){return(this.flags&1)>0}set strict(D){if(D)this.flags|=1;else this.flags&=-2}startIndex;curLine;lineStart;startLoc;endLoc;init({strictMode:D,sourceType:Z,startIndex:$,startLine:J,startColumn:Q}){this.strict=D===!1?!1:D===!0?!0:Z==="module",this.startIndex=$,this.curLine=J,this.lineStart=-Q,this.startLoc=this.endLoc=new N0(J,Q,$)}errors=[];noArrowAt=[];noArrowParamsConversionAt=[];get canStartArrow(){return(this.flags&2)>0}set canStartArrow(D){if(D)this.flags|=2;else this.flags&=-3}get inType(){return(this.flags&4)>0}set inType(D){if(D)this.flags|=4;else this.flags&=-5}get noAnonFunctionType(){return(this.flags&8)>0}set noAnonFunctionType(D){if(D)this.flags|=8;else this.flags&=-9}get hasFlowComment(){return(this.flags&16)>0}set hasFlowComment(D){if(D)this.flags|=16;else this.flags&=-17}get isAmbientContext(){return(this.flags&32)>0}set isAmbientContext(D){if(D)this.flags|=32;else this.flags&=-33}get inAbstractClass(){return(this.flags&64)>0}set inAbstractClass(D){if(D)this.flags|=64;else this.flags&=-65}get inDisallowConditionalTypesContext(){return(this.flags&128)>0}set inDisallowConditionalTypesContext(D){if(D)this.flags|=128;else this.flags&=-129}get inConditionalConsequent(){return(this.flags&256)>0}set inConditionalConsequent(D){if(D)this.flags|=256;else this.flags&=-257}get inHackPipelineBody(){return(this.flags&512)>0}set inHackPipelineBody(D){if(D)this.flags|=512;else this.flags&=-513}get seenTopicReference(){return(this.flags&1024)>0}set seenTopicReference(D){if(D)this.flags|=1024;else this.flags&=-1025}labels=[];commentsLen=0;commentStack=[];pos=0;type=135;value=null;start=0;end=0;lastTokEndLoc=null;lastTokStartLoc=null;context=[Y2.brace];get canStartJSXElement(){return(this.flags&2048)>0}set canStartJSXElement(D){if(D)this.flags|=2048;else this.flags&=-2049}get containsEsc(){return(this.flags&4096)>0}set containsEsc(D){if(D)this.flags|=4096;else this.flags&=-4097}firstInvalidTemplateEscapePos=null;get hasTopLevelAwait(){return(this.flags&8192)>0}set hasTopLevelAwait(D){if(D)this.flags|=8192;else this.flags&=-8193}strictErrors=new Map;tokensLength=0;curPosition(){return new N0(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){let D=new JY;return D.flags=this.flags,D.startIndex=this.startIndex,D.curLine=this.curLine,D.lineStart=this.lineStart,D.startLoc=this.startLoc,D.endLoc=this.endLoc,D.errors=this.errors.slice(),D.noArrowAt=this.noArrowAt.slice(),D.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),D.labels=this.labels.slice(),D.commentsLen=this.commentsLen,D.commentStack=this.commentStack.slice(),D.pos=this.pos,D.type=this.type,D.value=this.value,D.start=this.start,D.end=this.end,D.lastTokEndLoc=this.lastTokEndLoc,D.lastTokStartLoc=this.lastTokStartLoc,D.context=this.context.slice(),D.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,D.strictErrors=this.strictErrors,D.tokensLength=this.tokensLength,D}}var Om=function D(Z){return Z>=48&&Z<=57},vN={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},hZ={bin:(D)=>D===48||D===49,oct:(D)=>D>=48&&D<=55,dec:(D)=>D>=48&&D<=57,hex:(D)=>D>=48&&D<=57||D>=65&&D<=70||D>=97&&D<=102};function uN(D,Z,$,J,Q,X){let W=$,G=J,Y=Q,B="",H=null,K=$,{length:z}=Z;for(;;){if($>=z){X.unterminated(W,G,Y),B+=Z.slice(K,$);break}let V=Z.charCodeAt($);if(Tm(D,V,Z,$)){B+=Z.slice(K,$);break}if(V===92){B+=Z.slice(K,$);let _=jm(Z,$,J,Q,D==="template",X);if(_.ch===null&&!H)H={pos:$,lineStart:J,curLine:Q};else B+=_.ch;({pos:$,lineStart:J,curLine:Q}=_),K=$}else if(V===8232||V===8233)++$,++Q,J=$;else if(V===10||V===13)if(D==="template"){if(B+=Z.slice(K,$)+`
488
488
  `,++$,V===13&&Z.charCodeAt($)===10)++$;++Q,K=J=$}else X.unterminated(W,G,Y);else++$}return{pos:$,str:B,firstInvalidLoc:H,lineStart:J,curLine:Q}}function Tm(D,Z,$,J){if(D==="template")return Z===96||Z===36&&$.charCodeAt(J+1)===123;return Z===(D==="double"?34:39)}function jm(D,Z,$,J,Q,X){let W=!Q;Z++;let G=(B)=>({pos:Z,ch:B,lineStart:$,curLine:J}),Y=D.charCodeAt(Z++);switch(Y){case 110:return G(`
489
489
  `);case 114:return G("\r");case 120:{let B;return{code:B,pos:Z}=pG(D,Z,$,J,2,!1,W,X),G(B===null?null:String.fromCharCode(B))}case 117:{let B;return{code:B,pos:Z}=K_(D,Z,$,J,W,X),G(B===null?null:String.fromCodePoint(B))}case 116:return G("\t");case 98:return G("\b");case 118:return G("\v");case 102:return G("\f");case 13:if(D.charCodeAt(Z)===10)++Z;case 10:$=Z,++J;case 8232:case 8233:return G("");case 56:case 57:if(Q)return G(null);else X.strictNumericEscape(Z-1,$,J);default:if(Y>=48&&Y<=55){let B=Z-1,K=/^[0-7]+/.exec(D.slice(B,Z+2))[0],z=parseInt(K,8);if(z>255)K=K.slice(0,-1),z=parseInt(K,8);Z+=K.length-1;let V=D.charCodeAt(Z);if(K!=="0"||V===56||V===57)if(Q)return G(null);else X.strictNumericEscape(B,$,J);return G(String.fromCharCode(z))}return G(String.fromCharCode(Y))}}function pG(D,Z,$,J,Q,X,W,G){let Y=Z,B;if({n:B,pos:Z}=B_(D,Z,$,J,16,Q,X,!1,G,!W),B===null)if(W)G.invalidEscapeSequence(Y,$,J);else Z=Y-1;return{code:B,pos:Z}}function B_(D,Z,$,J,Q,X,W,G,Y,B){let H=Z,K=Q===16?vN.hex:vN.decBinOct,z=Q===16?hZ.hex:Q===10?hZ.dec:Q===8?hZ.oct:hZ.bin,V=!1,_=0;for(let N=0,F=X==null?1/0:X;N<F;++N){let U=D.charCodeAt(Z),M;if(U===95&&G!=="bail"){let L=D.charCodeAt(Z-1),C=D.charCodeAt(Z+1);if(!G){if(B)return{n:null,pos:Z};Y.numericSeparatorInEscapeSequence(Z,$,J)}else if(Number.isNaN(C)||!z(C)||K.has(L)||K.has(C)){if(B)return{n:null,pos:Z};Y.unexpectedNumericSeparator(Z,$,J)}++Z;continue}if(U>=97)M=U-97+10;else if(U>=65)M=U-65+10;else if(Om(U))M=U-48;else M=1/0;if(M>=Q)if(M<=9){if(B)return{n:null,pos:Z};Y.invalidDigit(Z,$,J,Q),M=0}else if(W)M=0,V=!0;else break;++Z,_=_*Q+M}if(Z===H||X!=null&&Z-H!==X||V)return{n:null,pos:Z};return{n:_,pos:Z}}function K_(D,Z,$,J,Q,X){let W=D.charCodeAt(Z),G;if(W===123){if(++Z,{code:G,pos:Z}=pG(D,Z,$,J,D.indexOf("}",Z)-Z,!0,Q,X),++Z,G!==null&&G>1114111)if(Q)X.invalidCodePoint(Z,$,J);else return{code:null,pos:Z}}else({code:G,pos:Z}=pG(D,Z,$,J,4,!1,Q,X));return{code:G,pos:Z}}function E4(D,Z,$){return new N0($,D-Z,D)}var qm=new Set([103,109,115,105,121,117,100,118]);class H_{constructor(D){let Z=D.startIndex||0;this.type=D.type,this.value=D.value,this.start=Z+D.start,this.end=Z+D.end,this.loc=new f4(D.startLoc,D.endLoc)}}var mZ;class z_ extends Y_{isLookahead;tokens=[];constructor(D,Z){super();if(this.state=new JY,this.state.init(D),this.input=Z,this.length=Z.length,this.comments=[],this.isLookahead=!1,!mZ||mZ.length<(this.length+1)*2)mZ=new Uint32Array((this.length+1)*2);this.locData=mZ}setLoc(D){let Z=this.offsetToSourcePos(D.index);this.locData[Z*2]=D.line,this.locData[Z*2+1]=D.column}getLoc(D){let Z=this.offsetToSourcePos(D);return new N0(this.locData[Z*2],this.locData[Z*2+1],D)}pushToken(D){this.tokens.length=this.state.tokensLength,this.tokens.push(D),++this.state.tokensLength}next(){if(this.checkKeywordEscapes(),this.optionFlags&512)this.pushToken(new H_(this.state));this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(D){if(this.match(D))return this.next(),!0;else return!1}match(D){return this.state.type===D}createLookaheadState(D){return{pos:D.pos,value:null,type:D.type,start:D.start,end:D.end,context:[this.curContext()],inType:D.inType,startLoc:D.startLoc,lastTokEndLoc:D.lastTokEndLoc,curLine:D.curLine,lineStart:D.lineStart,curPosition:D.curPosition}}lookahead(){let D=this.state;this.state=this.createLookaheadState(D),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;let Z=this.state;return this.state=D,Z}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(D){return fG.lastIndex=D,fG.test(this.input)?fG.lastIndex:D}lookaheadCharCode(){return this.lookaheadCharCodeSince(this.state.pos)}lookaheadCharCodeSince(D){return this.input.charCodeAt(this.nextTokenStartSince(D))}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(D){return yG.lastIndex=D,yG.test(this.input)?yG.lastIndex:D}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(D){let Z=this.input.charCodeAt(D);if((Z&64512)===55296&&++D<this.input.length){let $=this.input.charCodeAt(D);if(($&64512)===56320)Z=65536+((Z&1023)<<10)+($&1023)}return Z}setStrict(D){if(this.state.strict=D,D)this.state.strictErrors.forEach(([Z,$])=>this.raise(Z,$)),this.state.strictErrors.clear()}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,!this.isLookahead)this.state.startLoc=this.state.curPosition();if(this.state.pos>=this.length){this.finishToken(135);return}this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(D){let Z;if(!this.isLookahead)Z=this.state.curPosition();let $=this.state.pos,J=this.input.indexOf(D,$+2);if(J===-1)throw this.raise(m.UnterminatedComment,this.state.curPosition());this.state.pos=J+D.length,yZ.lastIndex=$+2;while(yZ.test(this.input)&&yZ.lastIndex<=J)++this.state.curLine,this.state.lineStart=yZ.lastIndex;if(this.isLookahead)return;let Q={type:"CommentBlock",value:this.input.slice($+2,J),start:this.sourceToOffsetPos($),end:this.sourceToOffsetPos(J+D.length),loc:new f4(Z,this.state.curPosition())};if(this.optionFlags&512)this.pushToken(Q);return Q}skipLineComment(D){let Z=this.state.pos,$;if(!this.isLookahead)$=this.state.curPosition();let J=this.input.charCodeAt(this.state.pos+=D);if(this.state.pos<this.length)while(!N5(J)&&++this.state.pos<this.length)J=this.input.charCodeAt(this.state.pos);if(this.isLookahead)return;let Q=this.state.pos,W={type:"CommentLine",value:this.input.slice(Z+D,Q),start:this.sourceToOffsetPos(Z),end:this.sourceToOffsetPos(Q),loc:new f4($,this.state.curPosition())};if(this.optionFlags&512)this.pushToken(W);return W}skipSpace(){let D=this.state.pos,Z=(this.optionFlags&8192)>0,$;D:while(this.state.pos<this.length){let J=this.input.charCodeAt(this.state.pos);switch(J){case 32:case 160:case 9:++this.state.pos;break;case 13:if(this.input.charCodeAt(this.state.pos+1)===10)++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{let Q=this.skipBlockComment("*/");if(Q!==void 0){if(this.addComment(Q),Z)($??=[]).push(Q)}break}case 47:{let Q=this.skipLineComment(2);if(Q!==void 0){if(this.addComment(Q),Z)($??=[]).push(Q)}break}default:break D}break;default:if(_m(J))++this.state.pos;else if(J===45&&!this.inModule&&this.optionFlags&16384){let Q=this.state.pos;if(this.input.charCodeAt(Q+1)===45&&this.input.charCodeAt(Q+2)===62&&(D===0||this.state.lineStart>D)){let X=this.skipLineComment(3);if(X!==void 0){if(this.addComment(X),Z)($??=[]).push(X)}}else break D}else if(J===60&&!this.inModule&&this.optionFlags&16384){let Q=this.state.pos;if(this.input.charCodeAt(Q+1)===33&&this.input.charCodeAt(Q+2)===45&&this.input.charCodeAt(Q+3)===45){let X=this.skipLineComment(4);if(X!==void 0){if(this.addComment(X),Z)($??=[]).push(X)}}else break D}else break D}}if($?.length){let J=this.state.pos,Q={start:this.sourceToOffsetPos(D),end:this.sourceToOffsetPos(J),comments:$,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(Q)}}finishToken(D,Z){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();let $=this.state.type;if(this.state.type=D,this.state.value=Z,!this.isLookahead)this.updateContext($)}replaceToken(D){this.state.type=D,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;let D=this.state.pos+1,Z=this.codePointAtPos(D);if(Z>=48&&Z<=57)throw this.raise(m.UnexpectedDigitAfterHash,this.state.curPosition());if(h8(Z))++this.state.pos,this.finishToken(134,this.readWord1(Z));else if(Z===92)++this.state.pos,this.finishToken(134,this.readWord1());else this.finishOp(23,1)}readToken_dot(){let D=this.input.charCodeAt(this.state.pos+1);if(D>=48&&D<=57){this.readNumber(!0);return}if(D===46&&this.input.charCodeAt(this.state.pos+2)===46)this.state.pos+=3,this.finishToken(17);else++this.state.pos,this.finishToken(12)}readToken_slash(){if(this.input.charCodeAt(this.state.pos+1)===61)this.finishOp(27,2);else this.finishOp(52,1)}readToken_interpreter(){if(this.state.pos!==0||this.length<2)return!1;let D=this.input.charCodeAt(this.state.pos+1);if(D!==33)return!1;let Z=this.state.pos;this.state.pos+=1;while(!N5(D)&&++this.state.pos<this.length)D=this.input.charCodeAt(this.state.pos);let $=this.input.slice(Z+2,this.state.pos);return this.finishToken(24,$),!0}readToken_mult_modulo(D){let Z=D===42?51:50,$=1,J=this.input.charCodeAt(this.state.pos+1);if(D===42&&J===42)$++,J=this.input.charCodeAt(this.state.pos+2),Z=53;if(J===61&&!this.state.inType)$++,Z=D===37?29:26;this.finishOp(Z,$)}readToken_pipe_amp(D){let Z=this.input.charCodeAt(this.state.pos+1);if(Z===D){if(this.input.charCodeAt(this.state.pos+2)===61)this.finishOp(26,3);else this.finishOp(D===124?37:38,2);return}if(D===124){if(Z===62){this.finishOp(35,2);return}}if(Z===61){this.finishOp(26,2);return}this.finishOp(D===124?39:41,1)}readToken_caret(){let D=this.input.charCodeAt(this.state.pos+1);if(D===61&&!this.state.inType)this.finishOp(28,2);else if(D===94&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"^^"}])){if(this.finishOp(33,2),this.input.codePointAt(this.state.pos)===94)this.unexpected()}else this.finishOp(40,1)}readToken_atSign(){if(this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"@@"}]))this.finishOp(34,2);else this.finishOp(22,1)}readToken_plus_min(D){let Z=this.input.charCodeAt(this.state.pos+1);if(Z===D){this.finishOp(30,2);return}if(Z===61)this.finishOp(26,2);else this.finishOp(49,1)}readToken_lt(){let{pos:D}=this.state,Z=this.input.charCodeAt(D+1);if(Z===60){if(this.input.charCodeAt(D+2)===61){this.finishOp(26,3);return}this.finishOp(47,2);return}if(Z===61){this.finishOp(45,2);return}this.finishOp(43,1)}readToken_gt(){let{pos:D}=this.state,Z=this.input.charCodeAt(D+1);if(Z===62){let $=this.input.charCodeAt(D+2)===62?3:2;if(this.input.charCodeAt(D+$)===61){this.finishOp(26,$+1);return}this.finishOp(48,$);return}if(Z===61){this.finishOp(45,2);return}this.finishOp(44,1)}readToken_eq_excl(D){let Z=this.input.charCodeAt(this.state.pos+1);if(Z===61){this.finishOp(42,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(D===61&&Z===62){this.state.pos+=2,this.finishToken(15);return}this.finishOp(D===61?25:31,1)}readToken_question(){let D=this.input.charCodeAt(this.state.pos+1),Z=this.input.charCodeAt(this.state.pos+2);if(D===63)if(Z===61)this.finishOp(26,3);else this.finishOp(36,2);else if(D===46&&!(Z>=48&&Z<=57))this.state.pos+=2,this.finishToken(14);else++this.state.pos,this.finishToken(13)}getTokenFromCode(D){switch(D){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(6);return;case 41:++this.state.pos,this.finishToken(7);return;case 59:++this.state.pos,this.finishToken(9);return;case 44:++this.state.pos,this.finishToken(8);return;case 91:++this.state.pos,this.finishToken(0);return;case 93:++this.state.pos,this.finishToken(1);return;case 123:++this.state.pos,this.finishToken(2);return;case 125:++this.state.pos,this.finishToken(4);return;case 58:if(this.hasPlugin("functionBind")&&this.input.charCodeAt(this.state.pos+1)===58)this.finishOp(11,2);else++this.state.pos,this.finishToken(10);return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{let Z=this.input.charCodeAt(this.state.pos+1);if(Z===120||Z===88){this.readRadixNumber(16);return}if(Z===111||Z===79){this.readRadixNumber(8);return}if(Z===98||Z===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(D);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(D);return;case 124:case 38:this.readToken_pipe_amp(D);return;case 94:this.readToken_caret();return;case 43:case 45:this.readToken_plus_min(D);return;case 60:this.readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(D);return;case 126:this.finishOp(32,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(h8(D)){this.readWord(D);return}}throw this.raise(m.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(D)})}finishOp(D,Z){let $=this.input.slice(this.state.pos,this.state.pos+Z);this.state.pos+=Z,this.finishToken(D,$)}readRegexp(){let D=this.state.startLoc,Z=this.state.start+1,$,J,{pos:Q}=this.state;for(;;++Q){if(Q>=this.length)throw this.raise(m.UnterminatedRegExp,e0(D,1));let Y=this.input.charCodeAt(Q);if(N5(Y))throw this.raise(m.UnterminatedRegExp,e0(D,1));if($)$=!1;else{if(Y===91)J=!0;else if(Y===93&&J)J=!1;else if(Y===47&&!J)break;$=Y===92}}let X=this.input.slice(Z,Q);++Q;let W="",G=()=>e0(D,Q+2-Z);while(Q<this.length){let Y=this.codePointAtPos(Q),B=String.fromCharCode(Y);if(qm.has(Y)){if(Y===118){if(W.includes("u"))this.raise(m.IncompatibleRegExpUVFlags,G())}else if(Y===117){if(W.includes("v"))this.raise(m.IncompatibleRegExpUVFlags,G())}if(W.includes(B))this.raise(m.DuplicateRegExpFlags,G())}else if(i1(Y)||Y===92)this.raise(m.MalformedRegExpFlags,G());else break;++Q,W+=B}this.state.pos=Q,this.finishToken(133,{pattern:X,flags:W})}readInt(D,Z,$=!1,J=!0){let{n:Q,pos:X}=B_(this.input,this.state.pos,this.state.lineStart,this.state.curLine,D,Z,$,J,this.errorHandlers_readInt,!1);return this.state.pos=X,Q}readRadixNumber(D){let Z=this.state.pos,$=this.state.curPosition(),J=!1;this.state.pos+=2;let Q=this.readInt(D);if(Q==null)this.raise(m.InvalidDigit,e0($,2),{radix:D});if(this.input.charCodeAt(this.state.pos)===110)++this.state.pos,J=!0;if(h8(this.codePointAtPos(this.state.pos)))throw this.raise(m.NumberIdentifier,this.state.curPosition());if(J){let W=this.input.slice(Z,this.state.pos).replace(/[_n]/g,"");this.finishToken(132,W);return}this.finishToken(131,Q)}readNumber(D){let Z=this.state.pos,$=this.state.curPosition(),J=!1,Q=!1,X=!1;if(!D&&this.readInt(10)===null)this.raise(m.InvalidNumber,this.state.curPosition());let W=this.state.pos-Z>=2&&this.input.charCodeAt(Z)===48;if(W){let H=this.input.slice(Z,this.state.pos);if(this.recordStrictModeErrors(m.StrictOctalLiteral,$),!this.state.strict){let K=H.indexOf("_");if(K>0)this.raise(m.ZeroDigitNumericSeparator,e0($,K))}X=W&&!/[89]/.test(H)}let G=this.input.charCodeAt(this.state.pos);if(G===46&&!X)++this.state.pos,this.readInt(10),J=!0,G=this.input.charCodeAt(this.state.pos);if((G===69||G===101)&&!X){if(G=this.input.charCodeAt(++this.state.pos),G===43||G===45)++this.state.pos;if(this.readInt(10)===null)this.raise(m.InvalidOrMissingExponent,$);J=!0,G=this.input.charCodeAt(this.state.pos)}let Y=this.input.slice(Z,this.state.pos).replaceAll("_","");if(G===110){if(J||W)this.raise(m.InvalidBigIntLiteral,$);++this.state.pos,Q=!0}if(h8(this.codePointAtPos(this.state.pos)))throw this.raise(m.NumberIdentifier,this.state.curPosition());if(Q){this.finishToken(132,Y);return}let B=X?parseInt(Y,8):parseFloat(Y);this.finishToken(131,B)}readCodePoint(D){let{code:Z,pos:$}=K_(this.input,this.state.pos,this.state.lineStart,this.state.curLine,D,this.errorHandlers_readCodePoint);return this.state.pos=$,Z}readString(D){let{str:Z,pos:$,curLine:J,lineStart:Q}=uN(D===34?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=$+1,this.state.lineStart=Q,this.state.curLine=J,this.finishToken(130,Z)}readTemplateContinuation(){if(!this.match(4))this.unexpected(null,4);this.state.pos--,this.readTemplateToken()}readTemplateToken(){let D=this.input[this.state.pos],{str:Z,firstInvalidLoc:$,pos:J,curLine:Q,lineStart:X}=uN("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);if(this.state.pos=J+1,this.state.lineStart=X,this.state.curLine=Q,$)this.state.firstInvalidTemplateEscapePos=new N0($.curLine,$.pos-$.lineStart,this.sourceToOffsetPos($.pos));if(this.input.codePointAt(J)===96)this.finishToken(20,$?null:D+Z+"`");else this.state.pos++,this.finishToken(21,$?null:D+Z+"${")}recordStrictModeErrors(D,Z){let $=Z.index;if(this.state.strict&&!this.state.strictErrors.has($))this.raise(D,Z);else this.state.strictErrors.set($,[D,Z])}readWord1(D){this.state.containsEsc=!1;let Z="",$=this.state.pos,J=this.state.pos;if(D!==void 0)this.state.pos+=D<=65535?1:2;while(this.state.pos<this.length){let Q=this.codePointAtPos(this.state.pos);if(i1(Q))this.state.pos+=Q<=65535?1:2;else if(Q===92){this.state.containsEsc=!0,Z+=this.input.slice(J,this.state.pos);let X=this.state.curPosition(),W=this.state.pos===$?h8:i1;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(m.MissingUnicodeEscape,this.state.curPosition()),J=this.state.pos-1;continue}++this.state.pos;let G=this.readCodePoint(!0);if(G!==null){if(!W(G))this.raise(m.EscapedCharNotAnIdentifier,X);Z+=String.fromCodePoint(G)}J=this.state.pos}else break}return Z+this.input.slice(J,this.state.pos)}readWord(D){let Z=this.readWord1(D),$=iG.get(Z);if($!==void 0)this.finishToken($,a3($));else this.finishToken(128,Z)}checkKeywordEscapes(){let{type:D}=this.state;if($Y(D)&&this.state.containsEsc)this.raise(m.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:a3(D)})}raise(D,Z,$={}){let J=Z instanceof N0?Z:typeof Z==="number"?this.getLoc(Z):this.optionFlags&256?Z.loc.start:this.getLoc(Z.start),Q=Z instanceof N0?J.index:typeof Z==="number"?Z:Z.start,X=D(J,Q,$);if(!(this.optionFlags&4096))throw X;if(!this.isLookahead)this.state.errors.push(X);return X}raiseOverwrite(D,Z,$={}){let J=Z instanceof N0?Z:this.optionFlags&256?Z.loc.start:this.getLoc(Z.start),Q=Z instanceof N0?J.index:Z.start,X=this.state.errors;for(let W=X.length-1;W>=0;W--){let G=X[W];if(G.pos===Q)return X[W]=D(J,Q,$);if(G.pos<Q)break}return this.raise(D,J,$)}updateContext(D){}unexpected(D,Z){throw this.raise(m.UnexpectedToken,D!=null?D:this.state.startLoc,{expected:Z?a3(Z):null})}expectPlugin(D,Z){if(this.hasPlugin(D))return!0;throw this.raise(m.MissingPlugin,Z!=null?Z:this.state.startLoc,{missingPlugin:[D]})}expectOnePlugin(D){if(!D.some((Z)=>this.hasPlugin(Z)))throw this.raise(m.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:D})}errorBuilder(D){return(Z,$,J)=>{this.raise(D,E4(Z,$,J))}}errorHandlers_readInt={invalidDigit:(D,Z,$,J)=>{this.raise(m.InvalidDigit,E4(D,Z,$),{radix:J})},numericSeparatorInEscapeSequence:this.errorBuilder(m.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(m.UnexpectedNumericSeparator)};errorHandlers_readCodePoint={...this.errorHandlers_readInt,invalidEscapeSequence:this.errorBuilder(m.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(m.InvalidCodePoint)};errorHandlers_readStringContents_string={...this.errorHandlers_readCodePoint,strictNumericEscape:(D,Z,$)=>{this.recordStrictModeErrors(m.StrictNumericEscape,E4(D,Z,$))},unterminated:(D,Z,$)=>{throw this.raise(m.UnterminatedString,E4(D-1,Z,$))}};errorHandlers_readStringContents_template={...this.errorHandlers_readCodePoint,strictNumericEscape:this.errorBuilder(m.StrictNumericEscape),unterminated:(D,Z,$)=>{throw this.raise(m.UnterminatedTemplate,E4(D,Z,$))}}}class V_{privateNames=new Set;loneAccessors=new Map;undefinedPrivateNames=new Map}class U_{parser;stack=[];constructor(D){this.parser=D}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new V_)}exit(){let D=this.stack.pop(),Z=this.current();for(let[$,J]of Array.from(D.undefinedPrivateNames))if(Z){if(!Z.undefinedPrivateNames.has($))Z.undefinedPrivateNames.set($,J)}else this.parser.raise(m.InvalidPrivateFieldResolution,J,{identifierName:$})}declarePrivateName(D,Z,$){let{privateNames:J,loneAccessors:Q,undefinedPrivateNames:X}=this.current(),W=J.has(D);if(Z&3){let G=W&&Q.get(D);if(G){let Y=G&4,B=Z&4,H=G&3,K=Z&3;if(W=H===K||Y!==B,!W)Q.delete(D)}else if(!W)Q.set(D,Z)}if(W)this.parser.raise(m.PrivateNameRedeclaration,$,{identifierName:D});J.add(D),X.delete(D)}usePrivateName(D,Z){let $;for($ of this.stack)if($.privateNames.has(D))return;if($)$.undefinedPrivateNames.set(D,Z);else this.parser.raise(m.InvalidPrivateFieldResolution,Z,{identifierName:D})}}class h4{constructor(D=0){this.type=D}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}}class QY extends h4{declarationErrors=new Map;constructor(D){super(D)}recordDeclarationError(D,Z){this.declarationErrors.set(Z,D)}clearDeclarationError(D){this.declarationErrors.delete(D)}iterateErrors(D){this.declarationErrors.forEach(D)}}class F_{parser;stack=[new h4];constructor(D){this.parser=D}enter(D){this.stack.push(D)}exit(){this.stack.pop()}recordParameterInitializerError(D,Z){let{stack:$}=this,J=$.length-1,Q=$[J];while(!Q.isCertainlyParameterDeclaration()){if(Q.canBeArrowParameterDeclaration())Q.recordDeclarationError(D,Z);else return;Q=$[--J]}this.parser.raise(D,Z)}recordArrowParameterBindingError(D,Z){let{stack:$}=this,J=$[$.length-1],Q=Z.start;if(J.isCertainlyParameterDeclaration())this.parser.raise(D,Q);else if(J.canBeArrowParameterDeclaration())J.recordDeclarationError(D,Q);else return}recordAsyncArrowParametersError(D){let{stack:Z}=this,$=Z.length-1,J=Z[$];while(J.canBeArrowParameterDeclaration()){if(J.type===2)J.recordDeclarationError(m.AwaitBindingIdentifier,D);J=Z[--$]}}validateAsPattern(){let{stack:D}=this,Z=D[D.length-1];if(!Z.canBeArrowParameterDeclaration())return;Z.iterateErrors(($,J)=>{this.parser.raise($,J);let Q=D.length-2,X=D[Q];while(X.canBeArrowParameterDeclaration())X.clearDeclarationError(J),X=D[--Q]})}}function Am(){return new h4(3)}function Im(){return new QY(1)}function Sm(){return new QY(2)}function cG(){return new h4}class L_{stacks=[];enter(D){this.stacks.push(D)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){return(this.currentFlags()&8)>0}get inFSharpPipelineDirectBody(){return(this.currentFlags()&16)===0}}function dZ(D,Z){return(D?2:0)|(Z?1:0)}class N_ extends z_{addExtra(D,Z,$,J=!0){if(!D)return;let{extra:Q}=D;if(Q==null)Q={},D.extra=Q;if(J)Q[Z]=$;else Object.defineProperty(Q,Z,{enumerable:J,value:$})}isContextual(D){return this.state.type===D&&!this.state.containsEsc}isUnparsedContextual(D,Z){if(this.input.startsWith(Z,D)){let $=this.input.charCodeAt(D+Z.length);return!(i1($)||($&64512)===55296)}return!1}isLookaheadContextual(D){let Z=this.nextTokenStart();return this.isUnparsedContextual(Z,D)}eatContextual(D){if(this.isContextual(D))return this.next(),!0;return!1}expectContextual(D,Z){if(!this.eatContextual(D)){if(Z!=null)throw this.raise(Z,this.state.startLoc);this.unexpected(null,D)}}canInsertSemicolon(){return this.match(135)||this.match(4)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return mN(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return mN(this.input,this.state.end,this.nextTokenStart())}isLineTerminator(){return this.eat(9)||this.canInsertSemicolon()}semicolon(D=!0){if(D?this.isLineTerminator():this.eat(9))return;this.raise(m.MissingSemicolon,this.state.lastTokEndLoc)}expect(D,Z){if(!this.eat(D))this.unexpected(Z,D)}tryParse(D,Z=this.state.clone()){let $={node:null};try{let J=D((Q=null)=>{throw $.node=Q,$});if(this.state.errors.length>Z.errors.length){let Q=this.state;return this.state=Z,this.state.tokensLength=Q.tokensLength,{node:J,error:Q.errors[Z.errors.length],thrown:!1,aborted:!1,failState:Q}}return{node:J,error:null,thrown:!1,aborted:!1,failState:null}}catch(J){let Q=this.state;if(this.state=Z,J instanceof SyntaxError)return{node:null,error:J,thrown:!0,aborted:!1,failState:Q};if(J===$)return{node:$.node,error:null,thrown:!1,aborted:!0,failState:Q};throw J}}checkExpressionErrors(D,Z){if(!D)return!1;let{shorthandAssignLoc:$,doubleProtoLoc:J,privateKeyLoc:Q,optionalParametersLoc:X,voidPatternLoc:W}=D,G=!!$||!!J||!!X||!!Q||!!W;if(!Z)return G;if($!=null)this.raise(m.InvalidCoverInitializedName,$);if(J!=null)this.raise(m.DuplicateProto,J);if(Q!=null)this.raise(m.UnexpectedPrivateField,Q);if(X!=null)this.unexpected(X);if(W!=null)this.raise(m.InvalidCoverDiscardElement,W)}isLiteralPropertyName(){return aN(this.state.type)}isPrivateName(D){return D.type==="PrivateName"}getPrivateNameSV(D){return D.id.name}hasPropertyAsPrivateName(D){return(D.type==="MemberExpression"||D.type==="OptionalMemberExpression")&&this.isPrivateName(D.property)}isObjectProperty(D){return D.type==="ObjectProperty"}isObjectMethod(D){return D.type==="ObjectMethod"}initializeScopes(D=this.options.sourceType==="module"){let Z=this.state.labels;this.state.labels=[];let $=this.exportedIdentifiers;this.exportedIdentifiers=new Set;let J=this.inModule;this.inModule=D;let Q=this.scope,X=this.getScopeHandler();this.scope=new X(this,D);let W=this.prodParam;this.prodParam=new L_;let G=this.classScope;this.classScope=new U_(this);let Y=this.expressionScope;return this.expressionScope=new F_(this),()=>{this.state.labels=Z,this.exportedIdentifiers=$,this.inModule=J,this.scope=Q,this.prodParam=W,this.classScope=G,this.expressionScope=Y}}enterInitialScopes(){let D=0;if(this.inModule||this.optionFlags&1)D|=2;if(this.optionFlags&32)D|=1;let Z=!this.inModule&&this.options.sourceType==="commonjs";if(Z||this.optionFlags&2)D|=4;this.prodParam.enter(D);let $=Z?514:1;if(this.optionFlags&4)$|=512;if(this.optionFlags&16)$|=48;this.scope.enter($)}checkDestructuringPrivate(D){let{privateKeyLoc:Z}=D;if(Z!==null)this.expectPlugin("destructuringPrivate",Z)}}class g4{shorthandAssignLoc=null;doubleProtoLoc=null;privateKeyLoc=null;optionalParametersLoc=null;voidPatternLoc=null}class L5{constructor(D,Z,$,J){if(this.start=$,this.end=0,J!==void 0)this.loc=new f4(J);if(D&128)this.range=[$,0];if(J!==void 0&&Z)this.loc.filename=Z}type=""}var dN=L5.prototype;class __ extends N_{createPosition(D){return D}startNode(){let{startLoc:D}=this.state;return this.setLoc(D),this.startNodeAt(D)}startNodeAt(D){let{optionFlags:Z,filename:$}=this;if(!(Z&256))return new L5(Z,$,D.index);return new L5(Z,$,D.index,this.createPosition(D))}startNodeAtNode(D){let{optionFlags:Z,filename:$}=this;if(!(Z&256))return new L5(Z,$,D.start);return new L5(Z,$,D.start,D.loc.start)}finishNode(D,Z){return this.finishNodeAt(D,Z,this.state.lastTokEndLoc)}finishNodeAt(D,Z,$){D.type=Z,D.end=$.index;let{optionFlags:J}=this;if(J&256)D.loc.end=this.createPosition($);if(J&128)D.range[1]=$.index;if(J&8192)this.processComment(D);return D}finishNodeAtNode(D,Z,$){D.type=Z,D.end=$.end;let{optionFlags:J}=this;if(J&256)D.loc.end=$.loc.end;if(J&128)D.range[1]=D.end;if(J&8192)this.processComment(D);return D}resetStartLocation(D,Z){D.start=Z.index;let{optionFlags:$}=this;if($&256)D.loc.start=this.createPosition(Z);if($&128)D.range[0]=Z.index}resetEndLocation(D,Z=this.state.lastTokEndLoc){D.end=Z.index;let{optionFlags:$}=this;if($&256)D.loc.end=this.createPosition(Z);if($&128)D.range[1]=Z.index}resetStartLocationFromNode(D,Z){D.start=Z.start;let{optionFlags:$}=this;if($&256)D.loc.start=Z.loc.start;if($&128)D.range[0]=Z.start}resetEndLocationFromNode(D,Z){D.end=Z.end;let{optionFlags:$}=this;if($&256)D.loc.end=Z.loc.end;if($&128)D.range[1]=Z.end}castNodeTo(D,Z){return D.type=Z,D}cloneIdentifier(D){let{type:Z,start:$,end:J,loc:Q,range:X,name:W}=D,G=Object.create(dN);if(G.type=Z,G.start=$,G.end=J,G.loc=Q,G.range=X,G.name=W,D.extra)G.extra=D.extra;return G}cloneStringLiteral(D){let{type:Z,start:$,end:J,loc:Q,range:X,extra:W}=D,G=Object.create(dN);return G.type=Z,G.start=$,G.end=J,G.loc=Q,G.range=X,G.extra=W,G.value=D.value,G}}var lG=(D)=>{return D.type==="ParenthesizedExpression"?lG(D.expression):D};class M_ extends __{toAssignable(D,Z=!1){let $=void 0;if(D.type==="ParenthesizedExpression"||D.extra?.parenthesized)if($=lG(D),Z){if($.type==="Identifier")this.expressionScope.recordArrowParameterBindingError(m.InvalidParenthesizedAssignment,D);else if($.type!=="CallExpression"&&$.type!=="MemberExpression"&&!this.isOptionalMemberExpression($))this.raise(m.InvalidParenthesizedAssignment,D)}else this.raise(m.InvalidParenthesizedAssignment,D);switch(D.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":case"VoidPattern":break;case"ObjectExpression":this.castNodeTo(D,"ObjectPattern");for(let J=0,Q=D.properties.length,X=Q-1;J<Q;J++){let W=D.properties[J],G=J===X;if(this.toAssignableObjectExpressionProp(W,G,Z),G&&W.type==="RestElement"&&D.extra?.trailingCommaLoc)this.raise(m.RestTrailingComma,D.extra.trailingCommaLoc)}break;case"ObjectProperty":{let{key:J,value:Q}=D;if(this.isPrivateName(J))this.classScope.usePrivateName(this.getPrivateNameSV(J),J.start);this.toAssignable(Q,Z);break}case"SpreadElement":throw Error("Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller.");case"ArrayExpression":this.castNodeTo(D,"ArrayPattern"),this.toAssignableList(D.elements,D.extra?.trailingCommaLoc,Z);break;case"AssignmentExpression":if(D.operator!=="=")this.raise(m.MissingEqInAssignment,this.optionFlags&256?D.left.loc.end:D.left);if(this.castNodeTo(D,"AssignmentPattern"),delete D.operator,D.left.type==="VoidPattern")this.raise(m.VoidPatternInitializer,D.left);this.toAssignable(D.left,Z);break;case"ParenthesizedExpression":this.toAssignable($,Z);break}}toAssignableObjectExpressionProp(D,Z,$){if(D.type==="ObjectMethod")this.raise(D.kind==="get"||D.kind==="set"?m.PatternHasAccessor:m.PatternHasMethod,D.key);else if(D.type==="SpreadElement"){this.castNodeTo(D,"RestElement");let J=D.argument;if(this.checkToRestConversion(J,!1),this.toAssignable(J,$),!Z)this.raise(m.RestTrailingComma,D)}else this.toAssignable(D,$)}toAssignableList(D,Z,$){let J=D.length-1;for(let Q=0;Q<=J;Q++){let X=D[Q];if(!X)continue;if(this.toAssignableListItem(D,Q,$),X.type==="RestElement"){if(Q<J)this.raise(m.RestTrailingComma,X);else if(Z)this.raise(m.RestTrailingComma,Z)}}}toAssignableListItem(D,Z,$){let J=D[Z];if(J.type==="SpreadElement"){this.castNodeTo(J,"RestElement");let Q=J.argument;this.checkToRestConversion(Q,!0),this.toAssignable(Q,$)}else this.toAssignable(J,$)}isAssignable(D,Z){switch(D.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":case"VoidPattern":return!0;case"ObjectExpression":{let $=D.properties.length-1;return D.properties.every((J,Q)=>{return J.type!=="ObjectMethod"&&(Q===$||J.type!=="SpreadElement")&&this.isAssignable(J)})}case"ObjectProperty":return this.isAssignable(D.value);case"SpreadElement":return this.isAssignable(D.argument);case"ArrayExpression":return D.elements.every(($)=>$===null||this.isAssignable($));case"AssignmentExpression":return D.operator==="=";case"ParenthesizedExpression":return this.isAssignable(D.expression);case"MemberExpression":case"OptionalMemberExpression":return!Z;default:return!1}}toReferencedList(D,Z){return D}parseSpread(D){let Z=this.startNode();return this.next(),Z.argument=this.parseMaybeAssignAllowIn(D),this.finishNode(Z,"SpreadElement")}parseRestBinding(){let D=this.startNode();this.next();let Z=this.parseBindingAtom();if(Z.type==="VoidPattern")this.raise(m.UnexpectedVoidPattern,Z);return D.argument=Z,this.finishNode(D,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{let D=this.startNode();return this.next(),D.elements=this.parseBindingList(1,93,1),this.finishNode(D,"ArrayPattern")}case 2:return this.parseObjectLike(4,!0);case 84:return this.parseVoidPattern(null)}return this.parseIdentifier()}parseBindingList(D,Z,$){let J=$&1,Q=[],X=!0;while(!this.eat(D)){if(X)X=!1;else this.expect(8);if(J&&this.match(8))Q.push(null);else if(this.eat(D))break;else if(this.match(17)){let W=this.parseRestBinding();if($&2)W=this.parseFunctionParamType(W);if(Q.push(W),!this.checkCommaAfterRest(Z)){this.expect(D);break}}else{let W=[];if($&2){if(this.match(22)&&this.hasPlugin("decorators"))this.raise(m.UnsupportedParameterDecorator,this.state.startLoc);while(this.match(22))W.push(this.parseDecorator())}Q.push(this.parseBindingElement($,W))}}return Q}parseBindingRestProperty(D){if(this.next(),this.hasPlugin("discardBinding")&&this.match(84))D.argument=this.parseVoidPattern(null),this.raise(m.UnexpectedVoidPattern,D.argument);else D.argument=this.parseIdentifier();return this.checkCommaAfterRest(125),this.finishNode(D,"RestElement")}parseBindingProperty(){let{type:D,startLoc:Z}=this.state;if(D===17)return this.parseBindingRestProperty(this.startNode());let $=this.startNode();if(D===134)this.expectPlugin("destructuringPrivate",Z),this.classScope.usePrivateName(this.state.value,Z),$.key=this.parsePrivateName();else this.parsePropertyName($);return $.method=!1,this.parseObjPropValue($,Z,!1,!1,!0,!1)}parseBindingElement(D,Z){let{startLoc:$}=this.state,J=this.parseMaybeDefault();if(D&2)this.parseFunctionParamType(J);if(Z.length)J.decorators=Z,this.resetStartLocationFromNode(J,Z[0]);return this.parseMaybeDefault($,J)}parseFunctionParamType(D){return D}parseMaybeDefault(D,Z){if(D??=this.state.startLoc,Z=Z??this.parseBindingAtom(),!this.eat(25))return Z;let $=this.startNodeAt(D);if(Z.type==="VoidPattern")this.raise(m.VoidPatternInitializer,Z);return $.left=Z,$.right=this.parseMaybeAssignAllowIn(),this.finishNode($,"AssignmentPattern")}isValidLVal(D,Z,$,J){switch(D){case"AssignmentPattern":return"left";case"RestElement":return"argument";case"ObjectProperty":return"value";case"ParenthesizedExpression":return"expression";case"ArrayPattern":return"elements";case"ObjectPattern":return"properties";case"VoidPattern":return!0;case"CallExpression":if(!Z&&!this.state.strict&&this.optionFlags&16384)return!0}return!1}isOptionalMemberExpression(D){return D.type==="OptionalMemberExpression"}checkLVal(D,Z,$=64,J=!1,Q=!1,X=!1,W=!1){let G=D.type;if(this.isObjectMethod(D))return;let Y=this.isOptionalMemberExpression(D);if(Y||G==="MemberExpression"){if(Y){if(this.expectPlugin("optionalChainingAssign",D.start),Z.type!=="AssignmentExpression")this.raise(m.InvalidLhsOptionalChaining,D,{ancestor:Z})}if($!==64)this.raise(m.InvalidPropertyBindingPattern,D);return}if(G==="Identifier"){this.checkIdentifier(D,$,Q);let{name:N}=D;if(J)if(J.has(N))this.raise(m.ParamDupe,D);else J.add(N);return}else if(G==="VoidPattern"&&Z.type==="CatchClause")this.raise(m.VoidPatternCatchClauseParam,D);let B=lG(D);W||=B.type==="CallExpression"&&(B.callee.type==="Import"||B.callee.type==="Super");let H=this.isValidLVal(G,W,!(X||D.extra?.parenthesized)&&Z.type==="AssignmentExpression",$);if(H===!0)return;if(H===!1){let N=$===64?m.InvalidLhs:m.InvalidLhsBinding;this.raise(N,D,{ancestor:Z});return}let K,z;if(typeof H==="string")K=H,z=G==="ParenthesizedExpression";else[K,z]=H;let V=G==="ArrayPattern"||G==="ObjectPattern"?{type:G}:Z,_=D[K];if(Array.isArray(_)){for(let N of _)if(N)this.checkLVal(N,V,$,J,Q,z,!0)}else if(_)this.checkLVal(_,V,$,J,Q,z,W)}checkIdentifier(D,Z,$=!1){if(this.state.strict&&($?$_(D.name,this.inModule):D_(D.name)))if(Z===64)this.raise(m.StrictEvalArguments,D,{referenceName:D.name});else this.raise(m.StrictEvalArgumentsBinding,D,{bindingName:D.name});if(Z&8192&&D.name==="let")this.raise(m.LetInLexicalBinding,D);if(!(Z&64))this.declareNameFromIdentifier(D,Z)}declareNameFromIdentifier(D,Z){this.scope.declareName(D.name,Z,D.start)}checkToRestConversion(D,Z){switch(D.type){case"ParenthesizedExpression":this.checkToRestConversion(D.expression,Z);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(Z)break;default:this.raise(m.InvalidRestAssignmentPattern,D)}}checkCommaAfterRest(D){if(!this.match(8))return!1;return this.raise(this.lookaheadCharCode()===D?m.RestTrailingComma:m.ElementAfterRest,this.state.startLoc),!0}}class C_ extends M_{checkProto(D,Z,$){if(D.type==="SpreadElement"||this.isObjectMethod(D)||D.computed||D.shorthand)return Z;let J=D.key;if((J.type==="Identifier"?J.name:J.value)==="__proto__"){if(Z)if($){if($.doubleProtoLoc===null)$.doubleProtoLoc=this.getLoc(J.start)}else this.raise(m.DuplicateProto,J);return!0}return Z}shouldExitDescending(D){return D.type==="ArrowFunctionExpression"&&!D.extra?.parenthesized}getExpression(){if(this.enterInitialScopes(),this.nextToken(),this.match(135))throw this.raise(m.ParseExpressionEmptyInput,this.state.startLoc);let D=this.parseExpression();if(!this.match(135))throw this.raise(m.ParseExpressionExpectsEOF,this.state.startLoc,{unexpected:this.input.codePointAt(this.state.start)});if(this.finalizeRemainingComments(),D.comments=this.comments,D.errors=this.state.errors,this.optionFlags&512)D.tokens=P_(this.tokens);return D}parseExpression(D,Z){if(D)return this.disallowInAnd(()=>this.parseExpressionBase(Z));return this.allowInAnd(()=>this.parseExpressionBase(Z))}parseExpressionBase(D){let Z=this.state.startLoc,$=this.parseMaybeAssign(D);if(this.match(8)){let J=this.startNodeAt(Z);J.expressions=[$];while(this.eat(8))J.expressions.push(this.parseMaybeAssign(D));return this.toReferencedList(J.expressions),this.finishNode(J,"SequenceExpression")}return $}parseMaybeAssignDisallowIn(D){return this.disallowInAnd(()=>this.parseMaybeAssign(D))}parseMaybeAssignAllowIn(D,Z){return this.allowInAnd(()=>this.parseMaybeAssign(D,Z))}setOptionalParametersError(D){D.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(D,Z){let $=this.state.startLoc,J=this.isContextual(104);if(J){if(this.prodParam.hasYield){this.next();let W=this.parseYield($);if(Z)W=this.parseParenItem(W,$);return W}}let Q;if(D)Q=!1;else D=new g4,Q=!0;this.state.canStartArrow=!0;let X=this.parseMaybeConditional(D);if(Z)X=this.parseParenItem(X,$);if(ah(this.state.type)){let W=this.startNodeAt($),G=this.state.value;if(W.operator=G,this.match(25)){this.toAssignable(X,!0),W.left=X;let Y=$.index;if(D.doubleProtoLoc!=null&&D.doubleProtoLoc.index>=Y)D.doubleProtoLoc=null;if(D.shorthandAssignLoc!=null&&D.shorthandAssignLoc.index>=Y)D.shorthandAssignLoc=null;if(D.privateKeyLoc!=null&&D.privateKeyLoc.index>=Y)this.checkDestructuringPrivate(D),D.privateKeyLoc=null;if(D.voidPatternLoc!=null&&D.voidPatternLoc.index>=Y)D.voidPatternLoc=null}else W.left=X;return this.next(),W.right=this.parseMaybeAssign(),this.checkLVal(X,this.finishNode(W,"AssignmentExpression"),void 0,void 0,void 0,void 0,G==="||="||G==="&&="||G==="??="),W}else if(Q)this.checkExpressionErrors(D,!0);if(J){let{type:W}=this.state;if((this.hasPlugin("v8intrinsic")?w4(W):w4(W)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(m.YieldNotInGeneratorFunction,$),this.parseYield($)}return X}parseMaybeConditional(D){let Z=this.state.startLoc,$=this.parseExprOps(D);if(this.shouldExitDescending($))return $;return this.parseConditional($,Z,D)}parseConditional(D,Z,$){if(this.eat(13)){let J=this.startNodeAt(Z);return J.test=D,J.consequent=this.parseMaybeAssignAllowIn(),this.expect(10),J.alternate=this.parseMaybeAssign(),this.finishNode(J,"ConditionalExpression")}return D}parseMaybeUnaryOrPrivate(D){return this.match(134)?this.parsePrivateName():this.parseMaybeUnary(D)}parseExprOps(D){let Z=this.state.startLoc,$=this.parseMaybeUnaryOrPrivate(D);if(this.shouldExitDescending($))return $;return this.state.canStartArrow=!1,this.parseExprOp($,Z,-1)}parseExprOp(D,Z,$){if(this.isPrivateName(D)){let Q=this.getPrivateNameSV(D);if($>=uZ(54)||!this.prodParam.hasIn||!this.match(54))this.raise(m.PrivateInExpectedIn,Z,{identifierName:Q});this.classScope.usePrivateName(Q,Z)}let J=this.state.type;if(gN(J)&&(this.prodParam.hasIn||!this.match(54))){let Q=uZ(J);if(Q>$){if(J===35){if(this.expectPlugin("pipelineOperator"),this.prodParam.inFSharpPipelineDirectBody)return D}let X=this.startNodeAt(Z);X.left=D,X.operator=this.state.value;let W=J===37||J===38,G=J===36;if(G)Q=uZ(38);this.next(),X.right=this.parseExprOpRightExpr(J,Q);let Y=this.finishNode(X,W||G?"LogicalExpression":"BinaryExpression"),B=this.state.type;if(G&&(B===37||B===38)||W&&B===36)throw this.raise(m.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(Y,Z,$)}}return D}parseExprOpRightExpr(D,Z){switch(D){case 35:switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext(()=>{return this.parseHackPipeBody()});case"fsharp":return this.parseFSharpPipelineBody(Z)}default:return this.parseExprOpBaseRightExpr(D,Z)}}parseExprOpBaseRightExpr(D,Z){let $=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),$,$m(D)?Z-1:Z)}parseHackPipeBody(){let{startLoc:D}=this.state,Z=this.parseMaybeAssign();if(hh.has(Z.type)&&!Z.extra?.parenthesized)this.raise(m.PipeUnparenthesizedBody,D,{type:Z.type});if(!this.topicReferenceWasUsedInCurrentContext())this.raise(m.PipeTopicUnused,D);return Z}checkExponentialAfterUnary(D){if(this.match(53))this.raise(m.UnexpectedTokenUnaryExponentiation,D.argument)}parseMaybeUnary(D,Z){let $=this.state.startLoc,J=this.isContextual(92);if(J&&this.recordAwaitIfAllowed()){this.next();let G=this.parseAwait($);if(!Z)this.checkExponentialAfterUnary(G);return G}let Q=this.match(30),X=this.startNode();if(th(this.state.type)){if(X.operator=this.state.value,X.prefix=!0,this.state.canStartArrow=!1,this.match(68))this.expectPlugin("throwExpressions");let G=this.match(85);if(this.next(),X.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(D,!0),this.state.strict&&G){let Y=X.argument;if(Y.type==="Identifier")this.raise(m.StrictDelete,X);else if(this.hasPropertyAsPrivateName(Y))this.raise(m.DeletePrivateField,X)}if(!Q){if(!Z)this.checkExponentialAfterUnary(X);return this.finishNode(X,"UnaryExpression")}}let W=this.parseUpdate(X,Q,D);if(J){let{type:G}=this.state;if((this.hasPlugin("v8intrinsic")?w4(G):w4(G)&&!this.match(50))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(m.AwaitNotInAsyncContext,$),this.parseAwait($)}return W}parseUpdate(D,Z,$){if(Z){let X=this.finishNode(D,"UpdateExpression");return this.checkLVal(X.argument,X),X}let J=this.state.startLoc,Q=this.parseExprSubscripts($);if(this.checkExpressionErrors($,!1))return Q;while(rh(this.state.type)&&!this.canInsertSemicolon()){let X=this.startNodeAt(J);X.operator=this.state.value,X.prefix=!1,X.argument=Q,this.next(),this.checkLVal(Q,Q=this.finishNode(X,"UpdateExpression"))}return Q}parseExprSubscripts(D){let Z=this.state.startLoc;this.setLoc(Z);let $=this.parseExprAtom(D);if(this.shouldExitDescending($))return $;return this.parseSubscripts($,Z)}parseSubscripts(D,Z,$){let J={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(D),stop:!1};do D=this.parseSubscript(D,Z,$,J),J.maybeAsyncArrow=!1;while(!J.stop);return D}parseSubscript(D,Z,$,J){let{type:Q}=this.state;if(!$&&Q===11)return this.parseBind(D,Z,J);else if(uG(Q))return this.parseTaggedTemplateExpression(D,Z,J);let X=!1;if(Q===14){if($){if(this.raise(m.OptionalChainingNoNew,this.state.startLoc),this.lookaheadCharCode()===40)return this.stopParseSubscript(D,J)}J.optionalChainMember=X=!0,this.next()}if(!$&&this.match(6))return this.parseCoverCallAndAsyncArrowHead(D,Z,J,X);else{let W=this.eat(0);if(W||X||this.eat(12))return this.parseMember(D,Z,J,W,X);else return this.stopParseSubscript(D,J)}}stopParseSubscript(D,Z){return Z.stop=!0,D}parseMember(D,Z,$,J,Q){let X=this.startNodeAt(Z);if(X.object=D,X.computed=J,J)X.property=this.parseExpression(),this.expect(1);else if(this.match(134)){if(D.type==="Super")this.raise(m.SuperPrivateField,Z);this.classScope.usePrivateName(this.state.value,this.state.startLoc),X.property=this.parsePrivateName()}else X.property=this.parseIdentifier(!0);if($.optionalChainMember)return X.optional=Q,this.finishNode(X,"OptionalMemberExpression");else return this.finishNode(X,"MemberExpression")}parseBind(D,Z,$){let J=this.startNodeAt(Z);J.object=D,this.next();let Q=this.parseNoCallExpr((X)=>{throw this.raise(m.UnsupportedBindRHS,X)});if(Q.type==="Super"||Q.type==="Import")throw this.raise(m.UnsupportedBindRHS,Q);return J.callee=Q,$.stop=!0,this.parseSubscripts(this.finishNode(J,"BindExpression"),Z,!1)}parseCoverCallAndAsyncArrowHead(D,Z,$,J){let Q=null;this.next();let X=this.startNodeAt(Z);X.callee=D;let{maybeAsyncArrow:W,optionalChainMember:G}=$;if(W)this.expressionScope.enter(Sm()),Q=new g4;if(G)X.optional=J;if(J)X.arguments=this.parseCallExpressionArguments();else X.arguments=this.parseCallExpressionArguments(D.type!=="Super",X,Q);let Y=this.finishCallExpression(X,G);if(W&&this.shouldParseAsyncArrow()&&!J)$.stop=!0,this.checkDestructuringPrivate(Q),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),Y=this.parseAsyncArrowFromCallExpression(this.startNodeAt(Z),Y);else{if(W)this.checkExpressionErrors(Q,!0),this.expressionScope.exit();this.toReferencedList(X.arguments)}return Y}parseTaggedTemplateExpression(D,Z,$){let J=this.startNodeAt(Z);if(J.tag=D,J.quasi=this.parseTemplate(!0),$.optionalChainMember)this.raise(m.OptionalChainingNoTemplate,Z);return this.finishNode(J,"TaggedTemplateExpression")}atPossibleAsyncArrow(D){return D.type==="Identifier"&&D.name==="async"&&this.state.lastTokEndLoc.index===D.end&&!this.canInsertSemicolon()&&D.end-D.start===5&&this.state.canStartArrow}finishCallExpression(D,Z){if(D.callee.type==="Import"){if(D.arguments.length===0||D.arguments.length>2)this.raise(m.ImportCallArity,D);else for(let $ of D.arguments)if($.type==="SpreadElement")this.raise(m.ImportCallSpreadArgument,$)}return this.finishNode(D,Z?"OptionalCallExpression":"CallExpression")}parseCallExpressionArguments(D,Z,$){let J=[],Q=!0;while(!this.eat(7)){if(Q)Q=!1;else if(this.expect(8),this.match(7)){if(Z)this.addTrailingCommaExtraToNode(Z);this.next();break}J.push(this.parseExprListItem(7,!1,$,D))}return J}shouldParseAsyncArrow(){return this.match(15)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(D,Z){if(this.resetPreviousNodeTrailingComments(Z),this.expect(15),this.parseArrowExpression(D,Z.arguments,!0,Z.extra?.trailingCommaLoc),Z.innerComments)y4(D,Z.innerComments);if(Z.callee.trailingComments)y4(D,Z.callee.trailingComments);return D}parseNoCallExpr(D){let Z=this.state.startLoc,$=this.match(79),J=this.parseExprAtom();if($&&J.type==="ImportExpression")D(J);return this.parseSubscripts(J,Z,!0)}parseExprAtom(D){let Z,$=null,{type:J}=this.state;switch(J){case 75:return this.parseSuper();case 79:if(Z=this.startNode(),this.next(),this.match(12))return this.parseImportMetaPropertyOrPhaseCall(Z);if(this.match(6))if(this.optionFlags&1024)return this.parseImportCall(Z);else return this.finishNode(Z,"Import");else return this.raise(m.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(Z,"Import");case 74:return Z=this.startNode(),this.next(),this.finishNode(Z,"ThisExpression");case 86:return this.parseDo(this.startNode(),!1);case 52:case 27:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 131:return this.parseNumericLiteral(this.state.value);case 132:return this.parseBigIntLiteral(this.state.value);case 130:return this.parseStringLiteral(this.state.value);case 80:return this.parseNullLiteral();case 81:return this.parseBooleanLiteral(!0);case 82:return this.parseBooleanLiteral(!1);case 6:return this.parseParenAndDistinguishExpression(this.state.canStartArrow);case 0:return this.parseArrayLike(1,D);case 2:return this.parseObjectLike(4,!1,D);case 64:return this.parseFunctionOrFunctionSent();case 22:$=this.parseDecorators();case 76:return this.parseClass(this.maybeTakeDecorators($,this.startNode()),!1);case 73:return this.parseNewOrNewTarget();case 21:case 20:return this.parseTemplate(!1);case 11:{Z=this.startNode(),this.next(),Z.object=null;let Q=Z.callee=this.parseNoCallExpr((X)=>{throw this.raise(m.UnsupportedBind,X)});if(Q.type==="MemberExpression")return this.finishNode(Z,"BindExpression");else throw this.raise(m.UnsupportedBind,Q)}case 134:return this.raise(m.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 29:return this.parseTopicReferenceThenEqualsSign(50,"%");case 28:return this.parseTopicReferenceThenEqualsSign(40,"^");case 33:case 34:return this.parseTopicReference("hack");case 40:case 50:case 23:{let Q=this.getPluginOption("pipelineOperator","proposal");if(Q)return this.parseTopicReference(Q);throw this.unexpected()}case 43:{let Q=this.input.codePointAt(this.nextTokenStart());if(h8(Q)||Q===62)throw this.expectOnePlugin(["jsx","flow","typescript"]);throw this.unexpected()}default:if(iD(J)){if(this.isContextual(123)&&this.lookaheadInLineCharCode()===123)return this.parseModuleExpression();let{canStartArrow:Q,containsEsc:X}=this.state,W=this.parseIdentifier();if(!X&&W.name==="async"&&!this.canInsertSemicolon()){let{type:G}=this.state;if(G===64)return this.resetPreviousNodeTrailingComments(W),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(W));else if(iD(G))if(Q&&this.lookaheadCharCode()===61)return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(W));else return W;else if(G===86)return this.resetPreviousNodeTrailingComments(W),this.parseDo(this.startNodeAtNode(W),!0)}if(Q&&this.match(15)&&!this.canInsertSemicolon())return this.next(),this.parseArrowExpression(this.startNodeAtNode(W),[W],!1);return W}else throw this.unexpected()}}parseTopicReferenceThenEqualsSign(D,Z){let $=this.getPluginOption("pipelineOperator","proposal");if($)return this.state.type=D,this.state.value=Z,this.state.pos--,this.state.end--,this.state.endLoc=e0(this.state.endLoc,-1),this.parseTopicReference($);throw this.unexpected()}parseTopicReference(D){let Z=this.startNode(),$=this.state.startLoc,J=this.state.type;return this.next(),this.finishTopicReference(Z,$,D,J)}finishTopicReference(D,Z,$,J){if(this.testTopicReferenceConfiguration($,Z,J)){if(!this.topicReferenceIsAllowedInCurrentContext())this.raise(m.PipeTopicUnbound,Z);return this.registerTopicReference(),this.finishNode(D,"TopicReference")}else throw this.raise(m.PipeTopicUnconfiguredToken,Z,{token:a3(J)})}testTopicReferenceConfiguration(D,Z,$){switch(D){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:a3($)}]);default:throw this.raise(m.PipeTopicRequiresHackPipes,Z)}}parseAsyncArrowUnaryFunction(D){this.prodParam.enter(dZ(!0,this.prodParam.hasYield));let Z=[this.parseIdentifier()];if(this.prodParam.exit(),this.hasPrecedingLineBreak())this.raise(m.LineTerminatorBeforeArrow,this.state.curPosition());return this.expect(15),this.parseArrowExpression(D,Z,!0)}parseDo(D,Z){if(this.expectPlugin("doExpressions"),Z)this.expectPlugin("asyncDoExpressions");D.async=Z,this.next();let $=this.state.labels;if(this.state.labels=[],Z)this.prodParam.enter(2),D.body=this.parseBlock(),this.prodParam.exit();else D.body=this.parseBlock();return this.state.labels=$,this.finishNode(D,"DoExpression")}parseSuper(){let D=this.startNode();if(this.next(),this.match(6)&&!this.scope.allowDirectSuper)this.raise(m.SuperNotAllowed,D);else if(!this.scope.allowSuper)this.raise(m.UnexpectedSuper,D);if(!this.match(6)&&!this.match(0)&&!this.match(12))this.raise(m.UnsupportedSuper,D);return this.finishNode(D,"Super")}parsePrivateName(){let D=this.startNode(),Z=this.startNodeAt(e0(this.state.startLoc,1)),$=this.state.value;return this.next(),D.id=this.createIdentifier(Z,$),this.finishNode(D,"PrivateName")}parseFunctionOrFunctionSent(){let D=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(12)){let Z=this.createIdentifier(this.startNodeAtNode(D),"function");if(this.next(),this.match(99))this.expectPlugin("functionSent");else if(!this.hasPlugin("functionSent"))this.unexpected();return this.parseMetaProperty(D,Z,"sent")}return this.parseFunction(D)}parseMetaProperty(D,Z,$){D.meta=Z;let J=this.state.containsEsc;if(D.property=this.parseIdentifier(!0),D.property.name!==$||J)this.raise(m.UnsupportedMetaProperty,D.property,{target:Z.name,onlyValidPropertyName:$});return this.finishNode(D,"MetaProperty")}parseImportMetaPropertyOrPhaseCall(D){if(this.next(),this.isContextual(101)||this.isContextual(93)){let Z=this.isContextual(101);return this.expectPlugin(Z?"sourcePhaseImports":"deferredImportEvaluation"),this.next(),D.phase=Z?"source":"defer",this.parseImportCall(D)}else{let Z=this.createIdentifierAt(this.startNodeAtNode(D),"import",this.state.lastTokStartLoc);if(this.isContextual(97)){if(!this.inModule)this.raise(m.ImportMetaOutsideModule,Z);this.sawUnambiguousESM=!0}return this.parseMetaProperty(D,Z,"meta")}}parseLiteralAtNode(D,Z,$){return this.addExtra($,"rawValue",D),this.addExtra($,"raw",this.input.slice(this.offsetToSourcePos($.start),this.state.end)),$.value=D,this.next(),this.finishNode($,Z)}parseLiteral(D,Z){let $=this.startNode();return this.parseLiteralAtNode(D,Z,$)}parseStringLiteral(D){return this.parseLiteral(D,"StringLiteral")}parseNumericLiteral(D){return this.parseLiteral(D,"NumericLiteral")}parseBigIntLiteral(D){let Z;try{Z=BigInt(D)}catch{Z=null}return this.parseLiteral(Z,"BigIntLiteral")}parseRegExpLiteral(D){let Z=this.startNode();return this.addExtra(Z,"raw",this.input.slice(this.offsetToSourcePos(Z.start),this.state.end)),Z.pattern=D.pattern,Z.flags=D.flags,this.next(),this.finishNode(Z,"RegExpLiteral")}parseBooleanLiteral(D){let Z=this.startNode();return Z.value=D,this.next(),this.finishNode(Z,"BooleanLiteral")}parseNullLiteral(){let D=this.startNode();return this.next(),this.finishNode(D,"NullLiteral")}parseParenAndDistinguishExpression(D){let Z=this.state.startLoc,$;this.next(),this.expressionScope.enter(Im());let J=this.state.startLoc,Q=[],X=new g4,W=!0,G,Y;while(!this.match(7)){if(W)W=!1;else if(this.expect(8,X.optionalParametersLoc===null?null:X.optionalParametersLoc),this.match(7)){Y=this.state.startLoc;break}if(this.match(17)){let K=this.state.startLoc;if(G=this.state.startLoc,Q.push(this.parseParenItem(this.parseRestBinding(),K)),!this.checkCommaAfterRest(41))break}else Q.push(this.parseMaybeAssignAllowInOrVoidPattern(7,X,!0))}let B=this.state.lastTokEndLoc;this.expect(7);let H=this.startNodeAt(Z);if(D&&this.shouldParseArrow(Q)&&(H=this.parseArrow(H)))return this.checkDestructuringPrivate(X),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(H,Q,!1),H;if(this.expressionScope.exit(),!Q.length)this.unexpected(this.state.lastTokStartLoc);if(Y)this.unexpected(Y);if(G)this.unexpected(G);if(this.checkExpressionErrors(X,!0),this.toReferencedList(Q,!0),Q.length>1)$=this.startNodeAt(J),$.expressions=Q,this.finishNode($,"SequenceExpression"),this.resetEndLocation($,B);else $=Q[0];return this.wrapParenthesis(Z,$)}wrapParenthesis(D,Z){if(!(this.optionFlags&2048))return this.addExtra(Z,"parenthesized",!0),this.addExtra(Z,"parenStart",D.index),this.takeSurroundingComments(Z,D.index,this.state.lastTokEndLoc.index),Z;let $=this.startNodeAt(D);return $.expression=Z,this.finishNode($,"ParenthesizedExpression")}shouldParseArrow(D){return!this.canInsertSemicolon()}parseArrow(D){if(this.eat(15))return D}parseParenItem(D,Z){return D}parseNewOrNewTarget(){let D=this.startNode();if(this.next(),this.match(12)){let Z=this.createIdentifier(this.startNodeAtNode(D),"new");this.next();let $=this.parseMetaProperty(D,Z,"target");if(!this.scope.allowNewTarget)this.raise(m.UnexpectedNewTarget,$);return $}return this.parseNew(D)}parseNew(D){if(this.parseNewCallee(D),this.eat(6)){let Z=this.parseExprList(7);this.toReferencedList(Z),D.arguments=Z}else D.arguments=[];return this.finishNode(D,"NewExpression")}parseNewCallee(D){let Z=this.parseNoCallExpr(($)=>{this.raise(m.ImportCallNotNewExpression,$,$)});if(D.callee=Z,Z.type==="Import")this.raise(m.ImportCallNotNewExpression,Z);if(Z.type==="Super")this.raise(m.SuperCallNotNewExpression,Z)}parseTemplateElement(D){let{start:Z,startLoc:$,end:J,value:Q}=this.state,X=Z+1,W=this.startNodeAt(e0($,1));if(Q===null){if(!D)this.raise(m.InvalidEscapeSequenceTemplate,e0(this.state.firstInvalidTemplateEscapePos,1))}let G=this.match(20),Y=G?-1:-2,B=J+Y;W.value={raw:this.input.slice(X,B).replace(/\r\n?/g,`
490
- `),cooked:Q===null?null:Q.slice(1,Y)},W.tail=G,this.next();let H=this.finishNode(W,"TemplateElement");return this.resetEndLocation(H,e0(this.state.lastTokEndLoc,Y)),H}parseTemplate(D){let Z=this.startNode(),$=this.parseTemplateElement(D),J=[$],Q=[];while(!$.tail)Q.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),J.push($=this.parseTemplateElement(D));return Z.expressions=Q,Z.quasis=J,this.finishNode(Z,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(D,Z,$){let J=!1,Q=!0,X=this.startNode();X.properties=[],this.next();while(!this.match(D)){if(Q)Q=!1;else if(this.expect(8),this.match(D)){this.addTrailingCommaExtraToNode(X);break}let G;if(Z)G=this.parseBindingProperty();else G=this.parsePropertyDefinition($),J=this.checkProto(G,J,$);X.properties.push(G)}this.next();let W=Z?"ObjectPattern":"ObjectExpression";return this.finishNode(X,W)}addTrailingCommaExtraToNode(D){this.addExtra(D,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(D,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(D){return!D.computed&&D.key.type==="Identifier"&&(this.isLiteralPropertyName()||this.match(0)||this.match(51))}parsePropertyDefinition(D){let Z=[];if(this.match(22)){if(this.hasPlugin("decorators"))this.raise(m.UnsupportedPropertyDecorator,this.state.startLoc);while(this.match(22))Z.push(this.parseDecorator())}let $=this.startNode(),J=!1,Q=!1,X;if(this.match(17)){if(Z.length)this.unexpected();return this.parseSpread()}if(Z.length)$.decorators=Z;if($.method=!1,D)X=this.state.startLoc;let W=this.eat(51);this.parsePropertyNamePrefixOperator($);let G=this.state.containsEsc;if(this.parsePropertyName($,D),!W&&!G&&this.maybeAsyncOrAccessorProp($)){let{key:Y}=$,B=Y.name;if(B==="async"&&!this.hasPrecedingLineBreak())J=!0,this.resetPreviousNodeTrailingComments(Y),W=this.eat(51),this.parsePropertyName($);if(B==="get"||B==="set"){if(Q=!0,this.resetPreviousNodeTrailingComments(Y),$.kind=B,this.match(51))W=!0,this.raise(m.AccessorIsGenerator,this.state.curPosition(),{kind:B}),this.next();this.parsePropertyName($)}}return this.parseObjPropValue($,X,W,J,!1,Q,D)}getGetterSetterExpectedParamCount(D){return D.kind==="get"?0:1}getObjectOrClassMethodParams(D){return D.params}checkGetterSetterParams(D){let Z=this.getGetterSetterExpectedParamCount(D),$=this.getObjectOrClassMethodParams(D);if($.length!==Z)this.raise(D.kind==="get"?m.BadGetterArity:m.BadSetterArity,D);if(D.kind==="set"&&$[$.length-1]?.type==="RestElement")this.raise(m.BadSetterRestParameter,D)}parseObjectMethod(D,Z,$,J,Q){if(Q){let X=this.parseMethod(D,Z,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(X),X}if($||Z||this.match(6)){if(J)this.unexpected();return D.kind="method",D.method=!0,this.parseMethod(D,Z,$,!1,!1,"ObjectMethod")}}parseObjectProperty(D,Z,$,J){if(D.shorthand=!1,this.eat(10))return D.value=$?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowInOrVoidPattern(4,J),this.finishObjectProperty(D);if(!D.computed&&D.key.type==="Identifier"){if(this.checkReservedWord(D.key.name,D.key.start,!0,!1),$)D.value=this.parseMaybeDefault(Z,this.cloneIdentifier(D.key));else if(this.match(25)){let Q=this.state.startLoc;if(J!=null){if(J.shorthandAssignLoc===null)J.shorthandAssignLoc=Q}else this.raise(m.InvalidCoverInitializedName,Q);D.value=this.parseMaybeDefault(Z,this.cloneIdentifier(D.key))}else D.value=this.cloneIdentifier(D.key);return D.shorthand=!0,this.finishObjectProperty(D)}}finishObjectProperty(D){return this.finishNode(D,"ObjectProperty")}parseObjPropValue(D,Z,$,J,Q,X,W){let G=this.parseObjectMethod(D,$,J,Q,X)||this.parseObjectProperty(D,Z,Q,W);if(!G)this.unexpected();return G}parsePropertyName(D,Z){if(this.eat(0))D.computed=!0,D.key=this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type:$,value:J}=this.state,Q;if(A0($))Q=this.parseIdentifier(!0);else switch($){case 131:Q=this.parseNumericLiteral(J);break;case 130:Q=this.parseStringLiteral(J);break;case 132:Q=this.parseBigIntLiteral(J);break;case 134:{let X=this.state.startLoc;if(Z!=null){if(Z.privateKeyLoc===null)Z.privateKeyLoc=X}else this.raise(m.UnexpectedPrivateField,X);Q=this.parsePrivateName();break}default:throw this.unexpected()}if(D.key=Q,$!==134)D.computed=!1}}initFunction(D,Z){D.id=null,D.generator=!1,D.async=Z}parseMethod(D,Z,$,J,Q,X,W=!1){this.initFunction(D,$),D.generator=Z,this.scope.enter(530|(W?576:0)|(Q?32:0)),this.prodParam.enter(dZ($,D.generator)),this.parseFunctionParams(D,J);let G=this.parseFunctionBodyAndFinish(D,X,!0);return this.prodParam.exit(),this.scope.exit(),G}parseArrayLike(D,Z){let $=this.startNode();return this.next(),$.elements=this.parseExprList(D,!0,Z,$),this.finishNode($,"ArrayExpression")}parseArrowExpression(D,Z,$,J){this.scope.enter(518);let Q=dZ($,!1);if(!this.match(2))Q|=this.prodParam.currentFlags()&24;if(this.prodParam.enter(Q),this.initFunction(D,$),Z)this.setArrowFunctionParameters(D,Z,J);return this.parseFunctionBody(D,!0),this.prodParam.exit(),this.scope.exit(),this.finishNode(D,"ArrowFunctionExpression")}setArrowFunctionParameters(D,Z,$){this.toAssignableList(Z,$,!1),D.params=Z}parseFunctionBodyAndFinish(D,Z,$=!1){return this.parseFunctionBody(D,!1,$),this.finishNode(D,Z)}parseFunctionBody(D,Z,$=!1){let J=Z&&!this.match(2);if(this.expressionScope.enter(cG()),J)D.body=this.parseMaybeAssign(),this.checkParams(D,!1,Z,!1);else{let Q=this.state.strict,X=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),D.body=this.parseBlock(!0,!1,(W)=>{let G=!this.isSimpleParamList(D.params);if(W&&G)this.raise(m.IllegalLanguageModeDirective,(D.kind==="method"||D.kind==="constructor")&&!!D.key?this.optionFlags&256?D.key.loc.end:D.key:D);let Y=!Q&&this.state.strict;if(this.checkParams(D,!this.state.strict&&!Z&&!$&&!G,Z,Y),this.state.strict&&D.id)this.checkIdentifier(D.id,65,Y)}),this.prodParam.exit(),this.state.labels=X}this.expressionScope.exit()}isSimpleParameter(D){return D.type==="Identifier"}isSimpleParamList(D){for(let Z=0,$=D.length;Z<$;Z++)if(!this.isSimpleParameter(D[Z]))return!1;return!0}checkParams(D,Z,$,J=!0){let Q=!Z&&new Set,X={type:"FormalParameters"};for(let W of D.params)this.checkLVal(W,X,5,Q,J)}parseExprList(D,Z,$,J){let Q=[],X=!0;while(!this.eat(D)){if(X)X=!1;else if(this.expect(8),this.match(D)){if(J)this.addTrailingCommaExtraToNode(J);this.next();break}Q.push(this.parseExprListItem(D,Z,$))}return Q}parseExprListItem(D,Z,$,J){let Q;if(this.match(8)){if(!Z)this.raise(m.UnexpectedToken,this.state.curPosition(),{unexpected:","});Q=null}else if(this.match(17)){let X=this.state.startLoc;Q=this.parseParenItem(this.parseSpread($),X)}else if(this.match(13)){if(this.expectPlugin("partialApplication"),!J)this.raise(m.UnexpectedArgumentPlaceholder,this.state.startLoc);let X=this.startNode();this.next(),Q=this.finishNode(X,"ArgumentPlaceholder")}else Q=this.parseMaybeAssignAllowInOrVoidPattern(D,$,!0);return Q}parseIdentifier(D){let Z=this.startNode(),$=this.parseIdentifierName(D);return this.createIdentifier(Z,$)}createIdentifier(D,Z){if(D.name=Z,this.optionFlags&256)D.loc.identifierName=Z;return this.finishNode(D,"Identifier")}createIdentifierAt(D,Z,$){if(D.name=Z,this.optionFlags&256)D.loc.identifierName=Z;return this.finishNodeAt(D,"Identifier",$)}parseIdentifierName(D){let Z,{start:$,type:J}=this.state;if(A0(J))Z=this.state.value;else this.unexpected();let Q=nh(J);if(D){if(Q)this.replaceToken(128)}else this.checkReservedWord(Z,this.sourceToOffsetPos($),Q,!1);return this.next(),Z}checkReservedWord(D,Z,$,J){if(D.length>10)return;if(!Bm(D))return;if($&&Wm(D)){this.raise(m.UnexpectedKeyword,Z,{keyword:D});return}if((!this.state.strict?tN:J?$_:eN)(D,this.inModule)){this.raise(m.UnexpectedReservedWord,Z,{reservedWord:D});return}else if(D==="yield"){if(this.prodParam.hasYield){this.raise(m.YieldBindingIdentifier,Z);return}}else if(D==="await"){if(this.prodParam.hasAwait){this.raise(m.AwaitBindingIdentifier,Z);return}if(this.scope.inStaticBlock){this.raise(m.AwaitBindingIdentifierInStaticBlock,Z);return}this.expressionScope.recordAsyncArrowParametersError(Z)}else if(D==="arguments"){if(this.scope.inClassAndNotInNonArrowFunction){this.raise(m.ArgumentsInClass,Z);return}}}recordAwaitIfAllowed(){let D=this.prodParam.hasAwait;if(D&&!this.scope.inFunction)this.state.hasTopLevelAwait=!0;return D}parseAwait(D,Z){let $=D.index;this.setLoc(D);let J=this.startNodeAt(D);if(this.expressionScope.recordParameterInitializerError(m.AwaitExpressionFormalParameter,$),this.eat(51))this.raise(m.ObsoleteAwaitStar,D);if(!this.scope.inFunction&&!(this.optionFlags&1))if(this.isAmbiguousPrefixOrIdentifier())this.ambiguousScriptDifferentAst=!0;else this.sawUnambiguousESM=!0;if(!Z)J.argument=this.parseMaybeUnary(null,!0);return this.finishNode(J,"AwaitExpression")}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;let{type:D}=this.state;return D===49||D===6||D===0||uG(D)||D===98&&!this.state.containsEsc||D===133||D===52||this.hasPlugin("v8intrinsic")&&D===50}parseYield(D){this.setLoc(D);let Z=this.startNodeAt(D);this.expressionScope.recordParameterInitializerError(m.YieldInParameter,D.index);let $=!1,J=null;if(!this.hasPrecedingLineBreak())switch($=this.eat(51),this.state.type){case 9:case 135:case 4:case 7:case 1:case 5:case 10:case 8:if(!$)break;default:J=this.parseMaybeAssign()}return Z.delegate=$,Z.argument=J,this.finishNode(Z,"YieldExpression")}parseImportCall(D){this.next();let Z=this.parseCallExpressionArguments();if(Z.length===0||Z.length>2)this.raise(m.ImportCallArity,D,D);else for(let $ of Z)if($.type==="SpreadElement")this.raise(m.ImportCallSpreadArgument,$,D);return D.source=Z[0],D.options=Z[1]??null,this.finishNode(D,"ImportExpression")}withTopicBindingContext(D){let Z=this.state.inHackPipelineBody;this.state.inHackPipelineBody=!0;let $=this.state.seenTopicReference;this.state.seenTopicReference=!1;try{return D()}finally{this.state.inHackPipelineBody=Z,this.state.seenTopicReference=$}}allowInAnd(D){let Z=this.prodParam.currentFlags();if(24&~Z){this.prodParam.enter(Z|8|16);try{return D()}finally{this.prodParam.exit()}}return D()}disallowInAnd(D){let Z=this.prodParam.currentFlags(),$=8&Z,J=16&~Z;if($||J){this.prodParam.enter(Z&-9|16);try{return D()}finally{this.prodParam.exit()}}return D()}registerTopicReference(){this.state.seenTopicReference=!0}topicReferenceIsAllowedInCurrentContext(){return this.state.inHackPipelineBody}topicReferenceWasUsedInCurrentContext(){return this.state.seenTopicReference}parseFSharpPipelineBody(D){let Z=this.state.startLoc;this.prodParam.enter(this.prodParam.currentFlags()&-17);let $;if(this.isContextual(92)&&this.recordAwaitIfAllowed()){this.next(),$=this.parseAwait(Z,!0);let J=this.state.type;if(gN(J)&&J!==35&&(this.prodParam.hasIn||J!==54))this.raise(m.PipelineUnparenthesized,Z)}else this.state.canStartArrow=!0,$=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),Z,D);return this.prodParam.exit(),$}parseModuleExpression(){this.expectPlugin("moduleBlocks");let D=this.startNode();if(this.next(),!this.match(2))this.unexpected(null,2);let Z=this.startNodeAt(this.state.endLoc);this.next();let $=this.initializeScopes(!0);this.enterInitialScopes();try{D.body=this.parseProgram(Z,4,"module")}finally{$()}return this.finishNode(D,"ModuleExpression")}parseVoidPattern(D){this.expectPlugin("discardBinding");let Z=this.startNode();if(D!=null)D.voidPatternLoc=this.state.startLoc;return this.next(),this.finishNode(Z,"VoidPattern")}parseMaybeAssignAllowInOrVoidPattern(D,Z,$){if(Z!=null&&this.match(84)){let J=this.lookaheadCharCode();if(J===44||J===(D===1?93:D===4?125:41)||J===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(Z))}return this.parseMaybeAssignAllowIn(Z,$)}parsePropertyNamePrefixOperator(D){}}var hG={kind:1},Rm={kind:2},Em=/[\uD800-\uDFFF]/u,mG=/in(?:stanceof)?/y;function P_(D){for(let Z=0;Z<D.length;Z++){let $=D[Z],{type:J}=$;if(typeof J==="number")$.type=oN(J)}return D}class O_ extends C_{parseTopLevel(D,Z){if(D.program=this.parseProgram(Z,135,this.options.sourceType==="module"?"module":"script"),D.comments=this.comments,this.optionFlags&512)D.tokens=P_(this.tokens);return this.finishNode(D,"File")}parseProgram(D,Z,$){if(D.sourceType=$,D.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(D,!0,!0,Z),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[Q,X]of Array.from(this.scope.undefinedExports))this.raise(m.ModuleExportUndefined,X,{localName:Q});this.addExtra(D,"topLevelAwait",this.state.hasTopLevelAwait)}let J;if(Z===135)J=this.finishNode(D,"Program");else J=this.finishNodeAt(D,"Program",e0(this.state.startLoc,-1));return J}stmtToDirective(D){let Z=this.castNodeTo(D,"Directive"),$=this.castNodeTo(D.expression,"DirectiveLiteral"),J=$.value,Q=this.input.slice(this.offsetToSourcePos($.start),this.offsetToSourcePos($.end)),X=$.value=Q.slice(1,-1);return this.addExtra($,"raw",Q),this.addExtra($,"rawValue",X),this.addExtra($,"expressionValue",J),Z.value=$,delete D.expression,Z}parseInterpreterDirective(){if(!this.match(24))return null;let D=this.startNode();return D.value=this.state.value,this.next(),this.finishNode(D,"InterpreterDirective")}isLet(){if(!this.isContextual(96))return!1;return this.hasFollowingBindingAtom()}isUsing(){if(!this.isContextual(103))return!1;return this.nextTokenIsIdentifierOnSameLine()}isForUsing(){if(!this.isContextual(103))return!1;let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);if(this.isUnparsedContextual(D,"of")){let $=this.lookaheadCharCodeSince(D+2);if($!==61&&$!==58&&$!==59)return!1}if(this.chStartsBindingIdentifier(Z,D)||this.isUnparsedContextual(D,"void"))return!0;return!1}nextTokenIsIdentifierOnSameLine(){let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);return this.chStartsBindingIdentifier(Z,D)}isAwaitUsing(){if(!this.isContextual(92))return!1;let D=this.nextTokenInLineStart();if(this.isUnparsedContextual(D,"using")){D=this.nextTokenInLineStartSince(D+5);let Z=this.codePointAtPos(D);if(this.chStartsBindingIdentifier(Z,D))return!0}return!1}chStartsBindingIdentifier(D,Z){if(h8(D)){if(mG.lastIndex=Z,mG.test(this.input)){let $=this.codePointAtPos(mG.lastIndex);if(!i1($)&&$!==92)return!1}return!0}else if(D===92)return!0;else return!1}chStartsBindingPattern(D){return D===91||D===123}hasFollowingBindingAtom(){let D=this.nextTokenStart(),Z=this.codePointAtPos(D);return this.chStartsBindingPattern(Z)||this.chStartsBindingIdentifier(Z,D)}hasInLineFollowingBindingIdentifierOrBrace(){let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);return Z===123||this.chStartsBindingIdentifier(Z,D)}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(D=!1){let Z=0;if(this.options.annexB&&!this.state.strict){if(Z|=4,D)Z|=8}return this.parseStatementLike(Z)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(D){let Z=null;if(this.match(22))Z=this.parseDecorators(!0);return this.parseStatementContent(D,Z)}parseStatementContent(D,Z){let $=this.state.type,J=this.startNode(),Q=!!(D&2),X=!!(D&4),W=D&1;switch($){case 56:return this.parseBreakContinueStatement(J,!0);case 59:return this.parseBreakContinueStatement(J,!1);case 60:return this.parseDebuggerStatement(J);case 86:return this.parseDoWhileStatement(J);case 87:return this.parseForStatement(J);case 64:if(this.lookaheadCharCode()===46)break;if(!X)this.raise(this.state.strict?m.StrictFunction:this.options.annexB?m.SloppyFunctionAnnexB:m.SloppyFunction,this.state.startLoc);return this.parseFunctionStatement(J,!1,!Q&&X);case 76:if(!Q)this.unexpected();return this.parseClass(this.maybeTakeDecorators(Z,J),!0);case 65:return this.parseIfStatement(J);case 66:return this.parseReturnStatement(J);case 67:return this.parseSwitchStatement(J);case 68:return this.parseThrowStatement(J);case 69:return this.parseTryStatement(J);case 92:if(this.isAwaitUsing()){if(!this.allowsUsing())this.raise(m.UnexpectedUsingDeclaration,J);else if(!Q)this.raise(m.UnexpectedLexicalDeclaration,J);else if(!this.recordAwaitIfAllowed())this.raise(m.AwaitUsingNotInAsyncContext,J);return this.next(),this.parseVarStatement(J,"await using")}break;case 103:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;if(!this.allowsUsing())this.raise(m.UnexpectedUsingDeclaration,this.state.startLoc);else if(!Q)this.raise(m.UnexpectedLexicalDeclaration,this.state.startLoc);return this.parseVarStatement(J,"using");case 96:{if(this.state.containsEsc)break;let B=this.nextTokenStart(),H=this.codePointAtPos(B);if(H!==91){if(!Q&&this.hasFollowingLineBreak())break;if(!this.chStartsBindingIdentifier(H,B)&&H!==123)break}}case 71:if(!Q)this.raise(m.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let B=this.state.value;return this.parseVarStatement(J,B)}case 88:return this.parseWhileStatement(J);case 72:return this.parseWithStatement(J);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(J);case 79:{let B=this.lookaheadCharCode();if(B===40||B===46)break}case 78:{if(!(this.optionFlags&8)&&!W)this.raise(m.UnexpectedImportExport,this.state.startLoc);this.next();let B;if($===79)B=this.parseImport(J);else B=this.parseExport(J,Z);return this.assertModuleNodeAllowed(B),B}default:if(this.isAsyncFunction()){if(!Q)this.raise(m.AsyncFunctionInSingleStatementContext,this.state.startLoc);return this.next(),this.parseFunctionStatement(J,!0,!Q&&X)}}let G=this.state.value,Y=this.parseExpression();if(iD($)&&Y.type==="Identifier"&&this.eat(10))return this.parseLabeledStatement(J,G,Y,D);else return this.parseExpressionStatement(J,Y)}assertModuleNodeAllowed(D){if(!(this.optionFlags&8)&&!this.inModule)this.raise(m.ImportOutsideModule,D)}maybeTakeDecorators(D,Z,$){if(D){if(Z.decorators?.length)this.raise(m.DecoratorsBeforeAfterExport,Z.decorators[0]),Z.decorators.unshift(...D);else Z.decorators=D;if(this.resetStartLocationFromNode(Z,D[0]),$)this.resetStartLocationFromNode($,Z)}return Z}canHaveLeadingDecorator(){return this.match(76)}parseDecorators(D){let Z=[];do Z.push(this.parseDecorator());while(this.match(22));if(this.match(78)){if(!D)this.unexpected()}else if(!this.canHaveLeadingDecorator())throw this.raise(m.UnexpectedLeadingDecorator,this.state.startLoc);return Z}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);let D=this.startNode();if(this.next(),this.hasPlugin("decorators")){let Z=this.state.startLoc,$;if(this.match(6)){let J=this.state.startLoc;this.next(),$=this.parseExpression(),this.expect(7),$=this.wrapParenthesis(J,$);let Q=this.state.startLoc;if(D.expression=this.parseMaybeDecoratorArguments($,J),D.expression!==$)this.raise(m.DecoratorArgumentsOutsideParentheses,Q)}else{$=this.parseIdentifier(!1);while(this.eat(12)){let J=this.startNodeAt(Z);if(J.object=$,this.match(134))this.classScope.usePrivateName(this.state.value,this.state.startLoc),J.property=this.parsePrivateName();else J.property=this.parseIdentifier(!0);J.computed=!1,$=this.finishNode(J,"MemberExpression")}D.expression=this.parseMaybeDecoratorArguments($,Z)}}else this.state.canStartArrow=!1,D.expression=this.parseExprSubscripts();return this.finishNode(D,"Decorator")}parseMaybeDecoratorArguments(D,Z){if(this.eat(6)){let $=this.startNodeAt(Z);return $.callee=D,$.arguments=this.parseCallExpressionArguments(),this.toReferencedList($.arguments),this.finishNode($,"CallExpression")}return D}parseBreakContinueStatement(D,Z){if(this.next(),this.isLineTerminator())D.label=null;else D.label=this.parseIdentifier(),this.semicolon();return this.verifyBreakContinue(D,Z),this.finishNode(D,Z?"BreakStatement":"ContinueStatement")}verifyBreakContinue(D,Z){let $;for($=0;$<this.state.labels.length;++$){let J=this.state.labels[$];if(D.label==null||J.name===D.label.name){if(J.kind!=null&&(Z||J.kind===1))break;if(D.label&&Z)break}}if($===this.state.labels.length){let J=Z?"BreakStatement":"ContinueStatement";this.raise(m.IllegalBreakContinue,D,{type:J})}}parseDebuggerStatement(D){return this.next(),this.semicolon(),this.finishNode(D,"DebuggerStatement")}parseHeaderExpression(){this.expect(6);let D=this.parseExpression();return this.expect(7),D}parseDoWhileStatement(D){return this.next(),this.state.labels.push(hG),D.body=this.parseStatement(),this.state.labels.pop(),this.expect(88),D.test=this.parseHeaderExpression(),this.eat(9),this.finishNode(D,"DoWhileStatement")}parseForStatement(D){this.next(),this.state.labels.push(hG);let Z=null;if(this.isContextual(92)&&this.recordAwaitIfAllowed())Z=this.state.startLoc,this.next();if(this.scope.enter(0),this.expect(6),this.match(9)){if(Z!==null)this.unexpected(Z);return this.parseFor(D,null)}let $=this.isContextual(96);{let G=this.isAwaitUsing(),Y=G||this.isForUsing(),B=$&&this.hasFollowingBindingAtom()||Y;if(this.match(70)||this.match(71)||B){let H=this.startNode(),K;if(G){if(K="await using",!this.recordAwaitIfAllowed())this.raise(m.AwaitUsingNotInAsyncContext,this.state.startLoc);this.next()}else K=this.state.value;this.next(),this.parseVar(H,!0,K);let z=this.finishNode(H,"VariableDeclaration"),V=this.match(54);if(V&&Y)this.raise(m.ForInUsing,z);if((V||this.isContextual(98))&&z.declarations.length===1)return this.parseForX(D,z,Z);if(Z!==null)this.unexpected(Z);return this.parseFor(D,z)}}let J=this.isContextual(91),Q=new g4,X=this.parseExpression(!0,Q),W=this.isContextual(98);if(W){if($)this.raise(m.ForOfLet,X);if(Z===null&&J&&X.type==="Identifier")this.raise(m.ForOfAsync,X)}if(W||this.match(54)){this.checkDestructuringPrivate(Q),this.toAssignable(X,!0);let G=W?"ForOfStatement":"ForInStatement";return this.checkLVal(X,{type:G}),this.parseForX(D,X,Z)}else this.checkExpressionErrors(Q,!0);if(Z!==null)this.unexpected(Z);return this.parseFor(D,X)}parseFunctionStatement(D,Z,$){return this.next(),this.parseFunction(D,1|($?2:0)|(Z?8:0))}parseIfStatement(D){return this.next(),D.test=this.parseHeaderExpression(),D.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),D.alternate=this.eat(62)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(D,"IfStatement")}parseReturnStatement(D){if(!this.prodParam.hasReturn)this.raise(m.IllegalReturn,this.state.startLoc);if(this.next(),this.isLineTerminator())D.argument=null;else D.argument=this.parseExpression(),this.semicolon();return this.finishNode(D,"ReturnStatement")}parseSwitchStatement(D){this.next(),D.discriminant=this.parseHeaderExpression();let Z=D.cases=[];this.expect(2),this.state.labels.push(Rm),this.scope.enter(256);let $;for(let J;!this.match(4);)if(this.match(57)||this.match(61)){let Q=this.match(57);if($)this.finishNode($,"SwitchCase");if(Z.push($=this.startNode()),$.consequent=[],this.next(),Q)$.test=this.parseExpression();else{if(J)this.raise(m.MultipleDefaultsInSwitch,this.state.lastTokStartLoc);J=!0,$.test=null}this.expect(10)}else if($)$.consequent.push(this.parseStatementListItem());else this.unexpected();if(this.scope.exit(),$)this.finishNode($,"SwitchCase");return this.next(),this.state.labels.pop(),this.finishNode(D,"SwitchStatement")}parseThrowStatement(D){if(this.next(),this.hasPrecedingLineBreak())this.raise(m.NewlineAfterThrow,this.state.lastTokEndLoc);return D.argument=this.parseExpression(),this.semicolon(),this.finishNode(D,"ThrowStatement")}parseCatchClauseParam(){let D=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&D.type==="Identifier"?8:0),this.checkLVal(D,{type:"CatchClause"},9),D}parseTryStatement(D){if(this.next(),D.block=this.parseBlock(),D.handler=null,this.match(58)){let Z=this.startNode();if(this.next(),this.match(6))this.expect(6),Z.param=this.parseCatchClauseParam(),this.expect(7);else Z.param=null,this.scope.enter(0);Z.body=this.parseBlock(!1,!1),this.scope.exit(),D.handler=this.finishNode(Z,"CatchClause")}if(D.finalizer=this.eat(63)?this.parseBlock():null,!D.handler&&!D.finalizer)this.raise(m.NoCatchOrFinally,D);return this.finishNode(D,"TryStatement")}parseVarStatement(D,Z,$=!1){return this.next(),this.parseVar(D,!1,Z,$),this.semicolon(),this.finishNode(D,"VariableDeclaration")}parseWhileStatement(D){return this.next(),D.test=this.parseHeaderExpression(),this.state.labels.push(hG),D.body=this.parseStatement(),this.state.labels.pop(),this.finishNode(D,"WhileStatement")}parseWithStatement(D){if(this.state.strict)this.raise(m.StrictWith,this.state.startLoc);return this.next(),D.object=this.parseHeaderExpression(),D.body=this.parseStatement(),this.finishNode(D,"WithStatement")}parseEmptyStatement(D){return this.next(),this.finishNode(D,"EmptyStatement")}parseLabeledStatement(D,Z,$,J){for(let X of this.state.labels)if(X.name===Z)this.raise(m.LabelRedeclaration,$,{labelName:Z});let Q=oh(this.state.type)?1:this.match(67)?2:null;for(let X=this.state.labels.length-1;X>=0;X--){let W=this.state.labels[X];if(W.statementStart===D.start)W.statementStart=this.sourceToOffsetPos(this.state.start),W.kind=Q;else break}return this.state.labels.push({name:Z,kind:Q,statementStart:this.sourceToOffsetPos(this.state.start)}),D.body=J&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),D.label=$,this.finishNode(D,"LabeledStatement")}parseExpressionStatement(D,Z){return D.expression=Z,this.semicolon(),this.finishNode(D,"ExpressionStatement")}parseBlock(D=!1,Z=!0,$){let J=this.startNode();if(D)this.state.strictErrors.clear();if(this.expect(2),Z)this.scope.enter(0);if(this.parseBlockBody(J,D,!1,4,$),Z)this.scope.exit();return this.finishNode(J,"BlockStatement")}isValidDirective(D){return D.type==="ExpressionStatement"&&D.expression.type==="StringLiteral"&&!D.expression.extra.parenthesized}parseBlockBody(D,Z,$,J,Q){let X=D.body=[],W=D.directives=[];this.parseBlockOrModuleBlockBody(X,Z?W:void 0,$,J,Q)}parseBlockOrModuleBlockBody(D,Z,$,J,Q){let X=this.state.strict,W=!1,G=!1;while(!this.match(J)){let Y=$?this.parseModuleItem():this.parseStatementListItem();if(Z&&!G){if(this.isValidDirective(Y)){let B=this.stmtToDirective(Y);if(Z.push(B),!W&&B.value.value==="use strict")W=!0,this.setStrict(!0);continue}G=!0,this.state.strictErrors.clear()}D.push(Y)}if(Q?.call(this,W),!X)this.setStrict(!1);this.next()}parseFor(D,Z){return D.init=Z,this.semicolon(!1),D.test=this.match(9)?null:this.parseExpression(),this.semicolon(!1),D.update=this.match(7)?null:this.parseExpression(),this.expect(7),D.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(D,"ForStatement")}parseForX(D,Z,$){let J=this.match(54);if(this.next(),J){if($!==null)this.unexpected($)}else D.await=$!==null;if(Z.type==="VariableDeclaration"&&Z.declarations[0].init!=null&&(!J||!this.options.annexB||this.state.strict||Z.kind!=="var"||Z.declarations[0].id.type!=="Identifier"))this.raise(m.ForInOfLoopInitializer,Z,{type:J?"ForInStatement":"ForOfStatement"});if(Z.type==="AssignmentPattern")this.raise(m.InvalidLhs,Z,{ancestor:{type:"ForStatement"}});return D.left=Z,D.right=J?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(7),D.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(D,J?"ForInStatement":"ForOfStatement")}parseVar(D,Z,$,J=!1){let Q=D.declarations=[];D.kind=$;for(;;){let X=this.startNode();if(this.parseVarId(X,$),X.init=!this.eat(25)?null:Z?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn(),X.init===null&&!J){if(X.id.type!=="Identifier"&&!(Z&&(this.match(54)||this.isContextual(98))))this.raise(m.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"});else if(($==="const"||$==="using"||$==="await using")&&!(this.match(54)||this.isContextual(98)))this.raise(m.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:$})}if(Q.push(this.finishNode(X,"VariableDeclarator")),!this.eat(8))break}return D}parseVarId(D,Z){let $=this.parseBindingAtom();if(Z==="using"||Z==="await using"){if($.type==="ArrayPattern"||$.type==="ObjectPattern")this.raise(m.UsingDeclarationHasBindingPattern,$)}else if($.type==="VoidPattern")this.raise(m.UnexpectedVoidPattern,$);this.checkLVal($,{type:"VariableDeclarator"},Z==="var"?5:8201),D.id=$}parseAsyncFunctionExpression(D){return this.parseFunction(D,8)}parseFunction(D,Z=0){let $=Z&2,J=!!(Z&1),Q=J&&!(Z&4),X=!!(Z&8);if(this.initFunction(D,X),this.match(51)){if($)this.raise(m.GeneratorInSingleStatementContext,this.state.startLoc);this.next(),D.generator=!0}if(J)D.id=this.parseFunctionId(Q);if(this.scope.enter(514),this.prodParam.enter(dZ(X,D.generator)),!J&&iD(this.state.type))this.expressionScope.enter(cG()),D.id=this.parseFunctionId(),this.expressionScope.exit();if(this.parseFunctionParams(D,!1),this.parseFunctionBodyAndFinish(D,J?"FunctionDeclaration":"FunctionExpression"),this.prodParam.exit(),this.scope.exit(),J&&!$)this.registerFunctionStatementId(D);return D}parseFunctionId(D){return D||iD(this.state.type)?this.parseIdentifier():null}parseFunctionParams(D,Z){this.expect(6),this.expressionScope.enter(Am()),D.params=this.parseBindingList(7,41,2|(Z?4:0)),this.expressionScope.exit()}registerFunctionStatementId(D){if(!D.id)return;this.scope.declareName(D.id.name,!this.options.annexB||this.state.strict||D.generator||D.async?this.scope.treatFunctionsAsVar?5:8201:17,D.id.start)}parseClass(D,Z,$){this.next();let J=this.state.strict;return this.state.strict=!0,this.parseClassId(D,Z,$),this.parseClassSuper(D),D.body=this.parseClassBody(!!D.superClass,J),this.finishNode(D,Z?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(D){return D.type==="Identifier"&&D.name==="constructor"||D.type==="StringLiteral"&&D.value==="constructor"}isNonstaticConstructor(D){return!D.computed&&!D.static&&this.nameIsConstructor(D.key)}parseClassBody(D,Z){this.classScope.enter();let $={hadConstructor:!1,hadSuperClass:D},J=[],Q=this.startNode();Q.body=[],this.expect(2);while(!this.match(4)){if(this.eat(9)){if(J.length>0)throw this.raise(m.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){J.push(this.parseDecorator());continue}let X=this.startNode();if(J.length)X.decorators=J,this.resetStartLocationFromNode(X,J[0]),J=[];this.parseClassMember(Q,X,$)}if(this.state.strict=Z,this.next(),J.length)throw this.raise(m.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(Q,"ClassBody")}parseClassMemberFromModifier(D,Z){let $=this.parseIdentifier(!0);if(this.isClassMethod()){let J=Z;return J.kind="method",J.computed=!1,J.key=$,J.static=!1,this.pushClassMethod(D,J,!1,!1,!1,!1),!0}else if(this.isClassProperty()){let J=Z;return J.computed=!1,J.key=$,J.static=!1,D.body.push(this.parseClassProperty(J)),!0}return this.resetPreviousNodeTrailingComments($),!1}parseClassMember(D,Z,$){let J=this.isContextual(102);if(J){if(this.parseClassMemberFromModifier(D,Z))return;if(this.eat(2)){this.parseClassStaticBlock(D,Z);return}}this.parseClassMemberWithIsStatic(D,Z,$,J)}parseClassMemberWithIsStatic(D,Z,$,J){let Q=Z,X=Z,W=Z,G=Z,Y=Z,B=Q,H=Q;if(Z.static=J,this.parsePropertyNamePrefixOperator(Z),this.eat(51)){B.kind="method";let F=this.match(134);if(this.parseClassElementName(B),this.parsePostMemberNameModifiers(B),F){this.pushClassPrivateMethod(D,X,!0,!1);return}if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsGenerator,Q.key);this.pushClassMethod(D,Q,!0,!1,!1,!1);return}let K=!this.state.containsEsc&&iD(this.state.type),z=this.parseClassElementName(Z),V=K?z.name:null,_=this.isPrivateName(z),N=this.state.startLoc;if(this.parsePostMemberNameModifiers(H),this.isClassMethod()){if(B.kind="method",_){this.pushClassPrivateMethod(D,X,!1,!1);return}let F=this.isNonstaticConstructor(Q),U=!1;if(F){if(Q.kind="constructor",Q.decorators&&Q.decorators.length>0)this.raise(m.DecoratorConstructor,Z);if($.hadConstructor&&!this.hasPlugin("typescript"))this.raise(m.DuplicateConstructor,z);if(F&&this.hasPlugin("typescript")&&Z.override)this.raise(m.OverrideOnConstructor,z);$.hadConstructor=!0,U=$.hadSuperClass}this.pushClassMethod(D,Q,!1,!1,F,U)}else if(this.isClassProperty())if(_)this.pushClassPrivateProperty(D,G);else this.pushClassProperty(D,W);else if(V==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(z);let F=this.eat(51);if(H.optional)this.unexpected(N);B.kind="method";let U=this.match(134);if(this.parseClassElementName(B),this.parsePostMemberNameModifiers(H),U)this.pushClassPrivateMethod(D,X,F,!0);else{if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsAsync,Q.key);this.pushClassMethod(D,Q,F,!0,!1,!1)}}else if((V==="get"||V==="set")&&!(this.match(51)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(z),B.kind=V;let F=this.match(134);if(this.parseClassElementName(Q),F)this.pushClassPrivateMethod(D,X,!1,!1);else{if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsAccessor,Q.key);this.pushClassMethod(D,Q,!1,!1,!1,!1)}this.checkGetterSetterParams(Q)}else if(V==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(z);let F=this.match(134);this.parseClassElementName(W),this.pushClassAccessorProperty(D,Y,F)}else if(this.isLineTerminator())if(_)this.pushClassPrivateProperty(D,G);else this.pushClassProperty(D,W);else this.unexpected()}parseClassElementName(D){let{type:Z,value:$}=this.state;if((Z===128||Z===130)&&D.static&&$==="prototype")this.raise(m.StaticPrototype,this.state.startLoc);if(Z===134){if($==="constructor")this.raise(m.ConstructorClassPrivateField,this.state.startLoc);let J=this.parsePrivateName();return D.key=J,J}return this.parsePropertyName(D),D.key}parseClassStaticBlock(D,Z){this.scope.enter(720);let $=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let J=Z.body=[];if(this.parseBlockOrModuleBlockBody(J,void 0,!1,4),this.prodParam.exit(),this.scope.exit(),this.state.labels=$,D.body.push(this.finishNode(Z,"StaticBlock")),Z.decorators?.length)this.raise(m.DecoratorStaticBlock,Z)}pushClassProperty(D,Z){if(!Z.computed&&this.nameIsConstructor(Z.key))this.raise(m.ConstructorClassField,Z.key);D.body.push(this.parseClassProperty(Z))}pushClassPrivateProperty(D,Z){let $=this.parseClassPrivateProperty(Z);D.body.push($),this.classScope.declarePrivateName(this.getPrivateNameSV($.key),0,$.key.start)}pushClassAccessorProperty(D,Z,$){if(!$&&!Z.computed&&this.nameIsConstructor(Z.key))this.raise(m.ConstructorClassField,Z.key);let J=this.parseClassAccessorProperty(Z);if(D.body.push(J),$)this.classScope.declarePrivateName(this.getPrivateNameSV(J.key),0,J.key.start)}pushClassMethod(D,Z,$,J,Q,X){D.body.push(this.parseMethod(Z,$,J,Q,X,"ClassMethod",!0))}pushClassPrivateMethod(D,Z,$,J){let Q=this.parseMethod(Z,$,J,!1,!1,"ClassPrivateMethod",!0);D.body.push(Q);let X=Q.kind==="get"?Q.static?6:2:Q.kind==="set"?Q.static?5:1:0;this.declareClassPrivateMethodInScope(Q,X)}declareClassPrivateMethodInScope(D,Z){this.classScope.declarePrivateName(this.getPrivateNameSV(D.key),Z,D.key.start)}parsePostMemberNameModifiers(D){}parseClassPrivateProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassPrivateProperty")}parseClassProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassProperty")}parseClassAccessorProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassAccessorProperty")}parseInitializer(D){this.scope.enter(592),this.expressionScope.enter(cG()),this.prodParam.enter(0),D.value=this.eat(25)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(D,Z,$,J=8331){if(iD(this.state.type)){if(D.id=this.parseIdentifier(),Z)this.declareNameFromIdentifier(D.id,J)}else if($||!Z)D.id=null;else throw this.raise(m.MissingClassName,this.state.startLoc)}parseClassSuper(D){if(this.eat(77))this.state.canStartArrow=!1,D.superClass=this.parseExprSubscripts();else D.superClass=null}parseExport(D,Z){let $=this.parseMaybeImportPhase(D,!0),J=this.maybeParseExportDefaultSpecifier(D,$),Q=!J||this.eat(8),X=Q&&this.eatExportStar(D),W=X&&this.maybeParseExportNamespaceSpecifier(D),G=Q&&(!W||this.eat(8)),Y=J||X;if(X&&!W){if(J)this.unexpected();if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);return this.parseExportFrom(D,!0),this.sawUnambiguousESM=!0,this.finishNode(D,"ExportAllDeclaration")}let B=this.maybeParseExportNamedSpecifiers(D);if(J&&Q&&!X&&!B)this.unexpected(null,2);if(W&&G)this.unexpected(null,94);let H;if(Y||B){if(H=!1,Z)throw this.raise(m.UnsupportedDecoratorExport,D);this.parseExportFrom(D,Y)}else H=this.maybeParseExportDeclaration(D);if(Y||B||H){let K=D;if(this.checkNamedExport(K,!!K.source),K.declaration?.type==="ClassDeclaration")this.maybeTakeDecorators(Z,K.declaration,K);else if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);return this.sawUnambiguousESM=!0,this.finishNode(K,"ExportNamedDeclaration")}if(this.eat(61)){let K=D,z=this.parseExportDefaultExpression();if(K.declaration=z,z.type==="ClassDeclaration")this.maybeTakeDecorators(Z,z,K);else if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);if(this.checkDuplicateExports(D,"default"),this.hasPlugin("exportDefaultFrom")){if(z.type==="Identifier"&&z.name==="from"&&z.end-z.start===4&&!z.extra?.parenthesized)this.raise(m.ExportDefaultFromAsIdentifier,z)}return this.sawUnambiguousESM=!0,this.finishNode(K,"ExportDefaultDeclaration")}throw this.unexpected(null,2)}eatExportStar(D){return this.eat(51)}maybeParseExportDefaultSpecifier(D,Z){if(Z||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",Z?.start);let $=Z||this.parseIdentifier(!0),J=this.startNodeAtNode($);return J.exported=$,D.specifiers=[this.finishNode(J,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(D){if(this.isContextual(89)){D.specifiers??=[];let Z=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),Z.exported=this.parseModuleExportName(),D.specifiers.push(this.finishNode(Z,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(D){if(this.match(2)){let Z=D;if(!Z.specifiers)Z.specifiers=[];let $=Z.exportKind==="type";return Z.specifiers.push(...this.parseExportSpecifiers($)),Z.source=null,Z.attributes=[],Z.declaration=null,!0}return!1}maybeParseExportDeclaration(D){if(this.shouldParseExportDeclaration())return D.specifiers=[],D.source=null,D.attributes=[],D.declaration=this.parseExportDeclaration(D),!0;return!1}isAsyncFunction(){if(!this.isContextual(91))return!1;let D=this.nextTokenInLineStart();return this.isUnparsedContextual(D,"function")}parseExportDefaultExpression(){let D=this.startNode();if(this.match(64))return this.next(),this.parseFunction(D,5);else if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(D,13);if(this.match(76))return this.parseClass(D,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.raise(m.UnsupportedDefaultExport,this.state.startLoc);let Z=this.parseMaybeAssignAllowIn();return this.semicolon(),Z}parseExportDeclaration(D){if(this.match(76))return this.parseClass(this.startNode(),!0,!1);return this.parseStatementListItem()}isExportDefaultSpecifier(){let{type:D}=this.state;if(iD(D)){if(D===91&&!this.state.containsEsc||D===96)return!1;if((D===126||D===125)&&!this.state.containsEsc){let J=this.nextTokenStart(),Q=this.input.charCodeAt(J);if(Q===123||this.chStartsBindingIdentifier(Q,J)&&!this.input.startsWith("from",J))return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(61))return!1;let Z=this.nextTokenStart(),$=this.isUnparsedContextual(Z,"from");if(this.input.charCodeAt(Z)===44||iD(this.state.type)&&$)return!0;if(this.match(61)&&$){let J=this.input.charCodeAt(this.nextTokenStartSince(Z+4));return J===34||J===39}return!1}parseExportFrom(D,Z){if(this.eatContextual(94))D.source=this.parseImportSource(),this.maybeParseImportAttributes(D);else if(Z)this.unexpected();this.semicolon()}shouldParseExportDeclaration(){let{type:D}=this.state;if(D===22){if(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))return!0}if(this.isUsing())return this.raise(m.UsingDeclarationExport,this.state.startLoc),!0;if(this.isAwaitUsing())return this.raise(m.UsingDeclarationExport,this.state.startLoc),!0;return D===70||D===71||D===64||D===76||this.isLet()||this.isAsyncFunction()}checkNamedExport(D,Z){if(D.specifiers?.length)for(let $ of D.specifiers){let{exported:J}=$,Q=J.type==="Identifier"?J.name:J.value;if(this.checkDuplicateExports($,Q),!Z&&$.type==="ExportSpecifier"){let{local:X}=$;if(X.type!=="Identifier")this.raise(m.ExportBindingIsString,$,{localName:X.value,exportName:Q});else this.checkReservedWord(X.name,X.start,!0,!1),this.scope.checkLocalExport(X)}}else if(D.declaration){let $=D.declaration;if($.type==="FunctionDeclaration"||$.type==="ClassDeclaration"){let{id:J}=$;if(!J)throw Error("Assertion failure");this.checkDuplicateExports(D,J.name)}else if($.type==="VariableDeclaration")for(let J of $.declarations)this.checkDeclaration(J.id)}}checkDeclaration(D){if(D.type==="Identifier")this.checkDuplicateExports(D,D.name);else if(D.type==="ObjectPattern")for(let Z of D.properties)this.checkDeclaration(Z);else if(D.type==="ArrayPattern"){for(let Z of D.elements)if(Z)this.checkDeclaration(Z)}else if(D.type==="ObjectProperty")this.checkDeclaration(D.value);else if(D.type==="RestElement")this.checkDeclaration(D.argument);else if(D.type==="AssignmentPattern")this.checkDeclaration(D.left)}checkDuplicateExports(D,Z){if(this.exportedIdentifiers.has(Z))if(Z==="default")this.raise(m.DuplicateDefaultExport,D);else this.raise(m.DuplicateExport,D,{exportName:Z});this.exportedIdentifiers.add(Z)}parseExportSpecifiers(D){let Z=[],$=!0;this.expect(2);while(!this.eat(4)){if($)$=!1;else if(this.expect(8),this.eat(4))break;let J=this.isContextual(126),Q=this.match(130),X=this.startNode();X.local=this.parseModuleExportName(),Z.push(this.parseExportSpecifier(X,Q,D,J))}return Z}parseExportSpecifier(D,Z,$,J){if(this.eatContextual(89))D.exported=this.parseModuleExportName();else if(Z)D.exported=this.cloneStringLiteral(D.local);else if(!D.exported)D.exported=this.cloneIdentifier(D.local);return this.finishNode(D,"ExportSpecifier")}parseModuleExportName(){if(this.match(130)){let D=this.parseStringLiteral(this.state.value),Z=Em.exec(D.value);if(Z)this.raise(m.ModuleExportNameHasLoneSurrogate,D,{surrogateCharCode:Z[0].charCodeAt(0)});return D}return this.parseIdentifier(!0)}checkImportPhase(D){let{specifiers:Z}=D,$=Z.length===1?Z[0].type:null;if(D.phase==="source"){if($!=="ImportDefaultSpecifier")this.raise(m.SourcePhaseImportRequiresDefault,Z[0])}else if(D.phase==="defer"){if($!=="ImportNamespaceSpecifier")this.raise(m.DeferImportRequiresNamespace,Z[0])}}isPotentialImportPhase(D){if(D)return!1;return this.isContextual(101)||this.isContextual(93)}applyImportPhase(D,Z,$,J){if(Z)return;if($==="source")this.expectPlugin("sourcePhaseImports",J),D.phase="source";else if($==="defer")this.expectPlugin("deferredImportEvaluation",J),D.phase="defer";else if(this.hasPlugin("sourcePhaseImports"))D.phase=null}parseMaybeImportPhase(D,Z){if(!this.isPotentialImportPhase(Z))return this.applyImportPhase(D,Z,null),null;let $=this.startNode(),J=this.parseIdentifierName(!0),{type:Q}=this.state;if(A0(Q)?Q!==94||this.lookaheadCharCode()===102:Q!==8)return this.applyImportPhase(D,Z,J,$.start),null;else return this.applyImportPhase(D,Z,null),this.createIdentifier($,J)}isPrecedingIdImportPhase(D){let{type:Z}=this.state;return iD(Z)?Z!==94||this.lookaheadCharCode()===102:Z!==8}parseImport(D){if(this.match(130))return this.parseImportSourceAndAttributes(D);return this.parseImportSpecifiersAndAfter(D,this.parseMaybeImportPhase(D,!1))}parseImportSpecifiersAndAfter(D,Z){D.specifiers=[];let J=!this.maybeParseDefaultImportSpecifier(D,Z)||this.eat(8),Q=J&&this.maybeParseStarImportSpecifier(D);if(J&&!Q)this.parseNamedImportSpecifiers(D);return this.expectContextual(94),this.parseImportSourceAndAttributes(D)}parseImportSourceAndAttributes(D){return D.specifiers??=[],D.source=this.parseImportSource(),this.maybeParseImportAttributes(D),this.checkImportPhase(D),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(D,"ImportDeclaration")}parseImportSource(){if(!this.match(130))this.unexpected();return this.parseExprAtom()}parseImportSpecifierLocal(D,Z,$){Z.local=this.parseIdentifier(),D.specifiers.push(this.finishImportSpecifier(Z,$))}finishImportSpecifier(D,Z,$=8201){return this.checkLVal(D.local,{type:Z},$),this.finishNode(D,Z)}parseImportAttributes(){this.expect(2);let D=[],Z=new Set;do{if(this.match(4))break;let $=this.startNode(),J=this.state.value;if(Z.has(J))this.raise(m.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:J});if(Z.add(J),this.match(130))$.key=this.parseStringLiteral(J);else $.key=this.parseIdentifier(!0);if(this.expect(10),!this.match(130))throw this.raise(m.ModuleAttributeInvalidValue,this.state.startLoc);$.value=this.parseStringLiteral(this.state.value),D.push(this.finishNode($,"ImportAttribute"))}while(this.eat(8));return this.expect(4),D}maybeParseImportAttributes(D){let Z;if(this.match(72)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),Z=this.parseImportAttributes()}else Z=[];D.attributes=Z}maybeParseDefaultImportSpecifier(D,Z){if(Z){let $=this.startNodeAtNode(Z);return $.local=Z,D.specifiers.push(this.finishImportSpecifier($,"ImportDefaultSpecifier")),!0}else if(A0(this.state.type))return this.parseImportSpecifierLocal(D,this.startNode(),"ImportDefaultSpecifier"),!0;return!1}maybeParseStarImportSpecifier(D){if(this.match(51)){let Z=this.startNode();return this.next(),this.expectContextual(89),this.parseImportSpecifierLocal(D,Z,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(D){let Z=!0;this.expect(2);while(!this.eat(4)){if(Z)Z=!1;else{if(this.eat(10))throw this.raise(m.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let $=this.startNode(),J=this.match(130),Q=this.isContextual(126);$.imported=this.parseModuleExportName();let X=this.parseImportSpecifier($,J,D.importKind==="type"||D.importKind==="typeof",Q,void 0);D.specifiers.push(X)}}parseImportSpecifier(D,Z,$,J,Q){if(this.eatContextual(89))D.local=this.parseIdentifier();else{let{imported:X}=D;if(Z)throw this.raise(m.ImportBindingIsString,D,{importName:X.value});if(this.checkReservedWord(X.name,D.start,!0,!0),!D.local)D.local=this.cloneIdentifier(X)}return this.finishImportSpecifier(D,"ImportSpecifier",Q)}isThisParam(D){return D.type==="Identifier"&&D.name==="this"}}var vG=/in(?:stanceof)?|as|satisfies/y;function wm(D){if(D==null)throw Error(`Unexpected ${D} value.`);return D}function pN(D){if(!D)throw Error("Assert fail")}var xm={AbstractMethodHasImplementation:({methodName:D})=>`Method '${D}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:D})=>`Property '${D}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",AccessorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccessorCannotHaveTypeParameters:"An accessor cannot have type parameters.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclaratorDefiniteAssertionRequiresTypeAnnotation:"Declarations with definite assignment assertions must also have type annotations.",DeclaratorDefiniteAssertionWithInitializer:"Declarations with initializers cannot also have definite assignment assertions.",DeclareAccessor:({kind:D})=>`'declare' is not allowed in ${D}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DecoratorAbstractMethod:({kind:D})=>`Decorators can't be used with ${D.startsWith("a")?"an":"a"} ${D}.`,DuplicateAccessibilityModifier:({modifier:D})=>`Accessibility modifier already seen: '${D}'.`,DuplicateModifier:({modifier:D})=>`Duplicate modifier: '${D}'.`,EmptyHeritageClauseType:({token:D})=>`'${D}' list cannot be empty.`,EmptyNamespaceName:"Namespace must be given a name.",EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ExportAssignmentInTSNamespace:"An export assignment cannot be used in a namespace.",ExportInTSNamespace:"Export declarations are not permitted in a namespace.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportInTSNamespace:"Import declarations in a namespace cannot reference a module.",IncompatibleModifiers:({modifiers:D})=>`'${D[0]}' modifier cannot be used with '${D[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:D})=>`Index signatures cannot have an accessibility modifier ('${D}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InlineModuleDeclarationMustUseString:"`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",InvalidHeritageClauseType:({token:D})=>`'${D}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnAwaitUsingDeclaration:(D)=>`'${D}' modifier cannot appear on an await using declaration.`,InvalidModifierOnTypeMember:({modifier:D})=>`'${D}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:D})=>`'${D}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:D})=>`'${D}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifierOnUsingDeclaration:(D)=>`'${D}' modifier cannot appear on a using declaration.`,InvalidModifiersOrder:({orderedModifiers:D})=>`'${D[0]}' modifier must precede '${D[1]}' modifier.`,InvalidNamespaceName:(D)=>`Namespace name cannot be '${D}'.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NamespaceExportInTSNamespace:"Global module exports may only appear at top level.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifier:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:D})=>`Private elements cannot have an accessibility modifier ('${D}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccessorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccessorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:D})=>`Single type parameter ${D} should have a trailing comma. Example usage: <${D},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterInitializer:"A parameter initializer is only allowed in a function or constructor implementation.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnexpectedTypeDeclaration:(D)=>`'${D}' declarations can only be declared inside a block.`,UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:D})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${D}.`,UsingDeclarationInAmbientContext:(D)=>`'${D}' declarations are not allowed in ambient contexts.`},$D=z8`typescript`(xm);function bm(D){switch(D){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}function cN(D){return D==="private"||D==="public"||D==="protected"}function km(D){return D==="in"||D==="out"}function sG(D){if(D.extra?.parenthesized)return!1;switch(D.type){case"Identifier":return!0;case"MemberExpression":return!D.computed&&sG(D.object);case"TSInstantiationExpression":return sG(D.expression);default:return!1}}var gm=a1(["declare","private","public","protected","override","abstract","readonly","static"],["in","out"]),fm=a1(["readonly"],["declare","abstract","private","protected","public","static","override"]),ym=a1(["public","private","protected","override","readonly"]),hm=a1(["private","public","protected"]),mm=(D)=>class Z extends D{getScopeHandler(){return X_}tsIsIdentifier(){return iD(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(134)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){if(this.next(),this.hasPrecedingLineBreak())return!1;return this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){if(this.match(102))return this.next(),this.tsTokenCanFollowModifier();return this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier($,J,Q){if(!iD(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let X=this.state.value;if($.has(X)){if(Q&&this.match(102))return;if(J&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return X}return}tsParseModifiers($,J=$D.InvalidModifierOnTypeMember,Q,X=!1){let W=(Y,B,H,K)=>{if(B===H&&Q[K])this.raise($D.InvalidModifiersOrder,Y,{orderedModifiers:[H,K]})},G=(Y,B,H,K)=>{if(Q[H]&&B===K||Q[K]&&B===H)this.raise($D.IncompatibleModifiers,Y,{modifiers:[H,K]})};for(;;){let{startLoc:Y}=this.state,B=this.tsParseModifier($,X,Q.static);if(!B)break;if(cN(B))if(Q.accessibility)this.raise($D.DuplicateAccessibilityModifier,Y,{modifier:B});else W(Y,B,B,"override"),W(Y,B,B,"static"),W(Y,B,B,"readonly"),Q.accessibility=B;else if(km(B)){if(Q[B])this.raise($D.DuplicateModifier,Y,{modifier:B});Q[B]=!0,W(Y,B,"in","out")}else{if(Object.hasOwn(Q,B))this.raise($D.DuplicateModifier,Y,{modifier:B});else W(Y,B,"static","readonly"),W(Y,B,"static","override"),W(Y,B,"override","readonly"),W(Y,B,"abstract","override"),G(Y,B,"declare","override"),G(Y,B,"static","abstract");Q[B]=!0}if(!$.get(B))this.raise(J,Y,{modifier:B})}}tsIsListTerminator($){switch($){case"EnumMembers":case"TypeMembers":return this.match(4);case"HeritageClauseElement":return this.match(2);case"TupleElementTypes":return this.match(1);case"TypeParametersOrArguments":return this.match(44)}}tsParseList($,J){let Q=[];while(!this.tsIsListTerminator($))Q.push(J());return Q}tsParseDelimitedList($,J,Q){return wm(this.tsParseDelimitedListWorker($,J,!0,Q))}tsParseDelimitedListWorker($,J,Q,X){let W=[],G=-1;for(;;){if(this.tsIsListTerminator($))break;G=-1;let Y=J();if(Y==null)return;if(W.push(Y),this.eat(8)){G=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator($))break;if(Q)this.expect(8);return}if(X)X.value=G;return W}tsParseBracketedList($,J,Q,X,W){if(!X)if(Q)this.expect(0);else this.expect(43);let G=this.tsParseDelimitedList($,J,W);if(Q)this.expect(1);else this.expect(44);return G}tsParseImportType(){let $=this.startNode();if(this.expect(79),this.expect(6),!this.match(130))this.raise($D.UnsupportedImportTypeArgument,this.state.startLoc),$.source=this.tsParseNonConditionalType();else $.source=this.parseStringLiteral(this.state.value);if(this.eat(8))$.options=this.tsParseImportTypeOptions();else $.options=null;if(this.expect(7),this.eat(12))$.qualifier=this.tsParseEntityName(3);if(this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSImportType")}tsParseImportTypeOptions(){let $=this.startNode();this.expect(2);let J=this.startNode();if(this.isContextual(72))J.method=!1,J.key=this.parseIdentifier(!0),J.computed=!1,J.shorthand=!1;else this.unexpected(null,72);return this.expect(10),J.value=this.tsParseImportTypeWithPropertyValue(),$.properties=[this.finishObjectProperty(J)],this.eat(8),this.expect(4),this.finishNode($,"ObjectExpression")}tsParseImportTypeWithPropertyValue(){let $=this.startNode(),J=[];this.expect(2);while(!this.match(4)){let Q=this.state.type;if(iD(Q)||Q===130)J.push(super.parsePropertyDefinition(null));else this.unexpected();this.eat(8)}return $.properties=J,this.next(),this.finishNode($,"ObjectExpression")}tsParseEntityName($){let J;if($&1&&this.match(74))if($&2)J=this.parseIdentifier(!0);else{let Q=this.startNode();this.next(),J=this.finishNode(Q,"ThisExpression")}else J=this.parseIdentifier(!!($&1));while(this.eat(12)){let Q=this.startNodeAtNode(J);Q.left=J,Q.right=this.parseIdentifier(!!($&1)),J=this.finishNode(Q,"TSQualifiedName")}return J}tsParseTypeReference(){let $=this.startNode();if($.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSTypeReference")}tsParseThisTypePredicate($){this.next();let J=this.startNodeAtNode($);return J.parameterName=$,J.typeAnnotation=this.tsParseTypeAnnotation(!1),J.asserts=!1,this.finishNode(J,"TSTypePredicate")}tsParseThisTypeNode(){let $=this.startNode();return this.next(),this.finishNode($,"TSThisType")}tsParseTypeQuery(){let $=this.startNode();if(this.expect(83),this.match(79))$.exprName=this.tsParseImportType();else $.exprName=this.tsParseEntityName(1);if(!this.hasPrecedingLineBreak()&&this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSTypeQuery")}tsParseInOutModifiers=this.tsParseModifiers.bind(this,a1(["in","out"],["const","public","private","protected","readonly","declare","abstract","override"]),$D.InvalidModifierOnTypeParameter);tsParseConstModifier=this.tsParseModifiers.bind(this,a1(["const"],["in","out"]),$D.InvalidModifierOnTypeParameterPositions);tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,a1(["in","out","const"],["public","private","protected","readonly","declare","abstract","override"]),$D.InvalidModifierOnTypeParameter);tsParseTypeParameter($){let J=this.startNode();return $(J),J.name=this.tsParseTypeParameterName(),J.constraint=this.tsEatThenParseType(77),J.default=this.tsEatThenParseType(25),this.finishNode(J,"TSTypeParameter")}tsTryParseTypeParameters($){if(this.match(43))return this.tsParseTypeParameters($)}tsParseTypeParameters($){let J=this.startNode();if(this.match(43)||this.match(138))this.next();else this.unexpected();let Q={value:-1};if(J.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,$),!1,!0,Q),J.params.length===0)this.raise($D.EmptyTypeParameters,J);if(Q.value!==-1)this.addExtra(J,"trailingComma",Q.value);return this.finishNode(J,"TSTypeParameterDeclaration")}tsFillSignature($,J){let Q=$===15,X="params",W="returnType";if(J.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(6),J.params=this.tsParseBindingListForSignature(),Q)J.returnType=this.tsParseTypeOrTypePredicateAnnotation($);else if(this.match($))J.returnType=this.tsParseTypeOrTypePredicateAnnotation($)}tsParseBindingListForSignature(){let $=super.parseBindingList(7,41,2);for(let J of $){let{type:Q}=J;if(Q==="AssignmentPattern"||Q==="TSParameterProperty")this.raise($D.UnsupportedSignatureParameterKind,J,{type:Q})}return $}tsParseTypeMemberSemicolon(){if(!this.eat(8)&&!this.isLineTerminator())this.expect(9)}tsParseSignatureMember($,J){return this.tsFillSignature(10,J),this.tsParseTypeMemberSemicolon(),this.finishNode(J,$)}tsIsUnambiguouslyIndexSignature(){if(this.next(),iD(this.state.type))return this.next(),this.match(10);return!1}tsTryParseIndexSignature($){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);let J=this.parseIdentifier();J.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(J),this.expect(1),$.parameters=[J];let Q=this.tsTryParseTypeAnnotation();if(Q)$.typeAnnotation=Q;return this.tsParseTypeMemberSemicolon(),this.finishNode($,"TSIndexSignature")}tsParsePropertyOrMethodSignature($,J){if(this.eat(13))$.optional=!0;if(this.match(6)||this.match(43)){if(J)this.raise($D.ReadonlyForMethodSignature,$);let Q=$;if(Q.kind&&this.match(43))this.raise($D.AccessorCannotHaveTypeParameters,this.state.curPosition());if(this.tsFillSignature(10,Q),this.tsParseTypeMemberSemicolon(),Q.kind==="get"){if(Q.params.length>0){if(this.raise(m.BadGetterArity,this.state.curPosition()),this.isThisParam(Q.params[0]))this.raise($D.AccessorCannotDeclareThisParameter,this.state.curPosition())}}else if(Q.kind==="set"){if(Q.params.length!==1)this.raise(m.BadSetterArity,this.state.curPosition());else{let X=Q.params[0];if(this.isThisParam(X))this.raise($D.AccessorCannotDeclareThisParameter,this.state.curPosition());if(X.type==="Identifier"&&X.optional)this.raise($D.SetAccessorCannotHaveOptionalParameter,this.state.curPosition());if(X.type==="RestElement")this.raise($D.SetAccessorCannotHaveRestParameter,this.state.curPosition())}if(Q.returnType)this.raise($D.SetAccessorCannotHaveReturnType,Q.returnType)}else Q.kind="method";return this.finishNode(Q,"TSMethodSignature")}else{let Q=$;if(J)Q.readonly=!0;let X=this.tsTryParseTypeAnnotation();if(X)Q.typeAnnotation=X;return this.tsParseTypeMemberSemicolon(),this.finishNode(Q,"TSPropertySignature")}}tsParseTypeMember(){let $=this.startNode();if(this.match(6)||this.match(43))return this.tsParseSignatureMember("TSCallSignatureDeclaration",$);if(this.match(73)){let Q=this.startNode();if(this.next(),this.match(6)||this.match(43))return this.tsParseSignatureMember("TSConstructSignatureDeclaration",$);else return $.key=this.createIdentifier(Q,"new"),this.tsParsePropertyOrMethodSignature($,!1)}this.tsParseModifiers(fm,void 0,$);let J=this.tsTryParseIndexSignature($);if(J)return J;if(super.parsePropertyName($),!$.computed&&$.key.type==="Identifier"&&($.key.name==="get"||$.key.name==="set")&&this.tsTokenCanFollowModifier()){if($.kind=$.key.name,super.parsePropertyName($),!this.match(6)&&!this.match(43))this.unexpected(null,6)}return this.tsParsePropertyOrMethodSignature($,!!$.readonly)}tsParseTypeLiteral(){let $=this.startNode();return $.members=this.tsParseObjectTypeMembers(),this.finishNode($,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(2);let $=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(4),$}tsIsStartOfMappedType(){if(this.next(),this.eat(49))return this.isContextual(118);if(this.isContextual(118))this.next();if(!this.match(0))return!1;if(this.next(),!this.tsIsIdentifier())return!1;return this.next(),this.match(54)}tsParseMappedType(){let $=this.startNode();if(this.expect(2),this.match(49))$.readonly=this.state.value,this.next(),this.expectContextual(118);else if(this.eatContextual(118))$.readonly=!0;if(this.expect(0),$.key=this.tsParseTypeParameterName(),$.constraint=this.tsExpectThenParseType(54),$.nameType=this.eatContextual(89)?this.tsParseType():null,this.expect(1),this.match(49))$.optional=this.state.value,this.next(),this.expect(13);else if(this.eat(13))$.optional=!0;return $.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(4),this.finishNode($,"TSMappedType")}tsParseTupleType(){let $=this.startNode();$.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let J=!1;return $.elementTypes.forEach((Q)=>{let{type:X}=Q;if(J&&X!=="TSRestType"&&X!=="TSOptionalType"&&!(X==="TSNamedTupleMember"&&Q.optional))this.raise($D.OptionalTypeBeforeRequired,Q);J||=X==="TSNamedTupleMember"&&Q.optional||X==="TSOptionalType"}),this.finishNode($,"TSTupleType")}tsParseTupleElementType(){let $=this.state.startLoc,J=this.eat(17),{startLoc:Q}=this.state,X,W,G,Y,H=A0(this.state.type)?this.lookaheadCharCode():null;if(H===58)X=!0,G=!1,W=this.parseIdentifier(!0),this.expect(10),Y=this.tsParseType();else if(H===63){G=!0;let K=this.state.value,z=this.tsParseNonArrayType();if(this.lookaheadCharCode()===58)X=!0,W=this.createIdentifier(this.startNodeAt(Q),K),this.expect(13),this.expect(10),Y=this.tsParseType();else X=!1,Y=z,this.expect(13)}else Y=this.tsParseType(),G=this.eat(13),X=this.eat(10);if(X){let K;if(W){if(K=this.startNodeAt(Q),K.optional=G,K.label=W,K.elementType=Y,this.eat(13))K.optional=!0,this.raise($D.TupleOptionalAfterType,this.state.lastTokStartLoc)}else K=this.startNodeAt(Q),K.optional=G,this.raise($D.InvalidTupleMemberLabel,Y),K.label=Y,K.elementType=this.tsParseType();Y=this.finishNode(K,"TSNamedTupleMember")}else if(G){let K=this.startNodeAt(Q);K.typeAnnotation=Y,Y=this.finishNode(K,"TSOptionalType")}if(J){let K=this.startNodeAt($);K.typeAnnotation=Y,Y=this.finishNode(K,"TSRestType")}return Y}tsParseParenthesizedType(){let $=this.startNode();return this.expect(6),$.typeAnnotation=this.tsParseType(),this.expect(7),this.finishNode($,"TSParenthesizedType")}tsParseFunctionOrConstructorType($,J){let Q=this.startNode();if($==="TSConstructorType"){if(Q.abstract=!!J,J)this.next();this.next()}return this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(15,Q)),this.finishNode(Q,$)}tsParseLiteralTypeNode(){let $=this.startNode();switch(this.state.type){case 131:case 132:case 130:case 81:case 82:$.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode($,"TSLiteralType")}tsParseTemplateLiteralType(){let $=this.state.startLoc,J=this.parseTemplateElement(!1),Q=[J];if(J.tail){let X=this.startNodeAt($),W=this.startNodeAt($);return W.expressions=[],W.quasis=Q,X.literal=this.finishNode(W,"TemplateLiteral"),this.finishNode(X,"TSLiteralType")}else{let X=[];while(!J.tail)X.push(this.tsParseType()),this.readTemplateContinuation(),Q.push(J=this.parseTemplateElement(!1));let W=this.startNodeAt($);return W.types=X,W.quasis=Q,this.finishNode(W,"TSTemplateLiteralType")}}parseTemplateSubstitution(){if(this.state.inType)return this.tsParseType();return super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){let $=this.tsParseThisTypeNode();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.tsParseThisTypePredicate($);else return $}tsParseNonArrayType(){switch(this.state.type){case 130:case 131:case 132:case 81:case 82:return this.tsParseLiteralTypeNode();case 49:if(this.state.value==="-"){let $=this.startNode(),J=this.lookahead();if(J.type!==131&&J.type!==132)this.unexpected();return $.literal=this.parseMaybeUnary(),this.finishNode($,"TSLiteralType")}break;case 74:return this.tsParseThisTypeOrThisTypePredicate();case 83:return this.tsParseTypeQuery();case 79:return this.tsParseImportType();case 2:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 6:if(!(this.optionFlags&2048)){let $=this.state.startLoc;this.next();let J=this.tsParseType();return this.expect(7),this.addExtra(J,"parenthesized",!0),this.addExtra(J,"parenStart",$.index),J}return this.tsParseParenthesizedType();case 21:case 20:return this.tsParseTemplateLiteralType();default:{let{type:$}=this.state;if(iD($)||$===84||$===80){let J=$===84?"TSVoidKeyword":$===80?"TSNullKeyword":bm(this.state.value);if(J!==void 0&&this.lookaheadCharCode()!==46){let Q=this.startNode();return this.next(),this.finishNode(Q,J)}return this.tsParseTypeReference()}}}throw this.unexpected()}tsParseArrayTypeOrHigher(){let{startLoc:$}=this.state,J=this.tsParseNonArrayType();while(!this.hasPrecedingLineBreak()&&this.eat(0))if(this.match(1)){let Q=this.startNodeAt($);Q.elementType=J,this.expect(1),J=this.finishNode(Q,"TSArrayType")}else{let Q=this.startNodeAt($);Q.objectType=J,Q.indexType=this.tsParseType(),this.expect(1),J=this.finishNode(Q,"TSIndexedAccessType")}return J}tsParseTypeOperator(){let $=this.startNode(),J=this.state.value;if(this.next(),$.operator=J,$.typeAnnotation=this.tsParseTypeOperatorOrHigher(),J==="readonly")this.tsCheckTypeAnnotationForReadOnly($);return this.finishNode($,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly($){switch($.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise($D.UnexpectedReadonly,$)}}tsParseInferType(){let $=this.startNode();this.expectContextual(111);let J=this.startNode();return J.name=this.tsParseTypeParameterName(),J.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),$.typeParameter=this.finishNode(J,"TSTypeParameter"),this.finishNode($,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(77)){let $=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(13))return $}}tsParseTypeOperatorOrHigher(){return eh(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(111)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType($,J,Q){let X=this.startNode(),W=this.eat(Q),G=[];do G.push(J());while(this.eat(Q));if(G.length===1&&!W)return G[0];return X.types=G,this.finishNode(X,$)}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),41)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),39)}tsIsStartOfFunctionType(){if(this.match(43))return!0;return this.match(6)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(iD(this.state.type)||this.match(74))return this.next(),!0;if(this.match(2)){let{errors:$}=this.state,J=$.length;try{return this.parseObjectLike(4,!0),$.length===J}catch{return!1}}if(this.match(0)){this.next();let{errors:$}=this.state,J=$.length;try{return super.parseBindingList(1,93,1),$.length===J}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){if(this.next(),this.match(7)||this.match(17))return!0;if(this.tsSkipParameterStart()){if(this.match(10)||this.match(8)||this.match(13)||this.match(25))return!0;if(this.match(7)){if(this.next(),this.match(15))return!0}}return!1}tsParseTypeOrTypePredicateAnnotation($){return this.tsInType(()=>{let J=this.startNode();this.expect($);let Q=this.startNode(),X=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(X&&this.match(74)){let Y=this.tsParseThisTypeOrThisTypePredicate();if(Y.type==="TSThisType")Q.parameterName=Y,Q.asserts=!0,Q.typeAnnotation=null,Y=this.finishNode(Q,"TSTypePredicate");else this.resetStartLocationFromNode(Y,Q),Y.asserts=!0;return J.typeAnnotation=Y,this.finishNode(J,"TSTypeAnnotation")}let W=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!W){if(!X)return this.tsParseTypeAnnotation(!1,J);return Q.parameterName=this.parseIdentifier(),Q.asserts=X,Q.typeAnnotation=null,J.typeAnnotation=this.finishNode(Q,"TSTypePredicate"),this.finishNode(J,"TSTypeAnnotation")}let G=this.tsParseTypeAnnotation(!1);return Q.parameterName=W,Q.typeAnnotation=G,Q.asserts=X,J.typeAnnotation=this.finishNode(Q,"TSTypePredicate"),this.finishNode(J,"TSTypeAnnotation")})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(10))return this.tsParseTypeOrTypePredicateAnnotation(10)}tsTryParseTypeAnnotation(){if(this.match(10))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(10)}tsParseTypePredicatePrefix(){let $=this.parseIdentifier();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.next(),$}tsParseTypePredicateAsserts(){if(this.state.type!==105)return!1;let $=this.state.containsEsc;if(this.next(),!iD(this.state.type)&&!this.match(74))return!1;if($)this.raise(m.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"});return!0}tsParseTypeAnnotation($=!0,J=this.startNode()){return this.tsInType(()=>{if($)this.expect(10);J.typeAnnotation=this.tsParseType()}),this.finishNode(J,"TSTypeAnnotation")}tsParseType(){pN(this.state.inType);let $=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(77))return $;let J=this.startNodeAtNode($);return J.checkType=$,J.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(13),J.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(10),J.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(J,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(120)&&this.isLookaheadContextual("new")}tsParseNonConditionalType(){if(this.tsIsStartOfFunctionType())return this.tsParseFunctionOrConstructorType("TSFunctionType");if(this.match(73))return this.tsParseFunctionOrConstructorType("TSConstructorType");else if(this.isAbstractConstructorSignature())return this.tsParseFunctionOrConstructorType("TSConstructorType",!0);return this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){if(this.getPluginOption("typescript","disallowAmbiguousJSXLike"))this.raise($D.ReservedTypeAssertion,this.state.startLoc);let $=this.startNode();return $.typeAnnotation=this.tsInType(()=>{return this.next(),this.match(71)?this.tsParseTypeReference():this.tsParseType()}),this.expect(44),$.expression=this.parseMaybeUnary(),this.finishNode($,"TSTypeAssertion")}tsParseHeritageClause($){let J=this.state.startLoc,Q=this.tsParseDelimitedList("HeritageClauseElement",()=>{let X=(this.state.canStartArrow=!1,super.parseExprSubscripts());if(!sG(X))this.raise($D.InvalidHeritageClauseType,X.start,{token:$});let W=$==="extends"?"TSInterfaceHeritage":"TSClassImplements";if(X.type==="TSInstantiationExpression")return X.type=W,X;let G=this.startNodeAtNode(X);if(G.expression=X,this.match(43)||this.match(47))G.typeArguments=this.tsParseTypeArgumentsInExpression();return this.finishNode(G,W)});if(!Q.length)this.raise($D.EmptyHeritageClauseType,J,{token:$});return Q}tsParseInterfaceDeclaration($,J={}){if(this.hasFollowingLineBreak())return null;if(this.expectContextual(125),J.declare)$.declare=!0;if(iD(this.state.type))$.id=this.parseIdentifier(),this.checkIdentifier($.id,130);else $.id=null,this.raise($D.MissingInterfaceName,this.state.startLoc);if($.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(77))$.extends=this.tsParseHeritageClause("extends");let Q=this.startNode();return Q.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),$.body=this.finishNode(Q,"TSInterfaceBody"),this.finishNode($,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration($){return $.id=this.parseIdentifier(),this.checkIdentifier($.id,2),$.typeAnnotation=this.tsInType(()=>{if($.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(25),this.isContextual(110)&&this.lookaheadCharCode()!==46){let J=this.startNode();return this.next(),this.finishNode(J,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode($,"TSTypeAliasDeclaration")}tsInTopLevelContext($){if(this.curContext()!==Y2.brace){let J=this.state.context;this.state.context=[J[0]];try{return $()}finally{this.state.context=J}}else return $()}tsInType($){let J=this.state.inType;this.state.inType=!0;try{return $()}finally{this.state.inType=J}}tsInDisallowConditionalTypesContext($){let J=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return $()}finally{this.state.inDisallowConditionalTypesContext=J}}tsInAllowConditionalTypesContext($){let J=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return $()}finally{this.state.inDisallowConditionalTypesContext=J}}tsEatThenParseType($){if(this.match($))return this.tsNextThenParseType()}tsExpectThenParseType($){return this.tsInType(()=>{return this.expect($),this.tsParseType()})}tsNextThenParseType(){return this.tsInType(()=>{return this.next(),this.tsParseType()})}tsParseEnumMember(){let $=this.startNode();if($.id=this.match(130)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(25))$.initializer=super.parseMaybeAssignAllowIn();return this.finishNode($,"TSEnumMember")}tsParseEnumDeclaration($,J={}){if(J.const)$.const=!0;if(J.declare)$.declare=!0;return this.expectContextual(122),$.id=this.parseIdentifier(),this.checkIdentifier($.id,$.const?8971:8459),$.body=this.tsParseEnumBody(),this.finishNode($,"TSEnumDeclaration")}tsParseEnumBody(){let $=this.startNode();return this.expect(2),$.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(4),this.finishNode($,"TSEnumBody")}tsParseModuleBlock($){let J=this.startNode();if(!$)this.scope.enter(0);if(this.expect(2),super.parseBlockOrModuleBlockBody(J.body=[],void 0,!0,4),!$)this.scope.exit();return this.finishNode(J,"TSModuleBlock")}tsParseNamespaceDeclaration($){if($.id=this.tsParseEntityName(0),$.id.type==="Identifier")this.checkIdentifier($.id,1024);return this.scope.enter(2048),this.prodParam.enter(0),$.body=this.tsParseModuleBlock(!1),this.prodParam.exit(),this.scope.exit(),this.finishNode($,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration($){let J=this.isContextual(108);if(J)$.kind="global",$.id=this.parseIdentifier();else{$.kind="module";let{type:Q,value:X}=this.state;if(Q===130)$.id=super.parseStringLiteral(X);else if(iD(Q))this.raise($D.InlineModuleDeclarationMustUseString,this.state.startLoc),$.id=this.tsParseEntityName(0);else if(Q===2)this.raise($D.EmptyNamespaceName,this.state.startLoc);else this.raise($D.InvalidNamespaceName,this.state.startLoc,X),$.id=super.parseExprAtom()}if(this.match(2)){if(!J)this.scope.enter(1024);if(this.prodParam.enter(0),$.body=this.tsParseModuleBlock(J),this.prodParam.exit(),!J)this.scope.exit()}else this.semicolon();return this.finishNode($,"TSModuleDeclaration")}tsParseImportEqualsDeclaration($,J){$.id=J||this.parseIdentifier(),this.checkIdentifier($.id,4096),this.expect(25);let Q=this.tsParseModuleReference();if($.importKind==="type"&&Q.type!=="TSExternalModuleReference")this.raise($D.ImportAliasHasImportType,Q);return $.moduleReference=Q,this.semicolon(),this.finishNode($,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(115)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){let $=this.startNode();if(this.expectContextual(115),this.expect(6),!this.match(130))this.unexpected();return $.expression=super.parseExprAtom(),this.expect(7),this.sawUnambiguousESM=!0,this.finishNode($,"TSExternalModuleReference")}tsLookAhead($){let J=this.state.clone(),Q=$();return this.state=J,Q}tsTryParseAndCatch($){let J=this.tryParse((Q)=>$()||Q());if(J.aborted||!J.node)return;if(J.error)this.state=J.failState;return J.node}tsTryParse($){let J=this.state.clone(),Q=$();if(Q!==void 0&&Q!==!1)return Q;this.state=J}tsTryParseDeclare($){if(this.isLineTerminator())return;let J=this.state.type;return this.tsInAmbientContext(()=>{switch(J){case 64:return $.declare=!0,super.parseFunctionStatement($,!1,!1);case 76:return $.declare=!0,this.parseClass($,!0,!1);case 122:return this.tsParseEnumDeclaration($,{declare:!0});case 108:return this.tsParseAmbientExternalModuleDeclaration($);case 96:if(this.state.containsEsc)return;case 71:case 70:if(!this.match(71)||!this.isLookaheadContextual("enum"))return $.declare=!0,this.parseVarStatement($,this.state.value,!0);return this.expect(71),this.tsParseEnumDeclaration($,{const:!0,declare:!0});case 103:if(this.isUsing())return this.raise($D.InvalidModifierOnUsingDeclaration,this.state.startLoc,"declare"),$.declare=!0,this.parseVarStatement($,"using",!0);break;case 92:if(this.isAwaitUsing())return this.raise($D.InvalidModifierOnAwaitUsingDeclaration,this.state.startLoc,"declare"),$.declare=!0,this.next(),this.parseVarStatement($,"await using",!0);break;case 125:{let Q=this.tsParseInterfaceDeclaration($,{declare:!0});if(Q)return Q}default:if(iD(J))return this.tsParseDeclaration($,this.state.type,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.type,!0,null)}tsParseDeclaration($,J,Q,X){switch(J){case 120:if(this.tsCheckLineTerminator(Q)&&(this.match(76)||iD(this.state.type)))return this.tsParseAbstractDeclaration($,X);break;case 123:if(this.tsCheckLineTerminator(Q))return this.tsParseAmbientExternalModuleDeclaration($);break;case 124:if(this.tsCheckLineTerminator(Q)&&iD(this.state.type))return $.kind="namespace",this.tsParseNamespaceDeclaration($);break;case 126:if(this.tsCheckLineTerminator(Q)&&iD(this.state.type))return this.tsParseTypeAliasDeclaration($);break}}tsCheckLineTerminator($){if($){if(this.hasFollowingLineBreak())return!1;return this.next(),!0}return!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction($){if(!this.match(43))return;let J=this.tsTryParseAndCatch(()=>{let Q=this.startNodeAt($);return Q.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(Q),Q.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(15),Q});if(!J)return;return super.parseArrowExpression(J,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()!==43)return;return this.tsParseTypeArguments()}tsParseTypeArguments(){let $=this.startNode();if($.params=this.tsInType(()=>this.tsInTopLevelContext(()=>{return this.expect(43),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))})),$.params.length===0)this.raise($D.EmptyTypeArguments,$);else if(!this.state.inType&&this.curContext()===Y2.brace)this.reScan_lt_gt();return this.expect(44),this.finishNode($,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return Dm(this.state.type)}isExportDefaultSpecifier(){if(this.tsIsDeclarationStart())return!1;return super.isExportDefaultSpecifier()}parseBindingElement($,J){let Q=J.length?null:this.state.startLoc,X={};this.tsParseModifiers(ym,void 0,X);let{accessibility:W,override:G,readonly:Y}=X;if(!($&4)&&(W||Y||G))this.raise($D.UnexpectedParameterModifier,Q||J[0]);let B=this.state.startLoc,H=this.parseMaybeDefault(B);if($&2)this.parseFunctionParamType(H);let K=this.parseMaybeDefault(B,H);if(W||Y||G){let z=Q?this.startNodeAt(Q):this.startNodeAtNode(J[0]);if(J.length)z.decorators=J;else this.setLoc(Q);if(W)z.accessibility=W;if(Y)z.readonly=Y;if(G)z.override=G;if(K.type!=="Identifier"&&K.type!=="AssignmentPattern")this.raise($D.UnsupportedParameterPropertyKind,Q||J[0]);return z.parameter=K,this.finishNode(z,"TSParameterProperty")}if(J.length)H.decorators=J;return K}isSimpleParameter($){return $.type==="TSParameterProperty"&&super.isSimpleParameter($.parameter)||super.isSimpleParameter($)}tsDisallowOptionalPattern($){for(let J of $.params)if(J.type!=="Identifier"&&J.optional&&!this.state.isAmbientContext)this.raise($D.PatternIsOptional,J)}setArrowFunctionParameters($,J,Q){super.setArrowFunctionParameters($,J,Q),this.tsDisallowOptionalPattern($)}parseFunctionBodyAndFinish($,J,Q=!1){if(this.match(10))$.returnType=this.tsParseTypeOrTypePredicateAnnotation(10);let X=J==="FunctionDeclaration"?"TSDeclareFunction":J==="ClassMethod"||J==="ClassPrivateMethod"?"TSDeclareMethod":void 0;if(X&&!this.match(2)&&this.isLineTerminator()){if(X==="TSDeclareMethod"&&$.kind==="constructor"){for(let W of $.params)if(W.type==="TSParameterProperty")this.raise($D.UnexpectedParameterModifier,W);else if(W.type==="AssignmentPattern")this.raise($D.UnexpectedParameterInitializer,W)}else for(let W of $.params)if(W.type==="AssignmentPattern")this.raise($D.UnexpectedParameterInitializer,W);return this.finishNode($,X)}if(X&&this.state.isAmbientContext){if(this.raise($D.DeclareFunctionHasImplementation,this.state.startLoc),X==="TSDeclareFunction"&&$.declare)return super.parseFunctionBodyAndFinish($,X,Q)}return this.tsDisallowOptionalPattern($),super.parseFunctionBodyAndFinish($,J,Q)}registerFunctionStatementId($){if(!$.body&&$.id)this.checkIdentifier($.id,1024);else super.registerFunctionStatementId($)}tsCheckForInvalidTypeCasts($){$.forEach((J)=>{if(J?.type==="TSTypeCastExpression")this.raise($D.UnexpectedTypeAnnotation,J.typeAnnotation)})}toReferencedList($,J){return this.tsCheckForInvalidTypeCasts($),$}parseArrayLike($,J){let Q=super.parseArrayLike($,J);if(Q.type==="ArrayExpression")this.tsCheckForInvalidTypeCasts(Q.elements);return Q}parseSubscript($,J,Q,X){if(!this.hasPrecedingLineBreak()&&this.match(31)){this.state.canStartJSXElement=!1,this.next();let G=this.startNodeAt(J);return G.expression=$,this.finishNode(G,"TSNonNullExpression")}let W=!1;if(this.match(14)&&this.lookaheadCharCode()===60){if(Q)return X.stop=!0,$;X.optionalChainMember=W=!0,this.next()}if(this.match(43)||this.match(47)){let G,Y=this.tsTryParseAndCatch(()=>{if(!Q&&this.atPossibleAsyncArrow($)){let z=this.tsTryParseGenericAsyncArrowFunction(J);if(z)return X.stop=!0,z}let B=this.tsParseTypeArgumentsInExpression();if(!B)return;if(W&&!this.match(6)){G=this.state.curPosition();return}if(uG(this.state.type)){let z=super.parseTaggedTemplateExpression($,J,X);return z.typeArguments=B,z}if(!Q&&this.eat(6)){let z=this.startNodeAt(J);if(z.callee=$,z.arguments=this.parseCallExpressionArguments(),this.tsCheckForInvalidTypeCasts(z.arguments),z.typeArguments=B,X.optionalChainMember)z.optional=W;return this.finishCallExpression(z,X.optionalChainMember)}let H=this.state.type;if(H===44||H===48||H!==6&&H!==89&&H!==116&&w4(H)&&!this.hasPrecedingLineBreak())return;let K=this.startNodeAt(J);return K.expression=$,K.typeArguments=B,this.finishNode(K,"TSInstantiationExpression")});if(G)this.unexpected(G,6);if(Y){if(Y.type==="TSInstantiationExpression"){if(this.match(12)||this.match(14)&&this.lookaheadCharCode()!==40)this.raise($D.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc);if(!this.match(12)&&!this.match(14))Y.expression=super.stopParseSubscript($,X)}return Y}}return super.parseSubscript($,J,Q,X)}parseNewCallee($){super.parseNewCallee($);let{callee:J}=$;if(J.type==="TSInstantiationExpression"&&!J.extra?.parenthesized)$.typeArguments=J.typeArguments,$.callee=J.expression}parseExprOp($,J,Q){let X;if(uZ(54)>Q&&!this.hasPrecedingLineBreak()&&(this.isContextual(89)||(X=this.isContextual(116)))){let W=this.startNodeAt(J);W.expression=$,W.typeAnnotation=this.tsInType(()=>{if(this.next(),this.match(71)){if(X)this.raise(m.UnexpectedKeyword,this.state.startLoc,{keyword:"const"});return this.tsParseTypeReference()}return this.tsParseType()});let G=this.finishNode(W,X?"TSSatisfiesExpression":"TSAsExpression");return this.reScan_lt_gt(),this.parseExprOp(G,J,Q)}return super.parseExprOp($,J,Q)}checkReservedWord($,J,Q,X){if(!this.state.isAmbientContext)super.checkReservedWord($,J,Q,X)}checkDuplicateExports(){}isPotentialImportPhase($){if(super.isPotentialImportPhase($))return!0;if(this.isContextual(126)){let J=this.lookaheadCharCode();return $?J===123||J===42:J!==61}return!$&&this.isContextual(83)}applyImportPhase($,J,Q,X){if(super.applyImportPhase($,J,Q,X),J)$.exportKind=Q==="type"?"type":"value";else $.importKind=Q==="type"||Q==="typeof"?Q:"value"}parseImport($){if(this.match(130)){if($.importKind="value",this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,$);return super.parseImport($)}let J;if(iD(this.state.type)&&this.lookaheadCharCode()===61){$.importKind="value";let Q=this.tsParseImportEqualsDeclaration($);if(this.scope.inTSNamespace&&Q.moduleReference.type==="TSExternalModuleReference")this.raise($D.ImportInTSNamespace,$);return Q}else if(this.isContextual(126)){let Q=this.parseMaybeImportPhase($,!1);if(this.lookaheadCharCode()===61){if(this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,$);return this.tsParseImportEqualsDeclaration($,Q)}else J=super.parseImportSpecifiersAndAfter($,Q)}else J=super.parseImport($);if(J.importKind==="type"&&J.specifiers.length>1&&J.specifiers[0].type==="ImportDefaultSpecifier")this.raise($D.TypeImportCannotSpecifyDefaultAndNamed,J);else if(this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,J);return J}parseExport($,J){if(this.match(79)){let Q=this.startNode();this.next();let X=null;if(this.isContextual(126)&&this.isPotentialImportPhase(!1))X=this.parseMaybeImportPhase(Q,!1);else Q.importKind="value";let W=this.tsParseImportEqualsDeclaration(Q,X);return $.attributes=[],$.declaration=W,$.exportKind="value",$.source=null,$.specifiers=[],this.finishNode($,"ExportNamedDeclaration")}else if(this.eat(25)){let Q=$;if(Q.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.scope.inTSNamespace)this.raise($D.ExportAssignmentInTSNamespace,Q);return this.finishNode(Q,"TSExportAssignment")}else if(this.eatContextual(89)){let Q=$;if(this.expectContextual(124),Q.id=this.parseIdentifier(),this.checkIdentifier(Q.id,8201),this.semicolon(),this.scope.inTSNamespace)this.raise($D.NamespaceExportInTSNamespace,Q);return this.finishNode(Q,"TSNamespaceExportDeclaration")}else{let Q=super.parseExport($,J);if(this.scope.inTSNamespace&&(Q.type!=="ExportNamedDeclaration"||Q.source||!Q.declaration&&!this.state.isAmbientContext))this.raise($D.ExportInTSNamespace,Q);return Q}}isAbstractClass(){return this.isContextual(120)&&this.isLookaheadContextual("class")}parseExportDefaultExpression(){if(this.isAbstractClass()){let $=this.startNode();return this.next(),$.abstract=!0,this.parseClass($,!0,!0)}if(this.match(125)){let $=this.tsParseInterfaceDeclaration(this.startNode());if($)return $}return super.parseExportDefaultExpression()}parseVarStatement($,J,Q=!1){let{isAmbientContext:X}=this.state,W=super.parseVarStatement($,J,Q||X);if(X&&!$.declare&&(J==="using"||J==="await using"))return this.raiseOverwrite($D.UsingDeclarationInAmbientContext,$,J),W;for(let G of W.declarations){let{id:Y,init:B,definite:H}=G;if(H){if(B)this.raise($D.DeclaratorDefiniteAssertionWithInitializer,Y);else if(!Y.typeAnnotation)this.raise($D.DeclaratorDefiniteAssertionRequiresTypeAnnotation,Y)}if(X&&B){if(J==="var"||J==="let"||!!Y.typeAnnotation)this.raise($D.InitializerNotAllowedInAmbientContext,B);else if(!um(B,this.hasPlugin("estree")))this.raise($D.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,B)}}return W}parseStatementContent($,J){let Q=!!($&2);if(!this.state.containsEsc)switch(this.state.type){case 71:{if(this.isLookaheadContextual("enum")){let X=this.startNode();return this.next(),this.tsParseEnumDeclaration(X,{const:!0})}break}case 120:case 121:{if(this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()){let X=this.state.type,W=this.startNode();this.next();let G=X===121?this.tsTryParseDeclare(W):this.tsParseAbstractDeclaration(W,J);if(G){if(X===121)G.declare=!0;return G}else return W.expression=this.createIdentifier(this.startNodeAtNode(W),X===121?"declare":"abstract"),this.semicolon(!1),this.finishNode(W,"ExpressionStatement")}break}case 122:return this.tsParseEnumDeclaration(this.startNode());case 108:{if(this.lookaheadCharCode()===123){let W=this.startNode();return this.tsParseAmbientExternalModuleDeclaration(W)}break}case 125:{let X=this.tsParseInterfaceDeclaration(this.startNode());if(X){if(!Q)this.raise($D.UnexpectedTypeDeclaration,X,"interface");return X}break}case 123:{if(this.nextTokenIsStringLiteralOnSameLine()){let X=this.startNode();return this.next(),this.tsParseDeclaration(X,123,!1,J)}else if(this.nextTokenIsIdentifierOnSameLine()){this.raise($D.InlineModuleDeclarationMustUseString,this.state.startLoc);let X=this.startNode();return this.next(),this.tsParseDeclaration(X,124,!1,J)}break}case 124:{if(this.nextTokenIsIdentifierOnSameLine()){let X=this.startNode();return this.next(),this.tsParseDeclaration(X,124,!1,J)}break}case 126:{if(this.nextTokenIsIdentifierOnSameLine()){let X=this.startNode();if(!Q)this.raise($D.UnexpectedTypeDeclaration,X,"type");return this.next(),this.tsParseTypeAliasDeclaration(X)}break}}return super.parseStatementContent($,J)}parseAccessModifier(){return this.tsParseModifier(hm)}tsHasSomeModifiers($,J){return J.some((Q)=>{if(cN(Q))return $.accessibility===Q;return!!$[Q]})}tsIsStartOfStaticBlocks(){return this.isContextual(102)&&this.lookaheadCharCode()===123}parseClassMember($,J,Q){this.tsParseModifiers(gm,$D.InvalidModifierOnTypeParameterPositions,J,!0);let X=()=>{if(this.tsIsStartOfStaticBlocks()){if(this.next(),this.next(),this.tsHasSomeModifiers(J,["declare","private","public","protected","override","abstract","readonly","static"]))this.raise($D.StaticBlockCannotHaveModifier,this.state.curPosition());super.parseClassStaticBlock($,J)}else this.parseClassMemberWithIsStatic($,J,Q,!!J.static)};if(J.declare)this.tsInAmbientContext(X);else X();if(J.decorators&&J.decorators.length>0&&!this.hasPlugin("decorators-legacy")){if(J.type==="TSAbstractMethodDefinition"||J.type==="TSDeclareMethod")this.raise($D.DecoratorAbstractMethod,J,{kind:"abstract method"});else if(J.type==="ClassProperty"&&J.abstract||J.type==="ClassProperty"&&J.declare||J.type==="TSAbstractPropertyDefinition"||J.type==="PropertyDefinition"&&J.declare)this.raise($D.DecoratorAbstractMethod,J,{kind:J.declare?"declare field":"abstract field"})}}parseClassMemberWithIsStatic($,J,Q,X){let W=this.tsTryParseIndexSignature(J);if(W){if($.body.push(W),J.abstract)this.raise($D.IndexSignatureHasAbstract,J);if(J.accessibility)this.raise($D.IndexSignatureHasAccessibility,J,{modifier:J.accessibility});if(J.declare)this.raise($D.IndexSignatureHasDeclare,J);if(J.override)this.raise($D.IndexSignatureHasOverride,J);return}if(!this.state.inAbstractClass&&J.abstract)this.raise($D.NonAbstractClassHasAbstractMethod,J);if(J.override){if(!Q.hadSuperClass)this.raise($D.OverrideNotInSubClass,J)}super.parseClassMemberWithIsStatic($,J,Q,X)}parsePostMemberNameModifiers($){if(this.eat(13))$.optional=!0;if($.readonly&&this.match(6))this.raise($D.ClassMethodHasReadonly,$);if($.declare&&this.match(6))this.raise($D.ClassMethodHasDeclare,$)}shouldParseExportDeclaration(){if(this.tsIsDeclarationStart())return!0;return super.shouldParseExportDeclaration()}parseConditional($,J,Q){if(!this.match(13))return $;if(Q!=null){let G=this.lookaheadCharCode();if(G===44||G===61||G===58||G===41)return this.setOptionalParametersError(Q),$}this.next();let X=this.startNodeAt(J);X.test=$;let W=this.state.inConditionalConsequent;return this.state.inConditionalConsequent=!0,X.consequent=this.parseMaybeAssignAllowIn(),this.state.inConditionalConsequent=W,this.expect(10),X.alternate=this.parseMaybeAssign(),this.finishNode(X,"ConditionalExpression")}parseParenItem($,J){let Q=super.parseParenItem($,J);if(this.eat(13))Q.optional=!0,this.resetEndLocation($);if(this.match(10)){let X=this.startNodeAt(J);return X.expression=$,X.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(X,"TSTypeCastExpression")}return $}parseExportDeclaration($){if(!this.state.isAmbientContext&&this.isContextual(121))return this.tsInAmbientContext(()=>this.parseExportDeclaration($));let J=this.state.startLoc,Q=this.eatContextual(121);if(Q&&(this.isContextual(121)||!this.shouldParseExportDeclaration()))throw this.raise($D.ExpectedAmbientAfterExportDeclare,this.state.startLoc);let W=iD(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration($);if(!W)return null;if(W.type==="TSInterfaceDeclaration"||W.type==="TSTypeAliasDeclaration"||Q)$.exportKind="type";if(Q&&W.type!=="TSImportEqualsDeclaration")this.resetStartLocation(W,J),W.declare=!0;return W}parseClassId($,J,Q,X){if((!J||Q)&&this.isContextual(109)){$.id=null;return}super.parseClassId($,J,Q,$.declare?1024:8331);let W=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);if(W)$.typeParameters=W}parseClassPropertyAnnotation($){if(!$.optional){if(this.eat(31))$.definite=!0;else if(this.eat(13))$.optional=!0}let J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J;if($.definite){if(this.match(25))this.raise($D.DeclaratorDefiniteAssertionWithInitializer,$);else if(!J)this.raise($D.DeclaratorDefiniteAssertionRequiresTypeAnnotation,$)}}parseClassProperty($){if(this.parseClassPropertyAnnotation($),this.state.isAmbientContext&&!($.readonly&&!$.typeAnnotation)&&this.match(25))this.raise($D.DeclareClassFieldHasInitializer,this.state.startLoc);if($.abstract&&this.match(25)){let{key:J}=$;this.raise($D.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:J.type==="Identifier"&&!$.computed?J.name:`[${this.input.slice(this.offsetToSourcePos(J.start),this.offsetToSourcePos(J.end))}]`})}return super.parseClassProperty($)}parseClassPrivateProperty($){if($.abstract)this.raise($D.PrivateElementHasAbstract,$);if($.accessibility)this.raise($D.PrivateElementHasAccessibility,$,{modifier:$.accessibility});return this.parseClassPropertyAnnotation($),super.parseClassPrivateProperty($)}parseClassAccessorProperty($){if(this.parseClassPropertyAnnotation($),$.optional)this.raise($D.AccessorCannotBeOptional,$);return super.parseClassAccessorProperty($)}pushClassMethod($,J,Q,X,W,G){let Y=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(Y&&W)this.raise($D.ConstructorHasTypeParameters,Y);let{declare:B=!1,kind:H}=J;if(B&&(H==="get"||H==="set"))this.raise($D.DeclareAccessor,J,{kind:H});if(Y)J.typeParameters=Y;super.pushClassMethod($,J,Q,X,W,G)}pushClassPrivateMethod($,J,Q,X){let W=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(W)J.typeParameters=W;super.pushClassPrivateMethod($,J,Q,X)}declareClassPrivateMethodInScope($,J){if($.type==="TSDeclareMethod")return;if($.type==="MethodDefinition"&&$.value.body==null)return;super.declareClassPrivateMethodInScope($,J)}parseClassSuper($){if(super.parseClassSuper($),$.superClass){if($.superClass.type==="TSInstantiationExpression"){let J=$.superClass,Q=J.expression;this.takeSurroundingComments(Q,Q.start,Q.end);let X=J.typeArguments;this.takeSurroundingComments(X,X.start,X.end),$.superClass=Q,$.superTypeArguments=X}else if(this.match(43)||this.match(47))$.superTypeArguments=this.tsParseTypeArgumentsInExpression()}if(this.eatContextual(109))$.implements=this.tsParseHeritageClause("implements")}parseObjPropValue($,J,Q,X,W,G,Y){let B=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(B)$.typeParameters=B;return super.parseObjPropValue($,J,Q,X,W,G,Y)}parseFunctionParams($,J){let Q=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(Q)$.typeParameters=Q;super.parseFunctionParams($,J)}parseVarId($,J){if(super.parseVarId($,J),$.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(31))$.definite=!0;let Q=this.tsTryParseTypeAnnotation();if(Q)$.id.typeAnnotation=Q,this.resetEndLocation($.id)}parseAsyncArrowFromCallExpression($,J){if(this.match(10))$.returnType=this.tsParseTypeAnnotation();return super.parseAsyncArrowFromCallExpression($,J)}parseMaybeAssign($,J){let Q,X,W;if(this.hasPlugin("jsx")&&(this.match(138)||this.match(43))){if(Q=this.state.clone(),X=this.tryParse(()=>super.parseMaybeAssign($,J),Q),!X.error)return X.node;let{context:B}=this.state,H=B[B.length-1];if(H===Y2.j_oTag||H===Y2.j_expr)B.pop()}if(!X?.error&&!this.match(43))return super.parseMaybeAssign($,J);if(!Q||Q===this.state)Q=this.state.clone();let G,Y=this.tryParse((B)=>{G=this.tsParseTypeParameters(this.tsParseConstModifier);let H=super.parseMaybeAssign($,J);if(H.type!=="ArrowFunctionExpression"||H.extra?.parenthesized)B();if(G?.params.length!==0)this.resetStartLocationFromNode(H,G);if(H.typeParameters=G,this.hasPlugin("jsx")&&H.typeParameters.params.length===1&&!H.typeParameters.extra?.trailingComma){let K=H.typeParameters.params[0];if(!K.constraint)this.raise($D.SingleTypeParameterWithoutTrailingComma,this.optionFlags&256?e0(K.loc.end,1):K,{typeParameterName:K.name.name})}return H},Q);if(!Y.error&&!Y.aborted){if(G)this.reportReservedArrowTypeParam(G);return Y.node}if(!X){if(pN(!this.hasPlugin("jsx")),W=this.tryParse(()=>super.parseMaybeAssign($,J),Q),!W.error)return W.node}if(X?.node)return this.state=X.failState,X.node;if(Y.node){if(this.state=Y.failState,G)this.reportReservedArrowTypeParam(G);return Y.node}if(W?.node)return this.state=W.failState,W.node;throw X?.error||Y.error||W?.error}reportReservedArrowTypeParam($){if($.params.length===1&&!$.params[0].constraint&&!$.extra?.trailingComma&&this.getPluginOption("typescript","disallowAmbiguousJSXLike"))this.raise($D.ReservedArrowTypeParam,$)}parseMaybeUnary($,J){if(!this.hasPlugin("jsx")&&this.match(43))return this.tsParseTypeAssertion();return super.parseMaybeUnary($,J)}parseArrow($){if(this.match(10)){let J=this.tryParse((Q)=>{let X=this.tsParseTypeOrTypePredicateAnnotation(10);if(this.canInsertSemicolon()||!this.match(15))Q();return X});if(J.aborted)return;if(!J.thrown){if(J.error)this.state=J.failState;$.returnType=J.node}}return super.parseArrow($)}parseFunctionParamType($){if(this.eat(13))$.optional=!0;let J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J;return this.resetEndLocation($),$}isAssignable($,J){switch($.type){case"TSTypeCastExpression":return this.isAssignable($.expression,J);case"TSParameterProperty":return!0;default:return super.isAssignable($,J)}}toAssignable($,J=!1){switch($.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression($,J);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":if(J)this.expressionScope.recordArrowParameterBindingError($D.UnexpectedTypeCastInParameter,$);else this.raise($D.UnexpectedTypeCastInParameter,$);this.toAssignable($.expression,J);break;case"AssignmentExpression":if(!J&&$.left.type==="TSTypeCastExpression")$.left=this.typeCastToParameter($.left);default:super.toAssignable($,J)}}toAssignableParenthesizedExpression($,J){switch($.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable($.expression,J);break;default:super.toAssignable($,J)}}checkToRestConversion($,J){switch($.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion($.expression,!1);break;default:super.checkToRestConversion($,J)}}isValidLVal($,J,Q,X){switch($){case"TSTypeCastExpression":return!0;case"TSParameterProperty":return"parameter";case"TSNonNullExpression":return"expression";case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return(X!==64||!Q)&&["expression",!0];default:return super.isValidLVal($,J,Q,X)}}parseBindingAtom(){if(this.state.type===74)return this.parseIdentifier(!0);return super.parseBindingAtom()}parseMaybeDecoratorArguments($,J){if(this.match(43)||this.match(47)){let Q=this.tsParseTypeArgumentsInExpression();if(this.match(6)){let X=super.parseMaybeDecoratorArguments($,J);return X.typeArguments=Q,X}this.unexpected(null,6)}return super.parseMaybeDecoratorArguments($,J)}checkCommaAfterRest($){if(this.state.isAmbientContext&&this.match(8)&&this.lookaheadCharCode()===$)return this.next(),!1;return super.checkCommaAfterRest($)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(31)||this.match(10)||super.isClassProperty()}parseMaybeDefault($,J){let Q=super.parseMaybeDefault($,J);if(Q.type==="AssignmentPattern"&&Q.typeAnnotation&&Q.right.start<Q.typeAnnotation.start)this.raise($D.TypeAnnotationAfterAssign,Q.typeAnnotation);return Q}getTokenFromCode($){if(this.state.inType){if($===62){this.finishOp(44,1);return}if($===60){this.finishOp(43,1);return}}super.getTokenFromCode($)}reScan_lt_gt(){let{type:$}=this.state;if($===43)this.state.pos-=1,this.readToken_lt();else if($===44)this.state.pos-=1,this.readToken_gt()}reScan_lt(){let{type:$}=this.state;if($===47)return this.state.pos-=2,this.finishOp(43,1),43;return $}toAssignableListItem($,J,Q){let X=$[J];if(X.type==="TSTypeCastExpression")$[J]=this.typeCastToParameter(X);super.toAssignableListItem($,J,Q)}typeCastToParameter($){return $.expression.typeAnnotation=$.typeAnnotation,this.resetEndLocationFromNode($.expression,$.typeAnnotation),$.expression}shouldParseArrow($){if(this.match(10))return $.every((J)=>this.isAssignable(J,!0));return super.shouldParseArrow($)}shouldParseAsyncArrow(){if(this.match(10)){if(this.state.inConditionalConsequent)return!1;return!0}return super.shouldParseAsyncArrow()}parseParenAndDistinguishExpression($){let J=this.state.inConditionalConsequent;this.state.inConditionalConsequent=!1;let Q=super.parseParenAndDistinguishExpression($);return this.state.inConditionalConsequent=J,Q}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName($){if(this.match(43)||this.match(47)){let J=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());if(J)$.typeArguments=J}return super.jsxParseOpeningElementAfterName($)}getGetterSetterExpectedParamCount($){let J=super.getGetterSetterExpectedParamCount($),X=this.getObjectOrClassMethodParams($)[0];return X&&this.isThisParam(X)?J+1:J}parseCatchClauseParam(){let $=super.parseCatchClauseParam(),J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J,this.resetEndLocation($);return $}tsInAmbientContext($){let{isAmbientContext:J,strict:Q}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return $()}finally{this.state.isAmbientContext=J,this.state.strict=Q}}parseClass($,J,Q){let X=this.state.inAbstractClass;this.state.inAbstractClass=!!$.abstract;try{return super.parseClass($,J,Q)}finally{this.state.inAbstractClass=X}}tsParseAbstractDeclaration($,J){if(this.match(76))return $.abstract=!0,this.maybeTakeDecorators(J,this.parseClass($,!0,!1));else if(this.isContextual(125))if(!this.hasFollowingLineBreak())return $.abstract=!0,this.raise($D.NonClassMethodPropertyHasAbstractModifier,$),this.tsParseInterfaceDeclaration($);else return null;throw this.unexpected(null,76)}parseMethod($,J,Q,X,W,G,Y){let B=super.parseMethod($,J,Q,X,W,G,Y);if(B.abstract||B.type==="TSAbstractMethodDefinition"){if((this.hasPlugin("estree")?B.value:B).body){let{key:z}=B;this.raise($D.AbstractMethodHasImplementation,B,{methodName:z.type==="Identifier"&&!B.computed?z.name:`[${this.input.slice(this.offsetToSourcePos(z.start),this.offsetToSourcePos(z.end))}]`})}}return B}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){if(this.shouldParseAsAmbientContext())this.state.isAmbientContext=!0;return super.parse()}getExpression(){if(this.shouldParseAsAmbientContext())this.state.isAmbientContext=!0;return super.getExpression()}parseExportSpecifier($,J,Q,X){if(!J&&X)return this.parseTypeOnlyExportSpecifier($,Q),this.finishNode($,"ExportSpecifier");return $.exportKind="value",super.parseExportSpecifier($,J,Q,X)}parseImportSpecifier($,J,Q,X,W){if(!J&&X)return this.parseTypeOnlyImportSpecifier($,Q),this.finishNode($,"ImportSpecifier");return $.importKind="value",super.parseImportSpecifier($,J,Q,X,Q?4098:4096)}parseTypeOnlyImportSpecifier($,J){let Q=$.imported,X=!1;if(this.isContextual(89)){let W=this.parseIdentifier();if(this.isContextual(89)){let G=this.parseIdentifier();if(A0(this.state.type))X=!0,Q=W,$.local=this.parseIdentifier();else $.local=G}else if(A0(this.state.type))$.local=this.parseIdentifier();else X=!0,Q=W}else if(A0(this.state.type)){if(X=!0,Q=this.parseIdentifier(!0),!this.isContextual(89))this.checkReservedWord(Q.name,Q.start,!0,!0)}if(X&&J)this.raise($D.TypeModifierIsUsedInTypeImports,$.imported);$.imported=Q,$.importKind=X?"type":"value",this.checkIdentifier($.local??=this.eatContextual(89)?this.parseIdentifier():this.cloneIdentifier($.imported),X?4098:4096)}parseTypeOnlyExportSpecifier($,J){let Q=$.local,X=!1;if(this.isContextual(89)){let W=this.parseIdentifier();if(this.isContextual(89)){let G=this.parseIdentifier();if(A0(this.state.type))X=!0,$.local=W,$.exported=this.parseModuleExportName();else $.exported=G}else if(A0(this.state.type))$.exported=this.parseModuleExportName();else X=!0,$.local=W}else if(A0(this.state.type))X=!0,$.local=this.parseModuleExportName();if(X&&J)this.raise($D.TypeModifierIsUsedInTypeExports,Q);$.exportKind=X?"type":"value",$.exported??=this.eatContextual(89)?this.parseModuleExportName():this.cloneIdentifier($.local)}fillOptionalPropertiesForTSESLint($){switch($.type){case"ImportDeclaration":$.phase??=null;return;case"ExpressionStatement":$.directive??=void 0;return;case"RestElement":$.value=void 0;case"Identifier":case"ArrayPattern":case"AssignmentPattern":case"ObjectPattern":$.decorators??=[],$.optional??=!1,$.typeAnnotation??=void 0;return;case"TSParameterProperty":$.accessibility??=void 0,$.decorators??=[],$.override??=!1,$.readonly??=!1,$.static??=!1;return;case"TSEmptyBodyFunctionExpression":$.body=null;case"TSDeclareFunction":case"FunctionDeclaration":case"FunctionExpression":case"ClassMethod":case"ClassPrivateMethod":$.declare??=!1,$.returnType??=void 0,$.typeParameters??=void 0;return;case"Property":$.optional??=!1;return;case"TSMethodSignature":case"TSPropertySignature":$.optional??=!1;case"TSIndexSignature":$.accessibility??=void 0,$.readonly??=!1,$.static??=!1;return;case"TSAbstractPropertyDefinition":case"PropertyDefinition":case"TSAbstractAccessorProperty":case"AccessorProperty":$.declare??=!1,$.definite??=!1,$.readonly??=!1,$.typeAnnotation??=void 0;case"TSAbstractMethodDefinition":case"MethodDefinition":$.accessibility??=void 0,$.decorators??=[],$.override??=!1,$.optional??=!1;return;case"ClassExpression":$.id??=null;case"ClassDeclaration":$.abstract??=!1,$.declare??=!1,$.decorators??=[],$.implements??=[],$.superTypeArguments??=void 0,$.typeParameters??=void 0;return;case"TSTypeAliasDeclaration":case"VariableDeclaration":$.declare??=!1;return;case"VariableDeclarator":$.definite??=!1;return;case"TSEnumDeclaration":$.const??=!1,$.declare??=!1;return;case"TSEnumMember":$.computed??=!1;return;case"TSImportType":$.qualifier??=null,$.options??=null,$.typeArguments??=null;return;case"TSInterfaceDeclaration":$.declare??=!1,$.extends??=[];return;case"TSMappedType":$.optional??=!1,$.readonly??=void 0;return;case"TSModuleDeclaration":$.declare??=!1,$.global??=$.kind==="global";return;case"TSTypeParameter":$.const??=!1,$.in??=!1,$.out??=!1;return}}chStartsBindingIdentifierAndNotRelationalOperator($,J){if(h8($)){if(vG.lastIndex=J,vG.test(this.input)){let Q=this.codePointAtPos(vG.lastIndex);if(!i1(Q)&&Q!==92)return!1}return!0}else if($===92)return!0;else return!1}nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine(){let $=this.nextTokenInLineStart(),J=this.codePointAtPos($);return this.chStartsBindingIdentifierAndNotRelationalOperator(J,$)}nextTokenIsStringLiteralOnSameLine(){let $=this.nextTokenInLineStart(),J=this.codePointAtPos($);return J===34||J===39}};function vm(D){if(D.type!=="MemberExpression")return!1;let{computed:Z,property:$}=D;if(Z&&$.type!=="StringLiteral"&&($.type!=="TemplateLiteral"||$.expressions.length>0))return!1;return j_(D.object)}function um(D,Z){let{type:$}=D;if(D.extra?.parenthesized)return!1;if(Z){if($==="Literal"){let{value:J}=D;if(typeof J==="string"||typeof J==="boolean")return!0}}else if($==="StringLiteral"||$==="BooleanLiteral")return!0;if(T_(D,Z)||dm(D,Z))return!0;if($==="TemplateLiteral"&&D.expressions.length===0)return!0;if(vm(D))return!0;return!1}function T_(D,Z){if(Z)return D.type==="Literal"&&(typeof D.value==="number"||("bigint"in D));return D.type==="NumericLiteral"||D.type==="BigIntLiteral"}function dm(D,Z){if(D.type==="UnaryExpression"){let{operator:$,argument:J}=D;if($==="-"&&T_(J,Z))return!0}return!1}function j_(D){if(D.type==="Identifier")return!0;if(D.type!=="MemberExpression"||D.computed)return!1;return j_(D.object)}function a1(D,Z=[]){let $=new Map;for(let J of D)$.set(J,!0);for(let J of Z)$.set(J,!1);return $}var pm={ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."},lN=z8`placeholders`(pm),cm=(D)=>class Z extends D{parsePlaceholder($){if(this.match(129)){let J=this.startNode();return this.next(),this.assertNoSpace(),J.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(129),this.finishPlaceholder(J,$)}}finishPlaceholder($,J){let Q=$;if(!Q.expectedNode||!Q.type)Q=this.finishNode(Q,"Placeholder");return Q.expectedNode=J,Q}getTokenFromCode($){if($===37&&this.input.charCodeAt(this.state.pos+1)===37)this.finishOp(129,2);else super.getTokenFromCode($)}parseExprAtom($){return this.parsePlaceholder("Expression")||super.parseExprAtom($)}parseIdentifier($){return this.parsePlaceholder("Identifier")||super.parseIdentifier($)}checkReservedWord($,J,Q,X){if($!==void 0)super.checkReservedWord($,J,Q,X)}cloneIdentifier($){let J=super.cloneIdentifier($);if(J.type==="Placeholder")J.expectedNode=$.expectedNode;return J}cloneStringLiteral($){if($.type==="Placeholder")return this.cloneIdentifier($);return super.cloneStringLiteral($)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal($,J,Q,X){return $==="Placeholder"||super.isValidLVal($,J,Q,X)}toAssignable($,J){if($&&$.type==="Placeholder"&&$.expectedNode==="Expression")$.expectedNode="Pattern";else super.toAssignable($,J)}chStartsBindingIdentifier($,J){if(super.chStartsBindingIdentifier($,J))return!0;let Q=this.nextTokenStart();if(this.input.charCodeAt(Q)===37&&this.input.charCodeAt(Q+1)===37)return!0;return!1}verifyBreakContinue($,J){if($.label?.type==="Placeholder")return;super.verifyBreakContinue($,J)}parseExpressionStatement($,J){if(J.type!=="Placeholder"||J.extra?.parenthesized)return super.parseExpressionStatement($,J);if(this.match(10)){let X=$;return X.label=this.finishPlaceholder(J,"Identifier"),this.next(),X.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(X,"LabeledStatement")}this.semicolon();let Q=$;return Q.name=J.name,this.finishPlaceholder(Q,"Statement")}parseBlock($,J,Q){return this.parsePlaceholder("BlockStatement")||super.parseBlock($,J,Q)}parseFunctionId($){return this.parsePlaceholder("Identifier")||super.parseFunctionId($)}parseClass($,J,Q){let X=J?"ClassDeclaration":"ClassExpression";this.next();let W=this.state.strict,G=this.parsePlaceholder("Identifier");if(G)if(this.match(77)||this.match(129)||this.match(2))$.id=G;else if(Q||!J)return $.id=null,$.body=this.finishPlaceholder(G,"ClassBody"),this.finishNode($,X);else throw this.raise(lN.ClassNameIsRequired,this.state.startLoc);else this.parseClassId($,J,Q);return super.parseClassSuper($),$.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!$.superClass,W),this.finishNode($,X)}parseExport($,J){let Q=this.parsePlaceholder("Identifier");if(!Q)return super.parseExport($,J);let X=$;if(!this.isContextual(94)&&!this.match(8))return X.specifiers=[],X.source=null,X.declaration=this.finishPlaceholder(Q,"Declaration"),this.finishNode(X,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");let W=this.startNode();return W.exported=Q,X.specifiers=[this.finishNode(W,"ExportDefaultSpecifier")],super.parseExport(X,J)}isExportDefaultSpecifier(){if(this.match(61)){let $=this.nextTokenStart();if(this.isUnparsedContextual($,"from")){if(this.input.startsWith(a3(129),this.nextTokenStartSince($+4)))return!0}}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier($,J){if($.specifiers?.length)return!0;return super.maybeParseExportDefaultSpecifier($,J)}checkNamedExport(){}parseImport($){let J=this.parsePlaceholder("Identifier");if(!J)return super.parseImport($);if($.specifiers=[],!this.isContextual(94)&&!this.match(8))return $.source=this.finishPlaceholder(J,"StringLiteral"),this.semicolon(),this.finishNode($,"ImportDeclaration");let Q=this.startNodeAtNode(J);if(Q.local=J,$.specifiers.push(this.finishNode(Q,"ImportDefaultSpecifier")),this.eat(8)){if(!this.maybeParseStarImportSpecifier($))this.parseNamedImportSpecifiers($)}return this.expectContextual(94),$.source=this.parseImportSource(),this.semicolon(),this.finishNode($,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){if(this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index))this.raise(lN.UnexpectedSpace,this.state.lastTokEndLoc)}},lm=(D)=>class Z extends D{parseV8Intrinsic(){if(this.match(50)){let $=this.state.startLoc,J=this.startNode();if(this.next(),iD(this.state.type)){let Q=this.parseIdentifierName(),X=this.createIdentifier(J,Q);if(this.castNodeTo(X,"V8IntrinsicIdentifier"),this.match(6))return X}this.unexpected($)}}parseExprAtom($){return this.parseV8Intrinsic()||super.parseExprAtom($)}},sN=["fsharp","hack"],nN=["^^","@@","^","%","#"];function sm(D){if(D.has("decorators")){if(D.has("decorators-legacy"))throw Error("Cannot use the decorators and decorators-legacy plugin together")}if(D.has("flow")&&D.has("typescript"))throw Error("Cannot combine flow and typescript plugins.");if(D.has("placeholders")&&D.has("v8intrinsic"))throw Error("Cannot combine placeholders and v8intrinsic plugins.");if(D.has("pipelineOperator")){let Z=D.get("pipelineOperator").proposal;if(!sN.includes(Z)){let $=sN.map((J)=>`"${J}"`).join(", ");throw Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${$}.`)}if(Z==="hack"){if(D.has("placeholders"))throw Error("Cannot combine placeholders plugin and Hack-style pipes.");if(D.has("v8intrinsic"))throw Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");let $=D.get("pipelineOperator").topicToken;if(!nN.includes($)){let J=nN.map((Q)=>`"${Q}"`).join(", ");throw Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${J}.`)}}}if(D.has("moduleAttributes"))throw Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(D.has("importAssertions"))throw Error("`importAssertions` has been removed in Babel 8, please use import attributes instead.");if(D.has("deprecatedImportAssert"))console.warn("`deprecatedImportAssert` has been removed in Babel 8, please use import attributes instead.");else if(D.has("importAttributes")&&D.get("importAttributes").deprecatedAssertSyntax)console.warn("The 'importAttributes' plugin has been removed in Babel 8. Please migrate any usage of `assert`-style attributes to `with`.");if(D.has("recordAndTuple"))throw Error("The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.");if(D.has("asyncDoExpressions")&&!D.has("doExpressions")){let Z=Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw Z.missingPlugins="doExpressions",Z}if(D.has("optionalChainingAssign")&&D.get("optionalChainingAssign").version!=="2023-07")throw Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");if(D.has("discardBinding")&&D.get("discardBinding").syntaxType!=="void")throw Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");if(D.has("decimal"))throw Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");if(D.has("importReflection"))throw Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}var q_={estree:ch,jsx:Cm,flow:Lm,typescript:mm,v8intrinsic:lm,placeholders:cm},nm=Object.keys(q_);class XY extends O_{constructor(D,Z,$){let J=ph(D);super(J,Z);this.options=J,this.initializeScopes(),this.plugins=$,this.filename=J.sourceFilename,this.startIndex=J.startIndex;let Q=0;if(J.allowAwaitOutsideFunction)Q|=1;if(J.allowReturnOutsideFunction)Q|=2;if(J.allowImportExportEverywhere)Q|=8;if(J.allowSuperOutsideMethod)Q|=16;if(J.allowUndeclaredExports)Q|=64;if(J.allowNewTargetOutsideFunction)Q|=4;if(J.allowYieldOutsideFunction)Q|=32;if(J.ranges)Q|=128;if(J.locations===!0)Q|=256;if(J.tokens)Q|=512;if(J.createImportExpressions)Q|=1024;if(J.createParenthesizedExpressions)Q|=2048;if(J.errorRecovery)Q|=4096;if(J.attachComment)Q|=8192;if(J.annexB)Q|=16384;this.optionFlags=Q}getScopeHandler(){return cZ}parse(){this.enterInitialScopes();let D=this.startNode(),Z=this.startNode();this.nextToken(),D.errors=[];let $=this.parseTopLevel(D,Z);return $.errors=this.state.errors,$.comments.length=this.state.commentsLen,$}}function lZ(D,Z){if(Z?.sourceType==="unambiguous"){Z={...Z};try{Z.sourceType="module";let $=b4(Z,D),J=$.parse();if($.sawUnambiguousESM)return J;if($.ambiguousScriptDifferentAst)try{return Z.sourceType="script",b4(Z,D).parse()}catch{}else J.program.sourceType="script";return J}catch($){try{return Z.sourceType="script",b4(Z,D).parse()}catch{}throw $}}else return b4(Z,D).parse()}function A_(D,Z){let $=b4(Z,D);if($.options.strictMode)$.state.strict=!0;return $.getExpression()}function im(D){let Z={};for(let $ of Object.keys(D))Z[$]=oN(D[$]);return Z}var p0D=im(sh);function b4(D,Z){let $=XY,J=new Map;if(D?.plugins){for(let Q of D.plugins){let X,W;if(typeof Q==="string")X=Q;else[X,W]=Q;if(!J.has(X))J.set(X,W||{})}sm(J),$=am(J)}return new $(D,Z,J)}var iN=new Map;function am(D){let Z=[];for(let Q of nm)if(D.has(Q))Z.push(Q);let $=Z.join("|"),J=iN.get($);if(!J){J=XY;for(let Q of Z)J=q_[Q](J);iN.set($,J)}return J}var G3=(D)=>!!D&&typeof D==="object"&&typeof D.type==="string",X0=(D,Z)=>G3(D)&&D.type==="Identifier"&&D.name===Z,I_=(D,Z,$)=>G3(D)&&D.type==="MemberExpression"&&!D.computed&&X0(D.object,Z)&&X0(D.property,$),WY=(D)=>G3(D)&&D.type==="MemberExpression"&&!D.computed&&G3(D.object)&&D.object.type==="MetaProperty"&&X0(D.object.meta,"import")&&X0(D.object.property,"meta")&&X0(D.property,"url"),S_=(D)=>G3(D)&&D.type==="StringLiteral"?D.value:void 0;function V8(D,Z,$){let J=[],Q=[],X=[],W=()=>{throw Error(`Local routine source unavailable: unsupported dynamic source or asset in ${Z}. Use literal imports/requires and new URL('./asset', import.meta.url).`)},G=(B,H=!1)=>{let K=S_(B);if(K===void 0)W();J.push({specifier:K,require:H})},Y=(B,H)=>{if(["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"].includes(B.type)&&B.source){let K=B.specifiers;if(B.importKind==="type"||B.exportKind==="type"||K?.length&&K.every((z)=>z.importKind==="type"||z.exportKind==="type"))return;G(B.source)}if(B.type==="ImportExpression"){let K=B.source;if(!($&&G3(K)&&K.type==="MemberExpression"&&!K.computed&&X0(K.property,"href")&&G3(K.object)&&K.object.type==="CallExpression"&&X0(K.object.callee,"pathToFileURL")&&Array.isArray(K.object.arguments)&&K.object.arguments.length===1&&I_(K.object.arguments[0],"bootstrap","entry")))G(K)}if(B.type==="CallExpression"&&X0(B.callee,"require"))G(B.arguments[0],!0);if((B.type==="CallExpression"||B.type==="NewExpression")&&(X0(B.callee,"eval")||X0(B.callee,"Function")||X0(B.callee,"createRequire")||I_(B.callee,"module","require")))W();if(B.type==="NewExpression"&&X0(B.callee,"URL")){let K=B.arguments;if(WY(K[1])){let z=S_(K[0]);if(!z||!z.startsWith("./")&&!z.startsWith("../")||K.length!==2)W();Q.push(z);let V=K[0];X.push({start:V.start,end:V.end,path:z})}}if(WY(B)&&!(H?.type==="NewExpression"&&X0(H.callee,"URL")))W();if(B.type==="MetaProperty"&&X0(B.meta,"import")&&!WY(H))W();if(X0(B,"createRequire"))W();if(B.type==="Identifier"&&(B.name==="__dirname"||B.name==="__filename")&&!(H?.type==="MemberExpression"&&H.property===B&&!H.computed))W();if(!$&&X0(B,"require")&&!(H?.type==="CallExpression"&&H.callee===B)&&!(H?.type==="MemberExpression"&&H.property===B&&!H.computed))W();for(let K of Object.values(B))if(G3(K))Y(K,B);else if(Array.isArray(K)){for(let z of K)if(G3(z))Y(z,B)}};try{Y(lZ(D,{sourceType:"unambiguous",createImportExpressions:!0,plugins:Z.endsWith(".ts")||Z.endsWith(".mts")||Z.endsWith(".cts")?["typescript"]:[]}))}catch(B){if(B instanceof Error&&B.message.startsWith("Local routine source unavailable:"))throw B;throw Error(`Local routine source unavailable: unsupported module syntax in ${Z}.`)}return{modules:J,assets:Q,assetLiterals:X}}T1();import{createHash as om}from"node:crypto";var sZ=(D,Z)=>fH({PATH:process.env.PATH,GIT_CONFIG_NOSYSTEM:"1",GIT_CONFIG_GLOBAL:"/dev/null"},()=>b0(D,["-c","core.fsmonitor=false",...Z],void 0,{localObjectsOnly:!0}));async function rm(D){let Z=(await sZ(D,["symbolic-ref","HEAD"])).toString().trim();if(!Z.startsWith("refs/heads/"))throw Error("Routine checkout branch unavailable");try{let $=(await sZ(D,["rev-parse","--verify",`${Z}^{commit}`])).toString().trim();if(!/^[0-9a-f]{40}$/.test($))throw Error("Routine checkout commit unavailable");return{branch:Z,commit:$}}catch($){if(!($ instanceof R9))throw $;try{await sZ(D,["show-ref","--verify","--quiet",Z])}catch(J){if(J instanceof R9&&J.exitCode===1)return{branch:Z};throw J}throw $}}async function nZ(D,Z){let $=await rm(D);if(!$.commit)return{...$,dirty:!0};let J=[...new Set([...Z.keys()].filter((W)=>!W.split("/").includes("node_modules")).map((W)=>W.split("/")[0]))],Q=(await sZ(D,["ls-tree","-rz","--full-tree",$.commit,"--",...J])).toString("utf8"),X=new Map(Q.split("\x00").flatMap((W)=>{let G=/^[0-7]{6} blob ([0-9a-f]{40})\t(.+)$/.exec(W);return G?[[G[2],G[1]]]:[]}));return{...$,dirty:[...Z].some(([W,G])=>!W.split("/").includes("node_modules")&&om("sha1").update(`blob ${G.length}\x00`).update(G).digest("hex")!==X.get(W))}}var j5=P8(S4(),1);import{execFile as mv}from"node:child_process";import{constants as BJ}from"node:fs";import{access as vv,lstat as qY,mkdir as YM,open as uv,readdir as dv,realpath as D6,writeFile as BM}from"node:fs/promises";import{dirname as KJ,join as m2,posix as pv,relative as cv,sep as HJ,win32 as lv}from"node:path";import{promisify as sv}from"node:util";var _0=P8(S4(),1);var o3="0.1.46";class Y3 extends Error{problem;action;constructor(D,Z){super(`${D}
490
+ `),cooked:Q===null?null:Q.slice(1,Y)},W.tail=G,this.next();let H=this.finishNode(W,"TemplateElement");return this.resetEndLocation(H,e0(this.state.lastTokEndLoc,Y)),H}parseTemplate(D){let Z=this.startNode(),$=this.parseTemplateElement(D),J=[$],Q=[];while(!$.tail)Q.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),J.push($=this.parseTemplateElement(D));return Z.expressions=Q,Z.quasis=J,this.finishNode(Z,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(D,Z,$){let J=!1,Q=!0,X=this.startNode();X.properties=[],this.next();while(!this.match(D)){if(Q)Q=!1;else if(this.expect(8),this.match(D)){this.addTrailingCommaExtraToNode(X);break}let G;if(Z)G=this.parseBindingProperty();else G=this.parsePropertyDefinition($),J=this.checkProto(G,J,$);X.properties.push(G)}this.next();let W=Z?"ObjectPattern":"ObjectExpression";return this.finishNode(X,W)}addTrailingCommaExtraToNode(D){this.addExtra(D,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(D,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(D){return!D.computed&&D.key.type==="Identifier"&&(this.isLiteralPropertyName()||this.match(0)||this.match(51))}parsePropertyDefinition(D){let Z=[];if(this.match(22)){if(this.hasPlugin("decorators"))this.raise(m.UnsupportedPropertyDecorator,this.state.startLoc);while(this.match(22))Z.push(this.parseDecorator())}let $=this.startNode(),J=!1,Q=!1,X;if(this.match(17)){if(Z.length)this.unexpected();return this.parseSpread()}if(Z.length)$.decorators=Z;if($.method=!1,D)X=this.state.startLoc;let W=this.eat(51);this.parsePropertyNamePrefixOperator($);let G=this.state.containsEsc;if(this.parsePropertyName($,D),!W&&!G&&this.maybeAsyncOrAccessorProp($)){let{key:Y}=$,B=Y.name;if(B==="async"&&!this.hasPrecedingLineBreak())J=!0,this.resetPreviousNodeTrailingComments(Y),W=this.eat(51),this.parsePropertyName($);if(B==="get"||B==="set"){if(Q=!0,this.resetPreviousNodeTrailingComments(Y),$.kind=B,this.match(51))W=!0,this.raise(m.AccessorIsGenerator,this.state.curPosition(),{kind:B}),this.next();this.parsePropertyName($)}}return this.parseObjPropValue($,X,W,J,!1,Q,D)}getGetterSetterExpectedParamCount(D){return D.kind==="get"?0:1}getObjectOrClassMethodParams(D){return D.params}checkGetterSetterParams(D){let Z=this.getGetterSetterExpectedParamCount(D),$=this.getObjectOrClassMethodParams(D);if($.length!==Z)this.raise(D.kind==="get"?m.BadGetterArity:m.BadSetterArity,D);if(D.kind==="set"&&$[$.length-1]?.type==="RestElement")this.raise(m.BadSetterRestParameter,D)}parseObjectMethod(D,Z,$,J,Q){if(Q){let X=this.parseMethod(D,Z,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(X),X}if($||Z||this.match(6)){if(J)this.unexpected();return D.kind="method",D.method=!0,this.parseMethod(D,Z,$,!1,!1,"ObjectMethod")}}parseObjectProperty(D,Z,$,J){if(D.shorthand=!1,this.eat(10))return D.value=$?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowInOrVoidPattern(4,J),this.finishObjectProperty(D);if(!D.computed&&D.key.type==="Identifier"){if(this.checkReservedWord(D.key.name,D.key.start,!0,!1),$)D.value=this.parseMaybeDefault(Z,this.cloneIdentifier(D.key));else if(this.match(25)){let Q=this.state.startLoc;if(J!=null){if(J.shorthandAssignLoc===null)J.shorthandAssignLoc=Q}else this.raise(m.InvalidCoverInitializedName,Q);D.value=this.parseMaybeDefault(Z,this.cloneIdentifier(D.key))}else D.value=this.cloneIdentifier(D.key);return D.shorthand=!0,this.finishObjectProperty(D)}}finishObjectProperty(D){return this.finishNode(D,"ObjectProperty")}parseObjPropValue(D,Z,$,J,Q,X,W){let G=this.parseObjectMethod(D,$,J,Q,X)||this.parseObjectProperty(D,Z,Q,W);if(!G)this.unexpected();return G}parsePropertyName(D,Z){if(this.eat(0))D.computed=!0,D.key=this.parseMaybeAssignAllowIn(),this.expect(1);else{let{type:$,value:J}=this.state,Q;if(A0($))Q=this.parseIdentifier(!0);else switch($){case 131:Q=this.parseNumericLiteral(J);break;case 130:Q=this.parseStringLiteral(J);break;case 132:Q=this.parseBigIntLiteral(J);break;case 134:{let X=this.state.startLoc;if(Z!=null){if(Z.privateKeyLoc===null)Z.privateKeyLoc=X}else this.raise(m.UnexpectedPrivateField,X);Q=this.parsePrivateName();break}default:throw this.unexpected()}if(D.key=Q,$!==134)D.computed=!1}}initFunction(D,Z){D.id=null,D.generator=!1,D.async=Z}parseMethod(D,Z,$,J,Q,X,W=!1){this.initFunction(D,$),D.generator=Z,this.scope.enter(530|(W?576:0)|(Q?32:0)),this.prodParam.enter(dZ($,D.generator)),this.parseFunctionParams(D,J);let G=this.parseFunctionBodyAndFinish(D,X,!0);return this.prodParam.exit(),this.scope.exit(),G}parseArrayLike(D,Z){let $=this.startNode();return this.next(),$.elements=this.parseExprList(D,!0,Z,$),this.finishNode($,"ArrayExpression")}parseArrowExpression(D,Z,$,J){this.scope.enter(518);let Q=dZ($,!1);if(!this.match(2))Q|=this.prodParam.currentFlags()&24;if(this.prodParam.enter(Q),this.initFunction(D,$),Z)this.setArrowFunctionParameters(D,Z,J);return this.parseFunctionBody(D,!0),this.prodParam.exit(),this.scope.exit(),this.finishNode(D,"ArrowFunctionExpression")}setArrowFunctionParameters(D,Z,$){this.toAssignableList(Z,$,!1),D.params=Z}parseFunctionBodyAndFinish(D,Z,$=!1){return this.parseFunctionBody(D,!1,$),this.finishNode(D,Z)}parseFunctionBody(D,Z,$=!1){let J=Z&&!this.match(2);if(this.expressionScope.enter(cG()),J)D.body=this.parseMaybeAssign(),this.checkParams(D,!1,Z,!1);else{let Q=this.state.strict,X=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),D.body=this.parseBlock(!0,!1,(W)=>{let G=!this.isSimpleParamList(D.params);if(W&&G)this.raise(m.IllegalLanguageModeDirective,(D.kind==="method"||D.kind==="constructor")&&!!D.key?this.optionFlags&256?D.key.loc.end:D.key:D);let Y=!Q&&this.state.strict;if(this.checkParams(D,!this.state.strict&&!Z&&!$&&!G,Z,Y),this.state.strict&&D.id)this.checkIdentifier(D.id,65,Y)}),this.prodParam.exit(),this.state.labels=X}this.expressionScope.exit()}isSimpleParameter(D){return D.type==="Identifier"}isSimpleParamList(D){for(let Z=0,$=D.length;Z<$;Z++)if(!this.isSimpleParameter(D[Z]))return!1;return!0}checkParams(D,Z,$,J=!0){let Q=!Z&&new Set,X={type:"FormalParameters"};for(let W of D.params)this.checkLVal(W,X,5,Q,J)}parseExprList(D,Z,$,J){let Q=[],X=!0;while(!this.eat(D)){if(X)X=!1;else if(this.expect(8),this.match(D)){if(J)this.addTrailingCommaExtraToNode(J);this.next();break}Q.push(this.parseExprListItem(D,Z,$))}return Q}parseExprListItem(D,Z,$,J){let Q;if(this.match(8)){if(!Z)this.raise(m.UnexpectedToken,this.state.curPosition(),{unexpected:","});Q=null}else if(this.match(17)){let X=this.state.startLoc;Q=this.parseParenItem(this.parseSpread($),X)}else if(this.match(13)){if(this.expectPlugin("partialApplication"),!J)this.raise(m.UnexpectedArgumentPlaceholder,this.state.startLoc);let X=this.startNode();this.next(),Q=this.finishNode(X,"ArgumentPlaceholder")}else Q=this.parseMaybeAssignAllowInOrVoidPattern(D,$,!0);return Q}parseIdentifier(D){let Z=this.startNode(),$=this.parseIdentifierName(D);return this.createIdentifier(Z,$)}createIdentifier(D,Z){if(D.name=Z,this.optionFlags&256)D.loc.identifierName=Z;return this.finishNode(D,"Identifier")}createIdentifierAt(D,Z,$){if(D.name=Z,this.optionFlags&256)D.loc.identifierName=Z;return this.finishNodeAt(D,"Identifier",$)}parseIdentifierName(D){let Z,{start:$,type:J}=this.state;if(A0(J))Z=this.state.value;else this.unexpected();let Q=nh(J);if(D){if(Q)this.replaceToken(128)}else this.checkReservedWord(Z,this.sourceToOffsetPos($),Q,!1);return this.next(),Z}checkReservedWord(D,Z,$,J){if(D.length>10)return;if(!Bm(D))return;if($&&Wm(D)){this.raise(m.UnexpectedKeyword,Z,{keyword:D});return}if((!this.state.strict?tN:J?$_:eN)(D,this.inModule)){this.raise(m.UnexpectedReservedWord,Z,{reservedWord:D});return}else if(D==="yield"){if(this.prodParam.hasYield){this.raise(m.YieldBindingIdentifier,Z);return}}else if(D==="await"){if(this.prodParam.hasAwait){this.raise(m.AwaitBindingIdentifier,Z);return}if(this.scope.inStaticBlock){this.raise(m.AwaitBindingIdentifierInStaticBlock,Z);return}this.expressionScope.recordAsyncArrowParametersError(Z)}else if(D==="arguments"){if(this.scope.inClassAndNotInNonArrowFunction){this.raise(m.ArgumentsInClass,Z);return}}}recordAwaitIfAllowed(){let D=this.prodParam.hasAwait;if(D&&!this.scope.inFunction)this.state.hasTopLevelAwait=!0;return D}parseAwait(D,Z){let $=D.index;this.setLoc(D);let J=this.startNodeAt(D);if(this.expressionScope.recordParameterInitializerError(m.AwaitExpressionFormalParameter,$),this.eat(51))this.raise(m.ObsoleteAwaitStar,D);if(!this.scope.inFunction&&!(this.optionFlags&1))if(this.isAmbiguousPrefixOrIdentifier())this.ambiguousScriptDifferentAst=!0;else this.sawUnambiguousESM=!0;if(!Z)J.argument=this.parseMaybeUnary(null,!0);return this.finishNode(J,"AwaitExpression")}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;let{type:D}=this.state;return D===49||D===6||D===0||uG(D)||D===98&&!this.state.containsEsc||D===133||D===52||this.hasPlugin("v8intrinsic")&&D===50}parseYield(D){this.setLoc(D);let Z=this.startNodeAt(D);this.expressionScope.recordParameterInitializerError(m.YieldInParameter,D.index);let $=!1,J=null;if(!this.hasPrecedingLineBreak())switch($=this.eat(51),this.state.type){case 9:case 135:case 4:case 7:case 1:case 5:case 10:case 8:if(!$)break;default:J=this.parseMaybeAssign()}return Z.delegate=$,Z.argument=J,this.finishNode(Z,"YieldExpression")}parseImportCall(D){this.next();let Z=this.parseCallExpressionArguments();if(Z.length===0||Z.length>2)this.raise(m.ImportCallArity,D,D);else for(let $ of Z)if($.type==="SpreadElement")this.raise(m.ImportCallSpreadArgument,$,D);return D.source=Z[0],D.options=Z[1]??null,this.finishNode(D,"ImportExpression")}withTopicBindingContext(D){let Z=this.state.inHackPipelineBody;this.state.inHackPipelineBody=!0;let $=this.state.seenTopicReference;this.state.seenTopicReference=!1;try{return D()}finally{this.state.inHackPipelineBody=Z,this.state.seenTopicReference=$}}allowInAnd(D){let Z=this.prodParam.currentFlags();if(24&~Z){this.prodParam.enter(Z|8|16);try{return D()}finally{this.prodParam.exit()}}return D()}disallowInAnd(D){let Z=this.prodParam.currentFlags(),$=8&Z,J=16&~Z;if($||J){this.prodParam.enter(Z&-9|16);try{return D()}finally{this.prodParam.exit()}}return D()}registerTopicReference(){this.state.seenTopicReference=!0}topicReferenceIsAllowedInCurrentContext(){return this.state.inHackPipelineBody}topicReferenceWasUsedInCurrentContext(){return this.state.seenTopicReference}parseFSharpPipelineBody(D){let Z=this.state.startLoc;this.prodParam.enter(this.prodParam.currentFlags()&-17);let $;if(this.isContextual(92)&&this.recordAwaitIfAllowed()){this.next(),$=this.parseAwait(Z,!0);let J=this.state.type;if(gN(J)&&J!==35&&(this.prodParam.hasIn||J!==54))this.raise(m.PipelineUnparenthesized,Z)}else this.state.canStartArrow=!0,$=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),Z,D);return this.prodParam.exit(),$}parseModuleExpression(){this.expectPlugin("moduleBlocks");let D=this.startNode();if(this.next(),!this.match(2))this.unexpected(null,2);let Z=this.startNodeAt(this.state.endLoc);this.next();let $=this.initializeScopes(!0);this.enterInitialScopes();try{D.body=this.parseProgram(Z,4,"module")}finally{$()}return this.finishNode(D,"ModuleExpression")}parseVoidPattern(D){this.expectPlugin("discardBinding");let Z=this.startNode();if(D!=null)D.voidPatternLoc=this.state.startLoc;return this.next(),this.finishNode(Z,"VoidPattern")}parseMaybeAssignAllowInOrVoidPattern(D,Z,$){if(Z!=null&&this.match(84)){let J=this.lookaheadCharCode();if(J===44||J===(D===1?93:D===4?125:41)||J===61)return this.parseMaybeDefault(this.state.startLoc,this.parseVoidPattern(Z))}return this.parseMaybeAssignAllowIn(Z,$)}parsePropertyNamePrefixOperator(D){}}var hG={kind:1},Rm={kind:2},Em=/[\uD800-\uDFFF]/u,mG=/in(?:stanceof)?/y;function P_(D){for(let Z=0;Z<D.length;Z++){let $=D[Z],{type:J}=$;if(typeof J==="number")$.type=oN(J)}return D}class O_ extends C_{parseTopLevel(D,Z){if(D.program=this.parseProgram(Z,135,this.options.sourceType==="module"?"module":"script"),D.comments=this.comments,this.optionFlags&512)D.tokens=P_(this.tokens);return this.finishNode(D,"File")}parseProgram(D,Z,$){if(D.sourceType=$,D.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(D,!0,!0,Z),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(let[Q,X]of Array.from(this.scope.undefinedExports))this.raise(m.ModuleExportUndefined,X,{localName:Q});this.addExtra(D,"topLevelAwait",this.state.hasTopLevelAwait)}let J;if(Z===135)J=this.finishNode(D,"Program");else J=this.finishNodeAt(D,"Program",e0(this.state.startLoc,-1));return J}stmtToDirective(D){let Z=this.castNodeTo(D,"Directive"),$=this.castNodeTo(D.expression,"DirectiveLiteral"),J=$.value,Q=this.input.slice(this.offsetToSourcePos($.start),this.offsetToSourcePos($.end)),X=$.value=Q.slice(1,-1);return this.addExtra($,"raw",Q),this.addExtra($,"rawValue",X),this.addExtra($,"expressionValue",J),Z.value=$,delete D.expression,Z}parseInterpreterDirective(){if(!this.match(24))return null;let D=this.startNode();return D.value=this.state.value,this.next(),this.finishNode(D,"InterpreterDirective")}isLet(){if(!this.isContextual(96))return!1;return this.hasFollowingBindingAtom()}isUsing(){if(!this.isContextual(103))return!1;return this.nextTokenIsIdentifierOnSameLine()}isForUsing(){if(!this.isContextual(103))return!1;let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);if(this.isUnparsedContextual(D,"of")){let $=this.lookaheadCharCodeSince(D+2);if($!==61&&$!==58&&$!==59)return!1}if(this.chStartsBindingIdentifier(Z,D)||this.isUnparsedContextual(D,"void"))return!0;return!1}nextTokenIsIdentifierOnSameLine(){let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);return this.chStartsBindingIdentifier(Z,D)}isAwaitUsing(){if(!this.isContextual(92))return!1;let D=this.nextTokenInLineStart();if(this.isUnparsedContextual(D,"using")){D=this.nextTokenInLineStartSince(D+5);let Z=this.codePointAtPos(D);if(this.chStartsBindingIdentifier(Z,D))return!0}return!1}chStartsBindingIdentifier(D,Z){if(h8(D)){if(mG.lastIndex=Z,mG.test(this.input)){let $=this.codePointAtPos(mG.lastIndex);if(!i1($)&&$!==92)return!1}return!0}else if(D===92)return!0;else return!1}chStartsBindingPattern(D){return D===91||D===123}hasFollowingBindingAtom(){let D=this.nextTokenStart(),Z=this.codePointAtPos(D);return this.chStartsBindingPattern(Z)||this.chStartsBindingIdentifier(Z,D)}hasInLineFollowingBindingIdentifierOrBrace(){let D=this.nextTokenInLineStart(),Z=this.codePointAtPos(D);return Z===123||this.chStartsBindingIdentifier(Z,D)}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(D=!1){let Z=0;if(this.options.annexB&&!this.state.strict){if(Z|=4,D)Z|=8}return this.parseStatementLike(Z)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(D){let Z=null;if(this.match(22))Z=this.parseDecorators(!0);return this.parseStatementContent(D,Z)}parseStatementContent(D,Z){let $=this.state.type,J=this.startNode(),Q=!!(D&2),X=!!(D&4),W=D&1;switch($){case 56:return this.parseBreakContinueStatement(J,!0);case 59:return this.parseBreakContinueStatement(J,!1);case 60:return this.parseDebuggerStatement(J);case 86:return this.parseDoWhileStatement(J);case 87:return this.parseForStatement(J);case 64:if(this.lookaheadCharCode()===46)break;if(!X)this.raise(this.state.strict?m.StrictFunction:this.options.annexB?m.SloppyFunctionAnnexB:m.SloppyFunction,this.state.startLoc);return this.parseFunctionStatement(J,!1,!Q&&X);case 76:if(!Q)this.unexpected();return this.parseClass(this.maybeTakeDecorators(Z,J),!0);case 65:return this.parseIfStatement(J);case 66:return this.parseReturnStatement(J);case 67:return this.parseSwitchStatement(J);case 68:return this.parseThrowStatement(J);case 69:return this.parseTryStatement(J);case 92:if(this.isAwaitUsing()){if(!this.allowsUsing())this.raise(m.UnexpectedUsingDeclaration,J);else if(!Q)this.raise(m.UnexpectedLexicalDeclaration,J);else if(!this.recordAwaitIfAllowed())this.raise(m.AwaitUsingNotInAsyncContext,J);return this.next(),this.parseVarStatement(J,"await using")}break;case 103:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;if(!this.allowsUsing())this.raise(m.UnexpectedUsingDeclaration,this.state.startLoc);else if(!Q)this.raise(m.UnexpectedLexicalDeclaration,this.state.startLoc);return this.parseVarStatement(J,"using");case 96:{if(this.state.containsEsc)break;let B=this.nextTokenStart(),H=this.codePointAtPos(B);if(H!==91){if(!Q&&this.hasFollowingLineBreak())break;if(!this.chStartsBindingIdentifier(H,B)&&H!==123)break}}case 71:if(!Q)this.raise(m.UnexpectedLexicalDeclaration,this.state.startLoc);case 70:{let B=this.state.value;return this.parseVarStatement(J,B)}case 88:return this.parseWhileStatement(J);case 72:return this.parseWithStatement(J);case 2:return this.parseBlock();case 9:return this.parseEmptyStatement(J);case 79:{let B=this.lookaheadCharCode();if(B===40||B===46)break}case 78:{if(!(this.optionFlags&8)&&!W)this.raise(m.UnexpectedImportExport,this.state.startLoc);this.next();let B;if($===79)B=this.parseImport(J);else B=this.parseExport(J,Z);return this.assertModuleNodeAllowed(B),B}default:if(this.isAsyncFunction()){if(!Q)this.raise(m.AsyncFunctionInSingleStatementContext,this.state.startLoc);return this.next(),this.parseFunctionStatement(J,!0,!Q&&X)}}let G=this.state.value,Y=this.parseExpression();if(iD($)&&Y.type==="Identifier"&&this.eat(10))return this.parseLabeledStatement(J,G,Y,D);else return this.parseExpressionStatement(J,Y)}assertModuleNodeAllowed(D){if(!(this.optionFlags&8)&&!this.inModule)this.raise(m.ImportOutsideModule,D)}maybeTakeDecorators(D,Z,$){if(D){if(Z.decorators?.length)this.raise(m.DecoratorsBeforeAfterExport,Z.decorators[0]),Z.decorators.unshift(...D);else Z.decorators=D;if(this.resetStartLocationFromNode(Z,D[0]),$)this.resetStartLocationFromNode($,Z)}return Z}canHaveLeadingDecorator(){return this.match(76)}parseDecorators(D){let Z=[];do Z.push(this.parseDecorator());while(this.match(22));if(this.match(78)){if(!D)this.unexpected()}else if(!this.canHaveLeadingDecorator())throw this.raise(m.UnexpectedLeadingDecorator,this.state.startLoc);return Z}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);let D=this.startNode();if(this.next(),this.hasPlugin("decorators")){let Z=this.state.startLoc,$;if(this.match(6)){let J=this.state.startLoc;this.next(),$=this.parseExpression(),this.expect(7),$=this.wrapParenthesis(J,$);let Q=this.state.startLoc;if(D.expression=this.parseMaybeDecoratorArguments($,J),D.expression!==$)this.raise(m.DecoratorArgumentsOutsideParentheses,Q)}else{$=this.parseIdentifier(!1);while(this.eat(12)){let J=this.startNodeAt(Z);if(J.object=$,this.match(134))this.classScope.usePrivateName(this.state.value,this.state.startLoc),J.property=this.parsePrivateName();else J.property=this.parseIdentifier(!0);J.computed=!1,$=this.finishNode(J,"MemberExpression")}D.expression=this.parseMaybeDecoratorArguments($,Z)}}else this.state.canStartArrow=!1,D.expression=this.parseExprSubscripts();return this.finishNode(D,"Decorator")}parseMaybeDecoratorArguments(D,Z){if(this.eat(6)){let $=this.startNodeAt(Z);return $.callee=D,$.arguments=this.parseCallExpressionArguments(),this.toReferencedList($.arguments),this.finishNode($,"CallExpression")}return D}parseBreakContinueStatement(D,Z){if(this.next(),this.isLineTerminator())D.label=null;else D.label=this.parseIdentifier(),this.semicolon();return this.verifyBreakContinue(D,Z),this.finishNode(D,Z?"BreakStatement":"ContinueStatement")}verifyBreakContinue(D,Z){let $;for($=0;$<this.state.labels.length;++$){let J=this.state.labels[$];if(D.label==null||J.name===D.label.name){if(J.kind!=null&&(Z||J.kind===1))break;if(D.label&&Z)break}}if($===this.state.labels.length){let J=Z?"BreakStatement":"ContinueStatement";this.raise(m.IllegalBreakContinue,D,{type:J})}}parseDebuggerStatement(D){return this.next(),this.semicolon(),this.finishNode(D,"DebuggerStatement")}parseHeaderExpression(){this.expect(6);let D=this.parseExpression();return this.expect(7),D}parseDoWhileStatement(D){return this.next(),this.state.labels.push(hG),D.body=this.parseStatement(),this.state.labels.pop(),this.expect(88),D.test=this.parseHeaderExpression(),this.eat(9),this.finishNode(D,"DoWhileStatement")}parseForStatement(D){this.next(),this.state.labels.push(hG);let Z=null;if(this.isContextual(92)&&this.recordAwaitIfAllowed())Z=this.state.startLoc,this.next();if(this.scope.enter(0),this.expect(6),this.match(9)){if(Z!==null)this.unexpected(Z);return this.parseFor(D,null)}let $=this.isContextual(96);{let G=this.isAwaitUsing(),Y=G||this.isForUsing(),B=$&&this.hasFollowingBindingAtom()||Y;if(this.match(70)||this.match(71)||B){let H=this.startNode(),K;if(G){if(K="await using",!this.recordAwaitIfAllowed())this.raise(m.AwaitUsingNotInAsyncContext,this.state.startLoc);this.next()}else K=this.state.value;this.next(),this.parseVar(H,!0,K);let z=this.finishNode(H,"VariableDeclaration"),V=this.match(54);if(V&&Y)this.raise(m.ForInUsing,z);if((V||this.isContextual(98))&&z.declarations.length===1)return this.parseForX(D,z,Z);if(Z!==null)this.unexpected(Z);return this.parseFor(D,z)}}let J=this.isContextual(91),Q=new g4,X=this.parseExpression(!0,Q),W=this.isContextual(98);if(W){if($)this.raise(m.ForOfLet,X);if(Z===null&&J&&X.type==="Identifier")this.raise(m.ForOfAsync,X)}if(W||this.match(54)){this.checkDestructuringPrivate(Q),this.toAssignable(X,!0);let G=W?"ForOfStatement":"ForInStatement";return this.checkLVal(X,{type:G}),this.parseForX(D,X,Z)}else this.checkExpressionErrors(Q,!0);if(Z!==null)this.unexpected(Z);return this.parseFor(D,X)}parseFunctionStatement(D,Z,$){return this.next(),this.parseFunction(D,1|($?2:0)|(Z?8:0))}parseIfStatement(D){return this.next(),D.test=this.parseHeaderExpression(),D.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),D.alternate=this.eat(62)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(D,"IfStatement")}parseReturnStatement(D){if(!this.prodParam.hasReturn)this.raise(m.IllegalReturn,this.state.startLoc);if(this.next(),this.isLineTerminator())D.argument=null;else D.argument=this.parseExpression(),this.semicolon();return this.finishNode(D,"ReturnStatement")}parseSwitchStatement(D){this.next(),D.discriminant=this.parseHeaderExpression();let Z=D.cases=[];this.expect(2),this.state.labels.push(Rm),this.scope.enter(256);let $;for(let J;!this.match(4);)if(this.match(57)||this.match(61)){let Q=this.match(57);if($)this.finishNode($,"SwitchCase");if(Z.push($=this.startNode()),$.consequent=[],this.next(),Q)$.test=this.parseExpression();else{if(J)this.raise(m.MultipleDefaultsInSwitch,this.state.lastTokStartLoc);J=!0,$.test=null}this.expect(10)}else if($)$.consequent.push(this.parseStatementListItem());else this.unexpected();if(this.scope.exit(),$)this.finishNode($,"SwitchCase");return this.next(),this.state.labels.pop(),this.finishNode(D,"SwitchStatement")}parseThrowStatement(D){if(this.next(),this.hasPrecedingLineBreak())this.raise(m.NewlineAfterThrow,this.state.lastTokEndLoc);return D.argument=this.parseExpression(),this.semicolon(),this.finishNode(D,"ThrowStatement")}parseCatchClauseParam(){let D=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&D.type==="Identifier"?8:0),this.checkLVal(D,{type:"CatchClause"},9),D}parseTryStatement(D){if(this.next(),D.block=this.parseBlock(),D.handler=null,this.match(58)){let Z=this.startNode();if(this.next(),this.match(6))this.expect(6),Z.param=this.parseCatchClauseParam(),this.expect(7);else Z.param=null,this.scope.enter(0);Z.body=this.parseBlock(!1,!1),this.scope.exit(),D.handler=this.finishNode(Z,"CatchClause")}if(D.finalizer=this.eat(63)?this.parseBlock():null,!D.handler&&!D.finalizer)this.raise(m.NoCatchOrFinally,D);return this.finishNode(D,"TryStatement")}parseVarStatement(D,Z,$=!1){return this.next(),this.parseVar(D,!1,Z,$),this.semicolon(),this.finishNode(D,"VariableDeclaration")}parseWhileStatement(D){return this.next(),D.test=this.parseHeaderExpression(),this.state.labels.push(hG),D.body=this.parseStatement(),this.state.labels.pop(),this.finishNode(D,"WhileStatement")}parseWithStatement(D){if(this.state.strict)this.raise(m.StrictWith,this.state.startLoc);return this.next(),D.object=this.parseHeaderExpression(),D.body=this.parseStatement(),this.finishNode(D,"WithStatement")}parseEmptyStatement(D){return this.next(),this.finishNode(D,"EmptyStatement")}parseLabeledStatement(D,Z,$,J){for(let X of this.state.labels)if(X.name===Z)this.raise(m.LabelRedeclaration,$,{labelName:Z});let Q=oh(this.state.type)?1:this.match(67)?2:null;for(let X=this.state.labels.length-1;X>=0;X--){let W=this.state.labels[X];if(W.statementStart===D.start)W.statementStart=this.sourceToOffsetPos(this.state.start),W.kind=Q;else break}return this.state.labels.push({name:Z,kind:Q,statementStart:this.sourceToOffsetPos(this.state.start)}),D.body=J&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),D.label=$,this.finishNode(D,"LabeledStatement")}parseExpressionStatement(D,Z){return D.expression=Z,this.semicolon(),this.finishNode(D,"ExpressionStatement")}parseBlock(D=!1,Z=!0,$){let J=this.startNode();if(D)this.state.strictErrors.clear();if(this.expect(2),Z)this.scope.enter(0);if(this.parseBlockBody(J,D,!1,4,$),Z)this.scope.exit();return this.finishNode(J,"BlockStatement")}isValidDirective(D){return D.type==="ExpressionStatement"&&D.expression.type==="StringLiteral"&&!D.expression.extra.parenthesized}parseBlockBody(D,Z,$,J,Q){let X=D.body=[],W=D.directives=[];this.parseBlockOrModuleBlockBody(X,Z?W:void 0,$,J,Q)}parseBlockOrModuleBlockBody(D,Z,$,J,Q){let X=this.state.strict,W=!1,G=!1;while(!this.match(J)){let Y=$?this.parseModuleItem():this.parseStatementListItem();if(Z&&!G){if(this.isValidDirective(Y)){let B=this.stmtToDirective(Y);if(Z.push(B),!W&&B.value.value==="use strict")W=!0,this.setStrict(!0);continue}G=!0,this.state.strictErrors.clear()}D.push(Y)}if(Q?.call(this,W),!X)this.setStrict(!1);this.next()}parseFor(D,Z){return D.init=Z,this.semicolon(!1),D.test=this.match(9)?null:this.parseExpression(),this.semicolon(!1),D.update=this.match(7)?null:this.parseExpression(),this.expect(7),D.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(D,"ForStatement")}parseForX(D,Z,$){let J=this.match(54);if(this.next(),J){if($!==null)this.unexpected($)}else D.await=$!==null;if(Z.type==="VariableDeclaration"&&Z.declarations[0].init!=null&&(!J||!this.options.annexB||this.state.strict||Z.kind!=="var"||Z.declarations[0].id.type!=="Identifier"))this.raise(m.ForInOfLoopInitializer,Z,{type:J?"ForInStatement":"ForOfStatement"});if(Z.type==="AssignmentPattern")this.raise(m.InvalidLhs,Z,{ancestor:{type:"ForStatement"}});return D.left=Z,D.right=J?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(7),D.body=this.parseStatement(),this.scope.exit(),this.state.labels.pop(),this.finishNode(D,J?"ForInStatement":"ForOfStatement")}parseVar(D,Z,$,J=!1){let Q=D.declarations=[];D.kind=$;for(;;){let X=this.startNode();if(this.parseVarId(X,$),X.init=!this.eat(25)?null:Z?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn(),X.init===null&&!J){if(X.id.type!=="Identifier"&&!(Z&&(this.match(54)||this.isContextual(98))))this.raise(m.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"});else if(($==="const"||$==="using"||$==="await using")&&!(this.match(54)||this.isContextual(98)))this.raise(m.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:$})}if(Q.push(this.finishNode(X,"VariableDeclarator")),!this.eat(8))break}return D}parseVarId(D,Z){let $=this.parseBindingAtom();if(Z==="using"||Z==="await using"){if($.type==="ArrayPattern"||$.type==="ObjectPattern")this.raise(m.UsingDeclarationHasBindingPattern,$)}else if($.type==="VoidPattern")this.raise(m.UnexpectedVoidPattern,$);this.checkLVal($,{type:"VariableDeclarator"},Z==="var"?5:8201),D.id=$}parseAsyncFunctionExpression(D){return this.parseFunction(D,8)}parseFunction(D,Z=0){let $=Z&2,J=!!(Z&1),Q=J&&!(Z&4),X=!!(Z&8);if(this.initFunction(D,X),this.match(51)){if($)this.raise(m.GeneratorInSingleStatementContext,this.state.startLoc);this.next(),D.generator=!0}if(J)D.id=this.parseFunctionId(Q);if(this.scope.enter(514),this.prodParam.enter(dZ(X,D.generator)),!J&&iD(this.state.type))this.expressionScope.enter(cG()),D.id=this.parseFunctionId(),this.expressionScope.exit();if(this.parseFunctionParams(D,!1),this.parseFunctionBodyAndFinish(D,J?"FunctionDeclaration":"FunctionExpression"),this.prodParam.exit(),this.scope.exit(),J&&!$)this.registerFunctionStatementId(D);return D}parseFunctionId(D){return D||iD(this.state.type)?this.parseIdentifier():null}parseFunctionParams(D,Z){this.expect(6),this.expressionScope.enter(Am()),D.params=this.parseBindingList(7,41,2|(Z?4:0)),this.expressionScope.exit()}registerFunctionStatementId(D){if(!D.id)return;this.scope.declareName(D.id.name,!this.options.annexB||this.state.strict||D.generator||D.async?this.scope.treatFunctionsAsVar?5:8201:17,D.id.start)}parseClass(D,Z,$){this.next();let J=this.state.strict;return this.state.strict=!0,this.parseClassId(D,Z,$),this.parseClassSuper(D),D.body=this.parseClassBody(!!D.superClass,J),this.finishNode(D,Z?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(25)||this.match(9)||this.match(4)}isClassMethod(){return this.match(6)}nameIsConstructor(D){return D.type==="Identifier"&&D.name==="constructor"||D.type==="StringLiteral"&&D.value==="constructor"}isNonstaticConstructor(D){return!D.computed&&!D.static&&this.nameIsConstructor(D.key)}parseClassBody(D,Z){this.classScope.enter();let $={hadConstructor:!1,hadSuperClass:D},J=[],Q=this.startNode();Q.body=[],this.expect(2);while(!this.match(4)){if(this.eat(9)){if(J.length>0)throw this.raise(m.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(22)){J.push(this.parseDecorator());continue}let X=this.startNode();if(J.length)X.decorators=J,this.resetStartLocationFromNode(X,J[0]),J=[];this.parseClassMember(Q,X,$)}if(this.state.strict=Z,this.next(),J.length)throw this.raise(m.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(Q,"ClassBody")}parseClassMemberFromModifier(D,Z){let $=this.parseIdentifier(!0);if(this.isClassMethod()){let J=Z;return J.kind="method",J.computed=!1,J.key=$,J.static=!1,this.pushClassMethod(D,J,!1,!1,!1,!1),!0}else if(this.isClassProperty()){let J=Z;return J.computed=!1,J.key=$,J.static=!1,D.body.push(this.parseClassProperty(J)),!0}return this.resetPreviousNodeTrailingComments($),!1}parseClassMember(D,Z,$){let J=this.isContextual(102);if(J){if(this.parseClassMemberFromModifier(D,Z))return;if(this.eat(2)){this.parseClassStaticBlock(D,Z);return}}this.parseClassMemberWithIsStatic(D,Z,$,J)}parseClassMemberWithIsStatic(D,Z,$,J){let Q=Z,X=Z,W=Z,G=Z,Y=Z,B=Q,H=Q;if(Z.static=J,this.parsePropertyNamePrefixOperator(Z),this.eat(51)){B.kind="method";let F=this.match(134);if(this.parseClassElementName(B),this.parsePostMemberNameModifiers(B),F){this.pushClassPrivateMethod(D,X,!0,!1);return}if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsGenerator,Q.key);this.pushClassMethod(D,Q,!0,!1,!1,!1);return}let K=!this.state.containsEsc&&iD(this.state.type),z=this.parseClassElementName(Z),V=K?z.name:null,_=this.isPrivateName(z),N=this.state.startLoc;if(this.parsePostMemberNameModifiers(H),this.isClassMethod()){if(B.kind="method",_){this.pushClassPrivateMethod(D,X,!1,!1);return}let F=this.isNonstaticConstructor(Q),U=!1;if(F){if(Q.kind="constructor",Q.decorators&&Q.decorators.length>0)this.raise(m.DecoratorConstructor,Z);if($.hadConstructor&&!this.hasPlugin("typescript"))this.raise(m.DuplicateConstructor,z);if(F&&this.hasPlugin("typescript")&&Z.override)this.raise(m.OverrideOnConstructor,z);$.hadConstructor=!0,U=$.hadSuperClass}this.pushClassMethod(D,Q,!1,!1,F,U)}else if(this.isClassProperty())if(_)this.pushClassPrivateProperty(D,G);else this.pushClassProperty(D,W);else if(V==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(z);let F=this.eat(51);if(H.optional)this.unexpected(N);B.kind="method";let U=this.match(134);if(this.parseClassElementName(B),this.parsePostMemberNameModifiers(H),U)this.pushClassPrivateMethod(D,X,F,!0);else{if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsAsync,Q.key);this.pushClassMethod(D,Q,F,!0,!1,!1)}}else if((V==="get"||V==="set")&&!(this.match(51)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(z),B.kind=V;let F=this.match(134);if(this.parseClassElementName(Q),F)this.pushClassPrivateMethod(D,X,!1,!1);else{if(this.isNonstaticConstructor(Q))this.raise(m.ConstructorIsAccessor,Q.key);this.pushClassMethod(D,Q,!1,!1,!1,!1)}this.checkGetterSetterParams(Q)}else if(V==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(z);let F=this.match(134);this.parseClassElementName(W),this.pushClassAccessorProperty(D,Y,F)}else if(this.isLineTerminator())if(_)this.pushClassPrivateProperty(D,G);else this.pushClassProperty(D,W);else this.unexpected()}parseClassElementName(D){let{type:Z,value:$}=this.state;if((Z===128||Z===130)&&D.static&&$==="prototype")this.raise(m.StaticPrototype,this.state.startLoc);if(Z===134){if($==="constructor")this.raise(m.ConstructorClassPrivateField,this.state.startLoc);let J=this.parsePrivateName();return D.key=J,J}return this.parsePropertyName(D),D.key}parseClassStaticBlock(D,Z){this.scope.enter(720);let $=this.state.labels;this.state.labels=[],this.prodParam.enter(0);let J=Z.body=[];if(this.parseBlockOrModuleBlockBody(J,void 0,!1,4),this.prodParam.exit(),this.scope.exit(),this.state.labels=$,D.body.push(this.finishNode(Z,"StaticBlock")),Z.decorators?.length)this.raise(m.DecoratorStaticBlock,Z)}pushClassProperty(D,Z){if(!Z.computed&&this.nameIsConstructor(Z.key))this.raise(m.ConstructorClassField,Z.key);D.body.push(this.parseClassProperty(Z))}pushClassPrivateProperty(D,Z){let $=this.parseClassPrivateProperty(Z);D.body.push($),this.classScope.declarePrivateName(this.getPrivateNameSV($.key),0,$.key.start)}pushClassAccessorProperty(D,Z,$){if(!$&&!Z.computed&&this.nameIsConstructor(Z.key))this.raise(m.ConstructorClassField,Z.key);let J=this.parseClassAccessorProperty(Z);if(D.body.push(J),$)this.classScope.declarePrivateName(this.getPrivateNameSV(J.key),0,J.key.start)}pushClassMethod(D,Z,$,J,Q,X){D.body.push(this.parseMethod(Z,$,J,Q,X,"ClassMethod",!0))}pushClassPrivateMethod(D,Z,$,J){let Q=this.parseMethod(Z,$,J,!1,!1,"ClassPrivateMethod",!0);D.body.push(Q);let X=Q.kind==="get"?Q.static?6:2:Q.kind==="set"?Q.static?5:1:0;this.declareClassPrivateMethodInScope(Q,X)}declareClassPrivateMethodInScope(D,Z){this.classScope.declarePrivateName(this.getPrivateNameSV(D.key),Z,D.key.start)}parsePostMemberNameModifiers(D){}parseClassPrivateProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassPrivateProperty")}parseClassProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassProperty")}parseClassAccessorProperty(D){return this.parseInitializer(D),this.semicolon(),this.finishNode(D,"ClassAccessorProperty")}parseInitializer(D){this.scope.enter(592),this.expressionScope.enter(cG()),this.prodParam.enter(0),D.value=this.eat(25)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(D,Z,$,J=8331){if(iD(this.state.type)){if(D.id=this.parseIdentifier(),Z)this.declareNameFromIdentifier(D.id,J)}else if($||!Z)D.id=null;else throw this.raise(m.MissingClassName,this.state.startLoc)}parseClassSuper(D){if(this.eat(77))this.state.canStartArrow=!1,D.superClass=this.parseExprSubscripts();else D.superClass=null}parseExport(D,Z){let $=this.parseMaybeImportPhase(D,!0),J=this.maybeParseExportDefaultSpecifier(D,$),Q=!J||this.eat(8),X=Q&&this.eatExportStar(D),W=X&&this.maybeParseExportNamespaceSpecifier(D),G=Q&&(!W||this.eat(8)),Y=J||X;if(X&&!W){if(J)this.unexpected();if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);return this.parseExportFrom(D,!0),this.sawUnambiguousESM=!0,this.finishNode(D,"ExportAllDeclaration")}let B=this.maybeParseExportNamedSpecifiers(D);if(J&&Q&&!X&&!B)this.unexpected(null,2);if(W&&G)this.unexpected(null,94);let H;if(Y||B){if(H=!1,Z)throw this.raise(m.UnsupportedDecoratorExport,D);this.parseExportFrom(D,Y)}else H=this.maybeParseExportDeclaration(D);if(Y||B||H){let K=D;if(this.checkNamedExport(K,!!K.source),K.declaration?.type==="ClassDeclaration")this.maybeTakeDecorators(Z,K.declaration,K);else if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);return this.sawUnambiguousESM=!0,this.finishNode(K,"ExportNamedDeclaration")}if(this.eat(61)){let K=D,z=this.parseExportDefaultExpression();if(K.declaration=z,z.type==="ClassDeclaration")this.maybeTakeDecorators(Z,z,K);else if(Z)throw this.raise(m.UnsupportedDecoratorExport,D);if(this.checkDuplicateExports(D,"default"),this.hasPlugin("exportDefaultFrom")){if(z.type==="Identifier"&&z.name==="from"&&z.end-z.start===4&&!z.extra?.parenthesized)this.raise(m.ExportDefaultFromAsIdentifier,z)}return this.sawUnambiguousESM=!0,this.finishNode(K,"ExportDefaultDeclaration")}throw this.unexpected(null,2)}eatExportStar(D){return this.eat(51)}maybeParseExportDefaultSpecifier(D,Z){if(Z||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",Z?.start);let $=Z||this.parseIdentifier(!0),J=this.startNodeAtNode($);return J.exported=$,D.specifiers=[this.finishNode(J,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(D){if(this.isContextual(89)){D.specifiers??=[];let Z=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),Z.exported=this.parseModuleExportName(),D.specifiers.push(this.finishNode(Z,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(D){if(this.match(2)){let Z=D;if(!Z.specifiers)Z.specifiers=[];let $=Z.exportKind==="type";return Z.specifiers.push(...this.parseExportSpecifiers($)),Z.source=null,Z.attributes=[],Z.declaration=null,!0}return!1}maybeParseExportDeclaration(D){if(this.shouldParseExportDeclaration())return D.specifiers=[],D.source=null,D.attributes=[],D.declaration=this.parseExportDeclaration(D),!0;return!1}isAsyncFunction(){if(!this.isContextual(91))return!1;let D=this.nextTokenInLineStart();return this.isUnparsedContextual(D,"function")}parseExportDefaultExpression(){let D=this.startNode();if(this.match(64))return this.next(),this.parseFunction(D,5);else if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(D,13);if(this.match(76))return this.parseClass(D,!0,!0);if(this.match(22))return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(71)||this.match(70)||this.isLet()||this.isUsing()||this.isAwaitUsing())throw this.raise(m.UnsupportedDefaultExport,this.state.startLoc);let Z=this.parseMaybeAssignAllowIn();return this.semicolon(),Z}parseExportDeclaration(D){if(this.match(76))return this.parseClass(this.startNode(),!0,!1);return this.parseStatementListItem()}isExportDefaultSpecifier(){let{type:D}=this.state;if(iD(D)){if(D===91&&!this.state.containsEsc||D===96)return!1;if((D===126||D===125)&&!this.state.containsEsc){let J=this.nextTokenStart(),Q=this.input.charCodeAt(J);if(Q===123||this.chStartsBindingIdentifier(Q,J)&&!this.input.startsWith("from",J))return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(61))return!1;let Z=this.nextTokenStart(),$=this.isUnparsedContextual(Z,"from");if(this.input.charCodeAt(Z)===44||iD(this.state.type)&&$)return!0;if(this.match(61)&&$){let J=this.input.charCodeAt(this.nextTokenStartSince(Z+4));return J===34||J===39}return!1}parseExportFrom(D,Z){if(this.eatContextual(94))D.source=this.parseImportSource(),this.maybeParseImportAttributes(D);else if(Z)this.unexpected();this.semicolon()}shouldParseExportDeclaration(){let{type:D}=this.state;if(D===22){if(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))return!0}if(this.isUsing())return this.raise(m.UsingDeclarationExport,this.state.startLoc),!0;if(this.isAwaitUsing())return this.raise(m.UsingDeclarationExport,this.state.startLoc),!0;return D===70||D===71||D===64||D===76||this.isLet()||this.isAsyncFunction()}checkNamedExport(D,Z){if(D.specifiers?.length)for(let $ of D.specifiers){let{exported:J}=$,Q=J.type==="Identifier"?J.name:J.value;if(this.checkDuplicateExports($,Q),!Z&&$.type==="ExportSpecifier"){let{local:X}=$;if(X.type!=="Identifier")this.raise(m.ExportBindingIsString,$,{localName:X.value,exportName:Q});else this.checkReservedWord(X.name,X.start,!0,!1),this.scope.checkLocalExport(X)}}else if(D.declaration){let $=D.declaration;if($.type==="FunctionDeclaration"||$.type==="ClassDeclaration"){let{id:J}=$;if(!J)throw Error("Assertion failure");this.checkDuplicateExports(D,J.name)}else if($.type==="VariableDeclaration")for(let J of $.declarations)this.checkDeclaration(J.id)}}checkDeclaration(D){if(D.type==="Identifier")this.checkDuplicateExports(D,D.name);else if(D.type==="ObjectPattern")for(let Z of D.properties)this.checkDeclaration(Z);else if(D.type==="ArrayPattern"){for(let Z of D.elements)if(Z)this.checkDeclaration(Z)}else if(D.type==="ObjectProperty")this.checkDeclaration(D.value);else if(D.type==="RestElement")this.checkDeclaration(D.argument);else if(D.type==="AssignmentPattern")this.checkDeclaration(D.left)}checkDuplicateExports(D,Z){if(this.exportedIdentifiers.has(Z))if(Z==="default")this.raise(m.DuplicateDefaultExport,D);else this.raise(m.DuplicateExport,D,{exportName:Z});this.exportedIdentifiers.add(Z)}parseExportSpecifiers(D){let Z=[],$=!0;this.expect(2);while(!this.eat(4)){if($)$=!1;else if(this.expect(8),this.eat(4))break;let J=this.isContextual(126),Q=this.match(130),X=this.startNode();X.local=this.parseModuleExportName(),Z.push(this.parseExportSpecifier(X,Q,D,J))}return Z}parseExportSpecifier(D,Z,$,J){if(this.eatContextual(89))D.exported=this.parseModuleExportName();else if(Z)D.exported=this.cloneStringLiteral(D.local);else if(!D.exported)D.exported=this.cloneIdentifier(D.local);return this.finishNode(D,"ExportSpecifier")}parseModuleExportName(){if(this.match(130)){let D=this.parseStringLiteral(this.state.value),Z=Em.exec(D.value);if(Z)this.raise(m.ModuleExportNameHasLoneSurrogate,D,{surrogateCharCode:Z[0].charCodeAt(0)});return D}return this.parseIdentifier(!0)}checkImportPhase(D){let{specifiers:Z}=D,$=Z.length===1?Z[0].type:null;if(D.phase==="source"){if($!=="ImportDefaultSpecifier")this.raise(m.SourcePhaseImportRequiresDefault,Z[0])}else if(D.phase==="defer"){if($!=="ImportNamespaceSpecifier")this.raise(m.DeferImportRequiresNamespace,Z[0])}}isPotentialImportPhase(D){if(D)return!1;return this.isContextual(101)||this.isContextual(93)}applyImportPhase(D,Z,$,J){if(Z)return;if($==="source")this.expectPlugin("sourcePhaseImports",J),D.phase="source";else if($==="defer")this.expectPlugin("deferredImportEvaluation",J),D.phase="defer";else if(this.hasPlugin("sourcePhaseImports"))D.phase=null}parseMaybeImportPhase(D,Z){if(!this.isPotentialImportPhase(Z))return this.applyImportPhase(D,Z,null),null;let $=this.startNode(),J=this.parseIdentifierName(!0),{type:Q}=this.state;if(A0(Q)?Q!==94||this.lookaheadCharCode()===102:Q!==8)return this.applyImportPhase(D,Z,J,$.start),null;else return this.applyImportPhase(D,Z,null),this.createIdentifier($,J)}isPrecedingIdImportPhase(D){let{type:Z}=this.state;return iD(Z)?Z!==94||this.lookaheadCharCode()===102:Z!==8}parseImport(D){if(this.match(130))return this.parseImportSourceAndAttributes(D);return this.parseImportSpecifiersAndAfter(D,this.parseMaybeImportPhase(D,!1))}parseImportSpecifiersAndAfter(D,Z){D.specifiers=[];let J=!this.maybeParseDefaultImportSpecifier(D,Z)||this.eat(8),Q=J&&this.maybeParseStarImportSpecifier(D);if(J&&!Q)this.parseNamedImportSpecifiers(D);return this.expectContextual(94),this.parseImportSourceAndAttributes(D)}parseImportSourceAndAttributes(D){return D.specifiers??=[],D.source=this.parseImportSource(),this.maybeParseImportAttributes(D),this.checkImportPhase(D),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(D,"ImportDeclaration")}parseImportSource(){if(!this.match(130))this.unexpected();return this.parseExprAtom()}parseImportSpecifierLocal(D,Z,$){Z.local=this.parseIdentifier(),D.specifiers.push(this.finishImportSpecifier(Z,$))}finishImportSpecifier(D,Z,$=8201){return this.checkLVal(D.local,{type:Z},$),this.finishNode(D,Z)}parseImportAttributes(){this.expect(2);let D=[],Z=new Set;do{if(this.match(4))break;let $=this.startNode(),J=this.state.value;if(Z.has(J))this.raise(m.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:J});if(Z.add(J),this.match(130))$.key=this.parseStringLiteral(J);else $.key=this.parseIdentifier(!0);if(this.expect(10),!this.match(130))throw this.raise(m.ModuleAttributeInvalidValue,this.state.startLoc);$.value=this.parseStringLiteral(this.state.value),D.push(this.finishNode($,"ImportAttribute"))}while(this.eat(8));return this.expect(4),D}maybeParseImportAttributes(D){let Z;if(this.match(72)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),Z=this.parseImportAttributes()}else Z=[];D.attributes=Z}maybeParseDefaultImportSpecifier(D,Z){if(Z){let $=this.startNodeAtNode(Z);return $.local=Z,D.specifiers.push(this.finishImportSpecifier($,"ImportDefaultSpecifier")),!0}else if(A0(this.state.type))return this.parseImportSpecifierLocal(D,this.startNode(),"ImportDefaultSpecifier"),!0;return!1}maybeParseStarImportSpecifier(D){if(this.match(51)){let Z=this.startNode();return this.next(),this.expectContextual(89),this.parseImportSpecifierLocal(D,Z,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(D){let Z=!0;this.expect(2);while(!this.eat(4)){if(Z)Z=!1;else{if(this.eat(10))throw this.raise(m.DestructureNamedImport,this.state.startLoc);if(this.expect(8),this.eat(4))break}let $=this.startNode(),J=this.match(130),Q=this.isContextual(126);$.imported=this.parseModuleExportName();let X=this.parseImportSpecifier($,J,D.importKind==="type"||D.importKind==="typeof",Q,void 0);D.specifiers.push(X)}}parseImportSpecifier(D,Z,$,J,Q){if(this.eatContextual(89))D.local=this.parseIdentifier();else{let{imported:X}=D;if(Z)throw this.raise(m.ImportBindingIsString,D,{importName:X.value});if(this.checkReservedWord(X.name,D.start,!0,!0),!D.local)D.local=this.cloneIdentifier(X)}return this.finishImportSpecifier(D,"ImportSpecifier",Q)}isThisParam(D){return D.type==="Identifier"&&D.name==="this"}}var vG=/in(?:stanceof)?|as|satisfies/y;function wm(D){if(D==null)throw Error(`Unexpected ${D} value.`);return D}function pN(D){if(!D)throw Error("Assert fail")}var xm={AbstractMethodHasImplementation:({methodName:D})=>`Method '${D}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:D})=>`Property '${D}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",AccessorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccessorCannotHaveTypeParameters:"An accessor cannot have type parameters.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclaratorDefiniteAssertionRequiresTypeAnnotation:"Declarations with definite assignment assertions must also have type annotations.",DeclaratorDefiniteAssertionWithInitializer:"Declarations with initializers cannot also have definite assignment assertions.",DeclareAccessor:({kind:D})=>`'declare' is not allowed in ${D}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DecoratorAbstractMethod:({kind:D})=>`Decorators can't be used with ${D.startsWith("a")?"an":"a"} ${D}.`,DuplicateAccessibilityModifier:({modifier:D})=>`Accessibility modifier already seen: '${D}'.`,DuplicateModifier:({modifier:D})=>`Duplicate modifier: '${D}'.`,EmptyHeritageClauseType:({token:D})=>`'${D}' list cannot be empty.`,EmptyNamespaceName:"Namespace must be given a name.",EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ExportAssignmentInTSNamespace:"An export assignment cannot be used in a namespace.",ExportInTSNamespace:"Export declarations are not permitted in a namespace.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportInTSNamespace:"Import declarations in a namespace cannot reference a module.",IncompatibleModifiers:({modifiers:D})=>`'${D[0]}' modifier cannot be used with '${D[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:D})=>`Index signatures cannot have an accessibility modifier ('${D}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InlineModuleDeclarationMustUseString:"`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",InvalidHeritageClauseType:({token:D})=>`'${D}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnAwaitUsingDeclaration:(D)=>`'${D}' modifier cannot appear on an await using declaration.`,InvalidModifierOnTypeMember:({modifier:D})=>`'${D}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:D})=>`'${D}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:D})=>`'${D}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifierOnUsingDeclaration:(D)=>`'${D}' modifier cannot appear on a using declaration.`,InvalidModifiersOrder:({orderedModifiers:D})=>`'${D[0]}' modifier must precede '${D[1]}' modifier.`,InvalidNamespaceName:(D)=>`Namespace name cannot be '${D}'.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NamespaceExportInTSNamespace:"Global module exports may only appear at top level.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifier:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:D})=>`Private elements cannot have an accessibility modifier ('${D}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccessorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccessorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:D})=>`Single type parameter ${D} should have a trailing comma. Example usage: <${D},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterInitializer:"A parameter initializer is only allowed in a function or constructor implementation.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnexpectedTypeDeclaration:(D)=>`'${D}' declarations can only be declared inside a block.`,UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:D})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${D}.`,UsingDeclarationInAmbientContext:(D)=>`'${D}' declarations are not allowed in ambient contexts.`},$D=z8`typescript`(xm);function bm(D){switch(D){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}function cN(D){return D==="private"||D==="public"||D==="protected"}function km(D){return D==="in"||D==="out"}function sG(D){if(D.extra?.parenthesized)return!1;switch(D.type){case"Identifier":return!0;case"MemberExpression":return!D.computed&&sG(D.object);case"TSInstantiationExpression":return sG(D.expression);default:return!1}}var gm=a1(["declare","private","public","protected","override","abstract","readonly","static"],["in","out"]),fm=a1(["readonly"],["declare","abstract","private","protected","public","static","override"]),ym=a1(["public","private","protected","override","readonly"]),hm=a1(["private","public","protected"]),mm=(D)=>class Z extends D{getScopeHandler(){return X_}tsIsIdentifier(){return iD(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(2)||this.match(51)||this.match(17)||this.match(134)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){if(this.next(),this.hasPrecedingLineBreak())return!1;return this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){if(this.match(102))return this.next(),this.tsTokenCanFollowModifier();return this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier($,J,Q){if(!iD(this.state.type)&&this.state.type!==54&&this.state.type!==71)return;let X=this.state.value;if($.has(X)){if(Q&&this.match(102))return;if(J&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return X}return}tsParseModifiers($,J=$D.InvalidModifierOnTypeMember,Q,X=!1){let W=(Y,B,H,K)=>{if(B===H&&Q[K])this.raise($D.InvalidModifiersOrder,Y,{orderedModifiers:[H,K]})},G=(Y,B,H,K)=>{if(Q[H]&&B===K||Q[K]&&B===H)this.raise($D.IncompatibleModifiers,Y,{modifiers:[H,K]})};for(;;){let{startLoc:Y}=this.state,B=this.tsParseModifier($,X,Q.static);if(!B)break;if(cN(B))if(Q.accessibility)this.raise($D.DuplicateAccessibilityModifier,Y,{modifier:B});else W(Y,B,B,"override"),W(Y,B,B,"static"),W(Y,B,B,"readonly"),Q.accessibility=B;else if(km(B)){if(Q[B])this.raise($D.DuplicateModifier,Y,{modifier:B});Q[B]=!0,W(Y,B,"in","out")}else{if(Object.hasOwn(Q,B))this.raise($D.DuplicateModifier,Y,{modifier:B});else W(Y,B,"static","readonly"),W(Y,B,"static","override"),W(Y,B,"override","readonly"),W(Y,B,"abstract","override"),G(Y,B,"declare","override"),G(Y,B,"static","abstract");Q[B]=!0}if(!$.get(B))this.raise(J,Y,{modifier:B})}}tsIsListTerminator($){switch($){case"EnumMembers":case"TypeMembers":return this.match(4);case"HeritageClauseElement":return this.match(2);case"TupleElementTypes":return this.match(1);case"TypeParametersOrArguments":return this.match(44)}}tsParseList($,J){let Q=[];while(!this.tsIsListTerminator($))Q.push(J());return Q}tsParseDelimitedList($,J,Q){return wm(this.tsParseDelimitedListWorker($,J,!0,Q))}tsParseDelimitedListWorker($,J,Q,X){let W=[],G=-1;for(;;){if(this.tsIsListTerminator($))break;G=-1;let Y=J();if(Y==null)return;if(W.push(Y),this.eat(8)){G=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator($))break;if(Q)this.expect(8);return}if(X)X.value=G;return W}tsParseBracketedList($,J,Q,X,W){if(!X)if(Q)this.expect(0);else this.expect(43);let G=this.tsParseDelimitedList($,J,W);if(Q)this.expect(1);else this.expect(44);return G}tsParseImportType(){let $=this.startNode();if(this.expect(79),this.expect(6),!this.match(130))this.raise($D.UnsupportedImportTypeArgument,this.state.startLoc),$.source=this.tsParseNonConditionalType();else $.source=this.parseStringLiteral(this.state.value);if(this.eat(8))$.options=this.tsParseImportTypeOptions();else $.options=null;if(this.expect(7),this.eat(12))$.qualifier=this.tsParseEntityName(3);if(this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSImportType")}tsParseImportTypeOptions(){let $=this.startNode();this.expect(2);let J=this.startNode();if(this.isContextual(72))J.method=!1,J.key=this.parseIdentifier(!0),J.computed=!1,J.shorthand=!1;else this.unexpected(null,72);return this.expect(10),J.value=this.tsParseImportTypeWithPropertyValue(),$.properties=[this.finishObjectProperty(J)],this.eat(8),this.expect(4),this.finishNode($,"ObjectExpression")}tsParseImportTypeWithPropertyValue(){let $=this.startNode(),J=[];this.expect(2);while(!this.match(4)){let Q=this.state.type;if(iD(Q)||Q===130)J.push(super.parsePropertyDefinition(null));else this.unexpected();this.eat(8)}return $.properties=J,this.next(),this.finishNode($,"ObjectExpression")}tsParseEntityName($){let J;if($&1&&this.match(74))if($&2)J=this.parseIdentifier(!0);else{let Q=this.startNode();this.next(),J=this.finishNode(Q,"ThisExpression")}else J=this.parseIdentifier(!!($&1));while(this.eat(12)){let Q=this.startNodeAtNode(J);Q.left=J,Q.right=this.parseIdentifier(!!($&1)),J=this.finishNode(Q,"TSQualifiedName")}return J}tsParseTypeReference(){let $=this.startNode();if($.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSTypeReference")}tsParseThisTypePredicate($){this.next();let J=this.startNodeAtNode($);return J.parameterName=$,J.typeAnnotation=this.tsParseTypeAnnotation(!1),J.asserts=!1,this.finishNode(J,"TSTypePredicate")}tsParseThisTypeNode(){let $=this.startNode();return this.next(),this.finishNode($,"TSThisType")}tsParseTypeQuery(){let $=this.startNode();if(this.expect(83),this.match(79))$.exprName=this.tsParseImportType();else $.exprName=this.tsParseEntityName(1);if(!this.hasPrecedingLineBreak()&&this.match(43))$.typeArguments=this.tsParseTypeArguments();return this.finishNode($,"TSTypeQuery")}tsParseInOutModifiers=this.tsParseModifiers.bind(this,a1(["in","out"],["const","public","private","protected","readonly","declare","abstract","override"]),$D.InvalidModifierOnTypeParameter);tsParseConstModifier=this.tsParseModifiers.bind(this,a1(["const"],["in","out"]),$D.InvalidModifierOnTypeParameterPositions);tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,a1(["in","out","const"],["public","private","protected","readonly","declare","abstract","override"]),$D.InvalidModifierOnTypeParameter);tsParseTypeParameter($){let J=this.startNode();return $(J),J.name=this.tsParseTypeParameterName(),J.constraint=this.tsEatThenParseType(77),J.default=this.tsEatThenParseType(25),this.finishNode(J,"TSTypeParameter")}tsTryParseTypeParameters($){if(this.match(43))return this.tsParseTypeParameters($)}tsParseTypeParameters($){let J=this.startNode();if(this.match(43)||this.match(138))this.next();else this.unexpected();let Q={value:-1};if(J.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,$),!1,!0,Q),J.params.length===0)this.raise($D.EmptyTypeParameters,J);if(Q.value!==-1)this.addExtra(J,"trailingComma",Q.value);return this.finishNode(J,"TSTypeParameterDeclaration")}tsFillSignature($,J){let Q=$===15,X="params",W="returnType";if(J.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(6),J.params=this.tsParseBindingListForSignature(),Q)J.returnType=this.tsParseTypeOrTypePredicateAnnotation($);else if(this.match($))J.returnType=this.tsParseTypeOrTypePredicateAnnotation($)}tsParseBindingListForSignature(){let $=super.parseBindingList(7,41,2);for(let J of $){let{type:Q}=J;if(Q==="AssignmentPattern"||Q==="TSParameterProperty")this.raise($D.UnsupportedSignatureParameterKind,J,{type:Q})}return $}tsParseTypeMemberSemicolon(){if(!this.eat(8)&&!this.isLineTerminator())this.expect(9)}tsParseSignatureMember($,J){return this.tsFillSignature(10,J),this.tsParseTypeMemberSemicolon(),this.finishNode(J,$)}tsIsUnambiguouslyIndexSignature(){if(this.next(),iD(this.state.type))return this.next(),this.match(10);return!1}tsTryParseIndexSignature($){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);let J=this.parseIdentifier();J.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(J),this.expect(1),$.parameters=[J];let Q=this.tsTryParseTypeAnnotation();if(Q)$.typeAnnotation=Q;return this.tsParseTypeMemberSemicolon(),this.finishNode($,"TSIndexSignature")}tsParsePropertyOrMethodSignature($,J){if(this.eat(13))$.optional=!0;if(this.match(6)||this.match(43)){if(J)this.raise($D.ReadonlyForMethodSignature,$);let Q=$;if(Q.kind&&this.match(43))this.raise($D.AccessorCannotHaveTypeParameters,this.state.curPosition());if(this.tsFillSignature(10,Q),this.tsParseTypeMemberSemicolon(),Q.kind==="get"){if(Q.params.length>0){if(this.raise(m.BadGetterArity,this.state.curPosition()),this.isThisParam(Q.params[0]))this.raise($D.AccessorCannotDeclareThisParameter,this.state.curPosition())}}else if(Q.kind==="set"){if(Q.params.length!==1)this.raise(m.BadSetterArity,this.state.curPosition());else{let X=Q.params[0];if(this.isThisParam(X))this.raise($D.AccessorCannotDeclareThisParameter,this.state.curPosition());if(X.type==="Identifier"&&X.optional)this.raise($D.SetAccessorCannotHaveOptionalParameter,this.state.curPosition());if(X.type==="RestElement")this.raise($D.SetAccessorCannotHaveRestParameter,this.state.curPosition())}if(Q.returnType)this.raise($D.SetAccessorCannotHaveReturnType,Q.returnType)}else Q.kind="method";return this.finishNode(Q,"TSMethodSignature")}else{let Q=$;if(J)Q.readonly=!0;let X=this.tsTryParseTypeAnnotation();if(X)Q.typeAnnotation=X;return this.tsParseTypeMemberSemicolon(),this.finishNode(Q,"TSPropertySignature")}}tsParseTypeMember(){let $=this.startNode();if(this.match(6)||this.match(43))return this.tsParseSignatureMember("TSCallSignatureDeclaration",$);if(this.match(73)){let Q=this.startNode();if(this.next(),this.match(6)||this.match(43))return this.tsParseSignatureMember("TSConstructSignatureDeclaration",$);else return $.key=this.createIdentifier(Q,"new"),this.tsParsePropertyOrMethodSignature($,!1)}this.tsParseModifiers(fm,void 0,$);let J=this.tsTryParseIndexSignature($);if(J)return J;if(super.parsePropertyName($),!$.computed&&$.key.type==="Identifier"&&($.key.name==="get"||$.key.name==="set")&&this.tsTokenCanFollowModifier()){if($.kind=$.key.name,super.parsePropertyName($),!this.match(6)&&!this.match(43))this.unexpected(null,6)}return this.tsParsePropertyOrMethodSignature($,!!$.readonly)}tsParseTypeLiteral(){let $=this.startNode();return $.members=this.tsParseObjectTypeMembers(),this.finishNode($,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(2);let $=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(4),$}tsIsStartOfMappedType(){if(this.next(),this.eat(49))return this.isContextual(118);if(this.isContextual(118))this.next();if(!this.match(0))return!1;if(this.next(),!this.tsIsIdentifier())return!1;return this.next(),this.match(54)}tsParseMappedType(){let $=this.startNode();if(this.expect(2),this.match(49))$.readonly=this.state.value,this.next(),this.expectContextual(118);else if(this.eatContextual(118))$.readonly=!0;if(this.expect(0),$.key=this.tsParseTypeParameterName(),$.constraint=this.tsExpectThenParseType(54),$.nameType=this.eatContextual(89)?this.tsParseType():null,this.expect(1),this.match(49))$.optional=this.state.value,this.next(),this.expect(13);else if(this.eat(13))$.optional=!0;return $.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(4),this.finishNode($,"TSMappedType")}tsParseTupleType(){let $=this.startNode();$.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let J=!1;return $.elementTypes.forEach((Q)=>{let{type:X}=Q;if(J&&X!=="TSRestType"&&X!=="TSOptionalType"&&!(X==="TSNamedTupleMember"&&Q.optional))this.raise($D.OptionalTypeBeforeRequired,Q);J||=X==="TSNamedTupleMember"&&Q.optional||X==="TSOptionalType"}),this.finishNode($,"TSTupleType")}tsParseTupleElementType(){let $=this.state.startLoc,J=this.eat(17),{startLoc:Q}=this.state,X,W,G,Y,H=A0(this.state.type)?this.lookaheadCharCode():null;if(H===58)X=!0,G=!1,W=this.parseIdentifier(!0),this.expect(10),Y=this.tsParseType();else if(H===63){G=!0;let K=this.state.value,z=this.tsParseNonArrayType();if(this.lookaheadCharCode()===58)X=!0,W=this.createIdentifier(this.startNodeAt(Q),K),this.expect(13),this.expect(10),Y=this.tsParseType();else X=!1,Y=z,this.expect(13)}else Y=this.tsParseType(),G=this.eat(13),X=this.eat(10);if(X){let K;if(W){if(K=this.startNodeAt(Q),K.optional=G,K.label=W,K.elementType=Y,this.eat(13))K.optional=!0,this.raise($D.TupleOptionalAfterType,this.state.lastTokStartLoc)}else K=this.startNodeAt(Q),K.optional=G,this.raise($D.InvalidTupleMemberLabel,Y),K.label=Y,K.elementType=this.tsParseType();Y=this.finishNode(K,"TSNamedTupleMember")}else if(G){let K=this.startNodeAt(Q);K.typeAnnotation=Y,Y=this.finishNode(K,"TSOptionalType")}if(J){let K=this.startNodeAt($);K.typeAnnotation=Y,Y=this.finishNode(K,"TSRestType")}return Y}tsParseParenthesizedType(){let $=this.startNode();return this.expect(6),$.typeAnnotation=this.tsParseType(),this.expect(7),this.finishNode($,"TSParenthesizedType")}tsParseFunctionOrConstructorType($,J){let Q=this.startNode();if($==="TSConstructorType"){if(Q.abstract=!!J,J)this.next();this.next()}return this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(15,Q)),this.finishNode(Q,$)}tsParseLiteralTypeNode(){let $=this.startNode();switch(this.state.type){case 131:case 132:case 130:case 81:case 82:$.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode($,"TSLiteralType")}tsParseTemplateLiteralType(){let $=this.state.startLoc,J=this.parseTemplateElement(!1),Q=[J];if(J.tail){let X=this.startNodeAt($),W=this.startNodeAt($);return W.expressions=[],W.quasis=Q,X.literal=this.finishNode(W,"TemplateLiteral"),this.finishNode(X,"TSLiteralType")}else{let X=[];while(!J.tail)X.push(this.tsParseType()),this.readTemplateContinuation(),Q.push(J=this.parseTemplateElement(!1));let W=this.startNodeAt($);return W.types=X,W.quasis=Q,this.finishNode(W,"TSTemplateLiteralType")}}parseTemplateSubstitution(){if(this.state.inType)return this.tsParseType();return super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){let $=this.tsParseThisTypeNode();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.tsParseThisTypePredicate($);else return $}tsParseNonArrayType(){switch(this.state.type){case 130:case 131:case 132:case 81:case 82:return this.tsParseLiteralTypeNode();case 49:if(this.state.value==="-"){let $=this.startNode(),J=this.lookahead();if(J.type!==131&&J.type!==132)this.unexpected();return $.literal=this.parseMaybeUnary(),this.finishNode($,"TSLiteralType")}break;case 74:return this.tsParseThisTypeOrThisTypePredicate();case 83:return this.tsParseTypeQuery();case 79:return this.tsParseImportType();case 2:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 6:if(!(this.optionFlags&2048)){let $=this.state.startLoc;this.next();let J=this.tsParseType();return this.expect(7),this.addExtra(J,"parenthesized",!0),this.addExtra(J,"parenStart",$.index),J}return this.tsParseParenthesizedType();case 21:case 20:return this.tsParseTemplateLiteralType();default:{let{type:$}=this.state;if(iD($)||$===84||$===80){let J=$===84?"TSVoidKeyword":$===80?"TSNullKeyword":bm(this.state.value);if(J!==void 0&&this.lookaheadCharCode()!==46){let Q=this.startNode();return this.next(),this.finishNode(Q,J)}return this.tsParseTypeReference()}}}throw this.unexpected()}tsParseArrayTypeOrHigher(){let{startLoc:$}=this.state,J=this.tsParseNonArrayType();while(!this.hasPrecedingLineBreak()&&this.eat(0))if(this.match(1)){let Q=this.startNodeAt($);Q.elementType=J,this.expect(1),J=this.finishNode(Q,"TSArrayType")}else{let Q=this.startNodeAt($);Q.objectType=J,Q.indexType=this.tsParseType(),this.expect(1),J=this.finishNode(Q,"TSIndexedAccessType")}return J}tsParseTypeOperator(){let $=this.startNode(),J=this.state.value;if(this.next(),$.operator=J,$.typeAnnotation=this.tsParseTypeOperatorOrHigher(),J==="readonly")this.tsCheckTypeAnnotationForReadOnly($);return this.finishNode($,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly($){switch($.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise($D.UnexpectedReadonly,$)}}tsParseInferType(){let $=this.startNode();this.expectContextual(111);let J=this.startNode();return J.name=this.tsParseTypeParameterName(),J.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),$.typeParameter=this.finishNode(J,"TSTypeParameter"),this.finishNode($,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(77)){let $=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(13))return $}}tsParseTypeOperatorOrHigher(){return eh(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(111)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType($,J,Q){let X=this.startNode(),W=this.eat(Q),G=[];do G.push(J());while(this.eat(Q));if(G.length===1&&!W)return G[0];return X.types=G,this.finishNode(X,$)}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),41)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),39)}tsIsStartOfFunctionType(){if(this.match(43))return!0;return this.match(6)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(iD(this.state.type)||this.match(74))return this.next(),!0;if(this.match(2)){let{errors:$}=this.state,J=$.length;try{return this.parseObjectLike(4,!0),$.length===J}catch{return!1}}if(this.match(0)){this.next();let{errors:$}=this.state,J=$.length;try{return super.parseBindingList(1,93,1),$.length===J}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){if(this.next(),this.match(7)||this.match(17))return!0;if(this.tsSkipParameterStart()){if(this.match(10)||this.match(8)||this.match(13)||this.match(25))return!0;if(this.match(7)){if(this.next(),this.match(15))return!0}}return!1}tsParseTypeOrTypePredicateAnnotation($){return this.tsInType(()=>{let J=this.startNode();this.expect($);let Q=this.startNode(),X=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(X&&this.match(74)){let Y=this.tsParseThisTypeOrThisTypePredicate();if(Y.type==="TSThisType")Q.parameterName=Y,Q.asserts=!0,Q.typeAnnotation=null,Y=this.finishNode(Q,"TSTypePredicate");else this.resetStartLocationFromNode(Y,Q),Y.asserts=!0;return J.typeAnnotation=Y,this.finishNode(J,"TSTypeAnnotation")}let W=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!W){if(!X)return this.tsParseTypeAnnotation(!1,J);return Q.parameterName=this.parseIdentifier(),Q.asserts=X,Q.typeAnnotation=null,J.typeAnnotation=this.finishNode(Q,"TSTypePredicate"),this.finishNode(J,"TSTypeAnnotation")}let G=this.tsParseTypeAnnotation(!1);return Q.parameterName=W,Q.typeAnnotation=G,Q.asserts=X,J.typeAnnotation=this.finishNode(Q,"TSTypePredicate"),this.finishNode(J,"TSTypeAnnotation")})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(10))return this.tsParseTypeOrTypePredicateAnnotation(10)}tsTryParseTypeAnnotation(){if(this.match(10))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(10)}tsParseTypePredicatePrefix(){let $=this.parseIdentifier();if(this.isContextual(112)&&!this.hasPrecedingLineBreak())return this.next(),$}tsParseTypePredicateAsserts(){if(this.state.type!==105)return!1;let $=this.state.containsEsc;if(this.next(),!iD(this.state.type)&&!this.match(74))return!1;if($)this.raise(m.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"});return!0}tsParseTypeAnnotation($=!0,J=this.startNode()){return this.tsInType(()=>{if($)this.expect(10);J.typeAnnotation=this.tsParseType()}),this.finishNode(J,"TSTypeAnnotation")}tsParseType(){pN(this.state.inType);let $=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(77))return $;let J=this.startNodeAtNode($);return J.checkType=$,J.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(13),J.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(10),J.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(J,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(120)&&this.isLookaheadContextual("new")}tsParseNonConditionalType(){if(this.tsIsStartOfFunctionType())return this.tsParseFunctionOrConstructorType("TSFunctionType");if(this.match(73))return this.tsParseFunctionOrConstructorType("TSConstructorType");else if(this.isAbstractConstructorSignature())return this.tsParseFunctionOrConstructorType("TSConstructorType",!0);return this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){if(this.getPluginOption("typescript","disallowAmbiguousJSXLike"))this.raise($D.ReservedTypeAssertion,this.state.startLoc);let $=this.startNode();return $.typeAnnotation=this.tsInType(()=>{return this.next(),this.match(71)?this.tsParseTypeReference():this.tsParseType()}),this.expect(44),$.expression=this.parseMaybeUnary(),this.finishNode($,"TSTypeAssertion")}tsParseHeritageClause($){let J=this.state.startLoc,Q=this.tsParseDelimitedList("HeritageClauseElement",()=>{let X=(this.state.canStartArrow=!1,super.parseExprSubscripts());if(!sG(X))this.raise($D.InvalidHeritageClauseType,X.start,{token:$});let W=$==="extends"?"TSInterfaceHeritage":"TSClassImplements";if(X.type==="TSInstantiationExpression")return X.type=W,X;let G=this.startNodeAtNode(X);if(G.expression=X,this.match(43)||this.match(47))G.typeArguments=this.tsParseTypeArgumentsInExpression();return this.finishNode(G,W)});if(!Q.length)this.raise($D.EmptyHeritageClauseType,J,{token:$});return Q}tsParseInterfaceDeclaration($,J={}){if(this.hasFollowingLineBreak())return null;if(this.expectContextual(125),J.declare)$.declare=!0;if(iD(this.state.type))$.id=this.parseIdentifier(),this.checkIdentifier($.id,130);else $.id=null,this.raise($D.MissingInterfaceName,this.state.startLoc);if($.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(77))$.extends=this.tsParseHeritageClause("extends");let Q=this.startNode();return Q.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),$.body=this.finishNode(Q,"TSInterfaceBody"),this.finishNode($,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration($){return $.id=this.parseIdentifier(),this.checkIdentifier($.id,2),$.typeAnnotation=this.tsInType(()=>{if($.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(25),this.isContextual(110)&&this.lookaheadCharCode()!==46){let J=this.startNode();return this.next(),this.finishNode(J,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode($,"TSTypeAliasDeclaration")}tsInTopLevelContext($){if(this.curContext()!==Y2.brace){let J=this.state.context;this.state.context=[J[0]];try{return $()}finally{this.state.context=J}}else return $()}tsInType($){let J=this.state.inType;this.state.inType=!0;try{return $()}finally{this.state.inType=J}}tsInDisallowConditionalTypesContext($){let J=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return $()}finally{this.state.inDisallowConditionalTypesContext=J}}tsInAllowConditionalTypesContext($){let J=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return $()}finally{this.state.inDisallowConditionalTypesContext=J}}tsEatThenParseType($){if(this.match($))return this.tsNextThenParseType()}tsExpectThenParseType($){return this.tsInType(()=>{return this.expect($),this.tsParseType()})}tsNextThenParseType(){return this.tsInType(()=>{return this.next(),this.tsParseType()})}tsParseEnumMember(){let $=this.startNode();if($.id=this.match(130)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(25))$.initializer=super.parseMaybeAssignAllowIn();return this.finishNode($,"TSEnumMember")}tsParseEnumDeclaration($,J={}){if(J.const)$.const=!0;if(J.declare)$.declare=!0;return this.expectContextual(122),$.id=this.parseIdentifier(),this.checkIdentifier($.id,$.const?8971:8459),$.body=this.tsParseEnumBody(),this.finishNode($,"TSEnumDeclaration")}tsParseEnumBody(){let $=this.startNode();return this.expect(2),$.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(4),this.finishNode($,"TSEnumBody")}tsParseModuleBlock($){let J=this.startNode();if(!$)this.scope.enter(0);if(this.expect(2),super.parseBlockOrModuleBlockBody(J.body=[],void 0,!0,4),!$)this.scope.exit();return this.finishNode(J,"TSModuleBlock")}tsParseNamespaceDeclaration($){if($.id=this.tsParseEntityName(0),$.id.type==="Identifier")this.checkIdentifier($.id,1024);return this.scope.enter(2048),this.prodParam.enter(0),$.body=this.tsParseModuleBlock(!1),this.prodParam.exit(),this.scope.exit(),this.finishNode($,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration($){let J=this.isContextual(108);if(J)$.kind="global",$.id=this.parseIdentifier();else{$.kind="module";let{type:Q,value:X}=this.state;if(Q===130)$.id=super.parseStringLiteral(X);else if(iD(Q))this.raise($D.InlineModuleDeclarationMustUseString,this.state.startLoc),$.id=this.tsParseEntityName(0);else if(Q===2)this.raise($D.EmptyNamespaceName,this.state.startLoc);else this.raise($D.InvalidNamespaceName,this.state.startLoc,X),$.id=super.parseExprAtom()}if(this.match(2)){if(!J)this.scope.enter(1024);if(this.prodParam.enter(0),$.body=this.tsParseModuleBlock(J),this.prodParam.exit(),!J)this.scope.exit()}else this.semicolon();return this.finishNode($,"TSModuleDeclaration")}tsParseImportEqualsDeclaration($,J){$.id=J||this.parseIdentifier(),this.checkIdentifier($.id,4096),this.expect(25);let Q=this.tsParseModuleReference();if($.importKind==="type"&&Q.type!=="TSExternalModuleReference")this.raise($D.ImportAliasHasImportType,Q);return $.moduleReference=Q,this.semicolon(),this.finishNode($,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(115)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){let $=this.startNode();if(this.expectContextual(115),this.expect(6),!this.match(130))this.unexpected();return $.expression=super.parseExprAtom(),this.expect(7),this.sawUnambiguousESM=!0,this.finishNode($,"TSExternalModuleReference")}tsLookAhead($){let J=this.state.clone(),Q=$();return this.state=J,Q}tsTryParseAndCatch($){let J=this.tryParse((Q)=>$()||Q());if(J.aborted||!J.node)return;if(J.error)this.state=J.failState;return J.node}tsTryParse($){let J=this.state.clone(),Q=$();if(Q!==void 0&&Q!==!1)return Q;this.state=J}tsTryParseDeclare($){if(this.isLineTerminator())return;let J=this.state.type;return this.tsInAmbientContext(()=>{switch(J){case 64:return $.declare=!0,super.parseFunctionStatement($,!1,!1);case 76:return $.declare=!0,this.parseClass($,!0,!1);case 122:return this.tsParseEnumDeclaration($,{declare:!0});case 108:return this.tsParseAmbientExternalModuleDeclaration($);case 96:if(this.state.containsEsc)return;case 71:case 70:if(!this.match(71)||!this.isLookaheadContextual("enum"))return $.declare=!0,this.parseVarStatement($,this.state.value,!0);return this.expect(71),this.tsParseEnumDeclaration($,{const:!0,declare:!0});case 103:if(this.isUsing())return this.raise($D.InvalidModifierOnUsingDeclaration,this.state.startLoc,"declare"),$.declare=!0,this.parseVarStatement($,"using",!0);break;case 92:if(this.isAwaitUsing())return this.raise($D.InvalidModifierOnAwaitUsingDeclaration,this.state.startLoc,"declare"),$.declare=!0,this.next(),this.parseVarStatement($,"await using",!0);break;case 125:{let Q=this.tsParseInterfaceDeclaration($,{declare:!0});if(Q)return Q}default:if(iD(J))return this.tsParseDeclaration($,this.state.type,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.type,!0,null)}tsParseDeclaration($,J,Q,X){switch(J){case 120:if(this.tsCheckLineTerminator(Q)&&(this.match(76)||iD(this.state.type)))return this.tsParseAbstractDeclaration($,X);break;case 123:if(this.tsCheckLineTerminator(Q))return this.tsParseAmbientExternalModuleDeclaration($);break;case 124:if(this.tsCheckLineTerminator(Q)&&iD(this.state.type))return $.kind="namespace",this.tsParseNamespaceDeclaration($);break;case 126:if(this.tsCheckLineTerminator(Q)&&iD(this.state.type))return this.tsParseTypeAliasDeclaration($);break}}tsCheckLineTerminator($){if($){if(this.hasFollowingLineBreak())return!1;return this.next(),!0}return!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction($){if(!this.match(43))return;let J=this.tsTryParseAndCatch(()=>{let Q=this.startNodeAt($);return Q.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(Q),Q.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(15),Q});if(!J)return;return super.parseArrowExpression(J,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()!==43)return;return this.tsParseTypeArguments()}tsParseTypeArguments(){let $=this.startNode();if($.params=this.tsInType(()=>this.tsInTopLevelContext(()=>{return this.expect(43),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))})),$.params.length===0)this.raise($D.EmptyTypeArguments,$);else if(!this.state.inType&&this.curContext()===Y2.brace)this.reScan_lt_gt();return this.expect(44),this.finishNode($,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return Dm(this.state.type)}isExportDefaultSpecifier(){if(this.tsIsDeclarationStart())return!1;return super.isExportDefaultSpecifier()}parseBindingElement($,J){let Q=J.length?null:this.state.startLoc,X={};this.tsParseModifiers(ym,void 0,X);let{accessibility:W,override:G,readonly:Y}=X;if(!($&4)&&(W||Y||G))this.raise($D.UnexpectedParameterModifier,Q||J[0]);let B=this.state.startLoc,H=this.parseMaybeDefault(B);if($&2)this.parseFunctionParamType(H);let K=this.parseMaybeDefault(B,H);if(W||Y||G){let z=Q?this.startNodeAt(Q):this.startNodeAtNode(J[0]);if(J.length)z.decorators=J;else this.setLoc(Q);if(W)z.accessibility=W;if(Y)z.readonly=Y;if(G)z.override=G;if(K.type!=="Identifier"&&K.type!=="AssignmentPattern")this.raise($D.UnsupportedParameterPropertyKind,Q||J[0]);return z.parameter=K,this.finishNode(z,"TSParameterProperty")}if(J.length)H.decorators=J;return K}isSimpleParameter($){return $.type==="TSParameterProperty"&&super.isSimpleParameter($.parameter)||super.isSimpleParameter($)}tsDisallowOptionalPattern($){for(let J of $.params)if(J.type!=="Identifier"&&J.optional&&!this.state.isAmbientContext)this.raise($D.PatternIsOptional,J)}setArrowFunctionParameters($,J,Q){super.setArrowFunctionParameters($,J,Q),this.tsDisallowOptionalPattern($)}parseFunctionBodyAndFinish($,J,Q=!1){if(this.match(10))$.returnType=this.tsParseTypeOrTypePredicateAnnotation(10);let X=J==="FunctionDeclaration"?"TSDeclareFunction":J==="ClassMethod"||J==="ClassPrivateMethod"?"TSDeclareMethod":void 0;if(X&&!this.match(2)&&this.isLineTerminator()){if(X==="TSDeclareMethod"&&$.kind==="constructor"){for(let W of $.params)if(W.type==="TSParameterProperty")this.raise($D.UnexpectedParameterModifier,W);else if(W.type==="AssignmentPattern")this.raise($D.UnexpectedParameterInitializer,W)}else for(let W of $.params)if(W.type==="AssignmentPattern")this.raise($D.UnexpectedParameterInitializer,W);return this.finishNode($,X)}if(X&&this.state.isAmbientContext){if(this.raise($D.DeclareFunctionHasImplementation,this.state.startLoc),X==="TSDeclareFunction"&&$.declare)return super.parseFunctionBodyAndFinish($,X,Q)}return this.tsDisallowOptionalPattern($),super.parseFunctionBodyAndFinish($,J,Q)}registerFunctionStatementId($){if(!$.body&&$.id)this.checkIdentifier($.id,1024);else super.registerFunctionStatementId($)}tsCheckForInvalidTypeCasts($){$.forEach((J)=>{if(J?.type==="TSTypeCastExpression")this.raise($D.UnexpectedTypeAnnotation,J.typeAnnotation)})}toReferencedList($,J){return this.tsCheckForInvalidTypeCasts($),$}parseArrayLike($,J){let Q=super.parseArrayLike($,J);if(Q.type==="ArrayExpression")this.tsCheckForInvalidTypeCasts(Q.elements);return Q}parseSubscript($,J,Q,X){if(!this.hasPrecedingLineBreak()&&this.match(31)){this.state.canStartJSXElement=!1,this.next();let G=this.startNodeAt(J);return G.expression=$,this.finishNode(G,"TSNonNullExpression")}let W=!1;if(this.match(14)&&this.lookaheadCharCode()===60){if(Q)return X.stop=!0,$;X.optionalChainMember=W=!0,this.next()}if(this.match(43)||this.match(47)){let G,Y=this.tsTryParseAndCatch(()=>{if(!Q&&this.atPossibleAsyncArrow($)){let z=this.tsTryParseGenericAsyncArrowFunction(J);if(z)return X.stop=!0,z}let B=this.tsParseTypeArgumentsInExpression();if(!B)return;if(W&&!this.match(6)){G=this.state.curPosition();return}if(uG(this.state.type)){let z=super.parseTaggedTemplateExpression($,J,X);return z.typeArguments=B,z}if(!Q&&this.eat(6)){let z=this.startNodeAt(J);if(z.callee=$,z.arguments=this.parseCallExpressionArguments(),this.tsCheckForInvalidTypeCasts(z.arguments),z.typeArguments=B,X.optionalChainMember)z.optional=W;return this.finishCallExpression(z,X.optionalChainMember)}let H=this.state.type;if(H===44||H===48||H!==6&&H!==89&&H!==116&&w4(H)&&!this.hasPrecedingLineBreak())return;let K=this.startNodeAt(J);return K.expression=$,K.typeArguments=B,this.finishNode(K,"TSInstantiationExpression")});if(G)this.unexpected(G,6);if(Y){if(Y.type==="TSInstantiationExpression"){if(this.match(12)||this.match(14)&&this.lookaheadCharCode()!==40)this.raise($D.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc);if(!this.match(12)&&!this.match(14))Y.expression=super.stopParseSubscript($,X)}return Y}}return super.parseSubscript($,J,Q,X)}parseNewCallee($){super.parseNewCallee($);let{callee:J}=$;if(J.type==="TSInstantiationExpression"&&!J.extra?.parenthesized)$.typeArguments=J.typeArguments,$.callee=J.expression}parseExprOp($,J,Q){let X;if(uZ(54)>Q&&!this.hasPrecedingLineBreak()&&(this.isContextual(89)||(X=this.isContextual(116)))){let W=this.startNodeAt(J);W.expression=$,W.typeAnnotation=this.tsInType(()=>{if(this.next(),this.match(71)){if(X)this.raise(m.UnexpectedKeyword,this.state.startLoc,{keyword:"const"});return this.tsParseTypeReference()}return this.tsParseType()});let G=this.finishNode(W,X?"TSSatisfiesExpression":"TSAsExpression");return this.reScan_lt_gt(),this.parseExprOp(G,J,Q)}return super.parseExprOp($,J,Q)}checkReservedWord($,J,Q,X){if(!this.state.isAmbientContext)super.checkReservedWord($,J,Q,X)}checkDuplicateExports(){}isPotentialImportPhase($){if(super.isPotentialImportPhase($))return!0;if(this.isContextual(126)){let J=this.lookaheadCharCode();return $?J===123||J===42:J!==61}return!$&&this.isContextual(83)}applyImportPhase($,J,Q,X){if(super.applyImportPhase($,J,Q,X),J)$.exportKind=Q==="type"?"type":"value";else $.importKind=Q==="type"||Q==="typeof"?Q:"value"}parseImport($){if(this.match(130)){if($.importKind="value",this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,$);return super.parseImport($)}let J;if(iD(this.state.type)&&this.lookaheadCharCode()===61){$.importKind="value";let Q=this.tsParseImportEqualsDeclaration($);if(this.scope.inTSNamespace&&Q.moduleReference.type==="TSExternalModuleReference")this.raise($D.ImportInTSNamespace,$);return Q}else if(this.isContextual(126)){let Q=this.parseMaybeImportPhase($,!1);if(this.lookaheadCharCode()===61){if(this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,$);return this.tsParseImportEqualsDeclaration($,Q)}else J=super.parseImportSpecifiersAndAfter($,Q)}else J=super.parseImport($);if(J.importKind==="type"&&J.specifiers.length>1&&J.specifiers[0].type==="ImportDefaultSpecifier")this.raise($D.TypeImportCannotSpecifyDefaultAndNamed,J);else if(this.scope.inTSNamespace)this.raise($D.ImportInTSNamespace,J);return J}parseExport($,J){if(this.match(79)){let Q=this.startNode();this.next();let X=null;if(this.isContextual(126)&&this.isPotentialImportPhase(!1))X=this.parseMaybeImportPhase(Q,!1);else Q.importKind="value";let W=this.tsParseImportEqualsDeclaration(Q,X);return $.attributes=[],$.declaration=W,$.exportKind="value",$.source=null,$.specifiers=[],this.finishNode($,"ExportNamedDeclaration")}else if(this.eat(25)){let Q=$;if(Q.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.scope.inTSNamespace)this.raise($D.ExportAssignmentInTSNamespace,Q);return this.finishNode(Q,"TSExportAssignment")}else if(this.eatContextual(89)){let Q=$;if(this.expectContextual(124),Q.id=this.parseIdentifier(),this.checkIdentifier(Q.id,8201),this.semicolon(),this.scope.inTSNamespace)this.raise($D.NamespaceExportInTSNamespace,Q);return this.finishNode(Q,"TSNamespaceExportDeclaration")}else{let Q=super.parseExport($,J);if(this.scope.inTSNamespace&&(Q.type!=="ExportNamedDeclaration"||Q.source||!Q.declaration&&!this.state.isAmbientContext))this.raise($D.ExportInTSNamespace,Q);return Q}}isAbstractClass(){return this.isContextual(120)&&this.isLookaheadContextual("class")}parseExportDefaultExpression(){if(this.isAbstractClass()){let $=this.startNode();return this.next(),$.abstract=!0,this.parseClass($,!0,!0)}if(this.match(125)){let $=this.tsParseInterfaceDeclaration(this.startNode());if($)return $}return super.parseExportDefaultExpression()}parseVarStatement($,J,Q=!1){let{isAmbientContext:X}=this.state,W=super.parseVarStatement($,J,Q||X);if(X&&!$.declare&&(J==="using"||J==="await using"))return this.raiseOverwrite($D.UsingDeclarationInAmbientContext,$,J),W;for(let G of W.declarations){let{id:Y,init:B,definite:H}=G;if(H){if(B)this.raise($D.DeclaratorDefiniteAssertionWithInitializer,Y);else if(!Y.typeAnnotation)this.raise($D.DeclaratorDefiniteAssertionRequiresTypeAnnotation,Y)}if(X&&B){if(J==="var"||J==="let"||!!Y.typeAnnotation)this.raise($D.InitializerNotAllowedInAmbientContext,B);else if(!um(B,this.hasPlugin("estree")))this.raise($D.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,B)}}return W}parseStatementContent($,J){let Q=!!($&2);if(!this.state.containsEsc)switch(this.state.type){case 71:{if(this.isLookaheadContextual("enum")){let X=this.startNode();return this.next(),this.tsParseEnumDeclaration(X,{const:!0})}break}case 120:case 121:{if(this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()){let X=this.state.type,W=this.startNode();this.next();let G=X===121?this.tsTryParseDeclare(W):this.tsParseAbstractDeclaration(W,J);if(G){if(X===121)G.declare=!0;return G}else return W.expression=this.createIdentifier(this.startNodeAtNode(W),X===121?"declare":"abstract"),this.semicolon(!1),this.finishNode(W,"ExpressionStatement")}break}case 122:return this.tsParseEnumDeclaration(this.startNode());case 108:{if(this.lookaheadCharCode()===123){let W=this.startNode();return this.tsParseAmbientExternalModuleDeclaration(W)}break}case 125:{let X=this.tsParseInterfaceDeclaration(this.startNode());if(X){if(!Q)this.raise($D.UnexpectedTypeDeclaration,X,"interface");return X}break}case 123:{if(this.nextTokenIsStringLiteralOnSameLine()){let X=this.startNode();return this.next(),this.tsParseDeclaration(X,123,!1,J)}else if(this.nextTokenIsIdentifierOnSameLine()){this.raise($D.InlineModuleDeclarationMustUseString,this.state.startLoc);let X=this.startNode();return this.next(),this.tsParseDeclaration(X,124,!1,J)}break}case 124:{if(this.nextTokenIsIdentifierOnSameLine()){let X=this.startNode();return this.next(),this.tsParseDeclaration(X,124,!1,J)}break}case 126:{if(this.nextTokenIsIdentifierOnSameLine()){let X=this.startNode();if(!Q)this.raise($D.UnexpectedTypeDeclaration,X,"type");return this.next(),this.tsParseTypeAliasDeclaration(X)}break}}return super.parseStatementContent($,J)}parseAccessModifier(){return this.tsParseModifier(hm)}tsHasSomeModifiers($,J){return J.some((Q)=>{if(cN(Q))return $.accessibility===Q;return!!$[Q]})}tsIsStartOfStaticBlocks(){return this.isContextual(102)&&this.lookaheadCharCode()===123}parseClassMember($,J,Q){this.tsParseModifiers(gm,$D.InvalidModifierOnTypeParameterPositions,J,!0);let X=()=>{if(this.tsIsStartOfStaticBlocks()){if(this.next(),this.next(),this.tsHasSomeModifiers(J,["declare","private","public","protected","override","abstract","readonly","static"]))this.raise($D.StaticBlockCannotHaveModifier,this.state.curPosition());super.parseClassStaticBlock($,J)}else this.parseClassMemberWithIsStatic($,J,Q,!!J.static)};if(J.declare)this.tsInAmbientContext(X);else X();if(J.decorators&&J.decorators.length>0&&!this.hasPlugin("decorators-legacy")){if(J.type==="TSAbstractMethodDefinition"||J.type==="TSDeclareMethod")this.raise($D.DecoratorAbstractMethod,J,{kind:"abstract method"});else if(J.type==="ClassProperty"&&J.abstract||J.type==="ClassProperty"&&J.declare||J.type==="TSAbstractPropertyDefinition"||J.type==="PropertyDefinition"&&J.declare)this.raise($D.DecoratorAbstractMethod,J,{kind:J.declare?"declare field":"abstract field"})}}parseClassMemberWithIsStatic($,J,Q,X){let W=this.tsTryParseIndexSignature(J);if(W){if($.body.push(W),J.abstract)this.raise($D.IndexSignatureHasAbstract,J);if(J.accessibility)this.raise($D.IndexSignatureHasAccessibility,J,{modifier:J.accessibility});if(J.declare)this.raise($D.IndexSignatureHasDeclare,J);if(J.override)this.raise($D.IndexSignatureHasOverride,J);return}if(!this.state.inAbstractClass&&J.abstract)this.raise($D.NonAbstractClassHasAbstractMethod,J);if(J.override){if(!Q.hadSuperClass)this.raise($D.OverrideNotInSubClass,J)}super.parseClassMemberWithIsStatic($,J,Q,X)}parsePostMemberNameModifiers($){if(this.eat(13))$.optional=!0;if($.readonly&&this.match(6))this.raise($D.ClassMethodHasReadonly,$);if($.declare&&this.match(6))this.raise($D.ClassMethodHasDeclare,$)}shouldParseExportDeclaration(){if(this.tsIsDeclarationStart())return!0;return super.shouldParseExportDeclaration()}parseConditional($,J,Q){if(!this.match(13))return $;if(Q!=null){let G=this.lookaheadCharCode();if(G===44||G===61||G===58||G===41)return this.setOptionalParametersError(Q),$}this.next();let X=this.startNodeAt(J);X.test=$;let W=this.state.inConditionalConsequent;return this.state.inConditionalConsequent=!0,X.consequent=this.parseMaybeAssignAllowIn(),this.state.inConditionalConsequent=W,this.expect(10),X.alternate=this.parseMaybeAssign(),this.finishNode(X,"ConditionalExpression")}parseParenItem($,J){let Q=super.parseParenItem($,J);if(this.eat(13))Q.optional=!0,this.resetEndLocation($);if(this.match(10)){let X=this.startNodeAt(J);return X.expression=$,X.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(X,"TSTypeCastExpression")}return $}parseExportDeclaration($){if(!this.state.isAmbientContext&&this.isContextual(121))return this.tsInAmbientContext(()=>this.parseExportDeclaration($));let J=this.state.startLoc,Q=this.eatContextual(121);if(Q&&(this.isContextual(121)||!this.shouldParseExportDeclaration()))throw this.raise($D.ExpectedAmbientAfterExportDeclare,this.state.startLoc);let W=iD(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration($);if(!W)return null;if(W.type==="TSInterfaceDeclaration"||W.type==="TSTypeAliasDeclaration"||Q)$.exportKind="type";if(Q&&W.type!=="TSImportEqualsDeclaration")this.resetStartLocation(W,J),W.declare=!0;return W}parseClassId($,J,Q,X){if((!J||Q)&&this.isContextual(109)){$.id=null;return}super.parseClassId($,J,Q,$.declare?1024:8331);let W=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);if(W)$.typeParameters=W}parseClassPropertyAnnotation($){if(!$.optional){if(this.eat(31))$.definite=!0;else if(this.eat(13))$.optional=!0}let J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J;if($.definite){if(this.match(25))this.raise($D.DeclaratorDefiniteAssertionWithInitializer,$);else if(!J)this.raise($D.DeclaratorDefiniteAssertionRequiresTypeAnnotation,$)}}parseClassProperty($){if(this.parseClassPropertyAnnotation($),this.state.isAmbientContext&&!($.readonly&&!$.typeAnnotation)&&this.match(25))this.raise($D.DeclareClassFieldHasInitializer,this.state.startLoc);if($.abstract&&this.match(25)){let{key:J}=$;this.raise($D.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:J.type==="Identifier"&&!$.computed?J.name:`[${this.input.slice(this.offsetToSourcePos(J.start),this.offsetToSourcePos(J.end))}]`})}return super.parseClassProperty($)}parseClassPrivateProperty($){if($.abstract)this.raise($D.PrivateElementHasAbstract,$);if($.accessibility)this.raise($D.PrivateElementHasAccessibility,$,{modifier:$.accessibility});return this.parseClassPropertyAnnotation($),super.parseClassPrivateProperty($)}parseClassAccessorProperty($){if(this.parseClassPropertyAnnotation($),$.optional)this.raise($D.AccessorCannotBeOptional,$);return super.parseClassAccessorProperty($)}pushClassMethod($,J,Q,X,W,G){let Y=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(Y&&W)this.raise($D.ConstructorHasTypeParameters,Y);let{declare:B=!1,kind:H}=J;if(B&&(H==="get"||H==="set"))this.raise($D.DeclareAccessor,J,{kind:H});if(Y)J.typeParameters=Y;super.pushClassMethod($,J,Q,X,W,G)}pushClassPrivateMethod($,J,Q,X){let W=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(W)J.typeParameters=W;super.pushClassPrivateMethod($,J,Q,X)}declareClassPrivateMethodInScope($,J){if($.type==="TSDeclareMethod")return;if($.type==="MethodDefinition"&&$.value.body==null)return;super.declareClassPrivateMethodInScope($,J)}parseClassSuper($){if(super.parseClassSuper($),$.superClass){if($.superClass.type==="TSInstantiationExpression"){let J=$.superClass,Q=J.expression;this.takeSurroundingComments(Q,Q.start,Q.end);let X=J.typeArguments;this.takeSurroundingComments(X,X.start,X.end),$.superClass=Q,$.superTypeArguments=X}else if(this.match(43)||this.match(47))$.superTypeArguments=this.tsParseTypeArgumentsInExpression()}if(this.eatContextual(109))$.implements=this.tsParseHeritageClause("implements")}parseObjPropValue($,J,Q,X,W,G,Y){let B=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(B)$.typeParameters=B;return super.parseObjPropValue($,J,Q,X,W,G,Y)}parseFunctionParams($,J){let Q=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(Q)$.typeParameters=Q;super.parseFunctionParams($,J)}parseVarId($,J){if(super.parseVarId($,J),$.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(31))$.definite=!0;let Q=this.tsTryParseTypeAnnotation();if(Q)$.id.typeAnnotation=Q,this.resetEndLocation($.id)}parseAsyncArrowFromCallExpression($,J){if(this.match(10))$.returnType=this.tsParseTypeAnnotation();return super.parseAsyncArrowFromCallExpression($,J)}parseMaybeAssign($,J){let Q,X,W;if(this.hasPlugin("jsx")&&(this.match(138)||this.match(43))){if(Q=this.state.clone(),X=this.tryParse(()=>super.parseMaybeAssign($,J),Q),!X.error)return X.node;let{context:B}=this.state,H=B[B.length-1];if(H===Y2.j_oTag||H===Y2.j_expr)B.pop()}if(!X?.error&&!this.match(43))return super.parseMaybeAssign($,J);if(!Q||Q===this.state)Q=this.state.clone();let G,Y=this.tryParse((B)=>{G=this.tsParseTypeParameters(this.tsParseConstModifier);let H=super.parseMaybeAssign($,J);if(H.type!=="ArrowFunctionExpression"||H.extra?.parenthesized)B();if(G?.params.length!==0)this.resetStartLocationFromNode(H,G);if(H.typeParameters=G,this.hasPlugin("jsx")&&H.typeParameters.params.length===1&&!H.typeParameters.extra?.trailingComma){let K=H.typeParameters.params[0];if(!K.constraint)this.raise($D.SingleTypeParameterWithoutTrailingComma,this.optionFlags&256?e0(K.loc.end,1):K,{typeParameterName:K.name.name})}return H},Q);if(!Y.error&&!Y.aborted){if(G)this.reportReservedArrowTypeParam(G);return Y.node}if(!X){if(pN(!this.hasPlugin("jsx")),W=this.tryParse(()=>super.parseMaybeAssign($,J),Q),!W.error)return W.node}if(X?.node)return this.state=X.failState,X.node;if(Y.node){if(this.state=Y.failState,G)this.reportReservedArrowTypeParam(G);return Y.node}if(W?.node)return this.state=W.failState,W.node;throw X?.error||Y.error||W?.error}reportReservedArrowTypeParam($){if($.params.length===1&&!$.params[0].constraint&&!$.extra?.trailingComma&&this.getPluginOption("typescript","disallowAmbiguousJSXLike"))this.raise($D.ReservedArrowTypeParam,$)}parseMaybeUnary($,J){if(!this.hasPlugin("jsx")&&this.match(43))return this.tsParseTypeAssertion();return super.parseMaybeUnary($,J)}parseArrow($){if(this.match(10)){let J=this.tryParse((Q)=>{let X=this.tsParseTypeOrTypePredicateAnnotation(10);if(this.canInsertSemicolon()||!this.match(15))Q();return X});if(J.aborted)return;if(!J.thrown){if(J.error)this.state=J.failState;$.returnType=J.node}}return super.parseArrow($)}parseFunctionParamType($){if(this.eat(13))$.optional=!0;let J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J;return this.resetEndLocation($),$}isAssignable($,J){switch($.type){case"TSTypeCastExpression":return this.isAssignable($.expression,J);case"TSParameterProperty":return!0;default:return super.isAssignable($,J)}}toAssignable($,J=!1){switch($.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression($,J);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":if(J)this.expressionScope.recordArrowParameterBindingError($D.UnexpectedTypeCastInParameter,$);else this.raise($D.UnexpectedTypeCastInParameter,$);this.toAssignable($.expression,J);break;case"AssignmentExpression":if(!J&&$.left.type==="TSTypeCastExpression")$.left=this.typeCastToParameter($.left);default:super.toAssignable($,J)}}toAssignableParenthesizedExpression($,J){switch($.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable($.expression,J);break;default:super.toAssignable($,J)}}checkToRestConversion($,J){switch($.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion($.expression,!1);break;default:super.checkToRestConversion($,J)}}isValidLVal($,J,Q,X){switch($){case"TSTypeCastExpression":return!0;case"TSParameterProperty":return"parameter";case"TSNonNullExpression":return"expression";case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return(X!==64||!Q)&&["expression",!0];default:return super.isValidLVal($,J,Q,X)}}parseBindingAtom(){if(this.state.type===74)return this.parseIdentifier(!0);return super.parseBindingAtom()}parseMaybeDecoratorArguments($,J){if(this.match(43)||this.match(47)){let Q=this.tsParseTypeArgumentsInExpression();if(this.match(6)){let X=super.parseMaybeDecoratorArguments($,J);return X.typeArguments=Q,X}this.unexpected(null,6)}return super.parseMaybeDecoratorArguments($,J)}checkCommaAfterRest($){if(this.state.isAmbientContext&&this.match(8)&&this.lookaheadCharCode()===$)return this.next(),!1;return super.checkCommaAfterRest($)}isClassMethod(){return this.match(43)||super.isClassMethod()}isClassProperty(){return this.match(31)||this.match(10)||super.isClassProperty()}parseMaybeDefault($,J){let Q=super.parseMaybeDefault($,J);if(Q.type==="AssignmentPattern"&&Q.typeAnnotation&&Q.right.start<Q.typeAnnotation.start)this.raise($D.TypeAnnotationAfterAssign,Q.typeAnnotation);return Q}getTokenFromCode($){if(this.state.inType){if($===62){this.finishOp(44,1);return}if($===60){this.finishOp(43,1);return}}super.getTokenFromCode($)}reScan_lt_gt(){let{type:$}=this.state;if($===43)this.state.pos-=1,this.readToken_lt();else if($===44)this.state.pos-=1,this.readToken_gt()}reScan_lt(){let{type:$}=this.state;if($===47)return this.state.pos-=2,this.finishOp(43,1),43;return $}toAssignableListItem($,J,Q){let X=$[J];if(X.type==="TSTypeCastExpression")$[J]=this.typeCastToParameter(X);super.toAssignableListItem($,J,Q)}typeCastToParameter($){return $.expression.typeAnnotation=$.typeAnnotation,this.resetEndLocationFromNode($.expression,$.typeAnnotation),$.expression}shouldParseArrow($){if(this.match(10))return $.every((J)=>this.isAssignable(J,!0));return super.shouldParseArrow($)}shouldParseAsyncArrow(){if(this.match(10)){if(this.state.inConditionalConsequent)return!1;return!0}return super.shouldParseAsyncArrow()}parseParenAndDistinguishExpression($){let J=this.state.inConditionalConsequent;this.state.inConditionalConsequent=!1;let Q=super.parseParenAndDistinguishExpression($);return this.state.inConditionalConsequent=J,Q}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName($){if(this.match(43)||this.match(47)){let J=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());if(J)$.typeArguments=J}return super.jsxParseOpeningElementAfterName($)}getGetterSetterExpectedParamCount($){let J=super.getGetterSetterExpectedParamCount($),X=this.getObjectOrClassMethodParams($)[0];return X&&this.isThisParam(X)?J+1:J}parseCatchClauseParam(){let $=super.parseCatchClauseParam(),J=this.tsTryParseTypeAnnotation();if(J)$.typeAnnotation=J,this.resetEndLocation($);return $}tsInAmbientContext($){let{isAmbientContext:J,strict:Q}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return $()}finally{this.state.isAmbientContext=J,this.state.strict=Q}}parseClass($,J,Q){let X=this.state.inAbstractClass;this.state.inAbstractClass=!!$.abstract;try{return super.parseClass($,J,Q)}finally{this.state.inAbstractClass=X}}tsParseAbstractDeclaration($,J){if(this.match(76))return $.abstract=!0,this.maybeTakeDecorators(J,this.parseClass($,!0,!1));else if(this.isContextual(125))if(!this.hasFollowingLineBreak())return $.abstract=!0,this.raise($D.NonClassMethodPropertyHasAbstractModifier,$),this.tsParseInterfaceDeclaration($);else return null;throw this.unexpected(null,76)}parseMethod($,J,Q,X,W,G,Y){let B=super.parseMethod($,J,Q,X,W,G,Y);if(B.abstract||B.type==="TSAbstractMethodDefinition"){if((this.hasPlugin("estree")?B.value:B).body){let{key:z}=B;this.raise($D.AbstractMethodHasImplementation,B,{methodName:z.type==="Identifier"&&!B.computed?z.name:`[${this.input.slice(this.offsetToSourcePos(z.start),this.offsetToSourcePos(z.end))}]`})}}return B}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){if(this.shouldParseAsAmbientContext())this.state.isAmbientContext=!0;return super.parse()}getExpression(){if(this.shouldParseAsAmbientContext())this.state.isAmbientContext=!0;return super.getExpression()}parseExportSpecifier($,J,Q,X){if(!J&&X)return this.parseTypeOnlyExportSpecifier($,Q),this.finishNode($,"ExportSpecifier");return $.exportKind="value",super.parseExportSpecifier($,J,Q,X)}parseImportSpecifier($,J,Q,X,W){if(!J&&X)return this.parseTypeOnlyImportSpecifier($,Q),this.finishNode($,"ImportSpecifier");return $.importKind="value",super.parseImportSpecifier($,J,Q,X,Q?4098:4096)}parseTypeOnlyImportSpecifier($,J){let Q=$.imported,X=!1;if(this.isContextual(89)){let W=this.parseIdentifier();if(this.isContextual(89)){let G=this.parseIdentifier();if(A0(this.state.type))X=!0,Q=W,$.local=this.parseIdentifier();else $.local=G}else if(A0(this.state.type))$.local=this.parseIdentifier();else X=!0,Q=W}else if(A0(this.state.type)){if(X=!0,Q=this.parseIdentifier(!0),!this.isContextual(89))this.checkReservedWord(Q.name,Q.start,!0,!0)}if(X&&J)this.raise($D.TypeModifierIsUsedInTypeImports,$.imported);$.imported=Q,$.importKind=X?"type":"value",this.checkIdentifier($.local??=this.eatContextual(89)?this.parseIdentifier():this.cloneIdentifier($.imported),X?4098:4096)}parseTypeOnlyExportSpecifier($,J){let Q=$.local,X=!1;if(this.isContextual(89)){let W=this.parseIdentifier();if(this.isContextual(89)){let G=this.parseIdentifier();if(A0(this.state.type))X=!0,$.local=W,$.exported=this.parseModuleExportName();else $.exported=G}else if(A0(this.state.type))$.exported=this.parseModuleExportName();else X=!0,$.local=W}else if(A0(this.state.type))X=!0,$.local=this.parseModuleExportName();if(X&&J)this.raise($D.TypeModifierIsUsedInTypeExports,Q);$.exportKind=X?"type":"value",$.exported??=this.eatContextual(89)?this.parseModuleExportName():this.cloneIdentifier($.local)}fillOptionalPropertiesForTSESLint($){switch($.type){case"ImportDeclaration":$.phase??=null;return;case"ExpressionStatement":$.directive??=void 0;return;case"RestElement":$.value=void 0;case"Identifier":case"ArrayPattern":case"AssignmentPattern":case"ObjectPattern":$.decorators??=[],$.optional??=!1,$.typeAnnotation??=void 0;return;case"TSParameterProperty":$.accessibility??=void 0,$.decorators??=[],$.override??=!1,$.readonly??=!1,$.static??=!1;return;case"TSEmptyBodyFunctionExpression":$.body=null;case"TSDeclareFunction":case"FunctionDeclaration":case"FunctionExpression":case"ClassMethod":case"ClassPrivateMethod":$.declare??=!1,$.returnType??=void 0,$.typeParameters??=void 0;return;case"Property":$.optional??=!1;return;case"TSMethodSignature":case"TSPropertySignature":$.optional??=!1;case"TSIndexSignature":$.accessibility??=void 0,$.readonly??=!1,$.static??=!1;return;case"TSAbstractPropertyDefinition":case"PropertyDefinition":case"TSAbstractAccessorProperty":case"AccessorProperty":$.declare??=!1,$.definite??=!1,$.readonly??=!1,$.typeAnnotation??=void 0;case"TSAbstractMethodDefinition":case"MethodDefinition":$.accessibility??=void 0,$.decorators??=[],$.override??=!1,$.optional??=!1;return;case"ClassExpression":$.id??=null;case"ClassDeclaration":$.abstract??=!1,$.declare??=!1,$.decorators??=[],$.implements??=[],$.superTypeArguments??=void 0,$.typeParameters??=void 0;return;case"TSTypeAliasDeclaration":case"VariableDeclaration":$.declare??=!1;return;case"VariableDeclarator":$.definite??=!1;return;case"TSEnumDeclaration":$.const??=!1,$.declare??=!1;return;case"TSEnumMember":$.computed??=!1;return;case"TSImportType":$.qualifier??=null,$.options??=null,$.typeArguments??=null;return;case"TSInterfaceDeclaration":$.declare??=!1,$.extends??=[];return;case"TSMappedType":$.optional??=!1,$.readonly??=void 0;return;case"TSModuleDeclaration":$.declare??=!1,$.global??=$.kind==="global";return;case"TSTypeParameter":$.const??=!1,$.in??=!1,$.out??=!1;return}}chStartsBindingIdentifierAndNotRelationalOperator($,J){if(h8($)){if(vG.lastIndex=J,vG.test(this.input)){let Q=this.codePointAtPos(vG.lastIndex);if(!i1(Q)&&Q!==92)return!1}return!0}else if($===92)return!0;else return!1}nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine(){let $=this.nextTokenInLineStart(),J=this.codePointAtPos($);return this.chStartsBindingIdentifierAndNotRelationalOperator(J,$)}nextTokenIsStringLiteralOnSameLine(){let $=this.nextTokenInLineStart(),J=this.codePointAtPos($);return J===34||J===39}};function vm(D){if(D.type!=="MemberExpression")return!1;let{computed:Z,property:$}=D;if(Z&&$.type!=="StringLiteral"&&($.type!=="TemplateLiteral"||$.expressions.length>0))return!1;return j_(D.object)}function um(D,Z){let{type:$}=D;if(D.extra?.parenthesized)return!1;if(Z){if($==="Literal"){let{value:J}=D;if(typeof J==="string"||typeof J==="boolean")return!0}}else if($==="StringLiteral"||$==="BooleanLiteral")return!0;if(T_(D,Z)||dm(D,Z))return!0;if($==="TemplateLiteral"&&D.expressions.length===0)return!0;if(vm(D))return!0;return!1}function T_(D,Z){if(Z)return D.type==="Literal"&&(typeof D.value==="number"||("bigint"in D));return D.type==="NumericLiteral"||D.type==="BigIntLiteral"}function dm(D,Z){if(D.type==="UnaryExpression"){let{operator:$,argument:J}=D;if($==="-"&&T_(J,Z))return!0}return!1}function j_(D){if(D.type==="Identifier")return!0;if(D.type!=="MemberExpression"||D.computed)return!1;return j_(D.object)}function a1(D,Z=[]){let $=new Map;for(let J of D)$.set(J,!0);for(let J of Z)$.set(J,!1);return $}var pm={ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."},lN=z8`placeholders`(pm),cm=(D)=>class Z extends D{parsePlaceholder($){if(this.match(129)){let J=this.startNode();return this.next(),this.assertNoSpace(),J.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(129),this.finishPlaceholder(J,$)}}finishPlaceholder($,J){let Q=$;if(!Q.expectedNode||!Q.type)Q=this.finishNode(Q,"Placeholder");return Q.expectedNode=J,Q}getTokenFromCode($){if($===37&&this.input.charCodeAt(this.state.pos+1)===37)this.finishOp(129,2);else super.getTokenFromCode($)}parseExprAtom($){return this.parsePlaceholder("Expression")||super.parseExprAtom($)}parseIdentifier($){return this.parsePlaceholder("Identifier")||super.parseIdentifier($)}checkReservedWord($,J,Q,X){if($!==void 0)super.checkReservedWord($,J,Q,X)}cloneIdentifier($){let J=super.cloneIdentifier($);if(J.type==="Placeholder")J.expectedNode=$.expectedNode;return J}cloneStringLiteral($){if($.type==="Placeholder")return this.cloneIdentifier($);return super.cloneStringLiteral($)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal($,J,Q,X){return $==="Placeholder"||super.isValidLVal($,J,Q,X)}toAssignable($,J){if($&&$.type==="Placeholder"&&$.expectedNode==="Expression")$.expectedNode="Pattern";else super.toAssignable($,J)}chStartsBindingIdentifier($,J){if(super.chStartsBindingIdentifier($,J))return!0;let Q=this.nextTokenStart();if(this.input.charCodeAt(Q)===37&&this.input.charCodeAt(Q+1)===37)return!0;return!1}verifyBreakContinue($,J){if($.label?.type==="Placeholder")return;super.verifyBreakContinue($,J)}parseExpressionStatement($,J){if(J.type!=="Placeholder"||J.extra?.parenthesized)return super.parseExpressionStatement($,J);if(this.match(10)){let X=$;return X.label=this.finishPlaceholder(J,"Identifier"),this.next(),X.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(X,"LabeledStatement")}this.semicolon();let Q=$;return Q.name=J.name,this.finishPlaceholder(Q,"Statement")}parseBlock($,J,Q){return this.parsePlaceholder("BlockStatement")||super.parseBlock($,J,Q)}parseFunctionId($){return this.parsePlaceholder("Identifier")||super.parseFunctionId($)}parseClass($,J,Q){let X=J?"ClassDeclaration":"ClassExpression";this.next();let W=this.state.strict,G=this.parsePlaceholder("Identifier");if(G)if(this.match(77)||this.match(129)||this.match(2))$.id=G;else if(Q||!J)return $.id=null,$.body=this.finishPlaceholder(G,"ClassBody"),this.finishNode($,X);else throw this.raise(lN.ClassNameIsRequired,this.state.startLoc);else this.parseClassId($,J,Q);return super.parseClassSuper($),$.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!$.superClass,W),this.finishNode($,X)}parseExport($,J){let Q=this.parsePlaceholder("Identifier");if(!Q)return super.parseExport($,J);let X=$;if(!this.isContextual(94)&&!this.match(8))return X.specifiers=[],X.source=null,X.declaration=this.finishPlaceholder(Q,"Declaration"),this.finishNode(X,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");let W=this.startNode();return W.exported=Q,X.specifiers=[this.finishNode(W,"ExportDefaultSpecifier")],super.parseExport(X,J)}isExportDefaultSpecifier(){if(this.match(61)){let $=this.nextTokenStart();if(this.isUnparsedContextual($,"from")){if(this.input.startsWith(a3(129),this.nextTokenStartSince($+4)))return!0}}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier($,J){if($.specifiers?.length)return!0;return super.maybeParseExportDefaultSpecifier($,J)}checkNamedExport(){}parseImport($){let J=this.parsePlaceholder("Identifier");if(!J)return super.parseImport($);if($.specifiers=[],!this.isContextual(94)&&!this.match(8))return $.source=this.finishPlaceholder(J,"StringLiteral"),this.semicolon(),this.finishNode($,"ImportDeclaration");let Q=this.startNodeAtNode(J);if(Q.local=J,$.specifiers.push(this.finishNode(Q,"ImportDefaultSpecifier")),this.eat(8)){if(!this.maybeParseStarImportSpecifier($))this.parseNamedImportSpecifiers($)}return this.expectContextual(94),$.source=this.parseImportSource(),this.semicolon(),this.finishNode($,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){if(this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index))this.raise(lN.UnexpectedSpace,this.state.lastTokEndLoc)}},lm=(D)=>class Z extends D{parseV8Intrinsic(){if(this.match(50)){let $=this.state.startLoc,J=this.startNode();if(this.next(),iD(this.state.type)){let Q=this.parseIdentifierName(),X=this.createIdentifier(J,Q);if(this.castNodeTo(X,"V8IntrinsicIdentifier"),this.match(6))return X}this.unexpected($)}}parseExprAtom($){return this.parseV8Intrinsic()||super.parseExprAtom($)}},sN=["fsharp","hack"],nN=["^^","@@","^","%","#"];function sm(D){if(D.has("decorators")){if(D.has("decorators-legacy"))throw Error("Cannot use the decorators and decorators-legacy plugin together")}if(D.has("flow")&&D.has("typescript"))throw Error("Cannot combine flow and typescript plugins.");if(D.has("placeholders")&&D.has("v8intrinsic"))throw Error("Cannot combine placeholders and v8intrinsic plugins.");if(D.has("pipelineOperator")){let Z=D.get("pipelineOperator").proposal;if(!sN.includes(Z)){let $=sN.map((J)=>`"${J}"`).join(", ");throw Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${$}.`)}if(Z==="hack"){if(D.has("placeholders"))throw Error("Cannot combine placeholders plugin and Hack-style pipes.");if(D.has("v8intrinsic"))throw Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");let $=D.get("pipelineOperator").topicToken;if(!nN.includes($)){let J=nN.map((Q)=>`"${Q}"`).join(", ");throw Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${J}.`)}}}if(D.has("moduleAttributes"))throw Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(D.has("importAssertions"))throw Error("`importAssertions` has been removed in Babel 8, please use import attributes instead.");if(D.has("deprecatedImportAssert"))console.warn("`deprecatedImportAssert` has been removed in Babel 8, please use import attributes instead.");else if(D.has("importAttributes")&&D.get("importAttributes").deprecatedAssertSyntax)console.warn("The 'importAttributes' plugin has been removed in Babel 8. Please migrate any usage of `assert`-style attributes to `with`.");if(D.has("recordAndTuple"))throw Error("The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.");if(D.has("asyncDoExpressions")&&!D.has("doExpressions")){let Z=Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw Z.missingPlugins="doExpressions",Z}if(D.has("optionalChainingAssign")&&D.get("optionalChainingAssign").version!=="2023-07")throw Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");if(D.has("discardBinding")&&D.get("discardBinding").syntaxType!=="void")throw Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");if(D.has("decimal"))throw Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");if(D.has("importReflection"))throw Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}var q_={estree:ch,jsx:Cm,flow:Lm,typescript:mm,v8intrinsic:lm,placeholders:cm},nm=Object.keys(q_);class XY extends O_{constructor(D,Z,$){let J=ph(D);super(J,Z);this.options=J,this.initializeScopes(),this.plugins=$,this.filename=J.sourceFilename,this.startIndex=J.startIndex;let Q=0;if(J.allowAwaitOutsideFunction)Q|=1;if(J.allowReturnOutsideFunction)Q|=2;if(J.allowImportExportEverywhere)Q|=8;if(J.allowSuperOutsideMethod)Q|=16;if(J.allowUndeclaredExports)Q|=64;if(J.allowNewTargetOutsideFunction)Q|=4;if(J.allowYieldOutsideFunction)Q|=32;if(J.ranges)Q|=128;if(J.locations===!0)Q|=256;if(J.tokens)Q|=512;if(J.createImportExpressions)Q|=1024;if(J.createParenthesizedExpressions)Q|=2048;if(J.errorRecovery)Q|=4096;if(J.attachComment)Q|=8192;if(J.annexB)Q|=16384;this.optionFlags=Q}getScopeHandler(){return cZ}parse(){this.enterInitialScopes();let D=this.startNode(),Z=this.startNode();this.nextToken(),D.errors=[];let $=this.parseTopLevel(D,Z);return $.errors=this.state.errors,$.comments.length=this.state.commentsLen,$}}function lZ(D,Z){if(Z?.sourceType==="unambiguous"){Z={...Z};try{Z.sourceType="module";let $=b4(Z,D),J=$.parse();if($.sawUnambiguousESM)return J;if($.ambiguousScriptDifferentAst)try{return Z.sourceType="script",b4(Z,D).parse()}catch{}else J.program.sourceType="script";return J}catch($){try{return Z.sourceType="script",b4(Z,D).parse()}catch{}throw $}}else return b4(Z,D).parse()}function A_(D,Z){let $=b4(Z,D);if($.options.strictMode)$.state.strict=!0;return $.getExpression()}function im(D){let Z={};for(let $ of Object.keys(D))Z[$]=oN(D[$]);return Z}var p0D=im(sh);function b4(D,Z){let $=XY,J=new Map;if(D?.plugins){for(let Q of D.plugins){let X,W;if(typeof Q==="string")X=Q;else[X,W]=Q;if(!J.has(X))J.set(X,W||{})}sm(J),$=am(J)}return new $(D,Z,J)}var iN=new Map;function am(D){let Z=[];for(let Q of nm)if(D.has(Q))Z.push(Q);let $=Z.join("|"),J=iN.get($);if(!J){J=XY;for(let Q of Z)J=q_[Q](J);iN.set($,J)}return J}var G3=(D)=>!!D&&typeof D==="object"&&typeof D.type==="string",X0=(D,Z)=>G3(D)&&D.type==="Identifier"&&D.name===Z,I_=(D,Z,$)=>G3(D)&&D.type==="MemberExpression"&&!D.computed&&X0(D.object,Z)&&X0(D.property,$),WY=(D)=>G3(D)&&D.type==="MemberExpression"&&!D.computed&&G3(D.object)&&D.object.type==="MetaProperty"&&X0(D.object.meta,"import")&&X0(D.object.property,"meta")&&X0(D.property,"url"),S_=(D)=>G3(D)&&D.type==="StringLiteral"?D.value:void 0;function V8(D,Z,$){let J=[],Q=[],X=[],W=()=>{throw Error(`Local routine source unavailable: unsupported dynamic source or asset in ${Z}. Use literal imports/requires and new URL('./asset', import.meta.url).`)},G=(B,H=!1)=>{let K=S_(B);if(K===void 0)W();J.push({specifier:K,require:H})},Y=(B,H)=>{if(["ImportDeclaration","ExportNamedDeclaration","ExportAllDeclaration"].includes(B.type)&&B.source){let K=B.specifiers;if(B.importKind==="type"||B.exportKind==="type"||K?.length&&K.every((z)=>z.importKind==="type"||z.exportKind==="type"))return;G(B.source)}if(B.type==="ImportExpression"){let K=B.source;if(!($&&G3(K)&&K.type==="MemberExpression"&&!K.computed&&X0(K.property,"href")&&G3(K.object)&&K.object.type==="CallExpression"&&X0(K.object.callee,"pathToFileURL")&&Array.isArray(K.object.arguments)&&K.object.arguments.length===1&&I_(K.object.arguments[0],"bootstrap","entry")))G(K)}if(B.type==="CallExpression"&&X0(B.callee,"require"))G(B.arguments[0],!0);if((B.type==="CallExpression"||B.type==="NewExpression")&&(X0(B.callee,"eval")||X0(B.callee,"Function")||X0(B.callee,"createRequire")||I_(B.callee,"module","require")))W();if(B.type==="NewExpression"&&X0(B.callee,"URL")){let K=B.arguments;if(WY(K[1])){let z=S_(K[0]);if(!z||!z.startsWith("./")&&!z.startsWith("../")||K.length!==2)W();Q.push(z);let V=K[0];X.push({start:V.start,end:V.end,path:z})}}if(WY(B)&&!(H?.type==="NewExpression"&&X0(H.callee,"URL")))W();if(B.type==="MetaProperty"&&X0(B.meta,"import")&&!WY(H))W();if(X0(B,"createRequire"))W();if(B.type==="Identifier"&&(B.name==="__dirname"||B.name==="__filename")&&!(H?.type==="MemberExpression"&&H.property===B&&!H.computed))W();if(!$&&X0(B,"require")&&!(H?.type==="CallExpression"&&H.callee===B)&&!(H?.type==="MemberExpression"&&H.property===B&&!H.computed))W();for(let K of Object.values(B))if(G3(K))Y(K,B);else if(Array.isArray(K)){for(let z of K)if(G3(z))Y(z,B)}};try{Y(lZ(D,{sourceType:"unambiguous",createImportExpressions:!0,plugins:Z.endsWith(".ts")||Z.endsWith(".mts")||Z.endsWith(".cts")?["typescript"]:[]}))}catch(B){if(B instanceof Error&&B.message.startsWith("Local routine source unavailable:"))throw B;throw Error(`Local routine source unavailable: unsupported module syntax in ${Z}.`)}return{modules:J,assets:Q,assetLiterals:X}}T1();import{createHash as om}from"node:crypto";var sZ=(D,Z)=>fH({PATH:process.env.PATH,GIT_CONFIG_NOSYSTEM:"1",GIT_CONFIG_GLOBAL:"/dev/null"},()=>b0(D,["-c","core.fsmonitor=false",...Z],void 0,{localObjectsOnly:!0}));async function rm(D){let Z=(await sZ(D,["symbolic-ref","HEAD"])).toString().trim();if(!Z.startsWith("refs/heads/"))throw Error("Routine checkout branch unavailable");try{let $=(await sZ(D,["rev-parse","--verify",`${Z}^{commit}`])).toString().trim();if(!/^[0-9a-f]{40}$/.test($))throw Error("Routine checkout commit unavailable");return{branch:Z,commit:$}}catch($){if(!($ instanceof R9))throw $;try{await sZ(D,["show-ref","--verify","--quiet",Z])}catch(J){if(J instanceof R9&&J.exitCode===1)return{branch:Z};throw J}throw $}}async function nZ(D,Z){let $=await rm(D);if(!$.commit)return{...$,dirty:!0};let J=[...new Set([...Z.keys()].filter((W)=>!W.split("/").includes("node_modules")).map((W)=>W.split("/")[0]))],Q=(await sZ(D,["ls-tree","-rz","--full-tree",$.commit,"--",...J])).toString("utf8"),X=new Map(Q.split("\x00").flatMap((W)=>{let G=/^[0-7]{6} blob ([0-9a-f]{40})\t(.+)$/.exec(W);return G?[[G[2],G[1]]]:[]}));return{...$,dirty:[...Z].some(([W,G])=>!W.split("/").includes("node_modules")&&om("sha1").update(`blob ${G.length}\x00`).update(G).digest("hex")!==X.get(W))}}var j5=P8(S4(),1);import{execFile as mv}from"node:child_process";import{constants as BJ}from"node:fs";import{access as vv,lstat as qY,mkdir as YM,open as uv,readdir as dv,realpath as D6,writeFile as BM}from"node:fs/promises";import{dirname as KJ,join as m2,posix as pv,relative as cv,sep as HJ,win32 as lv}from"node:path";import{promisify as sv}from"node:util";var _0=P8(S4(),1);var o3="0.1.47";class Y3 extends Error{problem;action;constructor(D,Z){super(`${D}
491
491
 
492
492
  ${Z}`);this.problem=D;this.action=Z}}var GY=`From routines/, run:
493
493
  bun install
@@ -1810,7 +1810,7 @@ Commands:
1810
1810
  ${ZQ}
1811
1811
 
1812
1812
  For more details, run:
1813
- os repository add --help`);if(D[0]!=="add")throw X();$=D[1];let W=new Set;for(let z=2;z<D.length;z+=2){let V=D[z],_=D[z+1];if(!["--workspace","--git-repository"].includes(V)||W.has(V)||!_||_.startsWith("-"))throw X();if(W.add(V),V==="--workspace")J=_;else Q=_}let G;try{if(G=P9({name:$,gitRepository:Q}),!J||!/^[a-z0-9][a-z0-9-]*$/.test(J))throw X()}catch{throw X()}let Y=await K2(`/workspaces/${J}/repositories`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(G)},Z),B=await Y.json().catch(()=>null);if(!Y.ok)throw Error(typeof B?.error==="string"?B.error:"Could not add the Data repository. Run the same command again.");let H=zH(B);if(H.repository.name!==G.name||H.repository.gitRepository!==G.gitRepository)throw Error("Invalid repository setup response");console.log(JSON.stringify(H,null,2));let K=await q9(J,Z);if(K)console.error(K)}var JQ={name:"@oddington/cli",version:"0.1.79",description:"OS command-line client",license:"SEE LICENSE IN LICENSE",type:"module",bin:{os:"dist/os.js"},files:["dist","LICENSE","README.md"],engines:{node:">=22.12.0"},publishConfig:{access:"public"},scripts:{build:"bun run --filter @oddington/sdk build && bun run scripts/build.ts",check:"tsc --noEmit",prepack:"bun run scripts/prepack.ts","verify:package":"bun run scripts/verify-package.ts"},devDependencies:{"@babel/parser":"8.0.7","@inquirer/select":"4.4.2","@inquirer/testing":"2.1.53","@types/node":"26.6.1","@types/semver":"^7.7.1",semver:"^7.7.3",typescript:"7.0.2"},dependencies:{"@oddington/sdk":"^0.1.46"},exports:{}};var pP=`Usage:
1813
+ os repository add --help`);if(D[0]!=="add")throw X();$=D[1];let W=new Set;for(let z=2;z<D.length;z+=2){let V=D[z],_=D[z+1];if(!["--workspace","--git-repository"].includes(V)||W.has(V)||!_||_.startsWith("-"))throw X();if(W.add(V),V==="--workspace")J=_;else Q=_}let G;try{if(G=P9({name:$,gitRepository:Q}),!J||!/^[a-z0-9][a-z0-9-]*$/.test(J))throw X()}catch{throw X()}let Y=await K2(`/workspaces/${J}/repositories`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(G)},Z),B=await Y.json().catch(()=>null);if(!Y.ok)throw Error(typeof B?.error==="string"?B.error:"Could not add the Data repository. Run the same command again.");let H=zH(B);if(H.repository.name!==G.name||H.repository.gitRepository!==G.gitRepository)throw Error("Invalid repository setup response");console.log(JSON.stringify(H,null,2));let K=await q9(J,Z);if(K)console.error(K)}var JQ={name:"@oddington/cli",version:"0.1.80",description:"OS command-line client",license:"SEE LICENSE IN LICENSE",type:"module",bin:{os:"dist/os.js"},files:["dist","LICENSE","README.md"],engines:{node:">=22.12.0"},publishConfig:{access:"public"},scripts:{build:"bun run --filter @oddington/sdk build && bun run scripts/build.ts",check:"tsc --noEmit",prepack:"bun run scripts/prepack.ts","verify:package":"bun run scripts/verify-package.ts"},devDependencies:{"@babel/parser":"8.0.7","@inquirer/select":"4.4.2","@inquirer/testing":"2.1.53","@types/node":"26.6.1","@types/semver":"^7.7.1",semver:"^7.7.3",typescript:"7.0.2"},dependencies:{"@oddington/sdk":"^0.1.47"},exports:{}};var pP=`Usage:
1814
1814
  os --version
1815
1815
  os login
1816
1816
  os whoami