text: /*---------------------------------------------------------------------------------------------
   *  Copyright (c) Microsoft Corporation. All rights reserved.
   *--------------------------------------------------------------------------------------------*/
  
  var Dn=Object.create;var I=Object.defineProperty,Hn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptor,Gn=Object.getOwnPropertyDescriptors,Fn=Object.getOwnPropertyNames,Ee=Object.getOwnPropertySymbols,Wn=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Se=(r,e,t)=>e in r?I(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,S=(r,e)=>{for(var t in e||(e={}))ke.call(e,t)&&Se(r,t,e[t]);if(Ee)for(var t of Ee(e))Yn.call(e,t)&&Se(r,t,e[t]);return r},Pe=(r,e)=>Hn(r,Gn(e)),Be=r=>I(r,"__esModule",{value:!0});var c=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Kn=(r,e)=>{Be(r);for(var t in e)I(r,t,{get:e[t],enumerable:!0})},Qn=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fn(e))!ke.call(r,n)&&n!=="default"&&I(r,n,{get:()=>e[n],enumerable:!(t=Mn(e,n))||t.enumerable});return r},P=r=>Qn(Be(I(r!=null?Dn(Wn(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var ne=c((Ai,Oe)=>{Oe.exports=function(e,t,n){e(t),n&&n(t===!0?null:t)}});var H=c((Ti,Te)=>{"use strict";var Ae=ne();Te.exports=function(e,t){if(!e)return function(u,i){return u?Ae(i,u,t):i(!0)};Array.isArray(e)||(e=Object.keys(e).map(function(u){return e[u]}));var n=0;return function(u,i){if(u)return Ae(i,u,t);n>=e.length?i(!0):i(null,e[n++])}}});var Ne=c((Ci,Ce)=>{"use strict";var zn=H();Ce.exports=function(r){return zn(Object.keys(r))}});var ue=c((Ni,Re)=>{"use strict";var Vn=ne();Re.exports=function(e,t){return function(n,u){if(n)return Vn(u,n,t);if(e!=null){var i=e;e=null,u(null,i)}else u(!0)}}});var Le=c((Ri,Ie)=>{"use strict";Ie.exports=function(e){var t=0;return e=e||1/0,function(n,u){if(n)return u&&u(n);if(t>e)return u(!0);u(null,t++)}}});var Je=c((Ii,Ue)=>{"use strict";Ue.exports=function(e){return e=e||Math.random,function(t,n){return t?n&&n(t):n(null,e())}}});var De=c((Li,$e)=>{"use strict";$e.exports=function(){return function(e,t){t(!0)}}});var Me=c((Ui,He)=>{"use strict";He.exports=function(e){return function(t,n){n(e)}}});var Fe=c((Ji,Ge)=>{"use strict";Ge.exports={keys:Ne(),once:ue(),values:H(),count:Le(),infinite:Je(),empty:De(),error:Me()}});var B=c(($i,We)=>{"use strict";We.exports=function(e,t){var n,u;function i(f){if(n=f,u)return i.abort();(function s(){for(var o=!0,l=!1;o;)if(l=!1,n(null,function(a,p){if(l=!0,a=a||u){if(o=!1,t)t(a===!0?null:a);else if(a&&a!==!0)throw a}else e&&e(p)===!1||u?(o=!1,n(u||!0,t||function(){})):o||s()}),!l){o=!1;return}})()}return i.abort=function(f,s){if(typeof f=="function"&&(s=f,f=!0),u=f||!0,n)return n(u,s||function(){})},i}});var Ke=c((Di,Ye)=>{"use strict";var Xn=B();Ye.exports=function(e){return Xn(null,e)}});var ze=c((Hi,Qe)=>{"use strict";var Zn=B();Qe.exports=function(e){return Zn(function(t){console.log(t)},e)}});var O=c((Mi,Ve)=>{Ve.exports=function(e){return e&&(typeof e=="string"?function(t){return t[e]}:typeof e=="object"&&typeof e.exec=="function"?function(t){var n=e.exec(t);return n&&n[0]}:e)}});var je=c((Gi,Ze)=>{"use strict";function Xe(r){return r}var jn=O(),bn=B();Ze.exports=function(e,t){var n=!1;return t?e=jn(e)||Xe:(t=e,e=Xe),bn(function(u){if(e(u))return n=!0,t(null,u),!1},function(u){n||t(u===!0?null:u,null)})}});var M=c((Fi,be)=>{"use strict";var eu=B();be.exports=function(e,t,n){n||(n=t,t=null);var u=eu(function(i){t=e(t,i)},function(i){n(i,t)});return arguments.length===2?function(i){i(null,function(f,s){if(f)return n(f===!0?null:f);t=s,u(i)})}:u}});var rr=c((Wi,er)=>{"use strict";var ru=M();er.exports=function(e){return ru(function(t,n){return t.push(n),t},[],e)}});var nr=c((Yi,tr)=>{"use strict";var tu=M();tr.exports=function(e){return tu(function(t,n){return t+n},"",e)}});var ir=c((Ki,ur)=>{"use strict";ur.exports={drain:B(),onEnd:Ke(),log:ze(),find:je(),reduce:M(),collect:rr(),concat:nr()}});var sr=c((Qi,or)=>{"use strict";function nu(r){return r}var uu=O();or.exports=function(e){return e?(e=uu(e),function(t){return function(n,u){t(n,function(i,f){try{f=i?null:e(f)}catch(s){return t(s,function(){return u(s)})}u(i,f)})}}):nu}});var lr=c((zi,fr)=>{"use strict";function iu(r){return r}var ou=O();fr.exports=function(e){if(!e)return iu;e=ou(e);var t=!1,n,u;return function(i){return function f(s,o){if(u)return o(u);s?(u=s,t?i(s,function(l){t?n=o:o(s)}):i(s,function(l){o(s)})):i(null,function(l,a){l?o(l):u?o(u):(t=!0,e(a,function(p,h){t=!1,u?(o(u),n&&n(u)):p?f(p,o):o(null,h)}))})}}}});var ie=c((Vi,cr)=>{var su=O();function fu(r){return r}cr.exports=function(e){return typeof e=="object"&&typeof e.test=="function"?function(t){return e.test(t)}:su(e)||fu}});var G=c((Xi,ar)=>{"use strict";var lu=ie();ar.exports=function(e){return e=lu(e),function(t){return function n(u,i){for(var f,s=!0;s;)s=!1,f=!0,t(u,function(o,l){if(!o&&!e(l))return f?s=!0:n(o,i);i(o,l)}),f=!1}}}});var hr=c((Zi,pr)=>{"use strict";var cu=ie(),au=G();pr.exports=function(e){return e=cu(e),au(function(t){return!e(t)})}});var vr=c((ji,dr)=>{"use strict";dr.exports=function(e,t){var n=!1;function u(i){n||!t||(n=!0,t(i===!0?null:i))}return function(i){return function(f,s){return f&&u(f),i(f,function(o,l){o?u(o):e&&e(l),s(o,l)})}}}});var yr=c((bi,qr)=>{"use strict";qr.exports=function(e,t){t=t||{};var n=t.last||!1,u=!1;if(typeof e=="number"){n=!0;var i=e;e=function(){return--i}}return function(f){function s(o){f(!0,function(l){n=!1,o(l||!0)})}return function(o,l){u&&!o?n?s(l):l(u):(u=o)?f(u,l):f(null,function(a,p){(u=u||a)?l(u):e(p)?l(null,p):(u=!0,n?l(null,p):s(l))})}}}});var oe=c((eo,xr)=>{"use strict";function pu(r){return r}var hu=O(),du=G();xr.exports=function(e,t){e=hu(e)||pu;var n={};return du(function(u){var i=e(u);return n[i]?!!t:(n[i]=!0,!t)})}});var wr=c((ro,gr)=>{"use strict";var vu=oe();gr.exports=function(e){return vu(e,!0)}});var _r=c((to,mr)=>{"use strict";var qu=H(),yu=ue();mr.exports=function(){return function(e){var t;return function(n,u){n?t?t(n,function(s){e(s||n,u)}):e(n,u):t?i():f();function i(){t(null,function(s,o){s===!0?f():s?e(!0,function(l){u(s)}):u(null,o)})}function f(){t=null,e(null,function(s,o){if(s)return u(s);Array.isArray(o)||o&&typeof o=="object"?o=qu(o):typeof o!="function"&&(o=yu(o)),t=o,i()})}}}}});var kr=c((no,Er)=>{"use strict";Er.exports={map:sr(),asyncMap:lr(),filter:G(),filterNot:hr(),through:vr(),take:yr(),unique:oe(),nonUnique:wr(),flatten:_r()}});var se=c((uo,Sr)=>{"use strict";Sr.exports=function r(e){var t=arguments.length;if(typeof e=="function"&&e.length===1){for(var n=new Array(t),u=0;u<t;u++)n[u]=arguments[u];return function(s){if(n==null)throw new TypeError("partial sink should only be called once!");var o=n;switch(n=null,t){case 1:return r(s,o[0]);case 2:return r(s,o[0],o[1]);case 3:return r(s,o[0],o[1],o[2]);case 4:return r(s,o[0],o[1],o[2],o[3]);default:return o.unshift(s),r.apply(null,o)}}}var i=e;i&&typeof i.source=="function"&&(i=i.source);for(var u=1;u<t;u++){var f=arguments[u];typeof f=="function"?i=f(i):f&&typeof f=="object"&&(f.sink(i),i=f.source)}return i}});var F=c((_,Ar)=>{"use strict";var Pr=Fe(),Br=ir(),Or=kr();_=Ar.exports=se();_.pull=_;for(y in Pr)_[y]=Pr[y];var y;for(y in Or)_[y]=Or[y];var y;for(y in Br)_[y]=Br[y];var y});var fe=c((oo,Tr)=>{var io=Tr.exports=function(r){(function e(){var t=!0,n=!1,u=!1;do u=!0,t=!1,r.call(this,function(){u?t=!0:e()}),u=!1;while(t)})()}});var Nr=c((so,Cr)=>{var xu=fe();Cr.exports=function(r,e){return function(t){var n=[],u,i;function f(l){n.push(l)}r=r||function(l){this.queue(l)},e=e||function(){this.queue(null)};var s={emit:function(l,a){l=="data"&&f(a),l=="end"&&(u=!0,f(null)),l=="error"&&(i=a)},queue:f},o;return function(l,a){if(u=u||l,l)return t(l,function(){if(o){var p=o;o=null,p(l)}a(l)});o=a,xu(function p(h){if(!!o)if(a=o,i)o=null,a(i);else if(n.length){var d=n.shift();o=null,a(d===null,d)}else t(u,function(v,w){if(v&&v!==!0)return i=v,h();if(u=u||v)e.call(s);else if(w!==null&&(r.call(s,w),i||u))return t(i||u,function(){o=null,a(i||u)});h(p)})})}}}});var Ir=c((fo,Rr)=>{Rr.exports=function(){var r=[],e=0;function t(){return r.reduce(function(n,u){return n+u.length},0)}return{length:e,data:this,add:function(n){if(!Buffer.isBuffer(n))throw new Error("data must be a buffer, was: "+JSON.stringify(n));return this.length=e=e+n.length,r.push(n),this},has:function(n){return n==null?e>0:e>=n},get:function(n){var u;if(n==null||n===e){e=0;var i=r;return r=[],i.length==1?i[0]:Buffer.concat(i)}else if(r.length>1&&n<=(u=r[0].length)){var f=r[0].slice(0,n);return n===u?r.shift():r[0]=r[0].slice(n,u),e-=n,f}else if(n<e){for(var s=[],o=0;o+r[0].length<n;){var l=r.shift();o+=l.length,s.push(l)}return o<n&&(s.push(r[0].slice(0,n-o)),r[0]=r[0].slice(n-o,r[0].length),this.length=e=e-n),Buffer.concat(s)}else throw new Error("could not get "+n+" bytes")}}}});var $r=c((lo,Jr)=>{"use strict";var gu=Ir();function wu(r){return Number.isFinite(r)}function Lr(r){return typeof r=="function"}function Ur(r,e){return e?function(t,n){var u=setTimeout(function(){r(new Error("pull-reader: read exceeded timeout"),n)},e);r(t,function(i,f){clearTimeout(u),n(i,f)})}:r}Jr.exports=function(r){var e=[],t,n,u=!1,i=gu(),f,s,o;function l(){for(;e.length;)if(e[0].length==null&&i.has(1))e.shift().cb(null,i.get());else if(i.has(e[0].length)){var h=e.shift();h.cb(null,i.get(h.length))}else if(f==!0&&e[0].length&&i.length<e[0].length){var d="stream ended with:"+i.length+" but wanted:"+e[0].length;e.shift().cb(new Error(d))}else if(f)e.shift().cb(f);else return!!e.length;return e.length||!i.has(1)||o}function a(){var h=l();h&&!u&&t&&!u&&!s&&(u=!0,n(null,function(d,v){if(u=!1,d)return f=d,l();i.add(v),a()}))}function p(h){if(o){for(;e.length;)e.shift().cb(o);return cb&&cb(o)}n=Ur(h,r),t=h,a()}return p.abort=function(h,d){o=h||!0,t?(u=!0,t(o,function(){for(;e.length;)e.shift().cb(o);d&&d(o)})):d()},p.read=function(h,d,v){if(Lr(d)&&(v=d,d=r),Lr(v))e.push({length:wu(h)?h:null,cb:v}),a();else return s=!0,function(w,R){if(u||i.has(1)){if(w)return t(w,R);e.push({length:null,cb:R}),a()}else Ur(t,d)(w,function(te,$n){R(te,$n)})}},p}});var Xr=c((E,Vr)=>{var mu=Nr(),_u=$r(),Dr=0,Hr=1,Mr=2,Gr="GOODBYE",Eu=Buffer.isBuffer;function Fr(r){return typeof r=="string"}function Wr(r){var e=Buffer.alloc(9),t=0,n=r.value!==void 0?r.value:r.end;return Fr(r)&&r===Gr?(e.fill(0),[e,null]):(Fr(n)?(t=Hr,n=Buffer.from(n,"utf-8")):Eu(n)?t=Dr:(t=Mr,n=Buffer.from(JSON.stringify(n),"utf-8")),t=r.stream<<3|r.end<<2|t,e[0]=t,e.writeUInt32BE(n.length,1),e.writeInt32BE(r.req||0,5),[e,n])}function Yr(r){if(r.length!=9)throw new Error("expected header to be 9 bytes long");var e=r[0],t=r.readUInt32BE(1),n=r.readInt32BE(5);return{req:n,stream:!!(e&8),end:!!(e&4),value:null,length:t,type:e&3}}function Kr(r,e){if(r.length!==e.length)throw new Error("incorrect length, expected:"+e.length+" found:"+r.length);if(Dr===e.type)e.value=r;else if(Hr===e.type)e.value=r.toString();else if(Mr===e.type)e.value=JSON.parse(r.toString());else throw new Error("unknown message type");return e}function Qr(){return mu(function(r){var e=Wr(r);this.queue(e[0]),e[1]!==null&&this.queue(e[1])})}function zr(){var r=_u(),e=!1;return function(t){return r(t),function(n,u){if(e)return u(!0);if(n)return r.abort(n,u);r.read(9,function(i,f){if(i)return u(i);var s=Yr(f);if(s.length===0)return e=!0,u(null,Gr);r.read(s.length,function(o,l){if(o)return u(o);try{Kr(l,s)}catch(a){return u(a)}u(null,s)})})}}}E=Vr.exports=function(r){return{source:Qr()(r.source),sink:function(e){return r.sink(zr()(e))}}};E.encodePair=Wr;E.decodeHead=Yr;E.decodeBody=Kr;E.encode=Qr;E.decode=zr});var br=c((co,jr)=>{function L(r){return r&&(r===!0?!0:{message:r.message,name:r.name,stack:r.stack})}jr.exports=function(r){return new q(r)};function q(r){this.ended=!1,this.opts=r,this._req_counter=1,this._requests={},this._instreams={},this._outstreams={},this._closecbs=[],this._closing=!1,this._closed=!1,r.close&&this._closecbs.push(r.close)}q.prototype.message=function(r){this.read({req:0,stream:!1,end:!1,value:r})};q.prototype.request=function(r,e){if(this._closing)return e(new Error("parent stream is closing"));var t=this._req_counter++,n=this;this._requests[t]=function(u,i){delete n._requests[t],e(u,i),n._maybedone(u)},this.read({req:t,stream:!1,end:!1,value:r})};q.prototype.stream=function(){if(this._closing)throw new Error("parent stream is closing");var r=this._req_counter++,e=this;return this._outstreams[r]=new U(r,this,function(){delete e._outstreams[r]}),this._outstreams[r]};q.prototype.close=function(r){if(!r)throw new Error("packet-stream.close *must* have callback");if(this._closed)return r();this._closecbs.push(r),this._closing=!0,this._maybedone()};q.prototype.destroy=function(r){r=r||L(r),this.ended=r,this._closing=!0;var e=r===!0?new Error("unexpected end of parent stream"):r,t=0;for(var n in this._requests)t++,this._requests[n](e);for(var n in this._instreams)t++,this._instreams[n].writeEnd=!0,this._instreams[n].destroy(e);for(var n in this._outstreams)t++,this._outstreams[n].writeEnd=!0,this._outstreams[n].destroy(e);t===0&&r===!0&&(e=null),this._maybedone(e)};q.prototype._maybedone=function(r){this._closed||!this._closing||Object.keys(this._requests).length!==0||Object.keys(this._instreams).length!==0||Object.keys(this._outstreams).length!==0||(this._closed=!0,this._closecbs.forEach(function(e){e(r)}),this.read(null,r||!0),this.opts=null,this._closecbs.length=0,this.read=Zr)};function Zr(r){console.error("packet-stream asked to read after closed",r)}q.prototype.read=function(r){console.error("please overwrite read method to do IO",r)};q.prototype.write=function(r,e){this.ended||(e?this.destroy(e):r.req&&!r.stream?this._onrequest(r):r.req&&r.stream?this._onstream(r):this._onmessage(r))};q.prototype._onmessage=function(r){this.opts&&typeof this.opts.message=="function"&&this.opts.message(r.value)};q.prototype._onrequest=function(r){var e=r.req*-1;if(r.req<0)typeof this._requests[e]=="function"&&this._requests[e](r.end?r.value:null,r.end?null:r.value);else if(this.opts&&typeof this.opts.request=="function"){var t=!1,n=this;this.opts.request(r.value,function(i,f){if(t)throw new Error("cb called twice from local api");t=!0,i?n.read({value:L(i),end:!0,req:e}):n.read({value:f,end:!1,req:e}),n._maybedone()})}else{if(this.ended){var u=this.ended===!0?new Error("unexpected end of parent stream"):this.ended;this.read({value:L(u),end:!0,stream:!1,req:e})}else this.read({value:{message:"Unable to handle requests",name:"NO_REQUEST_HANDLER",stack:null},end:!0,stream:!1,req:e});this._maybedone()}};q.prototype._onstream=function(r){if(r.req<0){var e=r.req*-1,t=this._outstreams[e];if(!t)return console.error("no stream for incoming msg",r);r.end?(t.writeEnd&&delete this._outstreams[e],t.readEnd=!0,t.read(null,r.value),this._maybedone()):t.read(r.value)}else{var e=r.req,n=this._instreams[e];if(!n){var u=this;n=this._instreams[e]=new U(e*-1,this,function(){delete u._instreams[e]}),this.opts&&typeof this.opts.stream=="function"&&this.opts.stream(n)}r.end?(n.writeEnd&&delete this._instreams[e],n.readEnd=!0,n.read&&n.read(null,r.value),this._maybedone()):n.read?n.read(r.value):console.error("no .read for stream:",n.id,"dropped:",r)}};function U(r,e,t){this.id=r,this.read=null,this.writeEnd=null,this.readEnd=null,this._ps=e,this._remove=t,this._seq_counter=1}U.prototype.write=function(r,e){if(e){this.writeEnd=e;var t=this._ps;t&&(t.read({req:this.id,stream:!0,end:!0,value:L(e)}),this.readEnd&&this.destroy(e),t._maybedone(e))}else this._ps&&this._ps.read({req:this.id,stream:!0,end:!1,value:r})};U.prototype.end=function(r){this.write(null,L(r||!0))};U.prototype.destroy=function(r){if(this.writeEnd){if(!this.readEnd){this.readEnd=!0;try{this.read&&this.read(null,r)}catch(e){console.error("Exception thrown by PacketStream substream end handler",e),console.error(e.stack)}}}else{if(this.writeEnd=!0,!this.readEnd){this.readEnd=!0;try{this.read(null,r)}catch(e){console.error("Exception thrown by PacketStream substream end handler",e),console.error(e.stack)}}this.write(null,r)}this._ps&&(this._remove(),this._remove=null,this.read=Zr,this._ps=null)}});var rt=c((ao,J)=>{"use strict";var ku=F();function Su(r){let e=!1;return(t,n)=>{e||(e=!0,r(t,n))}}function le(r,e){let t=[],n=!1,u,i,f=Su((s,o)=>{e&&e(s,o),r=null,e=null,u=null,i&&i(s||!0,()=>{})});return r.read=function(s,o){if(n=n||o,u){let l=u;u=null,l(n,s)}else n||t.push(s);n&&f(n!==!0?n:null)},{source(s,o){s?(r&&r.write(null,s),o(s),f(s!==!0?s:null)):t.length?o(null,t.shift()):n?o(n):u=o},sink(s){if(n)return i=null,s(n,()=>{});i=s,ku.drain(o=>{if(n)return!1;r.write(o)},o=>{r&&!r.writeEnd&&r.write(null,o||!0),f&&f(o)})(s)}}}function et(r,e){return le(r,t=>{r.writeEnd||r.write(null,t||!0),e&&e(t)})}function Pu(r){return et(r).source}function Bu(r,e){return et(r,e).sink}J.exports=le;J.exports.source=Pu;J.exports.sink=Bu;J.exports.duplex=le});var nt=c((po,tt)=>{tt.exports=function(e){var t,n,u;function i(f){return function(s,o){f(s,function(l,a){if(l&&!u)return u=!0,o(null,e);l&&t?o(l):l?n=o:o(null,a)})}}return i.end=function(){return t=!0,n&&n(t),i},i}});var ce=c((ho,ut)=>{ut.exports=function(e,t,n){e(t),n&&n(t===!0?null:t)}});var W=c((vo,ot)=>{"use strict";var it=ce();ot.exports=function(e,t){if(!e)return function(u,i){return u?it(i,u,t):i(!0)};Array.isArray(e)||(e=Object.keys(e).map(function(u){return e[u]}));var n=0;return function(u,i){if(u)return it(i,u,t);n>=e.length?i(!0):i(null,e[n++])}}});var ft=c((qo,st)=>{"use strict";var Ou=W();st.exports=function(r){return Ou(Object.keys(r))}});var ae=c((yo,lt)=>{"use strict";var Au=ce();lt.exports=function(e,t){return function(n,u){if(n)return Au(u,n,t);if(e!=null){var i=e;e=null,u(null,i)}else u(!0)}}});var at=c((xo,ct)=>{"use strict";ct.exports=function(e){var t=0;return e=e||1/0,function(n,u){if(n)return u&&u(n);if(t>e)return u(!0);u(null,t++)}}});var ht=c((go,pt)=>{"use strict";pt.exports=function(e){return e=e||Math.random,function(t,n){return t?n&&n(t):n(null,e())}}});var vt=c((wo,dt)=>{"use strict";dt.exports=function(){return function(e,t){t(!0)}}});var yt=c((mo,qt)=>{"use strict";qt.exports=function(e){return function(t,n){n(e)}}});var gt=c((_o,xt)=>{"use strict";xt.exports={keys:ft(),once:ae(),values:W(),count:at(),infinite:ht(),empty:vt(),error:yt()}});var A=c((Eo,wt)=>{"use strict";wt.exports=function(e,t){var n,u;function i(f){if(n=f,u)return i.abort();(function s(){for(var o=!0,l=!1;o;)if(l=!1,n(null,function(a,p){if(l=!0,a=a||u){if(o=!1,t)t(a===!0?null:a);else if(a&&a!==!0)throw a}else e&&e(p)===!1||u?(o=!1,n(u||!0,t||function(){})):o||s()}),!l){o=!1;return}})()}return i.abort=function(f,s){if(typeof f=="function"&&(s=f,f=!0),u=f||!0,n)return n(u,s||function(){})},i}});var _t=c((ko,mt)=>{"use strict";var Tu=A();mt.exports=function(e){return Tu(null,e)}});var kt=c((So,Et)=>{"use strict";var Cu=A();Et.exports=function(e){return Cu(function(t){console.log(t)},e)}});var T=c((Po,St)=>{St.exports=function(e){return e&&(typeof e=="string"?function(t){return t[e]}:typeof e=="object"&&typeof e.exec=="function"?function(t){var n=e.exec(t);return n&&n[0]}:e)}});var Ot=c((Bo,Bt)=>{"use strict";function Pt(r){return r}var Nu=T(),Ru=A();Bt.exports=function(e,t){var n=!1;return t?e=Nu(e)||Pt:(t=e,e=Pt),Ru(function(u){if(e(u))return n=!0,t(null,u),!1},function(u){n||t(u===!0?null:u,null)})}});var Y=c((Oo,At)=>{"use strict";var Iu=A();At.exports=function(e,t,n){n||(n=t,t=null);var u=Iu(function(i){t=e(t,i)},function(i){n(i,t)});return arguments.length===2?function(i){i(null,function(f,s){if(f)return n(f===!0?null:f);t=s,u(i)})}:u}});var Ct=c((Ao,Tt)=>{"use strict";var Lu=Y();Tt.exports=function(e){return Lu(function(t,n){return t.push(n),t},[],e)}});var Rt=c((To,Nt)=>{"use strict";var Uu=Y();Nt.exports=function(e){return Uu(function(t,n){return t+n},"",e)}});var Lt=c((Co,It)=>{"use strict";It.exports={drain:A(),onEnd:_t(),log:kt(),find:Ot(),reduce:Y(),collect:Ct(),concat:Rt()}});var Jt=c((No,Ut)=>{"use strict";function Ju(r){return r}var $u=T();Ut.exports=function(e){return e?(e=$u(e),function(t){return function(n,u){t(n,function(i,f){try{f=i?null:e(f)}catch(s){return t(s,function(){return u(s)})}u(i,f)})}}):Ju}});var Dt=c((Ro,$t)=>{"use strict";function Du(r){return r}var Hu=T();$t.exports=function(e){if(!e)return Du;e=Hu(e);var t=!1,n,u;return function(i){return function f(s,o){if(u)return o(u);s?(u=s,t?i(s,function(){t?n=o:o(s)}):i(s,o)):i(null,function(l,a){l?o(l):u?o(u):(t=!0,e(a,function(p,h){t=!1,u?(o(u),n(u)):p?f(p,o):o(null,h)}))})}}}});var pe=c((Io,Ht)=>{var Mu=T();function Gu(r){return r}Ht.exports=function(e){return typeof e=="object"&&typeof e.test=="function"?function(t){return e.test(t)}:Mu(e)||Gu}});var K=c((Lo,Mt)=>{"use strict";var Fu=pe();Mt.exports=function(e){return e=Fu(e),function(t){return function n(u,i){for(var f,s=!0;s;)s=!1,f=!0,t(u,function(o,l){if(!o&&!e(l))return f?s=!0:n(o,i);i(o,l)}),f=!1}}}});var Ft=c((Uo,Gt)=>{"use strict";var Wu=pe(),Yu=K();Gt.exports=function(e){return e=Wu(e),Yu(function(t){return!e(t)})}});var Yt=c((Jo,Wt)=>{"use strict";Wt.exports=function(e,t){var n=!1;function u(i){n||!t||(n=!0,t(i===!0?null:i))}return function(i){return function(f,s){return f&&u(f),i(f,function(o,l){o?u(o):e&&e(l),s(o,l)})}}}});var Qt=c(($o,Kt)=>{"use strict";Kt.exports=function(e,t){t=t||{};var n=t.last||!1,u=!1;if(typeof e=="number"){n=!0;var i=e;e=function(){return--i}}return function(f){function s(o){f(!0,function(l){n=!1,o(l||!0)})}return function(o,l){u?n?s(l):l(u):(u=o)?f(u,l):f(null,function(a,p){(u=u||a)?l(u):e(p)?l(null,p):(u=!0,n?l(null,p):s(l))})}}}});var he=c((Do,zt)=>{"use strict";function Ku(r){return r}var Qu=T(),zu=K();zt.exports=function(e,t){e=Qu(e)||Ku;var n={};return zu(function(u){var i=e(u);return n[i]?!!t:(n[i]=!0,!t)})}});var Xt=c((Ho,Vt)=>{"use strict";var Vu=he();Vt.exports=function(e){return Vu(e,!0)}});var jt=c((Mo,Zt)=>{"use strict";var Xu=W(),Zu=ae();Zt.exports=function(){return function(e){var t;return function(n,u){n?t?t(n,function(s){e(s||n,u)}):e(n,u):t?i():f();function i(){t(null,function(s,o){s===!0?f():s?e(!0,function(l){u(s)}):u(null,o)})}function f(){t=null,e(null,function(s,o){if(s)return u(s);Array.isArray(o)||o&&typeof o=="object"?o=Xu(o):typeof o!="function"&&(o=Zu(o)),t=o,i()})}}}}});var en=c((Go,bt)=>{"use strict";bt.exports={map:Jt(),asyncMap:Dt(),filter:K(),filterNot:Ft(),through:Yt(),take:Qt(),unique:he(),nonUnique:Xt(),flatten:jt()}});var tn=c((Fo,rn)=>{"use strict";rn.exports=function r(e){var t=arguments.length;if(typeof e=="function"&&e.length===1){for(var n=new Array(t),u=0;u<t;u++)n[u]=arguments[u];return function(s){if(n==null)throw new TypeError("partial sink should only be called once!");var o=n;switch(n=null,t){case 1:return r(s,o[0]);case 2:return r(s,o[0],o[1]);case 3:return r(s,o[0],o[1],o[2]);case 4:return r(s,o[0],o[1],o[2],o[3]);default:return o.unshift(s),r.apply(null,o)}}}var i=e;i&&typeof i.source=="function"&&(i=i.source);for(var u=1;u<t;u++){var f=arguments[u];typeof f=="function"?i=f(i):f&&typeof f=="object"&&(f.sink(i),i=f.source)}return i}});var fn=c(($,sn)=>{"use strict";var nn=gt(),un=Lt(),on=en();$=sn.exports=tn();for(x in nn)$[x]=nn[x];var x;for(x in on)$[x]=on[x];var x;for(x in un)$[x]=un[x];var x});var cn=c((Wo,ln)=>{var ju=nt(),de=fn();ln.exports=function(r,e){e=e||"GOODBYE";var t=ju(e);return{source:de(r.source,t),sink:de(de.filter(function(n){if(n!==e)return!0;t.end()}),r.sink)}}});var D=c(g=>{"use strict";var Q=F();function bu(r){return r?Object.keys(r).length===0:!0}g.set=function(e,t,n){let u,i;for(let f=0;f<t.length;f++){let s=t[f];e[s]=e[s]||{},u=e,i=s,e=e[s]}u[i]=n};g.get=function(e,t){if(typeof t=="string")return e[t];let n;for(let u=0;u<t.length;u++){let i=t[u];if(n=e=e[i],e==null)return e}return n};g.prefix=function(e,t){let n;for(let u=0;u<t.length;u++){let i=t[u];if(n=e=e[i],typeof e!="object")return e}return typeof n!="object"?!!n:!1};function ei(r,e){for(let t in e){let n=e[t];r[n]||(r[n]={}),r=r[n]}return r}function ri(r,e){(function t(n,u){let i=e[u];if(n)e.length-1===u?delete n[i]:u<e.length&&t(n[i],u+1);else return;bu(n[i])&&delete n[i]})(r,0)}function ti(r,e){for(let t in e)r[t]=e[t];return r}g.mount=function(e,t,n){if(!Array.isArray(t))throw new Error("path must be array of strings");return ti(ei(e,t),n)};g.unmount=function(e,t){return ri(e,t)};var z=r=>r==="source",V=r=>r==="sink",an=r=>r==="duplex",ni=r=>r==="sync",ui=r=>r==="async",pn=r=>ni(r)||ui(r),ii=r=>z(r)||V(r)||an(r);g.isRequest=pn;g.isStream=ii;function ve(r){return function(e){e(r||!0,()=>{})}}function hn(r){return{source:Q.error(r),sink:ve(r)}}g.errorAsStream=function(e,t){return z(e)?Q.error(t):V(e)?ve(t):hn(t)};g.errorAsStreamOrCb=function(e,t,n){return pn(e)?n(t):z(e)?Q.error(t):V(e)?ve(t):n(t),hn(t)};g.pipeToStream=function(e,t,n){z(e)?t(n):V(e)?n(t):an(e)&&Q(t,n,t)}});var qe=c((Qo,vn)=>{function dn(r){if(r.stack&&r.name&&r.message)return r.stack.substring(r.name.length+3+r.message.length).split(`
  `);if(r.stack)return r.stack.split(`
  `)}function oi(r,e){return r.filter(function(t){return!~e.indexOf(t)})}var Ko=vn.exports=function(r,e){if(!(r.stack&&r.name&&r.message))return console.error(new Error("stackless error")),r;var t=new Error(e),n=oi(dn(t).slice(1),dn(r)).join(`
  `);return t.__proto__=r,t.stack=t.name+": "+t.message+`
  `+n+`
    `+r.stack,t}});var xn=c((zo,yn)=>{"use strict";var si=br(),ye=rt(),fi=cn(),C=D(),qn=qe();yn.exports=function(e,t,n){let u=si({message(){},request(f,s){if(!Array.isArray(f.args))return s(new Error(`invalid request, args should be array, was: ${JSON.stringify(f)}`));let o=f.name,l=f.args,a=!1,p=!1;l.push((h,d)=>{p=!0,a=!0,s(h,d)});try{e("async",o,l)}catch(h){if(a||p)throw qn(h,"no callback provided to muxrpc async funtion");s(h)}},stream(f){f.read=function(o,l){if(l)return f.write(null,l);let{name:a,type:p,args:h}=o,d,v;if(f.read=null,!C.isStream(p))return f.write(null,new Error(`unsupported stream type: ${p}`));try{v=e(p,a,h)}catch(te){d=te}let R=ye[p==="source"?"sink":p==="sink"?"source":"duplex"](f);return C.pipeToStream(p,R,d?C.errorAsStream(p,d):v)}},close(f){if(u=null,i.ended=!0,!i.closed&&(i.closed=!0,n)){let s=n;n=null,s(f)}}}),i=fi(ye(u,()=>{}));return i=t?t(i):i,i.remoteCall=function(f,s,o,l){if(s==="emit")return u.message(o);if(!(C.isRequest(f)||C.isStream(f)))throw new Error(`unsupported type: ${JSON.stringify(f)}`);if(C.isRequest(f))return u.request({name:s,args:o},l);let a=u.stream(),p=ye[f](a,l);return a.write({name:s,args:o,type:f}),p},i.isOpen=function(){return!u.ended},i.close=function(f,s){if(typeof f=="function"&&(s=f,f=!1),!u){s&&s();return}if(f){u.destroy(f),s&&s();return}return u.close(o=>{if(s)s(o);else if(o)throw qn(o,"no callback provided for muxrpc close")}),this},i.closed=!1,i}});var wn=c((Vo,gn)=>{"use strict";var li=qe(),ci=D();function xe(r,e,t,n){for(let u in e){let i=e[u],f=t?t.concat(u):[u];if(i&&typeof i=="object"){let s=i;r[u]=xe({},s,f,n)}else{let s=i;r[u]=(...o)=>n(s,f,o)}}return r}function ai(r){if(r)throw li(r,"callback not provided")}function pi(r,e,t,n){r=r||{};function u(i,f,s){let o=typeof s[s.length-1]=="function"?s.pop():i==="sync"||i==="async"?null:ai;if(typeof o=="function"){let l;try{l=t(i,f,s,o)}catch(a){return ci.errorAsStreamOrCb(i,a,o)}return l}else return new Promise((l,a)=>{t(i,f,s,(p,h)=>{p?a(p):l(h)})})}return n?u("async","manifest",[function(i,f){if(i)return n(i);xe(r,f,null,u),n(null,f,r)}]):xe(r,e,null,u),r}gn.exports=pi});var En=c((Xo,_n)=>{"use strict";var X=D();function mn(r){return Array.isArray(r)?r:r.split(".")}function hi(r){return r&&typeof r.pre=="function"&&typeof r.test=="function"&&typeof r.post=="function"}_n.exports=function(e){if(hi(e))return e;if(typeof e=="function")return{pre:e};let t=null,n={};function u(i){if(i.allow){t={};for(let f of i.allow)X.set(t,mn(f),!0)}else t=null;if(i.deny)for(let f of i.deny)X.set(n,mn(f),!0);else n={};return this}return e&&u(e),u.pre=i=>{if(i=Array.isArray(i)?i:[i],t&&!X.prefix(t,i))return new Error(`method:${i} is not in list of allowed methods`);if(n&&X.prefix(n,i))return new Error(`method:${i} is on list of disallowed methods`)},u.post=()=>{},u.test=i=>u.pre(i),u.get=()=>({allow:t,deny:n}),u}});var Sn=c((Zo,kn)=>{"use strict";var di=En(),ge=D();kn.exports=function(e,t,n){n=di(n);function u(f,s){return f===ge.get(t,s)}function i(f,s,o){if(s==="emit")throw new Error("emit has been removed");if(f==="async"&&u("sync",s)){let l=o.pop(),a;try{a=ge.get(e,s).apply(this,o)}catch(p){return l(p)}return l(null,a)}if(!u(f,s))throw new Error(`no ${f}:${s}`);return ge.get(e,s).apply(this,o)}return function(s,o,l){let a=n.pre(o,l);if(a)throw a;return i.call(this,s,o,l)}}});var On=c((jo,Bn)=>{"use strict";var vi=Xr(),qi=require("events").EventEmitter,yi=xn(),xi=wn(),gi=Sn();function Pn(r,e,t,n,u,i,f){let s;typeof r=="function"&&(s=r,r={}),e=e||{},r=r||{};let o=new qi;i||(i=vi);let l,a={_emit(h,d){return o&&o._emit(h,d),a},id:n},p=yi(gi(t,e,u).bind(a),i,h=>{if(!o.closed&&(o.closed=!0,o.emit("closed"),l)){let d=l;l=null,d(h)}});if(xi(o,r,(h,d,v,w)=>{if(p.closed)throw new Error("stream is closed");return p.remoteCall(h,d,v,w)},s),o._emit=o.emit,f){Object.__defineGetter__.call(o,"id",()=>a.id),Object.__defineSetter__.call(o,"id",d=>{a.id=d});let h=!0;o.createStream=d=>{if(l=d,h)return h=!1,p;throw new Error("one stream per rpc")}}else o.stream=p;return o.closed=!1,o.close=function(h,d){return p.close(h,d),this},o}Bn.exports=function(r,e,t){return arguments.length>3?Pn.apply(this,arguments):function(n,u,i){return Pn(r,e,n,i,u,t,!0)}}});var Nn=c((m,Cn)=>{var bo=se(),wi=fe();function An(r){r.destroy?r.destroy():console.error("warning, stream-to-pull-stream: \nthe wrapped node-stream does not implement `destroy`, \nthis may cause resource leaks.")}function Tn(r,e,t){var n,u=!1,i;function f(){i||(i=!0,t&&t(n===!0?null:n))}function s(){u||(u=!0,l(),n?f():r(n=!0,f))}function o(a){l(),n||r(n=a,f)}function l(){e.on("finish",s),e.removeListener("close",s),e.removeListener("error",o)}e.on("close",s),e.on("finish",s),e.on("error",o),process.nextTick(function(){wi(function(a){r(null,function(p,h){if(n=n||p,p===!0)return e._isStdio?f():e.end();if(n=n||p)return An(e),f(n);if(e._isStdio)e.write(h,function(){a()});else{var d=e.write(h);d===!1?e.once("drain",a):a()}})})})}function mi(r){var e=!1,t=!1,n;function u(){var i=r.read();if(i!==null&&n){var f=n;n=null,f(null,i)}}return r.on("readable",function(){t=!0,n&&u()}).on("end",function(){e=!0,n&&n(e)}).on("error",function(i){e=i,n&&n(e)}),function(i,f){n=f,e?f(e):t&&u()}}function Z(r){var e=[],t=[],n,u=!1,i;function f(){for(;(e.length||n)&&t.length;)t.shift()(e.length?null:n,e.shift());!e.length&&u&&(u=!1,r.resume())}return r.on("data",function(s){e.push(s),f(),e.length&&r.pause&&(u=!0,r.pause())}),r.on("end",function(){n=!0,f()}),r.on("close",function(){n=!0,f()}),r.on("error",function(s){n=s,f()}),function(s,o){if(!o)throw new Error("*must* provide cb");if(s){let a=function(){for(;t.length;)t.shift()(s);o(s)};var l=a;if(n)return a();r.once("close",a),An(r)}else t.push(o),f()}}var _i=Z,j=function(r,e){return function(t){return Tn(t,r,e)}},b=function(r){return Z(r)};m=Cn.exports=function(r,e){return r.writable&&r.write?r.readable?function(t){return Tn(t,r,e),Z(r)}:j(r,e):b(r)};m.sink=j;m.source=b;m.read=_i;m.read1=Z;m.read2=mi;m.duplex=function(r,e){return{source:b(r),sink:j(r,e)}};m.transform=function(r){return function(e){var t=b(r);return j(r)(e),t}}});Kn(exports,{logThrough:()=>Bi});var Rn=P(require("net")),In=P(require("http")),ee=P(require("fs")),we=P(require("child_process")),me=P(F()),_e=P(require("util")),Ei=On(),N=Nn(),Ln=JSON.parse(process.env.REMOTE_CONTAINERS_SOCKETS),ki=Pe(S({},Ln.reduce((r,e)=>(r[e]="duplex",r),{})),{rpc:"async",ready:"async"}),Si={exec:"async",stdin:"sink",stdout:"source",stderr:"source",exit:"async",terminate:"async",dispose:"async",execToEnd:"async"},k={},Pi=0,re=Ei(ki,Si)({exec:(r,e)=>{let t=r.cwd,n=r.env?S(S({},process.env),r.env):process.env,u=we.spawn(r.cmd,r.args,{cwd:t,env:n,windowsHide:!0}),i=Pi++;k[i]={process:u,exit:new Promise((f,s)=>{u.once("error",s),u.once("close",(o,l)=>{f({code:o,signal:l})})}),stdin:N.sink(u.stdin),stdout:N.source(u.stdout),stderr:N.source(u.stderr)},e(null,i)},stdin:r=>k[r].stdin,stdout:r=>k[r].stdout,stderr:r=>k[r].stderr,exit:(r,e)=>{k[r].exit.then(t=>e(null,t),e)},terminate:(r,e)=>{k[r].process.kill("SIGKILL"),e()},dispose:(r,e)=>{delete k[r],e()},execToEnd:(r,e)=>{let t=r.cwd,n=r.env?S(S({},process.env),r.env):process.env,u=we.spawn(r.cmd,r.args,{cwd:t,env:n,windowsHide:!0}),i=[];u.stdout.on("data",s=>i.push(s));let f=[];u.stderr.on("data",s=>f.push(s)),u.once("error",e),u.once("close",(s,o)=>{e(null,{stdout:Buffer.concat(i),stderr:Buffer.concat(f),code:s,signal:o})})}});(0,me.default)(N.source(process.stdin),re.createStream(),N.sink(process.stdout));function Bi(r){return function(t,n){r(t,function(u,i){console.error(`logThrough: ${i==null?void 0:i.toString()}`),n(u,i)})}}var Un=Ln.map(async r=>{try{if(!(await(0,_e.promisify)(ee.lstat)(r)).isSocket())return;await(0,_e.promisify)(ee.unlink)(r)}catch(t){if(!(t&&t.code==="ENOENT"))throw t}let e=Rn.createServer(t=>{t=N.duplex(t),(0,me.default)(t,re[r](n=>{n&&console.error("Remote to local stream terminated with error:",n)}),t)});return new Promise(t=>e.listen(r,t))}),Jn;Un.push(new Promise(r=>Jn=r));In.createServer((r,e)=>{let t=[];r.on("data",n=>t.push(n)),r.on("end",()=>{re.rpc(Buffer.concat(t).toString(),(n,u)=>{n?(console.error(n),e.writeHead(500),e.end()):(e.writeHead(200),e.write(u,i=>{i&&console.error(i)}),e.end())})})}).listen(process.env.REMOTE_CONTAINERS_IPC,Jn);Promise.all(Un).then(()=>re.ready(r=>{r&&console.error(r)})).catch(r=>console.error(r));0&&(module.exports={logThrough});
  //# sourceMappingURL=remoteContainersServer.js.map
  