isomorfeus-asset-manager 0.12.2 → 0.12.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,12 @@ require 'thread'
3
3
  require 'tmpdir'
4
4
  require 'zlib'
5
5
  require 'opal'
6
+ require 'opal/compiler'
6
7
  require 'opal/builder'
7
8
  require 'oj'
8
9
  require 'rack'
10
+ require 'listen'
11
+ require 'iodine'
9
12
  require 'isomorfeus-speednode'
10
13
  require 'isomorfeus/asset_manager/version'
11
14
  require 'isomorfeus/asset_manager/js_import'
@@ -4,9 +4,9 @@
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "node_modules/esbuild-wasm": {
7
- "version": "0.12.25",
8
- "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.12.25.tgz",
9
- "integrity": "sha512-/lgWzZ1O5sXEVHw2gEQpSnVFc5kOMXiloNRQ3rASX+7/dswSMhlZ2Fw/4t4wTjqyq3cO51Fr48y5Yc4u4r74Cg==",
7
+ "version": "0.12.27",
8
+ "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.12.27.tgz",
9
+ "integrity": "sha512-vuzLng5lSXouUX+QXV+24U6Htn6Kh3azGYyBAMj44oRbCPEt0SquZQX4LAJCnVItP9/Axa9q7B3/9vTLBIcOoQ==",
10
10
  "bin": {
11
11
  "esbuild": "bin/esbuild"
12
12
  },
Binary file
@@ -322,6 +322,11 @@ export interface FormatMessagesOptions {
322
322
  terminalWidth?: number;
323
323
  }
324
324
 
325
+ export interface AnalyzeMetafileOptions {
326
+ color?: boolean;
327
+ verbose?: boolean;
328
+ }
329
+
325
330
  // This function invokes the "esbuild" command-line tool for you. It returns a
326
331
  // promise that either resolves with a "BuildResult" object or rejects with a
327
332
  // "BuildFailure" object.
@@ -356,6 +361,14 @@ export declare function transform(input: string, options?: TransformOptions): Pr
356
361
  // Works in browser: yes
357
362
  export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
358
363
 
364
+ // Pretty-prints an analysis of the metafile JSON to a string. This is just for
365
+ // convenience to be able to match esbuild's pretty-printing exactly. If you want
366
+ // to customize it, you can just inspect the data in the metafile yourself.
367
+ //
368
+ // Works in node: yes
369
+ // Works in browser: yes
370
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
371
+
359
372
  // A synchronous version of "build".
360
373
  //
361
374
  // Works in node: yes
@@ -375,6 +388,12 @@ export declare function transformSync(input: string, options?: TransformOptions)
375
388
  // Works in browser: no
376
389
  export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
377
390
 
391
+ // A synchronous version of "analyzeMetafile".
392
+ //
393
+ // Works in node: yes
394
+ // Works in browser: no
395
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
396
+
378
397
  // This configures the browser-based version of esbuild. It is necessary to
379
398
  // call this first and wait for the returned promise to be resolved before
380
399
  // making other API calls when using esbuild in the browser.
@@ -17,6 +17,9 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = typeof require !== "undefined" ? require : (x) => {
21
+ throw new Error('Dynamic require of "' + x + '" is not supported');
22
+ };
20
23
 
21
24
  // lib/shared/stdio_protocol.ts
22
25
  function encodePacket(packet) {
@@ -670,8 +673,8 @@ function createChannel(streamIn) {
670
673
  if (isFirstPacket) {
671
674
  isFirstPacket = false;
672
675
  let binaryVersion = String.fromCharCode(...bytes);
673
- if (binaryVersion !== "0.12.25") {
674
- throw new Error(`Cannot start service: Host version "${"0.12.25"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
676
+ if (binaryVersion !== "0.12.27") {
677
+ throw new Error(`Cannot start service: Host version "${"0.12.27"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
675
678
  }
676
679
  return;
677
680
  }
@@ -1312,13 +1315,35 @@ function createChannel(streamIn) {
1312
1315
  callback(null, response.messages);
1313
1316
  });
1314
1317
  };
1318
+ let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
1319
+ if (options === void 0)
1320
+ options = {};
1321
+ let keys = {};
1322
+ let color = getFlag(options, keys, "color", mustBeBoolean);
1323
+ let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
1324
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
1325
+ let request = {
1326
+ command: "analyze-metafile",
1327
+ metafile
1328
+ };
1329
+ if (color !== void 0)
1330
+ request.color = color;
1331
+ if (verbose !== void 0)
1332
+ request.verbose = verbose;
1333
+ sendRequest(refs, request, (error, response) => {
1334
+ if (error)
1335
+ return callback(new Error(error), null);
1336
+ callback(null, response.result);
1337
+ });
1338
+ };
1315
1339
  return {
1316
1340
  readFromStdout,
1317
1341
  afterClose,
1318
1342
  service: {
1319
1343
  buildOrServe,
1320
1344
  transform: transform2,
1321
- formatMessages: formatMessages2
1345
+ formatMessages: formatMessages2,
1346
+ analyzeMetafile: analyzeMetafile2
1322
1347
  }
1323
1348
  };
1324
1349
  }
@@ -1521,13 +1546,14 @@ function convertOutputFiles({ path, contents }) {
1521
1546
  }
1522
1547
 
1523
1548
  // lib/npm/browser.ts
1524
- var version = "0.12.25";
1549
+ var version = "0.12.27";
1525
1550
  var build = (options) => ensureServiceIsRunning().build(options);
1526
1551
  var serve = () => {
1527
1552
  throw new Error(`The "serve" API only works in node`);
1528
1553
  };
1529
1554
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
1530
1555
  var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
1556
+ var analyzeMetafile = (metafile, options) => ensureServiceIsRunning().analyzeMetafile(metafile, options);
1531
1557
  var buildSync = () => {
1532
1558
  throw new Error(`The "buildSync" API only works in node`);
1533
1559
  };
@@ -1537,6 +1563,9 @@ var transformSync = () => {
1537
1563
  var formatMessagesSync = () => {
1538
1564
  throw new Error(`The "formatMessagesSync" API only works in node`);
1539
1565
  };
1566
+ var analyzeMetafileSync = () => {
1567
+ throw new Error(`The "analyzeMetafileSync" API only works in node`);
1568
+ };
1540
1569
  var initializePromise;
1541
1570
  var longLivedService;
1542
1571
  var ensureServiceIsRunning = () => {
@@ -2267,7 +2296,7 @@ onmessage = ({ data: wasm }) => {
2267
2296
  callback(null, count);
2268
2297
  };
2269
2298
  let go = new global.Go();
2270
- go.argv = ["", \`--service=\${"0.12.25"}\`];
2299
+ go.argv = ["", \`--service=\${"0.12.27"}\`];
2271
2300
  WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
2272
2301
  };}`;
2273
2302
  let worker;
@@ -2325,10 +2354,19 @@ onmessage = ({ data: wasm }) => {
2325
2354
  messages,
2326
2355
  options,
2327
2356
  callback: (err, res2) => err ? reject(err) : resolve(res2)
2357
+ })),
2358
+ analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => service.analyzeMetafile({
2359
+ callName: "analyzeMetafile",
2360
+ refs: null,
2361
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
2362
+ options,
2363
+ callback: (err, res2) => err ? reject(err) : resolve(res2)
2328
2364
  }))
2329
2365
  };
2330
2366
  };
