/* Socket Lib - Built with esbuild */
var g=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var s in t)g(e,s,{get:t[s],enumerable:!0})},w=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!P.call(e,r)&&r!==s&&g(e,r,{get:()=>t[r],enumerable:!(n=G(t,r))||n.enumerable});return e};var R=e=>w(g({},"__esModule",{value:!0}),e);var U={};T(U,{load:()=>v,onExit:()=>k,signals:()=>C,unload:()=>E});module.exports=R(U);const S=Reflect.apply,i=globalThis.process,p=i?.emit,y=i?.platform??"",x=i?.reallyExit,b=y==="win32";let m;function N(){return m===void 0&&(m=require("node:events")),m}let o;function d(){if(o===void 0){if(i?.__signal_exit_emitter__)o=i.__signal_exit_emitter__;else if(i){const e=N().EventEmitter;o=i.__signal_exit_emitter__=new e,o.count=0,o.emitted={__proto__:null}}o&&!o.infinite&&(o.setMaxListeners(Number.POSITIVE_INFINITY),o.infinite=!0)}return o}let c;function L(){if(c===void 0){c={__proto__:null};const e=d(),t=_();for(const s of t)c[s]=function(){if((i?.listeners(s)||[]).length===e.count){const a=b&&s==="SIGHUP"?"SIGINT":s;i?.kill(i?.pid,a)}}}return c}let l;function _(){return l===void 0&&(l=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],b||l.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),y==="linux"&&l.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")),l}function u(e,t,s){const n=d();n.emitted?.[e]||(n.emitted&&(n.emitted[e]=!0),n.emit(e,t,s))}let f=!1;function v(){if(f||!i)return;f=!0;const e=d();e.count!==void 0&&(e.count+=1);const t=_(),s=L();l=t.filter(n=>{try{return i.on(n,s[n]),!0}catch{}return!1}),i.emit=O,i.reallyExit=M}function O(e,t,...s){if(e==="exit"){let n=t;if(n===void 0){const I=i?.exitCode;n=typeof I=="number"?I:void 0}else i&&(i.exitCode=n);const r=S(p,this,[e,n,...s]),a=typeof n=="number"?n:null;return r}return S(p,this,[e,t,...s])}function M(e){const t=e||0;throw i&&(i.exitCode=t),S(x,i,[t]),new Error("processReallyExit should never return")}function k(e,t){if(!i)return function(){};if(typeof e!="function")throw new TypeError("a callback must be provided for exit handler");const{alwaysLast:s}={__proto__:null,...t};let n="exit";s&&(n="afterexit");const r=d();return r.on(n,e),function(){r.removeListener(n,e),!r.listeners("exit").length&&r.listeners("afterexit").length}}function C(){return l}function E(){if(!f||!i)return;f=!1;const e=_(),t=L();for(const n of e)try{i.removeListener(n,t[n])}catch{}i.emit=p,x!==void 0&&(i.reallyExit=x);const s=d();s.count!==void 0&&(s.count-=1)}0&&(module.exports={load,onExit,signals,unload});
//# sourceMappingURL=signal-exit.js.map
