import { ref as x, computed as c, nextTick as n, createElementBlock as v, openBlock as k, createElementVNode as e, withDirectives as b, vModelText as g } from "vue";
import { uploadText as w, parseMd as T } from "./composables-BAZQlC3e.js";
import { _export_sfc as M } from "./_plugin-vue_export-helper-DueaC3du.js";
const y = { class: "flex flex-col" }, C = { class: "flex flex-col text-left" }, F = { class: "flex flex-wrap bg-dark-100 p-4" }, $ = {
  __name: "FormText",
  props: {
    text: { type: String, default: "" }
  },
  emits: ["update:text", "frontmatter", "close"],
  setup(a, { emit: i }) {
    const r = i, d = a, m = x(!1), s = c({
      get() {
        return d.text;
      },
      set(o) {
        r("update:text", o);
      }
    });
    n(() => {
    });
    function p(o) {
      var t;
      w((t = o.target) == null ? void 0 : t.files, (l) => {
        let { frontmatter: u, content: f } = T(l);
        r("frontmatter", u), f && (m.value = !0, n(() => {
        }));
      });
    }
    return (o, t) => (k(), v("div", y, [
      e("div", C, [
        b(e("textarea", {
          class: "dark-bg-dark-200 p-2",
          id: "myMD",
          ref: "md",
          "onUpdate:modelValue": t[0] || (t[0] = (l) => s.value = l),
          placeholder: "Main text content (with **markdown** support)"
        }, null, 512), [
          [g, s.value]
        ])
      ]),
      e("div", F, [
        e("button", {
          class: "button m-1",
          onClick: t[1] || (t[1] = (l) => o.$emit("close"))
        }, t[4] || (t[4] = [
          e("div", { class: "i-la-check" }, null, -1),
          e("div", { class: "ml-2" }, "Save", -1)
        ])),
        t[6] || (t[6] = e("label", {
          class: "m-1 button cursor-pointer flex items-center",
          for: "import-post"
        }, [
          e("div", { class: "i-la-markdown" }),
          e("div", { class: "ml-2" }, "Load")
        ], -1)),
        e("input", {
          class: "hidden dark-bg-dark-200",
          id: "import-post",
          ref: "file",
          tabindex: "-1",
          type: "file",
          accept: "text/markdown",
          onChange: t[2] || (t[2] = (l) => p(l))
        }, null, 544),
        t[7] || (t[7] = e("div", { class: "flex-1" }, null, -1)),
        e("button", {
          class: "button m-1",
          onClick: t[3] || (t[3] = (l) => s.value = "")
        }, t[5] || (t[5] = [
          e("div", { class: "i-la-trash" }, null, -1),
          e("div", { class: "ml-2" }, "Reset", -1)
        ]))
      ])
    ]));
  }
}, S = /* @__PURE__ */ M($, [["__scopeId", "data-v-a0d4e179"]]);
export {
  S as default
};
//# sourceMappingURL=FormText-BgEiwPJM.js.map