2331
2367
  export {
2368
+ analyzeMetafile,
2369
+ analyzeMetafileSync,
2332
2370
  build,
2333
2371
  buildSync,
2334
2372
  formatMessages,
@@ -1,8 +1,8 @@
1
- var Xe=Object.defineProperty,Ze=Object.defineProperties;var et=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var Le=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))tt.call(t,r)&&Le(e,r,t[r]);if(Me)for(var r of Me(t))rt.call(t,r)&&Le(e,r,t[r]);return e},De=(e,t)=>Ze(e,et(t));function Pe(e){let t=o=>{if(o===null)r.write8(0);else if(typeof o=="boolean")r.write8(1),r.write8(+o);else if(typeof o=="number")r.write8(2),r.write32(o|0);else if(typeof o=="string")r.write8(3),r.write(se(o));else if(o instanceof Uint8Array)r.write8(4),r.write(o);else if(o instanceof Array){r.write8(5),r.write32(o.length);for(let f of o)t(f)}else{let f=Object.keys(o);r.write8(6),r.write32(f.length);for(let l of f)r.write(se(l)),t(o[l])}},r=new Be;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Fe(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Ue(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ue(r.read());case 4:return r.read();case 5:{let u=r.read32(),i=[];for(let v=0;v<u;v++)i.push(t());return i}case 6:{let u=r.read32(),i={};for(let v=0;v<u;v++)i[ue(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Be(e),o=r.read32(),f=(o&1)==0;o>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:f,value:l}}var Be=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 r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Fe(this.buf,t,r)}write(t){let r=this._write(4+t.length);Fe(this.buf,t.length,r),this.buf.set(t,r+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 Te(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),o=this._read(r.length);return r.set(this.buf.subarray(o,o+t)),r}},se,ue;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;se=r=>e.encode(r),ue=r=>t.decode(r)}else if(typeof Buffer!="undefined")se=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ue=e=>{let{buffer:t,byteOffset:r,byteLength:o}=e;return Buffer.from(t,r,o).toString()};else throw new Error("No UTF-8 codec found");function Te(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Fe(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function We(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var je=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",nt=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",h=e=>typeof e=="string"?null:"a string",qe=e=>e instanceof RegExp?null:"a RegExp object",pe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ae=e=>typeof e=="function"?null:"a function",q=e=>Array.isArray(e)?null:"an array",ge=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",lt=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ke=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ne=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",it=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",st=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ot=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,o){let f=e[r];if(t[r+""]=!0,f===void 0)return;let l=o(f);if(l!==null)throw new Error(`"${r}" must be ${l}`);return f}function z(e,t,r){for(let o in e)if(!(o in t))throw new Error(`Invalid option ${r}: "${o}"`)}function _e(e){let t=Object.create(null),r=n(e,t,"wasmURL",h),o=n(e,t,"worker",W);return z(e,t,"in startService() call"),{wasmURL:r,worker:o}}function Re(e,t,r,o,f){let l=n(t,r,"color",W),u=n(t,r,"logLevel",h),i=n(t,r,"logLimit",pe);l!==void 0?e.push(`--color=${l}`):o&&e.push("--color=true"),e.push(`--log-level=${u||f}`),e.push(`--log-limit=${i||0}`)}function Ve(e,t,r){let o=n(t,r,"legalComments",h),f=n(t,r,"sourceRoot",h),l=n(t,r,"sourcesContent",W),u=n(t,r,"target",st),i=n(t,r,"format",h),v=n(t,r,"globalName",h),S=n(t,r,"minify",W),x=n(t,r,"minifySyntax",W),A=n(t,r,"minifyWhitespace",W),K=n(t,r,"minifyIdentifiers",W),$=n(t,r,"charset",h),M=n(t,r,"treeShaking",Ne),ee=n(t,r,"jsx",h),Q=n(t,r,"jsxFactory",h),re=n(t,r,"jsxFragment",h),te=n(t,r,"define",ge),oe=n(t,r,"pure",q),ae=n(t,r,"keepNames",W);if(o&&e.push(`--legal-comments=${o}`),f!==void 0&&e.push(`--source-root=${f}`),l!==void 0&&e.push(`--sources-content=${l}`),u&&(Array.isArray(u)?e.push(`--target=${Array.from(u).map(We).join(",")}`):e.push(`--target=${We(u)}`)),i&&e.push(`--format=${i}`),v&&e.push(`--global-name=${v}`),S&&e.push("--minify"),x&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),K&&e.push("--minify-identifiers"),$&&e.push(`--charset=${$}`),M!==void 0&&M!==!0&&e.push(`--tree-shaking=${M}`),ee&&e.push(`--jsx=${ee}`),Q&&e.push(`--jsx-factory=${Q}`),re&&e.push(`--jsx-fragment=${re}`),te)for(let H in te){if(H.indexOf("=")>=0)throw new Error(`Invalid define: ${H}`);e.push(`--define:${H}=${te[H]}`)}if(oe)for(let H of oe)e.push(`--pure:${H}`);ae&&e.push("--keep-names")}function at(e,t,r,o,f){var j;let l=[],u=[],i=Object.create(null),v=null,S=null,x=null;Re(l,t,i,r,o),Ve(l,t,i);let A=n(t,i,"sourcemap",Ne),K=n(t,i,"bundle",W),$=n(t,i,"watch",nt),M=n(t,i,"splitting",W),ee=n(t,i,"preserveSymlinks",W),Q=n(t,i,"metafile",W),re=n(t,i,"outfile",h),te=n(t,i,"outdir",h),oe=n(t,i,"outbase",h),ae=n(t,i,"platform",h),H=n(t,i,"tsconfig",h),ve=n(t,i,"resolveExtensions",q),we=n(t,i,"nodePaths",q),xe=n(t,i,"mainFields",q),ke=n(t,i,"conditions",q),p=n(t,i,"external",q),c=n(t,i,"loader",ge),a=n(t,i,"outExtension",ge),g=n(t,i,"publicPath",h),L=n(t,i,"entryNames",h),F=n(t,i,"chunkNames",h),B=n(t,i,"assetNames",h),C=n(t,i,"inject",q),P=n(t,i,"banner",ge),D=n(t,i,"footer",ge),R=n(t,i,"entryPoints",lt),N=n(t,i,"absWorkingDir",h),k=n(t,i,"stdin",ge),O=(j=n(t,i,"write",W))!=null?j:f,E=n(t,i,"allowOverwrite",W),m=n(t,i,"incremental",W)===!0;if(i.plugins=!0,z(t,i,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),K&&l.push("--bundle"),E&&l.push("--allow-overwrite"),$)if(l.push("--watch"),typeof $=="boolean")x={};else{let s=Object.create(null),y=n($,s,"onRebuild",Ae);z($,s,`on "watch" in ${e}() call`),x={onRebuild:y}}if(M&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),re&&l.push(`--outfile=${re}`),te&&l.push(`--outdir=${te}`),oe&&l.push(`--outbase=${oe}`),ae&&l.push(`--platform=${ae}`),H&&l.push(`--tsconfig=${H}`),ve){let s=[];for(let y of ve){if(y+="",y.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${y}`);s.push(y)}l.push(`--resolve-extensions=${s.join(",")}`)}if(g&&l.push(`--public-path=${g}`),L&&l.push(`--entry-names=${L}`),F&&l.push(`--chunk-names=${F}`),B&&l.push(`--asset-names=${B}`),xe){let s=[];for(let y of xe){if(y+="",y.indexOf(",")>=0)throw new Error(`Invalid main field: ${y}`);s.push(y)}l.push(`--main-fields=${s.join(",")}`)}if(ke){let s=[];for(let y of ke){if(y+="",y.indexOf(",")>=0)throw new Error(`Invalid condition: ${y}`);s.push(y)}l.push(`--conditions=${s.join(",")}`)}if(p)for(let s of p)l.push(`--external:${s}`);if(P)for(let s in P){if(s.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${s}`);l.push(`--banner:${s}=${P[s]}`)}if(D)for(let s in D){if(s.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${s}`);l.push(`--footer:${s}=${D[s]}`)}if(C)for(let s of C)l.push(`--inject:${s}`);if(c)for(let s in c){if(s.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${s}`);l.push(`--loader:${s}=${c[s]}`)}if(a)for(let s in a){if(s.indexOf("=")>=0)throw new Error(`Invalid out extension: ${s}`);l.push(`--out-extension:${s}=${a[s]}`)}if(R)if(Array.isArray(R))for(let s of R)u.push(["",s+""]);else for(let[s,y]of Object.entries(R))u.push([s+"",y+""]);if(k){let s=Object.create(null),y=n(k,s,"contents",h),d=n(k,s,"resolveDir",h),w=n(k,s,"sourcefile",h),I=n(k,s,"loader",h);z(k,s,'in "stdin" object'),w&&l.push(`--sourcefile=${w}`),I&&l.push(`--loader=${I}`),d&&(S=d+""),v=y?y+"":""}let b=[];if(we)for(let s of we)s+="",b.push(s);return{entries:u,flags:l,write:O,stdinContents:v,stdinResolveDir:S,absWorkingDir:N,incremental:m,nodePaths:b,watch:x}}function ut(e,t,r,o){let f=[],l=Object.create(null);Re(f,t,l,r,o),Ve(f,t,l);let u=n(t,l,"sourcemap",Ne),i=n(t,l,"tsconfigRaw",it),v=n(t,l,"sourcefile",h),S=n(t,l,"loader",h),x=n(t,l,"banner",h),A=n(t,l,"footer",h);return z(t,l,`in ${e}() call`),u&&f.push(`--sourcemap=${u===!0?"external":u}`),i&&f.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),v&&f.push(`--sourcefile=${v}`),S&&f.push(`--loader=${S}`),x&&f.push(`--banner=${x}`),A&&f.push(`--footer=${A}`),f}function Je(e){let t=new Map,r=new Map,o=new Map,f=new Map,l=0,u=!1,i=0,v=0,S=new Uint8Array(16*1024),x=0,A=p=>{let c=x+p.length;if(c>S.length){let g=new Uint8Array(c*2);g.set(S),S=g}S.set(p,x),x+=p.length;let a=0;for(;a+4<=x;){let g=Te(S,a);if(a+4+g>x)break;a+=4,re(S.subarray(a,a+g)),a+=g}a>0&&(S.copyWithin(0,a,x),x-=a)},K=()=>{u=!0;for(let p of t.values())p("The service was stopped",null);t.clear();for(let p of f.values())p.onWait("The service was stopped");f.clear();for(let p of o.values())try{p(new Error("The service was stopped"),null)}catch(c){console.error(c)}o.clear()},$=(p,c,a)=>{if(u)return a("The service is no longer running",null);let g=i++;t.set(g,(L,F)=>{try{a(L,F)}finally{p&&p.unref()}}),p&&p.ref(),e.writeToStdin(Pe({id:g,isRequest:!0,value:c}))},M=(p,c)=>{if(u)throw new Error("The service is no longer running");e.writeToStdin(Pe({id:p,isRequest:!1,value:c}))},ee=async(p,c)=>{try{switch(c.command){case"ping":{M(p,{});break}case"start":{let a=r.get(c.key);a?M(p,await a(c)):M(p,{});break}case"resolve":{let a=r.get(c.key);a?M(p,await a(c)):M(p,{});break}case"load":{let a=r.get(c.key);a?M(p,await a(c)):M(p,{});break}case"serve-request":{let a=f.get(c.serveID);a&&a.onRequest&&a.onRequest(c.args),M(p,{});break}case"serve-wait":{let a=f.get(c.serveID);a&&a.onWait(c.error),M(p,{});break}case"watch-rebuild":{let a=o.get(c.watchID);try{a&&a(null,c.args)}catch(g){console.error(g)}M(p,{});break}default:throw new Error("Invalid command: "+c.command)}}catch(a){M(p,{errors:[me(a,e,null,void 0,"")]})}},Q=!0,re=p=>{if(Q){Q=!1;let a=String.fromCharCode(...p);if(a!=="0.12.25")throw new Error(`Cannot start service: Host version "0.12.25" does not match binary version ${JSON.stringify(a)}`);return}let c=Ue(p);if(c.isRequest)ee(c.id,c.value);else{let a=t.get(c.id);t.delete(c.id),c.value.error?a(c.value.error,{}):a(null,c.value)}},te=async(p,c,a,g)=>{let L=[],F=[],B={},C={},P=0,D=0,R=[];c=[...c];for(let E of c){let m={};if(typeof E!="object")throw new Error(`Plugin at index ${D} must be an object`);let b=n(E,m,"name",h);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${D} is missing a name`);try{let j=n(E,m,"setup",Ae);if(typeof j!="function")throw new Error("Plugin is missing a setup function");z(E,m,`on plugin ${JSON.stringify(b)}`);let s={name:b,onResolve:[],onLoad:[]};D++;let y=j({initialOptions:p,onStart(d){let w='This error came from the "onStart" callback registered here',I=Oe(new Error(w),e,"onStart");L.push({name:b,callback:d,note:I})},onEnd(d){let w='This error came from the "onEnd" callback registered here',I=Oe(new Error(w),e,"onEnd");F.push({name:b,callback:d,note:I})},onResolve(d,w){let I='This error came from the "onResolve" callback registered here',U=Oe(new Error(I),e,"onResolve"),_={},V=n(d,_,"filter",qe),Y=n(d,_,"namespace",h);if(z(d,_,`in onResolve() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=P++;B[J]={name:b,callback:w,note:U},s.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(d,w){let I='This error came from the "onLoad" callback registered here',U=Oe(new Error(I),e,"onLoad"),_={},V=n(d,_,"filter",qe),Y=n(d,_,"namespace",h);if(z(d,_,`in onLoad() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=P++;C[J]={name:b,callback:w,note:U},s.onLoad.push({id:J,filter:V.source,namespace:Y||""})}});y&&await y,R.push(s)}catch(j){return{ok:!1,error:j,pluginName:b}}}let N=async E=>{switch(E.command){case"start":{let m={errors:[],warnings:[]};return await Promise.all(L.map(async({name:b,callback:j,note:s})=>{try{let y=await j();if(y!=null){if(typeof y!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let d={},w=n(y,d,"errors",q),I=n(y,d,"warnings",q);z(y,d,`from onStart() callback in plugin ${JSON.stringify(b)}`),w!=null&&m.errors.push(...ce(w,"errors",g,b)),I!=null&&m.warnings.push(...ce(I,"warnings",g,b))}}catch(y){m.errors.push(me(y,e,g,s&&s(),b))}})),m}case"resolve":{let m={},b="",j,s;for(let y of E.ids)try{({name:b,callback:j,note:s}=B[y]);let d=await j({path:E.path,importer:E.importer,namespace:E.namespace,resolveDir:E.resolveDir,kind:E.kind,pluginData:g.load(E.pluginData)});if(d!=null){if(typeof d!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},I=n(d,w,"pluginName",h),U=n(d,w,"path",h),_=n(d,w,"namespace",h),V=n(d,w,"external",W),Y=n(d,w,"sideEffects",W),J=n(d,w,"pluginData",je),le=n(d,w,"errors",q),ie=n(d,w,"warnings",q),T=n(d,w,"watchFiles",q),G=n(d,w,"watchDirs",q);z(d,w,`from onResolve() callback in plugin ${JSON.stringify(b)}`),m.id=y,I!=null&&(m.pluginName=I),U!=null&&(m.path=U),_!=null&&(m.namespace=_),V!=null&&(m.external=V),Y!=null&&(m.sideEffects=Y),J!=null&&(m.pluginData=g.store(J)),le!=null&&(m.errors=ce(le,"errors",g,b)),ie!=null&&(m.warnings=ce(ie,"warnings",g,b)),T!=null&&(m.watchFiles=Se(T,"watchFiles")),G!=null&&(m.watchDirs=Se(G,"watchDirs"));break}}catch(d){return{id:y,errors:[me(d,e,g,s&&s(),b)]}}return m}case"load":{let m={},b="",j,s;for(let y of E.ids)try{({name:b,callback:j,note:s}=C[y]);let d=await j({path:E.path,namespace:E.namespace,pluginData:g.load(E.pluginData)});if(d!=null){if(typeof d!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},I=n(d,w,"pluginName",h),U=n(d,w,"contents",ot),_=n(d,w,"resolveDir",h),V=n(d,w,"pluginData",je),Y=n(d,w,"loader",h),J=n(d,w,"errors",q),le=n(d,w,"warnings",q),ie=n(d,w,"watchFiles",q),T=n(d,w,"watchDirs",q);z(d,w,`from onLoad() callback in plugin ${JSON.stringify(b)}`),m.id=y,I!=null&&(m.pluginName=I),U instanceof Uint8Array?m.contents=U:U!=null&&(m.contents=se(U)),_!=null&&(m.resolveDir=_),V!=null&&(m.pluginData=g.store(V)),Y!=null&&(m.loader=Y),J!=null&&(m.errors=ce(J,"errors",g,b)),le!=null&&(m.warnings=ce(le,"warnings",g,b)),ie!=null&&(m.watchFiles=Se(ie,"watchFiles")),T!=null&&(m.watchDirs=Se(T,"watchDirs"));break}}catch(d){return{id:y,errors:[me(d,e,g,s&&s(),b)]}}return m}default:throw new Error("Invalid command: "+E.command)}},k=(E,m,b)=>b();F.length>0&&(k=(E,m,b)=>{(async()=>{for(let{name:j,callback:s,note:y}of F)try{await s(E)}catch(d){E.errors.push(await new Promise(w=>m(d,j,y&&y(),w)))}})().then(b)});let O=0;return{ok:!0,requestPlugins:R,runOnEndCallbacks:k,pluginRefs:{ref(){++O==1&&r.set(a,N)},unref(){--O==0&&r.delete(a)}}}},oe=(p,c,a)=>{let g={},L=n(c,g,"port",pe),F=n(c,g,"host",h),B=n(c,g,"servedir",h),C=n(c,g,"onRequest",Ae),P=l++,D,R=new Promise((N,k)=>{D=O=>{f.delete(P),O!==null?k(new Error(O)):N()}});return a.serve={serveID:P},z(c,g,"in serve() call"),L!==void 0&&(a.serve.port=L),F!==void 0&&(a.serve.host=F),B!==void 0&&(a.serve.servedir=B),f.set(P,{onRequest:C,onWait:D}),{wait:R,stop(){$(p,{command:"serve-stop",serveID:P},()=>{})}}},ae="warning",H="silent",ve=p=>{let c=v++,a=ze(),g,{refs:L,options:F,isTTY:B,callback:C}=p;if(typeof F=="object"){let R=F.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');g=R}}let P=(R,N,k,O)=>{let E=[];try{Re(E,F,{},B,ae)}catch(b){}let m=me(R,e,a,k,N);$(L,{command:"error",flags:E,error:m},()=>{m.detail=a.load(m.detail),O(m)})},D=(R,N)=>{P(R,N,void 0,k=>{C(ye("Build failed",[k],[]),null)})};if(g&&g.length>0){if(e.isSync)return D(new Error("Cannot use plugins in synchronous API calls"),"");te(F,g,c,a).then(R=>{if(!R.ok)D(R.error,R.pluginName);else try{we(De($e({},p),{key:c,details:a,logPluginError:P,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(N){D(N,"")}},R=>D(R,""))}else try{we(De($e({},p),{key:c,details:a,logPluginError:P,requestPlugins:null,runOnEndCallbacks:(R,N,k)=>k(),pluginRefs:null}))}catch(R){D(R,"")}},we=({callName:p,refs:c,serveOptions:a,options:g,isTTY:L,defaultWD:F,callback:B,key:C,details:P,logPluginError:D,requestPlugins:R,runOnEndCallbacks:N,pluginRefs:k})=>{let O={ref(){k&&k.ref(),c&&c.ref()},unref(){k&&k.unref(),c&&c.unref()}},E=!e.isBrowser,{entries:m,flags:b,write:j,stdinContents:s,stdinResolveDir:y,absWorkingDir:d,incremental:w,nodePaths:I,watch:U}=at(p,g,L,ae,E),_={command:"build",key:C,entries:m,flags:b,write:j,stdinContents:s,stdinResolveDir:y,absWorkingDir:d||F,incremental:w,nodePaths:I};R&&(_.plugins=R);let V=a&&oe(O,a,_),Y,J,le=(T,G)=>{T.outputFiles&&(G.outputFiles=T.outputFiles.map(ct)),T.metafile&&(G.metafile=JSON.parse(T.metafile)),T.writeToStdout!==void 0&&console.log(ue(T.writeToStdout).replace(/\n$/,""))},ie=(T,G)=>{let X={errors:he(T.errors,P),warnings:he(T.warnings,P)};le(T,X),N(X,D,()=>{if(X.errors.length>0)return G(ye("Build failed",X.errors,X.warnings),null);if(T.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((fe,de)=>{if(ne||u)throw new Error("Cannot rebuild");$(O,{command:"rebuild",rebuildID:T.rebuildID},(Z,Ge)=>{if(Z)return G(ye("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);ie(Ge,(Ee,Qe)=>{Ee?de(Ee):fe(Qe)})})}),O.ref(),Y.dispose=()=>{ne||(ne=!0,$(O,{command:"rebuild-dispose",rebuildID:T.rebuildID},()=>{}),O.unref())}}X.rebuild=Y}if(T.watchID!==void 0){if(!J){let ne=!1;O.ref(),J=()=>{ne||(ne=!0,o.delete(T.watchID),$(O,{command:"watch-stop",watchID:T.watchID},()=>{}),O.unref())},U&&o.set(T.watchID,(fe,de)=>{if(fe){U.onRebuild&&U.onRebuild(fe,null);return}let Z={errors:he(de.errors,P),warnings:he(de.warnings,P)};le(de,Z),N(Z,D,()=>{if(Z.errors.length>0){U.onRebuild&&U.onRebuild(ye("Build failed",Z.errors,Z.warnings),null);return}de.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,U.onRebuild&&U.onRebuild(null,Z)})})}X.stop=J}G(null,X)})};if(j&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(w&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(U&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');$(O,_,(T,G)=>{if(T)return B(new Error(T),null);if(V){let X=G,ne=!1;O.ref();let fe={port:X.port,host:X.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),O.unref())}};return O.ref(),V.wait.then(O.unref,O.unref),B(null,fe)}return ie(G,B)})};return{readFromStdout:A,afterClose:K,service:{buildOrServe:ve,transform:({callName:p,refs:c,input:a,options:g,isTTY:L,fs:F,callback:B})=>{let C=ze(),P=D=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let R=ut(p,g,L,H);$(c,{command:"transform",flags:R,inputFS:D!==null,input:D!==null?D:a},(k,O)=>{if(k)return B(new Error(k),null);let E=he(O.errors,C),m=he(O.warnings,C),b=1,j=()=>--b==0&&B(null,{warnings:m,code:O.code,map:O.map});if(E.length>0)return B(ye("Transform failed",E,m),null);O.codeFS&&(b++,F.readFile(O.code,(s,y)=>{s!==null?B(s,null):(O.code=y,j())})),O.mapFS&&(b++,F.readFile(O.map,(s,y)=>{s!==null?B(s,null):(O.map=y,j())})),j()})}catch(R){let N=[];try{Re(N,g,{},L,H)}catch(O){}let k=me(R,e,C,void 0,"");$(c,{command:"error",flags:N,error:k},()=>{k.detail=C.load(k.detail),B(ye("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let D=P;P=()=>F.writeFile(a,D)}P(null)},formatMessages:({callName:p,refs:c,messages:a,options:g,callback:L})=>{let F=ce(a,"messages",null,"");if(!g)throw new Error(`Missing second argument in ${p}() call`);let B={},C=n(g,B,"kind",h),P=n(g,B,"color",W),D=n(g,B,"terminalWidth",pe);if(z(g,B,`in ${p}() call`),C===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let R={command:"format-msgs",messages:F,isWarning:C==="warning"};P!==void 0&&(R.color=P),D!==void 0&&(R.terminalWidth=D),$(c,R,(N,k)=>{if(N)return L(new Error(N),null);L(null,k.messages)})}}}}function ze(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let o=t++;return e.set(o,r),o}}}function Oe(e,t,r){let o,f=!1;return()=>{if(f)return o;f=!0;try{let l=(e.stack+"").split(`
2
- `);l.splice(1,1);let u=Ye(t,l,r);if(u)return o={text:e.message,location:u},o}catch(l){}}}function me(e,t,r,o,f){let l="Internal error",u=null;try{l=(e&&e.message||e)+""}catch(i){}try{u=Ye(t,(e.stack+"").split(`
3
- `),"")}catch(i){}return{pluginName:f,text:l,location:u,notes:o?[o]:[],detail:r?r.store(e):-1}}function Ye(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let f=1;f<t.length;f++){let l=t[f];if(!!l.startsWith(o))for(l=l.slice(o.length);;){let u=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(u){l=u[1];continue}if(u=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),u){l=u[1];continue}if(u=/^(\S+):(\d+):(\d+)$/.exec(l),u){let i;try{i=e.readFileSync(u[1],"utf8")}catch(A){break}let v=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+u[2]-1]||"",S=+u[3]-1,x=v.slice(S,S+r.length)===r?r.length:0;return{file:u[1],namespace:"file",line:+u[2],column:se(v.slice(0,S)).length,length:se(v.slice(S,S+x)).length,lineText:v+`
1
+ var Ze=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var Ue=(e,t,r)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&Ue(e,r,t[r]);if(Le)for(var r of Le(t))nt.call(t,r)&&Ue(e,r,t[r]);return e},Me=(e,t)=>et(e,tt(t));var pt=typeof require!="undefined"?require:e=>{throw new Error('Dynamic require of "'+e+'" is not supported')};function Be(e){let t=s=>{if(s===null)r.write8(0);else if(typeof s=="boolean")r.write8(1),r.write8(+s);else if(typeof s=="number")r.write8(2),r.write32(s|0);else if(typeof s=="string")r.write8(3),r.write(se(s));else if(s instanceof Uint8Array)r.write8(4),r.write(s);else if(s instanceof Array){r.write8(5),r.write32(s.length);for(let p of s)t(p)}else{let p=Object.keys(s);r.write8(6),r.write32(p.length);for(let l of p)r.write(se(l)),t(s[l])}},r=new Te;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ae(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function qe(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ue(r.read());case 4:return r.read();case 5:{let c=r.read32(),i=[];for(let w=0;w<c;w++)i.push(t());return i}case 6:{let c=r.read32(),i={};for(let w=0;w<c;w++)i[ue(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Te(e),s=r.read32(),p=(s&1)==0;s>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:s,isRequest:p,value:l}}var Te=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 r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Ae(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ae(this.buf,t.length,r),this.buf.set(t,r+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 Fe(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),s=this._read(r.length);return r.set(this.buf.subarray(s,s+t)),r}},se,ue;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;se=r=>e.encode(r),ue=r=>t.decode(r)}else if(typeof Buffer!="undefined")se=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ue=e=>{let{buffer:t,byteOffset:r,byteLength:s}=e;return Buffer.from(t,r,s).toString()};else throw new Error("No UTF-8 codec found");function Fe(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ae(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function We(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Ne=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",lt=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",y=e=>typeof e=="string"?null:"a string",ze=e=>e instanceof RegExp?null:"a RegExp object",pe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",je=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",ge=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",it=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ke=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ie=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",st=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ot=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",at=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,s){let p=e[r];if(t[r+""]=!0,p===void 0)return;let l=s(p);if(l!==null)throw new Error(`"${r}" must be ${l}`);return p}function _(e,t,r){for(let s in e)if(!(s in t))throw new Error(`Invalid option ${r}: "${s}"`)}function _e(e){let t=Object.create(null),r=n(e,t,"wasmURL",y),s=n(e,t,"worker",q);return _(e,t,"in startService() call"),{wasmURL:r,worker:s}}function Re(e,t,r,s,p){let l=n(t,r,"color",q),c=n(t,r,"logLevel",y),i=n(t,r,"logLimit",pe);l!==void 0?e.push(`--color=${l}`):s&&e.push("--color=true"),e.push(`--log-level=${c||p}`),e.push(`--log-limit=${i||0}`)}function Ve(e,t,r){let s=n(t,r,"legalComments",y),p=n(t,r,"sourceRoot",y),l=n(t,r,"sourcesContent",q),c=n(t,r,"target",ot),i=n(t,r,"format",y),w=n(t,r,"globalName",y),O=n(t,r,"minify",q),x=n(t,r,"minifySyntax",q),N=n(t,r,"minifyWhitespace",q),C=n(t,r,"minifyIdentifiers",q),k=n(t,r,"charset",y),L=n(t,r,"treeShaking",Ie),ee=n(t,r,"jsx",y),Q=n(t,r,"jsxFactory",y),re=n(t,r,"jsxFragment",y),te=n(t,r,"define",ge),oe=n(t,r,"pure",z),ae=n(t,r,"keepNames",q);if(s&&e.push(`--legal-comments=${s}`),p!==void 0&&e.push(`--source-root=${p}`),l!==void 0&&e.push(`--sources-content=${l}`),c&&(Array.isArray(c)?e.push(`--target=${Array.from(c).map(We).join(",")}`):e.push(`--target=${We(c)}`)),i&&e.push(`--format=${i}`),w&&e.push(`--global-name=${w}`),O&&e.push("--minify"),x&&e.push("--minify-syntax"),N&&e.push("--minify-whitespace"),C&&e.push("--minify-identifiers"),k&&e.push(`--charset=${k}`),L!==void 0&&L!==!0&&e.push(`--tree-shaking=${L}`),ee&&e.push(`--jsx=${ee}`),Q&&e.push(`--jsx-factory=${Q}`),re&&e.push(`--jsx-fragment=${re}`),te)for(let H in te){if(H.indexOf("=")>=0)throw new Error(`Invalid define: ${H}`);e.push(`--define:${H}=${te[H]}`)}if(oe)for(let H of oe)e.push(`--pure:${H}`);ae&&e.push("--keep-names")}function ut(e,t,r,s,p){var b;let l=[],c=[],i=Object.create(null),w=null,O=null,x=null;Re(l,t,i,r,s),Ve(l,t,i);let N=n(t,i,"sourcemap",Ie),C=n(t,i,"bundle",q),k=n(t,i,"watch",lt),L=n(t,i,"splitting",q),ee=n(t,i,"preserveSymlinks",q),Q=n(t,i,"metafile",q),re=n(t,i,"outfile",y),te=n(t,i,"outdir",y),oe=n(t,i,"outbase",y),ae=n(t,i,"platform",y),H=n(t,i,"tsconfig",y),ve=n(t,i,"resolveExtensions",z),we=n(t,i,"nodePaths",z),ke=n(t,i,"mainFields",z),Ee=n(t,i,"conditions",z),$e=n(t,i,"external",z),d=n(t,i,"loader",ge),u=n(t,i,"outExtension",ge),o=n(t,i,"publicPath",y),f=n(t,i,"entryNames",y),I=n(t,i,"chunkNames",y),B=n(t,i,"assetNames",y),M=n(t,i,"inject",z),j=n(t,i,"banner",ge),D=n(t,i,"footer",ge),E=n(t,i,"entryPoints",it),R=n(t,i,"absWorkingDir",y),T=n(t,i,"stdin",ge),F=(b=n(t,i,"write",q))!=null?b:p,S=n(t,i,"allowOverwrite",q),$=n(t,i,"incremental",q)===!0;if(i.plugins=!0,_(t,i,`in ${e}() call`),N&&l.push(`--sourcemap${N===!0?"":`=${N}`}`),C&&l.push("--bundle"),S&&l.push("--allow-overwrite"),k)if(l.push("--watch"),typeof k=="boolean")x={};else{let a=Object.create(null),h=n(k,a,"onRebuild",je);_(k,a,`on "watch" in ${e}() call`),x={onRebuild:h}}if(L&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),re&&l.push(`--outfile=${re}`),te&&l.push(`--outdir=${te}`),oe&&l.push(`--outbase=${oe}`),ae&&l.push(`--platform=${ae}`),H&&l.push(`--tsconfig=${H}`),ve){let a=[];for(let h of ve){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${h}`);a.push(h)}l.push(`--resolve-extensions=${a.join(",")}`)}if(o&&l.push(`--public-path=${o}`),f&&l.push(`--entry-names=${f}`),I&&l.push(`--chunk-names=${I}`),B&&l.push(`--asset-names=${B}`),ke){let a=[];for(let h of ke){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid main field: ${h}`);a.push(h)}l.push(`--main-fields=${a.join(",")}`)}if(Ee){let a=[];for(let h of Ee){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid condition: ${h}`);a.push(h)}l.push(`--conditions=${a.join(",")}`)}if($e)for(let a of $e)l.push(`--external:${a}`);if(j)for(let a in j){if(a.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${a}`);l.push(`--banner:${a}=${j[a]}`)}if(D)for(let a in D){if(a.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${a}`);l.push(`--footer:${a}=${D[a]}`)}if(M)for(let a of M)l.push(`--inject:${a}`);if(d)for(let a in d){if(a.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${a}`);l.push(`--loader:${a}=${d[a]}`)}if(u)for(let a in u){if(a.indexOf("=")>=0)throw new Error(`Invalid out extension: ${a}`);l.push(`--out-extension:${a}=${u[a]}`)}if(E)if(Array.isArray(E))for(let a of E)c.push(["",a+""]);else for(let[a,h]of Object.entries(E))c.push([a+"",h+""]);if(T){let a=Object.create(null),h=n(T,a,"contents",y),P=n(T,a,"resolveDir",y),g=n(T,a,"sourcefile",y),v=n(T,a,"loader",y);_(T,a,'in "stdin" object'),g&&l.push(`--sourcefile=${g}`),v&&l.push(`--loader=${v}`),P&&(O=P+""),w=h?h+"":""}let m=[];if(we)for(let a of we)a+="",m.push(a);return{entries:c,flags:l,write:F,stdinContents:w,stdinResolveDir:O,absWorkingDir:R,incremental:$,nodePaths:m,watch:x}}function ct(e,t,r,s){let p=[],l=Object.create(null);Re(p,t,l,r,s),Ve(p,t,l);let c=n(t,l,"sourcemap",Ie),i=n(t,l,"tsconfigRaw",st),w=n(t,l,"sourcefile",y),O=n(t,l,"loader",y),x=n(t,l,"banner",y),N=n(t,l,"footer",y);return _(t,l,`in ${e}() call`),c&&p.push(`--sourcemap=${c===!0?"external":c}`),i&&p.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),w&&p.push(`--sourcefile=${w}`),O&&p.push(`--loader=${O}`),x&&p.push(`--banner=${x}`),N&&p.push(`--footer=${N}`),p}function Je(e){let t=new Map,r=new Map,s=new Map,p=new Map,l=0,c=!1,i=0,w=0,O=new Uint8Array(16*1024),x=0,N=d=>{let u=x+d.length;if(u>O.length){let f=new Uint8Array(u*2);f.set(O),O=f}O.set(d,x),x+=d.length;let o=0;for(;o+4<=x;){let f=Fe(O,o);if(o+4+f>x)break;o+=4,re(O.subarray(o,o+f)),o+=f}o>0&&(O.copyWithin(0,o,x),x-=o)},C=()=>{c=!0;for(let d of t.values())d("The service was stopped",null);t.clear();for(let d of p.values())d.onWait("The service was stopped");p.clear();for(let d of s.values())try{d(new Error("The service was stopped"),null)}catch(u){console.error(u)}s.clear()},k=(d,u,o)=>{if(c)return o("The service is no longer running",null);let f=i++;t.set(f,(I,B)=>{try{o(I,B)}finally{d&&d.unref()}}),d&&d.ref(),e.writeToStdin(Be({id:f,isRequest:!0,value:u}))},L=(d,u)=>{if(c)throw new Error("The service is no longer running");e.writeToStdin(Be({id:d,isRequest:!1,value:u}))},ee=async(d,u)=>{try{switch(u.command){case"ping":{L(d,{});break}case"start":{let o=r.get(u.key);o?L(d,await o(u)):L(d,{});break}case"resolve":{let o=r.get(u.key);o?L(d,await o(u)):L(d,{});break}case"load":{let o=r.get(u.key);o?L(d,await o(u)):L(d,{});break}case"serve-request":{let o=p.get(u.serveID);o&&o.onRequest&&o.onRequest(u.args),L(d,{});break}case"serve-wait":{let o=p.get(u.serveID);o&&o.onWait(u.error),L(d,{});break}case"watch-rebuild":{let o=s.get(u.watchID);try{o&&o(null,u.args)}catch(f){console.error(f)}L(d,{});break}default:throw new Error("Invalid command: "+u.command)}}catch(o){L(d,{errors:[me(o,e,null,void 0,"")]})}},Q=!0,re=d=>{if(Q){Q=!1;let o=String.fromCharCode(...d);if(o!=="0.12.27")throw new Error(`Cannot start service: Host version "0.12.27" does not match binary version ${JSON.stringify(o)}`);return}let u=qe(d);if(u.isRequest)ee(u.id,u.value);else{let o=t.get(u.id);t.delete(u.id),u.value.error?o(u.value.error,{}):o(null,u.value)}},te=async(d,u,o,f)=>{let I=[],B=[],M={},j={},D=0,E=0,R=[];u=[...u];for(let $ of u){let m={};if(typeof $!="object")throw new Error(`Plugin at index ${E} must be an object`);let b=n($,m,"name",y);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${E} is missing a name`);try{let a=n($,m,"setup",je);if(typeof a!="function")throw new Error("Plugin is missing a setup function");_($,m,`on plugin ${JSON.stringify(b)}`);let h={name:b,onResolve:[],onLoad:[]};E++;let P=a({initialOptions:d,onStart(g){let v='This error came from the "onStart" callback registered here',W=Oe(new Error(v),e,"onStart");I.push({name:b,callback:g,note:W})},onEnd(g){let v='This error came from the "onEnd" callback registered here',W=Oe(new Error(v),e,"onEnd");B.push({name:b,callback:g,note:W})},onResolve(g,v){let W='This error came from the "onResolve" callback registered here',U=Oe(new Error(W),e,"onResolve"),K={},V=n(g,K,"filter",ze),Y=n(g,K,"namespace",y);if(_(g,K,`in onResolve() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=D++;M[J]={name:b,callback:v,note:U},h.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(g,v){let W='This error came from the "onLoad" callback registered here',U=Oe(new Error(W),e,"onLoad"),K={},V=n(g,K,"filter",ze),Y=n(g,K,"namespace",y);if(_(g,K,`in onLoad() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=D++;j[J]={name:b,callback:v,note:U},h.onLoad.push({id:J,filter:V.source,namespace:Y||""})}});P&&await P,R.push(h)}catch(a){return{ok:!1,error:a,pluginName:b}}}let T=async $=>{switch($.command){case"start":{let m={errors:[],warnings:[]};return await Promise.all(I.map(async({name:b,callback:a,note:h})=>{try{let P=await a();if(P!=null){if(typeof P!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let g={},v=n(P,g,"errors",z),W=n(P,g,"warnings",z);_(P,g,`from onStart() callback in plugin ${JSON.stringify(b)}`),v!=null&&m.errors.push(...ce(v,"errors",f,b)),W!=null&&m.warnings.push(...ce(W,"warnings",f,b))}}catch(P){m.errors.push(me(P,e,f,h&&h(),b))}})),m}case"resolve":{let m={},b="",a,h;for(let P of $.ids)try{({name:b,callback:a,note:h}=M[P]);let g=await a({path:$.path,importer:$.importer,namespace:$.namespace,resolveDir:$.resolveDir,kind:$.kind,pluginData:f.load($.pluginData)});if(g!=null){if(typeof g!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let v={},W=n(g,v,"pluginName",y),U=n(g,v,"path",y),K=n(g,v,"namespace",y),V=n(g,v,"external",q),Y=n(g,v,"sideEffects",q),J=n(g,v,"pluginData",Ne),le=n(g,v,"errors",z),ie=n(g,v,"warnings",z),A=n(g,v,"watchFiles",z),G=n(g,v,"watchDirs",z);_(g,v,`from onResolve() callback in plugin ${JSON.stringify(b)}`),m.id=P,W!=null&&(m.pluginName=W),U!=null&&(m.path=U),K!=null&&(m.namespace=K),V!=null&&(m.external=V),Y!=null&&(m.sideEffects=Y),J!=null&&(m.pluginData=f.store(J)),le!=null&&(m.errors=ce(le,"errors",f,b)),ie!=null&&(m.warnings=ce(ie,"warnings",f,b)),A!=null&&(m.watchFiles=Se(A,"watchFiles")),G!=null&&(m.watchDirs=Se(G,"watchDirs"));break}}catch(g){return{id:P,errors:[me(g,e,f,h&&h(),b)]}}return m}case"load":{let m={},b="",a,h;for(let P of $.ids)try{({name:b,callback:a,note:h}=j[P]);let g=await a({path:$.path,namespace:$.namespace,pluginData:f.load($.pluginData)});if(g!=null){if(typeof g!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let v={},W=n(g,v,"pluginName",y),U=n(g,v,"contents",at),K=n(g,v,"resolveDir",y),V=n(g,v,"pluginData",Ne),Y=n(g,v,"loader",y),J=n(g,v,"errors",z),le=n(g,v,"warnings",z),ie=n(g,v,"watchFiles",z),A=n(g,v,"watchDirs",z);_(g,v,`from onLoad() callback in plugin ${JSON.stringify(b)}`),m.id=P,W!=null&&(m.pluginName=W),U instanceof Uint8Array?m.contents=U:U!=null&&(m.contents=se(U)),K!=null&&(m.resolveDir=K),V!=null&&(m.pluginData=f.store(V)),Y!=null&&(m.loader=Y),J!=null&&(m.errors=ce(J,"errors",f,b)),le!=null&&(m.warnings=ce(le,"warnings",f,b)),ie!=null&&(m.watchFiles=Se(ie,"watchFiles")),A!=null&&(m.watchDirs=Se(A,"watchDirs"));break}}catch(g){return{id:P,errors:[me(g,e,f,h&&h(),b)]}}return m}default:throw new Error("Invalid command: "+$.command)}},F=($,m,b)=>b();B.length>0&&(F=($,m,b)=>{(async()=>{for(let{name:a,callback:h,note:P}of B)try{await h($)}catch(g){$.errors.push(await new Promise(v=>m(g,a,P&&P(),v)))}})().then(b)});let S=0;return{ok:!0,requestPlugins:R,runOnEndCallbacks:F,pluginRefs:{ref(){++S==1&&r.set(o,T)},unref(){--S==0&&r.delete(o)}}}},oe=(d,u,o)=>{let f={},I=n(u,f,"port",pe),B=n(u,f,"host",y),M=n(u,f,"servedir",y),j=n(u,f,"onRequest",je),D=l++,E,R=new Promise((T,F)=>{E=S=>{p.delete(D),S!==null?F(new Error(S)):T()}});return o.serve={serveID:D},_(u,f,"in serve() call"),I!==void 0&&(o.serve.port=I),B!==void 0&&(o.serve.host=B),M!==void 0&&(o.serve.servedir=M),p.set(D,{onRequest:j,onWait:E}),{wait:R,stop(){k(d,{command:"serve-stop",serveID:D},()=>{})}}},ae="warning",H="silent",ve=d=>{let u=w++,o=Ye(),f,{refs:I,options:B,isTTY:M,callback:j}=d;if(typeof B=="object"){let R=B.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');f=R}}let D=(R,T,F,S)=>{let $=[];try{Re($,B,{},M,ae)}catch(b){}let m=me(R,e,o,F,T);k(I,{command:"error",flags:$,error:m},()=>{m.detail=o.load(m.detail),S(m)})},E=(R,T)=>{D(R,T,void 0,F=>{j(ye("Build failed",[F],[]),null)})};if(f&&f.length>0){if(e.isSync)return E(new Error("Cannot use plugins in synchronous API calls"),"");te(B,f,u,o).then(R=>{if(!R.ok)E(R.error,R.pluginName);else try{we(Me(Pe({},d),{key:u,details:o,logPluginError:D,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(T){E(T,"")}},R=>E(R,""))}else try{we(Me(Pe({},d),{key:u,details:o,logPluginError:D,requestPlugins:null,runOnEndCallbacks:(R,T,F)=>F(),pluginRefs:null}))}catch(R){E(R,"")}},we=({callName:d,refs:u,serveOptions:o,options:f,isTTY:I,defaultWD:B,callback:M,key:j,details:D,logPluginError:E,requestPlugins:R,runOnEndCallbacks:T,pluginRefs:F})=>{let S={ref(){F&&F.ref(),u&&u.ref()},unref(){F&&F.unref(),u&&u.unref()}},$=!e.isBrowser,{entries:m,flags:b,write:a,stdinContents:h,stdinResolveDir:P,absWorkingDir:g,incremental:v,nodePaths:W,watch:U}=ut(d,f,I,ae,$),K={command:"build",key:j,entries:m,flags:b,write:a,stdinContents:h,stdinResolveDir:P,absWorkingDir:g||B,incremental:v,nodePaths:W};R&&(K.plugins=R);let V=o&&oe(S,o,K),Y,J,le=(A,G)=>{A.outputFiles&&(G.outputFiles=A.outputFiles.map(ft)),A.metafile&&(G.metafile=JSON.parse(A.metafile)),A.writeToStdout!==void 0&&console.log(ue(A.writeToStdout).replace(/\n$/,""))},ie=(A,G)=>{let X={errors:he(A.errors,D),warnings:he(A.warnings,D)};le(A,X),T(X,E,()=>{if(X.errors.length>0)return G(ye("Build failed",X.errors,X.warnings),null);if(A.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((fe,de)=>{if(ne||c)throw new Error("Cannot rebuild");k(S,{command:"rebuild",rebuildID:A.rebuildID},(Z,Qe)=>{if(Z)return G(ye("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);ie(Qe,(De,Xe)=>{De?de(De):fe(Xe)})})}),S.ref(),Y.dispose=()=>{ne||(ne=!0,k(S,{command:"rebuild-dispose",rebuildID:A.rebuildID},()=>{}),S.unref())}}X.rebuild=Y}if(A.watchID!==void 0){if(!J){let ne=!1;S.ref(),J=()=>{ne||(ne=!0,s.delete(A.watchID),k(S,{command:"watch-stop",watchID:A.watchID},()=>{}),S.unref())},U&&s.set(A.watchID,(fe,de)=>{if(fe){U.onRebuild&&U.onRebuild(fe,null);return}let Z={errors:he(de.errors,D),warnings:he(de.warnings,D)};le(de,Z),T(Z,E,()=>{if(Z.errors.length>0){U.onRebuild&&U.onRebuild(ye("Build failed",Z.errors,Z.warnings),null);return}de.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,U.onRebuild&&U.onRebuild(null,Z)})})}X.stop=J}G(null,X)})};if(a&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(v&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(U&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');k(S,K,(A,G)=>{if(A)return M(new Error(A),null);if(V){let X=G,ne=!1;S.ref();let fe={port:X.port,host:X.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),S.unref())}};return S.ref(),V.wait.then(S.unref,S.unref),M(null,fe)}return ie(G,M)})};return{readFromStdout:N,afterClose:C,service:{buildOrServe:ve,transform:({callName:d,refs:u,input:o,options:f,isTTY:I,fs:B,callback:M})=>{let j=Ye(),D=E=>{try{if(typeof o!="string")throw new Error('The input to "transform" must be a string');let R=ct(d,f,I,H);k(u,{command:"transform",flags:R,inputFS:E!==null,input:E!==null?E:o},(F,S)=>{if(F)return M(new Error(F),null);let $=he(S.errors,j),m=he(S.warnings,j),b=1,a=()=>--b==0&&M(null,{warnings:m,code:S.code,map:S.map});if($.length>0)return M(ye("Transform failed",$,m),null);S.codeFS&&(b++,B.readFile(S.code,(h,P)=>{h!==null?M(h,null):(S.code=P,a())})),S.mapFS&&(b++,B.readFile(S.map,(h,P)=>{h!==null?M(h,null):(S.map=P,a())})),a()})}catch(R){let T=[];try{Re(T,f,{},I,H)}catch(S){}let F=me(R,e,j,void 0,"");k(u,{command:"error",flags:T,error:F},()=>{F.detail=j.load(F.detail),M(ye("Transform failed",[F],[]),null)})}};if(typeof o=="string"&&o.length>1024*1024){let E=D;D=()=>B.writeFile(o,E)}D(null)},formatMessages:({callName:d,refs:u,messages:o,options:f,callback:I})=>{let B=ce(o,"messages",null,"");if(!f)throw new Error(`Missing second argument in ${d}() call`);let M={},j=n(f,M,"kind",y),D=n(f,M,"color",q),E=n(f,M,"terminalWidth",pe);if(_(f,M,`in ${d}() call`),j===void 0)throw new Error(`Missing "kind" in ${d}() call`);if(j!=="error"&&j!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${d}() call`);let R={command:"format-msgs",messages:B,isWarning:j==="warning"};D!==void 0&&(R.color=D),E!==void 0&&(R.terminalWidth=E),k(u,R,(T,F)=>{if(T)return I(new Error(T),null);I(null,F.messages)})},analyzeMetafile:({callName:d,refs:u,metafile:o,options:f,callback:I})=>{f===void 0&&(f={});let B={},M=n(f,B,"color",q),j=n(f,B,"verbose",q);_(f,B,`in ${d}() call`);let D={command:"analyze-metafile",metafile:o};M!==void 0&&(D.color=M),j!==void 0&&(D.verbose=j),k(u,D,(E,R)=>{if(E)return I(new Error(E),null);I(null,R.result)})}}}}function Ye(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let s=t++;return e.set(s,r),s}}}function Oe(e,t,r){let s,p=!1;return()=>{if(p)return s;p=!0;try{let l=(e.stack+"").split(`
2
+ `);l.splice(1,1);let c=He(t,l,r);if(c)return s={text:e.message,location:c},s}catch(l){}}}function me(e,t,r,s,p){let l="Internal error",c=null;try{l=(e&&e.message||e)+""}catch(i){}try{c=He(t,(e.stack+"").split(`
3
+ `),"")}catch(i){}return{pluginName:p,text:l,location:c,notes:s?[s]:[],detail:r?r.store(e):-1}}function He(e,t,r){let s=" at ";if(e.readFileSync&&!t[0].startsWith(s)&&t[1].startsWith(s))for(let p=1;p<t.length;p++){let l=t[p];if(!!l.startsWith(s))for(l=l.slice(s.length);;){let c=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(c){l=c[1];continue}if(c=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),c){l=c[1];continue}if(c=/^(\S+):(\d+):(\d+)$/.exec(l),c){let i;try{i=e.readFileSync(c[1],"utf8")}catch(N){break}let w=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",O=+c[3]-1,x=w.slice(O,O+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:se(w.slice(0,O)).length,length:se(w.slice(O,O+x)).length,lineText:w+`
4
4
  `+t.slice(1).join(`
5
- `),suggestion:""}}break}}return null}function ye(e,t,r){let o=5,f=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,o+1).map((u,i)=>{if(i===o)return`
6
- ...`;if(!u.location)return`
7
- error: ${u.text}`;let{file:v,line:S,column:x}=u.location,A=u.pluginName?`[plugin: ${u.pluginName}] `:"";return`
8
- ${v}:${S}:${x}: error: ${A}${u.text}`}).join(""),l=new Error(`${e}${f}`);return l.errors=t,l.warnings=r,l}function he(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function He(e,t){if(e==null)return null;let r={},o=n(e,r,"file",h),f=n(e,r,"namespace",h),l=n(e,r,"line",pe),u=n(e,r,"column",pe),i=n(e,r,"length",pe),v=n(e,r,"lineText",h),S=n(e,r,"suggestion",h);return z(e,r,t),{file:o||"",namespace:f||"",line:l||0,column:u||0,length:i||0,lineText:v||"",suggestion:S||""}}function ce(e,t,r,o){let f=[],l=0;for(let u of e){let i={},v=n(u,i,"pluginName",h),S=n(u,i,"text",h),x=n(u,i,"location",Ke),A=n(u,i,"notes",q),K=n(u,i,"detail",je),$=`in element ${l} of "${t}"`;z(u,i,$);let M=[];if(A)for(let ee of A){let Q={},re=n(ee,Q,"text",h),te=n(ee,Q,"location",Ke);z(ee,Q,$),M.push({text:re||"",location:He(te,$)})}f.push({pluginName:v||o,text:S||"",location:He(x,$),notes:M,detail:r?r.store(K):-1}),l++}return f}function Se(e,t){let r=[];for(let o of e){if(typeof o!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(o)}return r}function ct({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ue(t)),r}}}var ht="0.12.25",bt=e=>Ie().build(e),wt=()=>{throw new Error('The "serve" API only works in node')},vt=(e,t)=>Ie().transform(e,t),Rt=(e,t)=>Ie().formatMessages(e,t),Ot=()=>{throw new Error('The "buildSync" API only works in node')},St=()=>{throw new Error('The "transformSync" API only works in node')},xt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},be,Ce,Ie=()=>{if(Ce)return Ce;throw be?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},kt=e=>{e=_e(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",be)throw new Error('Cannot call "initialize" more than once');return be=ft(t,r),be.catch(()=>{be=void 0}),be},ft=async(e,t)=>{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let o=await r.arrayBuffer(),f='{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(i,s,n,l,f,h){if(n===0&&l===s.length&&f===null){if(i===process.stdout.fd){try{process.stdout.write(s,u=>u?h(u,0,null):h(null,l,s))}catch(u){h(u,0,null)}return}if(i===process.stderr.fd){try{process.stderr.write(s,u=>u?h(u,0,null):h(null,l,s))}catch(u){h(u,0,null)}return}}r.write(i,s,n,l,f,h)}}))}const a=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){r+=g.decode(s);const n=r.lastIndexOf(`\n`);return n!=-1&&(console.log(r.substr(0,n)),r=r.substr(n+1)),s.length},write(i,s,n,l,f,h){if(n!==0||l!==s.length||f!==null){h(a());return}const u=this.writeSync(i,s);h(null,u)},chmod(i,s,n){n(a())},chown(i,s,n,l){l(a())},close(i,s){s(a())},fchmod(i,s,n){n(a())},fchown(i,s,n,l){l(a())},fstat(i,s){s(a())},fsync(i,s){s(null)},ftruncate(i,s,n){n(a())},lchown(i,s,n,l){l(a())},link(i,s,n){n(a())},lstat(i,s){s(a())},mkdir(i,s,n){n(a())},open(i,s,n,l){l(a())},read(i,s,n,l,f,h){h(a())},readdir(i,s){s(a())},readlink(i,s){s(a())},rename(i,s,n){n(a())},rmdir(i,s){s(a())},stat(i,s){s(a())},symlink(i,s,n){n(a())},truncate(i,s,n){n(a())},unlink(i,s){s(a())},utimes(i,s,n,l){l(a())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw a()},pid:-1,ppid:-1,umask(){throw a()},cwd(){throw a()},chdir(){throw a()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(i){r.randomFillSync(i)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,i]=process.hrtime();return r*1e3+i/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const d=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=e=>{const t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const o=this.mem.getUint32(e,!0);return this._values[o]},n=(e,t)=>{const o=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,o,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,o|m,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=i(e+0),o=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},f=e=>{const t=i(e+0),o=i(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},h=e=>{const t=i(e+0),o=i(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},u=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=i(e+8),o=i(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(u+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,n(e+24,h(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),h(e+16));e=this._inst.exports.getsp()>>>0,n(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),h(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,n(e+24,Reflect.get(s(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),i(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,h(e+16)),c=f(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,n(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=f(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=f(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=d.encode(String(s(e+8)));n(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=l(e+8),o=s(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(r){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=u=>{const e=i,t=d.encode(u+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!=0&&(i+=8-i%8),e},n=this.argv.length,l=[];this.argv.forEach(u=>{l.push(s(u))}),l.push(0),Object.keys(this.env).sort().forEach(u=>{l.push(s(`${u}=${this.env[u]}`))}),l.push(0);const h=i;l.forEach(u=>{this.mem.setUint32(i,u,!0),this.mem.setUint32(i+4,0,!0),i+=8}),this._inst.exports.run(n,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const i=this;return function(){const s={id:r,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(i=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(i.instance))).catch(i=>{console.error(i),process.exit(1)})}})();\nonmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(`\n`);n.length>1&&console.log(n.slice(0,-1).join(`\n`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.12.25"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let v=new Blob([f],{type:"text/javascript"});l=new Worker(URL.createObjectURL(v))}else{let S=new Function("postMessage",f+"var onmessage; return m => onmessage(m)")(x=>l.onmessage({data:x}));l={onmessage:null,postMessage:x=>S({data:x}),terminate(){}}}l.postMessage(o),l.onmessage=({data:v})=>u(v);let{readFromStdout:u,service:i}=Je({writeToStdin(v){l.postMessage(v)},isSync:!1,isBrowser:!0});Ce={build:v=>new Promise((S,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:v,isTTY:!1,defaultWD:"/",callback:(A,K)=>A?x(A):S(K)})),transform:(v,S)=>new Promise((x,A)=>i.transform({callName:"transform",refs:null,input:v,options:S||{},isTTY:!1,fs:{readFile(K,$){$(new Error("Internal error"),null)},writeFile(K,$){$(null)}},callback:(K,$)=>K?A(K):x($)})),formatMessages:(v,S)=>new Promise((x,A)=>i.formatMessages({callName:"formatMessages",refs:null,messages:v,options:S,callback:(K,$)=>K?A(K):x($)}))}};export{bt as build,Ot as buildSync,Rt as formatMessages,xt as formatMessagesSync,kt as initialize,wt as serve,vt as transform,St as transformSync,ht as version};
5
+ `),suggestion:""}}break}}return null}function ye(e,t,r){let s=5,p=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,s+1).map((c,i)=>{if(i===s)return`
6
+ ...`;if(!c.location)return`
7
+ error: ${c.text}`;let{file:w,line:O,column:x}=c.location,N=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
8
+ ${w}:${O}:${x}: error: ${N}${c.text}`}).join(""),l=new Error(`${e}${p}`);return l.errors=t,l.warnings=r,l}function he(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Ge(e,t){if(e==null)return null;let r={},s=n(e,r,"file",y),p=n(e,r,"namespace",y),l=n(e,r,"line",pe),c=n(e,r,"column",pe),i=n(e,r,"length",pe),w=n(e,r,"lineText",y),O=n(e,r,"suggestion",y);return _(e,r,t),{file:s||"",namespace:p||"",line:l||0,column:c||0,length:i||0,lineText:w||"",suggestion:O||""}}function ce(e,t,r,s){let p=[],l=0;for(let c of e){let i={},w=n(c,i,"pluginName",y),O=n(c,i,"text",y),x=n(c,i,"location",Ke),N=n(c,i,"notes",z),C=n(c,i,"detail",Ne),k=`in element ${l} of "${t}"`;_(c,i,k);let L=[];if(N)for(let ee of N){let Q={},re=n(ee,Q,"text",y),te=n(ee,Q,"location",Ke);_(ee,Q,k),L.push({text:re||"",location:Ge(te,k)})}p.push({pluginName:w||s,text:O||"",location:Ge(x,k),notes:L,detail:r?r.store(C):-1}),l++}return p}function Se(e,t){let r=[];for(let s of e){if(typeof s!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(s)}return r}function ft({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ue(t)),r}}}var wt="0.12.27",vt=e=>xe().build(e),Rt=()=>{throw new Error('The "serve" API only works in node')},Ot=(e,t)=>xe().transform(e,t),St=(e,t)=>xe().formatMessages(e,t),xt=(e,t)=>xe().analyzeMetafile(e,t),kt=()=>{throw new Error('The "buildSync" API only works in node')},Et=()=>{throw new Error('The "transformSync" API only works in node')},$t=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Dt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},be,Ce,xe=()=>{if(Ce)return Ce;throw be?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},Pt=e=>{e=_e(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",be)throw new Error('Cannot call "initialize" more than once');return be=dt(t,r),be.catch(()=>{be=void 0}),be},dt=async(e,t)=>{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let s=await r.arrayBuffer(),p='{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(i,s,n,l,f,h){if(n===0&&l===s.length&&f===null){if(i===process.stdout.fd){try{process.stdout.write(s,u=>u?h(u,0,null):h(null,l,s))}catch(u){h(u,0,null)}return}if(i===process.stderr.fd){try{process.stderr.write(s,u=>u?h(u,0,null):h(null,l,s))}catch(u){h(u,0,null)}return}}r.write(i,s,n,l,f,h)}}))}const a=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){r+=g.decode(s);const n=r.lastIndexOf(`\n`);return n!=-1&&(console.log(r.substr(0,n)),r=r.substr(n+1)),s.length},write(i,s,n,l,f,h){if(n!==0||l!==s.length||f!==null){h(a());return}const u=this.writeSync(i,s);h(null,u)},chmod(i,s,n){n(a())},chown(i,s,n,l){l(a())},close(i,s){s(a())},fchmod(i,s,n){n(a())},fchown(i,s,n,l){l(a())},fstat(i,s){s(a())},fsync(i,s){s(null)},ftruncate(i,s,n){n(a())},lchown(i,s,n,l){l(a())},link(i,s,n){n(a())},lstat(i,s){s(a())},mkdir(i,s,n){n(a())},open(i,s,n,l){l(a())},read(i,s,n,l,f,h){h(a())},readdir(i,s){s(a())},readlink(i,s){s(a())},rename(i,s,n){n(a())},rmdir(i,s){s(a())},stat(i,s){s(a())},symlink(i,s,n){n(a())},truncate(i,s,n){n(a())},unlink(i,s){s(a())},utimes(i,s,n,l){l(a())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw a()},pid:-1,ppid:-1,umask(){throw a()},cwd(){throw a()},chdir(){throw a()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(i){r.randomFillSync(i)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,i]=process.hrtime();return r*1e3+i/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const d=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=e=>{const t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const o=this.mem.getUint32(e,!0);return this._values[o]},n=(e,t)=>{const o=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,o,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,o|m,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=i(e+0),o=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},f=e=>{const t=i(e+0),o=i(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},h=e=>{const t=i(e+0),o=i(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},u=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=i(e+8),o=i(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(u+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,n(e+24,h(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),h(e+16));e=this._inst.exports.getsp()>>>0,n(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),h(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,n(e+24,Reflect.get(s(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),i(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,h(e+16)),c=f(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,n(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=f(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=f(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=d.encode(String(s(e+8)));n(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=l(e+8),o=s(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(r){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=u=>{const e=i,t=d.encode(u+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!=0&&(i+=8-i%8),e},n=this.argv.length,l=[];this.argv.forEach(u=>{l.push(s(u))}),l.push(0),Object.keys(this.env).sort().forEach(u=>{l.push(s(`${u}=${this.env[u]}`))}),l.push(0);const h=i;l.forEach(u=>{this.mem.setUint32(i,u,!0),this.mem.setUint32(i+4,0,!0),i+=8}),this._inst.exports.run(n,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const i=this;return function(){const s={id:r,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(i=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(i.instance))).catch(i=>{console.error(i),process.exit(1)})}})();\nonmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(`\n`);n.length>1&&console.log(n.slice(0,-1).join(`\n`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.12.27"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let w=new Blob([p],{type:"text/javascript"});l=new Worker(URL.createObjectURL(w))}else{let O=new Function("postMessage",p+"var onmessage; return m => onmessage(m)")(x=>l.onmessage({data:x}));l={onmessage:null,postMessage:x=>O({data:x}),terminate(){}}}l.postMessage(s),l.onmessage=({data:w})=>c(w);let{readFromStdout:c,service:i}=Je({writeToStdin(w){l.postMessage(w)},isSync:!1,isBrowser:!0});Ce={build:w=>new Promise((O,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:w,isTTY:!1,defaultWD:"/",callback:(N,C)=>N?x(N):O(C)})),transform:(w,O)=>new Promise((x,N)=>i.transform({callName:"transform",refs:null,input:w,options:O||{},isTTY:!1,fs:{readFile(C,k){k(new Error("Internal error"),null)},writeFile(C,k){k(null)}},callback:(C,k)=>C?N(C):x(k)})),formatMessages:(w,O)=>new Promise((x,N)=>i.formatMessages({callName:"formatMessages",refs:null,messages:w,options:O,callback:(C,k)=>C?N(C):x(k)})),analyzeMetafile:(w,O)=>new Promise((x,N)=>i.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof w=="string"?w:JSON.stringify(w),options:O,callback:(C,k)=>C?N(C):x(k)}))}};export{xt as analyzeMetafile,Dt as analyzeMetafileSync,vt as build,kt as buildSync,St as formatMessages,$t as formatMessagesSync,Pt as initialize,Rt as serve,Ot as transform,Et as transformSync,wt as version};
@@ -322,6 +322,11 @@ export interface FormatMessagesOptions {
322
322
  terminalWidth?: number;
323
323
  }
324
324
 
325
+ export interface AnalyzeMetafileOptions {
326
+ color?: boolean;
327
+ verbose?: boolean;
328
+ }
329
+
325
330
  // This function invokes the "esbuild" command-line tool for you. It returns a
326
331
  // promise that either resolves with a "BuildResult" object or rejects with a
327
332
  // "BuildFailure" object.
@@ -356,6 +361,14 @@ export declare function transform(input: string, options?: TransformOptions): Pr
356
361
  // Works in browser: yes
357
362
  export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
358
363
 
364
+ // Pretty-prints an analysis of the metafile JSON to a string. This is just for
365
+ // convenience to be able to match esbuild's pretty-printing exactly. If you want
366
+ // to customize it, you can just inspect the data in the metafile yourself.
367
+ //
368
+ // Works in node: yes
369
+ // Works in browser: yes
370
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
371
+
359
372
  // A synchronous version of "build".
360
373
  //
361
374
  // Works in node: yes
@@ -375,6 +388,12 @@ export declare function transformSync(input: string, options?: TransformOptions)
375
388
  // Works in browser: no
376
389
  export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
377
390
 
391
+ // A synchronous version of "analyzeMetafile".
392
+ //
393
+ // Works in node: yes
394
+ // Works in browser: no
395
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
396
+
378
397
  // This configures the browser-based version of esbuild. It is necessary to
379
398
  // call this first and wait for the returned promise to be resolved before
380
399
  // making other API calls when using esbuild in the browser.
@@ -19,6 +19,9 @@ var __spreadValues = (a, b) => {
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
21
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
+ var __require = typeof require !== "undefined" ? require : (x) => {
23
+ throw new Error('Dynamic require of "' + x + '" is not supported');
24
+ };
22
25
  var __export = (target, all) => {
23
26
  __markAsModule(target);
24
27
  for (var name in all)
@@ -47,6 +50,8 @@ var __async = (__this, __arguments, generator) => {
47
50
 
48
51
  // lib/npm/browser.ts
49
52
  __export(exports, {
53
+ analyzeMetafile: () => analyzeMetafile,
54
+ analyzeMetafileSync: () => analyzeMetafileSync,
50
55
  build: () => build,
51
56
  buildSync: () => buildSync,
52
57
  formatMessages: () => formatMessages,
@@ -710,8 +715,8 @@ function createChannel(streamIn) {
710
715
  if (isFirstPacket) {
711
716
  isFirstPacket = false;
712
717
  let binaryVersion = String.fromCharCode(...bytes);
713
- if (binaryVersion !== "0.12.25") {
714
- throw new Error(`Cannot start service: Host version "${"0.12.25"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
718
+ if (binaryVersion !== "0.12.27") {
719
+ throw new Error(`Cannot start service: Host version "${"0.12.27"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
715
720
  }
716
721
  return;
717
722
  }
@@ -1352,13 +1357,35 @@ function createChannel(streamIn) {
1352
1357
  callback(null, response.messages);
1353
1358
  });
1354
1359
  };
1360
+ let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
1361
+ if (options === void 0)
1362
+ options = {};
1363
+ let keys = {};
1364
+ let color = getFlag(options, keys, "color", mustBeBoolean);
1365
+ let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
1366
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
1367
+ let request = {
1368
+ command: "analyze-metafile",
1369
+ metafile
1370
+ };
1371
+ if (color !== void 0)
1372
+ request.color = color;
1373
+ if (verbose !== void 0)
1374
+ request.verbose = verbose;
1375
+ sendRequest(refs, request, (error, response) => {
1376
+ if (error)
1377
+ return callback(new Error(error), null);
1378
+ callback(null, response.result);
1379
+ });
1380
+ };
1355
1381
  return {
1356
1382
  readFromStdout,
1357
1383
  afterClose,
1358
1384
  service: {
1359
1385
  buildOrServe,
1360
1386
  transform: transform2,
1361
- formatMessages: formatMessages2
1387
+ formatMessages: formatMessages2,
1388
+ analyzeMetafile: analyzeMetafile2
1362
1389
  }
1363
1390
  };
1364
1391
  }
@@ -1561,13 +1588,14 @@ function convertOutputFiles({ path, contents }) {
1561
1588
  }
1562
1589
 
1563
1590
  // lib/npm/browser.ts
1564
- var version = "0.12.25";
1591
+ var version = "0.12.27";
1565
1592
  var build = (options) => ensureServiceIsRunning().build(options);
1566
1593
  var serve = () => {
1567
1594
  throw new Error(`The "serve" API only works in node`);
1568
1595
  };
1569
1596
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
1570
1597
  var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
1598
+ var analyzeMetafile = (metafile, options) => ensureServiceIsRunning().analyzeMetafile(metafile, options);
1571
1599
  var buildSync = () => {
1572
1600
  throw new Error(`The "buildSync" API only works in node`);
1573
1601
  };
@@ -1577,6 +1605,9 @@ var transformSync = () => {
1577
1605
  var formatMessagesSync = () => {
1578
1606
  throw new Error(`The "formatMessagesSync" API only works in node`);
1579
1607
  };
1608
+ var analyzeMetafileSync = () => {
1609
+ throw new Error(`The "analyzeMetafileSync" API only works in node`);
1610
+ };
1580
1611
  var initializePromise;
1581
1612
  var longLivedService;
1582
1613
  var ensureServiceIsRunning = () => {
@@ -2307,7 +2338,7 @@ onmessage = ({ data: wasm }) => {
2307
2338
  callback(null, count);
2308
2339
  };
2309
2340
  let go = new global.Go();
2310
- go.argv = ["", \`--service=\${"0.12.25"}\`];
2341
+ go.argv = ["", \`--service=\${"0.12.27"}\`];
2311
2342
  WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
2312
2343
  };}`;
2313
2344
  let worker;
@@ -2365,6 +2396,13 @@ onmessage = ({ data: wasm }) => {
2365
2396
  messages,
2366
2397
  options,
2367
2398
  callback: (err, res2) => err ? reject(err) : resolve(res2)
2399
+ })),
2400
+ analyzeMetafile: (metafile, options) => new Promise((resolve, reject) => service.analyzeMetafile({
2401
+ callName: "analyzeMetafile",
2402
+ refs: null,
2403
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
2404
+ options,
2405
+ callback: (err, res2) => err ? reject(err) : resolve(res2)
2368
2406
  }))
2369
2407
  };
2370
2408
  });
