import { useCssVars as j, computed as m, ref as p, onMounted as z, reactive as D, createElementBlock as x, openBlock as b, withDirectives as k, createCommentVNode as I, createElementVNode as o, createVNode as n, vModelText as C, withKeys as M, withModifiers as N, normalizeClass as y, unref as u, withCtx as g } from "vue";
import { useColor as T, addPost as B } from "./composables-BAZQlC3e.js";
import { FormPicture as U, FormLink as E, FormYoutube as K, UiLayer as $, FormText as L } from "./components.js";
import { _export_sfc as c } from "./_plugin-vue_export-helper-DueaC3du.js";
const A = {
  class: "w-full flex flex-col p-2 shadow-xl m-1 rounded-2xl",
  action: "javascript:void(0);"
}, H = { class: "flex flex-wrap z-100" }, R = { class: "flex justify-center flex-1" }, Y = ["disabled"], q = {
  __name: "PostForm",
  props: {
    tag: {
      type: String,
      default: " "
    }
  },
  emits: ["close"],
  setup(w, { emit: F }) {
    j((i) => ({
      "569a1dcc": S.value
    }));
    const r = w, V = F, P = T("deep"), S = m(() => P.hex(r.tag)), a = p();
    z(() => {
      var i;
      (i = a.value) == null || i.focus();
    });
    const l = p({}), s = D({
      form: !1,
      youtube: !1,
      text: !1
    }), d = m(() => l.value.title || l.value.statement || l.value.text || l.value.cover);
    function f() {
      if (!d.value) return;
      const i = {
        ...l.value
      };
      B(r.tag, i), v();
    }
    function v() {
      s.form = !1, l.value = {}, V("close");
    }
    return (i, t) => (b(), x("form", A, [
      s.title ? k((b(), x("input", {
        key: 0,
        class: "font-bold text-xl dark-bg-dark-200",
        ref_key: "titleInput",
        ref: a,
        "onUpdate:modelValue": t[0] || (t[0] = (e) => l.value.title = e),
        placeholder: "Title",
        autofocus: ""
      }, null, 512)), [
        [C, l.value.title]
      ]) : I("", !0),
      k(o("textarea", {
        class: "text-1rem leading-relaxed dark-bg-dark-200",
        "onUpdate:modelValue": t[1] || (t[1] = (e) => l.value.statement = e),
        placeholder: "Short text statement",
        onKeyup: t[2] || (t[2] = M(N((e) => f(), ["ctrl"]), ["enter"]))
      }, null, 544), [
        [C, l.value.statement]
      ]),
      o("div", H, [
        o("button", {
          class: y(["button m-1", { active: l.value.title }]),
          title: "Add a heading",
          onClick: t[3] || (t[3] = (e) => s.title = !s.title)
        }, "H1", 2),
        n(u(U), {
          field: "icon",
          options: { picSize: 400, preserveRatio: !1 },
          onUpdate: t[4] || (t[4] = (e) => l.value.icon = e)
        }, {
          default: g(() => t[15] || (t[15] = [
            o("div", { class: "i-la-info-circle" }, null, -1)
          ])),
          _: 1
        }),
        n(u(U), {
          onUpdate: t[5] || (t[5] = (e) => l.value.cover = e)
        }),
        n(u(E), {
          onUpdate: t[6] || (t[6] = (e) => l.value.link = e)
        }),
        n(u(K), {
          onUpdate: t[7] || (t[7] = (e) => l.value.youtube = e)
        }),
        o("button", {
          class: y(["m-1 button", { active: l.value.text }]),
          onClick: t[8] || (t[8] = (e) => s.text = !0)
        }, t[16] || (t[16] = [
          o("div", { class: "i-mdi-text-long" }, null, -1)
        ]), 2),
        t[19] || (t[19] = o("div", { class: "flex-1" }, null, -1)),
        o("div", R, [
          o("button", {
            class: "plus button flex-1 justify-center m-1",
            disabled: !d.value,
            type: "submit",
            onClick: t[9] || (t[9] = (e) => f())
          }, t[17] || (t[17] = [
            o("div", { class: "i-la-check" }, null, -1),
            o("div", { class: "font-bold ml-2" }, "Submit", -1)
          ]), 8, Y),
          o("button", {
            class: "m-1 button text-xl",
            onClick: t[10] || (t[10] = (e) => v())
          }, t[18] || (t[18] = [
            o("div", { class: "i-la-trash-alt" }, null, -1)
          ]))
        ])
      ]),
      n(u($), {
        open: s.youtube,
        offset: "22vh",
        onClose: t[11] || (t[11] = (e) => s.youtube = !1)
      }, null, 8, ["open"]),
      n(u($), {
        open: s.text,
        offset: "22vh",
        onClose: t[14] || (t[14] = (e) => s.text = !1)
      }, {
        default: g(() => [
          n(u(L), {
            text: l.value.text,
            "onUpdate:text": t[12] || (t[12] = (e) => l.value.text = e),
            onClose: t[13] || (t[13] = (e) => s.text = !1)
          }, null, 8, ["text"])
        ]),
        _: 1
      }, 8, ["open"])
    ]));
  }
}, W = /* @__PURE__ */ c(q, [["__scopeId", "data-v-c53fdb98"]]);
export {
  W as default
};
//# sourceMappingURL=PostForm-CFbyG7OO.js.map
