// @bun
import{KG as T}from"./chunk-vk8psqqh.js";import{MG as G,PG as J}from"./chunk-xyhgvt88.js";var K=G((Q)=>{Object.defineProperty(Q,"__esModule",{value:!0});Q.AbstractAsyncHooksContextManager=void 0;var b=J("events"),f=["addListener","on","once","prependListener","prependOnceListener"];class P{bind(q,j){if(j instanceof b.EventEmitter)return this._bindEventEmitter(q,j);if(typeof j==="function")return this._bindFunction(q,j);return j}_bindFunction(q,j){let z=this,w=function(...B){return z.with(q,()=>j.apply(this,B))};return Object.defineProperty(w,"length",{enumerable:!1,configurable:!0,writable:!1,value:j.length}),w}_bindEventEmitter(q,j){if(this._getPatchMap(j)!==void 0)return j;if(this._createPatchMap(j),f.forEach((w)=>{if(j[w]===void 0)return;j[w]=this._patchAddListener(j,j[w],q)}),typeof j.removeListener==="function")j.removeListener=this._patchRemoveListener(j,j.removeListener);if(typeof j.off==="function")j.off=this._patchRemoveListener(j,j.off);if(typeof j.removeAllListeners==="function")j.removeAllListeners=this._patchRemoveAllListeners(j,j.removeAllListeners);return j}_patchRemoveListener(q,j){let z=this;return function(w,B){let D=z._getPatchMap(q)?.[w];if(D===void 0)return j.call(this,w,B);let E=D.get(B);return j.call(this,w,E||B)}}_patchRemoveAllListeners(q,j){let z=this;return function(w){let B=z._getPatchMap(q);if(B!==void 0){if(arguments.length===0)z._createPatchMap(q);else if(B[w]!==void 0)delete B[w]}return j.apply(this,arguments)}}_patchAddListener(q,j,z){let w=this;return function(B,D){if(w._wrapped)return j.call(this,B,D);let E=w._getPatchMap(q);if(E===void 0)E=w._createPatchMap(q);let F=E[B];if(F===void 0)F=new WeakMap,E[B]=F;let O=w.bind(z,D);F.set(D,O),w._wrapped=!0;try{return j.call(this,B,O)}finally{w._wrapped=!1}}}_createPatchMap(q){let j=Object.create(null);return q[this._kOtListeners]=j,j}_getPatchMap(q){return q[this._kOtListeners]}_kOtListeners=Symbol("OtListeners");_wrapped=!1}Q.AbstractAsyncHooksContextManager=P});var Y=G((V)=>{Object.defineProperty(V,"__esModule",{value:!0});V.AsyncHooksContextManager=void 0;var u=T(),L=J("async_hooks"),N=K();class U extends N.AbstractAsyncHooksContextManager{_asyncHook;_contexts=new Map;_stack=[];constructor(){super();this._asyncHook=L.createHook({init:this._init.bind(this),before:this._before.bind(this),after:this._after.bind(this),destroy:this._destroy.bind(this),promiseResolve:this._destroy.bind(this)})}active(){return this._stack[this._stack.length-1]??u.ROOT_CONTEXT}with(q,j,z,...w){this._enterContext(q);try{return j.call(z,...w)}finally{this._exitContext()}}enable(){return this._asyncHook.enable(),this}disable(){return this._asyncHook.disable(),this._contexts.clear(),this._stack=[],this}_init(q,j){if(j==="TIMERWRAP")return;let z=this._stack[this._stack.length-1];if(z!==void 0)this._contexts.set(q,z)}_destroy(q){this._contexts.delete(q)}_before(q){let j=this._contexts.get(q);if(j!==void 0)this._enterContext(j)}_after(){this._exitContext()}_enterContext(q){this._stack.push(q)}_exitContext(){this._stack.pop()}}V.AsyncHooksContextManager=U});var S=G(($)=>{Object.defineProperty($,"__esModule",{value:!0});$.AsyncLocalStorageContextManager=void 0;var H=T(),k=J("async_hooks"),_=K();class Z extends _.AbstractAsyncHooksContextManager{_asyncLocalStorage;constructor(){super();this._asyncLocalStorage=new k.AsyncLocalStorage}active(){return this._asyncLocalStorage.getStore()??H.ROOT_CONTEXT}with(q,j,z,...w){let B=z==null?j:j.bind(z);return this._asyncLocalStorage.run(q,B,...w)}enable(){return this}disable(){return this._asyncLocalStorage.disable(),this}}$.AsyncLocalStorageContextManager=Z});var h=G((I)=>{Object.defineProperty(I,"__esModule",{value:!0});I.AsyncLocalStorageContextManager=I.AsyncHooksContextManager=void 0;var C=Y();Object.defineProperty(I,"AsyncHooksContextManager",{enumerable:!0,get:function(){return C.AsyncHooksContextManager}});var y=S();Object.defineProperty(I,"AsyncLocalStorageContextManager",{enumerable:!0,get:function(){return y.AsyncLocalStorageContextManager}})});
export{h as vw};
