isomorfeus-asset-manager 0.14.8 → 0.14.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f39c837b3ec72e3d9fee92fc4eeb65b283015a32dce4552f20757e7a1a9b74
4
- data.tar.gz: 59c41bdbb567a2932c9a0649e2b6d2a3a099404e77a4c8c2deb6a4bc75af76e0
3
+ metadata.gz: 72c3557faab5046cf4a3f166cde680d0e4cd00d4829d60e036f466c6f69dcd5f
4
+ data.tar.gz: 42198b62586fa62d3516ccf553b79b415dd77830cadd40631a66c9c252f9f6b0
5
5
  SHA512:
6
- metadata.gz: d641b821399571e961ffb9f55a1437585ab51761ffcb6531ec291a4bf62976993a55ea988061eef909fa6052aa8156cbeb938a575d946bcf9c0df822a3105b4c
7
- data.tar.gz: 481be082b3e9715e7548124ee0428c4cde8a61bbc945170276806331bd66d226050058e3ebc2303e167b50d8c148c85fae308b435738b854eb6eb2eb34d982c3
6
+ metadata.gz: b8ec3a05a2caa23313493e65b5500ec4e11203e97518531b753550e02f37c2b12117c104a4e2a4769c40696caa83064050a3b1dcf96ca92a4751b040f87ecd0c
7
+ data.tar.gz: 3d78711a4350ea69d54ca3426df1886dd39c8249e7be67b396e3d253b5f3bcdd0cc39d7f1caf2fee0e499a4ff086f1e8fc730cb0ad9c7ec0b465a2d64cd8e370
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  class AssetManager
3
- VERSION = '0.14.8'
3
+ VERSION = '0.14.9'
4
4
  end
5
5
  end
