(module=>{ "use strict";var xe=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Je=(e,t)=>{for(var n in t)xe(e,n,{get:t[n],enumerable:!0})},Ge=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ve(t))!Ye.call(e,a)&&a!==n&&xe(e,a,{get:()=>t[a],enumerable:!(i=_e(t,a))||i.enumerable});return e};var Qe=e=>Ge(xe({},"__esModule",{value:!0}),e);var ne=(e,t,n)=>new Promise((i,a)=>{var l=d=>{try{s(n.next(d))}catch(P){a(P)}},p=d=>{try{s(n.throw(d))}catch(P){a(P)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,p);s((n=n.apply(e,t)).next())});var Re={};Je(Re,{analyzeMetafile:()=>yt,analyzeMetafileSync:()=>vt,build:()=>dt,buildSync:()=>ht,context:()=>pt,default:()=>Et,formatMessages:()=>mt,formatMessagesSync:()=>wt,initialize:()=>xt,stop:()=>Rt,transform:()=>gt,transformSync:()=>bt,version:()=>ft});module.exports=Qe(Re);function Se(e){let t=i=>{if(i===null)n.write8(0);else if(typeof i=="boolean")n.write8(1),n.write8(+i);else if(typeof i=="number")n.write8(2),n.write32(i|0);else if(typeof i=="string")n.write8(3),n.write(Z(i));else if(i instanceof Uint8Array)n.write8(4),n.write(i);else if(i instanceof Array){n.write8(5),n.write32(i.length);for(let a of i)t(a)}else{let a=Object.keys(i);n.write8(6),n.write32(a.length);for(let l of a)n.write(Z(l)),t(i[l])}},n=new pe;return n.write32(0),n.write32(e.id<<1|+!e.isRequest),t(e.value),Ee(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function $e(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return ie(n.read());case 4:return n.read();case 5:{let p=n.read32(),s=[];for(let d=0;d
>>=1;let l=t();if(n.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:a,value:l}}var pe=class{constructor(t=new Uint8Array(1024)){this.buf=t;this.len=0;this.ptr=0}_write(t){if(this.len+t>this.buf.length){let n=new Uint8Array((this.len+t)*2);n.set(this.buf),this.buf=n}return this.len+=t,this.len-t}write8(t){let n=this._write(1);this.buf[n]=t}write32(t){let n=this._write(4);Ee(this.buf,t,n)}write(t){let n=this._write(4+t.length);Ee(this.buf,t.length,n),this.buf.set(t,n+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return ke(this.buf,this._read(4))}read(){let t=this.read32(),n=new Uint8Array(t),i=this._read(n.length);return n.set(this.buf.subarray(i,i+t)),n}},Z,ie,Oe;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),ie=n=>t.decode(n),Oe='new TextEncoder().encode("")'}else if(typeof Buffer!="undefined")Z=e=>Buffer.from(e),ie=e=>{let{buffer:t,byteOffset:n,byteLength:i}=e;return Buffer.from(t,n,i).toString()},Oe='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${Oe} instanceof Uint8Array" is incorrectly false
This indicates that your JavaScript environment is broken. You cannot use
esbuild in this environment because esbuild relies on this invariant. This
is not a problem with esbuild. You need to fix your environment instead.
`);function ke(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ee(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,Me="warning",Ce="silent";function Ae(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ye=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",he=e=>e instanceof RegExp?null:"a RegExp object",ae=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Xe=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",Te=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ze=e=>typeof e=="object"&&e!==null?null:"an array or an object",et=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Fe=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",De=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",tt=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",nt=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Be=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",rt=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let a=e[n];if(t[n+""]=!0,a===void 0)return;let l=i(a);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return a}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function Ue(e){let t=Object.create(null),n=r(e,t,"wasmURL",rt),i=r(e,t,"wasmModule",et),a=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:a}}function je(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function be(e,t,n,i,a){let l=r(t,n,"color",W),p=r(t,n,"logLevel",y),s=r(t,n,"logLimit",ae);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${p||a}`),e.push(`--log-limit=${s||0}`)}function G(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+V(n):""} to be a string, got ${typeof e} instead`);return e}function Le(e,t,n){let i=r(t,n,"legalComments",y),a=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),p=r(t,n,"target",nt),s=r(t,n,"format",y),d=r(t,n,"globalName",y),P=r(t,n,"mangleProps",he),A=r(t,n,"reserveProps",he),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),E=r(t,n,"lineLimit",ae),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),m=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),D=r(t,n,"jsxDev",W),u=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),S=r(t,n,"supported",ee),F=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),C=r(t,n,"tsconfigRaw",tt);if(i&&e.push(`--legal-comments=${i}`),a!==void 0&&e.push(`--source-root=${a}`),l!==void 0&&e.push(`--sources-content=${l}`),p&&(Array.isArray(p)?e.push(`--target=${Array.from(p).map(Ae).join(",")}`):e.push(`--target=${Ae(p)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),x&&e.push(`--platform=${x}`),C&&e.push(`--tsconfig-raw=${typeof C=="string"?C:JSON.stringify(C)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),E&&e.push(`--line-limit=${E}`),w&&e.push(`--charset=${w}`),m!==void 0&&e.push(`--tree-shaking=${m}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),P&&e.push(`--mangle-props=${P.source}`),A&&e.push(`--reserve-props=${A.source}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),D&&e.push("--jsx-dev"),u&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(S)for(let R in S){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=S[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(F)for(let R of F)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function it(e,t,n,i,a){var oe;let l=[],p=[],s=Object.create(null),d=null,P=null;be(l,t,s,n,i),Le(l,t,s);let A=r(t,s,"sourcemap",De),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),E=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),m=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),D=r(t,s,"loader",ee),u=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),S=r(t,s,"chunkNames",y),F=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),C=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Ze),k=r(t,s,"absWorkingDir",y),B=r(t,s,"stdin",ee),q=(oe=r(t,s,"write",W))!=null?oe:a,U=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),b&&l.push("--bundle"),U&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),E&&l.push(`--outdir=${E}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let g=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);g.push(I)}l.push(`--resolve-extensions=${g.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),S&&l.push(`--chunk-names=${S}`),F&&l.push(`--asset-names=${F}`),f){let g=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);g.push(I)}l.push(`--main-fields=${g.join(",")}`)}if(o){let g=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);g.push(I)}l.push(`--conditions=${g.join(",")}`)}if(v)for(let g of v)l.push(`--external:${G(g,"external")}`);if(M)for(let g in M){if(g.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${g}`);l.push(`--alias:${g}=${G(M[g],"alias",g)}`)}if(x)for(let g in x){if(g.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${g}`);l.push(`--banner:${g}=${G(x[g],"banner",g)}`)}if(C)for(let g in C){if(g.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${g}`);l.push(`--footer:${g}=${G(C[g],"footer",g)}`)}if($)for(let g of $)l.push(`--inject:${G(g,"inject")}`);if(D)for(let g in D){if(g.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${g}`);l.push(`--loader:${g}=${G(D[g],"loader",g)}`)}if(u)for(let g in u){if(g.indexOf("=")>=0)throw new Error(`Invalid out extension: ${g}`);l.push(`--out-extension:${g}=${G(u[g],"out extension",g)}`)}if(R)if(Array.isArray(R))for(let g=0,I=R.length;g{let m=s+w.length;if(m>p.length){let o=new Uint8Array(m*2);o.set(p),p=o}p.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=ke(p,f);if(f+4+o>s)break;f+=4,L(p.subarray(f,f+o)),f+=o}f>0&&(p.copyWithin(0,f,s),s-=f)},P=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let m="The service was stopped"+n.reason;for(let f in i)i[f](m,null);i={}},A=(w,m,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=a++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(Se({id:o,isRequest:!0,value:m}))},b=(w,m)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Se({id:w,isRequest:!1,value:m}))},j=(w,m)=>ne(this,null,function*(){try{if(m.command==="ping"){b(w,{});return}if(typeof m.key=="number"){let f=t[m.key];if(!f)return;let o=f[m.command];if(o){yield o(w,m);return}}throw new Error("Invalid command: "+m.command)}catch(f){let o=[le(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}}),T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.1")throw new Error(`Cannot start service: Host version "0.25.1" does not match binary version ${V(f)}`);return}let m=$e(w);if(m.isRequest)j(m.id,m.value);else{let f=i[m.id];delete i[m.id],m.value.error?f(m.value.error,{}):f(null,m.value)}};return{readFromStdout:d,afterClose:P,service:{buildOrContext:({callName:w,refs:m,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,D=l++,u={},c={ref(){++M===1&&m&&m.ref()},unref(){--M===0&&(delete t[D],m&&m.unref())}};t[D]=u,c.ref(),st(w,D,A,b,c,e,u,f,o,v,(h,S)=>{try{O(h,S)}finally{c.unref()}})},transform:({callName:w,refs:m,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let D=qe(),u=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:S}=lt(w,o,v,Ce),F={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};S&&(F.mangleCache=S),A(m,F,($,x)=>{if($)return M(new Error($),null);let C=ue(x.errors,D),R=ue(x.warnings,D),k=1,B=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(C.length>0)return M(fe("Transform failed",C,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,U)=>{q!==null?M(q,null):(x.code=U,B())})),x.mapFS&&(k++,O.readFile(x.map,(q,U)=>{q!==null?M(q,null):(x.map=U,B())})),B()})}catch(h){let S=[];try{be(S,o,{},v,Ce)}catch($){}let F=le(h,e,D,void 0,"");A(m,{command:"error",flags:S,error:F},()=>{F.detail=D.load(F.detail),M(fe("Transform failed",[F],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=u;u=()=>O.writeFile(f,c)}u(null)},formatMessages:({callName:w,refs:m,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),D=r(o,O,"color",W),u=r(o,O,"terminalWidth",ae);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:re(f,"messages",null,"",u),isWarning:M==="warning"};D!==void 0&&(c.color=D),u!==void 0&&(c.terminalWidth=u),A(m,c,(h,S)=>{if(h)return v(new Error(h),null);v(null,S.messages)})},analyzeMetafile:({callName:w,refs:m,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),D=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let u={command:"analyze-metafile",metafile:f};M!==void 0&&(u.color=M),D!==void 0&&(u.verbose=D),A(m,u,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function st(e,t,n,i,a,l,p,s,d,P,A){let b=qe(),j=e==="context",T=(E,_)=>{let J=[];try{be(J,s,{},d,Me)}catch(m){}let w=le(E,l,b,void 0,_);n(a,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),A(fe(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let E=s.plugins;if(E!==void 0){if(!Array.isArray(E))return T(new Error('"plugins" must be an array'),"");L=E}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");ot(t,n,i,a,l,p,s,L,b).then(E=>{if(!E.ok)return T(E.error,E.pluginName);try{N(E.requestPlugins,E.runOnEndCallbacks,E.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},E=>T(E,""));return}try{N(null,(E,_)=>_([],[]),()=>{})}catch(E){T(E,"")}function N(E,_,J){let w=l.hasFS,{entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:D,mangleCache:u}=it(e,s,d,Me,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:m,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||P,nodePaths:D,context:j};E&&(c.plugins=E),u&&(c.mangleCache=u);let h=($,x)=>{let C={errors:ue($.errors,b),warnings:ue($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=C.errors.slice(),k=C.warnings.slice();$.outputFiles&&(C.outputFiles=$.outputFiles.map(ut)),$.metafile&&(C.metafile=JSON.parse($.metafile)),$.mangleCache&&(C.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(ie($.writeToStdout).replace(/\n$/,"")),_(C,(B,q)=>{if(R.length>0||B.length>0){let U=fe("Build failed",R.concat(B),k.concat(q));return x(U,null,B,q)}x(null,C,B,q)})},S,F;j&&(p["on-end"]=($,x)=>new Promise(C=>{h(x,(R,k,B,q)=>{let U={errors:B,warnings:q};F&&F(R,k),S=void 0,F=void 0,i($,U),C()})})),n(a,c,($,x)=>{if($)return A(new Error($),null);if(!j)return h(x,(k,B)=>(J(),A(k,B)));if(x.errors.length>0)return A(fe("Context failed",x.errors,x.warnings),null);let C=!1,R={rebuild:()=>(S||(S=new Promise((k,B)=>{let q;F=(H,z)=>{q||(q=()=>H?B(H):k(z))};let U=()=>{n(a,{command:"rebuild",key:t},(z,oe)=>{z?B(new Error(z)):q?q():U()})};U()})),S),watch:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(a,{command:"watch",key:t},z=>{z?q(new Error(z)):B(void 0)})}),serve:(k={})=>new Promise((B,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let U={},H=r(k,U,"port",Xe),z=r(k,U,"host",y),oe=r(k,U,"servedir",y),g=r(k,U,"keyfile",y),I=r(k,U,"certfile",y),X=r(k,U,"fallback",y),te=r(k,U,"onRequest",Te);Y(k,U,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),oe!==void 0&&(Q.servedir=oe),g!==void 0&&(Q.keyfile=g),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(a,Q,(ce,We)=>{if(ce)return q(new Error(ce));te&&(p["serve-request"]=(ze,Ke)=>{te(Ke.args),i(ze,{})}),B(We)})}),cancel:()=>new Promise(k=>{if(C)return k();n(a,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(C)return k();C=!0,n(a,{command:"dispose",key:t},()=>{k(),J(),a.unref()})})};a.ref(),A(null,R)})}}var ot=(e,t,n,i,a,l,p,s,d)=>ne(void 0,null,function*(){let P=[],A=[],b={},j={},T=[],L=0,N=0,E=[],_=!1;s=[...s];for(let m of s){let f={};if(typeof m!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(m,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(m,f,"setup",Te);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(m,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let D=v({initialOptions:p,resolve:(u,c={})=>{if(!_)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof u!="string")throw new Error("The path to resolve must be a string");let h=Object.create(null),S=r(c,h,"pluginName",y),F=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),C=r(c,h,"kind",y),R=r(c,h,"pluginData",ye),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((B,q)=>{let U={command:"resolve",path:u,key:e,pluginName:o};if(S!=null&&(U.pluginName=S),F!=null&&(U.importer=F),$!=null&&(U.namespace=$),x!=null&&(U.resolveDir=x),C!=null)U.kind=C;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(U.pluginData=d.store(R)),k!=null&&(U.with=at(k,"with")),t(i,U,(H,z)=>{H!==null?q(new Error(H)):B({errors:ue(z.errors,d),warnings:ue(z.warnings,d),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:d.load(z.pluginData)})})})},onStart(u){let c='This error came from the "onStart" callback registered here:',h=ge(new Error(c),a,"onStart");P.push({name:o,callback:u,note:h}),O.onStart=!0},onEnd(u){let c='This error came from the "onEnd" callback registered here:',h=ge(new Error(c),a,"onEnd");A.push({name:o,callback:u,note:h}),O.onEnd=!0},onResolve(u,c){let h='This error came from the "onResolve" callback registered here:',S=ge(new Error(h),a,"onResolve"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let C=L++;b[C]={name:o,callback:c,note:S},O.onResolve.push({id:C,filter:$.source,namespace:x||""})},onLoad(u,c){let h='This error came from the "onLoad" callback registered here:',S=ge(new Error(h),a,"onLoad"),F={},$=r(u,F,"filter",he),x=r(u,F,"namespace",y);if(Y(u,F,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let C=L++;j[C]={name:o,callback:c,note:S},O.onLoad.push({id:C,filter:$.source,namespace:x||""})},onDispose(u){T.push(u)},esbuild:a.esbuild});D&&(yield D),E.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=(m,f)=>ne(void 0,null,function*(){d.clear();let o={errors:[],warnings:[]};yield Promise.all(P.map(D=>ne(void 0,[D],function*({name:v,callback:O,note:M}){try{let u=yield O();if(u!=null){if(typeof u!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"errors",K),S=r(u,c,"warnings",K);Y(u,c,`from onStart() callback in plugin ${V(v)}`),h!=null&&o.errors.push(...re(h,"errors",d,v,void 0)),S!=null&&o.warnings.push(...re(S,"warnings",d,v,void 0))}}catch(u){o.errors.push(le(u,a,d,M&&M(),v))}}))),n(m,o)}),l["on-resolve"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=b[D]);let u=yield O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"path",y),F=r(u,c,"namespace",y),$=r(u,c,"suffix",y),x=r(u,c,"external",W),C=r(u,c,"sideEffects",W),R=r(u,c,"pluginData",ye),k=r(u,c,"errors",K),B=r(u,c,"warnings",K),q=r(u,c,"watchFiles",K),U=r(u,c,"watchDirs",K);Y(u,c,`from onResolve() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S!=null&&(o.path=S),F!=null&&(o.namespace=F),$!=null&&(o.suffix=$),x!=null&&(o.external=x),C!=null&&(o.sideEffects=C),R!=null&&(o.pluginData=d.store(R)),k!=null&&(o.errors=re(k,"errors",d,v,void 0)),B!=null&&(o.warnings=re(B,"warnings",d,v,void 0)),q!=null&&(o.watchFiles=me(q,"watchFiles")),U!=null&&(o.watchDirs=me(U,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)}),l["on-load"]=(m,f)=>ne(void 0,null,function*(){let o={},v="",O,M;for(let D of f.ids)try{({name:v,callback:O,note:M}=j[D]);let u=yield O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:d.load(f.pluginData),with:f.with});if(u!=null){if(typeof u!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(u,c,"pluginName",y),S=r(u,c,"contents",Be),F=r(u,c,"resolveDir",y),$=r(u,c,"pluginData",ye),x=r(u,c,"loader",y),C=r(u,c,"errors",K),R=r(u,c,"warnings",K),k=r(u,c,"watchFiles",K),B=r(u,c,"watchDirs",K);Y(u,c,`from onLoad() callback in plugin ${V(v)}`),o.id=D,h!=null&&(o.pluginName=h),S instanceof Uint8Array?o.contents=S:S!=null&&(o.contents=Z(S)),F!=null&&(o.resolveDir=F),$!=null&&(o.pluginData=d.store($)),x!=null&&(o.loader=x),C!=null&&(o.errors=re(C,"errors",d,v,void 0)),R!=null&&(o.warnings=re(R,"warnings",d,v,void 0)),k!=null&&(o.watchFiles=me(k,"watchFiles")),B!=null&&(o.watchDirs=me(B,"watchDirs"));break}}catch(u){o={id:D,errors:[le(u,a,d,M&&M(),v)]};break}n(m,o)});let J=(m,f)=>f([],[]);A.length>0&&(J=(m,f)=>{ne(void 0,null,function*(){let o=[],v=[];for(let{name:O,callback:M,note:D}of A){let u,c;try{let h=yield M(m);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let S={},F=r(h,S,"errors",K),$=r(h,S,"warnings",K);Y(h,S,`from onEnd() callback in plugin ${V(O)}`),F!=null&&(u=re(F,"errors",d,O,void 0)),$!=null&&(c=re($,"warnings",d,O,void 0))}}catch(h){u=[le(h,a,d,D&&D(),O)]}if(u){o.push(...u);try{m.errors.push(...u)}catch(h){}}if(c){v.push(...c);try{m.warnings.push(...c)}catch(h){}}}f(o,v)})});let w=()=>{for(let m of T)setTimeout(()=>m(),0)};return _=!0,{ok:!0,requestPlugins:E,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}});function qe(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function ge(e,t,n){let i,a=!1;return()=>{if(a)return i;a=!0;try{let l=(e.stack+"").split(`
`);l.splice(1,1);let p=Ie(t,l,n);if(p)return i={text:e.message,location:p},i}catch(l){}}}function le(e,t,n,i,a){let l="Internal error",p=null;try{l=(e&&e.message||e)+""}catch(s){}try{p=Ie(t,(e.stack+"").split(`
`),"")}catch(s){}return{id:"",pluginName:a,text:l,location:p,notes:i?[i]:[],detail:n?n.store(e):-1}}function Ie(e,t,n){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let a=1;a