UNPKG

inklecate-wasm

Version:

A package bundling the desktop executable for inklecate, and all its dependencies, into a WebAssembly module executable fully in-browser.

1 lines 215 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=33)}([function(e,t){e.exports=require("path")},function(e,t,r){var n=r(5),o=r(35),i=r(36),s=r(37),a=[],c=r(17);var u,l,f=function(){};function d(e){o(e),e.gracefulify=d,e.FileReadStream=f,e.FileWriteStream=m,e.createReadStream=function(e,t){return new f(e,t)},e.createWriteStream=function(e,t){return new m(e,t)};var t=e.readFile;e.readFile=function(e,r,n){"function"==typeof r&&(n=r,r=null);return function e(r,n,o){return t(r,n,(function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof o&&o.apply(this,arguments),S()):_([e,[r,n,o]])}))}(e,r,n)};var r=e.writeFile;e.writeFile=function(e,t,n,o){"function"==typeof n&&(o=n,n=null);return function e(t,n,o,i){return r(t,n,o,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof i&&i.apply(this,arguments),S()):_([e,[t,n,o,i]])}))}(e,t,n,o)};var n=e.appendFile;n&&(e.appendFile=function(e,t,r,o){"function"==typeof r&&(o=r,r=null);return function e(t,r,o,i){return n(t,r,o,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?("function"==typeof i&&i.apply(this,arguments),S()):_([e,[t,r,o,i]])}))}(e,t,r,o)});var s=e.readdir;function a(t){return s.apply(e,t)}if(e.readdir=function(e,t,r){var n=[e];"function"!=typeof t?n.push(t):r=t;return n.push((function(e,t){t&&t.sort&&t.sort();!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof r&&r.apply(this,arguments),S()):_([a,[n]])})),a(n)},"v0.8"===process.version.substr(0,4)){var c=i(e);f=c.ReadStream,m=c.WriteStream}var u=e.ReadStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var e=this;p(e.path,e.flags,e.mode,(function(t,r){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=r,e.emit("open",r),e.read())}))});var l=e.WriteStream;function f(e,t){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}function m(e,t){return this instanceof m?(l.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}l&&(m.prototype=Object.create(l.prototype),m.prototype.open=function(){var e=this;p(e.path,e.flags,e.mode,(function(t,r){t?(e.destroy(),e.emit("error",t)):(e.fd=r,e.emit("open",r))}))}),e.ReadStream=f,e.WriteStream=m;var E=e.open;function p(e,t,r,n){return"function"==typeof r&&(n=r,r=null),function e(t,r,n,o){return E(t,r,n,(function(i,s){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?("function"==typeof o&&o.apply(this,arguments),S()):_([e,[t,r,n,o]])}))}(e,t,r,n)}return e.open=p,e}function _(e){f("ENQUEUE",e[0].name,e[1]),a.push(e)}function S(){var e=a.shift();e&&(f("RETRY",e[0].name,e[1]),e[0].apply(null,e[1]))}c.debuglog?f=c.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(f=function(){var e=c.format.apply(c,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){f(a),r(13).equal(a.length,0)})),e.exports=d(s(n)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!n.__patched&&(e.exports=d(n),n.__patched=!0),e.exports.close=(u=n.close,function(e,t){return u.call(n,e,(function(e){e||S(),"function"==typeof t&&t.apply(this,arguments)}))}),e.exports.closeSync=(l=n.closeSync,function(e){var t=l.apply(n,arguments);return S(),t}),/\bgraceful-fs\b/.test(n.closeSync.toString())||(n.closeSync=e.exports.closeSync,n.close=e.exports.close)},function(e,t,r){"use strict";t.fromCallback=function(e){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise((t,r)=>{arguments[arguments.length]=(e,n)=>{if(e)return r(e);t(n)},arguments.length++,e.apply(this,arguments)});e.apply(this,arguments)}),"name",{value:e.name})},t.fromPromise=function(e){return Object.defineProperty((function(){const t=arguments[arguments.length-1];if("function"!=typeof t)return e.apply(this,arguments);e.apply(this,arguments).then(e=>t(null,e),t)}),"name",{value:e.name})}},function(e,t,r){"use strict";const n=(0,r(2).fromCallback)(r(39)),o=r(40);e.exports={mkdirs:n,mkdirsSync:o,mkdirp:n,mkdirpSync:o,ensureDir:n,ensureDirSync:o}},function(e,t,r){"use strict";const n=r(2).fromPromise,o=r(15);e.exports={pathExists:n((function(e){return o.access(e).then(()=>!0).catch(()=>!1)})),pathExistsSync:o.existsSync}},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}}},function(e,t){e.exports=require("stream")},function(e,t,r){"use strict";const n=r(1),o=r(0),i=process.versions.node.split("."),s=Number.parseInt(i[0],10),a=Number.parseInt(i[1],10),c=Number.parseInt(i[2],10);function u(){if(s>10)return!0;if(10===s){if(a>5)return!0;if(5===a&&c>=0)return!0}return!1}function l(e,t){const r=o.resolve(e).split(o.sep).filter(e=>e),n=o.resolve(t).split(o.sep).filter(e=>e);return r.reduce((e,t,r)=>e&&n[r]===t,!0)}function f(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}e.exports={checkPaths:function(e,t,r,o){!function(e,t,r){u()?n.stat(e,{bigint:!0},(e,o)=>{if(e)return r(e);n.stat(t,{bigint:!0},(e,t)=>e?"ENOENT"===e.code?r(null,{srcStat:o,destStat:null}):r(e):r(null,{srcStat:o,destStat:t}))}):n.stat(e,(e,o)=>{if(e)return r(e);n.stat(t,(e,t)=>e?"ENOENT"===e.code?r(null,{srcStat:o,destStat:null}):r(e):r(null,{srcStat:o,destStat:t}))})}(e,t,(n,i)=>{if(n)return o(n);const{srcStat:s,destStat:a}=i;return a&&a.ino&&a.dev&&a.ino===s.ino&&a.dev===s.dev?o(new Error("Source and destination must not be the same.")):s.isDirectory()&&l(e,t)?o(new Error(f(e,t,r))):o(null,{srcStat:s,destStat:a})})},checkPathsSync:function(e,t,r){const{srcStat:o,destStat:i}=function(e,t){let r,o;r=u()?n.statSync(e,{bigint:!0}):n.statSync(e);try{o=u()?n.statSync(t,{bigint:!0}):n.statSync(t)}catch(e){if("ENOENT"===e.code)return{srcStat:r,destStat:null};throw e}return{srcStat:r,destStat:o}}(e,t);if(i&&i.ino&&i.dev&&i.ino===o.ino&&i.dev===o.dev)throw new Error("Source and destination must not be the same.");if(o.isDirectory()&&l(e,t))throw new Error(f(e,t,r));return{srcStat:o,destStat:i}},checkParentPaths:function e(t,r,i,s,a){const c=o.resolve(o.dirname(t)),l=o.resolve(o.dirname(i));if(l===c||l===o.parse(l).root)return a();u()?n.stat(l,{bigint:!0},(n,o)=>n?"ENOENT"===n.code?a():a(n):o.ino&&o.dev&&o.ino===r.ino&&o.dev===r.dev?a(new Error(f(t,i,s))):e(t,r,l,s,a)):n.stat(l,(n,o)=>n?"ENOENT"===n.code?a():a(n):o.ino&&o.dev&&o.ino===r.ino&&o.dev===r.dev?a(new Error(f(t,i,s))):e(t,r,l,s,a))},checkParentPathsSync:function e(t,r,i,s){const a=o.resolve(o.dirname(t)),c=o.resolve(o.dirname(i));if(c===a||c===o.parse(c).root)return;let l;try{l=u()?n.statSync(c,{bigint:!0}):n.statSync(c)}catch(e){if("ENOENT"===e.code)return;throw e}if(l.ino&&l.dev&&l.ino===r.ino&&l.dev===r.dev)throw new Error(f(t,i,s));return e(t,r,c,s)},isSrcSubdir:l}},function(e,t,r){"use strict";const n=r(2).fromCallback,o=r(44);e.exports={remove:n(o),removeSync:o.sync}},function(e,t){e.exports=require("crypto")},function(e,t,r){"use strict";const n=r(68),o=r(12),i=r(71),{kStatusCode:s,NOOP:a}=r(6),c=Buffer.from([0,0,255,255]),u=Symbol("permessage-deflate"),l=Symbol("total-length"),f=Symbol("callback"),d=Symbol("buffers"),_=Symbol("error");let S;function m(e){this[d].push(e),this[l]+=e.length}function E(e){this[l]+=e.length,this[u]._maxPayload<1||this[l]<=this[u]._maxPayload?this[d].push(e):(this[_]=new RangeError("Max payload size exceeded"),this[_][s]=1009,this.removeListener("data",E),this.reset())}function p(e){this[u]._inflate=null,e[s]=1007,this[f](e)}e.exports=class{constructor(e,t,r){if(this._maxPayload=0|r,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!S){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;S=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate&&(this._deflate[f]&&this._deflate[f](),this._deflate.close(),this._deflate=null)}acceptAsServer(e){const t=this._options,r=e.find(e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:!0!==r.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete r.client_max_window_bits,r}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let r=e[t];if(r.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==r)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}e[t]=r})}),e}decompress(e,t,r){S.add(n=>{this._decompress(e,t,(e,t)=>{n(),r(e,t)})})}compress(e,t,r){S.add(n=>{this._compress(e,t,(e,t)=>{n(),(e||t)&&r(e,t)})})}_decompress(e,t,r){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[u]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on("error",p),this._inflate.on("data",E)}this._inflate[f]=r,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{const e=this._inflate[_];if(e)return this._inflate.close(),this._inflate=null,void r(e);const n=o.concat(this._inflate[d],this._inflate[l]);t&&this.params[`${i}_no_context_takeover`]?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[]),r(null,n)})}_compress(e,t,r){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on("error",a),this._deflate.on("data",m)}this._deflate[f]=r,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=o.concat(this._deflate[d],this._deflate[l]);t&&(e=e.slice(0,e.length-4)),this._deflate[f]=null,t&&this.params[`${i}_no_context_takeover`]?(this._deflate.close(),this._deflate=null):(this._deflate[l]=0,this._deflate[d]=[]),r(null,e)})}}},function(e,t,r){"use strict";const{EMPTY_BUFFER:n}=r(6);function o(e,t){if(0===e.length)return n;if(1===e.length)return e[0];const r=Buffer.allocUnsafe(t);let o=0;for(let t=0;t<e.length;t++){const n=e[t];r.set(n,o),o+=n.length}return o<t?r.slice(0,o):r}function i(e,t,r,n,o){for(let i=0;i<o;i++)r[n+i]=e[i]^t[3&i]}function s(e,t){const r=e.length;for(let n=0;n<r;n++)e[n]^=t[3&n]}function a(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function c(e){if(c.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=function(e){const t=Buffer.from(e.buffer);if(e.byteLength!==e.buffer.byteLength)return t.slice(e.byteOffset,e.byteOffset+e.byteLength);return t}(e):(t=Buffer.from(e),c.readOnly=!1),t}try{const t=r(69),n=t.BufferUtil||t;e.exports={concat:o,mask(e,t,r,o,s){s<48?i(e,t,r,o,s):n.mask(e,t,r,o,s)},toArrayBuffer:a,toBuffer:c,unmask(e,t){e.length<32?s(e,t):n.unmask(e,t)}}}catch(t){e.exports={concat:o,mask:i,toArrayBuffer:a,toBuffer:c,unmask:s}}},function(e,t){e.exports=require("assert")},function(e,t,r){"use strict";const n=r(2).fromCallback,o=r(52);e.exports={readJson:n(o.readFile),readJsonSync:o.readFileSync,writeJson:n(o.writeFile),writeJsonSync:o.writeFileSync}},function(e,t,r){"use strict";const n=r(2).fromCallback,o=r(1),i=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>"function"==typeof o[e]);Object.keys(o).forEach(e=>{"promises"!==e&&(t[e]=o[e])}),i.forEach(e=>{t[e]=n(o[e])}),t.exists=function(e,t){return"function"==typeof t?o.exists(e,t):new Promise(t=>o.exists(e,t))},t.read=function(e,t,r,n,i,s){return"function"==typeof s?o.read(e,t,r,n,i,s):new Promise((s,a)=>{o.read(e,t,r,n,i,(e,t,r)=>{if(e)return a(e);s({bytesRead:t,buffer:r})})})},t.write=function(e,t,...r){return"function"==typeof r[r.length-1]?o.write(e,t,...r):new Promise((n,i)=>{o.write(e,t,...r,(e,t,r)=>{if(e)return i(e);n({bytesWritten:t,buffer:r})})})},"function"==typeof o.realpath.native&&(t.realpath.native=n(o.realpath.native))},function(e,t){e.exports=require("constants")},function(e,t){e.exports=require("util")},function(e,t,r){"use strict";e.exports={copySync:r(38)}},function(e,t,r){"use strict";const n=r(0);function o(e){return(e=n.normalize(n.resolve(e)).split(n.sep)).length>0?e[0]:null}const i=/[<>:"|?*]/;e.exports={getRootPath:o,invalidWin32Path:function(e){const t=o(e);return e=e.replace(t,""),i.test(e)}}},function(e,t,r){"use strict";const n=r(1),o=r(21),i=r(0);e.exports={hasMillisRes:function(e){let t=i.join("millis-test"+Date.now().toString()+Math.random().toString().slice(2));t=i.join(o.tmpdir(),t);const r=new Date(1435410243862);n.writeFile(t,"https://github.com/jprichardson/node-fs-extra/pull/141",o=>{if(o)return e(o);n.open(t,"r+",(o,i)=>{if(o)return e(o);n.futimes(i,r,r,r=>{if(r)return e(r);n.close(i,r=>{if(r)return e(r);n.stat(t,(t,r)=>{if(t)return e(t);e(null,r.mtime>1435410243e3)})})})})})},hasMillisResSync:function(){let e=i.join("millis-test-sync"+Date.now().toString()+Math.random().toString().slice(2));e=i.join(o.tmpdir(),e);const t=new Date(1435410243862);n.writeFileSync(e,"https://github.com/jprichardson/node-fs-extra/pull/141");const r=n.openSync(e,"r+");return n.futimesSync(r,t,t),n.closeSync(r),n.statSync(e).mtime>1435410243e3},timeRemoveMillis:function(e){if("number"==typeof e)return 1e3*Math.floor(e/1e3);if(e instanceof Date)return new Date(1e3*Math.floor(e.getTime()/1e3));throw new Error("fs-extra: timeRemoveMillis() unknown parameter type")},utimesMillis:function(e,t,r,o){n.open(e,"r+",(e,i)=>{if(e)return o(e);n.futimes(i,t,r,e=>{n.close(i,t=>{o&&o(e||t)})})})},utimesMillisSync:function(e,t,r){const o=n.openSync(e,"r+");return n.futimesSync(o,t,r),n.closeSync(o)}}},function(e,t){e.exports=require("os")},function(e,t,r){"use strict";const n=r(2).fromCallback;e.exports={copy:n(r(42))}},function(e,t,r){"use strict";const n=r(24);n.createWebSocketStream=r(75),n.Server=r(76),n.Receiver=r(28),n.Sender=r(30),e.exports=n},function(e,t,r){"use strict";const n=r(25),o=r(64),i=r(26),s=r(65),a=r(66),{randomBytes:c,createHash:u}=r(10),{URL:l}=r(67),f=r(11),d=r(28),_=r(30),{BINARY_TYPES:S,EMPTY_BUFFER:m,GUID:E,kStatusCode:p,kWebSocket:h,NOOP:y}=r(6),{addEventListener:g,removeEventListener:v}=r(74),{format:w,parse:F}=r(31),{toBuffer:O}=r(12),A=["CONNECTING","OPEN","CLOSING","CLOSED"],b=[8,13];class N extends n{constructor(e,t,r){super(),this.readyState=N.CONNECTING,this.protocol="",this._binaryType=S[0],this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._closeCode=1006,this._extensions={},this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(t)?t=t.join(", "):"object"==typeof t&&null!==t&&(r=t,t=void 0),function e(t,r,n,s){const a={protocolVersion:b[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,auth:void 0,host:void 0,path:void 0,port:void 0};if(!b.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} `+`(supported versions: ${b.join(", ")})`);let d;r instanceof l?(d=r,t.url=r.href):(d=new l(r),t.url=r);const _="ws+unix:"===d.protocol;if(!(d.host||_&&d.pathname))throw new Error(`Invalid URL: ${t.url}`);const S="wss:"===d.protocol||"https:"===d.protocol,m=S?443:80,p=c(16).toString("base64"),h=S?o.get:i.get;let y;a.createConnection=S?M:R,a.defaultPort=a.defaultPort||m,a.port=d.port||m,a.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,a.headers={"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":p,Connection:"Upgrade",Upgrade:"websocket",...a.headers},a.path=d.pathname+d.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(y=new f(!0!==a.perMessageDeflate?a.perMessageDeflate:{},!1,a.maxPayload),a.headers["Sec-WebSocket-Extensions"]=w({[f.extensionName]:y.offer()}));n&&(a.headers["Sec-WebSocket-Protocol"]=n);a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin);(d.username||d.password)&&(a.auth=`${d.username}:${d.password}`);if(_){const e=a.path.split(":");a.socketPath=e[0],a.path=e[1]}let g=t._req=h(a);a.timeout&&g.on("timeout",()=>{k(t,g,"Opening handshake has timed out")});g.on("error",e=>{t._req.aborted||(g=t._req=null,t.readyState=N.CLOSING,t.emit("error",e),t.emitClose())}),g.on("response",o=>{const i=o.headers.location,c=o.statusCode;if(i&&a.followRedirects&&c>=300&&c<400){if(++t._redirects>a.maxRedirects)return void k(t,g,"Maximum redirects exceeded");g.abort();const o=new l(i,r);e(t,o,n,s)}else t.emit("unexpected-response",g,o)||k(t,g,`Unexpected server response: ${o.statusCode}`)}),g.on("upgrade",(e,r,o)=>{if(t.emit("upgrade",e),t.readyState!==N.CONNECTING)return;g=t._req=null;const i=u("sha1").update(p+E).digest("base64");if(e.headers["sec-websocket-accept"]!==i)return void k(t,r,"Invalid Sec-WebSocket-Accept header");const s=e.headers["sec-websocket-protocol"],c=(n||"").split(/, */);let l;if(!n&&s?l="Server sent a subprotocol but none was requested":n&&!s?l="Server sent no subprotocol":s&&!c.includes(s)&&(l="Server sent an invalid subprotocol"),l)k(t,r,l);else{if(s&&(t.protocol=s),y)try{const r=F(e.headers["sec-websocket-extensions"]);r[f.extensionName]&&(y.accept(r[f.extensionName]),t._extensions[f.extensionName]=y)}catch(e){return void k(t,r,"Invalid Sec-WebSocket-Extensions header")}t.setSocket(r,o,a.maxPayload)}})}(this,e,t,r)):this._isServer=!0}get CONNECTING(){return N.CONNECTING}get CLOSING(){return N.CLOSING}get CLOSED(){return N.CLOSED}get OPEN(){return N.OPEN}get binaryType(){return this._binaryType}set binaryType(e){S.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?(this._socket.bufferSize||0)+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}setSocket(e,t,r){const n=new d(this._binaryType,this._extensions,r);this._sender=new _(e,this._extensions),this._receiver=n,this._socket=e,n[h]=this,e[h]=this,n.on("conclude",P),n.on("drain",C),n.on("error",L),n.on("message",I),n.on("ping",x),n.on("pong",H),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Y),e.on("data",B),e.on("end",U),e.on("error",W),this.readyState=N.OPEN,this.emit("open")}emitClose(){this.readyState=N.CLOSED,this._socket?(this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this.emit("close",this._closeCode,this._closeMessage)):this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return k(this,this._req,e)}this.readyState!==N.CLOSING?(this.readyState=N.CLOSING,this._sender.close(e,t,!this._isServer,e=>{e||(this._closeFrameSent=!0,this._closeFrameReceived&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&this._closeFrameReceived&&this._socket.end()}}ping(e,t,r){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||m,t,r)):T(this,e,r)}pong(e,t,r){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||m,t,r)):T(this,e,r)}send(e,t,r){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==N.OPEN)return void T(this,e,r);const n={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[f.extensionName]||(n.compress=!1),this._sender.send(e||m,n,r)}terminate(){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return k(this,this._req,e)}this._socket&&(this.readyState=N.CLOSING,this._socket.destroy())}}}function R(e){return e.path=e.socketPath,s.connect(e)}function M(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=e.host),a.connect(e)}function k(e,t,r){e.readyState=N.CLOSING;const n=new Error(r);Error.captureStackTrace(n,k),t.setHeader?(t.abort(),t.once("abort",e.emitClose.bind(e)),e.emit("error",n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function T(e,t,r){if(t){const r=O(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){r(new Error(`WebSocket is not open: readyState ${e.readyState} `+`(${A[e.readyState]})`))}}function P(e,t){const r=this[h];r._socket.removeListener("data",B),r._socket.resume(),r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,1005===e?r.close():r.close(e,t)}function C(){this[h]._socket.resume()}function L(e){const t=this[h];t._socket.removeListener("data",B),t.readyState=N.CLOSING,t._closeCode=e[p],t.emit("error",e),t._socket.destroy()}function D(){this[h].emitClose()}function I(e){this[h].emit("message",e)}function x(e){const t=this[h];t.pong(e,!t._isServer,y),t.emit("ping",e)}function H(e){this[h].emit("pong",e)}function Y(){const e=this[h];this.removeListener("close",Y),this.removeListener("end",U),e.readyState=N.CLOSING,e._socket.read(),e._receiver.end(),this.removeListener("data",B),this[h]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",D),e._receiver.on("finish",D))}function B(e){this[h]._receiver.write(e)||this.pause()}function U(){const e=this[h];e.readyState=N.CLOSING,e._receiver.end(),this.end()}function W(){const e=this[h];this.removeListener("error",W),this.on("error",y),e&&(e.readyState=N.CLOSING,this.destroy())}A.forEach((e,t)=>{N[e]=t}),["open","error","close","message"].forEach(e=>{Object.defineProperty(N.prototype,`on${e}`,{get(){const t=this.listeners(e);for(let e=0;e<t.length;e++)if(t[e]._listener)return t[e]._listener},set(t){const r=this.listeners(e);for(let t=0;t<r.length;t++)r[t]._listener&&this.removeListener(e,r[t]);this.addEventListener(e,t)}})}),N.prototype.addEventListener=g,N.prototype.removeEventListener=v,e.exports=N},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("http")},function(e,t,r){var n=r(5),o=r(0),i=r(21),s=require,a=process.versions.modules,c=!(!process.versions||!process.versions.electron)||!!process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":"node",u=i.arch(),l=i.platform();function f(e){return s(f.path(e))}function d(e,t){try{var r=n.readdirSync(e).filter(t);return r[0]&&o.join(e,r[0])}catch(e){return null}}function _(e){return e===c+"-napi.node"}function S(e){return"node-napi.node"===e}function m(e){var t=e.split("-");return t[0]===c&&t[1]===a+".node"}function E(e){return/\.node$/.test(e)}e.exports=f,f.path=function(e){e=o.resolve(e||".");try{var t=s(o.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}var r=d(o.join(e,"build/Release"),E);if(r)return r;var n=d(o.join(e,"build/Debug"),E);if(n)return n;var i=d(o.join(e,"prebuilds/"+l+"-"+u),m);if(i)return i;var f=d(o.join(e,"prebuilds/"+l+"-"+u),_);if(f)return f;var p=d(o.join(e,"prebuilds/"+l+"-"+u),S);if(p)return p;throw new Error("No native build was found for runtime="+c+" abi="+a+" platform="+l+" arch="+u)}},function(e,t,r){"use strict";const{Writable:n}=r(7),o=r(11),{BINARY_TYPES:i,EMPTY_BUFFER:s,kStatusCode:a,kWebSocket:c}=r(6),{concat:u,toArrayBuffer:l,unmask:f}=r(12),{isValidStatusCode:d,isValidUTF8:_}=r(29);function S(e,t,r,n){const o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,S),o[a]=n,o}e.exports=class extends n{constructor(e,t,r){super(),this._binaryType=e||i[0],this[c]=void 0,this._extensions=t||{},this._maxPayload=0|r,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,r){if(8===this._opcode&&0==this._state)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=t.slice(e),t.slice(0,e)}const t=Buffer.allocUnsafe(e);do{const r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,S(RangeError,"RSV2 and RSV3 must be clear",!0,1002);const t=64==(64&e[0]);if(t&&!this._extensions[o.extensionName])return this._loop=!1,S(RangeError,"RSV1 must be clear",!0,1002);if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,S(RangeError,"RSV1 must be clear",!0,1002);if(!this._fragmented)return this._loop=!1,S(RangeError,"invalid opcode 0",!0,1002);this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,S(RangeError,`invalid opcode ${this._opcode}`,!0,1002);this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,S(RangeError,`invalid opcode ${this._opcode}`,!0,1002);if(!this._fin)return this._loop=!1,S(RangeError,"FIN must be set",!0,1002);if(t)return this._loop=!1,S(RangeError,"RSV1 must be clear",!0,1002);if(this._payloadLength>125)return this._loop=!1,S(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002)}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,S(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009)):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,S(RangeError,"Max payload size exceeded",!1,1009);this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=s;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&f(t,this._mask)}return this._opcode>7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[o.extensionName].decompress(e,this._fin,(e,r)=>{if(e)return t(e);if(r.length){if(this._messageLength+=r.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(S(RangeError,"Max payload size exceeded",!1,1009));this._fragments.push(r)}const n=this.dataMessage();if(n)return t(n);this.startLoop(t)})}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?u(t,e):"arraybuffer"===this._binaryType?l(u(t,e)):t,this.emit("message",r)}else{const r=u(t,e);if(!_(r))return this._loop=!1,S(Error,"invalid UTF-8 sequence",!0,1007);this.emit("message",r.toString())}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,""),this.end();else{if(1===e.length)return S(RangeError,"invalid payload length 1",!0,1002);{const t=e.readUInt16BE(0);if(!d(t))return S(RangeError,`invalid status code ${t}`,!0,1002);const r=e.slice(2);if(!_(r))return S(Error,"invalid UTF-8 sequence",!0,1007);this.emit("conclude",t,r.toString()),this.end()}}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}}},function(e,t,r){"use strict";try{const e=r(72);t.isValidUTF8="object"==typeof e?e.Validation.isValidUTF8:e}catch(e){t.isValidUTF8=()=>!0}t.isValidStatusCode=e=>e>=1e3&&e<=1013&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},function(e,t,r){"use strict";const{randomFillSync:n}=r(10),o=r(11),{EMPTY_BUFFER:i}=r(6),{isValidStatusCode:s}=r(29),{mask:a,toBuffer:c}=r(12),u=Buffer.alloc(4);class l{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){const r=t.mask&&t.readOnly;let o=t.mask?6:2,i=e.length;e.length>=65536?(o+=8,i=127):e.length>125&&(o+=2,i=126);const s=Buffer.allocUnsafe(r?e.length+o:o);return s[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(s[0]|=64),s[1]=i,126===i?s.writeUInt16BE(e.length,2):127===i&&(s.writeUInt32BE(0,2),s.writeUInt32BE(e.length,6)),t.mask?(n(u,0,4),s[1]|=128,s[o-4]=u[0],s[o-3]=u[1],s[o-2]=u[2],s[o-1]=u[3],r?(a(e,u,s,o,e.length),[s]):(a(e,u,e,0,e.length),[s,e])):[s,e]}close(e,t,r,n){let o;if(void 0===e)o=i;else{if("number"!=typeof e||!s(e))throw new TypeError("First argument must be a valid error code number");void 0===t||""===t?(o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0)):(o=Buffer.allocUnsafe(2+Buffer.byteLength(t)),o.writeUInt16BE(e,0),o.write(t,2))}this._deflating?this.enqueue([this.doClose,o,r,n]):this.doClose(o,r,n)}doClose(e,t,r){this.sendFrame(l.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),r)}ping(e,t,r){const n=c(e);this._deflating?this.enqueue([this.doPing,n,t,c.readOnly,r]):this.doPing(n,t,c.readOnly,r)}doPing(e,t,r,n){this.sendFrame(l.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:r}),n)}pong(e,t,r){const n=c(e);this._deflating?this.enqueue([this.doPong,n,t,c.readOnly,r]):this.doPong(n,t,c.readOnly,r)}doPong(e,t,r,n){this.sendFrame(l.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:r}),n)}send(e,t,r){const n=c(e),i=this._extensions[o.extensionName];let s=t.binary?2:1,a=t.compress;if(this._firstFragment?(this._firstFragment=!1,a&&i&&(a=n.length>=i._threshold),this._compress=a):(a=!1,s=0),t.fin&&(this._firstFragment=!0),i){const e={fin:t.fin,rsv1:a,opcode:s,mask:t.mask,readOnly:c.readOnly};this._deflating?this.enqueue([this.dispatch,n,this._compress,e,r]):this.dispatch(n,this._compress,e,r)}else this.sendFrame(l.frame(n,{fin:t.fin,rsv1:!1,opcode:s,mask:t.mask,readOnly:c.readOnly}),r)}dispatch(e,t,r,n){if(!t)return void this.sendFrame(l.frame(e,r),n);const i=this._extensions[o.extensionName];this._deflating=!0,i.compress(e,r.fin,(e,t)=>{this._deflating=!1,r.readOnly=!1,this.sendFrame(l.frame(t,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[1].length,Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[1].length,this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}e.exports=l},function(e,t,r){"use strict";const n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function o(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}e.exports={format:function(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>[t].concat(Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){const t=Object.create(null);if(void 0===e||""===e)return t;let r,i,s=Object.create(null),a=!1,c=!1,u=!1,l=-1,f=-1,d=0;for(;d<e.length;d++){const _=e.charCodeAt(d);if(void 0===r)if(-1===f&&1===n[_])-1===l&&(l=d);else if(32===_||9===_)-1===f&&-1!==l&&(f=d);else{if(59!==_&&44!==_)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d);const n=e.slice(l,f);44===_?(o(t,n,s),s=Object.create(null)):r=n,l=f=-1}}else if(void 0===i)if(-1===f&&1===n[_])-1===l&&(l=d);else if(32===_||9===_)-1===f&&-1!==l&&(f=d);else if(59===_||44===_){if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d),o(s,e.slice(l,f),!0),44===_&&(o(t,r,s),s=Object.create(null),r=void 0),l=f=-1}else{if(61!==_||-1===l||-1!==f)throw new SyntaxError(`Unexpected character at index ${d}`);i=e.slice(l,d),l=f=-1}else if(c){if(1!==n[_])throw new SyntaxError(`Unexpected character at index ${d}`);-1===l?l=d:a||(a=!0),c=!1}else if(u)if(1===n[_])-1===l&&(l=d);else if(34===_&&-1!==l)u=!1,f=d;else{if(92!==_)throw new SyntaxError(`Unexpected character at index ${d}`);c=!0}else if(34===_&&61===e.charCodeAt(d-1))u=!0;else if(-1===f&&1===n[_])-1===l&&(l=d);else if(-1===l||32!==_&&9!==_){if(59!==_&&44!==_)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d);let n=e.slice(l,f);a&&(n=n.replace(/\\/g,""),a=!1),o(s,i,n),44===_&&(o(t,r,s),s=Object.create(null),r=void 0),i=void 0,l=f=-1}}else-1===f&&(f=d)}if(-1===l||u)throw new SyntaxError("Unexpected end of input");-1===f&&(f=d);const _=e.slice(l,f);return void 0===r?o(t,_,s):(void 0===i?o(s,_,!0):o(s,i,a?_.replace(/\\/g,""):_),o(t,r,s)),t}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=(e,t,r)=>{const n={text:r,compilerOutput:[],storyContent:null};let o,i=!1;const s=e.entryPoint.assemblyName,a=e.entryPoint.nsName,c=e.entryPoint.className;let u,l;const f=process&&process.stdout&&"function"==typeof process.stdout.write;f&&(l=process.stdout.write,u=function(e){/^(error|warning):?\s/i.test(e)?n.compilerOutput.push(e):console.warn(e)},process.stdout.write=u);try{const e=t.assembly_load()(s),n=t.find_class()(e,a,c),i=t.find_method()(n,"CompileToString",1),u=t.mono_string()(r);o=t.call_method(i,n,[u])}catch(e){i=!0;const t=String(e);/^(error|warning):?\s/i.test(t)&&n.compilerOutput.push(t)}if(f&&(process.stdout.write=l),i)return n;const d=t.conv_string(o);try{n.storyContent=JSON.parse(d)}catch(e){compilerErrors.push("INKLECATE-WASM: The inklecate response could not be loaded from JSON.")}return n}},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"Module",(function(){return Module})),__webpack_require__.d(__webpack_exports__,"MonoRuntime",(function(){return MonoRuntime})),__webpack_require__.d(__webpack_exports__,"WebAssemblyApp",(function(){return WebAssemblyApp})),__webpack_require__.d(__webpack_exports__,"initializeMonoEnvironment",(function(){return initializeMonoEnvironment}));var _compileInk__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(32);const debug=!1;let ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER,ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;const Module={assemblies:["ink_compiler.dll","ink-engine-runtime.dll","inklecate_wasm.dll","mscorlib.dll","System.Core.dll","System.dll"],entryPoint:{assemblyName:"inklecate_wasm",nsName:"inklecate_wasm",className:"Program",mainMethodName:"Main"},onRuntimeInitialized:function(e){debug&&console.log("Done with WASM module instantiation."),Module.FS_createPath("/","managed",!0,!0);let t=0;this.assemblies.forEach((function(r){let n;if(debug&&console.log("Loading "+r+"."),++t,ENVIRONMENT_IS_NODE){const{readFile:e}=__webpack_require__(34);n=e(__webpack_require__(0).join(__dirname,"managed",r))}else n=fetch("managed/"+r,{contentType:"application/wasm",credentials:"same-origin"});n.then((function(n){const o=new Uint8Array(n);Module.FS_createDataFile("managed/"+r,null,o,!0,!0,!0),t-=1,t||Module.bclLoadingDone(e)}))}))},bclLoadingDone:function(e){return debug&&console.log("Done loading the Mono Base Class Library."),MonoRuntime.init(),WebAssemblyApp.compileInk=_compileInk__WEBPACK_IMPORTED_MODULE_0__.a.bind(WebAssemblyApp,Module,MonoRuntime),e(WebAssemblyApp.compileInk)},compileInk:null},MonoRuntime={load_runtime:()=>Module.cwrap("mono_wasm_load_runtime",null,["string","number"]),assembly_load:()=>Module.cwrap("mono_wasm_assembly_load","number",["string"]),find_class:()=>Module.cwrap("mono_wasm_assembly_find_class","number",["number","string","string"]),find_method:()=>Module.cwrap("mono_wasm_assembly_find_method","number",["number","string","number"]),invoke_method:()=>Module.cwrap("mono_wasm_invoke_method","number",["number","number","number"]),mono_string_get_utf8:()=>Module.cwrap("mono_wasm_string_get_utf8","number",["number"]),mono_string:()=>Module.cwrap("mono_wasm_string_from_js","number",["string"]),init(){this.load_runtime()("managed",1),debug&&console.log("Done initializing the runtime."),WebAssemblyApp.init()},call_method(e,t,r){const n=Module._malloc(4*r.length),o=Module._malloc(4);for(let e=0;e<r.length;++e)Module.setValue(n+4*e,r[e],"i32");Module.setValue(o,0,"i32");var i=this.invoke_method()(e,t,n,o),s=Module.getValue(o,"i32");if(Module._free(n),Module._free(o),0!==s){const e=this.conv_string(i);throw new Error(e)}return i},conv_string(e){if(0===e)return null;const t=this.mono_string_get_utf8()(e),r=Module.UTF8ToString(t);return Module._free(t),r}},WebAssemblyApp={init(){this.findMethods(),MonoRuntime.call_method(this.main_method,null,[])},findMethods(){if(this.main_module=MonoRuntime.assembly_load()(Module.entryPoint.assemblyName),!this.main_module)throw new Error("Could not find Main Module "+Module.entryPoint.assemblyName+".dll.");if(this.main_class=MonoRuntime.find_class()(this.main_module,Module.entryPoint.nsName,Module.entryPoint.className),!this.main_class)throw new Error(`Could not find ${Module.entryPoint.className} class in main module.`);if(this.main_method=MonoRuntime.find_method()(this.main_class,Module.entryPoint.mainMethodName,-1),!this.main_method)throw new Error("Could not find Main method.")}},initializeMonoEnvironment=()=>new Promise((resolve,reject)=>{if("function"==typeof WebAssemblyApp.compileInk)return resolve(WebAssemblyApp.compileInk);var moduleOverrides={},key,nodeFS,nodePath;for(key in Module)Module.hasOwnProperty(key)&&(moduleOverrides[key]=Module[key]);if(Module.arguments=[],Module.thisProgram="./this.program",Module.quit=function(e,t){return err.code=e,reject(err)},Module.preRun=[],Module.postRun=[],Module.ENVIRONMENT)if("WEB"===Module.ENVIRONMENT)ENVIRONMENT_IS_WEB=!0;else if("WORKER"===Module.ENVIRONMENT)ENVIRONMENT_IS_WORKER=!0;else if("NODE"===Module.ENVIRONMENT)ENVIRONMENT_IS_NODE=!0;else{if("SHELL"!==Module.ENVIRONMENT)return reject(new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL."));ENVIRONMENT_IS_SHELL=!0}ENVIRONMENT_IS_NODE?(Module.read=function(e,t){var r;return nodeFS||(nodeFS=__webpack_require__(5)),nodePath||(nodePath=__webpack_require__(0)),e=nodePath.normalize(e),r=nodeFS.readFileSync(e),t?r:r.toString()},Module.readBinary=function(e){var t=Module.read(e,!0);return t.buffer||(t=new Uint8Array(t)),assert(t.buffer),t},process.argv.length>1&&(Module.thisProgram=process.argv[1].replace(/\\/g,"/")),Module.arguments=process.argv.slice(2),Module.inspect=function(){return"[Emscripten Module object]"}):ENVIRONMENT_IS_SHELL?("undefined"!=typeof read&&(Module.read=function(e){return read(e)}),Module.readBinary=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(assert("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:void 0!==arguments&&(Module.arguments=arguments),"function"==typeof quit&&(Module.quit=function(e,t){quit(e,t)})):(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(Module.read=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},ENVIRONMENT_IS_WORKER&&(Module.readBinary=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),Module.readAsync=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)},void 0!==arguments&&(Module.arguments=Array.from(arguments)),Module.setWindowTitle=function(e){document.title=e});for(key in Module.print="undefined"!=typeof console?console.log.bind(console):"undefined"!=typeof print?print:null,Module.printErr="undefined"!=typeof printErr?printErr:"undefined"!=typeof console&&console.warn.bind(console)||Module.print,Module.print=Module.print,Module.printErr=Module.printErr,moduleOverrides)moduleOverrides.hasOwnProperty(key)&&(Module[key]=moduleOverrides[key]);moduleOverrides=void 0;var STACK_ALIGN=16;function staticAlloc(e){assert(!staticSealed);var t=STATICTOP;return STATICTOP=STATICTOP+e+15&-16,t}function dynamicAlloc(e){assert(DYNAMICTOP_PTR);var t=HEAP32[DYNAMICTOP_PTR>>2],r=t+e+15&-16;if((HEAP32[DYNAMICTOP_PTR>>2]=r,r>=TOTAL_MEMORY)&&!enlargeMemory())return HEAP32[DYNAMICTOP_PTR>>2]=t,0;return t}function alignMemory(e,t){return t||(t=STACK_ALIGN),e=Math.ceil(e/t)*t}function getNativeTypeSize(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===e[e.length-1])return 4;if("i"===e[0]){var t=parseInt(e.substr(1));return assert(t%8==0),t/8}return 0}}var functionPointers=new Array(0),GLOBAL_BASE=1024,ABORT=0,EXITSTATUS=0;function assert(e,t){e||abort("Assertion failed: "+t)}function getCFunc(e){var t=Module["_"+e];return assert(t,"Cannot call unknown function "+e+", make sure it is exported"),t}var JSfuncs={stackSave:function(){stackSave()},stackRestore:function(){stackRestore()},arrayToC:function(e){var t=stackAlloc(e.length);return writeArrayToMemory(e,t),t},stringToC:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);stringToUTF8(e,t=stackAlloc(r),r)}return t}},toC={string:JSfuncs.stringToC,array:JSfuncs.arrayToC};function ccall(e,t,r,n,o){var i=getCFunc(e),s=[],a=0;if(n)for(var c=0;c<n.length;c++){var u=toC[r[c]];u?(0===a&&(a=stackSave()),s[c]=u(n[c])):s[c]=n[c]}var l=i.apply(null,s);return"string"===t&&(l=Pointer_stringify(l)),0!==a&&stackRestore(a),l}function cwrap(e,t,r){r=r||[];var n=getCFunc(e),o=r.every((function(e){return"number"===e}));return"string"!==t&&o?n:function(){return ccall(e,t,r,arguments)}}function setValue(e,t,r,n){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":HEAP8[e>>0]=t;break;case"i16":HEAP16[e>>1]=t;break;case"i32":HEAP32[e>>2]=t;break;case"i64":tempI64=[t>>>0,(tempDouble=t,+Math_abs(tempDouble)>=1?tempDouble>0?(0|Math_min(+Math_floor(tempDouble/4294967296),4294967295))>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e>>2]=tempI64[0],HEAP32[e+4>>2]=tempI64[1];break;case"float":HEAPF32[e>>2]=t;break;case"double":HEAPF64[e>>3]=t;break;default:abort("invalid type for setValue: "+r)}}function getValue(e,t,r){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return HEAP8[e>>0];case"i16":return HEAP16[e>>1];case"i32":case"i64":return HEAP32[e>>2];case"float":return HEAPF32[e>>2];case"double":return HEAPF64[e>>3];default:abort("invalid type for getValue: "+t)}return null}var ALLOC_NORMAL=0,ALLOC_STATIC=2,ALLOC_NONE=4;function allocate(e,t,r,n){var o,i;"number"==typeof e?(o=!0,i=e):(o=!1,i=e.length);var s,a="string"==typeof t?t:null;if(s=r==ALLOC_NONE?n:["function"==typeof _malloc?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][void 0===r?ALLOC_STATIC:r](Math.max(i,a?1:t.length)),o){var c;for(n=s,assert(0==(3&s)),c=s+(-4&i);n<c;n+=4)HEAP32[n>>2]=0;for(c=s+i;n<c;)HEAP8[n++>>0]=0;return s}if("i8"===a)return e.subarray||e.slice?HEAPU8.set(e,s):HEAPU8.set(new Uint8Array(e),s),s;for(var u,l,f,d=0;d<i;){var _=e[d];0!==(u=a||t[d])?("i64"==u&&(u="i32"),setValue(s+d,_,u),f!==u&&(l=getNativeTypeSize(u),f=u),d+=l):d++}return s}function Pointer_stringify(e,t){if(0===t||!e)return"";for(var r,n=0,o=0;n|=r=HEAPU8[e+o>>0],(0!=r||t)&&(o++,!t||o!=t););t||(t=o);var i="";if(n<128){for(var s;t>0;)s=String.fromCharCode.apply(String,HEAPU8.subarray(e,e+Math.min(t,1024))),i=i?i+s:s,e+=1024,t-=1024;return i}return UTF8ToString(e)}var UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function UTF8ArrayToString(e,t){for(var r=t;e[r];)++r;if(r-t>16&&e.subarray&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,r));for(var n,o,i,s,a,c="";;){if(!(n=e[t++]))return c;if(128&n)if(o=63&e[t++],192!=(224&n))if(i=63&e[t++],224==(240&n)?n=(15&n)<<12|o<<6|i:(s=63&e[t++],240==(248&n)?n=(7&n)<<18|o<<12|i<<6|s:(a=63&e[t++],n=248==(252&n)