import { computed as c, unref as i } from "vue";
/* empty css                                            */
import M from "../icons/CommunicationPanelPhoneIcon.vue.js";
import b from "../icons/CommunicationPanelWhatsAppIcon.vue.js";
import w from "../icons/CommunicationPanelTelegramIcon.vue.js";
import x from "../icons/CommunicationPanelMaxIcon.vue.js";
import A from "../icons/CommunicationPanelSMSIcon.vue.js";
import y from "../icons/CommunicationPanelSubmenuPhoneIcon.vue.js";
import E from "../icons/CommunicationPanelSubmenuWhatsAppIcon.vue.js";
import F from "../icons/CommunicationPanelSubmenuTelegramIcon.vue.js";
import L from "../icons/CommunicationPanelSubmenuMaxIcon.vue.js";
import N from "../icons/CommunicationPanelSubmenuSMSIcon.vue.js";
const I = ["whatsapp", "telegram", "max", "sms", "phone"], _ = ["max", "telegram", "whatsapp", "sms", "phone"];
function g(a) {
  return I.includes(a);
}
function D(a, r) {
  const u = (a ?? _).filter(g), m = r === void 0 ? [...I] : r.filter(g), p = new Set(m), t = /* @__PURE__ */ new Set(), l = [];
  for (const o of u)
    p.has(o) && !t.has(o) && (t.add(o), l.push(o));
  for (const o of m)
    t.has(o) || (t.add(o), l.push(o));
  return l;
}
const H = {
  phone: M,
  whatsapp: b,
  telegram: w,
  max: x,
  sms: A
}, R = {
  phone: y,
  whatsapp: E,
  telegram: F,
  max: L,
  sms: N
}, W = {
  phone: "Позвонить",
  whatsapp: "Выберите контакт и канал для отправки сообщения",
  telegram: "Выберите контакт и канал для отправки сообщения",
  max: "Выберите контакт и канал для отправки сообщения",
  sms: "Выберите контакт и канал для отправки сообщения"
};
function Z({
  channels: a,
  channelTooltips: r,
  channelOrder: u,
  visibleChannelTypes: m,
  selectedChannelType: p
}) {
  const t = c(() => i(a) ?? []), l = c(() => i(r) ?? {}), o = c(
    () => D(i(u), i(m))
  ), d = c(
    () => o.value.map((n) => ({
      type: n,
      component: H[n]
    }))
  ), S = (n) => {
    const e = l.value[n];
    return e || (W[n] ?? "");
  }, s = (n) => {
    if (!n) return null;
    const [e] = n.split(".");
    return e.includes("waba") ? "whatsapp" : e.includes("telegrambot") ? "telegram" : e;
  }, P = (n) => t.value.filter((e) => s(e.channelId) === n).length > 1, T = (n) => p.value === n, C = (n) => {
    const e = t.value.filter((v) => s(v.channelId) === n);
    return e.length === 1 ? e[0] : null;
  }, h = (n) => R[n] ?? null, f = (n) => {
    const e = s(n);
    return e ? h(e) : null;
  };
  return {
    panelChannelTypes: o,
    channelsTypes: d,
    getTooltipText: S,
    getChannelTypeFromId: s,
    hasMultipleChannels: P,
    isChannelActive: T,
    getSingleChannelForType: C,
    getMenuChannelIconComponent: h,
    getMenuChannelIconComponentForChannelId: f,
    getSingleMenuChannelIconComponent: (n) => {
      const e = C(n);
      return e ? f(e.channelId) : h(n);
    },
    getAvailableChannels: (n) => t.value.filter((e) => s(e.channelId) === n)
  };
}
export {
  I as CHANNEL_TYPES,
  _ as DEFAULT_CHANNEL_ORDER,
  g as isChannelType,
  D as resolvePanelChannelTypes,
  Z as useCommunicationChannels
};
