import{t as e}from"./DTkg6Mnx.js";var t={onSessionStart:`SessionStart`,onSessionEnd:`SessionEnd`,onToolStart:`PreToolUse`,onToolComplete:`PostToolUse`,onFileChange:`Notification`,onError:`PostToolUseFailure`,onPromptSubmit:`PromptSubmit`,onResponseComplete:`ResponseComplete`},n={enabled:!0,events:{SessionStart:!0,SessionEnd:!0,PromptSubmit:!0,ResponseComplete:!0,PreToolUse:!0,PostToolUse:!0,PostToolUseFailure:!0,PermissionRequest:!0,SubagentStart:!0,SubagentStop:!0,PreModel:!0,PostModel:!0,PreCompact:!0,PostCompact:!0,Notification:!0,ConfigChange:!0,onWorkAvailable:!0,onAgentSpawn:!0,onAgentComplete:!0,onCascadeStart:!0,onPatrol:!0}},r=class{handlers=new Map;config=n;resolveEvent(n){let r=t[n];return r?(e(`hooks`).warn({legacyEvent:n,canonicalEvent:r},`[DEPRECATED] Hook event '${n}' has been renamed to '${r}'. Update your handler registration.`),r):n}register(e){let t=this.resolveEvent(e.event),n={...e,event:t},r=this.handlers.get(t)||[];return r.push(n),r.sort((e,t)=>t.priority-e.priority),this.handlers.set(t,r),()=>{let n=this.handlers.get(t);if(n){let t=n.findIndex(t=>t.id===e.id);t!==-1&&n.splice(t,1)}}}async dispatch(t,n,r){if(!this.config.enabled)return;let i=this.resolveEvent(t);if(!this.config.events[i])return;let a=this.handlers.get(i);!a||a.length===0||await Promise.allSettled(a.map(async t=>{try{await t.handler(n,r)}catch(n){e(`hooks`).warn({err:n,hookId:t.id,event:i},`Hook handler failed`)}}))}isEnabled(e){let t=this.resolveEvent(e);return this.config.enabled&&this.config.events[t]}setConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}listHandlers(e){let t=this.resolveEvent(e);return[...this.handlers.get(t)||[]]}},i=new r;export{i as n,r as t};