import{EXEC_HOOKS as e,HOOK_EVENTS as t,HOOK_TOOL_MATCHERS as n}from"../definitions/exec-hooks.mjs";const r={PreCompact:3e3,PostToolUse:3e3},i={copilot:`hooks.json`,claude:`hooks-settings.json`,copilotCli:`hooks.json`};function a(e,t){return(e.matcher||[]).flatMap(e=>{let r=n[e];if(!r)throw Error(`Unknown hook matcher: ${e}`);return r[t]||[]})}function o(e,t,n,i){let o=`${n}/${e.script}`;return a(e,i),i===`copilot`?{event:t,steps:[{type:`command`,command:`node`,args:[o],timeout:r[e.event]||5e3}]}:i===`claude`?{type:`command`,command:`node ${o}`}:{command:`node`,args:[o]}}function s(n,r){if(n===`copilot`){let a=Object.values(e).map(e=>{let i=t[e.event]?.[n];if(!i)throw Error(`Unsupported hook event ${e.event} for ${n}`);return o(e,i,r,n)});return[{path:i[n],content:JSON.stringify({hooks:a},null,2)}]}let a={};for(let i of Object.values(e)){let e=t[i.event]?.[n];if(!e)throw Error(`Unsupported hook event ${i.event} for ${n}`);a[e]||=[],a[e].push(o(i,e,r,n))}return[{path:i[n],content:JSON.stringify({hooks:a},null,2)}]}function c(){return[`_runtime.mjs`,...Object.values(e).map(e=>e.script)]}export{s as generateHooks,c as getHookScriptFiles};