import { ref as v, computed as d, createElementBlock as a, openBlock as i, createElementVNode as t, toDisplayString as u, withDirectives as m, Fragment as f, renderList as p, vModelSelect as _ } from "vue";
/* empty css                  */
import D from "../../../_virtual/_plugin-vue_export-helper.js";
const S = { class: "modal__contact-line" }, k = ["value"], q = { class: "modal__channel-line" }, w = ["disabled"], x = ["value"], V = ["disabled"], A = {
  __name: "CreateDialog",
  props: {
    title: {
      type: String,
      required: !0
    },
    name: {
      type: String,
      required: !0
    },
    contacts: {
      type: Array,
      required: !0
    },
    channels: {
      type: Array,
      required: !0
    },
    filter: {
      type: Function,
      required: !1,
      default: null
    }
  },
  emits: ["change", "submit"],
  setup(o, { emit: g }) {
    const r = o, s = v(), n = v(), y = d(() => !!(s.value && n.value)), b = d(() => !!(r.filter && n.value || !r.filter)), h = d(() => r.filter && n.value ? r.filter(n.value, r.channels) : r.channels), c = g, C = () => {
      c("change", { channel: s.value, contact: n.value }), c("submit");
    };
    return (B, l) => (i(), a("div", null, [
      t("h3", null, u(o.title), 1),
      t("div", null, " Контакт: " + u(o.name), 1),
      t("div", S, [
        l[2] || (l[2] = t("h3", { style: { margin: "0" } }, " Куда пишем ", -1)),
        m(t("select", {
          id: "folder",
          "onUpdate:modelValue": l[0] || (l[0] = (e) => n.value = e)
        }, [
          (i(!0), a(f, null, p(o.contacts, (e) => (i(), a("option", {
            key: e.id || e.value,
            value: e
          }, u(e.value), 9, k))), 128))
        ], 512), [
          [_, n.value]
        ])
      ]),
      t("div", q, [
        l[3] || (l[3] = t("h3", { style: { margin: "0" } }, " Через какой канал ", -1)),
        m(t("select", {
          id: "folder",
          "onUpdate:modelValue": l[1] || (l[1] = (e) => s.value = e),
          disabled: !b.value
        }, [
          (i(!0), a(f, null, p(h.value, (e) => (i(), a("option", {
            key: e.id || e.title,
            value: e
          }, u(e.title), 9, x))), 128))
        ], 8, w), [
          [_, s.value]
        ])
      ]),
      t("button", {
        type: "button",
        class: "modal__button-start",
        "aria-label": "Close modal",
        disabled: !y.value,
        onClick: C
      }, " Начать диалог ", 8, V)
    ]));
  }
}, I = /* @__PURE__ */ D(A, [["__scopeId", "data-v-c9b375bd"]]);
export {
  I as default
};
