cloudstudio
Version:
Run VS Code on a remote server.
1 lines • 103 kB
JavaScript
(()=>{var e={8309:(e,t,r)=>{"use strict";const s=r(2081),n=r(4605),o=r(3743);function i(e,t,r){const i=n(e,t,r),a=s.spawn(i.command,i.args,i.options);return o.hookChildProcess(a,i),a}e.exports=i,e.exports.spawn=i,e.exports.sync=function(e,t,r){const i=n(e,t,r),a=s.spawnSync(i.command,i.args,i.options);return a.error=a.error||o.verifyENOENTSync(a.status,i),a},e.exports._parse=n,e.exports._enoent=o},3743:e=>{"use strict";const t="win32"===process.platform;function r(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function s(e,s){return t&&1===e&&!s.file?r(s.original,"spawn"):null}e.exports={hookChildProcess:function(e,r){if(!t)return;const n=e.emit;e.emit=function(t,o){if("exit"===t){const t=s(o,r);if(t)return n.call(e,"error",t)}return n.apply(e,arguments)}},verifyENOENT:s,verifyENOENTSync:function(e,s){return t&&1===e&&!s.file?r(s.original,"spawnSync"):null},notFoundError:r}},4605:(e,t,r)=>{"use strict";const s=r(1017),n=r(2202),o=r(5081),i=r(7550),a="win32"===process.platform,c=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;e.exports=function(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null);const d={command:e,args:t=t?t.slice(0):[],options:r=Object.assign({},r),file:void 0,original:{command:e,args:t}};return r.shell?d:function(e){if(!a)return e;const t=function(e){e.file=n(e);const t=e.file&&i(e.file);return t?(e.args.unshift(e.file),e.command=t,n(e)):e.file}(e),r=!c.test(t);if(e.options.forceShell||r){const r=l.test(t);e.command=s.normalize(e.command),e.command=o.command(e.command),e.args=e.args.map((e=>o.argument(e,r)));const n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}(d)}},5081:e=>{"use strict";const t=/([()\][%!^"`<>&|;, *?])/g;e.exports.command=function(e){return e.replace(t,"^$1")},e.exports.argument=function(e,r){return e=(e=`"${e=(e=(e=`${e}`).replace(/(\\*)"/g,'$1$1\\"')).replace(/(\\*)$/,"$1$1")}"`).replace(t,"^$1"),r&&(e=e.replace(t,"^$1")),e}},7550:(e,t,r)=>{"use strict";const s=r(7147),n=r(2063);e.exports=function(e){const t=Buffer.alloc(150);let r;try{r=s.openSync(e,"r"),s.readSync(r,t,0,150,0),s.closeSync(r)}catch(e){}return n(t.toString())}},2202:(e,t,r)=>{"use strict";const s=r(1017),n=r(2806),o=r(3024);function i(e,t){const r=e.options.env||process.env,i=process.cwd(),a=null!=e.options.cwd,c=a&&void 0!==process.chdir&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch(e){}let l;try{l=n.sync(e.command,{path:r[o({env:r})],pathExt:t?s.delimiter:void 0})}catch(e){}finally{c&&process.chdir(i)}return l&&(l=s.resolve(a?e.options.cwd:"",l)),l}e.exports=function(e){return i(e)||i(e,!0)}},8468:(e,t,r)=>{"use strict";const s=r(1017),n=r(2081),o=r(8309),i=r(8150),a=r(6147),c=r(7678),l=r(4353),d=r(3111),{spawnedKill:u,spawnedCancel:h,setupTimeout:f,validateTimeout:p,setExitHandler:m}=r(3820),{handleInput:g,getSpawnedResult:_,makeAllStream:y,validateInputSync:v}=r(4994),{mergePromise:w,getSpawnedPromise:b}=r(1708),{joinCommand:S,parseCommand:x,getEscapedCommand:E}=r(4077),k=(e,t,r={})=>{const n=o._parse(e,t,r);return e=n.command,t=n.args,(r={maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(r=n.options).cwd||process.cwd(),execPath:process.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r}).env=(({env:e,extendEnv:t,preferLocal:r,localDir:s,execPath:n})=>{const o=t?{...process.env,...e}:e;return r?a.env({env:o,cwd:s,execPath:n}):o})(r),r.stdio=d(r),"win32"===process.platform&&"cmd"===s.basename(e,".exe")&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},C=(e,t,r)=>"string"==typeof t||Buffer.isBuffer(t)?e.stripFinalNewline?i(t):t:void 0===r?void 0:"",O=(e,t,r)=>{const s=k(e,t,r),o=S(e,t),i=E(e,t);let a;p(s.options);try{a=n.spawn(s.file,s.args,s.options)}catch(e){const t=new n.ChildProcess,r=Promise.reject(l({error:e,stdout:"",stderr:"",all:"",command:o,escapedCommand:i,parsed:s,timedOut:!1,isCanceled:!1,killed:!1}));return w(t,r)}const d=b(a),v=f(a,s.options,d),x=m(a,s.options,v),O={isCanceled:!1};a.kill=u.bind(null,a.kill.bind(a)),a.cancel=h.bind(null,a,O);const P=c((async()=>{const[{error:e,exitCode:t,signal:r,timedOut:n},c,d,u]=await _(a,s.options,x),h=C(s.options,c),f=C(s.options,d),p=C(s.options,u);if(e||0!==t||null!==r){const c=l({error:e,exitCode:t,signal:r,stdout:h,stderr:f,all:p,command:o,escapedCommand:i,parsed:s,timedOut:n,isCanceled:O.isCanceled,killed:a.killed});if(!s.options.reject)return c;throw c}return{command:o,escapedCommand:i,exitCode:0,stdout:h,stderr:f,all:p,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}));return g(a,s.options.input),a.all=y(a,s.options),w(a,P)};e.exports=O,e.exports.sync=(e,t,r)=>{const s=k(e,t,r),o=S(e,t),i=E(e,t);let a;v(s.options);try{a=n.spawnSync(s.file,s.args,s.options)}catch(e){throw l({error:e,stdout:"",stderr:"",all:"",command:o,escapedCommand:i,parsed:s,timedOut:!1,isCanceled:!1,killed:!1})}const c=C(s.options,a.stdout,a.error),d=C(s.options,a.stderr,a.error);if(a.error||0!==a.status||null!==a.signal){const e=l({stdout:c,stderr:d,error:a.error,signal:a.signal,exitCode:a.status,command:o,escapedCommand:i,parsed:s,timedOut:a.error&&"ETIMEDOUT"===a.error.code,isCanceled:!1,killed:null!==a.signal});if(!s.options.reject)return e;throw e}return{command:o,escapedCommand:i,exitCode:0,stdout:c,stderr:d,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},e.exports.command=(e,t)=>{const[r,...s]=x(e);return O(r,s,t)},e.exports.commandSync=(e,t)=>{const[r,...s]=x(e);return O.sync(r,s,t)},e.exports.node=(e,t,r={})=>{t&&!Array.isArray(t)&&"object"==typeof t&&(r=t,t=[]);const s=d.node(r),n=process.execArgv.filter((e=>!e.startsWith("--inspect"))),{nodePath:o=process.execPath,nodeOptions:i=n}=r;return O(o,[...i,e,...Array.isArray(t)?t:[]],{...r,stdin:void 0,stdout:void 0,stderr:void 0,stdio:s,shell:!1})}},4077:e=>{"use strict";const t=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],r=/^[\w.-]+$/,s=/"/g,n=/ +/g;e.exports={joinCommand:(e,r)=>t(e,r).join(" "),getEscapedCommand:(e,n)=>t(e,n).map((e=>(e=>"string"!=typeof e||r.test(e)?e:`"${e.replace(s,'\\"')}"`)(e))).join(" "),parseCommand:e=>{const t=[];for(const r of e.trim().split(n)){const e=t[t.length-1];e&&e.endsWith("\\")?t[t.length-1]=`${e.slice(0,-1)} ${r}`:t.push(r)}return t}}},4353:(e,t,r)=>{"use strict";const{signalsByName:s}=r(7787);e.exports=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:i,command:a,escapedCommand:c,timedOut:l,isCanceled:d,killed:u,parsed:{options:{timeout:h}}})=>{i=null===i?void 0:i;const f=void 0===(o=null===o?void 0:o)?void 0:s[o].description,p=`Command ${(({timedOut:e,timeout:t,errorCode:r,signal:s,signalDescription:n,exitCode:o,isCanceled:i})=>e?`timed out after ${t} milliseconds`:i?"was canceled":void 0!==r?`failed with ${r}`:void 0!==s?`was killed with ${s} (${n})`:void 0!==o?`failed with exit code ${o}`:"failed")({timedOut:l,timeout:h,errorCode:n&&n.code,signal:o,signalDescription:f,exitCode:i,isCanceled:d})}: ${a}`,m="[object Error]"===Object.prototype.toString.call(n),g=m?`${p}\n${n.message}`:p,_=[g,t,e].filter(Boolean).join("\n");return m?(n.originalMessage=n.message,n.message=_):n=new Error(_),n.shortMessage=g,n.command=a,n.escapedCommand=c,n.exitCode=i,n.signal=o,n.signalDescription=f,n.stdout=e,n.stderr=t,void 0!==r&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=Boolean(l),n.isCanceled=d,n.killed=u&&!l,n}},3820:(e,t,r)=>{"use strict";const s=r(2037),n=r(7908),o=(e,{forceKillAfterTimeout:t},r)=>i(e)&&!1!==t&&r,i=e=>e===s.constants.signals.SIGTERM||"string"==typeof e&&"SIGTERM"===e.toUpperCase(),a=({forceKillAfterTimeout:e=!0})=>{if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e};e.exports={spawnedKill:(e,t="SIGTERM",r={})=>{const s=e(t);return((e,t,r,s)=>{if(!o(t,r,s))return;const n=a(r),i=setTimeout((()=>{e("SIGKILL")}),n);i.unref&&i.unref()})(e,t,r,s),s},spawnedCancel:(e,t)=>{e.kill()&&(t.isCanceled=!0)},setupTimeout:(e,{timeout:t,killSignal:r="SIGTERM"},s)=>{if(0===t||void 0===t)return s;let n;const o=new Promise(((s,o)=>{n=setTimeout((()=>{((e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))})(e,r,o)}),t)})),i=s.finally((()=>{clearTimeout(n)}));return Promise.race([o,i])},validateTimeout:({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},setExitHandler:async(e,{cleanup:t,detached:r},s)=>{if(!t||r)return s;const o=n((()=>{e.kill()}));return s.finally((()=>{o()}))}}},1708:e=>{"use strict";const t=(async()=>{})().constructor.prototype,r=["then","catch","finally"].map((e=>[e,Reflect.getOwnPropertyDescriptor(t,e)]));e.exports={mergePromise:(e,t)=>{for(const[s,n]of r){const r="function"==typeof t?(...e)=>Reflect.apply(n.value,t(),e):n.value.bind(t);Reflect.defineProperty(e,s,{...n,value:r})}return e},getSpawnedPromise:e=>new Promise(((t,r)=>{e.on("exit",((e,r)=>{t({exitCode:e,signal:r})})),e.on("error",(e=>{r(e)})),e.stdin&&e.stdin.on("error",(e=>{r(e)}))}))}},3111:e=>{"use strict";const t=["stdin","stdout","stderr"],r=e=>{if(!e)return;const{stdio:r}=e;if(void 0===r)return t.map((t=>e[t]));if((e=>t.some((t=>void 0!==e[t])))(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${t.map((e=>`\`${e}\``)).join(", ")}`);if("string"==typeof r)return r;if(!Array.isArray(r))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof r}\``);const s=Math.max(r.length,t.length);return Array.from({length:s},((e,t)=>r[t]))};e.exports=r,e.exports.node=e=>{const t=r(e);return"ipc"===t?"ipc":void 0===t||"string"==typeof t?[t,t,t,"ipc"]:t.includes("ipc")?t:[...t,"ipc"]}},4994:(e,t,r)=>{"use strict";const s=r(4970),n=r(31),o=r(4034),i=async(e,t)=>{if(e){e.destroy();try{return await t}catch(e){return e.bufferedData}}},a=(e,{encoding:t,buffer:r,maxBuffer:s})=>{if(e&&r)return t?n(e,{encoding:t,maxBuffer:s}):n.buffer(e,{maxBuffer:s})};e.exports={handleInput:(e,t)=>{void 0!==t&&void 0!==e.stdin&&(s(t)?t.pipe(e.stdin):e.stdin.end(t))},makeAllStream:(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=o();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},getSpawnedResult:async({stdout:e,stderr:t,all:r},{encoding:s,buffer:n,maxBuffer:o},c)=>{const l=a(e,{encoding:s,buffer:n,maxBuffer:o}),d=a(t,{encoding:s,buffer:n,maxBuffer:o}),u=a(r,{encoding:s,buffer:n,maxBuffer:2*o});try{return await Promise.all([c,l,d,u])}catch(s){return Promise.all([{error:s,signal:s.signal,timedOut:s.timedOut},i(e,l),i(t,d),i(r,u)])}},validateInputSync:({input:e})=>{if(s(e))throw new TypeError("The `input` option cannot be a stream in sync mode")}}},5105:(e,t,r)=>{"use strict";const{PassThrough:s}=r(2781);e.exports=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n="buffer"===r;let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const i=new s({objectMode:o});r&&i.setEncoding(r);let a=0;const c=[];return i.on("data",(e=>{c.push(e),o?a=c.length:a+=e.length})),i.getBufferedValue=()=>t?c:n?Buffer.concat(c,a):c.join(""),i.getBufferedLength=()=>a,i}},31:(e,t,r)=>{"use strict";const{constants:s}=r(4300),n=r(2781),{promisify:o}=r(3837),i=r(5105),a=o(n.pipeline);class c extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function l(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=i(t);return await new Promise(((t,o)=>{const i=e=>{e&&n.getBufferedLength()<=s.MAX_LENGTH&&(e.bufferedData=n.getBufferedValue()),o(e)};(async()=>{try{await a(e,n),t()}catch(e){i(e)}})(),n.on("data",(()=>{n.getBufferedLength()>r&&i(new c)}))})),n.getBufferedValue()}e.exports=l,e.exports.buffer=(e,t)=>l(e,{...t,encoding:"buffer"}),e.exports.array=(e,t)=>l(e,{...t,array:!0}),e.exports.MaxBufferError=c},7:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SIGNALS=void 0,t.SIGNALS=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]},7787:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signalsByNumber=t.signalsByName=void 0;var s=r(2037),n=r(8699),o=r(7603);const i=(0,n.getSignals)().reduce((function(e,{name:t,number:r,description:s,supported:n,action:o,forced:i,standard:a}){return{...e,[t]:{name:t,number:r,description:s,supported:n,action:o,forced:i,standard:a}}}),{});t.signalsByName=i;const a=function(e,t){const r=t.find((({name:t})=>s.constants.signals[t]===e));return void 0!==r?r:t.find((t=>t.number===e))},c=function(){const e=(0,n.getSignals)(),t=o.SIGRTMAX+1,r=Array.from({length:t},((t,r)=>function(e,t){const r=a(e,t);if(void 0===r)return{};const{name:s,description:n,supported:o,action:i,forced:c,standard:l}=r;return{[e]:{name:s,number:e,description:n,supported:o,action:i,forced:c,standard:l}}}(r,e)));return Object.assign({},...r)}();t.signalsByNumber=c},7603:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SIGRTMAX=t.getRealtimeSignals=void 0,t.getRealtimeSignals=function(){const e=n-s+1;return Array.from({length:e},r)};const r=function(e,t){return{name:`SIGRT${t+1}`,number:s+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},s=34,n=64;t.SIGRTMAX=n},8699:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSignals=void 0;var s=r(2037),n=r(7),o=r(7603);t.getSignals=function(){const e=(0,o.getRealtimeSignals)();return[...n.SIGNALS,...e].map(i)};const i=function({name:e,number:t,description:r,action:n,forced:o=!1,standard:i}){const{signals:{[e]:a}}=s.constants,c=void 0!==a;return{name:e,number:c?a:t,description:r,supported:c,action:n,forced:o,standard:i}}},4970:e=>{"use strict";const t=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;t.writable=e=>t(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState,t.readable=e=>t(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState,t.duplex=e=>t.writable(e)&&t.readable(e),t.transform=e=>t.duplex(e)&&"function"==typeof e._transform&&"object"==typeof e._transformState,e.exports=t},1959:(e,t,r)=>{var s;function n(e,t,r){if("function"==typeof t&&(r=t,t={}),!r){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise((function(r,s){n(e,t||{},(function(e,t){e?s(e):r(t)}))}))}s(e,t||{},(function(e,s){e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,s=!1),r(e,s)}))}r(7147),s="win32"===process.platform||global.TESTING_WINDOWS?r(1429):r(4601),e.exports=n,n.sync=function(e,t){try{return s.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||"EACCES"===e.code)return!1;throw e}}},4601:(e,t,r)=>{e.exports=n,n.sync=function(e,t){return o(s.statSync(e),t)};var s=r(7147);function n(e,t,r){s.stat(e,(function(e,s){r(e,!e&&o(s,t))}))}function o(e,t){return e.isFile()&&function(e,t){var r=e.mode,s=e.uid,n=e.gid,o=void 0!==t.uid?t.uid:process.getuid&&process.getuid(),i=void 0!==t.gid?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8);return r&parseInt("001",8)||r&c&&n===i||r&a&&s===o||r&(a|c)&&0===o}(e,t)}},1429:(e,t,r)=>{e.exports=o,o.sync=function(e,t){return n(s.statSync(e),e,t)};var s=r(7147);function n(e,t,r){return!(!e.isSymbolicLink()&&!e.isFile())&&function(e,t){var r=void 0!==t.pathExt?t.pathExt:process.env.PATHEXT;if(!r)return!0;if(-1!==(r=r.split(";")).indexOf(""))return!0;for(var s=0;s<r.length;s++){var n=r[s].toLowerCase();if(n&&e.substr(-n.length).toLowerCase()===n)return!0}return!1}(t,r)}function o(e,t,r){s.stat(e,(function(s,o){r(s,!s&&n(o,e,t))}))}},4034:(e,t,r)=>{"use strict";const{PassThrough:s}=r(2781);e.exports=function(){var e=[],t=new s({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(s){return Array.isArray(s)?(s.forEach(r),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}function n(){return 0==e.length}function o(r){!(e=e.filter((function(e){return e!==r}))).length&&t.readable&&t.end()}}},4341:e=>{"use strict";const t=(e,t)=>{for(const r of Reflect.ownKeys(t))Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));return e};e.exports=t,e.exports.default=t},6147:(e,t,r)=>{"use strict";const s=r(1017),n=r(3024),o=e=>{let t;e={cwd:process.cwd(),path:process.env[n()],execPath:process.execPath,...e};let r=s.resolve(e.cwd);const o=[];for(;t!==r;)o.push(s.join(r,"node_modules/.bin")),t=r,r=s.resolve(r,"..");const i=s.resolve(e.cwd,e.execPath,"..");return o.push(i),o.concat(e.path).join(s.delimiter)};e.exports=o,e.exports.default=o,e.exports.env=t=>{const r={...(t={env:process.env,...t}).env},s=n({env:r});return t.path=r[s],r[s]=e.exports(t),r}},7678:(e,t,r)=>{"use strict";const s=r(4341),n=new WeakMap,o=(e,t={})=>{if("function"!=typeof e)throw new TypeError("Expected a function");let r,o=0;const i=e.displayName||e.name||"<anonymous>",a=function(...s){if(n.set(a,++o),1===o)r=e.apply(this,s),e=null;else if(!0===t.throw)throw new Error(`Function \`${i}\` can only be called once`);return r};return s(a,e),n.set(a,o),a};e.exports=o,e.exports.default=o,e.exports.callCount=e=>{if(!n.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return n.get(e)}},3024:e=>{"use strict";const t=(e={})=>{const t=e.env||process.env;return"win32"!==(e.platform||process.platform)?"PATH":Object.keys(t).reverse().find((e=>"PATH"===e.toUpperCase()))||"Path"};e.exports=t,e.exports.default=t},2063:(e,t,r)=>{"use strict";const s=r(9395);e.exports=(e="")=>{const t=e.match(s);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return"env"===o?n:n?`${o} ${n}`:o}},9395:e=>{"use strict";e.exports=/^#!(.*)/},7908:(e,t,r)=>{var s,n=r(9491),o=r(5397),i=/^win/i.test(process.platform),a=r(2361);function c(){u&&(u=!1,o.forEach((function(e){try{process.removeListener(e,d[e])}catch(e){}})),process.emit=m,process.reallyExit=f,s.count-=1)}function l(e,t,r){s.emitted[e]||(s.emitted[e]=!0,s.emit(e,t,r))}"function"!=typeof a&&(a=a.EventEmitter),process.__signal_exit_emitter__?s=process.__signal_exit_emitter__:((s=process.__signal_exit_emitter__=new a).count=0,s.emitted={}),s.infinite||(s.setMaxListeners(1/0),s.infinite=!0),e.exports=function(e,t){n.equal(typeof e,"function","a callback must be provided for exit handler"),!1===u&&h();var r="exit";return t&&t.alwaysLast&&(r="afterexit"),s.on(r,e),function(){s.removeListener(r,e),0===s.listeners("exit").length&&0===s.listeners("afterexit").length&&c()}},e.exports.unload=c;var d={};o.forEach((function(e){d[e]=function(){process.listeners(e).length===s.count&&(c(),l("exit",null,e),l("afterexit",null,e),i&&"SIGHUP"===e&&(e="SIGINT"),process.kill(process.pid,e))}})),e.exports.signals=function(){return o},e.exports.load=h;var u=!1;function h(){u||(u=!0,s.count+=1,o=o.filter((function(e){try{return process.on(e,d[e]),!0}catch(e){return!1}})),process.emit=g,process.reallyExit=p)}var f=process.reallyExit;function p(e){process.exitCode=e||0,l("exit",process.exitCode,null),l("afterexit",process.exitCode,null),f.call(process,process.exitCode)}var m=process.emit;function g(e,t){if("exit"===e){void 0!==t&&(process.exitCode=t);var r=m.apply(this,arguments);return l("exit",process.exitCode,null),l("afterexit",process.exitCode,null),r}return m.apply(this,arguments)}},5397:e=>{e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],"win32"!==process.platform&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")},861:(e,t,r)=>{"use strict";const{Transform:s}=r(2781),{StringDecoder:n}=r(1576),o=Symbol("last"),i=Symbol("decoder");function a(e,t,r){let s;if(this.overflow){if(s=this[i].write(e).split(this.matcher),1===s.length)return r();s.shift(),this.overflow=!1}else this[o]+=this[i].write(e),s=this[o].split(this.matcher);this[o]=s.pop();for(let e=0;e<s.length;e++)try{l(this,this.mapper(s[e]))}catch(e){return r(e)}this.overflow=this[o].length>this.maxLength,!this.overflow||this.skipOverflow?r():r(new Error("maximum buffer reached"))}function c(e){if(this[o]+=this[i].end(),this[o])try{l(this,this.mapper(this[o]))}catch(t){return e(t)}e()}function l(e,t){void 0!==t&&e.push(t)}function d(e){return e}e.exports=function(e,t,r){switch(e=e||/\r?\n/,t=t||d,r=r||{},arguments.length){case 1:"function"==typeof e?(t=e,e=/\r?\n/):"object"!=typeof e||e instanceof RegExp||(r=e,e=/\r?\n/);break;case 2:"function"==typeof e?(r=t,t=e,e=/\r?\n/):"object"==typeof t&&(r=t,t=d)}(r=Object.assign({},r)).autoDestroy=!0,r.transform=a,r.flush=c,r.readableObjectMode=!0;const l=new s(r);return l[o]="",l[i]=new n("utf8"),l.matcher=e,l.mapper=t,l.maxLength=r.maxLength,l.skipOverflow=r.skipOverflow||!1,l.overflow=!1,l._destroy=function(e,t){this._writableState.errorEmitted=!1,t(e)},l}},8150:e=>{"use strict";e.exports=e=>{const t="string"==typeof e?"\n":"\n".charCodeAt(),r="string"==typeof e?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,e.length-1)),e[e.length-1]===r&&(e=e.slice(0,e.length-1)),e}},6758:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserError=void 0;class r extends Error{}t.UserError=r},112:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.deactivate=t.activate=void 0;const i=o(r(9496)),a=r(6409),c=r(457),l=r(2037);let d;t.activate=function(e){var t,r;d=new a.SessionManager(new c.BrowserSpawner(null!==(r=null===(t=e.storageUri)||void 0===t?void 0:t.fsPath)&&void 0!==r?r:(0,l.tmpdir)(),e)),e.subscriptions.push(i.commands.registerCommand("js-debug-companion.launchAndAttach",(e=>{null==d||d.create(e).catch((e=>i.window.showErrorMessage(e.message)))})),i.commands.registerCommand("js-debug-companion.kill",(({launchId:e})=>{null==d||d.destroy(e)})))},t.deactivate=function(){null==d||d.dispose(),d=void 0}},5896:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.exists=void 0;const n=r(7147);t.exists=function(e){return s(this,void 0,void 0,(function*(){try{return yield n.promises.access(e),!0}catch(e){return!1}}))}},8224:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},i=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getWSEndpoint=t.retryGetWSEndpoint=void 0;const a=o(r(3685)),c=r(7310);function l(e,t){return i(this,void 0,void 0,(function*(){const r=yield d((0,c.resolve)(e,"/json/version"),t);if(null==r?void 0:r.webSocketDebuggerUrl)return u(e,r.webSocketDebuggerUrl);const s=yield d((0,c.resolve)(e,"/json/list"),t);if(null==s?void 0:s.length)return u(e,s[0].webSocketDebuggerUrl);throw new Error("Could not find any debuggable target")}))}function d(e,t){return i(this,void 0,void 0,(function*(){return JSON.parse(yield function(e,t){const r=[];return new Promise(((s,n)=>{const o=a.request(e,{headers:{host:"localhost"}},(e=>{r.push(t.onCancellationRequested((()=>e.destroy())));let o="";e.setEncoding("utf8"),e.on("data",(e=>o+=e)),e.on("end",(()=>s(o))),e.on("error",n)}));r.push(t.onCancellationRequested((()=>{o.destroy(),n(new Error(`Cancelled GET ${e}`))}))),o.on("error",n),o.end()})).finally((()=>r.forEach((e=>e.dispose()))))}(e,t))}))}function u(e,t){const r=new c.URL(e),s=new c.URL(t);return s.host=r.host,s.toString()}t.retryGetWSEndpoint=function e(t,r){return i(this,void 0,void 0,(function*(){try{return yield l(t,r)}catch(s){if(r.isCancellationRequested)throw new Error(`Could not connect to debug target at ${t}: ${s}`);return yield new Promise((e=>setTimeout(e,200))),e(t,r)}}))},t.getWSEndpoint=l},3928:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Session=void 0;const n=r(7310),o=r(9496),i=s(r(8777));class a{constructor(){this.qOrFn=[]}push(e){"function"==typeof this.qOrFn?this.qOrFn(e):this.qOrFn.push(e)}connect(e){if("function"==typeof this.qOrFn)throw new Error("Already connected");const t=this.qOrFn;this.qOrFn=e;for(const r of t)e(r)}}t.Session=class{constructor(){this.errorEmitter=new o.EventEmitter,this.onError=this.errorEmitter.event,this.closeEmitter=new o.EventEmitter,this.onClose=this.closeEmitter.event,this.disposed=!1,this.fromSocketQueue=new a,this.fromBrowserQueue=new a,this.onClose((()=>this.dispose())),this.onError((()=>this.dispose()))}attachSocket(e,t,r){const s=new n.URL(`ws://${e}:${t}${r}`);this.attachSocketLoop(s,Date.now()+5e3)}attachChild(e){this.disposed?e.dispose():(this.browserProcess=e,e.onClose((()=>this.closeEmitter.fire())),e.onError((e=>this.errorEmitter.fire(e))),e.onMessage((e=>this.fromBrowserQueue.push(e))),this.fromSocketQueue.connect((t=>e.send(t))))}dispose(){var e,t;this.disposed||(null===(e=this.browserProcess)||void 0===e||e.dispose(),null===(t=this.socket)||void 0===t||t.close(),this.disposed=!0)}attachSocketLoop(e,t){if(this.disposed)return;const r=new i.default(e,{perMessageDeflate:!0});r.on("open",(()=>{this.disposed?r.close():(this.socket=r,this.socket.on("close",(()=>this.closeEmitter.fire())),this.socket.on("message",(e=>this.fromSocketQueue.push(e))),this.fromBrowserQueue.connect((e=>r.send(e))))})),r.on("error",(s=>{this.socket===r||Date.now()>t?this.errorEmitter.fire(s):setTimeout((()=>this.attachSocketLoop(e,t)),100)}))}}},6409:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},i=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.SessionManager=void 0;const a=o(r(9496)),c=r(3928),l=r(8389);t.SessionManager=class{constructor(e){this.spawn=e,this.sessions=new Map}create(e){return i(this,void 0,void 0,(function*(){const t=new c.Session;this.sessions.set(e.launchId,t),t.onClose((()=>this.sessions.delete(e.launchId))),t.onError((t=>{a.window.showErrorMessage(`Error running browserasd: ${t.message||t.stack}`),this.sessions.delete(e.launchId)})),yield Promise.all([this.addChildSocket(t,e),e.attach?this.addChildAttach(t,e.attach):this.addChildBrowser(t,e)])}))}destroy(e){const t=this.sessions.get(e);null==t||t.dispose(),this.sessions.delete(e)}dispose(){for(const e of this.sessions.values())e.dispose();this.sessions.clear()}addChildSocket(e,t){return i(this,void 0,void 0,(function*(){const[r,s]=t.proxyUri.split(":");e.attachSocket(r,Number(s),t.path)}))}addChildBrowser(e,t){return i(this,void 0,void 0,(function*(){const r=yield this.spawn.launch(t);e.attachChild(r)}))}addChildAttach(e,t){return i(this,void 0,void 0,(function*(){const r=yield l.AttachTarget.create(t.host,t.port);e.attachChild(r)}))}}},457:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},i=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((s=s.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserSpawner=void 0;const c=r(2081),l=a(r(8468)),d=r(7147),u=r(1017),h=r(2331),f=o(r(8472)),p=r(6758),m=r(5896),g=r(8389),_=f.loadMessageBundle(),y="--remote-debugging-port=",v="--remote-debugging-port=",w="availableBrowsers_";t.BrowserSpawner=class{constructor(e,t){this.storagePath=e,this.context=t,this.finders={edge:new h.EdgeBrowserFinder(process.env,d.promises,l.default),chrome:new h.ChromeBrowserFinder(process.env,d.promises,l.default)}}findBrowserPath(e,t){var r;return i(this,void 0,void 0,(function*(){if("*"!==t&&!(0,h.isQuality)(t))return t;if(!this.finders.hasOwnProperty(e))throw new p.UserError(`Browser type "${e}" is not supported.`);const s=this.context.globalState.get(w+e)||(yield this.finders[e].findAll()),n="*"===t?null!==(r=s.find((e=>"stable"===e.quality)))&&void 0!==r?r:s[0]:s.find((e=>e.quality===t));if(!n)throw yield this.context.globalState.update(w+e,void 0),"stable"!==t||s.length?new p.UserError(_("browserVersionNotFound",'Unable to find {0} version {1}. Available auto-discovered versions are: {2}. You can set the "runtimeExecutable" in your launch.json to one of these, or provide an absolute path to the browser executable.',e,t,JSON.stringify([...new Set(s)]))):new p.UserError(_("noBrowserInstallFound",'Unable to find a {0} installation on your system. Try installing it, or providing an absolute path to the browser in the "runtimeExecutable" in your launch.json.',e));return yield this.context.globalState.update(w+e,s),n.path}))}findBrowserByExe(e,t){var r;return i(this,void 0,void 0,(function*(){if("*"===t){const t=(yield e.findWhere((e=>"stable"===e.quality)))||(yield e.findAll())[0];return null==t?void 0:t.path}return(0,h.isQuality)(t)?null===(r=yield e.findWhere((e=>e.quality===t)))||void 0===r?void 0:r.path:t}))}getUserDataDir(e){var t;return i(this,void 0,void 0,(function*(){const r=e.params.userDataDir;if(!1===r)return;const s=(0,u.join)(this.storagePath,(null===(t=e.browserArgs)||void 0===t?void 0:t.includes("--headless"))?".headless-profile":".profile");return!0===r?s:(yield(0,m.exists)(r))?r:s}))}launch(e){var t;return i(this,void 0,void 0,(function*(){const r=yield this.findBrowserPath(e.type,e.params.runtimeExecutable),s=e.browserArgs.slice(),n=yield this.getUserDataDir(e);void 0!==n&&s.unshift(`--user-data-dir=${n}`);let o=e.params.cwd||e.params.webRoot;o&&(yield(0,m.exists)(o))||(o=process.cwd());const i=null===(t=s.find((e=>e.startsWith(y))))||void 0===t?void 0:t.slice(y.length);if(!i)return new g.PipedTarget((0,c.spawn)(r,s,{detached:"win32"!==process.platform,env:Object.assign(Object.assign(Object.assign({},process.env),{GDK_PIXBUF_MODULEDIR:void 0,GDK_PIXBUF_MODULE_FILE:void 0,ELECTRON_RUN_AS_NODE:void 0}),e.params.env),stdio:["ignore","ignore","ignore","pipe","pipe"],cwd:o}));s.includes(v)||s.unshift(v);const a=(0,c.spawn)(r,s,{detached:"win32"!==process.platform,env:Object.assign({ELECTRON_RUN_AS_NODE:void 0},e.params.env),stdio:"ignore",cwd:o});return yield g.ServerTarget.create(a,Number(i))}))}}},8389:function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ServerTarget=t.AttachTarget=t.PipedTarget=void 0;const o=n(r(861)),i=r(9496),a=n(r(8777)),c=r(8224),l=e=>s(void 0,void 0,void 0,(function*(){e.exitCode||(yield Promise.race([new Promise((t=>e.on("exit",t))),new Promise((e=>setTimeout(e,1e3)))]))}));t.PipedTarget=class{constructor(e){if(this.process=e,this.errorEmitter=new i.EventEmitter,this.closeEmitter=new i.EventEmitter,this.messageEmitter=new i.EventEmitter,this.onError=this.errorEmitter.event,this.onClose=this.closeEmitter.event,this.onMessage=this.messageEmitter.event,this.process.stdio.length<5)throw new Error("Insufficient fd number on child process");e.on("error",(e=>this.errorEmitter.fire(e))),e.on("exit",(()=>this.closeEmitter.fire())),e.stdio[4].pipe((0,o.default)("\0")).on("data",(e=>this.messageEmitter.fire(e))).resume()}send(e){const t=this.process.stdio[3];if(e instanceof Uint8Array)t.write(e);else if(e instanceof ArrayBuffer)t.write(new Uint8Array(e));else for(const r of e)t.write(r);t.write("\0")}dispose(){return s(this,void 0,void 0,(function*(){yield l(this.process),this.process.kill()}))}};class d{constructor(e){this.ws=e,this.errorEmitter=new i.EventEmitter,this.closeEmitter=new i.EventEmitter,this.messageEmitter=new i.EventEmitter,this.onError=this.errorEmitter.event,this.onClose=this.closeEmitter.event,this.onMessage=this.messageEmitter.event,e.on("error",(e=>this.errorEmitter.fire(e))),e.on("close",(()=>this.closeEmitter.fire())),e.on("message",(e=>this.messageEmitter.fire(e)))}static create(e,t){return s(this,void 0,void 0,(function*(){const r=new i.CancellationTokenSource;setTimeout((()=>r.cancel()),1e4);const s=yield(0,c.retryGetWSEndpoint)(`http://${e}:${t}`,r.token),n=new a.default(s,[],{headers:{host:"localhost"},perMessageDeflate:!1,maxPayload:268435456,followRedirects:!0});return yield new Promise(((e,t)=>{n.addEventListener("open",(()=>e(new d(n)))),n.addEventListener("error",(e=>t(e.error)))}))}))}send(e){this.ws.send(e.toString())}dispose(){return s(this,void 0,void 0,(function*(){yield new Promise((e=>{this.ws.on("close",e),this.ws.close()}))}))}}t.AttachTarget=d;class u{constructor(e,t){this.process=e,this.attach=t,this.errorEmitter=new i.EventEmitter,this.closeEmitter=new i.EventEmitter,this.messageEmitter=new i.EventEmitter,this.onError=this.errorEmitter.event,this.onClose=this.closeEmitter.event,this.onMessage=this.messageEmitter.event,e.on("error",(e=>this.errorEmitter.fire(e))),e.on("close",(()=>this.closeEmitter.fire())),t.onError((e=>this.errorEmitter.fire(e))),t.onClose((()=>this.closeEmitter.fire())),t.onMessage((e=>this.messageEmitter.fire(e)))}static create(e,t){return s(this,void 0,void 0,(function*(){const r=new i.CancellationTokenSource;setTimeout((()=>r.cancel()),1e4);try{const r=yield d.create("localhost",t);return new u(e,r)}catch(t){throw e.kill(),t}}))}send(e){this.attach.send(e)}dispose(){return s(this,void 0,void 0,(function*(){this.attach.dispose(),yield l(this.process),this.process.kill()}))}}t.ServerTarget=u},9135:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarwinChromeBrowserFinder=void 0;const s=r(690),n=r(1668);class o extends n.DarwinFinderBase{constructor(){super(...arguments),this.wellKnownPaths=[{path:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",quality:"stable"},{path:"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",quality:"canary"},{path:"/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta",quality:"beta"},{path:"/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev",quality:"dev"}]}async findAll(){const e=await this.findLaunchRegisteredApps("google chrome\\( canary\\)\\?.app",["/Applications/Google Chrome.app","/Applications/Google Chrome Canary.app"],["/Contents/MacOS/Google Chrome Canary","/Contents/MacOS/Google Chrome"]);return(0,s.sort)(e,this.createPriorities([{name:"Chrome.app",weight:0,quality:"stable"},{name:"Chrome Canary.app",weight:1,quality:"canary"}]))}getPreferredPath(){return this.env.CHROME_PATH}}t.DarwinChromeBrowserFinder=o},9143:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarwinEdgeBrowserFinder=void 0;const s=r(690),n=r(1668);class o extends n.DarwinFinderBase{constructor(){super(...arguments),this.wellKnownPaths=[{path:"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",quality:"stable"},{path:"/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary",quality:"canary"},{path:"/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta",quality:"beta"},{path:"/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev",quality:"dev"}]}async findAll(){const e=await this.findLaunchRegisteredApps("Microsoft Edge[A-Za-z ]*.app",["/Applications/Microsoft Edge.app"],["/Contents/MacOS/Microsoft Edge Canary","/Contents/MacOS/Microsoft Edge Beta","/Contents/MacOS/Microsoft Edge Dev","/Contents/MacOS/Microsoft Edge"]);return(0,s.sort)(e,this.createPriorities([{name:"Microsoft Edge.app",weight:0,quality:"stable"},{name:"Microsoft Edge Canary.app",weight:1,quality:"canary"},{name:"Microsoft Edge Beta.app",weight:2,quality:"beta"},{name:"Microsoft Edge Dev.app",weight:3,quality:"dev"}]))}getPreferredPath(){return this.env.EDGE_PATH}}t.DarwinEdgeBrowserFinder=o},1668:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarwinFinderBase=void 0;const s=r(1017),n=r(690),o=/( \(0x[a-f0-9]+\))/;t.DarwinFinderBase=class{constructor(e,t,r){this.env=e,this.fs=t,this.execa=r,this.lsRegisterCommand="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump",this.wellKnownPaths=[]}async findWhere(e){for(const t of this.wellKnownPaths)if(e(t)&&await(0,n.canAccess)(this.fs,t.path))return t;return(await this.findAll()).find(e)}async findLaunchRegisteredApps(e,t,r){const{stdout:n}=await this.execa.command(`${this.lsRegisterCommand} | awk '$0 ~ /${e}${o.source}?$/ { $1=""; print $0 }'`,{shell:!0,stdio:"pipe"}),i=[...t,...n.split("\n").map((e=>e.trim().replace(o,"")))].filter((e=>!!e)),a=this.getPreferredPath();a&&i.push(a);const c=new Set;for(const e of i)for(const t of r){const r=s.posix.join(e.trim(),t);try{await this.fs.access(r),c.add(r)}catch(e){}}return c}createPriorities(e){const t=this.env.HOME&&(0,n.escapeRegexSpecialChars)(this.env.HOME),r=this.getPreferredPath(),s=e.reduce(((e,r)=>[...e,{regex:new RegExp(`^/Applications/.*${r.name}`),weight:r.weight+100,quality:r.quality},{regex:new RegExp(`^${t}/Applications/.*${r.name}`),weight:r.weight,quality:r.quality},{regex:new RegExp(`^/Volumes/.*${r.name}`),weight:r.weight-100,quality:r.quality}]),[]);return r&&s.unshift({regex:new RegExp((0,n.escapeRegexSpecialChars)(r)),weight:151,quality:"custom"}),s}}},2331:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EdgeBrowserFinder=t.ChromeBrowserFinder=t.isQuality=t.allQualities=void 0;const s=r(9135),n=r(9143),o=r(8651),i=r(6718),a=r(9498),c=r(3061);t.allQualities=new Set(Object.keys({canary:null,stable:null,beta:null,dev:null,custom:null})),t.isQuality=e=>t.allQualities.has(e),t.ChromeBrowserFinder="win32"===process.platform?a.WindowsChromeBrowserFinder:"darwin"===process.platform?s.DarwinChromeBrowserFinder:o.LinuxChromeBrowserFinder,t.EdgeBrowserFinder="win32"===process.platform?c.WindowsEdgeBrowserFinder:"darwin"===process.platform?n.DarwinEdgeBrowserFinder:i.LinuxEdgeBrowserFinder},8651:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LinuxChromeBrowserFinder=void 0;const s=r(1017),n=r(690),o=r(2081),i=r(2037),a=/\r?\n/;t.LinuxChromeBrowserFinder=class{constructor(e,t){this.env=e,this.fs=t,this.pathEnvironmentVar="CHROME_PATH",this.priorities=[{regex:/chrome-wrapper$/,weight:54,quality:"custom"},{regex:/google-chrome-dev$/,weight:53,quality:"dev"},{regex:/google-chrome-canary$/,weight:52,quality:"canary"},{regex:/google-chrome-unstable$/,weight:51,quality:"canary"},{regex:/google-chrome-canary$/,weight:51,quality:"canary"},{regex:/google-chrome-stable$/,weight:50,quality:"stable"},{regex:/google-chrome$/,weight:49,quality:"stable"},{regex:/chromium-browser$/,weight:48,quality:"custom"},{regex:/chromium$/,weight:47,quality:"custom"}],this.executablesOnPath=["google-chrome-unstable","google-chrome-dev","google-chrome-beta","google-chrome-canary","google-chrome-stable","google-chrome","chromium-browser","chromium"]}async findWhere(e){return(await this.findAll()).find(e)}async findAll(){const e=new Set,t=this.env[this.pathEnvironmentVar];if(t&&await(0,n.canAccess)(this.fs,t)&&e.add(t),[s.posix.join((0,i.homedir)(),".local/share/applications/"),"/usr/share/applications/","/usr/bin"].forEach((t=>{for(const r in this.findChromeExecutables(t))e.add(r)})),await Promise.all(this.executablesOnPath.map((async t=>{try{const r=(0,o.execFileSync)("which",[t],{stdio:"pipe"}).toString().split(a)[0];await(0,n.canAccess)(this.fs,r)&&e.add(r)}catch(e){}}))),!e.size)throw new Error(`The environment variable ${t} must be set to executable of a build of the browser.`);const r=t?[{regex:new RegExp((0,n.escapeRegexSpecialChars)(t)),weight:101,quality:"custom"}].concat(this.priorities):this.priorities;return(0,n.sort)(e,r)}async findChromeExecutables(e){const t=/(^[^ ]+).*/,r=`^Exec=/.*/(${this.executablesOnPath.join("|")})-.*`,s=[];if(await(0,n.canAccess)(this.fs,e)){let i;try{i=(0,o.execSync)(`grep -ER "${r}" ${e} | awk -F '=' '{print $2}'`)}catch(t){i=(0,o.execSync)(`grep -Er "${r}" ${e} | awk -F '=' '{print $2}'`)}const c=i.toString().split(a).map((e=>e.replace(t,"$1")));await Promise.all(c.map((async e=>{await(0,n.canAccess)(this.fs,e)&&s.push(e)})))}return s}}},6718:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LinuxEdgeBrowserFinder=void 0;const s=r(8651);class n extends s.LinuxChromeBrowserFinder{constructor(){super(...arguments),this.pathEnvironmentVar="EDGE_PATH",this.executablesOnPath=["microsoft-edge-dev","microsoft-edge-beta","microsoft-edge-stable","microsoft-edge"],this.priorities=[{regex:/microsoft-edge\-wrapper$/,weight:52,quality:"custom"},{regex:/microsoft-edge\-dev$/,weight:51,quality:"dev"},{regex:/microsoft-edge\-beta$/,weight:51,quality:"beta"},{regex:/microsoft-edge\-stable$/,weight:50,quality:"stable"},{regex:/microsoft-edge$/,weight:49,quality:"stable"}]}}t.LinuxEdgeBrowserFinder=n},690:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findWindowsCandidates=t.sort=t.preferredEdgePath=t.preferredChromePath=t.escapeRegexSpecialChars=t.canAccess=void 0;const s=r(1017);async function n({access:e},t){if(!t)return!1;try{return await e(t),!0}catch(e){return!1}}t.canAccess=n,t.escapeRegexSpecialChars=function(e,t){const r="/\\.?*()^${}|[]+".split("").filter((e=>!t||t.indexOf(e)<0)).join("").replace(/[\\\]]/g,"\\$&"),s=new RegExp(`[${r}]`,"g");return e.replace(s,"\\$&")},t.preferredChromePath=async function(e,t){if(await n(e,t.CHROME_PATH))return t.CHROME_PATH},t.preferredEdgePath=async function(e,t){if(await n(e,t.EDGE_PATH))return t.EDGE_PATH},t.sort=function(e,t){return[...e].filter((e=>!!e)).map((e=>{const r=t.find((t=>t.regex.test(e)));return r?{path:e,weight:r.weight,quality:r.quality}:{path:e,weight:10,quality:"dev"}})).sort(((e,t)=>t.weight-e.weight)).map((e=>({path:e.path,quality:e.quality})))},t.findWindowsCandidates=async function(e,t,r){const o=[e.LOCALAPPDATA,e.PROGRAMFILES,e["PROGRAMFILES(X86)"]].filter((e=>!!e)),i=[];for(const e of o)for(const o of r){const r=s.win32.join(e,o.name);i.push(n(t,r).then((e=>e?{path:r,quality:o.type}:void 0)))}return(await Promise.all(i)).filter((e=>!!e))}},9498:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WindowsChromeBrowserFinder=void 0;const s=r(1017),n=r(690);t.WindowsChromeBrowserFinder=class{constructor(e,t){this.env=e,this.fs=t}async findWhere(e){return(await this.findAll()).find(e)}async findAll(){const e=s.win32.sep,t=[{name:`${e}Google${e}Chrome Dev${e}Application${e}chrome.exe`,type:"dev"},{name:`${e}Google${e}Chrome SxS${e}Application${e}chrome.