//#region node_modules/hookable/dist/index.mjs function callHooks(hooks, args, startIndex, task) { for (let i = startIndex; i < hooks.length; i += 1) try { const result = task ? task.run(() => hooks[i](...args)) : hooks[i](...args); if (result && typeof result.then === "function") return Promise.resolve(result).then(() => callHooks(hooks, args, i + 1, task)); } catch (error) { return Promise.reject(error); } } var HookableCore = class { _hooks; constructor() { this._hooks = {}; } hook(name, fn) { if (!name || typeof fn !== "function") return () => {}; this._hooks[name] = this._hooks[name] || []; this._hooks[name].push(fn); return () => { if (fn) { this.removeHook(name, fn); fn = void 0; } }; } removeHook(name, function_) { const hooks = this._hooks[name]; if (hooks) { const index = hooks.indexOf(function_); if (index !== -1) hooks.splice(index, 1); if (hooks.length === 0) this._hooks[name] = void 0; } } callHook(name, ...args) { const hooks = this._hooks[name]; if (!hooks || hooks.length === 0) return; return callHooks(hooks, args, 0); } }; //#endregion export { HookableCore as t };