@@ -4,9 +4,9 @@
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "node_modules/esbuild-wasm": {
7
- "version": "0.14.16",
8
- "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.16.tgz",
9
- "integrity": "sha512-0TnQyxKeNqdnKYEQwf475WkthvVL1aK9p/WaZsHY56Ek1jaxDuciEKRyqZhNZqWvBdjbkaFC46O19+HkIoppJQ==",
7
+ "version": "0.14.20",
8
+ "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.20.tgz",
9
+ "integrity": "sha512-ujhUCYGYdRUIajByyynJDQr8h9c1/bWk8kdsimtp8GrDWjm13T1hWnozjJ+OgnQKtCjL8fw0w4AleEnOwIlqBA==",
10
10
  "bin": {
11
11
  "esbuild": "bin/esbuild"
12
12
  },
Binary file
@@ -26,6 +26,8 @@ interface CommonOptions {
26
26
  mangleProps?: RegExp;
27
27
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
28
  reserveProps?: RegExp;
29
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleCache?: Record<string, string | false>;
29
31
  /** Documentation: https://esbuild.github.io/api/#drop */
30
32
  drop?: Drop[];
31
33
  /** Documentation: https://esbuild.github.io/api/#minify */
@@ -200,6 +202,8 @@ export interface BuildResult {
200
202
  stop?: () => void;
201
203
  /** Only when "metafile: true" */
202
204
  metafile?: Metafile;
205
+ /** Only when "mangleCache" is present */
206
+ mangleCache?: Record<string, string | false>;
203
207
  }
204
208
 
205
209
  export interface BuildFailure extends Error {
@@ -253,6 +257,8 @@ export interface TransformResult {
253
257
  code: string;
254
258
  map: string;
255
259
  warnings: Message[];
260
+ /** Only when "mangleCache" is present */
261
+ mangleCache?: Record<string, string | false>;
256
262
  }
257
263
 
258
264
  export interface TransformFailure extends Error {
@@ -251,6 +251,21 @@ function validateInitializeOptions(options) {
251
251
  worker
252
252
  };
253
253
  }
254
+ function validateMangleCache(mangleCache) {
255
+ let validated;
256
+ if (mangleCache !== void 0) {
257
+ validated = /* @__PURE__ */ Object.create(null);
258
+ for (let key of Object.keys(mangleCache)) {
259
+ let value = mangleCache[key];
260
+ if (typeof value === "string" || value === false) {
261
+ validated[key] = value;
262
+ } else {
263
+ throw new Error(`Expected ${JSON.stringify(key)} in mangle cache to map to either a string or false`);
264
+ }
265
+ }
266
+ }
267
+ return validated;
268
+ }
254
269
  function pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {
255
270
  let color = getFlag(options, keys, "color", mustBeBoolean);
256
271
  let logLevel = getFlag(options, keys, "logLevel", mustBeString);
@@ -382,6 +397,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
382
397
  let write = (_a = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a : writeDefault;
383
398
  let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
384
399
  let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
400
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
385
401
  keys.plugins = true;
386
402
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
387
403
  if (sourcemap)
@@ -531,7 +547,8 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
531
547
  absWorkingDir,
532
548
  incremental,
533
549
  nodePaths,
534
- watch: watchMode
550
+ watch: watchMode,
551
+ mangleCache: validateMangleCache(mangleCache)
535
552
  };
536
553
  }
537
554
  function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
@@ -545,6 +562,7 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
545
562
  let loader = getFlag(options, keys, "loader", mustBeString);
546
563
  let banner = getFlag(options, keys, "banner", mustBeString);
547
564
  let footer = getFlag(options, keys, "footer", mustBeString);
565
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
548
566
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
549
567
  if (sourcemap)
550
568
  flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
@@ -558,7 +576,10 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
558
576
  flags.push(`--banner=${banner}`);
559
577
  if (footer)
560
578
  flags.push(`--footer=${footer}`);
561
- return flags;
579
+ return {
580
+ flags,
581
+ mangleCache: validateMangleCache(mangleCache)
582
+ };
562
583
  }
563
584
  function createChannel(streamIn) {
564
585
  let responseCallbacks = /* @__PURE__ */ new Map();
@@ -702,8 +723,8 @@ function createChannel(streamIn) {
702
723
  if (isFirstPacket) {
703
724
  isFirstPacket = false;
704
725
  let binaryVersion = String.fromCharCode(...bytes);
705
- if (binaryVersion !== "0.14.16") {
706
- throw new Error(`Cannot start service: Host version "${"0.14.16"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
726
+ if (binaryVersion !== "0.14.20") {
727
+ throw new Error(`Cannot start service: Host version "${"0.14.20"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
707
728
  }
708
729
  return;
709
730
  }
@@ -1162,7 +1183,8 @@ function createChannel(streamIn) {
1162
1183
  absWorkingDir,
1163
1184
  incremental,
1164
1185
  nodePaths,
1165
- watch
1186
+ watch,
1187
+ mangleCache
1166
1188
  } = flagsForBuildOptions(callName, options, isTTY, buildLogLevelDefault, writeDefault);
1167
1189
  let request = {
1168
1190
  command: "build",
@@ -1178,6 +1200,8 @@ function createChannel(streamIn) {
1178
1200
  };
1179
1201
  if (requestPlugins)
1180
1202
  request.plugins = requestPlugins;
1203
+ if (mangleCache)
1204
+ request.mangleCache = mangleCache;
1181
1205
  let serve2 = serveOptions && buildServeData(refs, serveOptions, request, key);
1182
1206
  let rebuild;
1183
1207
  let stop;
@@ -1186,6 +1210,8 @@ function createChannel(streamIn) {
1186
1210
  result.outputFiles = response.outputFiles.map(convertOutputFiles);
1187
1211
  if (response.metafile)
1188
1212
  result.metafile = JSON.parse(response.metafile);
1213
+ if (response.mangleCache)
1214
+ result.mangleCache = response.mangleCache;
1189
1215
  if (response.writeToStdout !== void 0)
1190
1216
  console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1191
1217
  };
@@ -1313,20 +1339,32 @@ function createChannel(streamIn) {
1313
1339
  try {
1314
1340
  if (typeof input !== "string")
1315
1341
  throw new Error('The input to "transform" must be a string');
1316
- let flags = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1342
+ let {
1343
+ flags,
1344
+ mangleCache
1345
+ } = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1317
1346
  let request = {
1318
1347
  command: "transform",
1319
1348
  flags,
1320
1349
  inputFS: inputPath !== null,
1321
1350
  input: inputPath !== null ? inputPath : input
1322
1351
  };
1352
+ if (mangleCache)
1353
+ request.mangleCache = mangleCache;
1323
1354
  sendRequest(refs, request, (error, response) => {
1324
1355
  if (error)
1325
1356
  return callback(new Error(error), null);
1326
1357
  let errors = replaceDetailsInMessages(response.errors, details);
1327
1358
  let warnings = replaceDetailsInMessages(response.warnings, details);
1328
1359
  let outstanding = 1;
1329
- let next = () => --outstanding === 0 && callback(null, { warnings, code: response.code, map: response.map });
1360
+ let next = () => {
1361
+ if (--outstanding === 0) {
1362
+ let result = { warnings, code: response.code, map: response.map };
1363
+ if (response.mangleCache)
1364
+ result.mangleCache = response == null ? void 0 : response.mangleCache;
1365
+ callback(null, result);
1366
+ }
1367
+ };
1330
1368
  if (errors.length > 0)
1331
1369
  return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1332
1370
  if (response.codeFS) {
@@ -1631,7 +1669,7 @@ function convertOutputFiles({ path, contents }) {
1631
1669
  }
1632
1670
 
1633
1671
  // lib/npm/browser.ts
1634
- var version = "0.14.16";
1672
+ var version = "0.14.20";
1635
1673
  var build = (options) => ensureServiceIsRunning().build(options);
1636
1674
  var serve = () => {
1637
1675
  throw new Error(`The "serve" API only works in node`);
@@ -2388,7 +2426,7 @@ onmessage = ({ data: wasm }) => {
2388
2426
  callback(null, count);
2389
2427
  };
2390
2428
  let go = new global.Go();
2391
- go.argv = ["", \`--service=\${"0.14.16"}\`];
2429
+ go.argv = ["", \`--service=\${"0.14.20"}\`];
2392
2430
  WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
2393
2431
  };}`;
2394
2432
  let worker;
@@ -1,8 +1,8 @@
1
- var We=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var qe=(e,t,r)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Be=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&qe(e,r,t[r]);if(Ue)for(var r of Ue(t))nt.call(t,r)&&qe(e,r,t[r]);return e},Te=(e,t)=>et(e,tt(t));var lt=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})};var Le={};lt(Le,{analyzeMetafile:()=>vt,analyzeMetafileSync:()=>xt,build:()=>yt,buildSync:()=>Rt,formatMessages:()=>wt,formatMessagesSync:()=>St,initialize:()=>kt,serve:()=>ht,transform:()=>bt,transformSync:()=>Ot,version:()=>mt});function Ae(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(ce(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 d of o)t(d)}else{let d=Object.keys(o);r.write8(6),r.write32(d.length);for(let i of d)r.write(ce(i)),t(o[i])}},r=new Fe;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),De(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Ie(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ge(r.read());case 4:return r.read();case 5:{let c=r.read32(),s=[];for(let y=0;y<c;y++)s.push(t());return s}case 6:{let c=r.read32(),s={};for(let y=0;y<c;y++)s[ge(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new Fe(e),o=r.read32(),d=(o&1)===0;o>>>=1;let i=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:d,value:i}}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);De(this.buf,t,r)}write(t){let r=this._write(4+t.length);De(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),o=this._read(r.length);return r.set(this.buf.subarray(o,o+t)),r}},ce,ge;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;ce=r=>e.encode(r),ge=r=>t.decode(r)}else if(typeof Buffer!="undefined")ce=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ge=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 Ne(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function De(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function ze(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var ke=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",st=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",g=e=>typeof e=="string"?null:"a string",Ee=e=>e instanceof RegExp?null:"a RegExp object",ve=e=>typeof e=="number"&&e===(e|0)?null:"an integer",je=e=>typeof e=="function"?null:"a function",_=e=>Array.isArray(e)?null:"an array",we=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",Ke=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Je=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",ft=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,o){let d=e[r];if(t[r+""]=!0,d===void 0)return;let i=o(d);if(i!==null)throw new Error(`"${r}" must be ${i}`);return d}function Y(e,t,r){for(let o in e)if(!(o in t))throw new Error(`Invalid option ${r}: "${o}"`)}function Ye(e){let t=Object.create(null),r=n(e,t,"wasmURL",g),o=n(e,t,"worker",q);return Y(e,t,"in startService() call"),{wasmURL:r,worker:o}}function $e(e,t,r,o,d){let i=n(t,r,"color",q),c=n(t,r,"logLevel",g),s=n(t,r,"logLimit",ve);i!==void 0?e.push(`--color=${i}`):o&&e.push("--color=true"),e.push(`--log-level=${c||d}`),e.push(`--log-limit=${s||0}`)}function He(e,t,r){let o=n(t,r,"legalComments",g),d=n(t,r,"sourceRoot",g),i=n(t,r,"sourcesContent",q),c=n(t,r,"target",ut),s=n(t,r,"format",g),y=n(t,r,"globalName",g),R=n(t,r,"mangleProps",Ee),T=n(t,r,"reserveProps",Ee),C=n(t,r,"minify",q),$=n(t,r,"minifySyntax",q),S=n(t,r,"minifyWhitespace",q),oe=n(t,r,"minifyIdentifiers",q),re=n(t,r,"drop",_),ne=n(t,r,"charset",g),le=n(t,r,"treeShaking",q),ae=n(t,r,"ignoreAnnotations",q),ue=n(t,r,"jsx",g),fe=n(t,r,"jsxFactory",g),pe=n(t,r,"jsxFragment",g),ie=n(t,r,"define",we),ye=n(t,r,"pure",_),Oe=n(t,r,"keepNames",q);if(o&&e.push(`--legal-comments=${o}`),d!==void 0&&e.push(`--source-root=${d}`),i!==void 0&&e.push(`--sources-content=${i}`),c&&(Array.isArray(c)?e.push(`--target=${Array.from(c).map(ze).join(",")}`):e.push(`--target=${ze(c)}`)),s&&e.push(`--format=${s}`),y&&e.push(`--global-name=${y}`),C&&e.push("--minify"),$&&e.push("--minify-syntax"),S&&e.push("--minify-whitespace"),oe&&e.push("--minify-identifiers"),ne&&e.push(`--charset=${ne}`),le!==void 0&&e.push(`--tree-shaking=${le}`),ae&&e.push("--ignore-annotations"),re)for(let ee of re)e.push(`--drop:${ee}`);if(R&&e.push(`--mangle-props=${R.source}`),T&&e.push(`--reserve-props=${T.source}`),ue&&e.push(`--jsx=${ue}`),fe&&e.push(`--jsx-factory=${fe}`),pe&&e.push(`--jsx-fragment=${pe}`),ie)for(let ee in ie){if(ee.indexOf("=")>=0)throw new Error(`Invalid define: ${ee}`);e.push(`--define:${ee}=${ie[ee]}`)}if(ye)for(let ee of ye)e.push(`--pure:${ee}`);Oe&&e.push("--keep-names")}function ct(e,t,r,o,d){var h;let i=[],c=[],s=Object.create(null),y=null,R=null,T=null;$e(i,t,s,r,o),He(i,t,s);let C=n(t,s,"sourcemap",Je),$=n(t,s,"bundle",q),S=n(t,s,"watch",st),oe=n(t,s,"splitting",q),re=n(t,s,"preserveSymlinks",q),ne=n(t,s,"metafile",q),le=n(t,s,"outfile",g),ae=n(t,s,"outdir",g),ue=n(t,s,"outbase",g),fe=n(t,s,"platform",g),pe=n(t,s,"tsconfig",g),ie=n(t,s,"resolveExtensions",_),ye=n(t,s,"nodePaths",_),Oe=n(t,s,"mainFields",_),ee=n(t,s,"conditions",_),p=n(t,s,"external",_),u=n(t,s,"loader",we),a=n(t,s,"outExtension",we),f=n(t,s,"publicPath",g),j=n(t,s,"entryNames",g),N=n(t,s,"chunkNames",g),P=n(t,s,"assetNames",g),E=n(t,s,"inject",_),D=n(t,s,"banner",we),M=n(t,s,"footer",we),w=n(t,s,"entryPoints",ot),U=n(t,s,"absWorkingDir",g),k=n(t,s,"stdin",we),O=(h=n(t,s,"write",q))!=null?h:d,te=n(t,s,"allowOverwrite",q),X=n(t,s,"incremental",q)===!0;if(s.plugins=!0,Y(t,s,`in ${e}() call`),C&&i.push(`--sourcemap${C===!0?"":`=${C}`}`),$&&i.push("--bundle"),te&&i.push("--allow-overwrite"),S)if(i.push("--watch"),typeof S=="boolean")T={};else{let l=Object.create(null),v=n(S,l,"onRebuild",je);Y(S,l,`on "watch" in ${e}() call`),T={onRebuild:v}}if(oe&&i.push("--splitting"),re&&i.push("--preserve-symlinks"),ne&&i.push("--metafile"),le&&i.push(`--outfile=${le}`),ae&&i.push(`--outdir=${ae}`),ue&&i.push(`--outbase=${ue}`),fe&&i.push(`--platform=${fe}`),pe&&i.push(`--tsconfig=${pe}`),ie){let l=[];for(let v of ie){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);l.push(v)}i.push(`--resolve-extensions=${l.join(",")}`)}if(f&&i.push(`--public-path=${f}`),j&&i.push(`--entry-names=${j}`),N&&i.push(`--chunk-names=${N}`),P&&i.push(`--asset-names=${P}`),Oe){let l=[];for(let v of Oe){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);l.push(v)}i.push(`--main-fields=${l.join(",")}`)}if(ee){let l=[];for(let v of ee){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);l.push(v)}i.push(`--conditions=${l.join(",")}`)}if(p)for(let l of p)i.push(`--external:${l}`);if(D)for(let l in D){if(l.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${l}`);i.push(`--banner:${l}=${D[l]}`)}if(M)for(let l in M){if(l.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${l}`);i.push(`--footer:${l}=${M[l]}`)}if(E)for(let l of E)i.push(`--inject:${l}`);if(u)for(let l in u){if(l.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${l}`);i.push(`--loader:${l}=${u[l]}`)}if(a)for(let l in a){if(l.indexOf("=")>=0)throw new Error(`Invalid out extension: ${l}`);i.push(`--out-extension:${l}=${a[l]}`)}if(w)if(Array.isArray(w))for(let l of w)c.push(["",l+""]);else for(let[l,v]of Object.entries(w))c.push([l+"",v+""]);if(k){let l=Object.create(null),v=n(k,l,"contents",g),W=n(k,l,"resolveDir",g),L=n(k,l,"sourcefile",g),b=n(k,l,"loader",g);Y(k,l,'in "stdin" object'),L&&i.push(`--sourcefile=${L}`),b&&i.push(`--loader=${b}`),W&&(R=W+""),y=v?v+"":""}let x=[];if(ye)for(let l of ye)l+="",x.push(l);return{entries:c,flags:i,write:O,stdinContents:y,stdinResolveDir:R,absWorkingDir:U,incremental:X,nodePaths:x,watch:T}}function dt(e,t,r,o){let d=[],i=Object.create(null);$e(d,t,i,r,o),He(d,t,i);let c=n(t,i,"sourcemap",Je),s=n(t,i,"tsconfigRaw",at),y=n(t,i,"sourcefile",g),R=n(t,i,"loader",g),T=n(t,i,"banner",g),C=n(t,i,"footer",g);return Y(t,i,`in ${e}() call`),c&&d.push(`--sourcemap=${c===!0?"external":c}`),s&&d.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),y&&d.push(`--sourcefile=${y}`),R&&d.push(`--loader=${R}`),T&&d.push(`--banner=${T}`),C&&d.push(`--footer=${C}`),d}function Ge(e){let t=new Map,r=new Map,o=new Map,d=new Map,i=!1,c=0,s=0,y=new Uint8Array(16*1024),R=0,T=p=>{let u=R+p.length;if(u>y.length){let f=new Uint8Array(u*2);f.set(y),y=f}y.set(p,R),R+=p.length;let a=0;for(;a+4<=R;){let f=Ne(y,a);if(a+4+f>R)break;a+=4,ne(y.subarray(a,a+f)),a+=f}a>0&&(y.copyWithin(0,a,R),R-=a)},C=()=>{i=!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 o.values())try{p(new Error("The service was stopped"),null)}catch(u){console.error(u)}o.clear()},$=(p,u,a)=>{if(i)return a("The service is no longer running",null);let f=c++;t.set(f,(j,N)=>{try{a(j,N)}finally{p&&p.unref()}}),p&&p.ref(),e.writeToStdin(Ae({id:f,isRequest:!0,value:u}))},S=(p,u)=>{if(i)throw new Error("The service is no longer running");e.writeToStdin(Ae({id:p,isRequest:!1,value:u}))},oe=async(p,u)=>{try{switch(u.command){case"ping":{S(p,{});break}case"on-start":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"on-resolve":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"on-load":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"serve-request":{let a=d.get(u.key);a&&a.onRequest&&a.onRequest(u.args),S(p,{});break}case"serve-wait":{let a=d.get(u.key);a&&a.onWait(u.error),S(p,{});break}case"watch-rebuild":{let a=o.get(u.key);try{a&&a(null,u.args)}catch(f){console.error(f)}S(p,{});break}default:throw new Error("Invalid command: "+u.command)}}catch(a){S(p,{errors:[he(a,e,null,void 0,"")]})}},re=!0,ne=p=>{if(re){re=!1;let a=String.fromCharCode(...p);if(a!=="0.14.16")throw new Error(`Cannot start service: Host version "0.14.16" does not match binary version ${JSON.stringify(a)}`);return}let u=Ie(p);if(u.isRequest)oe(u.id,u.value);else{let a=t.get(u.id);t.delete(u.id),u.value.error?a(u.value.error,{}):a(null,u.value)}},le=async(p,u,a,f,j)=>{let N=[],P=[],E={},D={},M=0,w=0,U=[],k=!1;u=[...u];for(let x of u){let h={};if(typeof x!="object")throw new Error(`Plugin at index ${w} must be an object`);let l=n(x,h,"name",g);if(typeof l!="string"||l==="")throw new Error(`Plugin at index ${w} is missing a name`);try{let v=n(x,h,"setup",je);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(x,h,`on plugin ${JSON.stringify(l)}`);let W={name:l,onResolve:[],onLoad:[]};w++;let b=v({initialOptions:p,resolve:(m,A={})=>{if(!k)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof m!="string")throw new Error("The path to resolve must be a string");let F=Object.create(null),V=n(A,F,"pluginName",g),I=n(A,F,"importer",g),H=n(A,F,"namespace",g),Q=n(A,F,"resolveDir",g),B=n(A,F,"kind",g),J=n(A,F,"pluginData",ke);return Y(A,F,"in resolve() call"),new Promise((K,Z)=>{let G={command:"resolve",path:m,key:a,pluginName:l};V!=null&&(G.pluginName=V),I!=null&&(G.importer=I),H!=null&&(G.namespace=H),Q!=null&&(G.resolveDir=Q),B!=null&&(G.kind=B),J!=null&&(G.pluginData=f.store(J)),$(j,G,(se,z)=>{se!==null?Z(new Error(se)):K({errors:de(z.errors,f),warnings:de(z.warnings,f),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:f.load(z.pluginData)})})})},onStart(m){let A='This error came from the "onStart" callback registered here:',F=Se(new Error(A),e,"onStart");N.push({name:l,callback:m,note:F})},onEnd(m){let A='This error came from the "onEnd" callback registered here:',F=Se(new Error(A),e,"onEnd");P.push({name:l,callback:m,note:F})},onResolve(m,A){let F='This error came from the "onResolve" callback registered here:',V=Se(new Error(F),e,"onResolve"),I={},H=n(m,I,"filter",Ee),Q=n(m,I,"namespace",g);if(Y(m,I,`in onResolve() call for plugin ${JSON.stringify(l)}`),H==null)throw new Error("onResolve() call is missing a filter");let B=M++;E[B]={name:l,callback:A,note:V},W.onResolve.push({id:B,filter:H.source,namespace:Q||""})},onLoad(m,A){let F='This error came from the "onLoad" callback registered here:',V=Se(new Error(F),e,"onLoad"),I={},H=n(m,I,"filter",Ee),Q=n(m,I,"namespace",g);if(Y(m,I,`in onLoad() call for plugin ${JSON.stringify(l)}`),H==null)throw new Error("onLoad() call is missing a filter");let B=M++;D[B]={name:l,callback:A,note:V},W.onLoad.push({id:B,filter:H.source,namespace:Q||""})},esbuild:e.esbuild});b&&await b,U.push(W)}catch(v){return{ok:!1,error:v,pluginName:l}}}let O=async x=>{switch(x.command){case"on-start":{let h={errors:[],warnings:[]};return await Promise.all(N.map(async({name:l,callback:v,note:W})=>{try{let L=await v();if(L!=null){if(typeof L!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(l)} to return an object`);let b={},m=n(L,b,"errors",_),A=n(L,b,"warnings",_);Y(L,b,`from onStart() callback in plugin ${JSON.stringify(l)}`),m!=null&&h.errors.push(...me(m,"errors",f,l)),A!=null&&h.warnings.push(...me(A,"warnings",f,l))}}catch(L){h.errors.push(he(L,e,f,W&&W(),l))}})),h}case"on-resolve":{let h={},l="",v,W;for(let L of x.ids)try{({name:l,callback:v,note:W}=E[L]);let b=await v({path:x.path,importer:x.importer,namespace:x.namespace,resolveDir:x.resolveDir,kind:x.kind,pluginData:f.load(x.pluginData)});if(b!=null){if(typeof b!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(l)} to return an object`);let m={},A=n(b,m,"pluginName",g),F=n(b,m,"path",g),V=n(b,m,"namespace",g),I=n(b,m,"suffix",g),H=n(b,m,"external",q),Q=n(b,m,"sideEffects",q),B=n(b,m,"pluginData",ke),J=n(b,m,"errors",_),K=n(b,m,"warnings",_),Z=n(b,m,"watchFiles",_),G=n(b,m,"watchDirs",_);Y(b,m,`from onResolve() callback in plugin ${JSON.stringify(l)}`),h.id=L,A!=null&&(h.pluginName=A),F!=null&&(h.path=F),V!=null&&(h.namespace=V),I!=null&&(h.suffix=I),H!=null&&(h.external=H),Q!=null&&(h.sideEffects=Q),B!=null&&(h.pluginData=f.store(B)),J!=null&&(h.errors=me(J,"errors",f,l)),K!=null&&(h.warnings=me(K,"warnings",f,l)),Z!=null&&(h.watchFiles=xe(Z,"watchFiles")),G!=null&&(h.watchDirs=xe(G,"watchDirs"));break}}catch(b){return{id:L,errors:[he(b,e,f,W&&W(),l)]}}return h}case"on-load":{let h={},l="",v,W;for(let L of x.ids)try{({name:l,callback:v,note:W}=D[L]);let b=await v({path:x.path,namespace:x.namespace,suffix:x.suffix,pluginData:f.load(x.pluginData)});if(b!=null){if(typeof b!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(l)} to return an object`);let m={},A=n(b,m,"pluginName",g),F=n(b,m,"contents",ft),V=n(b,m,"resolveDir",g),I=n(b,m,"pluginData",ke),H=n(b,m,"loader",g),Q=n(b,m,"errors",_),B=n(b,m,"warnings",_),J=n(b,m,"watchFiles",_),K=n(b,m,"watchDirs",_);Y(b,m,`from onLoad() callback in plugin ${JSON.stringify(l)}`),h.id=L,A!=null&&(h.pluginName=A),F instanceof Uint8Array?h.contents=F:F!=null&&(h.contents=ce(F)),V!=null&&(h.resolveDir=V),I!=null&&(h.pluginData=f.store(I)),H!=null&&(h.loader=H),Q!=null&&(h.errors=me(Q,"errors",f,l)),B!=null&&(h.warnings=me(B,"warnings",f,l)),J!=null&&(h.watchFiles=xe(J,"watchFiles")),K!=null&&(h.watchDirs=xe(K,"watchDirs"));break}}catch(b){return{id:L,errors:[he(b,e,f,W&&W(),l)]}}return h}default:throw new Error("Invalid command: "+x.command)}},te=(x,h,l)=>l();P.length>0&&(te=(x,h,l)=>{(async()=>{for(let{name:v,callback:W,note:L}of P)try{await W(x)}catch(b){x.errors.push(await new Promise(m=>h(b,v,L&&L(),m)))}})().then(l)}),k=!0;let X=0;return{ok:!0,requestPlugins:U,runOnEndCallbacks:te,pluginRefs:{ref(){++X===1&&r.set(a,O)},unref(){--X===0&&r.delete(a)}}}},ae=(p,u,a,f)=>{let j={},N=n(u,j,"port",ve),P=n(u,j,"host",g),E=n(u,j,"servedir",g),D=n(u,j,"onRequest",je),M,w=new Promise((U,k)=>{M=O=>{d.delete(f),O!==null?k(new Error(O)):U()}});return a.serve={},Y(u,j,"in serve() call"),N!==void 0&&(a.serve.port=N),P!==void 0&&(a.serve.host=P),E!==void 0&&(a.serve.servedir=E),d.set(f,{onRequest:D,onWait:M}),{wait:w,stop(){$(p,{command:"serve-stop",key:f},()=>{})}}},ue="warning",fe="silent",pe=p=>{let u=s++,a=_e(),f,{refs:j,options:N,isTTY:P,callback:E}=p;if(typeof N=="object"){let w=N.plugins;if(w!==void 0){if(!Array.isArray(w))throw new Error('"plugins" must be an array');f=w}}let D=(w,U,k,O)=>{let te=[];try{$e(te,N,{},P,ue)}catch(x){}let X=he(w,e,a,k,U);$(j,{command:"error",flags:te,error:X},()=>{X.detail=a.load(X.detail),O(X)})},M=(w,U)=>{D(w,U,void 0,k=>{E(be("Build failed",[k],[]),null)})};if(f&&f.length>0){if(e.isSync)return M(new Error("Cannot use plugins in synchronous API calls"),"");le(N,f,u,a,j).then(w=>{if(!w.ok)M(w.error,w.pluginName);else try{ie(Te(Be({},p),{key:u,details:a,logPluginError:D,requestPlugins:w.requestPlugins,runOnEndCallbacks:w.runOnEndCallbacks,pluginRefs:w.pluginRefs}))}catch(U){M(U,"")}},w=>M(w,""))}else try{ie(Te(Be({},p),{key:u,details:a,logPluginError:D,requestPlugins:null,runOnEndCallbacks:(w,U,k)=>k(),pluginRefs:null}))}catch(w){M(w,"")}},ie=({callName:p,refs:u,serveOptions:a,options:f,isTTY:j,defaultWD:N,callback:P,key:E,details:D,logPluginError:M,requestPlugins:w,runOnEndCallbacks:U,pluginRefs:k})=>{let O={ref(){k&&k.ref(),u&&u.ref()},unref(){k&&k.unref(),u&&u.unref()}},te=!e.isBrowser,{entries:X,flags:x,write:h,stdinContents:l,stdinResolveDir:v,absWorkingDir:W,incremental:L,nodePaths:b,watch:m}=ct(p,f,j,ue,te),A={command:"build",key:E,entries:X,flags:x,write:h,stdinContents:l,stdinResolveDir:v,absWorkingDir:W||N,incremental:L,nodePaths:b};w&&(A.plugins=w);let F=a&&ae(O,a,A,E),V,I,H=(B,J)=>{B.outputFiles&&(J.outputFiles=B.outputFiles.map(pt)),B.metafile&&(J.metafile=JSON.parse(B.metafile)),B.writeToStdout!==void 0&&console.log(ge(B.writeToStdout).replace(/\n$/,""))},Q=(B,J)=>{let K={errors:de(B.errors,D),warnings:de(B.warnings,D)};H(B,K),U(K,M,()=>{if(K.errors.length>0)return J(be("Build failed",K.errors,K.warnings),null);if(B.rebuild){if(!V){let Z=!1;V=()=>new Promise((G,se)=>{if(Z||i)throw new Error("Cannot rebuild");$(O,{command:"rebuild",key:E},(z,Xe)=>{if(z)return J(be("Build failed",[{pluginName:"",text:z,location:null,notes:[],detail:void 0}],[]),null);Q(Xe,(Me,Ze)=>{Me?se(Me):G(Ze)})})}),O.ref(),V.dispose=()=>{Z||(Z=!0,$(O,{command:"rebuild-dispose",key:E},()=>{}),O.unref())}}K.rebuild=V}if(B.watch){if(!I){let Z=!1;O.ref(),I=()=>{Z||(Z=!0,o.delete(E),$(O,{command:"watch-stop",key:E},()=>{}),O.unref())},m&&o.set(E,(G,se)=>{if(G){m.onRebuild&&m.onRebuild(G,null);return}let z={errors:de(se.errors,D),warnings:de(se.warnings,D)};H(se,z),U(z,M,()=>{if(z.errors.length>0){m.onRebuild&&m.onRebuild(be("Build failed",z.errors,z.warnings),null);return}se.rebuildID!==void 0&&(z.rebuild=V),z.stop=I,m.onRebuild&&m.onRebuild(null,z)})})}K.stop=I}J(null,K)})};if(h&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(L&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(m&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');$(O,A,(B,J)=>{if(B)return P(new Error(B),null);if(F){let K=J,Z=!1;O.ref();let G={port:K.port,host:K.host,wait:F.wait,stop(){Z||(Z=!0,F.stop(),O.unref())}};return O.ref(),F.wait.then(O.unref,O.unref),P(null,G)}return Q(J,P)})};return{readFromStdout:T,afterClose:C,service:{buildOrServe:pe,transform:({callName:p,refs:u,input:a,options:f,isTTY:j,fs:N,callback:P})=>{let E=_e(),D=M=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let w=dt(p,f,j,fe);$(u,{command:"transform",flags:w,inputFS:M!==null,input:M!==null?M:a},(k,O)=>{if(k)return P(new Error(k),null);let te=de(O.errors,E),X=de(O.warnings,E),x=1,h=()=>--x===0&&P(null,{warnings:X,code:O.code,map:O.map});if(te.length>0)return P(be("Transform failed",te,X),null);O.codeFS&&(x++,N.readFile(O.code,(l,v)=>{l!==null?P(l,null):(O.code=v,h())})),O.mapFS&&(x++,N.readFile(O.map,(l,v)=>{l!==null?P(l,null):(O.map=v,h())})),h()})}catch(w){let U=[];try{$e(U,f,{},j,fe)}catch(O){}let k=he(w,e,E,void 0,"");$(u,{command:"error",flags:U,error:k},()=>{k.detail=E.load(k.detail),P(be("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let M=D;D=()=>N.writeFile(a,M)}D(null)},formatMessages:({callName:p,refs:u,messages:a,options:f,callback:j})=>{let N=me(a,"messages",null,"");if(!f)throw new Error(`Missing second argument in ${p}() call`);let P={},E=n(f,P,"kind",g),D=n(f,P,"color",q),M=n(f,P,"terminalWidth",ve);if(Y(f,P,`in ${p}() call`),E===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let w={command:"format-msgs",messages:N,isWarning:E==="warning"};D!==void 0&&(w.color=D),M!==void 0&&(w.terminalWidth=M),$(u,w,(U,k)=>{if(U)return j(new Error(U),null);j(null,k.messages)})},analyzeMetafile:({callName:p,refs:u,metafile:a,options:f,callback:j})=>{f===void 0&&(f={});let N={},P=n(f,N,"color",q),E=n(f,N,"verbose",q);Y(f,N,`in ${p}() call`);let D={command:"analyze-metafile",metafile:a};P!==void 0&&(D.color=P),E!==void 0&&(D.verbose=E),$(u,D,(M,w)=>{if(M)return j(new Error(M),null);j(null,w.result)})}}}}function _e(){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 Se(e,t,r){let o,d=!1;return()=>{if(d)return o;d=!0;try{let i=(e.stack+"").split(`
2
- `);i.splice(1,1);let c=Qe(t,i,r);if(c)return o={text:e.message,location:c},o}catch(i){}}}function he(e,t,r,o,d){let i="Internal error",c=null;try{i=(e&&e.message||e)+""}catch(s){}try{c=Qe(t,(e.stack+"").split(`
3
- `),"")}catch(s){}return{pluginName:d,text:i,location:c,notes:o?[o]:[],detail:r?r.store(e):-1}}function Qe(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let d=1;d<t.length;d++){let i=t[d];if(!!i.startsWith(o))for(i=i.slice(o.length);;){let c=/^(?:new |async )?\S+ \((.*)\)$/.exec(i);if(c){i=c[1];continue}if(c=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(i),c){i=c[1];continue}if(c=/^(\S+):(\d+):(\d+)$/.exec(i),c){let s;try{s=e.readFileSync(c[1],"utf8")}catch(C){break}let y=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",R=+c[3]-1,T=y.slice(R,R+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:ce(y.slice(0,R)).length,length:ce(y.slice(R,R+T)).length,lineText:y+`
1
+ var Ie=Object.defineProperty,rt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var qe=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var We=(e,t,r)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Te=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&We(e,r,t[r]);if(qe)for(var r of qe(t))it.call(t,r)&&We(e,r,t[r]);return e},Be=(e,t)=>rt(e,nt(t));var st=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})};var Ue={};st(Ue,{analyzeMetafile:()=>Ot,analyzeMetafileSync:()=>Et,build:()=>bt,buildSync:()=>St,formatMessages:()=>Rt,formatMessagesSync:()=>kt,initialize:()=>$t,serve:()=>wt,transform:()=>vt,transformSync:()=>xt,version:()=>ht});function Ae(e){let t=i=>{if(i===null)r.write8(0);else if(typeof i=="boolean")r.write8(1),r.write8(+i);else if(typeof i=="number")r.write8(2),r.write32(i|0);else if(typeof i=="string")r.write8(3),r.write(de(i));else if(i instanceof Uint8Array)r.write8(4),r.write(i);else if(i instanceof Array){r.write8(5),r.write32(i.length);for(let p of i)t(p)}else{let p=Object.keys(i);r.write8(6),r.write32(p.length);for(let l of p)r.write(de(l)),t(i[l])}},r=new Ne;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),De(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 ye(r.read());case 4:return r.read();case 5:{let c=r.read32(),s=[];for(let y=0;y<c;y++)s.push(t());return s}case 6:{let c=r.read32(),s={};for(let y=0;y<c;y++)s[ye(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new Ne(e),i=r.read32(),p=(i&1)===0;i>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:p,value:l}}var Ne=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);De(this.buf,t,r)}write(t){let r=this._write(4+t.length);De(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),i=this._read(r.length);return r.set(this.buf.subarray(i,i+t)),r}},de,ye;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;de=r=>e.encode(r),ye=r=>t.decode(r)}else if(typeof Buffer!="undefined")de=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ye=e=>{let{buffer:t,byteOffset:r,byteLength:i}=e;return Buffer.from(t,r,i).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 De(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 Ee=()=>null,z=e=>typeof e=="boolean"?null:"a boolean",at=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",m=e=>typeof e=="string"?null:"a string",$e=e=>e instanceof RegExp?null:"a RegExp object",Re=e=>typeof e=="number"&&e===(e|0)?null:"an integer",je=e=>typeof e=="function"?null:"a function",V=e=>Array.isArray(e)?null:"an array",ge=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",ut=e=>typeof e=="object"&&e!==null?null:"an array or an object",_e=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ye=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",ft=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",dt=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,i){let p=e[r];if(t[r+""]=!0,p===void 0)return;let l=i(p);if(l!==null)throw new Error(`"${r}" must be ${l}`);return p}function Y(e,t,r){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${r}: "${i}"`)}function He(e){let t=Object.create(null),r=n(e,t,"wasmURL",m),i=n(e,t,"worker",z);return Y(e,t,"in startService() call"),{wasmURL:r,worker:i}}function Ge(e){let t;if(e!==void 0){t=Object.create(null);for(let r of Object.keys(e)){let i=e[r];if(typeof i=="string"||i===!1)t[r]=i;else throw new Error(`Expected ${JSON.stringify(r)} in mangle cache to map to either a string or false`)}}return t}function Me(e,t,r,i,p){let l=n(t,r,"color",z),c=n(t,r,"logLevel",m),s=n(t,r,"logLimit",Re);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${c||p}`),e.push(`--log-limit=${s||0}`)}function Qe(e,t,r){let i=n(t,r,"legalComments",m),p=n(t,r,"sourceRoot",m),l=n(t,r,"sourcesContent",z),c=n(t,r,"target",ct),s=n(t,r,"format",m),y=n(t,r,"globalName",m),O=n(t,r,"mangleProps",$e),P=n(t,r,"reserveProps",$e),L=n(t,r,"minify",z),x=n(t,r,"minifySyntax",z),S=n(t,r,"minifyWhitespace",z),ae=n(t,r,"minifyIdentifiers",z),re=n(t,r,"drop",V),le=n(t,r,"charset",m),ie=n(t,r,"treeShaking",z),ue=n(t,r,"ignoreAnnotations",z),fe=n(t,r,"jsx",m),ce=n(t,r,"jsxFactory",m),me=n(t,r,"jsxFragment",m),se=n(t,r,"define",ge),be=n(t,r,"pure",V),Se=n(t,r,"keepNames",z);if(i&&e.push(`--legal-comments=${i}`),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(Ke).join(",")}`):e.push(`--target=${Ke(c)}`)),s&&e.push(`--format=${s}`),y&&e.push(`--global-name=${y}`),L&&e.push("--minify"),x&&e.push("--minify-syntax"),S&&e.push("--minify-whitespace"),ae&&e.push("--minify-identifiers"),le&&e.push(`--charset=${le}`),ie!==void 0&&e.push(`--tree-shaking=${ie}`),ue&&e.push("--ignore-annotations"),re)for(let te of re)e.push(`--drop:${te}`);if(O&&e.push(`--mangle-props=${O.source}`),P&&e.push(`--reserve-props=${P.source}`),fe&&e.push(`--jsx=${fe}`),ce&&e.push(`--jsx-factory=${ce}`),me&&e.push(`--jsx-fragment=${me}`),se)for(let te in se){if(te.indexOf("=")>=0)throw new Error(`Invalid define: ${te}`);e.push(`--define:${te}=${se[te]}`)}if(be)for(let te of be)e.push(`--pure:${te}`);Se&&e.push("--keep-names")}function pt(e,t,r,i,p){var b;let l=[],c=[],s=Object.create(null),y=null,O=null,P=null;Me(l,t,s,r,i),Qe(l,t,s);let L=n(t,s,"sourcemap",Ye),x=n(t,s,"bundle",z),S=n(t,s,"watch",at),ae=n(t,s,"splitting",z),re=n(t,s,"preserveSymlinks",z),le=n(t,s,"metafile",z),ie=n(t,s,"outfile",m),ue=n(t,s,"outdir",m),fe=n(t,s,"outbase",m),ce=n(t,s,"platform",m),me=n(t,s,"tsconfig",m),se=n(t,s,"resolveExtensions",V),be=n(t,s,"nodePaths",V),Se=n(t,s,"mainFields",V),te=n(t,s,"conditions",V),g=n(t,s,"external",V),u=n(t,s,"loader",ge),a=n(t,s,"outExtension",ge),f=n(t,s,"publicPath",m),F=n(t,s,"entryNames",m),D=n(t,s,"chunkNames",m),M=n(t,s,"assetNames",m),E=n(t,s,"inject",V),T=n(t,s,"banner",ge),C=n(t,s,"footer",ge),R=n(t,s,"entryPoints",ut),U=n(t,s,"absWorkingDir",m),k=n(t,s,"stdin",ge),A=(b=n(t,s,"write",z))!=null?b:p,W=n(t,s,"allowOverwrite",z),ee=n(t,s,"incremental",z)===!0,$=n(t,s,"mangleCache",ge);if(s.plugins=!0,Y(t,s,`in ${e}() call`),L&&l.push(`--sourcemap${L===!0?"":`=${L}`}`),x&&l.push("--bundle"),W&&l.push("--allow-overwrite"),S)if(l.push("--watch"),typeof S=="boolean")P={};else{let o=Object.create(null),v=n(S,o,"onRebuild",je);Y(S,o,`on "watch" in ${e}() call`),P={onRebuild:v}}if(ae&&l.push("--splitting"),re&&l.push("--preserve-symlinks"),le&&l.push("--metafile"),ie&&l.push(`--outfile=${ie}`),ue&&l.push(`--outdir=${ue}`),fe&&l.push(`--outbase=${fe}`),ce&&l.push(`--platform=${ce}`),me&&l.push(`--tsconfig=${me}`),se){let o=[];for(let v of se){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);o.push(v)}l.push(`--resolve-extensions=${o.join(",")}`)}if(f&&l.push(`--public-path=${f}`),F&&l.push(`--entry-names=${F}`),D&&l.push(`--chunk-names=${D}`),M&&l.push(`--asset-names=${M}`),Se){let o=[];for(let v of Se){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);o.push(v)}l.push(`--main-fields=${o.join(",")}`)}if(te){let o=[];for(let v of te){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);o.push(v)}l.push(`--conditions=${o.join(",")}`)}if(g)for(let o of g)l.push(`--external:${o}`);if(T)for(let o in T){if(o.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${o}`);l.push(`--banner:${o}=${T[o]}`)}if(C)for(let o in C){if(o.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${o}`);l.push(`--footer:${o}=${C[o]}`)}if(E)for(let o of E)l.push(`--inject:${o}`);if(u)for(let o in u){if(o.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${o}`);l.push(`--loader:${o}=${u[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)c.push(["",o+""]);else for(let[o,v]of Object.entries(R))c.push([o+"",v+""]);if(k){let o=Object.create(null),v=n(k,o,"contents",m),q=n(k,o,"resolveDir",m),w=n(k,o,"sourcefile",m),d=n(k,o,"loader",m);Y(k,o,'in "stdin" object'),w&&l.push(`--sourcefile=${w}`),d&&l.push(`--loader=${d}`),q&&(O=q+""),y=v?v+"":""}let h=[];if(be)for(let o of be)o+="",h.push(o);return{entries:c,flags:l,write:A,stdinContents:y,stdinResolveDir:O,absWorkingDir:U,incremental:ee,nodePaths:h,watch:P,mangleCache:Ge($)}}function gt(e,t,r,i){let p=[],l=Object.create(null);Me(p,t,l,r,i),Qe(p,t,l);let c=n(t,l,"sourcemap",Ye),s=n(t,l,"tsconfigRaw",ft),y=n(t,l,"sourcefile",m),O=n(t,l,"loader",m),P=n(t,l,"banner",m),L=n(t,l,"footer",m),x=n(t,l,"mangleCache",ge);return Y(t,l,`in ${e}() call`),c&&p.push(`--sourcemap=${c===!0?"external":c}`),s&&p.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),y&&p.push(`--sourcefile=${y}`),O&&p.push(`--loader=${O}`),P&&p.push(`--banner=${P}`),L&&p.push(`--footer=${L}`),{flags:p,mangleCache:Ge(x)}}function Xe(e){let t=new Map,r=new Map,i=new Map,p=new Map,l=!1,c=0,s=0,y=new Uint8Array(16*1024),O=0,P=g=>{let u=O+g.length;if(u>y.length){let f=new Uint8Array(u*2);f.set(y),y=f}y.set(g,O),O+=g.length;let a=0;for(;a+4<=O;){let f=Fe(y,a);if(a+4+f>O)break;a+=4,le(y.subarray(a,a+f)),a+=f}a>0&&(y.copyWithin(0,a,O),O-=a)},L=()=>{l=!0;for(let g of t.values())g("The service was stopped",null);t.clear();for(let g of p.values())g.onWait("The service was stopped");p.clear();for(let g of i.values())try{g(new Error("The service was stopped"),null)}catch(u){console.error(u)}i.clear()},x=(g,u,a)=>{if(l)return a("The service is no longer running",null);let f=c++;t.set(f,(F,D)=>{try{a(F,D)}finally{g&&g.unref()}}),g&&g.ref(),e.writeToStdin(Ae({id:f,isRequest:!0,value:u}))},S=(g,u)=>{if(l)throw new Error("The service is no longer running");e.writeToStdin(Ae({id:g,isRequest:!1,value:u}))},ae=async(g,u)=>{try{switch(u.command){case"ping":{S(g,{});break}case"on-start":{let a=r.get(u.key);a?S(g,await a(u)):S(g,{});break}case"on-resolve":{let a=r.get(u.key);a?S(g,await a(u)):S(g,{});break}case"on-load":{let a=r.get(u.key);a?S(g,await a(u)):S(g,{});break}case"serve-request":{let a=p.get(u.key);a&&a.onRequest&&a.onRequest(u.args),S(g,{});break}case"serve-wait":{let a=p.get(u.key);a&&a.onWait(u.error),S(g,{});break}case"watch-rebuild":{let a=i.get(u.key);try{a&&a(null,u.args)}catch(f){console.error(f)}S(g,{});break}default:throw new Error("Invalid command: "+u.command)}}catch(a){S(g,{errors:[we(a,e,null,void 0,"")]})}},re=!0,le=g=>{if(re){re=!1;let a=String.fromCharCode(...g);if(a!=="0.14.20")throw new Error(`Cannot start service: Host version "0.14.20" does not match binary version ${JSON.stringify(a)}`);return}let u=ze(g);if(u.isRequest)ae(u.id,u.value);else{let a=t.get(u.id);t.delete(u.id),u.value.error?a(u.value.error,{}):a(null,u.value)}},ie=async(g,u,a,f,F)=>{let D=[],M=[],E={},T={},C=0,R=0,U=[],k=!1;u=[...u];for(let $ of u){let h={};if(typeof $!="object")throw new Error(`Plugin at index ${R} must be an object`);let b=n($,h,"name",m);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${R} is missing a name`);try{let o=n($,h,"setup",je);if(typeof o!="function")throw new Error("Plugin is missing a setup function");Y($,h,`on plugin ${JSON.stringify(b)}`);let v={name:b,onResolve:[],onLoad:[]};R++;let w=o({initialOptions:g,resolve:(d,N={})=>{if(!k)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof d!="string")throw new Error("The path to resolve must be a string");let B=Object.create(null),H=n(N,B,"pluginName",m),I=n(N,B,"importer",m),_=n(N,B,"namespace",m),X=n(N,B,"resolveDir",m),G=n(N,B,"kind",m),j=n(N,B,"pluginData",Ee);return Y(N,B,"in resolve() call"),new Promise((J,Q)=>{let K={command:"resolve",path:d,key:a,pluginName:b};H!=null&&(K.pluginName=H),I!=null&&(K.importer=I),_!=null&&(K.namespace=_),X!=null&&(K.resolveDir=X),G!=null&&(K.kind=G),j!=null&&(K.pluginData=f.store(j)),x(F,K,(oe,Z)=>{oe!==null?Q(new Error(oe)):J({errors:pe(Z.errors,f),warnings:pe(Z.warnings,f),path:Z.path,external:Z.external,sideEffects:Z.sideEffects,namespace:Z.namespace,suffix:Z.suffix,pluginData:f.load(Z.pluginData)})})})},onStart(d){let N='This error came from the "onStart" callback registered here:',B=xe(new Error(N),e,"onStart");D.push({name:b,callback:d,note:B})},onEnd(d){let N='This error came from the "onEnd" callback registered here:',B=xe(new Error(N),e,"onEnd");M.push({name:b,callback:d,note:B})},onResolve(d,N){let B='This error came from the "onResolve" callback registered here:',H=xe(new Error(B),e,"onResolve"),I={},_=n(d,I,"filter",$e),X=n(d,I,"namespace",m);if(Y(d,I,`in onResolve() call for plugin ${JSON.stringify(b)}`),_==null)throw new Error("onResolve() call is missing a filter");let G=C++;E[G]={name:b,callback:N,note:H},v.onResolve.push({id:G,filter:_.source,namespace:X||""})},onLoad(d,N){let B='This error came from the "onLoad" callback registered here:',H=xe(new Error(B),e,"onLoad"),I={},_=n(d,I,"filter",$e),X=n(d,I,"namespace",m);if(Y(d,I,`in onLoad() call for plugin ${JSON.stringify(b)}`),_==null)throw new Error("onLoad() call is missing a filter");let G=C++;T[G]={name:b,callback:N,note:H},v.onLoad.push({id:G,filter:_.source,namespace:X||""})},esbuild:e.esbuild});w&&await w,U.push(v)}catch(o){return{ok:!1,error:o,pluginName:b}}}let A=async $=>{switch($.command){case"on-start":{let h={errors:[],warnings:[]};return await Promise.all(D.map(async({name:b,callback:o,note:v})=>{try{let q=await o();if(q!=null){if(typeof q!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},d=n(q,w,"errors",V),N=n(q,w,"warnings",V);Y(q,w,`from onStart() callback in plugin ${JSON.stringify(b)}`),d!=null&&h.errors.push(...he(d,"errors",f,b)),N!=null&&h.warnings.push(...he(N,"warnings",f,b))}}catch(q){h.errors.push(we(q,e,f,v&&v(),b))}})),h}case"on-resolve":{let h={},b="",o,v;for(let q of $.ids)try{({name:b,callback:o,note:v}=E[q]);let w=await o({path:$.path,importer:$.importer,namespace:$.namespace,resolveDir:$.resolveDir,kind:$.kind,pluginData:f.load($.pluginData)});if(w!=null){if(typeof w!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let d={},N=n(w,d,"pluginName",m),B=n(w,d,"path",m),H=n(w,d,"namespace",m),I=n(w,d,"suffix",m),_=n(w,d,"external",z),X=n(w,d,"sideEffects",z),G=n(w,d,"pluginData",Ee),j=n(w,d,"errors",V),J=n(w,d,"warnings",V),Q=n(w,d,"watchFiles",V),K=n(w,d,"watchDirs",V);Y(w,d,`from onResolve() callback in plugin ${JSON.stringify(b)}`),h.id=q,N!=null&&(h.pluginName=N),B!=null&&(h.path=B),H!=null&&(h.namespace=H),I!=null&&(h.suffix=I),_!=null&&(h.external=_),X!=null&&(h.sideEffects=X),G!=null&&(h.pluginData=f.store(G)),j!=null&&(h.errors=he(j,"errors",f,b)),J!=null&&(h.warnings=he(J,"warnings",f,b)),Q!=null&&(h.watchFiles=ke(Q,"watchFiles")),K!=null&&(h.watchDirs=ke(K,"watchDirs"));break}}catch(w){return{id:q,errors:[we(w,e,f,v&&v(),b)]}}return h}case"on-load":{let h={},b="",o,v;for(let q of $.ids)try{({name:b,callback:o,note:v}=T[q]);let w=await o({path:$.path,namespace:$.namespace,suffix:$.suffix,pluginData:f.load($.pluginData)});if(w!=null){if(typeof w!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let d={},N=n(w,d,"pluginName",m),B=n(w,d,"contents",dt),H=n(w,d,"resolveDir",m),I=n(w,d,"pluginData",Ee),_=n(w,d,"loader",m),X=n(w,d,"errors",V),G=n(w,d,"warnings",V),j=n(w,d,"watchFiles",V),J=n(w,d,"watchDirs",V);Y(w,d,`from onLoad() callback in plugin ${JSON.stringify(b)}`),h.id=q,N!=null&&(h.pluginName=N),B instanceof Uint8Array?h.contents=B:B!=null&&(h.contents=de(B)),H!=null&&(h.resolveDir=H),I!=null&&(h.pluginData=f.store(I)),_!=null&&(h.loader=_),X!=null&&(h.errors=he(X,"errors",f,b)),G!=null&&(h.warnings=he(G,"warnings",f,b)),j!=null&&(h.watchFiles=ke(j,"watchFiles")),J!=null&&(h.watchDirs=ke(J,"watchDirs"));break}}catch(w){return{id:q,errors:[we(w,e,f,v&&v(),b)]}}return h}default:throw new Error("Invalid command: "+$.command)}},W=($,h,b)=>b();M.length>0&&(W=($,h,b)=>{(async()=>{for(let{name:o,callback:v,note:q}of M)try{await v($)}catch(w){$.errors.push(await new Promise(d=>h(w,o,q&&q(),d)))}})().then(b)}),k=!0;let ee=0;return{ok:!0,requestPlugins:U,runOnEndCallbacks:W,pluginRefs:{ref(){++ee===1&&r.set(a,A)},unref(){--ee===0&&r.delete(a)}}}},ue=(g,u,a,f)=>{let F={},D=n(u,F,"port",Re),M=n(u,F,"host",m),E=n(u,F,"servedir",m),T=n(u,F,"onRequest",je),C,R=new Promise((U,k)=>{C=A=>{p.delete(f),A!==null?k(new Error(A)):U()}});return a.serve={},Y(u,F,"in serve() call"),D!==void 0&&(a.serve.port=D),M!==void 0&&(a.serve.host=M),E!==void 0&&(a.serve.servedir=E),p.set(f,{onRequest:T,onWait:C}),{wait:R,stop(){x(g,{command:"serve-stop",key:f},()=>{})}}},fe="warning",ce="silent",me=g=>{let u=s++,a=Ve(),f,{refs:F,options:D,isTTY:M,callback:E}=g;if(typeof D=="object"){let R=D.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');f=R}}let T=(R,U,k,A)=>{let W=[];try{Me(W,D,{},M,fe)}catch($){}let ee=we(R,e,a,k,U);x(F,{command:"error",flags:W,error:ee},()=>{ee.detail=a.load(ee.detail),A(ee)})},C=(R,U)=>{T(R,U,void 0,k=>{E(ve("Build failed",[k],[]),null)})};if(f&&f.length>0){if(e.isSync)return C(new Error("Cannot use plugins in synchronous API calls"),"");ie(D,f,u,a,F).then(R=>{if(!R.ok)C(R.error,R.pluginName);else try{se(Be(Te({},g),{key:u,details:a,logPluginError:T,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(U){C(U,"")}},R=>C(R,""))}else try{se(Be(Te({},g),{key:u,details:a,logPluginError:T,requestPlugins:null,runOnEndCallbacks:(R,U,k)=>k(),pluginRefs:null}))}catch(R){C(R,"")}},se=({callName:g,refs:u,serveOptions:a,options:f,isTTY:F,defaultWD:D,callback:M,key:E,details:T,logPluginError:C,requestPlugins:R,runOnEndCallbacks:U,pluginRefs:k})=>{let A={ref(){k&&k.ref(),u&&u.ref()},unref(){k&&k.unref(),u&&u.unref()}},W=!e.isBrowser,{entries:ee,flags:$,write:h,stdinContents:b,stdinResolveDir:o,absWorkingDir:v,incremental:q,nodePaths:w,watch:d,mangleCache:N}=pt(g,f,F,fe,W),B={command:"build",key:E,entries:ee,flags:$,write:h,stdinContents:b,stdinResolveDir:o,absWorkingDir:v||D,incremental:q,nodePaths:w};R&&(B.plugins=R),N&&(B.mangleCache=N);let H=a&&ue(A,a,B,E),I,_,X=(j,J)=>{j.outputFiles&&(J.outputFiles=j.outputFiles.map(mt)),j.metafile&&(J.metafile=JSON.parse(j.metafile)),j.mangleCache&&(J.mangleCache=j.mangleCache),j.writeToStdout!==void 0&&console.log(ye(j.writeToStdout).replace(/\n$/,""))},G=(j,J)=>{let Q={errors:pe(j.errors,T),warnings:pe(j.warnings,T)};X(j,Q),U(Q,C,()=>{if(Q.errors.length>0)return J(ve("Build failed",Q.errors,Q.warnings),null);if(j.rebuild){if(!I){let K=!1;I=()=>new Promise((oe,Z)=>{if(K||l)throw new Error("Cannot rebuild");x(A,{command:"rebuild",key:E},(ne,et)=>{if(ne)return J(ve("Build failed",[{pluginName:"",text:ne,location:null,notes:[],detail:void 0}],[]),null);G(et,(Pe,tt)=>{Pe?Z(Pe):oe(tt)})})}),A.ref(),I.dispose=()=>{K||(K=!0,x(A,{command:"rebuild-dispose",key:E},()=>{}),A.unref())}}Q.rebuild=I}if(j.watch){if(!_){let K=!1;A.ref(),_=()=>{K||(K=!0,i.delete(E),x(A,{command:"watch-stop",key:E},()=>{}),A.unref())},d&&i.set(E,(oe,Z)=>{if(oe){d.onRebuild&&d.onRebuild(oe,null);return}let ne={errors:pe(Z.errors,T),warnings:pe(Z.warnings,T)};X(Z,ne),U(ne,C,()=>{if(ne.errors.length>0){d.onRebuild&&d.onRebuild(ve("Build failed",ne.errors,ne.warnings),null);return}Z.rebuildID!==void 0&&(ne.rebuild=I),ne.stop=_,d.onRebuild&&d.onRebuild(null,ne)})})}Q.stop=_}J(null,Q)})};if(h&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(q&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(d&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');x(A,B,(j,J)=>{if(j)return M(new Error(j),null);if(H){let Q=J,K=!1;A.ref();let oe={port:Q.port,host:Q.host,wait:H.wait,stop(){K||(K=!0,H.stop(),A.unref())}};return A.ref(),H.wait.then(A.unref,A.unref),M(null,oe)}return G(J,M)})};return{readFromStdout:P,afterClose:L,service:{buildOrServe:me,transform:({callName:g,refs:u,input:a,options:f,isTTY:F,fs:D,callback:M})=>{let E=Ve(),T=C=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let{flags:R,mangleCache:U}=gt(g,f,F,ce),k={command:"transform",flags:R,inputFS:C!==null,input:C!==null?C:a};U&&(k.mangleCache=U),x(u,k,(A,W)=>{if(A)return M(new Error(A),null);let ee=pe(W.errors,E),$=pe(W.warnings,E),h=1,b=()=>{if(--h===0){let o={warnings:$,code:W.code,map:W.map};W.mangleCache&&(o.mangleCache=W==null?void 0:W.mangleCache),M(null,o)}};if(ee.length>0)return M(ve("Transform failed",ee,$),null);W.codeFS&&(h++,D.readFile(W.code,(o,v)=>{o!==null?M(o,null):(W.code=v,b())})),W.mapFS&&(h++,D.readFile(W.map,(o,v)=>{o!==null?M(o,null):(W.map=v,b())})),b()})}catch(R){let U=[];try{Me(U,f,{},F,ce)}catch(A){}let k=we(R,e,E,void 0,"");x(u,{command:"error",flags:U,error:k},()=>{k.detail=E.load(k.detail),M(ve("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let C=T;T=()=>D.writeFile(a,C)}T(null)},formatMessages:({callName:g,refs:u,messages:a,options:f,callback:F})=>{let D=he(a,"messages",null,"");if(!f)throw new Error(`Missing second argument in ${g}() call`);let M={},E=n(f,M,"kind",m),T=n(f,M,"color",z),C=n(f,M,"terminalWidth",Re);if(Y(f,M,`in ${g}() call`),E===void 0)throw new Error(`Missing "kind" in ${g}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${g}() call`);let R={command:"format-msgs",messages:D,isWarning:E==="warning"};T!==void 0&&(R.color=T),C!==void 0&&(R.terminalWidth=C),x(u,R,(U,k)=>{if(U)return F(new Error(U),null);F(null,k.messages)})},analyzeMetafile:({callName:g,refs:u,metafile:a,options:f,callback:F})=>{f===void 0&&(f={});let D={},M=n(f,D,"color",z),E=n(f,D,"verbose",z);Y(f,D,`in ${g}() call`);let T={command:"analyze-metafile",metafile:a};M!==void 0&&(T.color=M),E!==void 0&&(T.verbose=E),x(u,T,(C,R)=>{if(C)return F(new Error(C),null);F(null,R.result)})}}}}function Ve(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let i=t++;return e.set(i,r),i}}}function xe(e,t,r){let i,p=!1;return()=>{if(p)return i;p=!0;try{let l=(e.stack+"").split(`
2
+ `);l.splice(1,1);let c=Ze(t,l,r);if(c)return i={text:e.message,location:c},i}catch(l){}}}function we(e,t,r,i,p){let l="Internal error",c=null;try{l=(e&&e.message||e)+""}catch(s){}try{c=Ze(t,(e.stack+"").split(`
3
+ `),"")}catch(s){}return{pluginName:p,text:l,location:c,notes:i?[i]:[],detail:r?r.store(e):-1}}function Ze(e,t,r){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let p=1;p<t.length;p++){let l=t[p];if(!!l.startsWith(i))for(l=l.slice(i.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 s;try{s=e.readFileSync(c[1],"utf8")}catch(L){break}let y=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",O=+c[3]-1,P=y.slice(O,O+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:de(y.slice(0,O)).length,length:de(y.slice(O,O+P)).length,lineText:y+`
4
4
  `+t.slice(1).join(`
5
- `),suggestion:""}}break}}return null}function be(e,t,r){let o=5,d=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,o+1).map((c,s)=>{if(s===o)return`
5
+ `),suggestion:""}}break}}return null}function ve(e,t,r){let i=5,p=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,i+1).map((c,s)=>{if(s===i)return`
6
6
  ...`;if(!c.location)return`
7
- error: ${c.text}`;let{file:y,line:R,column:T}=c.location,C=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
8
- ${y}:${R}:${T}: ERROR: ${C}${c.text}`}).join(""),i=new Error(`${e}${d}`);return i.errors=t,i.warnings=r,i}function de(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Ve(e,t){if(e==null)return null;let r={},o=n(e,r,"file",g),d=n(e,r,"namespace",g),i=n(e,r,"line",ve),c=n(e,r,"column",ve),s=n(e,r,"length",ve),y=n(e,r,"lineText",g),R=n(e,r,"suggestion",g);return Y(e,r,t),{file:o||"",namespace:d||"",line:i||0,column:c||0,length:s||0,lineText:y||"",suggestion:R||""}}function me(e,t,r,o){let d=[],i=0;for(let c of e){let s={},y=n(c,s,"pluginName",g),R=n(c,s,"text",g),T=n(c,s,"location",Ke),C=n(c,s,"notes",_),$=n(c,s,"detail",ke),S=`in element ${i} of "${t}"`;Y(c,s,S);let oe=[];if(C)for(let re of C){let ne={},le=n(re,ne,"text",g),ae=n(re,ne,"location",Ke);Y(re,ne,S),oe.push({text:le||"",location:Ve(ae,S)})}d.push({pluginName:y||o,text:R||"",location:Ve(T,S),notes:oe,detail:r?r.store($):-1}),i++}return d}function xe(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 pt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ge(t)),r}}}var mt="0.14.16",yt=e=>Pe().build(e),ht=()=>{throw new Error('The "serve" API only works in node')},bt=(e,t)=>Pe().transform(e,t),wt=(e,t)=>Pe().formatMessages(e,t),vt=(e,t)=>Pe().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')},Re,Ce,Pe=()=>{if(Ce)return Ce;throw Re?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=Ye(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",Re)throw new Error('Cannot call "initialize" more than once');return Re=Et(t,r),Re.catch(()=>{Re=void 0}),Re},Et=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(),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.\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(n,s,i,l,d,u){if(i===0&&l===s.length&&d===null){if(n===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}}r.write(n,s,i,l,d,u)}}))}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(n,s){r+=g.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,l,d,u){if(i!==0||l!==s.length||d!==null){u(a());return}const h=this.writeSync(n,s);u(null,h)},chmod(n,s,i){i(a())},chown(n,s,i,l){l(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,l){l(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,l){l(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,l){l(a())},read(n,s,i,l,d,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,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(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/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 f=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)},n=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]},i=(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=n(e+0),o=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},d=e=>{const t=n(e+0),o=n(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},u=e=>{const t=n(e+0),o=n(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},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=n(e+8),o=n(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,(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()},n(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,i(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,i(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,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,u(e+16)),c=d(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(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=f.encode(String(s(e+8)));i(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 n=4096;const s=e=>{const t=n,o=f.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!==0&&(n+=8-n%8),t},i=this.argv.length,l=[];this.argv.forEach(e=>{l.push(s(e))}),l.push(0),Object.keys(this.env).sort().forEach(e=>{l.push(s(`${e}=${this.env[e]}`))}),l.push(0);const u=n;l.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const h=4096+8192;if(n>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,u),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 n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._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(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),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.14.16"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',i;if(t){let y=new Blob([d],{type:"text/javascript"});i=new Worker(URL.createObjectURL(y))}else{let R=new Function("postMessage",d+"var onmessage; return m => onmessage(m)")(T=>i.onmessage({data:T}));i={onmessage:null,postMessage:T=>R({data:T}),terminate(){}}}i.postMessage(o),i.onmessage=({data:y})=>c(y);let{readFromStdout:c,service:s}=Ge({writeToStdin(y){i.postMessage(y)},isSync:!1,isBrowser:!0,esbuild:Le});Ce={build:y=>new Promise((R,T)=>s.buildOrServe({callName:"build",refs:null,serveOptions:null,options:y,isTTY:!1,defaultWD:"/",callback:(C,$)=>C?T(C):R($)})),transform:(y,R)=>new Promise((T,C)=>s.transform({callName:"transform",refs:null,input:y,options:R||{},isTTY:!1,fs:{readFile($,S){S(new Error("Internal error"),null)},writeFile($,S){S(null)}},callback:($,S)=>$?C($):T(S)})),formatMessages:(y,R)=>new Promise((T,C)=>s.formatMessages({callName:"formatMessages",refs:null,messages:y,options:R,callback:($,S)=>$?C($):T(S)})),analyzeMetafile:(y,R)=>new Promise((T,C)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof y=="string"?y:JSON.stringify(y),options:R,callback:($,S)=>$?C($):T(S)}))}};export{vt as analyzeMetafile,xt as analyzeMetafileSync,yt as build,Rt as buildSync,wt as formatMessages,St as formatMessagesSync,kt as initialize,ht as serve,bt as transform,Ot as transformSync,mt as version};
7
+ error: ${c.text}`;let{file:y,line:O,column:P}=c.location,L=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
8
+ ${y}:${O}:${P}: ERROR: ${L}${c.text}`}).join(""),l=new Error(`${e}${p}`);return l.errors=t,l.warnings=r,l}function pe(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Je(e,t){if(e==null)return null;let r={},i=n(e,r,"file",m),p=n(e,r,"namespace",m),l=n(e,r,"line",Re),c=n(e,r,"column",Re),s=n(e,r,"length",Re),y=n(e,r,"lineText",m),O=n(e,r,"suggestion",m);return Y(e,r,t),{file:i||"",namespace:p||"",line:l||0,column:c||0,length:s||0,lineText:y||"",suggestion:O||""}}function he(e,t,r,i){let p=[],l=0;for(let c of e){let s={},y=n(c,s,"pluginName",m),O=n(c,s,"text",m),P=n(c,s,"location",_e),L=n(c,s,"notes",V),x=n(c,s,"detail",Ee),S=`in element ${l} of "${t}"`;Y(c,s,S);let ae=[];if(L)for(let re of L){let le={},ie=n(re,le,"text",m),ue=n(re,le,"location",_e);Y(re,le,S),ae.push({text:ie||"",location:Je(ue,S)})}p.push({pluginName:y||i,text:O||"",location:Je(P,S),notes:ae,detail:r?r.store(x):-1}),l++}return p}function ke(e,t){let r=[];for(let i of e){if(typeof i!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(i)}return r}function mt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ye(t)),r}}}var ht="0.14.20",bt=e=>Ce().build(e),wt=()=>{throw new Error('The "serve" API only works in node')},vt=(e,t)=>Ce().transform(e,t),Rt=(e,t)=>Ce().formatMessages(e,t),Ot=(e,t)=>Ce().analyzeMetafile(e,t),St=()=>{throw new Error('The "buildSync" API only works in node')},xt=()=>{throw new Error('The "transformSync" API only works in node')},kt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Et=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},Oe,Le,Ce=()=>{if(Le)return Le;throw Oe?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')},$t=e=>{e=He(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",Oe)throw new Error('Cannot call "initialize" more than once');return Oe=Mt(t,r),Oe.catch(()=>{Oe=void 0}),Oe},Mt=async(e,t)=>{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let i=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(n,s,i,l,d,u){if(i===0&&l===s.length&&d===null){if(n===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}}r.write(n,s,i,l,d,u)}}))}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(n,s){r+=g.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,l,d,u){if(i!==0||l!==s.length||d!==null){u(a());return}const h=this.writeSync(n,s);u(null,h)},chmod(n,s,i){i(a())},chown(n,s,i,l){l(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,l){l(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,l){l(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,l){l(a())},read(n,s,i,l,d,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,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(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/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 f=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)},n=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]},i=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!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,2146959360|m,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=n(e+0),o=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},d=e=>{const t=n(e+0),o=n(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},u=e=>{const t=n(e+0),o=n(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},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=n(e+8),o=n(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,(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()},n(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,i(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,i(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,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,u(e+16)),c=d(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(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=f.encode(String(s(e+8)));i(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 n=4096;const s=e=>{const t=n,o=f.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!==0&&(n+=8-n%8),t},i=this.argv.length,l=[];this.argv.forEach(e=>{l.push(s(e))}),l.push(0),Object.keys(this.env).sort().forEach(e=>{l.push(s(`${e}=${this.env[e]}`))}),l.push(0);const u=n;l.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const h=4096+8192;if(n>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,u),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 n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._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(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),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.14.20"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let y=new Blob([p],{type:"text/javascript"});l=new Worker(URL.createObjectURL(y))}else{let O=new Function("postMessage",p+"var onmessage; return m => onmessage(m)")(P=>l.onmessage({data:P}));l={onmessage:null,postMessage:P=>O({data:P}),terminate(){}}}l.postMessage(i),l.onmessage=({data:y})=>c(y);let{readFromStdout:c,service:s}=Xe({writeToStdin(y){l.postMessage(y)},isSync:!1,isBrowser:!0,esbuild:Ue});Le={build:y=>new Promise((O,P)=>s.buildOrServe({callName:"build",refs:null,serveOptions:null,options:y,isTTY:!1,defaultWD:"/",callback:(L,x)=>L?P(L):O(x)})),transform:(y,O)=>new Promise((P,L)=>s.transform({callName:"transform",refs:null,input:y,options:O||{},isTTY:!1,fs:{readFile(x,S){S(new Error("Internal error"),null)},writeFile(x,S){S(null)}},callback:(x,S)=>x?L(x):P(S)})),formatMessages:(y,O)=>new Promise((P,L)=>s.formatMessages({callName:"formatMessages",refs:null,messages:y,options:O,callback:(x,S)=>x?L(x):P(S)})),analyzeMetafile:(y,O)=>new Promise((P,L)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof y=="string"?y:JSON.stringify(y),options:O,callback:(x,S)=>x?L(x):P(S)}))}};export{Ot as analyzeMetafile,Et as analyzeMetafileSync,bt as build,St as buildSync,Rt as formatMessages,kt as formatMessagesSync,$t as initialize,wt as serve,vt as transform,xt as transformSync,ht as version};
@@ -26,6 +26,8 @@ interface CommonOptions {
26
26
  mangleProps?: RegExp;
27
27
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
28
  reserveProps?: RegExp;
29
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleCache?: Record<string, string | false>;
29
31
  /** Documentation: https://esbuild.github.io/api/#drop */
30
32
  drop?: Drop[];
31
33
  /** Documentation: https://esbuild.github.io/api/#minify */
@@ -200,6 +202,8 @@ export interface BuildResult {
200
202
  stop?: () => void;
201
203
  /** Only when "metafile: true" */
202
204
  metafile?: Metafile;
205
+ /** Only when "mangleCache" is present */
206
+ mangleCache?: Record<string, string | false>;
203
207
  }
204
208
 
205
209
  export interface BuildFailure extends Error {
@@ -253,6 +257,8 @@ export interface TransformResult {
253
257
  code: string;
254
258
  map: string;
255
259
  warnings: Message[];
260
+ /** Only when "mangleCache" is present */
261
+ mangleCache?: Record<string, string | false>;
256
262
  }
257
263
 
258
264
  export interface TransformFailure extends Error {
@@ -288,6 +288,21 @@ function validateInitializeOptions(options) {
288
288
  worker
289
289
  };
290
290
  }
291
+ function validateMangleCache(mangleCache) {
292
+ let validated;
293
+ if (mangleCache !== void 0) {
294
+ validated = /* @__PURE__ */ Object.create(null);
295
+ for (let key of Object.keys(mangleCache)) {
296
+ let value = mangleCache[key];
297
+ if (typeof value === "string" || value === false) {
298
+ validated[key] = value;
299
+ } else {
300
+ throw new Error(`Expected ${JSON.stringify(key)} in mangle cache to map to either a string or false`);
301
+ }
302
+ }
303
+ }
304
+ return validated;
305
+ }
291
306
  function pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {
292
307
  let color = getFlag(options, keys, "color", mustBeBoolean);
293
308
  let logLevel = getFlag(options, keys, "logLevel", mustBeString);
@@ -419,6 +434,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
419
434
  let write = (_a = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a : writeDefault;
420
435
  let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
421
436
  let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
437
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
422
438
  keys.plugins = true;
423
439
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
424
440
  if (sourcemap)
@@ -568,7 +584,8 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
568
584
  absWorkingDir,
569
585
  incremental,
570
586
  nodePaths,
571
- watch: watchMode
587
+ watch: watchMode,
588
+ mangleCache: validateMangleCache(mangleCache)
572
589
  };
573
590
  }
574
591
  function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
@@ -582,6 +599,7 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
582
599
  let loader = getFlag(options, keys, "loader", mustBeString);
583
600
  let banner = getFlag(options, keys, "banner", mustBeString);
584
601
  let footer = getFlag(options, keys, "footer", mustBeString);
602
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
585
603
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
586
604
  if (sourcemap)
587
605
  flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
@@ -595,7 +613,10 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
595
613
  flags.push(`--banner=${banner}`);
596
614
  if (footer)
597
615
  flags.push(`--footer=${footer}`);
598
- return flags;
616
+ return {
617
+ flags,
618
+ mangleCache: validateMangleCache(mangleCache)
619
+ };
599
620
  }
600
621
  function createChannel(streamIn) {
601
622
  let responseCallbacks = /* @__PURE__ */ new Map();
@@ -739,8 +760,8 @@ function createChannel(streamIn) {
739
760
  if (isFirstPacket) {
740
761
  isFirstPacket = false;
741
762
  let binaryVersion = String.fromCharCode(...bytes);
742
- if (binaryVersion !== "0.14.16") {
743
- throw new Error(`Cannot start service: Host version "${"0.14.16"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
763
+ if (binaryVersion !== "0.14.20") {
764
+ throw new Error(`Cannot start service: Host version "${"0.14.20"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
744
765
  }
745
766
  return;
746
767
  }
@@ -1199,7 +1220,8 @@ function createChannel(streamIn) {
1199
1220
  absWorkingDir,
1200
1221
  incremental,
1201
1222
  nodePaths,
1202
- watch
1223
+ watch,
1224
+ mangleCache
1203
1225
  } = flagsForBuildOptions(callName, options, isTTY, buildLogLevelDefault, writeDefault);
1204
1226
  let request = {
1205
1227
  command: "build",
@@ -1215,6 +1237,8 @@ function createChannel(streamIn) {
1215
1237
  };
1216
1238
  if (requestPlugins)
1217
1239
  request.plugins = requestPlugins;
1240
+ if (mangleCache)
1241
+ request.mangleCache = mangleCache;
1218
1242
  let serve2 = serveOptions && buildServeData(refs, serveOptions, request, key);
1219
1243
  let rebuild;
1220
1244
  let stop;
@@ -1223,6 +1247,8 @@ function createChannel(streamIn) {
1223
1247
  result.outputFiles = response.outputFiles.map(convertOutputFiles);
1224
1248
  if (response.metafile)
1225
1249
  result.metafile = JSON.parse(response.metafile);
1250
+ if (response.mangleCache)
1251
+ result.mangleCache = response.mangleCache;
1226
1252
  if (response.writeToStdout !== void 0)
1227
1253
  console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1228
1254
  };
@@ -1350,20 +1376,32 @@ function createChannel(streamIn) {
1350
1376
  try {
1351
1377
  if (typeof input !== "string")
1352
1378
  throw new Error('The input to "transform" must be a string');
1353
- let flags = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1379
+ let {
1380
+ flags,
1381
+ mangleCache
1382
+ } = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1354
1383
  let request = {
1355
1384
  command: "transform",
1356
1385
  flags,
1357
1386
  inputFS: inputPath !== null,
1358
1387
  input: inputPath !== null ? inputPath : input
1359
1388
  };
1389
+ if (mangleCache)
1390
+ request.mangleCache = mangleCache;
1360
1391
  sendRequest(refs, request, (error, response) => {
1361
1392
  if (error)
1362
1393
  return callback(new Error(error), null);
1363
1394
  let errors = replaceDetailsInMessages(response.errors, details);
1364
1395
  let warnings = replaceDetailsInMessages(response.warnings, details);
1365
1396
  let outstanding = 1;
1366
- let next = () => --outstanding === 0 && callback(null, { warnings, code: response.code, map: response.map });
1397
+ let next = () => {
1398
+ if (--outstanding === 0) {
1399
+ let result = { warnings, code: response.code, map: response.map };
1400
+ if (response.mangleCache)
1401
+ result.mangleCache = response == null ? void 0 : response.mangleCache;
1402
+ callback(null, result);
1403
+ }
1404
+ };
1367
1405
  if (errors.length > 0)
1368
1406
  return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1369
1407
  if (response.codeFS) {
@@ -1668,7 +1706,7 @@ function convertOutputFiles({ path, contents }) {
1668
1706
  }
1669
1707
 
1670
1708
  // lib/npm/browser.ts
1671
- var version = "0.14.16";
1709
+ var version = "0.14.20";
1672
1710
  var build = (options) => ensureServiceIsRunning().build(options);
1673
1711
  var serve = () => {
1674
1712
  throw new Error(`The "serve" API only works in node`);
@@ -2425,7 +2463,7 @@ onmessage = ({ data: wasm }) => {
2425
2463
  callback(null, count);
2426
2464
  };
2427
2465
  let go = new global.Go();
2428
- go.argv = ["", \`--service=\${"0.14.16"}\`];
2466
+ go.argv = ["", \`--service=\${"0.14.20"}\`];
2429
2467
  WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
2430
2468
  };}`;
2431
2469
  let worker;
@@ -1,10 +1,10 @@
1
1
  (module=>{
2
- var xe=Object.defineProperty,rt=Object.defineProperties,nt=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var Ie=(e,t,r)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,De=(e,t)=>{for(var r in t||(t={}))ze.call(t,r)&&Ie(e,r,t[r]);if(We)for(var r of We(t))st.call(t,r)&&Ie(e,r,t[r]);return e},Ae=(e,t)=>rt(e,lt(t)),ot=e=>xe(e,"__esModule",{value:!0});var at=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of it(t))!ze.call(e,u)&&(r||u!=="default")&&xe(e,u,{get:()=>t[u],enumerable:!(o=nt(t,u))||o.enumerable});return e};var ft=(e=>(t,r)=>e&&e.get(t)||(r=ut(ot({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var ce=(e,t,r)=>new Promise((o,u)=>{var l=d=>{try{s(r.next(d))}catch(v){u(v)}},c=d=>{try{s(r.throw(d))}catch(v){u(v)}},s=d=>d.done?o(d.value):Promise.resolve(d.value).then(l,c);s((r=r.apply(e,t)).next())});var qe={};at(qe,{analyzeMetafile:()=>Et,analyzeMetafileSync:()=>Bt,build:()=>Ot,buildSync:()=>$t,formatMessages:()=>kt,formatMessagesSync:()=>Mt,initialize:()=>Tt,serve:()=>St,transform:()=>xt,transformSync:()=>Pt,version:()=>Rt});function Ne(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(de(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 u of o)t(u)}else{let u=Object.keys(o);r.write8(6),r.write32(u.length);for(let l of u)r.write(de(l)),t(o[l])}},r=new je;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 Ke(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return me(r.read());case 4:return r.read();case 5:{let c=r.read32(),s=[];for(let d=0;d<c;d++)s.push(t());return s}case 6:{let c=r.read32(),s={};for(let d=0;d<c;d++)s[me(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new je(e),o=r.read32(),u=(o&1)===0;o>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:u,value:l}}var je=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 Ce(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}},de,me;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;de=r=>e.encode(r),me=r=>t.decode(r)}else if(typeof Buffer!="undefined")de=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},me=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 Ce(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 _e(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var $e=()=>null,U=e=>typeof e=="boolean"?null:"a boolean",dt=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",y=e=>typeof e=="string"?null:"a string",Pe=e=>e instanceof RegExp?null:"a RegExp object",Re=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Le=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ve=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",pt=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",He=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",gt=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",mt=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",yt=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,o){let u=e[r];if(t[r+""]=!0,u===void 0)return;let l=o(u);if(l!==null)throw new Error(`"${r}" must be ${l}`);return u}function J(e,t,r){for(let o in e)if(!(o in t))throw new Error(`Invalid option ${r}: "${o}"`)}function Ge(e){let t=Object.create(null),r=n(e,t,"wasmURL",y),o=n(e,t,"worker",U);return J(e,t,"in startService() call"),{wasmURL:r,worker:o}}function Me(e,t,r,o,u){let l=n(t,r,"color",U),c=n(t,r,"logLevel",y),s=n(t,r,"logLimit",Re);l!==void 0?e.push(`--color=${l}`):o&&e.push("--color=true"),e.push(`--log-level=${c||u}`),e.push(`--log-limit=${s||0}`)}function Qe(e,t,r){let o=n(t,r,"legalComments",y),u=n(t,r,"sourceRoot",y),l=n(t,r,"sourcesContent",U),c=n(t,r,"target",mt),s=n(t,r,"format",y),d=n(t,r,"globalName",y),v=n(t,r,"mangleProps",Pe),D=n(t,r,"reserveProps",Pe),C=n(t,r,"minify",U),P=n(t,r,"minifySyntax",U),S=n(t,r,"minifyWhitespace",U),oe=n(t,r,"minifyIdentifiers",U),re=n(t,r,"drop",K),ne=n(t,r,"charset",y),le=n(t,r,"treeShaking",U),ae=n(t,r,"ignoreAnnotations",U),ue=n(t,r,"jsx",y),fe=n(t,r,"jsxFactory",y),ge=n(t,r,"jsxFragment",y),ie=n(t,r,"define",ve),he=n(t,r,"pure",K),Se=n(t,r,"keepNames",U);if(o&&e.push(`--legal-comments=${o}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),c&&(Array.isArray(c)?e.push(`--target=${Array.from(c).map(_e).join(",")}`):e.push(`--target=${_e(c)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),C&&e.push("--minify"),P&&e.push("--minify-syntax"),S&&e.push("--minify-whitespace"),oe&&e.push("--minify-identifiers"),ne&&e.push(`--charset=${ne}`),le!==void 0&&e.push(`--tree-shaking=${le}`),ae&&e.push("--ignore-annotations"),re)for(let ee of re)e.push(`--drop:${ee}`);if(v&&e.push(`--mangle-props=${v.source}`),D&&e.push(`--reserve-props=${D.source}`),ue&&e.push(`--jsx=${ue}`),fe&&e.push(`--jsx-factory=${fe}`),ge&&e.push(`--jsx-fragment=${ge}`),ie)for(let ee in ie){if(ee.indexOf("=")>=0)throw new Error(`Invalid define: ${ee}`);e.push(`--define:${ee}=${ie[ee]}`)}if(he)for(let ee of he)e.push(`--pure:${ee}`);Se&&e.push("--keep-names")}function ht(e,t,r,o,u){var b;let l=[],c=[],s=Object.create(null),d=null,v=null,D=null;Me(l,t,s,r,o),Qe(l,t,s);let C=n(t,s,"sourcemap",He),P=n(t,s,"bundle",U),S=n(t,s,"watch",dt),oe=n(t,s,"splitting",U),re=n(t,s,"preserveSymlinks",U),ne=n(t,s,"metafile",U),le=n(t,s,"outfile",y),ae=n(t,s,"outdir",y),ue=n(t,s,"outbase",y),fe=n(t,s,"platform",y),ge=n(t,s,"tsconfig",y),ie=n(t,s,"resolveExtensions",K),he=n(t,s,"nodePaths",K),Se=n(t,s,"mainFields",K),ee=n(t,s,"conditions",K),g=n(t,s,"external",K),f=n(t,s,"loader",ve),a=n(t,s,"outExtension",ve),p=n(t,s,"publicPath",y),j=n(t,s,"entryNames",y),N=n(t,s,"chunkNames",y),M=n(t,s,"assetNames",y),E=n(t,s,"inject",K),A=n(t,s,"banner",ve),B=n(t,s,"footer",ve),w=n(t,s,"entryPoints",pt),L=n(t,s,"absWorkingDir",y),k=n(t,s,"stdin",ve),O=(b=n(t,s,"write",U))!=null?b:u,te=n(t,s,"allowOverwrite",U),X=n(t,s,"incremental",U)===!0;if(s.plugins=!0,J(t,s,`in ${e}() call`),C&&l.push(`--sourcemap${C===!0?"":`=${C}`}`),P&&l.push("--bundle"),te&&l.push("--allow-overwrite"),S)if(l.push("--watch"),typeof S=="boolean")D={};else{let i=Object.create(null),R=n(S,i,"onRebuild",Le);J(S,i,`on "watch" in ${e}() call`),D={onRebuild:R}}if(oe&&l.push("--splitting"),re&&l.push("--preserve-symlinks"),ne&&l.push("--metafile"),le&&l.push(`--outfile=${le}`),ae&&l.push(`--outdir=${ae}`),ue&&l.push(`--outbase=${ue}`),fe&&l.push(`--platform=${fe}`),ge&&l.push(`--tsconfig=${ge}`),ie){let i=[];for(let R of ie){if(R+="",R.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${R}`);i.push(R)}l.push(`--resolve-extensions=${i.join(",")}`)}if(p&&l.push(`--public-path=${p}`),j&&l.push(`--entry-names=${j}`),N&&l.push(`--chunk-names=${N}`),M&&l.push(`--asset-names=${M}`),Se){let i=[];for(let R of Se){if(R+="",R.indexOf(",")>=0)throw new Error(`Invalid main field: ${R}`);i.push(R)}l.push(`--main-fields=${i.join(",")}`)}if(ee){let i=[];for(let R of ee){if(R+="",R.indexOf(",")>=0)throw new Error(`Invalid condition: ${R}`);i.push(R)}l.push(`--conditions=${i.join(",")}`)}if(g)for(let i of g)l.push(`--external:${i}`);if(A)for(let i in A){if(i.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${i}`);l.push(`--banner:${i}=${A[i]}`)}if(B)for(let i in B){if(i.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${i}`);l.push(`--footer:${i}=${B[i]}`)}if(E)for(let i of E)l.push(`--inject:${i}`);if(f)for(let i in f){if(i.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${i}`);l.push(`--loader:${i}=${f[i]}`)}if(a)for(let i in a){if(i.indexOf("=")>=0)throw new Error(`Invalid out extension: ${i}`);l.push(`--out-extension:${i}=${a[i]}`)}if(w)if(Array.isArray(w))for(let i of w)c.push(["",i+""]);else for(let[i,R]of Object.entries(w))c.push([i+"",R+""]);if(k){let i=Object.create(null),R=n(k,i,"contents",y),q=n(k,i,"resolveDir",y),Y=n(k,i,"sourcefile",y),h=n(k,i,"loader",y);J(k,i,'in "stdin" object'),Y&&l.push(`--sourcefile=${Y}`),h&&l.push(`--loader=${h}`),q&&(v=q+""),d=R?R+"":""}let x=[];if(he)for(let i of he)i+="",x.push(i);return{entries:c,flags:l,write:O,stdinContents:d,stdinResolveDir:v,absWorkingDir:L,incremental:X,nodePaths:x,watch:D}}function bt(e,t,r,o){let u=[],l=Object.create(null);Me(u,t,l,r,o),Qe(u,t,l);let c=n(t,l,"sourcemap",He),s=n(t,l,"tsconfigRaw",gt),d=n(t,l,"sourcefile",y),v=n(t,l,"loader",y),D=n(t,l,"banner",y),C=n(t,l,"footer",y);return J(t,l,`in ${e}() call`),c&&u.push(`--sourcemap=${c===!0?"external":c}`),s&&u.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),d&&u.push(`--sourcefile=${d}`),v&&u.push(`--loader=${v}`),D&&u.push(`--banner=${D}`),C&&u.push(`--footer=${C}`),u}function Xe(e){let t=new Map,r=new Map,o=new Map,u=new Map,l=!1,c=0,s=0,d=new Uint8Array(16*1024),v=0,D=g=>{let f=v+g.length;if(f>d.length){let p=new Uint8Array(f*2);p.set(d),d=p}d.set(g,v),v+=g.length;let a=0;for(;a+4<=v;){let p=Ce(d,a);if(a+4+p>v)break;a+=4,ne(d.subarray(a,a+p)),a+=p}a>0&&(d.copyWithin(0,a,v),v-=a)},C=()=>{l=!0;for(let g of t.values())g("The service was stopped",null);t.clear();for(let g of u.values())g.onWait("The service was stopped");u.clear();for(let g of o.values())try{g(new Error("The service was stopped"),null)}catch(f){console.error(f)}o.clear()},P=(g,f,a)=>{if(l)return a("The service is no longer running",null);let p=c++;t.set(p,(j,N)=>{try{a(j,N)}finally{g&&g.unref()}}),g&&g.ref(),e.writeToStdin(Ne({id:p,isRequest:!0,value:f}))},S=(g,f)=>{if(l)throw new Error("The service is no longer running");e.writeToStdin(Ne({id:g,isRequest:!1,value:f}))},oe=(g,f)=>ce(this,null,function*(){try{switch(f.command){case"ping":{S(g,{});break}case"on-start":{let a=r.get(f.key);a?S(g,yield a(f)):S(g,{});break}case"on-resolve":{let a=r.get(f.key);a?S(g,yield a(f)):S(g,{});break}case"on-load":{let a=r.get(f.key);a?S(g,yield a(f)):S(g,{});break}case"serve-request":{let a=u.get(f.key);a&&a.onRequest&&a.onRequest(f.args),S(g,{});break}case"serve-wait":{let a=u.get(f.key);a&&a.onWait(f.error),S(g,{});break}case"watch-rebuild":{let a=o.get(f.key);try{a&&a(null,f.args)}catch(p){console.error(p)}S(g,{});break}default:throw new Error("Invalid command: "+f.command)}}catch(a){S(g,{errors:[be(a,e,null,void 0,"")]})}}),re=!0,ne=g=>{if(re){re=!1;let a=String.fromCharCode(...g);if(a!=="0.14.16")throw new Error(`Cannot start service: Host version "0.14.16" does not match binary version ${JSON.stringify(a)}`);return}let f=Ke(g);if(f.isRequest)oe(f.id,f.value);else{let a=t.get(f.id);t.delete(f.id),f.value.error?a(f.value.error,{}):a(null,f.value)}},le=(g,f,a,p,j)=>ce(this,null,function*(){let N=[],M=[],E={},A={},B=0,w=0,L=[],k=!1;f=[...f];for(let x of f){let b={};if(typeof x!="object")throw new Error(`Plugin at index ${w} must be an object`);let i=n(x,b,"name",y);if(typeof i!="string"||i==="")throw new Error(`Plugin at index ${w} is missing a name`);try{let R=n(x,b,"setup",Le);if(typeof R!="function")throw new Error("Plugin is missing a setup function");J(x,b,`on plugin ${JSON.stringify(i)}`);let q={name:i,onResolve:[],onLoad:[]};w++;let h=R({initialOptions:g,resolve:(m,F={})=>{if(!k)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof m!="string")throw new Error("The path to resolve must be a string");let $=Object.create(null),_=n(F,$,"pluginName",y),W=n(F,$,"importer",y),H=n(F,$,"namespace",y),Q=n(F,$,"resolveDir",y),T=n(F,$,"kind",y),V=n(F,$,"pluginData",$e);return J(F,$,"in resolve() call"),new Promise((z,Z)=>{let G={command:"resolve",path:m,key:a,pluginName:i};_!=null&&(G.pluginName=_),W!=null&&(G.importer=W),H!=null&&(G.namespace=H),Q!=null&&(G.resolveDir=Q),T!=null&&(G.kind=T),V!=null&&(G.pluginData=p.store(V)),P(j,G,(se,I)=>{se!==null?Z(new Error(se)):z({errors:pe(I.errors,p),warnings:pe(I.warnings,p),path:I.path,external:I.external,sideEffects:I.sideEffects,namespace:I.namespace,suffix:I.suffix,pluginData:p.load(I.pluginData)})})})},onStart(m){let F='This error came from the "onStart" callback registered here:',$=ke(new Error(F),e,"onStart");N.push({name:i,callback:m,note:$})},onEnd(m){let F='This error came from the "onEnd" callback registered here:',$=ke(new Error(F),e,"onEnd");M.push({name:i,callback:m,note:$})},onResolve(m,F){let $='This error came from the "onResolve" callback registered here:',_=ke(new Error($),e,"onResolve"),W={},H=n(m,W,"filter",Pe),Q=n(m,W,"namespace",y);if(J(m,W,`in onResolve() call for plugin ${JSON.stringify(i)}`),H==null)throw new Error("onResolve() call is missing a filter");let T=B++;E[T]={name:i,callback:F,note:_},q.onResolve.push({id:T,filter:H.source,namespace:Q||""})},onLoad(m,F){let $='This error came from the "onLoad" callback registered here:',_=ke(new Error($),e,"onLoad"),W={},H=n(m,W,"filter",Pe),Q=n(m,W,"namespace",y);if(J(m,W,`in onLoad() call for plugin ${JSON.stringify(i)}`),H==null)throw new Error("onLoad() call is missing a filter");let T=B++;A[T]={name:i,callback:F,note:_},q.onLoad.push({id:T,filter:H.source,namespace:Q||""})},esbuild:e.esbuild});h&&(yield h),L.push(q)}catch(R){return{ok:!1,error:R,pluginName:i}}}let O=x=>ce(this,null,function*(){switch(x.command){case"on-start":{let b={errors:[],warnings:[]};return yield Promise.all(N.map(Y=>ce(this,[Y],function*({name:i,callback:R,note:q}){try{let h=yield R();if(h!=null){if(typeof h!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(i)} to return an object`);let m={},F=n(h,m,"errors",K),$=n(h,m,"warnings",K);J(h,m,`from onStart() callback in plugin ${JSON.stringify(i)}`),F!=null&&b.errors.push(...ye(F,"errors",p,i)),$!=null&&b.warnings.push(...ye($,"warnings",p,i))}}catch(h){b.errors.push(be(h,e,p,q&&q(),i))}}))),b}case"on-resolve":{let b={},i="",R,q;for(let Y of x.ids)try{({name:i,callback:R,note:q}=E[Y]);let h=yield R({path:x.path,importer:x.importer,namespace:x.namespace,resolveDir:x.resolveDir,kind:x.kind,pluginData:p.load(x.pluginData)});if(h!=null){if(typeof h!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(i)} to return an object`);let m={},F=n(h,m,"pluginName",y),$=n(h,m,"path",y),_=n(h,m,"namespace",y),W=n(h,m,"suffix",y),H=n(h,m,"external",U),Q=n(h,m,"sideEffects",U),T=n(h,m,"pluginData",$e),V=n(h,m,"errors",K),z=n(h,m,"warnings",K),Z=n(h,m,"watchFiles",K),G=n(h,m,"watchDirs",K);J(h,m,`from onResolve() callback in plugin ${JSON.stringify(i)}`),b.id=Y,F!=null&&(b.pluginName=F),$!=null&&(b.path=$),_!=null&&(b.namespace=_),W!=null&&(b.suffix=W),H!=null&&(b.external=H),Q!=null&&(b.sideEffects=Q),T!=null&&(b.pluginData=p.store(T)),V!=null&&(b.errors=ye(V,"errors",p,i)),z!=null&&(b.warnings=ye(z,"warnings",p,i)),Z!=null&&(b.watchFiles=Ee(Z,"watchFiles")),G!=null&&(b.watchDirs=Ee(G,"watchDirs"));break}}catch(h){return{id:Y,errors:[be(h,e,p,q&&q(),i)]}}return b}case"on-load":{let b={},i="",R,q;for(let Y of x.ids)try{({name:i,callback:R,note:q}=A[Y]);let h=yield R({path:x.path,namespace:x.namespace,suffix:x.suffix,pluginData:p.load(x.pluginData)});if(h!=null){if(typeof h!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(i)} to return an object`);let m={},F=n(h,m,"pluginName",y),$=n(h,m,"contents",yt),_=n(h,m,"resolveDir",y),W=n(h,m,"pluginData",$e),H=n(h,m,"loader",y),Q=n(h,m,"errors",K),T=n(h,m,"warnings",K),V=n(h,m,"watchFiles",K),z=n(h,m,"watchDirs",K);J(h,m,`from onLoad() callback in plugin ${JSON.stringify(i)}`),b.id=Y,F!=null&&(b.pluginName=F),$ instanceof Uint8Array?b.contents=$:$!=null&&(b.contents=de($)),_!=null&&(b.resolveDir=_),W!=null&&(b.pluginData=p.store(W)),H!=null&&(b.loader=H),Q!=null&&(b.errors=ye(Q,"errors",p,i)),T!=null&&(b.warnings=ye(T,"warnings",p,i)),V!=null&&(b.watchFiles=Ee(V,"watchFiles")),z!=null&&(b.watchDirs=Ee(z,"watchDirs"));break}}catch(h){return{id:Y,errors:[be(h,e,p,q&&q(),i)]}}return b}default:throw new Error("Invalid command: "+x.command)}}),te=(x,b,i)=>i();M.length>0&&(te=(x,b,i)=>{(()=>ce(this,null,function*(){for(let{name:R,callback:q,note:Y}of M)try{yield q(x)}catch(h){x.errors.push(yield new Promise(m=>b(h,R,Y&&Y(),m)))}}))().then(i)}),k=!0;let X=0;return{ok:!0,requestPlugins:L,runOnEndCallbacks:te,pluginRefs:{ref(){++X===1&&r.set(a,O)},unref(){--X===0&&r.delete(a)}}}}),ae=(g,f,a,p)=>{let j={},N=n(f,j,"port",Re),M=n(f,j,"host",y),E=n(f,j,"servedir",y),A=n(f,j,"onRequest",Le),B,w=new Promise((L,k)=>{B=O=>{u.delete(p),O!==null?k(new Error(O)):L()}});return a.serve={},J(f,j,"in serve() call"),N!==void 0&&(a.serve.port=N),M!==void 0&&(a.serve.host=M),E!==void 0&&(a.serve.servedir=E),u.set(p,{onRequest:A,onWait:B}),{wait:w,stop(){P(g,{command:"serve-stop",key:p},()=>{})}}},ue="warning",fe="silent",ge=g=>{let f=s++,a=Je(),p,{refs:j,options:N,isTTY:M,callback:E}=g;if(typeof N=="object"){let w=N.plugins;if(w!==void 0){if(!Array.isArray(w))throw new Error('"plugins" must be an array');p=w}}let A=(w,L,k,O)=>{let te=[];try{Me(te,N,{},M,ue)}catch(x){}let X=be(w,e,a,k,L);P(j,{command:"error",flags:te,error:X},()=>{X.detail=a.load(X.detail),O(X)})},B=(w,L)=>{A(w,L,void 0,k=>{E(we("Build failed",[k],[]),null)})};if(p&&p.length>0){if(e.isSync)return B(new Error("Cannot use plugins in synchronous API calls"),"");le(N,p,f,a,j).then(w=>{if(!w.ok)B(w.error,w.pluginName);else try{ie(Ae(De({},g),{key:f,details:a,logPluginError:A,requestPlugins:w.requestPlugins,runOnEndCallbacks:w.runOnEndCallbacks,pluginRefs:w.pluginRefs}))}catch(L){B(L,"")}},w=>B(w,""))}else try{ie(Ae(De({},g),{key:f,details:a,logPluginError:A,requestPlugins:null,runOnEndCallbacks:(w,L,k)=>k(),pluginRefs:null}))}catch(w){B(w,"")}},ie=({callName:g,refs:f,serveOptions:a,options:p,isTTY:j,defaultWD:N,callback:M,key:E,details:A,logPluginError:B,requestPlugins:w,runOnEndCallbacks:L,pluginRefs:k})=>{let O={ref(){k&&k.ref(),f&&f.ref()},unref(){k&&k.unref(),f&&f.unref()}},te=!e.isBrowser,{entries:X,flags:x,write:b,stdinContents:i,stdinResolveDir:R,absWorkingDir:q,incremental:Y,nodePaths:h,watch:m}=ht(g,p,j,ue,te),F={command:"build",key:E,entries:X,flags:x,write:b,stdinContents:i,stdinResolveDir:R,absWorkingDir:q||N,incremental:Y,nodePaths:h};w&&(F.plugins=w);let $=a&&ae(O,a,F,E),_,W,H=(T,V)=>{T.outputFiles&&(V.outputFiles=T.outputFiles.map(wt)),T.metafile&&(V.metafile=JSON.parse(T.metafile)),T.writeToStdout!==void 0&&console.log(me(T.writeToStdout).replace(/\n$/,""))},Q=(T,V)=>{let z={errors:pe(T.errors,A),warnings:pe(T.warnings,A)};H(T,z),L(z,B,()=>{if(z.errors.length>0)return V(we("Build failed",z.errors,z.warnings),null);if(T.rebuild){if(!_){let Z=!1;_=()=>new Promise((G,se)=>{if(Z||l)throw new Error("Cannot rebuild");P(O,{command:"rebuild",key:E},(I,et)=>{if(I)return V(we("Build failed",[{pluginName:"",text:I,location:null,notes:[],detail:void 0}],[]),null);Q(et,(Te,tt)=>{Te?se(Te):G(tt)})})}),O.ref(),_.dispose=()=>{Z||(Z=!0,P(O,{command:"rebuild-dispose",key:E},()=>{}),O.unref())}}z.rebuild=_}if(T.watch){if(!W){let Z=!1;O.ref(),W=()=>{Z||(Z=!0,o.delete(E),P(O,{command:"watch-stop",key:E},()=>{}),O.unref())},m&&o.set(E,(G,se)=>{if(G){m.onRebuild&&m.onRebuild(G,null);return}let I={errors:pe(se.errors,A),warnings:pe(se.warnings,A)};H(se,I),L(I,B,()=>{if(I.errors.length>0){m.onRebuild&&m.onRebuild(we("Build failed",I.errors,I.warnings),null);return}se.rebuildID!==void 0&&(I.rebuild=_),I.stop=W,m.onRebuild&&m.onRebuild(null,I)})})}z.stop=W}V(null,z)})};if(b&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(Y&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(m&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');P(O,F,(T,V)=>{if(T)return M(new Error(T),null);if($){let z=V,Z=!1;O.ref();let G={port:z.port,host:z.host,wait:$.wait,stop(){Z||(Z=!0,$.stop(),O.unref())}};return O.ref(),$.wait.then(O.unref,O.unref),M(null,G)}return Q(V,M)})};return{readFromStdout:D,afterClose:C,service:{buildOrServe:ge,transform:({callName:g,refs:f,input:a,options:p,isTTY:j,fs:N,callback:M})=>{let E=Je(),A=B=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let w=bt(g,p,j,fe);P(f,{command:"transform",flags:w,inputFS:B!==null,input:B!==null?B:a},(k,O)=>{if(k)return M(new Error(k),null);let te=pe(O.errors,E),X=pe(O.warnings,E),x=1,b=()=>--x===0&&M(null,{warnings:X,code:O.code,map:O.map});if(te.length>0)return M(we("Transform failed",te,X),null);O.codeFS&&(x++,N.readFile(O.code,(i,R)=>{i!==null?M(i,null):(O.code=R,b())})),O.mapFS&&(x++,N.readFile(O.map,(i,R)=>{i!==null?M(i,null):(O.map=R,b())})),b()})}catch(w){let L=[];try{Me(L,p,{},j,fe)}catch(O){}let k=be(w,e,E,void 0,"");P(f,{command:"error",flags:L,error:k},()=>{k.detail=E.load(k.detail),M(we("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let B=A;A=()=>N.writeFile(a,B)}A(null)},formatMessages:({callName:g,refs:f,messages:a,options:p,callback:j})=>{let N=ye(a,"messages",null,"");if(!p)throw new Error(`Missing second argument in ${g}() call`);let M={},E=n(p,M,"kind",y),A=n(p,M,"color",U),B=n(p,M,"terminalWidth",Re);if(J(p,M,`in ${g}() call`),E===void 0)throw new Error(`Missing "kind" in ${g}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${g}() call`);let w={command:"format-msgs",messages:N,isWarning:E==="warning"};A!==void 0&&(w.color=A),B!==void 0&&(w.terminalWidth=B),P(f,w,(L,k)=>{if(L)return j(new Error(L),null);j(null,k.messages)})},analyzeMetafile:({callName:g,refs:f,metafile:a,options:p,callback:j})=>{p===void 0&&(p={});let N={},M=n(p,N,"color",U),E=n(p,N,"verbose",U);J(p,N,`in ${g}() call`);let A={command:"analyze-metafile",metafile:a};M!==void 0&&(A.color=M),E!==void 0&&(A.verbose=E),P(f,A,(B,w)=>{if(B)return j(new Error(B),null);j(null,w.result)})}}}}function Je(){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 ke(e,t,r){let o,u=!1;return()=>{if(u)return o;u=!0;try{let l=(e.stack+"").split(`
3
- `);l.splice(1,1);let c=Ze(t,l,r);if(c)return o={text:e.message,location:c},o}catch(l){}}}function be(e,t,r,o,u){let l="Internal error",c=null;try{l=(e&&e.message||e)+""}catch(s){}try{c=Ze(t,(e.stack+"").split(`
4
- `),"")}catch(s){}return{pluginName:u,text:l,location:c,notes:o?[o]:[],detail:r?r.store(e):-1}}function Ze(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let u=1;u<t.length;u++){let l=t[u];if(!!l.startsWith(o))for(l=l.slice(o.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 s;try{s=e.readFileSync(c[1],"utf8")}catch(C){break}let d=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",v=+c[3]-1,D=d.slice(v,v+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:de(d.slice(0,v)).length,length:de(d.slice(v,v+D)).length,lineText:d+`
2
+ var ke=Object.defineProperty,lt=Object.defineProperties,it=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertyNames,Ie=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var ze=(e,t,r)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,De=(e,t)=>{for(var r in t||(t={}))Ke.call(t,r)&&ze(e,r,t[r]);if(Ie)for(var r of Ie(t))at.call(t,r)&&ze(e,r,t[r]);return e},Ae=(e,t)=>lt(e,st(t)),ut=e=>ke(e,"__esModule",{value:!0});var ft=(e,t)=>{for(var r in t)ke(e,r,{get:t[r],enumerable:!0})},ct=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ot(t))!Ke.call(e,u)&&(r||u!=="default")&&ke(e,u,{get:()=>t[u],enumerable:!(i=it(t,u))||i.enumerable});return e};var dt=(e=>(t,r)=>e&&e.get(t)||(r=ct(ut({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var de=(e,t,r)=>new Promise((i,u)=>{var l=d=>{try{s(r.next(d))}catch(O){u(O)}},c=d=>{try{s(r.throw(d))}catch(O){u(O)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(l,c);s((r=r.apply(e,t)).next())});var We={};ft(We,{analyzeMetafile:()=>Mt,analyzeMetafileSync:()=>Bt,build:()=>xt,buildSync:()=>Ct,formatMessages:()=>$t,formatMessagesSync:()=>Tt,initialize:()=>Dt,serve:()=>kt,transform:()=>Et,transformSync:()=>Pt,version:()=>St});function Fe(e){let t=i=>{if(i===null)r.write8(0);else if(typeof i=="boolean")r.write8(1),r.write8(+i);else if(typeof i=="number")r.write8(2),r.write32(i|0);else if(typeof i=="string")r.write8(3),r.write(pe(i));else if(i instanceof Uint8Array)r.write8(4),r.write(i);else if(i instanceof Array){r.write8(5),r.write32(i.length);for(let u of i)t(u)}else{let u=Object.keys(i);r.write8(6),r.write32(u.length);for(let l of u)r.write(pe(l)),t(i[l])}},r=new je;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ne(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function _e(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return he(r.read());case 4:return r.read();case 5:{let c=r.read32(),s=[];for(let d=0;d<c;d++)s.push(t());return s}case 6:{let c=r.read32(),s={};for(let d=0;d<c;d++)s[he(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new je(e),i=r.read32(),u=(i&1)===0;i>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:u,value:l}}var je=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);Ne(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ne(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 Le(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),i=this._read(r.length);return r.set(this.buf.subarray(i,i+t)),r}},pe,he;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;pe=r=>e.encode(r),he=r=>t.decode(r)}else if(typeof Buffer!="undefined")pe=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},he=e=>{let{buffer:t,byteOffset:r,byteLength:i}=e;return Buffer.from(t,r,i).toString()};else throw new Error("No UTF-8 codec found");function Le(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ne(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function Ve(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Me=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",gt=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",y=e=>typeof e=="string"?null:"a string",Ce=e=>e instanceof RegExp?null:"a RegExp object",Oe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ue=e=>typeof e=="function"?null:"a function",_=e=>Array.isArray(e)?null:"an array",me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",mt=e=>typeof e=="object"&&e!==null?null:"an array or an object",Je=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ge=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",yt=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ht=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",bt=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,i){let u=e[r];if(t[r+""]=!0,u===void 0)return;let l=i(u);if(l!==null)throw new Error(`"${r}" must be ${l}`);return u}function J(e,t,r){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${r}: "${i}"`)}function Qe(e){let t=Object.create(null),r=n(e,t,"wasmURL",y),i=n(e,t,"worker",I);return J(e,t,"in startService() call"),{wasmURL:r,worker:i}}function Xe(e){let t;if(e!==void 0){t=Object.create(null);for(let r of Object.keys(e)){let i=e[r];if(typeof i=="string"||i===!1)t[r]=i;else throw new Error(`Expected ${JSON.stringify(r)} in mangle cache to map to either a string or false`)}}return t}function Pe(e,t,r,i,u){let l=n(t,r,"color",I),c=n(t,r,"logLevel",y),s=n(t,r,"logLimit",Oe);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${c||u}`),e.push(`--log-limit=${s||0}`)}function Ze(e,t,r){let i=n(t,r,"legalComments",y),u=n(t,r,"sourceRoot",y),l=n(t,r,"sourcesContent",I),c=n(t,r,"target",ht),s=n(t,r,"format",y),d=n(t,r,"globalName",y),O=n(t,r,"mangleProps",Ce),T=n(t,r,"reserveProps",Ce),L=n(t,r,"minify",I),x=n(t,r,"minifySyntax",I),S=n(t,r,"minifyWhitespace",I),ae=n(t,r,"minifyIdentifiers",I),re=n(t,r,"drop",_),le=n(t,r,"charset",y),ie=n(t,r,"treeShaking",I),ue=n(t,r,"ignoreAnnotations",I),fe=n(t,r,"jsx",y),ce=n(t,r,"jsxFactory",y),ye=n(t,r,"jsxFragment",y),se=n(t,r,"define",me),we=n(t,r,"pure",_),xe=n(t,r,"keepNames",I);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),c&&(Array.isArray(c)?e.push(`--target=${Array.from(c).map(Ve).join(",")}`):e.push(`--target=${Ve(c)}`)),s&&e.push(`--format=${s}`),d&&e.push(`--global-name=${d}`),L&&e.push("--minify"),x&&e.push("--minify-syntax"),S&&e.push("--minify-whitespace"),ae&&e.push("--minify-identifiers"),le&&e.push(`--charset=${le}`),ie!==void 0&&e.push(`--tree-shaking=${ie}`),ue&&e.push("--ignore-annotations"),re)for(let te of re)e.push(`--drop:${te}`);if(O&&e.push(`--mangle-props=${O.source}`),T&&e.push(`--reserve-props=${T.source}`),fe&&e.push(`--jsx=${fe}`),ce&&e.push(`--jsx-factory=${ce}`),ye&&e.push(`--jsx-fragment=${ye}`),se)for(let te in se){if(te.indexOf("=")>=0)throw new Error(`Invalid define: ${te}`);e.push(`--define:${te}=${se[te]}`)}if(we)for(let te of we)e.push(`--pure:${te}`);xe&&e.push("--keep-names")}function wt(e,t,r,i,u){var w;let l=[],c=[],s=Object.create(null),d=null,O=null,T=null;Pe(l,t,s,r,i),Ze(l,t,s);let L=n(t,s,"sourcemap",Ge),x=n(t,s,"bundle",I),S=n(t,s,"watch",gt),ae=n(t,s,"splitting",I),re=n(t,s,"preserveSymlinks",I),le=n(t,s,"metafile",I),ie=n(t,s,"outfile",y),ue=n(t,s,"outdir",y),fe=n(t,s,"outbase",y),ce=n(t,s,"platform",y),ye=n(t,s,"tsconfig",y),se=n(t,s,"resolveExtensions",_),we=n(t,s,"nodePaths",_),xe=n(t,s,"mainFields",_),te=n(t,s,"conditions",_),m=n(t,s,"external",_),f=n(t,s,"loader",me),a=n(t,s,"outExtension",me),p=n(t,s,"publicPath",y),F=n(t,s,"entryNames",y),D=n(t,s,"chunkNames",y),C=n(t,s,"assetNames",y),E=n(t,s,"inject",_),B=n(t,s,"banner",me),P=n(t,s,"footer",me),R=n(t,s,"entryPoints",mt),U=n(t,s,"absWorkingDir",y),k=n(t,s,"stdin",me),A=(w=n(t,s,"write",I))!=null?w:u,q=n(t,s,"allowOverwrite",I),ee=n(t,s,"incremental",I)===!0,$=n(t,s,"mangleCache",me);if(s.plugins=!0,J(t,s,`in ${e}() call`),L&&l.push(`--sourcemap${L===!0?"":`=${L}`}`),x&&l.push("--bundle"),q&&l.push("--allow-overwrite"),S)if(l.push("--watch"),typeof S=="boolean")T={};else{let o=Object.create(null),v=n(S,o,"onRebuild",Ue);J(S,o,`on "watch" in ${e}() call`),T={onRebuild:v}}if(ae&&l.push("--splitting"),re&&l.push("--preserve-symlinks"),le&&l.push("--metafile"),ie&&l.push(`--outfile=${ie}`),ue&&l.push(`--outdir=${ue}`),fe&&l.push(`--outbase=${fe}`),ce&&l.push(`--platform=${ce}`),ye&&l.push(`--tsconfig=${ye}`),se){let o=[];for(let v of se){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);o.push(v)}l.push(`--resolve-extensions=${o.join(",")}`)}if(p&&l.push(`--public-path=${p}`),F&&l.push(`--entry-names=${F}`),D&&l.push(`--chunk-names=${D}`),C&&l.push(`--asset-names=${C}`),xe){let o=[];for(let v of xe){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);o.push(v)}l.push(`--main-fields=${o.join(",")}`)}if(te){let o=[];for(let v of te){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);o.push(v)}l.push(`--conditions=${o.join(",")}`)}if(m)for(let o of m)l.push(`--external:${o}`);if(B)for(let o in B){if(o.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${o}`);l.push(`--banner:${o}=${B[o]}`)}if(P)for(let o in P){if(o.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${o}`);l.push(`--footer:${o}=${P[o]}`)}if(E)for(let o of E)l.push(`--inject:${o}`);if(f)for(let o in f){if(o.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${o}`);l.push(`--loader:${o}=${f[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)c.push(["",o+""]);else for(let[o,v]of Object.entries(R))c.push([o+"",v+""]);if(k){let o=Object.create(null),v=n(k,o,"contents",y),Y=n(k,o,"resolveDir",y),h=n(k,o,"sourcefile",y),g=n(k,o,"loader",y);J(k,o,'in "stdin" object'),h&&l.push(`--sourcefile=${h}`),g&&l.push(`--loader=${g}`),Y&&(O=Y+""),d=v?v+"":""}let b=[];if(we)for(let o of we)o+="",b.push(o);return{entries:c,flags:l,write:A,stdinContents:d,stdinResolveDir:O,absWorkingDir:U,incremental:ee,nodePaths:b,watch:T,mangleCache:Xe($)}}function vt(e,t,r,i){let u=[],l=Object.create(null);Pe(u,t,l,r,i),Ze(u,t,l);let c=n(t,l,"sourcemap",Ge),s=n(t,l,"tsconfigRaw",yt),d=n(t,l,"sourcefile",y),O=n(t,l,"loader",y),T=n(t,l,"banner",y),L=n(t,l,"footer",y),x=n(t,l,"mangleCache",me);return J(t,l,`in ${e}() call`),c&&u.push(`--sourcemap=${c===!0?"external":c}`),s&&u.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),d&&u.push(`--sourcefile=${d}`),O&&u.push(`--loader=${O}`),T&&u.push(`--banner=${T}`),L&&u.push(`--footer=${L}`),{flags:u,mangleCache:Xe(x)}}function et(e){let t=new Map,r=new Map,i=new Map,u=new Map,l=!1,c=0,s=0,d=new Uint8Array(16*1024),O=0,T=m=>{let f=O+m.length;if(f>d.length){let p=new Uint8Array(f*2);p.set(d),d=p}d.set(m,O),O+=m.length;let a=0;for(;a+4<=O;){let p=Le(d,a);if(a+4+p>O)break;a+=4,le(d.subarray(a,a+p)),a+=p}a>0&&(d.copyWithin(0,a,O),O-=a)},L=()=>{l=!0;for(let m of t.values())m("The service was stopped",null);t.clear();for(let m of u.values())m.onWait("The service was stopped");u.clear();for(let m of i.values())try{m(new Error("The service was stopped"),null)}catch(f){console.error(f)}i.clear()},x=(m,f,a)=>{if(l)return a("The service is no longer running",null);let p=c++;t.set(p,(F,D)=>{try{a(F,D)}finally{m&&m.unref()}}),m&&m.ref(),e.writeToStdin(Fe({id:p,isRequest:!0,value:f}))},S=(m,f)=>{if(l)throw new Error("The service is no longer running");e.writeToStdin(Fe({id:m,isRequest:!1,value:f}))},ae=(m,f)=>de(this,null,function*(){try{switch(f.command){case"ping":{S(m,{});break}case"on-start":{let a=r.get(f.key);a?S(m,yield a(f)):S(m,{});break}case"on-resolve":{let a=r.get(f.key);a?S(m,yield a(f)):S(m,{});break}case"on-load":{let a=r.get(f.key);a?S(m,yield a(f)):S(m,{});break}case"serve-request":{let a=u.get(f.key);a&&a.onRequest&&a.onRequest(f.args),S(m,{});break}case"serve-wait":{let a=u.get(f.key);a&&a.onWait(f.error),S(m,{});break}case"watch-rebuild":{let a=i.get(f.key);try{a&&a(null,f.args)}catch(p){console.error(p)}S(m,{});break}default:throw new Error("Invalid command: "+f.command)}}catch(a){S(m,{errors:[ve(a,e,null,void 0,"")]})}}),re=!0,le=m=>{if(re){re=!1;let a=String.fromCharCode(...m);if(a!=="0.14.20")throw new Error(`Cannot start service: Host version "0.14.20" does not match binary version ${JSON.stringify(a)}`);return}let f=_e(m);if(f.isRequest)ae(f.id,f.value);else{let a=t.get(f.id);t.delete(f.id),f.value.error?a(f.value.error,{}):a(null,f.value)}},ie=(m,f,a,p,F)=>de(this,null,function*(){let D=[],C=[],E={},B={},P=0,R=0,U=[],k=!1;f=[...f];for(let $ of f){let b={};if(typeof $!="object")throw new Error(`Plugin at index ${R} must be an object`);let w=n($,b,"name",y);if(typeof w!="string"||w==="")throw new Error(`Plugin at index ${R} is missing a name`);try{let o=n($,b,"setup",Ue);if(typeof o!="function")throw new Error("Plugin is missing a setup function");J($,b,`on plugin ${JSON.stringify(w)}`);let v={name:w,onResolve:[],onLoad:[]};R++;let h=o({initialOptions:m,resolve:(g,N={})=>{if(!k)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof g!="string")throw new Error("The path to resolve must be a string");let M=Object.create(null),H=n(N,M,"pluginName",y),W=n(N,M,"importer",y),K=n(N,M,"namespace",y),X=n(N,M,"resolveDir",y),G=n(N,M,"kind",y),j=n(N,M,"pluginData",Me);return J(N,M,"in resolve() call"),new Promise((V,Q)=>{let z={command:"resolve",path:g,key:a,pluginName:w};H!=null&&(z.pluginName=H),W!=null&&(z.importer=W),K!=null&&(z.namespace=K),X!=null&&(z.resolveDir=X),G!=null&&(z.kind=G),j!=null&&(z.pluginData=p.store(j)),x(F,z,(oe,Z)=>{oe!==null?Q(new Error(oe)):V({errors:ge(Z.errors,p),warnings:ge(Z.warnings,p),path:Z.path,external:Z.external,sideEffects:Z.sideEffects,namespace:Z.namespace,suffix:Z.suffix,pluginData:p.load(Z.pluginData)})})})},onStart(g){let N='This error came from the "onStart" callback registered here:',M=Ee(new Error(N),e,"onStart");D.push({name:w,callback:g,note:M})},onEnd(g){let N='This error came from the "onEnd" callback registered here:',M=Ee(new Error(N),e,"onEnd");C.push({name:w,callback:g,note:M})},onResolve(g,N){let M='This error came from the "onResolve" callback registered here:',H=Ee(new Error(M),e,"onResolve"),W={},K=n(g,W,"filter",Ce),X=n(g,W,"namespace",y);if(J(g,W,`in onResolve() call for plugin ${JSON.stringify(w)}`),K==null)throw new Error("onResolve() call is missing a filter");let G=P++;E[G]={name:w,callback:N,note:H},v.onResolve.push({id:G,filter:K.source,namespace:X||""})},onLoad(g,N){let M='This error came from the "onLoad" callback registered here:',H=Ee(new Error(M),e,"onLoad"),W={},K=n(g,W,"filter",Ce),X=n(g,W,"namespace",y);if(J(g,W,`in onLoad() call for plugin ${JSON.stringify(w)}`),K==null)throw new Error("onLoad() call is missing a filter");let G=P++;B[G]={name:w,callback:N,note:H},v.onLoad.push({id:G,filter:K.source,namespace:X||""})},esbuild:e.esbuild});h&&(yield h),U.push(v)}catch(o){return{ok:!1,error:o,pluginName:w}}}let A=$=>de(this,null,function*(){switch($.command){case"on-start":{let b={errors:[],warnings:[]};return yield Promise.all(D.map(Y=>de(this,[Y],function*({name:w,callback:o,note:v}){try{let h=yield o();if(h!=null){if(typeof h!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(w)} to return an object`);let g={},N=n(h,g,"errors",_),M=n(h,g,"warnings",_);J(h,g,`from onStart() callback in plugin ${JSON.stringify(w)}`),N!=null&&b.errors.push(...be(N,"errors",p,w)),M!=null&&b.warnings.push(...be(M,"warnings",p,w))}}catch(h){b.errors.push(ve(h,e,p,v&&v(),w))}}))),b}case"on-resolve":{let b={},w="",o,v;for(let Y of $.ids)try{({name:w,callback:o,note:v}=E[Y]);let h=yield o({path:$.path,importer:$.importer,namespace:$.namespace,resolveDir:$.resolveDir,kind:$.kind,pluginData:p.load($.pluginData)});if(h!=null){if(typeof h!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(w)} to return an object`);let g={},N=n(h,g,"pluginName",y),M=n(h,g,"path",y),H=n(h,g,"namespace",y),W=n(h,g,"suffix",y),K=n(h,g,"external",I),X=n(h,g,"sideEffects",I),G=n(h,g,"pluginData",Me),j=n(h,g,"errors",_),V=n(h,g,"warnings",_),Q=n(h,g,"watchFiles",_),z=n(h,g,"watchDirs",_);J(h,g,`from onResolve() callback in plugin ${JSON.stringify(w)}`),b.id=Y,N!=null&&(b.pluginName=N),M!=null&&(b.path=M),H!=null&&(b.namespace=H),W!=null&&(b.suffix=W),K!=null&&(b.external=K),X!=null&&(b.sideEffects=X),G!=null&&(b.pluginData=p.store(G)),j!=null&&(b.errors=be(j,"errors",p,w)),V!=null&&(b.warnings=be(V,"warnings",p,w)),Q!=null&&(b.watchFiles=$e(Q,"watchFiles")),z!=null&&(b.watchDirs=$e(z,"watchDirs"));break}}catch(h){return{id:Y,errors:[ve(h,e,p,v&&v(),w)]}}return b}case"on-load":{let b={},w="",o,v;for(let Y of $.ids)try{({name:w,callback:o,note:v}=B[Y]);let h=yield o({path:$.path,namespace:$.namespace,suffix:$.suffix,pluginData:p.load($.pluginData)});if(h!=null){if(typeof h!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(w)} to return an object`);let g={},N=n(h,g,"pluginName",y),M=n(h,g,"contents",bt),H=n(h,g,"resolveDir",y),W=n(h,g,"pluginData",Me),K=n(h,g,"loader",y),X=n(h,g,"errors",_),G=n(h,g,"warnings",_),j=n(h,g,"watchFiles",_),V=n(h,g,"watchDirs",_);J(h,g,`from onLoad() callback in plugin ${JSON.stringify(w)}`),b.id=Y,N!=null&&(b.pluginName=N),M instanceof Uint8Array?b.contents=M:M!=null&&(b.contents=pe(M)),H!=null&&(b.resolveDir=H),W!=null&&(b.pluginData=p.store(W)),K!=null&&(b.loader=K),X!=null&&(b.errors=be(X,"errors",p,w)),G!=null&&(b.warnings=be(G,"warnings",p,w)),j!=null&&(b.watchFiles=$e(j,"watchFiles")),V!=null&&(b.watchDirs=$e(V,"watchDirs"));break}}catch(h){return{id:Y,errors:[ve(h,e,p,v&&v(),w)]}}return b}default:throw new Error("Invalid command: "+$.command)}}),q=($,b,w)=>w();C.length>0&&(q=($,b,w)=>{(()=>de(this,null,function*(){for(let{name:o,callback:v,note:Y}of C)try{yield v($)}catch(h){$.errors.push(yield new Promise(g=>b(h,o,Y&&Y(),g)))}}))().then(w)}),k=!0;let ee=0;return{ok:!0,requestPlugins:U,runOnEndCallbacks:q,pluginRefs:{ref(){++ee===1&&r.set(a,A)},unref(){--ee===0&&r.delete(a)}}}}),ue=(m,f,a,p)=>{let F={},D=n(f,F,"port",Oe),C=n(f,F,"host",y),E=n(f,F,"servedir",y),B=n(f,F,"onRequest",Ue),P,R=new Promise((U,k)=>{P=A=>{u.delete(p),A!==null?k(new Error(A)):U()}});return a.serve={},J(f,F,"in serve() call"),D!==void 0&&(a.serve.port=D),C!==void 0&&(a.serve.host=C),E!==void 0&&(a.serve.servedir=E),u.set(p,{onRequest:B,onWait:P}),{wait:R,stop(){x(m,{command:"serve-stop",key:p},()=>{})}}},fe="warning",ce="silent",ye=m=>{let f=s++,a=Ye(),p,{refs:F,options:D,isTTY:C,callback:E}=m;if(typeof D=="object"){let R=D.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');p=R}}let B=(R,U,k,A)=>{let q=[];try{Pe(q,D,{},C,fe)}catch($){}let ee=ve(R,e,a,k,U);x(F,{command:"error",flags:q,error:ee},()=>{ee.detail=a.load(ee.detail),A(ee)})},P=(R,U)=>{B(R,U,void 0,k=>{E(Re("Build failed",[k],[]),null)})};if(p&&p.length>0){if(e.isSync)return P(new Error("Cannot use plugins in synchronous API calls"),"");ie(D,p,f,a,F).then(R=>{if(!R.ok)P(R.error,R.pluginName);else try{se(Ae(De({},m),{key:f,details:a,logPluginError:B,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(U){P(U,"")}},R=>P(R,""))}else try{se(Ae(De({},m),{key:f,details:a,logPluginError:B,requestPlugins:null,runOnEndCallbacks:(R,U,k)=>k(),pluginRefs:null}))}catch(R){P(R,"")}},se=({callName:m,refs:f,serveOptions:a,options:p,isTTY:F,defaultWD:D,callback:C,key:E,details:B,logPluginError:P,requestPlugins:R,runOnEndCallbacks:U,pluginRefs:k})=>{let A={ref(){k&&k.ref(),f&&f.ref()},unref(){k&&k.unref(),f&&f.unref()}},q=!e.isBrowser,{entries:ee,flags:$,write:b,stdinContents:w,stdinResolveDir:o,absWorkingDir:v,incremental:Y,nodePaths:h,watch:g,mangleCache:N}=wt(m,p,F,fe,q),M={command:"build",key:E,entries:ee,flags:$,write:b,stdinContents:w,stdinResolveDir:o,absWorkingDir:v||D,incremental:Y,nodePaths:h};R&&(M.plugins=R),N&&(M.mangleCache=N);let H=a&&ue(A,a,M,E),W,K,X=(j,V)=>{j.outputFiles&&(V.outputFiles=j.outputFiles.map(Rt)),j.metafile&&(V.metafile=JSON.parse(j.metafile)),j.mangleCache&&(V.mangleCache=j.mangleCache),j.writeToStdout!==void 0&&console.log(he(j.writeToStdout).replace(/\n$/,""))},G=(j,V)=>{let Q={errors:ge(j.errors,B),warnings:ge(j.warnings,B)};X(j,Q),U(Q,P,()=>{if(Q.errors.length>0)return V(Re("Build failed",Q.errors,Q.warnings),null);if(j.rebuild){if(!W){let z=!1;W=()=>new Promise((oe,Z)=>{if(z||l)throw new Error("Cannot rebuild");x(A,{command:"rebuild",key:E},(ne,rt)=>{if(ne)return V(Re("Build failed",[{pluginName:"",text:ne,location:null,notes:[],detail:void 0}],[]),null);G(rt,(Be,nt)=>{Be?Z(Be):oe(nt)})})}),A.ref(),W.dispose=()=>{z||(z=!0,x(A,{command:"rebuild-dispose",key:E},()=>{}),A.unref())}}Q.rebuild=W}if(j.watch){if(!K){let z=!1;A.ref(),K=()=>{z||(z=!0,i.delete(E),x(A,{command:"watch-stop",key:E},()=>{}),A.unref())},g&&i.set(E,(oe,Z)=>{if(oe){g.onRebuild&&g.onRebuild(oe,null);return}let ne={errors:ge(Z.errors,B),warnings:ge(Z.warnings,B)};X(Z,ne),U(ne,P,()=>{if(ne.errors.length>0){g.onRebuild&&g.onRebuild(Re("Build failed",ne.errors,ne.warnings),null);return}Z.rebuildID!==void 0&&(ne.rebuild=W),ne.stop=K,g.onRebuild&&g.onRebuild(null,ne)})})}Q.stop=K}V(null,Q)})};if(b&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(Y&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(g&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');x(A,M,(j,V)=>{if(j)return C(new Error(j),null);if(H){let Q=V,z=!1;A.ref();let oe={port:Q.port,host:Q.host,wait:H.wait,stop(){z||(z=!0,H.stop(),A.unref())}};return A.ref(),H.wait.then(A.unref,A.unref),C(null,oe)}return G(V,C)})};return{readFromStdout:T,afterClose:L,service:{buildOrServe:ye,transform:({callName:m,refs:f,input:a,options:p,isTTY:F,fs:D,callback:C})=>{let E=Ye(),B=P=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let{flags:R,mangleCache:U}=vt(m,p,F,ce),k={command:"transform",flags:R,inputFS:P!==null,input:P!==null?P:a};U&&(k.mangleCache=U),x(f,k,(A,q)=>{if(A)return C(new Error(A),null);let ee=ge(q.errors,E),$=ge(q.warnings,E),b=1,w=()=>{if(--b===0){let o={warnings:$,code:q.code,map:q.map};q.mangleCache&&(o.mangleCache=q==null?void 0:q.mangleCache),C(null,o)}};if(ee.length>0)return C(Re("Transform failed",ee,$),null);q.codeFS&&(b++,D.readFile(q.code,(o,v)=>{o!==null?C(o,null):(q.code=v,w())})),q.mapFS&&(b++,D.readFile(q.map,(o,v)=>{o!==null?C(o,null):(q.map=v,w())})),w()})}catch(R){let U=[];try{Pe(U,p,{},F,ce)}catch(A){}let k=ve(R,e,E,void 0,"");x(f,{command:"error",flags:U,error:k},()=>{k.detail=E.load(k.detail),C(Re("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let P=B;B=()=>D.writeFile(a,P)}B(null)},formatMessages:({callName:m,refs:f,messages:a,options:p,callback:F})=>{let D=be(a,"messages",null,"");if(!p)throw new Error(`Missing second argument in ${m}() call`);let C={},E=n(p,C,"kind",y),B=n(p,C,"color",I),P=n(p,C,"terminalWidth",Oe);if(J(p,C,`in ${m}() call`),E===void 0)throw new Error(`Missing "kind" in ${m}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${m}() call`);let R={command:"format-msgs",messages:D,isWarning:E==="warning"};B!==void 0&&(R.color=B),P!==void 0&&(R.terminalWidth=P),x(f,R,(U,k)=>{if(U)return F(new Error(U),null);F(null,k.messages)})},analyzeMetafile:({callName:m,refs:f,metafile:a,options:p,callback:F})=>{p===void 0&&(p={});let D={},C=n(p,D,"color",I),E=n(p,D,"verbose",I);J(p,D,`in ${m}() call`);let B={command:"analyze-metafile",metafile:a};C!==void 0&&(B.color=C),E!==void 0&&(B.verbose=E),x(f,B,(P,R)=>{if(P)return F(new Error(P),null);F(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 i=t++;return e.set(i,r),i}}}function Ee(e,t,r){let i,u=!1;return()=>{if(u)return i;u=!0;try{let l=(e.stack+"").split(`
3
+ `);l.splice(1,1);let c=tt(t,l,r);if(c)return i={text:e.message,location:c},i}catch(l){}}}function ve(e,t,r,i,u){let l="Internal error",c=null;try{l=(e&&e.message||e)+""}catch(s){}try{c=tt(t,(e.stack+"").split(`
4
+ `),"")}catch(s){}return{pluginName:u,text:l,location:c,notes:i?[i]:[],detail:r?r.store(e):-1}}function tt(e,t,r){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let u=1;u<t.length;u++){let l=t[u];if(!!l.startsWith(i))for(l=l.slice(i.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 s;try{s=e.readFileSync(c[1],"utf8")}catch(L){break}let d=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",O=+c[3]-1,T=d.slice(O,O+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:pe(d.slice(0,O)).length,length:pe(d.slice(O,O+T)).length,lineText:d+`
5
5
  `+t.slice(1).join(`
6
- `),suggestion:""}}break}}return null}function we(e,t,r){let o=5,u=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,o+1).map((c,s)=>{if(s===o)return`
6
+ `),suggestion:""}}break}}return null}function Re(e,t,r){let i=5,u=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,i+1).map((c,s)=>{if(s===i)return`
7
7
  ...`;if(!c.location)return`
8
- error: ${c.text}`;let{file:d,line:v,column:D}=c.location,C=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
9
- ${d}:${v}:${D}: ERROR: ${C}${c.text}`}).join(""),l=new Error(`${e}${u}`);return l.errors=t,l.warnings=r,l}function pe(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Ye(e,t){if(e==null)return null;let r={},o=n(e,r,"file",y),u=n(e,r,"namespace",y),l=n(e,r,"line",Re),c=n(e,r,"column",Re),s=n(e,r,"length",Re),d=n(e,r,"lineText",y),v=n(e,r,"suggestion",y);return J(e,r,t),{file:o||"",namespace:u||"",line:l||0,column:c||0,length:s||0,lineText:d||"",suggestion:v||""}}function ye(e,t,r,o){let u=[],l=0;for(let c of e){let s={},d=n(c,s,"pluginName",y),v=n(c,s,"text",y),D=n(c,s,"location",Ve),C=n(c,s,"notes",K),P=n(c,s,"detail",$e),S=`in element ${l} of "${t}"`;J(c,s,S);let oe=[];if(C)for(let re of C){let ne={},le=n(re,ne,"text",y),ae=n(re,ne,"location",Ve);J(re,ne,S),oe.push({text:le||"",location:Ye(ae,S)})}u.push({pluginName:d||o,text:v||"",location:Ye(D,S),notes:oe,detail:r?r.store(P):-1}),l++}return u}function Ee(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 wt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=me(t)),r}}}var Rt="0.14.16",Ot=e=>Be().build(e),St=()=>{throw new Error('The "serve" API only works in node')},xt=(e,t)=>Be().transform(e,t),kt=(e,t)=>Be().formatMessages(e,t),Et=(e,t)=>Be().analyzeMetafile(e,t),$t=()=>{throw new Error('The "buildSync" API only works in node')},Pt=()=>{throw new Error('The "transformSync" API only works in node')},Mt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Bt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},Oe,Ue,Be=()=>{if(Ue)return Ue;throw Oe?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')},Tt=e=>{e=Ge(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",Oe)throw new Error('Cannot call "initialize" more than once');return Oe=Dt(t,r),Oe.catch(()=>{Oe=void 0}),Oe},Dt=(e,t)=>ce(void 0,null,function*(){let r=yield fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let o=yield r.arrayBuffer(),u='{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=(a,g,f)=>new Promise((r,n)=>{var s=h=>{try{l(f.next(h))}catch(u){n(u)}},i=h=>{try{l(f.throw(h))}catch(u){n(u)}},l=h=>h.done?r(h.value):Promise.resolve(h.value).then(s,i);l((f=f.apply(a,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(n,s,i,l,h,u){if(i===0&&l===s.length&&h===null){if(n===process.stdout.fd){try{process.stdout.write(s,m=>m?u(m,0,null):u(null,l,s))}catch(m){u(m,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,m=>m?u(m,0,null):u(null,l,s))}catch(m){u(m,0,null)}return}}r.write(n,s,i,l,h,u)}}))}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(n,s){r+=f.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,l,h,u){if(i!==0||l!==s.length||h!==null){u(a());return}const m=this.writeSync(n,s);u(null,m)},chmod(n,s,i){i(a())},chown(n,s,i,l){l(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,l){l(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,l){l(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,l){l(a())},read(n,s,i,l,h,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,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(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/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"),f=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)},n=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]},i=(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 d=0;switch(typeof t){case"object":t!==null&&(d=1);break;case"string":d=2;break;case"symbol":d=3;break;case"function":d=4;break}this.mem.setUint32(e+4,o|d,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=n(e+0),o=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},h=e=>{const t=n(e+0),o=n(e+8),c=new Array(o);for(let d=0;d<o;d++)c[d]=s(t+d*8);return c},u=e=>{const t=n(e+0),o=n(e+8);return f.decode(new DataView(this._inst.exports.mem.buffer,t,o))},m=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=n(e+8),o=n(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,(m+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()},n(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,i(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,i(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,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,u(e+16)),c=h(e+32),d=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,d),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=h(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=h(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(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)));i(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)}}}}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 n=4096;const s=e=>{const t=n,o=g.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!==0&&(n+=8-n%8),t},i=this.argv.length,l=[];this.argv.forEach(e=>{l.push(s(e))}),l.push(0),Object.keys(this.env).sort().forEach(e=>{l.push(s(`${e}=${this.env[e]}`))}),l.push(0);const u=n;l.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const m=4096+8192;if(n>=m)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,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 n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._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(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),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.14.16"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let d=new Blob([u],{type:"text/javascript"});l=new Worker(URL.createObjectURL(d))}else{let v=new Function("postMessage",u+"var onmessage; return m => onmessage(m)")(D=>l.onmessage({data:D}));l={onmessage:null,postMessage:D=>v({data:D}),terminate(){}}}l.postMessage(o),l.onmessage=({data:d})=>c(d);let{readFromStdout:c,service:s}=Xe({writeToStdin(d){l.postMessage(d)},isSync:!1,isBrowser:!0,esbuild:qe});Ue={build:d=>new Promise((v,D)=>s.buildOrServe({callName:"build",refs:null,serveOptions:null,options:d,isTTY:!1,defaultWD:"/",callback:(C,P)=>C?D(C):v(P)})),transform:(d,v)=>new Promise((D,C)=>s.transform({callName:"transform",refs:null,input:d,options:v||{},isTTY:!1,fs:{readFile(P,S){S(new Error("Internal error"),null)},writeFile(P,S){S(null)}},callback:(P,S)=>P?C(P):D(S)})),formatMessages:(d,v)=>new Promise((D,C)=>s.formatMessages({callName:"formatMessages",refs:null,messages:d,options:v,callback:(P,S)=>P?C(P):D(S)})),analyzeMetafile:(d,v)=>new Promise((D,C)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof d=="string"?d:JSON.stringify(d),options:v,callback:(P,S)=>P?C(P):D(S)}))}});module.exports=ft(qe);
8
+ error: ${c.text}`;let{file:d,line:O,column:T}=c.location,L=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
9
+ ${d}:${O}:${T}: ERROR: ${L}${c.text}`}).join(""),l=new Error(`${e}${u}`);return l.errors=t,l.warnings=r,l}function ge(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={},i=n(e,r,"file",y),u=n(e,r,"namespace",y),l=n(e,r,"line",Oe),c=n(e,r,"column",Oe),s=n(e,r,"length",Oe),d=n(e,r,"lineText",y),O=n(e,r,"suggestion",y);return J(e,r,t),{file:i||"",namespace:u||"",line:l||0,column:c||0,length:s||0,lineText:d||"",suggestion:O||""}}function be(e,t,r,i){let u=[],l=0;for(let c of e){let s={},d=n(c,s,"pluginName",y),O=n(c,s,"text",y),T=n(c,s,"location",Je),L=n(c,s,"notes",_),x=n(c,s,"detail",Me),S=`in element ${l} of "${t}"`;J(c,s,S);let ae=[];if(L)for(let re of L){let le={},ie=n(re,le,"text",y),ue=n(re,le,"location",Je);J(re,le,S),ae.push({text:ie||"",location:He(ue,S)})}u.push({pluginName:d||i,text:O||"",location:He(T,S),notes:ae,detail:r?r.store(x):-1}),l++}return u}function $e(e,t){let r=[];for(let i of e){if(typeof i!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(i)}return r}function Rt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=he(t)),r}}}var St="0.14.20",xt=e=>Te().build(e),kt=()=>{throw new Error('The "serve" API only works in node')},Et=(e,t)=>Te().transform(e,t),$t=(e,t)=>Te().formatMessages(e,t),Mt=(e,t)=>Te().analyzeMetafile(e,t),Ct=()=>{throw new Error('The "buildSync" API only works in node')},Pt=()=>{throw new Error('The "transformSync" API only works in node')},Tt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Bt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},Se,qe,Te=()=>{if(qe)return qe;throw Se?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')},Dt=e=>{e=Qe(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",Se)throw new Error('Cannot call "initialize" more than once');return Se=At(t,r),Se.catch(()=>{Se=void 0}),Se},At=(e,t)=>de(void 0,null,function*(){let r=yield fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let i=yield r.arrayBuffer(),u='{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=(a,g,f)=>new Promise((r,n)=>{var s=h=>{try{o(f.next(h))}catch(u){n(u)}},i=h=>{try{o(f.throw(h))}catch(u){n(u)}},o=h=>h.done?r(h.value):Promise.resolve(h.value).then(s,i);o((f=f.apply(a,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(n,s,i,o,h,u){if(i===0&&o===s.length&&h===null){if(n===process.stdout.fd){try{process.stdout.write(s,m=>m?u(m,0,null):u(null,o,s))}catch(m){u(m,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,m=>m?u(m,0,null):u(null,o,s))}catch(m){u(m,0,null)}return}}r.write(n,s,i,o,h,u)}}))}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(n,s){r+=f.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,o,h,u){if(i!==0||o!==s.length||h!==null){u(a());return}const m=this.writeSync(n,s);u(null,m)},chmod(n,s,i){i(a())},chown(n,s,i,o){o(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,o){o(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,o){o(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,o){o(a())},read(n,s,i,o,h,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,o){o(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(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/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"),f=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)},n=e=>{const t=this.mem.getUint32(e+0,!0),l=this.mem.getInt32(e+4,!0);return t+l*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const l=this.mem.getUint32(e,!0);return this._values[l]},i=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!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 d=0;switch(typeof t){case"object":t!==null&&(d=1);break;case"string":d=2;break;case"symbol":d=3;break;case"function":d=4;break}this.mem.setUint32(e+4,2146959360|d,!0),this.mem.setUint32(e,c,!0)},o=e=>{const t=n(e+0),l=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,l)},h=e=>{const t=n(e+0),l=n(e+8),c=new Array(l);for(let d=0;d<l;d++)c[d]=s(t+d*8);return c},u=e=>{const t=n(e+0),l=n(e+8);return f.decode(new DataView(this._inst.exports.mem.buffer,t,l))},m=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=n(e+8),l=n(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,l,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(m+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()},n(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 l=this._values[t];this._values[t]=null,this._ids.delete(l),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,i(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,i(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,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),l=Reflect.get(t,u(e+16)),c=h(e+32),d=Reflect.apply(l,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,d),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),l=h(e+16),c=Reflect.apply(t,void 0,l);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),l=h(e+16),c=Reflect.construct(t,l);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(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)));i(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),l=s(e+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=l.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),l=o(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=l.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 n=4096;const s=e=>{const t=n,l=g.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,l.length).set(l),n+=l.length,n%8!==0&&(n+=8-n%8),t},i=this.argv.length,o=[];this.argv.forEach(e=>{o.push(s(e))}),o.push(0),Object.keys(this.env).sort().forEach(e=>{o.push(s(`${e}=${this.env[e]}`))}),o.push(0);const u=n;o.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const m=4096+8192;if(n>=m)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,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 n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._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(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),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.14.20"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let d=new Blob([u],{type:"text/javascript"});l=new Worker(URL.createObjectURL(d))}else{let O=new Function("postMessage",u+"var onmessage; return m => onmessage(m)")(T=>l.onmessage({data:T}));l={onmessage:null,postMessage:T=>O({data:T}),terminate(){}}}l.postMessage(i),l.onmessage=({data:d})=>c(d);let{readFromStdout:c,service:s}=et({writeToStdin(d){l.postMessage(d)},isSync:!1,isBrowser:!0,esbuild:We});qe={build:d=>new Promise((O,T)=>s.buildOrServe({callName:"build",refs:null,serveOptions:null,options:d,isTTY:!1,defaultWD:"/",callback:(L,x)=>L?T(L):O(x)})),transform:(d,O)=>new Promise((T,L)=>s.transform({callName:"transform",refs:null,input:d,options:O||{},isTTY:!1,fs:{readFile(x,S){S(new Error("Internal error"),null)},writeFile(x,S){S(null)}},callback:(x,S)=>x?L(x):T(S)})),formatMessages:(d,O)=>new Promise((T,L)=>s.formatMessages({callName:"formatMessages",refs:null,messages:d,options:O,callback:(x,S)=>x?L(x):T(S)})),analyzeMetafile:(d,O)=>new Promise((T,L)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof d=="string"?d:JSON.stringify(d),options:O,callback:(x,S)=>x?L(x):T(S)}))}});module.exports=dt(We);
10
10
  })(typeof module==="object"?module:{set exports(x){(typeof self!=="undefined"?self:this).esbuild=x}});
@@ -26,6 +26,8 @@ interface CommonOptions {
26
26
  mangleProps?: RegExp;
27
27
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
28
  reserveProps?: RegExp;
29
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleCache?: Record<string, string | false>;
29
31
  /** Documentation: https://esbuild.github.io/api/#drop */
30
32
  drop?: Drop[];
31
33
  /** Documentation: https://esbuild.github.io/api/#minify */
@@ -200,6 +202,8 @@ export interface BuildResult {
200
202
  stop?: () => void;
201
203
  /** Only when "metafile: true" */
202
204
  metafile?: Metafile;
205
+ /** Only when "mangleCache" is present */
206
+ mangleCache?: Record<string, string | false>;
203
207
  }
204
208
 
205
209
  export interface BuildFailure extends Error {
@@ -253,6 +257,8 @@ export interface TransformResult {
253
257
  code: string;
254
258
  map: string;
255
259
  warnings: Message[];
260
+ /** Only when "mangleCache" is present */
261
+ mangleCache?: Record<string, string | false>;
256
262
  }
257
263
 
258
264
  export interface TransformFailure extends Error {
@@ -272,6 +272,21 @@ function validateInitializeOptions(options) {
272
272
  worker
273
273
  };
274
274
  }
275
+ function validateMangleCache(mangleCache) {
276
+ let validated;
277
+ if (mangleCache !== void 0) {
278
+ validated = /* @__PURE__ */ Object.create(null);
279
+ for (let key of Object.keys(mangleCache)) {
280
+ let value = mangleCache[key];
281
+ if (typeof value === "string" || value === false) {
282
+ validated[key] = value;
283
+ } else {
284
+ throw new Error(`Expected ${JSON.stringify(key)} in mangle cache to map to either a string or false`);
285
+ }
286
+ }
287
+ }
288
+ return validated;
289
+ }
275
290
  function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
276
291
  let color = getFlag(options, keys, "color", mustBeBoolean);
277
292
  let logLevel = getFlag(options, keys, "logLevel", mustBeString);
@@ -403,6 +418,7 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
403
418
  let write = (_a2 = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a2 : writeDefault;
404
419
  let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
405
420
  let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
421
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
406
422
  keys.plugins = true;
407
423
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
408
424
  if (sourcemap)
@@ -552,7 +568,8 @@ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeD
552
568
  absWorkingDir,
553
569
  incremental,
554
570
  nodePaths,
555
- watch: watchMode
571
+ watch: watchMode,
572
+ mangleCache: validateMangleCache(mangleCache)
556
573
  };
557
574
  }
558
575
  function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
@@ -566,6 +583,7 @@ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
566
583
  let loader = getFlag(options, keys, "loader", mustBeString);
567
584
  let banner = getFlag(options, keys, "banner", mustBeString);
568
585
  let footer = getFlag(options, keys, "footer", mustBeString);
586
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
569
587
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
570
588
  if (sourcemap)
571
589
  flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
@@ -579,7 +597,10 @@ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
579
597
  flags.push(`--banner=${banner}`);
580
598
  if (footer)
581
599
  flags.push(`--footer=${footer}`);
582
- return flags;
600
+ return {
601
+ flags,
602
+ mangleCache: validateMangleCache(mangleCache)
603
+ };
583
604
  }
584
605
  function createChannel(streamIn) {
585
606
  let responseCallbacks = /* @__PURE__ */ new Map();
@@ -723,8 +744,8 @@ function createChannel(streamIn) {
723
744
  if (isFirstPacket) {
724
745
  isFirstPacket = false;
725
746
  let binaryVersion = String.fromCharCode(...bytes);
726
- if (binaryVersion !== "0.14.16") {
727
- throw new Error(`Cannot start service: Host version "${"0.14.16"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
747
+ if (binaryVersion !== "0.14.20") {
748
+ throw new Error(`Cannot start service: Host version "${"0.14.20"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
728
749
  }
729
750
  return;
730
751
  }
@@ -1183,7 +1204,8 @@ function createChannel(streamIn) {
1183
1204
  absWorkingDir,
1184
1205
  incremental,
1185
1206
  nodePaths,
1186
- watch
1207
+ watch,
1208
+ mangleCache
1187
1209
  } = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
1188
1210
  let request = {
1189
1211
  command: "build",
@@ -1199,6 +1221,8 @@ function createChannel(streamIn) {
1199
1221
  };
1200
1222
  if (requestPlugins)
1201
1223
  request.plugins = requestPlugins;
1224
+ if (mangleCache)
1225
+ request.mangleCache = mangleCache;
1202
1226
  let serve2 = serveOptions && buildServeData(refs, serveOptions, request, key);
1203
1227
  let rebuild;
1204
1228
  let stop;
@@ -1207,6 +1231,8 @@ function createChannel(streamIn) {
1207
1231
  result.outputFiles = response.outputFiles.map(convertOutputFiles);
1208
1232
  if (response.metafile)
1209
1233
  result.metafile = JSON.parse(response.metafile);
1234
+ if (response.mangleCache)
1235
+ result.mangleCache = response.mangleCache;
1210
1236
  if (response.writeToStdout !== void 0)
1211
1237
  console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1212
1238
  };
@@ -1334,20 +1360,32 @@ function createChannel(streamIn) {
1334
1360
  try {
1335
1361
  if (typeof input !== "string")
1336
1362
  throw new Error('The input to "transform" must be a string');
1337
- let flags = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
1363
+ let {
1364
+ flags,
1365
+ mangleCache
1366
+ } = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
1338
1367
  let request = {
1339
1368
  command: "transform",
1340
1369
  flags,
1341
1370
  inputFS: inputPath !== null,
1342
1371
  input: inputPath !== null ? inputPath : input
1343
1372
  };
1373
+ if (mangleCache)
1374
+ request.mangleCache = mangleCache;
1344
1375
  sendRequest(refs, request, (error, response) => {
1345
1376
  if (error)
1346
1377
  return callback(new Error(error), null);
1347
1378
  let errors = replaceDetailsInMessages(response.errors, details);
1348
1379
  let warnings = replaceDetailsInMessages(response.warnings, details);
1349
1380
  let outstanding = 1;
1350
- let next = () => --outstanding === 0 && callback(null, { warnings, code: response.code, map: response.map });
1381
+ let next = () => {
1382
+ if (--outstanding === 0) {
1383
+ let result = { warnings, code: response.code, map: response.map };
1384
+ if (response.mangleCache)
1385
+ result.mangleCache = response == null ? void 0 : response.mangleCache;
1386
+ callback(null, result);
1387
+ }
1388
+ };
1351
1389
  if (errors.length > 0)
1352
1390
  return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1353
1391
  if (response.codeFS) {
@@ -1810,7 +1848,7 @@ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1810
1848
  }
1811
1849
  }
1812
1850
  var _a;
1813
- var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.16";
1851
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.14.20";
1814
1852
  var esbuildCommandAndArgs = () => {
1815
1853
  if ((!ESBUILD_BINARY_PATH || true) && (path2.basename(__filename) !== "main.js" || path2.basename(__dirname) !== "lib")) {
1816
1854
  throw new Error(`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
@@ -1869,7 +1907,7 @@ var fsAsync = {
1869
1907
  }
1870
1908
  }
1871
1909
  };
1872
- var version = "0.14.16";
1910
+ var version = "0.14.20";
1873
1911
  var build = (options) => ensureServiceIsRunning().build(options);
1874
1912
  var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1875
1913
  var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
@@ -1978,7 +2016,7 @@ var ensureServiceIsRunning = () => {
1978
2016
  if (longLivedService)
1979
2017
  return longLivedService;
1980
2018
  let [command, args] = esbuildCommandAndArgs();
1981
- let child = child_process.spawn(command, args.concat(`--service=${"0.14.16"}`, "--ping"), {
2019
+ let child = child_process.spawn(command, args.concat(`--service=${"0.14.20"}`, "--ping"), {
1982
2020
  windowsHide: true,
1983
2021
  stdio: ["pipe", "pipe", "inherit"],
1984
2022
  cwd: defaultWD
@@ -2087,7 +2125,7 @@ var runServiceSync = (callback) => {
2087
2125
  esbuild: node_exports
2088
2126
  });
2089
2127
  callback(service);
2090
- let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.16"}`), {
2128
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.14.20"}`), {
2091
2129
  cwd: defaultWD,
2092
2130
  windowsHide: true,
2093
2131
  input: stdin,
@@ -2103,7 +2141,7 @@ var workerThreadService = null;
2103
2141
  var startWorkerThreadService = (worker_threads2) => {
2104
2142
  let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
2105
2143
  let worker = new worker_threads2.Worker(__filename, {
2106
- workerData: { workerPort, defaultWD, esbuildVersion: "0.14.16" },
2144
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.14.20" },
2107
2145
  transferList: [workerPort],
2108
2146
  execArgv: []
2109
2147
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esbuild-wasm",
3
- "version": "0.14.16",
3
+ "version": "0.14.20",
4
4
  "description": "The cross-platform WebAssembly binary for esbuild, a JavaScript bundler.",
5
5
  "repository": "https://github.com/evanw/esbuild",
6
6
  "license": "MIT",
data/package.json CHANGED
@@ -4,6 +4,6 @@
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/isomorfeus/isomorfeus-asset-manager",
6
6
  "dependencies": {
7
- "esbuild-wasm": "0.14.16"
7
+ "esbuild-wasm": "0.14.20"
8
8
  }
9
9
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-asset-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.8
4
+ version: 0.14.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-01 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isomorfeus-iodine
@@ -163,11 +163,12 @@ files:
163
163
  - node_modules/esbuild-wasm/package.json
164
164
  - node_modules/esbuild-wasm/wasm_exec.js
165
165
  - package.json
166
- homepage: http://isomorfeus.com
166
+ homepage: https://isomorfeus.com
167
167
  licenses:
168
168
  - MIT
169
169
  metadata:
170
170
  github_repo: ssh://github.com/isomorfeus/gems
171
+ source_code_uri: https://github.com/isomorfeus/isomorfeus-asset-manager
171
172
  post_install_message:
172
173
  rdoc_options: []
173
174
  require_paths: