import { defineComponent as p, inject as g, useTemplateRef as C, watch as h, createBlock as n, openBlock as m, Transition as x, withCtx as i, createCommentVNode as y, unref as d, createElementVNode as B, normalizeClass as M } from "vue";
import { useMessageDraft as b } from "../../../hooks/useMessageDraft.js";
import "../../../hooks/useSearchModel.js";
import "../../../hooks/useTheme.js";
/* empty css                              */
/* empty css                                              */
import "../../../node_modules/linkifyjs/dist/linkify.js";
import "../../../node_modules/linkify-string/dist/linkify-string.js";
import "../../../functions/parseMarkdown.js";
import k from "../../1_atoms/ButtonContextMenu/ButtonContextMenu.vue.js";
const T = /* @__PURE__ */ p({
  __name: "ButtonCommandsSelector",
  props: {
    commands: {
      type: Array,
      required: !1,
      default: null
    },
    mode: {
      type: String,
      required: !1,
      default: "hover"
    },
    state: {
      type: String,
      default: "active"
    }
  },
  emits: ["send"],
  setup(e, { emit: r }) {
    const c = e, l = r, u = g("chatAppId"), { getMessage: s } = b(u), a = C("refBCM"), f = (t) => {
      console.log(t);
      const o = {
        type: "message.command",
        text: t.action
      };
      l("send", o);
    };
    return h(
      () => s().text,
      () => {
        var t, o;
        c.commands && (s().text.startsWith("/") ? (t = a.value) == null || t.updatePosition() : (o = a.value) == null || o.hideMenu());
      }
    ), (t, o) => (m(), n(x, null, {
      default: i(() => [
        e.commands ? (m(), n(k, {
          key: 0,
          ref_key: "refBCM",
          ref: a,
          "menu-side": "top",
          mode: e.mode,
          disabled: d(s)().isRecording || e.state == "disabled",
          actions: e.commands,
          onClick: f
        }, {
          default: i(() => [
            B("span", {
              class: M(["commands__trigger", { commands__disabled: d(s)().isRecording || e.state == "disabled" }])
            }, " / ", 2)
          ]),
          _: 1
        }, 8, ["mode", "disabled", "actions"])) : y("", !0)
      ]),
      _: 1
    }));
  }
});
export {
  T as default
};