@@ -1,10 +1,18 @@
1
1
  (exports=>{
2
- var De=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var We=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&We(e,r,t[r]);if(Ue)for(var r of Ue(t))nt.call(t,r)&&We(e,r,t[r]);return e},Be=(e,t)=>et(e,tt(t)),lt=e=>De(e,"__esModule",{value:!0});var it=(e,t)=>{lt(e);for(var r in t)De(e,r,{get:t[r],enumerable:!0})};var se=(e,t,r)=>new Promise((s,d)=>{var l=y=>{try{i(r.next(y))}catch(O){d(O)}},u=y=>{try{i(r.throw(y))}catch(O){d(O)}},i=y=>y.done?s(y.value):Promise.resolve(y.value).then(l,u);i((r=r.apply(e,t)).next())});it(exports,{build:()=>mt,buildSync:()=>wt,formatMessages:()=>bt,formatMessagesSync:()=>Rt,initialize:()=>Ot,serve:()=>yt,transform:()=>ht,transformSync:()=>vt,version:()=>gt});function Te(e){let t=s=>{if(s===null)r.write8(0);else if(typeof s=="boolean")r.write8(1),r.write8(+s);else if(typeof s=="number")r.write8(2),r.write32(s|0);else if(typeof s=="string")r.write8(3),r.write(oe(s));else if(s instanceof Uint8Array)r.write8(4),r.write(s);else if(s instanceof Array){r.write8(5),r.write32(s.length);for(let d of s)t(d)}else{let d=Object.keys(s);r.write8(6),r.write32(d.length);for(let l of d)r.write(oe(l)),t(s[l])}},r=new Fe;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ae(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function qe(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ce(r.read());case 4:return r.read();case 5:{let u=r.read32(),i=[];for(let y=0;y<u;y++)i.push(t());return i}case 6:{let u=r.read32(),i={};for(let y=0;y<u;y++)i[ce(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Fe(e),s=r.read32(),d=(s&1)==0;s>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:s,isRequest:d,value:l}}var Fe=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 r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Ae(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ae(this.buf,t.length,r),this.buf.set(t,r+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 je(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),s=this._read(r.length);return r.set(this.buf.subarray(s,s+t)),r}},oe,ce;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;oe=r=>e.encode(r),ce=r=>t.decode(r)}else if(typeof Buffer!="undefined")oe=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ce=e=>{let{buffer:t,byteOffset:r,byteLength:s}=e;return Buffer.from(t,r,s).toString()};else throw new Error("No UTF-8 codec found");function je(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ae(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function Ke(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Ne=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",st=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",h=e=>typeof e=="string"?null:"a string",_e=e=>e instanceof RegExp?null:"a RegExp object",ge=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ce=e=>typeof e=="function"?null:"a function",q=e=>Array.isArray(e)?null:"an array",me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",ot=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ve=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ie=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",at=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ut=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ct=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,s){let d=e[r];if(t[r+""]=!0,d===void 0)return;let l=s(d);if(l!==null)throw new Error(`"${r}" must be ${l}`);return d}function z(e,t,r){for(let s in e)if(!(s in t))throw new Error(`Invalid option ${r}: "${s}"`)}function Je(e){let t=Object.create(null),r=n(e,t,"wasmURL",h),s=n(e,t,"worker",W);return z(e,t,"in startService() call"),{wasmURL:r,worker:s}}function Oe(e,t,r,s,d){let l=n(t,r,"color",W),u=n(t,r,"logLevel",h),i=n(t,r,"logLimit",ge);l!==void 0?e.push(`--color=${l}`):s&&e.push("--color=true"),e.push(`--log-level=${u||d}`),e.push(`--log-limit=${i||0}`)}function ze(e,t,r){let s=n(t,r,"legalComments",h),d=n(t,r,"sourceRoot",h),l=n(t,r,"sourcesContent",W),u=n(t,r,"target",ut),i=n(t,r,"format",h),y=n(t,r,"globalName",h),O=n(t,r,"minify",W),x=n(t,r,"minifySyntax",W),A=n(t,r,"minifyWhitespace",W),K=n(t,r,"minifyIdentifiers",W),$=n(t,r,"charset",h),L=n(t,r,"treeShaking",Ie),ee=n(t,r,"jsx",h),Q=n(t,r,"jsxFactory",h),re=n(t,r,"jsxFragment",h),te=n(t,r,"define",me),ae=n(t,r,"pure",q),ue=n(t,r,"keepNames",W);if(s&&e.push(`--legal-comments=${s}`),d!==void 0&&e.push(`--source-root=${d}`),l!==void 0&&e.push(`--sources-content=${l}`),u&&(Array.isArray(u)?e.push(`--target=${Array.from(u).map(Ke).join(",")}`):e.push(`--target=${Ke(u)}`)),i&&e.push(`--format=${i}`),y&&e.push(`--global-name=${y}`),O&&e.push("--minify"),x&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),K&&e.push("--minify-identifiers"),$&&e.push(`--charset=${$}`),L!==void 0&&L!==!0&&e.push(`--tree-shaking=${L}`),ee&&e.push(`--jsx=${ee}`),Q&&e.push(`--jsx-factory=${Q}`),re&&e.push(`--jsx-fragment=${re}`),te)for(let H in te){if(H.indexOf("=")>=0)throw new Error(`Invalid define: ${H}`);e.push(`--define:${H}=${te[H]}`)}if(ae)for(let H of ae)e.push(`--pure:${H}`);ue&&e.push("--keep-names")}function ft(e,t,r,s,d){var j;let l=[],u=[],i=Object.create(null),y=null,O=null,x=null;Oe(l,t,i,r,s),ze(l,t,i);let A=n(t,i,"sourcemap",Ie),K=n(t,i,"bundle",W),$=n(t,i,"watch",st),L=n(t,i,"splitting",W),ee=n(t,i,"preserveSymlinks",W),Q=n(t,i,"metafile",W),re=n(t,i,"outfile",h),te=n(t,i,"outdir",h),ae=n(t,i,"outbase",h),ue=n(t,i,"platform",h),H=n(t,i,"tsconfig",h),Re=n(t,i,"resolveExtensions",q),ve=n(t,i,"nodePaths",q),ke=n(t,i,"mainFields",q),Ee=n(t,i,"conditions",q),p=n(t,i,"external",q),c=n(t,i,"loader",me),a=n(t,i,"outExtension",me),g=n(t,i,"publicPath",h),U=n(t,i,"entryNames",h),F=n(t,i,"chunkNames",h),B=n(t,i,"assetNames",h),I=n(t,i,"inject",q),P=n(t,i,"banner",me),D=n(t,i,"footer",me),R=n(t,i,"entryPoints",ot),C=n(t,i,"absWorkingDir",h),k=n(t,i,"stdin",me),S=(j=n(t,i,"write",W))!=null?j:d,E=n(t,i,"allowOverwrite",W),m=n(t,i,"incremental",W)===!0;if(i.plugins=!0,z(t,i,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),K&&l.push("--bundle"),E&&l.push("--allow-overwrite"),$)if(l.push("--watch"),typeof $=="boolean")x={};else{let o=Object.create(null),v=n($,o,"onRebuild",Ce);z($,o,`on "watch" in ${e}() call`),x={onRebuild:v}}if(L&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),re&&l.push(`--outfile=${re}`),te&&l.push(`--outdir=${te}`),ae&&l.push(`--outbase=${ae}`),ue&&l.push(`--platform=${ue}`),H&&l.push(`--tsconfig=${H}`),Re){let o=[];for(let v of Re){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);o.push(v)}l.push(`--resolve-extensions=${o.join(",")}`)}if(g&&l.push(`--public-path=${g}`),U&&l.push(`--entry-names=${U}`),F&&l.push(`--chunk-names=${F}`),B&&l.push(`--asset-names=${B}`),ke){let o=[];for(let v of ke){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);o.push(v)}l.push(`--main-fields=${o.join(",")}`)}if(Ee){let o=[];for(let v of Ee){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);o.push(v)}l.push(`--conditions=${o.join(",")}`)}if(p)for(let o of p)l.push(`--external:${o}`);if(P)for(let o in P){if(o.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${o}`);l.push(`--banner:${o}=${P[o]}`)}if(D)for(let o in D){if(o.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${o}`);l.push(`--footer:${o}=${D[o]}`)}if(I)for(let o of I)l.push(`--inject:${o}`);if(c)for(let o in c){if(o.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${o}`);l.push(`--loader:${o}=${c[o]}`)}if(a)for(let o in a){if(o.indexOf("=")>=0)throw new Error(`Invalid out extension: ${o}`);l.push(`--out-extension:${o}=${a[o]}`)}if(R)if(Array.isArray(R))for(let o of R)u.push(["",o+""]);else for(let[o,v]of Object.entries(R))u.push([o+"",v+""]);if(k){let o=Object.create(null),v=n(k,o,"contents",h),f=n(k,o,"resolveDir",h),w=n(k,o,"sourcefile",h),M=n(k,o,"loader",h);z(k,o,'in "stdin" object'),w&&l.push(`--sourcefile=${w}`),M&&l.push(`--loader=${M}`),f&&(O=f+""),y=v?v+"":""}let b=[];if(ve)for(let o of ve)o+="",b.push(o);return{entries:u,flags:l,write:S,stdinContents:y,stdinResolveDir:O,absWorkingDir:C,incremental:m,nodePaths:b,watch:x}}function dt(e,t,r,s){let d=[],l=Object.create(null);Oe(d,t,l,r,s),ze(d,t,l);let u=n(t,l,"sourcemap",Ie),i=n(t,l,"tsconfigRaw",at),y=n(t,l,"sourcefile",h),O=n(t,l,"loader",h),x=n(t,l,"banner",h),A=n(t,l,"footer",h);return z(t,l,`in ${e}() call`),u&&d.push(`--sourcemap=${u===!0?"external":u}`),i&&d.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),y&&d.push(`--sourcefile=${y}`),O&&d.push(`--loader=${O}`),x&&d.push(`--banner=${x}`),A&&d.push(`--footer=${A}`),d}function Ye(e){let t=new Map,r=new Map,s=new Map,d=new Map,l=0,u=!1,i=0,y=0,O=new Uint8Array(16*1024),x=0,A=p=>{let c=x+p.length;if(c>O.length){let g=new Uint8Array(c*2);g.set(O),O=g}O.set(p,x),x+=p.length;let a=0;for(;a+4<=x;){let g=je(O,a);if(a+4+g>x)break;a+=4,re(O.subarray(a,a+g)),a+=g}a>0&&(O.copyWithin(0,a,x),x-=a)},K=()=>{u=!0;for(let p of t.values())p("The service was stopped",null);t.clear();for(let p of d.values())p.onWait("The service was stopped");d.clear();for(let p of s.values())try{p(new Error("The service was stopped"),null)}catch(c){console.error(c)}s.clear()},$=(p,c,a)=>{if(u)return a("The service is no longer running",null);let g=i++;t.set(g,(U,F)=>{try{a(U,F)}finally{p&&p.unref()}}),p&&p.ref(),e.writeToStdin(Te({id:g,isRequest:!0,value:c}))},L=(p,c)=>{if(u)throw new Error("The service is no longer running");e.writeToStdin(Te({id:p,isRequest:!1,value:c}))},ee=(p,c)=>se(this,null,function*(){try{switch(c.command){case"ping":{L(p,{});break}case"start":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"resolve":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"load":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"serve-request":{let a=d.get(c.serveID);a&&a.onRequest&&a.onRequest(c.args),L(p,{});break}case"serve-wait":{let a=d.get(c.serveID);a&&a.onWait(c.error),L(p,{});break}case"watch-rebuild":{let a=s.get(c.watchID);try{a&&a(null,c.args)}catch(g){console.error(g)}L(p,{});break}default:throw new Error("Invalid command: "+c.command)}}catch(a){L(p,{errors:[ye(a,e,null,void 0,"")]})}}),Q=!0,re=p=>{if(Q){Q=!1;let a=String.fromCharCode(...p);if(a!=="0.12.25")throw new Error(`Cannot start service: Host version "0.12.25" does not match binary version ${JSON.stringify(a)}`);return}let c=qe(p);if(c.isRequest)ee(c.id,c.value);else{let a=t.get(c.id);t.delete(c.id),c.value.error?a(c.value.error,{}):a(null,c.value)}},te=(p,c,a,g)=>se(this,null,function*(){let U=[],F=[],B={},I={},P=0,D=0,R=[];c=[...c];for(let E of c){let m={};if(typeof E!="object")throw new Error(`Plugin at index ${D} must be an object`);let b=n(E,m,"name",h);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${D} is missing a name`);try{let j=n(E,m,"setup",Ce);if(typeof j!="function")throw new Error("Plugin is missing a setup function");z(E,m,`on plugin ${JSON.stringify(b)}`);let o={name:b,onResolve:[],onLoad:[]};D++;let v=j({initialOptions:p,onStart(f){let w='This error came from the "onStart" callback registered here',M=Se(new Error(w),e,"onStart");U.push({name:b,callback:f,note:M})},onEnd(f){let w='This error came from the "onEnd" callback registered here',M=Se(new Error(w),e,"onEnd");F.push({name:b,callback:f,note:M})},onResolve(f,w){let M='This error came from the "onResolve" callback registered here',N=Se(new Error(M),e,"onResolve"),_={},V=n(f,_,"filter",_e),Y=n(f,_,"namespace",h);if(z(f,_,`in onResolve() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=P++;B[J]={name:b,callback:w,note:N},o.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(f,w){let M='This error came from the "onLoad" callback registered here',N=Se(new Error(M),e,"onLoad"),_={},V=n(f,_,"filter",_e),Y=n(f,_,"namespace",h);if(z(f,_,`in onLoad() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=P++;I[J]={name:b,callback:w,note:N},o.onLoad.push({id:J,filter:V.source,namespace:Y||""})}});v&&(yield v),R.push(o)}catch(j){return{ok:!1,error:j,pluginName:b}}}let C=E=>se(this,null,function*(){switch(E.command){case"start":{let m={errors:[],warnings:[]};return yield Promise.all(U.map(v=>se(this,[v],function*({name:b,callback:j,note:o}){try{let f=yield j();if(f!=null){if(typeof f!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"errors",q),N=n(f,w,"warnings",q);z(f,w,`from onStart() callback in plugin ${JSON.stringify(b)}`),M!=null&&m.errors.push(...fe(M,"errors",g,b)),N!=null&&m.warnings.push(...fe(N,"warnings",g,b))}}catch(f){m.errors.push(ye(f,e,g,o&&o(),b))}}))),m}case"resolve":{let m={},b="",j,o;for(let v of E.ids)try{({name:b,callback:j,note:o}=B[v]);let f=yield j({path:E.path,importer:E.importer,namespace:E.namespace,resolveDir:E.resolveDir,kind:E.kind,pluginData:g.load(E.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"pluginName",h),N=n(f,w,"path",h),_=n(f,w,"namespace",h),V=n(f,w,"external",W),Y=n(f,w,"sideEffects",W),J=n(f,w,"pluginData",Ne),le=n(f,w,"errors",q),ie=n(f,w,"warnings",q),T=n(f,w,"watchFiles",q),G=n(f,w,"watchDirs",q);z(f,w,`from onResolve() callback in plugin ${JSON.stringify(b)}`),m.id=v,M!=null&&(m.pluginName=M),N!=null&&(m.path=N),_!=null&&(m.namespace=_),V!=null&&(m.external=V),Y!=null&&(m.sideEffects=Y),J!=null&&(m.pluginData=g.store(J)),le!=null&&(m.errors=fe(le,"errors",g,b)),ie!=null&&(m.warnings=fe(ie,"warnings",g,b)),T!=null&&(m.watchFiles=xe(T,"watchFiles")),G!=null&&(m.watchDirs=xe(G,"watchDirs"));break}}catch(f){return{id:v,errors:[ye(f,e,g,o&&o(),b)]}}return m}case"load":{let m={},b="",j,o;for(let v of E.ids)try{({name:b,callback:j,note:o}=I[v]);let f=yield j({path:E.path,namespace:E.namespace,pluginData:g.load(E.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"pluginName",h),N=n(f,w,"contents",ct),_=n(f,w,"resolveDir",h),V=n(f,w,"pluginData",Ne),Y=n(f,w,"loader",h),J=n(f,w,"errors",q),le=n(f,w,"warnings",q),ie=n(f,w,"watchFiles",q),T=n(f,w,"watchDirs",q);z(f,w,`from onLoad() callback in plugin ${JSON.stringify(b)}`),m.id=v,M!=null&&(m.pluginName=M),N instanceof Uint8Array?m.contents=N:N!=null&&(m.contents=oe(N)),_!=null&&(m.resolveDir=_),V!=null&&(m.pluginData=g.store(V)),Y!=null&&(m.loader=Y),J!=null&&(m.errors=fe(J,"errors",g,b)),le!=null&&(m.warnings=fe(le,"warnings",g,b)),ie!=null&&(m.watchFiles=xe(ie,"watchFiles")),T!=null&&(m.watchDirs=xe(T,"watchDirs"));break}}catch(f){return{id:v,errors:[ye(f,e,g,o&&o(),b)]}}return m}default:throw new Error("Invalid command: "+E.command)}}),k=(E,m,b)=>b();F.length>0&&(k=(E,m,b)=>{(()=>se(this,null,function*(){for(let{name:j,callback:o,note:v}of F)try{yield o(E)}catch(f){E.errors.push(yield new Promise(w=>m(f,j,v&&v(),w)))}}))().then(b)});let S=0;return{ok:!0,requestPlugins:R,runOnEndCallbacks:k,pluginRefs:{ref(){++S==1&&r.set(a,C)},unref(){--S==0&&r.delete(a)}}}}),ae=(p,c,a)=>{let g={},U=n(c,g,"port",ge),F=n(c,g,"host",h),B=n(c,g,"servedir",h),I=n(c,g,"onRequest",Ce),P=l++,D,R=new Promise((C,k)=>{D=S=>{d.delete(P),S!==null?k(new Error(S)):C()}});return a.serve={serveID:P},z(c,g,"in serve() call"),U!==void 0&&(a.serve.port=U),F!==void 0&&(a.serve.host=F),B!==void 0&&(a.serve.servedir=B),d.set(P,{onRequest:I,onWait:D}),{wait:R,stop(){$(p,{command:"serve-stop",serveID:P},()=>{})}}},ue="warning",H="silent",Re=p=>{let c=y++,a=He(),g,{refs:U,options:F,isTTY:B,callback:I}=p;if(typeof F=="object"){let R=F.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');g=R}}let P=(R,C,k,S)=>{let E=[];try{Oe(E,F,{},B,ue)}catch(b){}let m=ye(R,e,a,k,C);$(U,{command:"error",flags:E,error:m},()=>{m.detail=a.load(m.detail),S(m)})},D=(R,C)=>{P(R,C,void 0,k=>{I(he("Build failed",[k],[]),null)})};if(g&&g.length>0){if(e.isSync)return D(new Error("Cannot use plugins in synchronous API calls"),"");te(F,g,c,a).then(R=>{if(!R.ok)D(R.error,R.pluginName);else try{ve(Be(Pe({},p),{key:c,details:a,logPluginError:P,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(C){D(C,"")}},R=>D(R,""))}else try{ve(Be(Pe({},p),{key:c,details:a,logPluginError:P,requestPlugins:null,runOnEndCallbacks:(R,C,k)=>k(),pluginRefs:null}))}catch(R){D(R,"")}},ve=({callName:p,refs:c,serveOptions:a,options:g,isTTY:U,defaultWD:F,callback:B,key:I,details:P,logPluginError:D,requestPlugins:R,runOnEndCallbacks:C,pluginRefs:k})=>{let S={ref(){k&&k.ref(),c&&c.ref()},unref(){k&&k.unref(),c&&c.unref()}},E=!e.isBrowser,{entries:m,flags:b,write:j,stdinContents:o,stdinResolveDir:v,absWorkingDir:f,incremental:w,nodePaths:M,watch:N}=ft(p,g,U,ue,E),_={command:"build",key:I,entries:m,flags:b,write:j,stdinContents:o,stdinResolveDir:v,absWorkingDir:f||F,incremental:w,nodePaths:M};R&&(_.plugins=R);let V=a&&ae(S,a,_),Y,J,le=(T,G)=>{T.outputFiles&&(G.outputFiles=T.outputFiles.map(pt)),T.metafile&&(G.metafile=JSON.parse(T.metafile)),T.writeToStdout!==void 0&&console.log(ce(T.writeToStdout).replace(/\n$/,""))},ie=(T,G)=>{let X={errors:be(T.errors,P),warnings:be(T.warnings,P)};le(T,X),C(X,D,()=>{if(X.errors.length>0)return G(he("Build failed",X.errors,X.warnings),null);if(T.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((de,pe)=>{if(ne||u)throw new Error("Cannot rebuild");$(S,{command:"rebuild",rebuildID:T.rebuildID},(Z,Xe)=>{if(Z)return G(he("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);ie(Xe,($e,Ze)=>{$e?pe($e):de(Ze)})})}),S.ref(),Y.dispose=()=>{ne||(ne=!0,$(S,{command:"rebuild-dispose",rebuildID:T.rebuildID},()=>{}),S.unref())}}X.rebuild=Y}if(T.watchID!==void 0){if(!J){let ne=!1;S.ref(),J=()=>{ne||(ne=!0,s.delete(T.watchID),$(S,{command:"watch-stop",watchID:T.watchID},()=>{}),S.unref())},N&&s.set(T.watchID,(de,pe)=>{if(de){N.onRebuild&&N.onRebuild(de,null);return}let Z={errors:be(pe.errors,P),warnings:be(pe.warnings,P)};le(pe,Z),C(Z,D,()=>{if(Z.errors.length>0){N.onRebuild&&N.onRebuild(he("Build failed",Z.errors,Z.warnings),null);return}pe.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,N.onRebuild&&N.onRebuild(null,Z)})})}X.stop=J}G(null,X)})};if(j&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(w&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(N&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');$(S,_,(T,G)=>{if(T)return B(new Error(T),null);if(V){let X=G,ne=!1;S.ref();let de={port:X.port,host:X.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),S.unref())}};return S.ref(),V.wait.then(S.unref,S.unref),B(null,de)}return ie(G,B)})};return{readFromStdout:A,afterClose:K,service:{buildOrServe:Re,transform:({callName:p,refs:c,input:a,options:g,isTTY:U,fs:F,callback:B})=>{let I=He(),P=D=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let R=dt(p,g,U,H);$(c,{command:"transform",flags:R,inputFS:D!==null,input:D!==null?D:a},(k,S)=>{if(k)return B(new Error(k),null);let E=be(S.errors,I),m=be(S.warnings,I),b=1,j=()=>--b==0&&B(null,{warnings:m,code:S.code,map:S.map});if(E.length>0)return B(he("Transform failed",E,m),null);S.codeFS&&(b++,F.readFile(S.code,(o,v)=>{o!==null?B(o,null):(S.code=v,j())})),S.mapFS&&(b++,F.readFile(S.map,(o,v)=>{o!==null?B(o,null):(S.map=v,j())})),j()})}catch(R){let C=[];try{Oe(C,g,{},U,H)}catch(S){}let k=ye(R,e,I,void 0,"");$(c,{command:"error",flags:C,error:k},()=>{k.detail=I.load(k.detail),B(he("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let D=P;P=()=>F.writeFile(a,D)}P(null)},formatMessages:({callName:p,refs:c,messages:a,options:g,callback:U})=>{let F=fe(a,"messages",null,"");if(!g)throw new Error(`Missing second argument in ${p}() call`);let B={},I=n(g,B,"kind",h),P=n(g,B,"color",W),D=n(g,B,"terminalWidth",ge);if(z(g,B,`in ${p}() call`),I===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(I!=="error"&&I!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let R={command:"format-msgs",messages:F,isWarning:I==="warning"};P!==void 0&&(R.color=P),D!==void 0&&(R.terminalWidth=D),$(c,R,(C,k)=>{if(C)return U(new Error(C),null);U(null,k.messages)})}}}}function He(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let s=t++;return e.set(s,r),s}}}function Se(e,t,r){let s,d=!1;return()=>{if(d)return s;d=!0;try{let l=(e.stack+"").split(`
3
- `);l.splice(1,1);let u=Ge(t,l,r);if(u)return s={text:e.message,location:u},s}catch(l){}}}function ye(e,t,r,s,d){let l="Internal error",u=null;try{l=(e&&e.message||e)+""}catch(i){}try{u=Ge(t,(e.stack+"").split(`
4
- `),"")}catch(i){}return{pluginName:d,text:l,location:u,notes:s?[s]:[],detail:r?r.store(e):-1}}function Ge(e,t,r){let s=" at ";if(e.readFileSync&&!t[0].startsWith(s)&&t[1].startsWith(s))for(let d=1;d<t.length;d++){let l=t[d];if(!!l.startsWith(s))for(l=l.slice(s.length);;){let u=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(u){l=u[1];continue}if(u=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),u){l=u[1];continue}if(u=/^(\S+):(\d+):(\d+)$/.exec(l),u){let i;try{i=e.readFileSync(u[1],"utf8")}catch(A){break}let y=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+u[2]-1]||"",O=+u[3]-1,x=y.slice(O,O+r.length)===r?r.length:0;return{file:u[1],namespace:"file",line:+u[2],column:oe(y.slice(0,O)).length,length:oe(y.slice(O,O+x)).length,lineText:y+`
2
+ var Me=Object.defineProperty,tt=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var qe=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var We=(e,t,r)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Be=(e,t)=>{for(var r in t||(t={}))nt.call(t,r)&&We(e,r,t[r]);if(qe)for(var r of qe(t))lt.call(t,r)&&We(e,r,t[r]);return e},Te=(e,t)=>tt(e,rt(t)),it=e=>Me(e,"__esModule",{value:!0});var $t=typeof require!="undefined"?require:e=>{throw new Error('Dynamic require of "'+e+'" is not supported')};var st=(e,t)=>{it(e);for(var r in t)Me(e,r,{get:t[r],enumerable:!0})};var se=(e,t,r)=>new Promise((s,d)=>{var l=m=>{try{i(r.next(m))}catch(R){d(R)}},u=m=>{try{i(r.throw(m))}catch(R){d(R)}},i=m=>m.done?s(m.value):Promise.resolve(m.value).then(l,u);i((r=r.apply(e,t)).next())});st(exports,{analyzeMetafile:()=>vt,analyzeMetafileSync:()=>xt,build:()=>yt,buildSync:()=>Rt,formatMessages:()=>wt,formatMessagesSync:()=>St,initialize:()=>kt,serve:()=>ht,transform:()=>bt,transformSync:()=>Ot,version:()=>mt});function Fe(e){let t=s=>{if(s===null)r.write8(0);else if(typeof s=="boolean")r.write8(1),r.write8(+s);else if(typeof s=="number")r.write8(2),r.write32(s|0);else if(typeof s=="string")r.write8(3),r.write(oe(s));else if(s instanceof Uint8Array)r.write8(4),r.write(s);else if(s instanceof Array){r.write8(5),r.write32(s.length);for(let d of s)t(d)}else{let d=Object.keys(s);r.write8(6),r.write32(d.length);for(let l of d)r.write(oe(l)),t(s[l])}},r=new Ae;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),je(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function ze(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ce(r.read());case 4:return r.read();case 5:{let u=r.read32(),i=[];for(let m=0;m<u;m++)i.push(t());return i}case 6:{let u=r.read32(),i={};for(let m=0;m<u;m++)i[ce(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Ae(e),s=r.read32(),d=(s&1)==0;s>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:s,isRequest:d,value:l}}var Ae=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 r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);je(this.buf,t,r)}write(t){let r=this._write(4+t.length);je(this.buf,t.length,r),this.buf.set(t,r+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 Ne(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),s=this._read(r.length);return r.set(this.buf.subarray(s,s+t)),r}},oe,ce;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;oe=r=>e.encode(r),ce=r=>t.decode(r)}else if(typeof Buffer!="undefined")oe=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ce=e=>{let{buffer:t,byteOffset:r,byteLength:s}=e;return Buffer.from(t,r,s).toString()};else throw new Error("No UTF-8 codec found");function Ne(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function je(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function Ke(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Ie=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",ot=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",h=e=>typeof e=="string"?null:"a string",_e=e=>e instanceof RegExp?null:"a RegExp object",ge=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ce=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",at=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ve=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Le=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",ut=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ct=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ft=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,s){let d=e[r];if(t[r+""]=!0,d===void 0)return;let l=s(d);if(l!==null)throw new Error(`"${r}" must be ${l}`);return d}function _(e,t,r){for(let s in e)if(!(s in t))throw new Error(`Invalid option ${r}: "${s}"`)}function Je(e){let t=Object.create(null),r=n(e,t,"wasmURL",h),s=n(e,t,"worker",q);return _(e,t,"in startService() call"),{wasmURL:r,worker:s}}function Oe(e,t,r,s,d){let l=n(t,r,"color",q),u=n(t,r,"logLevel",h),i=n(t,r,"logLimit",ge);l!==void 0?e.push(`--color=${l}`):s&&e.push("--color=true"),e.push(`--log-level=${u||d}`),e.push(`--log-limit=${i||0}`)}function Ye(e,t,r){let s=n(t,r,"legalComments",h),d=n(t,r,"sourceRoot",h),l=n(t,r,"sourcesContent",q),u=n(t,r,"target",ct),i=n(t,r,"format",h),m=n(t,r,"globalName",h),R=n(t,r,"minify",q),x=n(t,r,"minifySyntax",q),A=n(t,r,"minifyWhitespace",q),L=n(t,r,"minifyIdentifiers",q),k=n(t,r,"charset",h),U=n(t,r,"treeShaking",Le),ee=n(t,r,"jsx",h),Q=n(t,r,"jsxFactory",h),re=n(t,r,"jsxFragment",h),te=n(t,r,"define",me),ae=n(t,r,"pure",z),ue=n(t,r,"keepNames",q);if(s&&e.push(`--legal-comments=${s}`),d!==void 0&&e.push(`--source-root=${d}`),l!==void 0&&e.push(`--sources-content=${l}`),u&&(Array.isArray(u)?e.push(`--target=${Array.from(u).map(Ke).join(",")}`):e.push(`--target=${Ke(u)}`)),i&&e.push(`--format=${i}`),m&&e.push(`--global-name=${m}`),R&&e.push("--minify"),x&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),L&&e.push("--minify-identifiers"),k&&e.push(`--charset=${k}`),U!==void 0&&U!==!0&&e.push(`--tree-shaking=${U}`),ee&&e.push(`--jsx=${ee}`),Q&&e.push(`--jsx-factory=${Q}`),re&&e.push(`--jsx-fragment=${re}`),te)for(let H in te){if(H.indexOf("=")>=0)throw new Error(`Invalid define: ${H}`);e.push(`--define:${H}=${te[H]}`)}if(ae)for(let H of ae)e.push(`--pure:${H}`);ue&&e.push("--keep-names")}function dt(e,t,r,s,d){var w;let l=[],u=[],i=Object.create(null),m=null,R=null,x=null;Oe(l,t,i,r,s),Ye(l,t,i);let A=n(t,i,"sourcemap",Le),L=n(t,i,"bundle",q),k=n(t,i,"watch",ot),U=n(t,i,"splitting",q),ee=n(t,i,"preserveSymlinks",q),Q=n(t,i,"metafile",q),re=n(t,i,"outfile",h),te=n(t,i,"outdir",h),ae=n(t,i,"outbase",h),ue=n(t,i,"platform",h),H=n(t,i,"tsconfig",h),Re=n(t,i,"resolveExtensions",z),ve=n(t,i,"nodePaths",z),Ee=n(t,i,"mainFields",z),$e=n(t,i,"conditions",z),De=n(t,i,"external",z),g=n(t,i,"loader",me),c=n(t,i,"outExtension",me),o=n(t,i,"publicPath",h),p=n(t,i,"entryNames",h),j=n(t,i,"chunkNames",h),M=n(t,i,"assetNames",h),P=n(t,i,"inject",z),N=n(t,i,"banner",me),D=n(t,i,"footer",me),E=n(t,i,"entryPoints",at),O=n(t,i,"absWorkingDir",h),B=n(t,i,"stdin",me),T=(w=n(t,i,"write",q))!=null?w:d,S=n(t,i,"allowOverwrite",q),$=n(t,i,"incremental",q)===!0;if(i.plugins=!0,_(t,i,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),L&&l.push("--bundle"),S&&l.push("--allow-overwrite"),k)if(l.push("--watch"),typeof k=="boolean")x={};else{let a=Object.create(null),b=n(k,a,"onRebuild",Ce);_(k,a,`on "watch" in ${e}() call`),x={onRebuild:b}}if(U&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),re&&l.push(`--outfile=${re}`),te&&l.push(`--outdir=${te}`),ae&&l.push(`--outbase=${ae}`),ue&&l.push(`--platform=${ue}`),H&&l.push(`--tsconfig=${H}`),Re){let a=[];for(let b of Re){if(b+="",b.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${b}`);a.push(b)}l.push(`--resolve-extensions=${a.join(",")}`)}if(o&&l.push(`--public-path=${o}`),p&&l.push(`--entry-names=${p}`),j&&l.push(`--chunk-names=${j}`),M&&l.push(`--asset-names=${M}`),Ee){let a=[];for(let b of Ee){if(b+="",b.indexOf(",")>=0)throw new Error(`Invalid main field: ${b}`);a.push(b)}l.push(`--main-fields=${a.join(",")}`)}if($e){let a=[];for(let b of $e){if(b+="",b.indexOf(",")>=0)throw new Error(`Invalid condition: ${b}`);a.push(b)}l.push(`--conditions=${a.join(",")}`)}if(De)for(let a of De)l.push(`--external:${a}`);if(N)for(let a in N){if(a.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${a}`);l.push(`--banner:${a}=${N[a]}`)}if(D)for(let a in D){if(a.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${a}`);l.push(`--footer:${a}=${D[a]}`)}if(P)for(let a of P)l.push(`--inject:${a}`);if(g)for(let a in g){if(a.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${a}`);l.push(`--loader:${a}=${g[a]}`)}if(c)for(let a in c){if(a.indexOf("=")>=0)throw new Error(`Invalid out extension: ${a}`);l.push(`--out-extension:${a}=${c[a]}`)}if(E)if(Array.isArray(E))for(let a of E)u.push(["",a+""]);else for(let[a,b]of Object.entries(E))u.push([a+"",b+""]);if(B){let a=Object.create(null),b=n(B,a,"contents",h),C=n(B,a,"resolveDir",h),f=n(B,a,"sourcefile",h),v=n(B,a,"loader",h);_(B,a,'in "stdin" object'),f&&l.push(`--sourcefile=${f}`),v&&l.push(`--loader=${v}`),C&&(R=C+""),m=b?b+"":""}let y=[];if(ve)for(let a of ve)a+="",y.push(a);return{entries:u,flags:l,write:T,stdinContents:m,stdinResolveDir:R,absWorkingDir:O,incremental:$,nodePaths:y,watch:x}}function pt(e,t,r,s){let d=[],l=Object.create(null);Oe(d,t,l,r,s),Ye(d,t,l);let u=n(t,l,"sourcemap",Le),i=n(t,l,"tsconfigRaw",ut),m=n(t,l,"sourcefile",h),R=n(t,l,"loader",h),x=n(t,l,"banner",h),A=n(t,l,"footer",h);return _(t,l,`in ${e}() call`),u&&d.push(`--sourcemap=${u===!0?"external":u}`),i&&d.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),m&&d.push(`--sourcefile=${m}`),R&&d.push(`--loader=${R}`),x&&d.push(`--banner=${x}`),A&&d.push(`--footer=${A}`),d}function He(e){let t=new Map,r=new Map,s=new Map,d=new Map,l=0,u=!1,i=0,m=0,R=new Uint8Array(16*1024),x=0,A=g=>{let c=x+g.length;if(c>R.length){let p=new Uint8Array(c*2);p.set(R),R=p}R.set(g,x),x+=g.length;let o=0;for(;o+4<=x;){let p=Ne(R,o);if(o+4+p>x)break;o+=4,re(R.subarray(o,o+p)),o+=p}o>0&&(R.copyWithin(0,o,x),x-=o)},L=()=>{u=!0;for(let g of t.values())g("The service was stopped",null);t.clear();for(let g of d.values())g.onWait("The service was stopped");d.clear();for(let g of s.values())try{g(new Error("The service was stopped"),null)}catch(c){console.error(c)}s.clear()},k=(g,c,o)=>{if(u)return o("The service is no longer running",null);let p=i++;t.set(p,(j,M)=>{try{o(j,M)}finally{g&&g.unref()}}),g&&g.ref(),e.writeToStdin(Fe({id:p,isRequest:!0,value:c}))},U=(g,c)=>{if(u)throw new Error("The service is no longer running");e.writeToStdin(Fe({id:g,isRequest:!1,value:c}))},ee=(g,c)=>se(this,null,function*(){try{switch(c.command){case"ping":{U(g,{});break}case"start":{let o=r.get(c.key);o?U(g,yield o(c)):U(g,{});break}case"resolve":{let o=r.get(c.key);o?U(g,yield o(c)):U(g,{});break}case"load":{let o=r.get(c.key);o?U(g,yield o(c)):U(g,{});break}case"serve-request":{let o=d.get(c.serveID);o&&o.onRequest&&o.onRequest(c.args),U(g,{});break}case"serve-wait":{let o=d.get(c.serveID);o&&o.onWait(c.error),U(g,{});break}case"watch-rebuild":{let o=s.get(c.watchID);try{o&&o(null,c.args)}catch(p){console.error(p)}U(g,{});break}default:throw new Error("Invalid command: "+c.command)}}catch(o){U(g,{errors:[ye(o,e,null,void 0,"")]})}}),Q=!0,re=g=>{if(Q){Q=!1;let o=String.fromCharCode(...g);if(o!=="0.12.27")throw new Error(`Cannot start service: Host version "0.12.27" does not match binary version ${JSON.stringify(o)}`);return}let c=ze(g);if(c.isRequest)ee(c.id,c.value);else{let o=t.get(c.id);t.delete(c.id),c.value.error?o(c.value.error,{}):o(null,c.value)}},te=(g,c,o,p)=>se(this,null,function*(){let j=[],M=[],P={},N={},D=0,E=0,O=[];c=[...c];for(let $ of c){let y={};if(typeof $!="object")throw new Error(`Plugin at index ${E} must be an object`);let w=n($,y,"name",h);if(typeof w!="string"||w==="")throw new Error(`Plugin at index ${E} is missing a name`);try{let a=n($,y,"setup",Ce);if(typeof a!="function")throw new Error("Plugin is missing a setup function");_($,y,`on plugin ${JSON.stringify(w)}`);let b={name:w,onResolve:[],onLoad:[]};E++;let C=a({initialOptions:g,onStart(f){let v='This error came from the "onStart" callback registered here',W=Se(new Error(v),e,"onStart");j.push({name:w,callback:f,note:W})},onEnd(f){let v='This error came from the "onEnd" callback registered here',W=Se(new Error(v),e,"onEnd");M.push({name:w,callback:f,note:W})},onResolve(f,v){let W='This error came from the "onResolve" callback registered here',I=Se(new Error(W),e,"onResolve"),K={},V=n(f,K,"filter",_e),Y=n(f,K,"namespace",h);if(_(f,K,`in onResolve() call for plugin ${JSON.stringify(w)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=D++;P[J]={name:w,callback:v,note:I},b.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(f,v){let W='This error came from the "onLoad" callback registered here',I=Se(new Error(W),e,"onLoad"),K={},V=n(f,K,"filter",_e),Y=n(f,K,"namespace",h);if(_(f,K,`in onLoad() call for plugin ${JSON.stringify(w)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=D++;N[J]={name:w,callback:v,note:I},b.onLoad.push({id:J,filter:V.source,namespace:Y||""})}});C&&(yield C),O.push(b)}catch(a){return{ok:!1,error:a,pluginName:w}}}let B=$=>se(this,null,function*(){switch($.command){case"start":{let y={errors:[],warnings:[]};return yield Promise.all(j.map(C=>se(this,[C],function*({name:w,callback:a,note:b}){try{let f=yield a();if(f!=null){if(typeof f!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(w)} to return an object`);let v={},W=n(f,v,"errors",z),I=n(f,v,"warnings",z);_(f,v,`from onStart() callback in plugin ${JSON.stringify(w)}`),W!=null&&y.errors.push(...fe(W,"errors",p,w)),I!=null&&y.warnings.push(...fe(I,"warnings",p,w))}}catch(f){y.errors.push(ye(f,e,p,b&&b(),w))}}))),y}case"resolve":{let y={},w="",a,b;for(let C of $.ids)try{({name:w,callback:a,note:b}=P[C]);let f=yield a({path:$.path,importer:$.importer,namespace:$.namespace,resolveDir:$.resolveDir,kind:$.kind,pluginData:p.load($.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(w)} to return an object`);let v={},W=n(f,v,"pluginName",h),I=n(f,v,"path",h),K=n(f,v,"namespace",h),V=n(f,v,"external",q),Y=n(f,v,"sideEffects",q),J=n(f,v,"pluginData",Ie),le=n(f,v,"errors",z),ie=n(f,v,"warnings",z),F=n(f,v,"watchFiles",z),G=n(f,v,"watchDirs",z);_(f,v,`from onResolve() callback in plugin ${JSON.stringify(w)}`),y.id=C,W!=null&&(y.pluginName=W),I!=null&&(y.path=I),K!=null&&(y.namespace=K),V!=null&&(y.external=V),Y!=null&&(y.sideEffects=Y),J!=null&&(y.pluginData=p.store(J)),le!=null&&(y.errors=fe(le,"errors",p,w)),ie!=null&&(y.warnings=fe(ie,"warnings",p,w)),F!=null&&(y.watchFiles=xe(F,"watchFiles")),G!=null&&(y.watchDirs=xe(G,"watchDirs"));break}}catch(f){return{id:C,errors:[ye(f,e,p,b&&b(),w)]}}return y}case"load":{let y={},w="",a,b;for(let C of $.ids)try{({name:w,callback:a,note:b}=N[C]);let f=yield a({path:$.path,namespace:$.namespace,pluginData:p.load($.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(w)} to return an object`);let v={},W=n(f,v,"pluginName",h),I=n(f,v,"contents",ft),K=n(f,v,"resolveDir",h),V=n(f,v,"pluginData",Ie),Y=n(f,v,"loader",h),J=n(f,v,"errors",z),le=n(f,v,"warnings",z),ie=n(f,v,"watchFiles",z),F=n(f,v,"watchDirs",z);_(f,v,`from onLoad() callback in plugin ${JSON.stringify(w)}`),y.id=C,W!=null&&(y.pluginName=W),I instanceof Uint8Array?y.contents=I:I!=null&&(y.contents=oe(I)),K!=null&&(y.resolveDir=K),V!=null&&(y.pluginData=p.store(V)),Y!=null&&(y.loader=Y),J!=null&&(y.errors=fe(J,"errors",p,w)),le!=null&&(y.warnings=fe(le,"warnings",p,w)),ie!=null&&(y.watchFiles=xe(ie,"watchFiles")),F!=null&&(y.watchDirs=xe(F,"watchDirs"));break}}catch(f){return{id:C,errors:[ye(f,e,p,b&&b(),w)]}}return y}default:throw new Error("Invalid command: "+$.command)}}),T=($,y,w)=>w();M.length>0&&(T=($,y,w)=>{(()=>se(this,null,function*(){for(let{name:a,callback:b,note:C}of M)try{yield b($)}catch(f){$.errors.push(yield new Promise(v=>y(f,a,C&&C(),v)))}}))().then(w)});let S=0;return{ok:!0,requestPlugins:O,runOnEndCallbacks:T,pluginRefs:{ref(){++S==1&&r.set(o,B)},unref(){--S==0&&r.delete(o)}}}}),ae=(g,c,o)=>{let p={},j=n(c,p,"port",ge),M=n(c,p,"host",h),P=n(c,p,"servedir",h),N=n(c,p,"onRequest",Ce),D=l++,E,O=new Promise((B,T)=>{E=S=>{d.delete(D),S!==null?T(new Error(S)):B()}});return o.serve={serveID:D},_(c,p,"in serve() call"),j!==void 0&&(o.serve.port=j),M!==void 0&&(o.serve.host=M),P!==void 0&&(o.serve.servedir=P),d.set(D,{onRequest:N,onWait:E}),{wait:O,stop(){k(g,{command:"serve-stop",serveID:D},()=>{})}}},ue="warning",H="silent",Re=g=>{let c=m++,o=Ge(),p,{refs:j,options:M,isTTY:P,callback:N}=g;if(typeof M=="object"){let O=M.plugins;if(O!==void 0){if(!Array.isArray(O))throw new Error('"plugins" must be an array');p=O}}let D=(O,B,T,S)=>{let $=[];try{Oe($,M,{},P,ue)}catch(w){}let y=ye(O,e,o,T,B);k(j,{command:"error",flags:$,error:y},()=>{y.detail=o.load(y.detail),S(y)})},E=(O,B)=>{D(O,B,void 0,T=>{N(he("Build failed",[T],[]),null)})};if(p&&p.length>0){if(e.isSync)return E(new Error("Cannot use plugins in synchronous API calls"),"");te(M,p,c,o).then(O=>{if(!O.ok)E(O.error,O.pluginName);else try{ve(Te(Be({},g),{key:c,details:o,logPluginError:D,requestPlugins:O.requestPlugins,runOnEndCallbacks:O.runOnEndCallbacks,pluginRefs:O.pluginRefs}))}catch(B){E(B,"")}},O=>E(O,""))}else try{ve(Te(Be({},g),{key:c,details:o,logPluginError:D,requestPlugins:null,runOnEndCallbacks:(O,B,T)=>T(),pluginRefs:null}))}catch(O){E(O,"")}},ve=({callName:g,refs:c,serveOptions:o,options:p,isTTY:j,defaultWD:M,callback:P,key:N,details:D,logPluginError:E,requestPlugins:O,runOnEndCallbacks:B,pluginRefs:T})=>{let S={ref(){T&&T.ref(),c&&c.ref()},unref(){T&&T.unref(),c&&c.unref()}},$=!e.isBrowser,{entries:y,flags:w,write:a,stdinContents:b,stdinResolveDir:C,absWorkingDir:f,incremental:v,nodePaths:W,watch:I}=dt(g,p,j,ue,$),K={command:"build",key:N,entries:y,flags:w,write:a,stdinContents:b,stdinResolveDir:C,absWorkingDir:f||M,incremental:v,nodePaths:W};O&&(K.plugins=O);let V=o&&ae(S,o,K),Y,J,le=(F,G)=>{F.outputFiles&&(G.outputFiles=F.outputFiles.map(gt)),F.metafile&&(G.metafile=JSON.parse(F.metafile)),F.writeToStdout!==void 0&&console.log(ce(F.writeToStdout).replace(/\n$/,""))},ie=(F,G)=>{let X={errors:be(F.errors,D),warnings:be(F.warnings,D)};le(F,X),B(X,E,()=>{if(X.errors.length>0)return G(he("Build failed",X.errors,X.warnings),null);if(F.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((de,pe)=>{if(ne||u)throw new Error("Cannot rebuild");k(S,{command:"rebuild",rebuildID:F.rebuildID},(Z,Ze)=>{if(Z)return G(he("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);ie(Ze,(Pe,et)=>{Pe?pe(Pe):de(et)})})}),S.ref(),Y.dispose=()=>{ne||(ne=!0,k(S,{command:"rebuild-dispose",rebuildID:F.rebuildID},()=>{}),S.unref())}}X.rebuild=Y}if(F.watchID!==void 0){if(!J){let ne=!1;S.ref(),J=()=>{ne||(ne=!0,s.delete(F.watchID),k(S,{command:"watch-stop",watchID:F.watchID},()=>{}),S.unref())},I&&s.set(F.watchID,(de,pe)=>{if(de){I.onRebuild&&I.onRebuild(de,null);return}let Z={errors:be(pe.errors,D),warnings:be(pe.warnings,D)};le(pe,Z),B(Z,E,()=>{if(Z.errors.length>0){I.onRebuild&&I.onRebuild(he("Build failed",Z.errors,Z.warnings),null);return}pe.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,I.onRebuild&&I.onRebuild(null,Z)})})}X.stop=J}G(null,X)})};if(a&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(v&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(I&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');k(S,K,(F,G)=>{if(F)return P(new Error(F),null);if(V){let X=G,ne=!1;S.ref();let de={port:X.port,host:X.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),S.unref())}};return S.ref(),V.wait.then(S.unref,S.unref),P(null,de)}return ie(G,P)})};return{readFromStdout:A,afterClose:L,service:{buildOrServe:Re,transform:({callName:g,refs:c,input:o,options:p,isTTY:j,fs:M,callback:P})=>{let N=Ge(),D=E=>{try{if(typeof o!="string")throw new Error('The input to "transform" must be a string');let O=pt(g,p,j,H);k(c,{command:"transform",flags:O,inputFS:E!==null,input:E!==null?E:o},(T,S)=>{if(T)return P(new Error(T),null);let $=be(S.errors,N),y=be(S.warnings,N),w=1,a=()=>--w==0&&P(null,{warnings:y,code:S.code,map:S.map});if($.length>0)return P(he("Transform failed",$,y),null);S.codeFS&&(w++,M.readFile(S.code,(b,C)=>{b!==null?P(b,null):(S.code=C,a())})),S.mapFS&&(w++,M.readFile(S.map,(b,C)=>{b!==null?P(b,null):(S.map=C,a())})),a()})}catch(O){let B=[];try{Oe(B,p,{},j,H)}catch(S){}let T=ye(O,e,N,void 0,"");k(c,{command:"error",flags:B,error:T},()=>{T.detail=N.load(T.detail),P(he("Transform failed",[T],[]),null)})}};if(typeof o=="string"&&o.length>1024*1024){let E=D;D=()=>M.writeFile(o,E)}D(null)},formatMessages:({callName:g,refs:c,messages:o,options:p,callback:j})=>{let M=fe(o,"messages",null,"");if(!p)throw new Error(`Missing second argument in ${g}() call`);let P={},N=n(p,P,"kind",h),D=n(p,P,"color",q),E=n(p,P,"terminalWidth",ge);if(_(p,P,`in ${g}() call`),N===void 0)throw new Error(`Missing "kind" in ${g}() call`);if(N!=="error"&&N!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${g}() call`);let O={command:"format-msgs",messages:M,isWarning:N==="warning"};D!==void 0&&(O.color=D),E!==void 0&&(O.terminalWidth=E),k(c,O,(B,T)=>{if(B)return j(new Error(B),null);j(null,T.messages)})},analyzeMetafile:({callName:g,refs:c,metafile:o,options:p,callback:j})=>{p===void 0&&(p={});let M={},P=n(p,M,"color",q),N=n(p,M,"verbose",q);_(p,M,`in ${g}() call`);let D={command:"analyze-metafile",metafile:o};P!==void 0&&(D.color=P),N!==void 0&&(D.verbose=N),k(c,D,(E,O)=>{if(E)return j(new Error(E),null);j(null,O.result)})}}}}function Ge(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let s=t++;return e.set(s,r),s}}}function Se(e,t,r){let s,d=!1;return()=>{if(d)return s;d=!0;try{let l=(e.stack+"").split(`
3
+ `);l.splice(1,1);let u=Qe(t,l,r);if(u)return s={text:e.message,location:u},s}catch(l){}}}function ye(e,t,r,s,d){let l="Internal error",u=null;try{l=(e&&e.message||e)+""}catch(i){}try{u=Qe(t,(e.stack+"").split(`
4
+ `),"")}catch(i){}return{pluginName:d,text:l,location:u,notes:s?[s]:[],detail:r?r.store(e):-1}}function Qe(e,t,r){let s=" at ";if(e.readFileSync&&!t[0].startsWith(s)&&t[1].startsWith(s))for(let d=1;d<t.length;d++){let l=t[d];if(!!l.startsWith(s))for(l=l.slice(s.length);;){let u=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(u){l=u[1];continue}if(u=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),u){l=u[1];continue}if(u=/^(\S+):(\d+):(\d+)$/.exec(l),u){let i;try{i=e.readFileSync(u[1],"utf8")}catch(A){break}let m=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+u[2]-1]||"",R=+u[3]-1,x=m.slice(R,R+r.length)===r?r.length:0;return{file:u[1],namespace:"file",line:+u[2],column:oe(m.slice(0,R)).length,length:oe(m.slice(R,R+x)).length,lineText:m+`
5
5
  `+t.slice(1).join(`
6
6
  `),suggestion:""}}break}}return null}function he(e,t,r){let s=5,d=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,s+1).map((u,i)=>{if(i===s)return`
7
7
  ...`;if(!u.location)return`
8
- error: ${u.text}`;let{file:y,line:O,column:x}=u.location,A=u.pluginName?`[plugin: ${u.pluginName}] `:"";return`
9
- ${y}:${O}:${x}: error: ${A}${u.text}`}).join(""),l=new Error(`${e}${d}`);return l.errors=t,l.warnings=r,l}function be(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Qe(e,t){if(e==null)return null;let r={},s=n(e,r,"file",h),d=n(e,r,"namespace",h),l=n(e,r,"line",ge),u=n(e,r,"column",ge),i=n(e,r,"length",ge),y=n(e,r,"lineText",h),O=n(e,r,"suggestion",h);return z(e,r,t),{file:s||"",namespace:d||"",line:l||0,column:u||0,length:i||0,lineText:y||"",suggestion:O||""}}function fe(e,t,r,s){let d=[],l=0;for(let u of e){let i={},y=n(u,i,"pluginName",h),O=n(u,i,"text",h),x=n(u,i,"location",Ve),A=n(u,i,"notes",q),K=n(u,i,"detail",Ne),$=`in element ${l} of "${t}"`;z(u,i,$);let L=[];if(A)for(let ee of A){let Q={},re=n(ee,Q,"text",h),te=n(ee,Q,"location",Ve);z(ee,Q,$),L.push({text:re||"",location:Qe(te,$)})}d.push({pluginName:y||s,text:O||"",location:Qe(x,$),notes:L,detail:r?r.store(K):-1}),l++}return d}function xe(e,t){let r=[];for(let s of e){if(typeof s!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(s)}return r}function pt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ce(t)),r}}}var gt="0.12.25",mt=e=>Le().build(e),yt=()=>{throw new Error('The "serve" API only works in node')},ht=(e,t)=>Le().transform(e,t),bt=(e,t)=>Le().formatMessages(e,t),wt=()=>{throw new Error('The "buildSync" API only works in node')},vt=()=>{throw new Error('The "transformSync" API only works in node')},Rt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},we,Me,Le=()=>{if(Me)return Me;throw we?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},Ot=e=>{e=Je(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",we)throw new Error('Cannot call "initialize" more than once');return we=St(t,r),we.catch(()=>{we=void 0}),we},St=(e,t)=>se(void 0,null,function*(){let r=yield fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let s=yield r.arrayBuffer(),d='{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\nvar y=(l,g,d)=>new Promise((r,i)=>{var s=m=>{try{o(d.next(m))}catch(u){i(u)}},n=m=>{try{o(d.throw(m))}catch(u){i(u)}},o=m=>m.done?r(m.value):Promise.resolve(m.value).then(s,n);o((d=d.apply(l,g)).next())});(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(i,s,n,o,m,u){if(n===0&&o===s.length&&m===null){if(i===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}if(i===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}}r.write(i,s,n,o,m,u)}}))}const l=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){r+=d.decode(s);const n=r.lastIndexOf(`\n`);return n!=-1&&(console.log(r.substr(0,n)),r=r.substr(n+1)),s.length},write(i,s,n,o,m,u){if(n!==0||o!==s.length||m!==null){u(l());return}const h=this.writeSync(i,s);u(null,h)},chmod(i,s,n){n(l())},chown(i,s,n,o){o(l())},close(i,s){s(l())},fchmod(i,s,n){n(l())},fchown(i,s,n,o){o(l())},fstat(i,s){s(l())},fsync(i,s){s(null)},ftruncate(i,s,n){n(l())},lchown(i,s,n,o){o(l())},link(i,s,n){n(l())},lstat(i,s){s(l())},mkdir(i,s,n){n(l())},open(i,s,n,o){o(l())},read(i,s,n,o,m,u){u(l())},readdir(i,s){s(l())},readlink(i,s){s(l())},rename(i,s,n){n(l())},rmdir(i,s){s(l())},stat(i,s){s(l())},symlink(i,s,n){n(l())},truncate(i,s,n){n(l())},unlink(i,s){s(l())},utimes(i,s,n,o){o(l())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(i){r.randomFillSync(i)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,i]=process.hrtime();return r*1e3+i/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const g=new TextEncoder("utf-8"),d=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=e=>{const t=this.mem.getUint32(e+0,!0),a=this.mem.getInt32(e+4,!0);return t+a*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const a=this.mem.getUint32(e,!0);return this._values[a]},n=(e,t)=>{const a=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,a,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let f=0;switch(typeof t){case"object":t!==null&&(f=1);break;case"string":f=2;break;case"symbol":f=3;break;case"function":f=4;break}this.mem.setUint32(e+4,a|f,!0),this.mem.setUint32(e,c,!0)},o=e=>{const t=i(e+0),a=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,a)},m=e=>{const t=i(e+0),a=i(e+8),c=new Array(a);for(let f=0;f<a;f++)c[f]=s(t+f*8);return c},u=e=>{const t=i(e+0),a=i(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,a))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=i(e+8),a=i(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,a,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(h+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(o(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const a=this._values[t];this._values[t]=null,this._ids.delete(a),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,n(e+24,u(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),u(e+16));e=this._inst.exports.getsp()>>>0,n(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),u(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),u(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,n(e+24,Reflect.get(s(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),i(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),a=Reflect.get(t,u(e+16)),c=m(e+32),f=Reflect.apply(a,t,c);e=this._inst.exports.getsp()>>>0,n(e+56,f),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.apply(t,void 0,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.construct(t,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=g.encode(String(s(e+8)));n(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);o(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=o(e+8),a=s(e+32);if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),a=o(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(r){return y(this,null,function*(){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=h=>{const e=i,t=g.encode(h+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!=0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(h=>{o.push(s(h))}),o.push(0),Object.keys(this.env).sort().forEach(h=>{o.push(s(`${h}=${this.env[h]}`))}),o.push(0);const u=i;o.forEach(h=>{this.mem.setUint32(i,h,!0),this.mem.setUint32(i+4,0,!0),i+=8}),this._inst.exports.run(n,u),this.exited&&this._resolveExitPromise(),yield this._exitPromise})}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const i=this;return function(){const s={id:r,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(i=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(i.instance))).catch(i=>{console.error(i),process.exit(1)})}})();\nonmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(`\n`);n.length>1&&console.log(n.slice(0,-1).join(`\n`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.12.25"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let y=new Blob([d],{type:"text/javascript"});l=new Worker(URL.createObjectURL(y))}else{let O=new Function("postMessage",d+"var onmessage; return m => onmessage(m)")(x=>l.onmessage({data:x}));l={onmessage:null,postMessage:x=>O({data:x}),terminate(){}}}l.postMessage(s),l.onmessage=({data:y})=>u(y);let{readFromStdout:u,service:i}=Ye({writeToStdin(y){l.postMessage(y)},isSync:!1,isBrowser:!0});Me={build:y=>new Promise((O,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:y,isTTY:!1,defaultWD:"/",callback:(A,K)=>A?x(A):O(K)})),transform:(y,O)=>new Promise((x,A)=>i.transform({callName:"transform",refs:null,input:y,options:O||{},isTTY:!1,fs:{readFile(K,$){$(new Error("Internal error"),null)},writeFile(K,$){$(null)}},callback:(K,$)=>K?A(K):x($)})),formatMessages:(y,O)=>new Promise((x,A)=>i.formatMessages({callName:"formatMessages",refs:null,messages:y,options:O,callback:(K,$)=>K?A(K):x($)}))}});
8
+ error: ${u.text}`;let{file:m,line:R,column:x}=u.location,A=u.pluginName?`[plugin: ${u.pluginName}] `:"";return`
9
+ ${m}:${R}:${x}: error: ${A}${u.text}`}).join(""),l=new Error(`${e}${d}`);return l.errors=t,l.warnings=r,l}function be(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Xe(e,t){if(e==null)return null;let r={},s=n(e,r,"file",h),d=n(e,r,"namespace",h),l=n(e,r,"line",ge),u=n(e,r,"column",ge),i=n(e,r,"length",ge),m=n(e,r,"lineText",h),R=n(e,r,"suggestion",h);return _(e,r,t),{file:s||"",namespace:d||"",line:l||0,column:u||0,length:i||0,lineText:m||"",suggestion:R||""}}function fe(e,t,r,s){let d=[],l=0;for(let u of e){let i={},m=n(u,i,"pluginName",h),R=n(u,i,"text",h),x=n(u,i,"location",Ve),A=n(u,i,"notes",z),L=n(u,i,"detail",Ie),k=`in element ${l} of "${t}"`;_(u,i,k);let U=[];if(A)for(let ee of A){let Q={},re=n(ee,Q,"text",h),te=n(ee,Q,"location",Ve);_(ee,Q,k),U.push({text:re||"",location:Xe(te,k)})}d.push({pluginName:m||s,text:R||"",location:Xe(x,k),notes:U,detail:r?r.store(L):-1}),l++}return d}function xe(e,t){let r=[];for(let s of e){if(typeof s!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(s)}return r}function gt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ce(t)),r}}}var mt="0.12.27",yt=e=>ke().build(e),ht=()=>{throw new Error('The "serve" API only works in node')},bt=(e,t)=>ke().transform(e,t),wt=(e,t)=>ke().formatMessages(e,t),vt=(e,t)=>ke().analyzeMetafile(e,t),Rt=()=>{throw new Error('The "buildSync" API only works in node')},Ot=()=>{throw new Error('The "transformSync" API only works in node')},St=()=>{throw new Error('The "formatMessagesSync" API only works in node')},xt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},we,Ue,ke=()=>{if(Ue)return Ue;throw we?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},kt=e=>{e=Je(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",we)throw new Error('Cannot call "initialize" more than once');return we=Et(t,r),we.catch(()=>{we=void 0}),we},Et=(e,t)=>se(void 0,null,function*(){let r=yield fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let s=yield r.arrayBuffer(),d=`{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});
10
+ // Copyright 2018 The Go Authors. All rights reserved.
11
+ // Use of this source code is governed by a BSD-style
12
+ // license that can be found in the LICENSE file.
13
+ var w=typeof require!="undefined"?require:l=>{throw new Error('Dynamic require of "'+l+'" is not supported')};var y=(l,g,d)=>new Promise((r,i)=>{var s=m=>{try{o(d.next(m))}catch(u){i(u)}},n=m=>{try{o(d.throw(m))}catch(u){i(u)}},o=m=>m.done?r(m.value):Promise.resolve(m.value).then(s,n);o((d=d.apply(l,g)).next())});(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(i,s,n,o,m,u){if(n===0&&o===s.length&&m===null){if(i===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}if(i===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}}r.write(i,s,n,o,m,u)}}))}const l=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){r+=d.decode(s);const n=r.lastIndexOf(\`
14
+ \`);return n!=-1&&(console.log(r.substr(0,n)),r=r.substr(n+1)),s.length},write(i,s,n,o,m,u){if(n!==0||o!==s.length||m!==null){u(l());return}const h=this.writeSync(i,s);u(null,h)},chmod(i,s,n){n(l())},chown(i,s,n,o){o(l())},close(i,s){s(l())},fchmod(i,s,n){n(l())},fchown(i,s,n,o){o(l())},fstat(i,s){s(l())},fsync(i,s){s(null)},ftruncate(i,s,n){n(l())},lchown(i,s,n,o){o(l())},link(i,s,n){n(l())},lstat(i,s){s(l())},mkdir(i,s,n){n(l())},open(i,s,n,o){o(l())},read(i,s,n,o,m,u){u(l())},readdir(i,s){s(l())},readlink(i,s){s(l())},rename(i,s,n){n(l())},rmdir(i,s){s(l())},stat(i,s){s(l())},symlink(i,s,n){n(l())},truncate(i,s,n){n(l())},unlink(i,s){s(l())},utimes(i,s,n,o){o(l())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(i){r.randomFillSync(i)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,i]=process.hrtime();return r*1e3+i/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const g=new TextEncoder("utf-8"),d=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=e=>{const t=this.mem.getUint32(e+0,!0),a=this.mem.getInt32(e+4,!0);return t+a*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const a=this.mem.getUint32(e,!0);return this._values[a]},n=(e,t)=>{const a=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,a,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let f=0;switch(typeof t){case"object":t!==null&&(f=1);break;case"string":f=2;break;case"symbol":f=3;break;case"function":f=4;break}this.mem.setUint32(e+4,a|f,!0),this.mem.setUint32(e,c,!0)},o=e=>{const t=i(e+0),a=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,a)},m=e=>{const t=i(e+0),a=i(e+8),c=new Array(a);for(let f=0;f<a;f++)c[f]=s(t+f*8);return c},u=e=>{const t=i(e+0),a=i(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,a))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=i(e+8),a=i(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,a,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(h+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(o(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const a=this._values[t];this._values[t]=null,this._ids.delete(a),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,n(e+24,u(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),u(e+16));e=this._inst.exports.getsp()>>>0,n(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),u(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),u(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,n(e+24,Reflect.get(s(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),i(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),a=Reflect.get(t,u(e+16)),c=m(e+32),f=Reflect.apply(a,t,c);e=this._inst.exports.getsp()>>>0,n(e+56,f),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.apply(t,void 0,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.construct(t,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=g.encode(String(s(e+8)));n(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);o(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=o(e+8),a=s(e+32);if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),a=o(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(r){return y(this,null,function*(){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=h=>{const e=i,t=g.encode(h+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!=0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(h=>{o.push(s(h))}),o.push(0),Object.keys(this.env).sort().forEach(h=>{o.push(s(\`\${h}=\${this.env[h]}\`))}),o.push(0);const u=i;o.forEach(h=>{this.mem.setUint32(i,h,!0),this.mem.setUint32(i+4,0,!0),i+=8}),this._inst.exports.run(n,u),this.exited&&this._resolveExitPromise(),yield this._exitPromise})}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const i=this;return function(){const s={id:r,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(i=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(i.instance))).catch(i=>{console.error(i),process.exit(1)})}})();
15
+ onmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(\`
16
+ \`);n.length>1&&console.log(n.slice(0,-1).join(\`
17
+ \`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.12.27"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}`,l;if(t){let m=new Blob([d],{type:"text/javascript"});l=new Worker(URL.createObjectURL(m))}else{let R=new Function("postMessage",d+"var onmessage; return m => onmessage(m)")(x=>l.onmessage({data:x}));l={onmessage:null,postMessage:x=>R({data:x}),terminate(){}}}l.postMessage(s),l.onmessage=({data:m})=>u(m);let{readFromStdout:u,service:i}=He({writeToStdin(m){l.postMessage(m)},isSync:!1,isBrowser:!0});Ue={build:m=>new Promise((R,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:m,isTTY:!1,defaultWD:"/",callback:(A,L)=>A?x(A):R(L)})),transform:(m,R)=>new Promise((x,A)=>i.transform({callName:"transform",refs:null,input:m,options:R||{},isTTY:!1,fs:{readFile(L,k){k(new Error("Internal error"),null)},writeFile(L,k){k(null)}},callback:(L,k)=>L?A(L):x(k)})),formatMessages:(m,R)=>new Promise((x,A)=>i.formatMessages({callName:"formatMessages",refs:null,messages:m,options:R,callback:(L,k)=>L?A(L):x(k)})),analyzeMetafile:(m,R)=>new Promise((x,A)=>i.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof m=="string"?m:JSON.stringify(m),options:R,callback:(L,k)=>L?A(L):x(k)}))}});
10
18
  })(typeof exports==="object"?exports:(typeof self!=="undefined"?self:this).esbuild={});
