e=E;function k(w){if(typeof w!="string")return k(E(w).stack);const g=w;if(g){const o=c(g),l=/at [^\/]*((?:(?:[a-zA-Z]+:)|(?:[\/])|(?:\\\\))(?:.+)):(\d+):(\d+)/.exec(o||"");if(l&&l.length===4)return{uri:m.URI.file(l[1]),line:Number(l[2]),column:Number(l[3])}}}e.getFirstFrame=k;function c(w){if(!w)return w;const g=w.indexOf(`
`);return g===-1?w:w.substring(0,g)}function s(w,g){const{args:o,stack:l}=E(w),h=typeof o[0]=="string"&&o.length===1;let B=c(l);B&&(B=`(${B.trim()})`);let W=[];if(typeof o[0]=="string"?B&&h?W=[`%c[${g}] %c${o[0]} %c${B}`,S("blue"),S(""),S("grey")]:W=[`%c[${g}] %c${o[0]}`,S("blue"),S(""),...o.slice(1)]:W=[`%c[${g}]%`,S("blue"),...o],B&&!h&&W.push(B),typeof console[w.severity]!="function")throw new Error("Unknown console method");console[w.severity].apply(console,W)}e.log=s;function S(w){return`color: ${w}`}}),define(L[10],$([0,1]),function(T,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.refineServiceDecorator=e.createDecorator=e.IInstantiationService=e._util=void 0;var m;(function(c){c.serviceIds=new Map,c.DI_TARGET="$di$target",c.DI_DEPENDENCIES="$di$dependencies";function s(S){return S[c.DI_DEPENDENCIES]||[]}c.getServiceDependencies=s})(m=e._util||(e._util={})),e.IInstantiationService=E("instantiationService");function b(c,s,S){s[m.DI_TARGET]===s?s[m.DI_DEPENDENCIES].push({id:c,index:S}):(s[m.DI_DEPENDENCIES]=[{id:c,index:S}],s[m.DI_TARGET]=s)}function E(c){if(m.serviceIds.has(c))return m.serviceIds.get(c);const s=function(S,w,g){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");b(s,S,g)};return s.toString=()=>c,m.serviceIds.set(c,s),s}e.createDecorator=E;function k(c){return c}e.refineServiceDecorator=k}),define(L[11],$([0,1,19,10]),function(T,e,m,b){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ipcSharedProcessWorkerChannelName=e.ISharedProcessWorkerService=e.hash=void 0;function E(k){return(0,m.hash)({moduleId:k.process.moduleId,windowId:k.reply.windowId})}e.hash=E,e.ISharedProcessWorkerService=(0,b.createDecorator)("sharedProcessWorkerService"),e.ipcSharedProcessWorkerChannelName="sharedProcessWorker"}),define(L[12],$([0,1]),function(T,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SharedProcessWorkerMessages=void 0;var m;(function(b){b.Spawn="vscode:shared-process->shared-process-worker=spawn",b.Terminate="vscode:shared-process->shared-process-worker=terminate",b.SelfTerminated="vscode:shared-process-worker->shared-process=selfTerminated",b.Ready="vscode:shared-process-worker->shared-process=ready",b.Ack="vscode:shared-process-worker->shared-process=ack",b.Trace="vscode:shared-process-worker->shared-process=trace",b.Info="vscode:shared-process-worker->shared-process=info",b.Warn="vscode:shared-process-worker->shared-process=warn",b.Error="vscode:shared-process-worker->shared-process=error"})(m=e.SharedProcessWorkerMessages||(e.SharedProcessWorkerMessages={}))}),define(L[20],$([0,1,21,22,4,9,6,23,3,24,7,8,11,12]),function(T,e,m,b,E,k,c,s,S,w,g,o,l,h){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.create=void 0;function B(){const A=new W;return N({id:h.SharedProcessWorkerMessages.Ready}),{onmessage:(n,t)=>A.onMessage(n,t)}}e.create=B;class W{constructor(){this.processes=new Map}onMessage(n,t){switch(n.id){case h.SharedProcessWorkerMessages.Spawn:t&&t[0]instanceof MessagePort&&n.environment&&this.spawn(t[0],n.configuration,n.environment);break;case h.SharedProcessWorkerMessages.Terminate:this.terminate(n.configuration);break;default:R.warn(`Unexpected shared process message '${n}'`)}n.nonce&&N({id:h.SharedProcessWorkerMessages.Ack,nonce:n.nonce})}spawn(n,t,a){try{this.terminate(t);const f=new _(n,t,a);f.spawn();const u=s.Event.once(f.onDidProcessSelfTerminate)(y=>{N({id:h.SharedProcessWorkerMessages.SelfTerminated,configuration:t,message:JSON.stringify(y)})}),D=(0,l.hash)(t);this.processes.set(D,(0,S.toDisposable)(()=>{u.dispose(),f.dispose(),this.processes.delete(D)}))}catch(f){R.error(`Unexpected error forking worker process: ${(0,c.toErrorMessage)(f)}`)}}terminate(n){this.processes.get((0,l.hash)(n))?.dispose()}}class _ extends S.Disposable{constructor(n,t,a){super(),this.port=n,this.configuration=t,this.environment=a,this._onDidProcessSelfTerminate=this._register(new s.Emitter),this.onDidProcessSelfTerminate=this._onDidProcessSelfTerminate.event,this.child=void 0}spawn(){R.trace("Forking worker process"),this.child=(0,m.fork)(this.environment.bootstrapPath,[`--type=${this.configuration.process.type}`],{env:this.getEnv()}),R.info(`Starting worker process with pid ${this.child.pid} (type: ${this.configuration.process.type}, window: ${this.configuration.reply.windowId}).`);const n=s.Event.fromNodeEventEmitter(this.child,"error");this._register(n(y=>R.warn(`Error from child process: ${(0,c.toErrorMessage)(y)}`)));const t=s.Event.fromNodeEventEmitter(this.child,"exit",(y,O)=>({code:y,signal:O}));this._register(t(({code:y,signal:O})=>{const i=`Worker process with pid ${this.child?.pid} terminated by itself with code ${y}, signal: ${O} (type: ${this.configuration.process.type}, window: ${this.configuration.reply.windowId})`;y!==0&&O!=="SIGTERM"?R.error(i):R.info(i),this.child=void 0,this._onDidProcessSelfTerminate.fire({code:(0,g.withNullAsUndefined)(y),signal:(0,g.withNullAsUndefined)(O)})}));const a=this._register(new s.Emitter),f=s.Event.fromNodeEventEmitter(this.child,"message",y=>y);this._register(f(y=>{(0,k.isRemoteConsoleLog)(y)?(0,b.log)(y,"SharedProcess worker"):a.fire(E.VSBuffer.wrap(Buffer.from(y,"base64")))}));const u=y=>{this.child?.connected?this.child.send(y.buffer.toString("base64")):R.warn("Unable to deliver message to disconnected child")},D=a.event;this._register(D(y=>this.port.postMessage(y.buffer))),this.port.onmessage=y=>u(E.VSBuffer.wrap(y.data)),this._register((0,S.toDisposable)(()=>this.port.onmessage=null))}getEnv(){const n={...(0,w.deepClone)(process.env),VSCODE_AMD_ENTRYPOINT:this.configuration.process.moduleId,VSCODE_PIPE_LOGGING:"true",VSCODE_VERBOSE_LOGGING:"true",VSCODE_PARENT_PID:String(process.pid)};return(0,o.removeDangerousEnvVariables)(n),n}dispose(){super.dispose(),this.child&&(this.child.kill(),R.info(`Worker process with pid ${this.child?.pid} terminated normally (type: ${this.configuration.process.type}, window: ${this.configuration.reply.windowId}).`))}}var R;(function(A){function n(u){N({id:h.SharedProcessWorkerMessages.Error,message:u})}A.error=n;function t(u){N({id:h.SharedProcessWorkerMessages.Warn,message:u})}A.warn=t;function a(u){N({id:h.SharedProcessWorkerMessages.Info,message:u})}A.info=a;function f(u){N({id:h.SharedProcessWorkerMessages.Trace,message:u})}A.trace=f})(R||(R={}));function N(A){postMessage(A)}})}).call(this);

//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/8fa188b2b301d36553cbc9ce1b0a146ccb93351f/core/vs/platform/sharedProcess/electron-browser/sharedProcessWorkerMain.js.map
