# shellcheck shell=dash

xrc:mod:lib    hotkey   co/cfg
if [ -n "$ZSH_VERSION" ]; then
    xrc:mod hotkey/lib/co/bind.zsh
elif [ -n "$BASH_VERSION" ]; then
    xrc:mod hotkey/lib/co/bind.bash
fi

___x_cmd_hotkey_co(){
    local op="$1";
    case "$op" in
        -h|--help)  ___x_cmd help -m hotkey co; return ;;
        --exec)     shift; ___x_cmd_hotkey_co_exec "$@"; return ;;
        --bind)
                    ___x_cmd_hotkey___widget_supported co || return 1
                    shift;
                    local cur_emoji=""
                    ___x_cmd_hotkey_co_cur cur_emoji:=emoji 2>/dev/null
                    ___X_CMD_HOTKEY_CO_EMOJI="${cur_emoji:-"🤖"}"
                    ___x_cmd_hotkey_co_bind "$@"; return ;;
        init)       shift; ___x_cmd_hotkey_co_init "$@"; return ;;
        cfg)        shift; ___x_cmd_hotkey_co_cfg "$@"; return ;;
    esac
}

___x_cmd_hotkey_co_exec(){
    local cur_aicmd=""
    ___x_cmd_hotkey_co_cur cur_aicmd:=aicmd 2>/dev/null
    cur_aicmd="${cur_aicmd:-"kimi -c"}"

    eval "set -- $cur_aicmd \"\$*\""
    "$@"
}