@@ -322,6 +322,11 @@ export interface FormatMessagesOptions {
322
322
  terminalWidth?: number;
323
323
  }
324
324
 
325
+ export interface AnalyzeMetafileOptions {
326
+ color?: boolean;
327
+ verbose?: boolean;
328
+ }
329
+
325
330
  // This function invokes the "esbuild" command-line tool for you. It returns a
326
331
  // promise that either resolves with a "BuildResult" object or rejects with a
327
332
  // "BuildFailure" object.
@@ -356,6 +361,14 @@ export declare function transform(input: string, options?: TransformOptions): Pr
356
361
  // Works in browser: yes
357
362
  export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
358
363
 
364
+ // Pretty-prints an analysis of the metafile JSON to a string. This is just for
365
+ // convenience to be able to match esbuild's pretty-printing exactly. If you want
366
+ // to customize it, you can just inspect the data in the metafile yourself.
367
+ //
368
+ // Works in node: yes
369
+ // Works in browser: yes
370
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
371
+
359
372
  // A synchronous version of "build".
360
373
  //
361
374
  // Works in node: yes
@@ -375,6 +388,12 @@ export declare function transformSync(input: string, options?: TransformOptions)
375
388
  // Works in browser: no
376
389
  export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
377
390
 
391
+ // A synchronous version of "analyzeMetafile".
392
+ //
393
+ // Works in node: yes
394
+ // Works in browser: no
395
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
396
+
378
397
  // This configures the browser-based version of esbuild. It is necessary to
