import { ref as c, watchEffect as x, computed as y, createElementBlock as s, openBlock as n, createCommentVNode as p, createElementVNode as l, withDirectives as g, unref as o, toDisplayString as a, vModelText as k } from "vue";
import { useNewProject as C, genUUID as D } from "./composables-BAZQlC3e.js";
const w = { class: "p-2" }, b = {
  key: 0,
  class: "flex flex-col gap-2 max-w-16em"
}, E = {
  class: "grid gap-2 items-center",
  style: { "grid-template-columns": "auto 1fr" }
}, $ = { class: "text-xs overflow-scroll" }, P = {
  __name: "ProjectForm",
  props: {
    title: { type: String, default: "" },
    source: { type: String, default: "" },
    required: { type: Array, default: ["id", "title"] }
  },
  emits: ["added"],
  setup(f, { emit: j }) {
    const i = f, u = c(!1), { newProject: t, addProject: v } = C();
    x(() => {
      t.title = i.title, t.source = i.source;
    });
    const m = y(() => i.required.reduce((d, e) => d && !!(t != null && t[e]), !0));
    return (d, e) => (n(), s("div", w, [
      u.value ? (n(), s("div", b, [
        l("div", E, [
          e[6] || (e[6] = l("h3", null, "ID: ", -1)),
          l("div", {
            class: "p-2 flex items-center cursor-pointer gap-1",
            onClick: e[0] || (e[0] = (r) => o(t).id = o(D)(6))
          }, [
            l("pre", null, a(o(t).id), 1),
            e[4] || (e[4] = l("div", { class: "flex-1" }, null, -1)),
            e[5] || (e[5] = l("div", { class: "i-la-sync" }, null, -1))
          ]),
          e[7] || (e[7] = l("h3", null, "Title:", -1)),
          g(l("input", {
            type: "text",
            "onUpdate:modelValue": e[1] || (e[1] = (r) => o(t).title = r)
          }, null, 512), [
            [k, o(t).title]
          ])
        ]),
        l("pre", $, a(o(t)), 1),
        m.value ? (n(), s("button", {
          key: 0,
          class: "button",
          onClick: e[2] || (e[2] = (r) => o(v)(() => d.$emit("added")))
        }, "ADD PROJECT " + a(m.value), 1)) : p("", !0)
      ])) : p("", !0),
      u.value ? p("", !0) : (n(), s("button", {
        key: 1,
        class: "button text-lg",
        onClick: e[3] || (e[3] = (r) => u.value = !0)
      }, "Add a new project"))
    ]));
  }
};
export {
  P as default
};
//# sourceMappingURL=ProjectForm-CvKTXg7G.js.map
