import{n as e}from"./chunk-DR8-3Aex.js";import{B as t,E as n,O as r,U as i}from"./debug-otxXY3j-.js";import{FT as a,HT as o,IT as s,PT as c,UT as l,VT as u,WT as d,zT as f}from"./loadAgentsDir-C_wFhytF.js";import{r as p,t as m}from"./promptEditor-Dz41P-3I.js";import{dirname as h}from"path";import{mkdir as g,writeFile as _}from"fs/promises";function v(e){let t=new Set(f.map(e=>o(e.key)));return e.map(e=>{let n={};for(let[r,i]of Object.entries(e.bindings))t.has(o(r))||(n[r]=i);return{context:e.context,bindings:n}}).filter(e=>Object.keys(e.bindings).length>0)}function y(){return r({$schema:`https://www.schemastore.org/claude-code-keybindings.json`,$docs:`https://code.claude.com/docs/en/keybindings`,bindings:v(l)},null,2)+`
`}var b=e((()=>{n(),d(),u()}));async function x(){if(!s())return{type:`text`,value:`Keybinding customization is not enabled. This feature is currently in preview.`};let e=c(),n=!1;await g(h(e),{recursive:!0});try{await _(e,y(),{encoding:`utf-8`,flag:`wx`})}catch(e){if(t(e)===`EEXIST`)n=!0;else throw e}let r=await m(e);return r.error?{type:`text`,value:`${n?`Opened`:`Created`} ${e}. Could not open in editor: ${r.error}`}:{type:`text`,value:n?`Opened ${e} in your editor.`:`Created ${e} with template. Opened in your editor.`}}e((()=>{a(),b(),i(),p()}))();export{x as call};