import { watch as d, unref as p } from "vue";
import { CHANNEL_TYPES as v } from "./useCommunicationChannels.js";
function b({
  selectedChannelType: e,
  selectedChannel: u,
  channels: c,
  selectedDialog: i,
  isChannelEmpty: m,
  isNewDialog: o,
  showDefaultChannelTooltipWithTimer: f,
  clearDefaultChannelTooltip: l
}) {
  const r = (n) => {
    if (!n || !n.channelId) {
      e.value = null, u.value = {}, l();
      return;
    }
    const a = n.channelId ? n.channelId.split(".")[0] : null, t = a ? I(a) : null;
    if (t) {
      e.value = t;
      const h = c.value.find((s) => s.channelId === n.channelId);
      u.value = h ?? {}, m(n.channelId) && o.value ? f() : l();
    }
  };
  return d(
    () => p(i),
    (n) => {
      r(n ?? null);
    },
    { immediate: !0, deep: !0 }
  ), {
    updateSelectedChannelFromDialog: r
  };
}
function I(e) {
  return e.includes("waba") ? "whatsapp" : e.includes("telegrambot") ? "telegram" : v.includes(e) ? e : null;
}
export {
  b as useCommunicationDialogSync
};