379
398
  // call this first and wait for the returned promise to be resolved before
380
399
  // making other API calls when using esbuild in the browser.
@@ -18,6 +18,9 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
21
+ var __require = typeof require !== "undefined" ? require : (x) => {
22
+ throw new Error('Dynamic require of "' + x + '" is not supported');
23
+ };
21
24
  var __export = (target, all) => {
22
25
  __markAsModule(target);
23
26
  for (var name in all)
@@ -26,6 +29,8 @@ var __export = (target, all) => {
26
29
 
27
30
  // lib/npm/node.ts
28
31
  __export(exports, {
32
+ analyzeMetafile: () => analyzeMetafile,
33
+ analyzeMetafileSync: () => analyzeMetafileSync,
29
34
  build: () => build,
30
35
  buildSync: () => buildSync,
31
36
  formatMessages: () => formatMessages,
@@ -689,8 +694,8 @@ function createChannel(streamIn) {
689
694
  if (isFirstPacket) {
690
695
  isFirstPacket = false;
691
696
  let binaryVersion = String.fromCharCode(...bytes);
692
- if (binaryVersion !== "0.12.25") {
693
- throw new Error(`Cannot start service: Host version "${"0.12.25"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
697
+ if (binaryVersion !== "0.12.27") {
698
+ throw new Error(`Cannot start service: Host version "${"0.12.27"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
694
699
  }
695
700
  return;
696
701
  }
@@ -1331,13 +1336,35 @@ function createChannel(streamIn) {
1331
1336
  callback(null, response.messages);
1332
1337
  });
1333
1338
  };
1339
+ let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
1340
+ if (options === void 0)
1341
+ options = {};
1342
+ let keys = {};
1343
+ let color = getFlag(options, keys, "color", mustBeBoolean);
1344
+ let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
1345
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
1346
+ let request = {
1347
+ command: "analyze-metafile",
1348
+ metafile
1349
+ };
1350
+ if (color !== void 0)
1351
+ request.color = color;
1352
+ if (verbose !== void 0)
1353
+ request.verbose = verbose;
1354
+ sendRequest(refs, request, (error, response) => {
1355
+ if (error)
1356
+ return callback(new Error(error), null);
1357
+ callback(null, response.result);
1358
+ });
1359
+ };
1334
1360
  return {
1335
1361
  readFromStdout,
1336
1362
  afterClose,
1337
1363
  service: {
1338
1364
  buildOrServe,
1339
1365
  transform: transform2,
1340
- formatMessages: formatMessages2
1366
+ formatMessages: formatMessages2,
1367
+ analyzeMetafile: analyzeMetafile2
1341
1368
  }
1342
1369
  };
1343
1370
  }
@@ -1558,7 +1585,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1558
1585
  }
1559
1586
  }
1560
1587
  var _a;
1561
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.25";
1588
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.27";
1562
1589
  var esbuildCommandAndArgs = () => {
1563
1590
  if (process.env.ESBUILD_BINARY_PATH) {
1564
1591
  return [path.resolve(process.env.ESBUILD_BINARY_PATH), []];
@@ -1627,11 +1654,12 @@ var fsAsync = {
1627
1654
  }
1628
1655
  }
1629
1656
  };
1630
- var version = "0.12.25";
1657
+ var version = "0.12.27";
1631
1658
  var build = (options) => ensureServiceIsRunning().build(options);
1632
1659
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1633
1660
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
1634
1661
  var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
1662
+ var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
1635
1663
  var buildSync = (options) => {
1636
1664
  if (worker_threads && !isInternalWorkerThread) {
1637
1665
  if (!workerThreadService)
@@ -1696,6 +1724,26 @@ var formatMessagesSync = (messages, options) => {
1696
1724
  }));
1697
1725
  return result;
1698
1726
  };
1727
+ var analyzeMetafileSync = (metafile, options) => {
1728
+ if (worker_threads && !isInternalWorkerThread) {
1729
+ if (!workerThreadService)
1730
+ workerThreadService = startWorkerThreadService(worker_threads);
1731
+ return workerThreadService.analyzeMetafileSync(metafile, options);
1732
+ }
1733
+ let result;
1734
+ runServiceSync((service) => service.analyzeMetafile({
1735
+ callName: "analyzeMetafileSync",
1736
+ refs: null,
1737
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
1738
+ options,
1739
+ callback: (err, res) => {
1740
+ if (err)
1741
+ throw err;
1742
+ result = res;
1743
+ }
1744
+ }));
1745
+ return result;
1746
+ };
1699
1747
  var initializeWasCalled = false;
1700
1748
  var initialize = (options) => {
1701
1749
  options = validateInitializeOptions(options || {});
@@ -1715,7 +1763,7 @@ var ensureServiceIsRunning = () => {
1715
1763
  if (longLivedService)
1716
1764
  return longLivedService;
1717
1765
  let [command, args] = esbuildCommandAndArgs();
1718
- let child = child_process.spawn(command, args.concat(`--service=${"0.12.25"}`, "--ping"), {
1766
+ let child = child_process.spawn(command, args.concat(`--service=${"0.12.27"}`, "--ping"), {
1719
1767
  windowsHide: true,
1720
1768
  stdio: ["pipe", "pipe", "inherit"],
1721
1769
  cwd: defaultWD
@@ -1796,6 +1844,15 @@ var ensureServiceIsRunning = () => {
1796
1844
  options,
1797
1845
  callback: (err, res) => err ? reject(err) : resolve(res)
1798
1846
  }));
1847
+ },
1848
+ analyzeMetafile: (metafile, options) => {
1849
+ return new Promise((resolve, reject) => service.analyzeMetafile({
1850
+ callName: "analyzeMetafile",
1851
+ refs,
1852
+ metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
1853
+ options,
1854
+ callback: (err, res) => err ? reject(err) : resolve(res)
1855
+ }));
1799
1856
  }
1800
1857
  };
1801
1858
  return longLivedService;
@@ -1813,7 +1870,7 @@ var runServiceSync = (callback) => {
1813
1870
  isBrowser: false
1814
1871
  });
1815
1872
  callback(service);
1816
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.25"}`), {
1873
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.27"}`), {
1817
1874
  cwd: defaultWD,
1818
1875
  windowsHide: true,
1819
1876
  input: stdin,
@@ -1829,7 +1886,7 @@ var workerThreadService = null;
1829
1886
  var startWorkerThreadService = (worker_threads2) => {
1830
1887
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
1831
1888
  let worker = new worker_threads2.Worker(__filename, {
1832
- workerData: { workerPort, defaultWD, esbuildVersion: "0.12.25" },
1889
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.12.27" },
1833
1890
  transferList: [workerPort],
1834
1891
  execArgv: []
1835
1892
  });
@@ -1892,6 +1949,9 @@ error: ${text}`);
1892
1949
  },
1893
1950
  formatMessagesSync(messages, options) {
1894
1951
  return runCallSync("formatMessages", [messages, options]);
1952
+ },
1953
+ analyzeMetafileSync(metafile, options) {
1954
+ return runCallSync("analyzeMetafile", [metafile, options]);
1895
1955
  }
1896
1956
  };
1897
1957
  };
@@ -1914,14 +1974,21 @@ var startSyncServiceWorker = () => {
1914
1974
  let { sharedBuffer, id, command, args } = msg;
1915
1975
  let sharedBufferView = new Int32Array(sharedBuffer);
1916
1976
  try {
1917
- if (command === "build") {
1918
- workerPort.postMessage({ id, resolve: await service.build(args[0]) });
1919
- } else if (command === "transform") {
1920
- workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
1921
- } else if (command === "formatMessages") {
1922
- workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
1923
- } else {
1924
- throw new Error(`Invalid command: ${command}`);
1977
+ switch (command) {
1978
+ case "build":
1979
+ workerPort.postMessage({ id, resolve: await service.build(args[0]) });
1980
+ break;
1981
+ case "transform":
1982
+ workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
1983
+ break;
1984
+ case "formatMessages":
1985
+ workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
1986
+ break;
1987
+ case "analyzeMetafile":
1988
+ workerPort.postMessage({ id, resolve: await service.analyzeMetafile(args[0], args[1]) });
1989
+ break;
1990
+ default:
1991
+ throw new Error(`Invalid command: ${command}`);
1925
1992
  }
1926
1993
  } catch (reject) {
1927
1994
  workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
@@ -1936,6 +2003,8 @@ if (isInternalWorkerThread) {
1936
2003
  }
1937
2004
  // Annotate the CommonJS export names for ESM import in node:
1938
2005
  0 && (module.exports = {
2006
+ analyzeMetafile,
2007
+ analyzeMetafileSync,
1939
2008
  build,
1940
2009
  buildSync,
1941
2010
  formatMessages,