import { computed as x, ref as d, usePictureUpload as h, watch as p, openBlock as v, createElementBlock as f, unref as i, createCommentVNode as y, createBaseVNode as o, renderSlot as b, normalizeClass as C, createVNode as g, withCtx as k, pushScopeId as S, popScopeId as $ } from "./composables-108ad332.js";
import { UiLayer as w } from "./components.js";
import { _export_sfc as I } from "./_plugin-vue_export-helper-6a641814.js";
const P = (l) => (S("data-v-8b3f873f"), l = l(), $(), l), B = { class: "flex flex-wrap" }, F = ["id"], N = ["for"], V = /* @__PURE__ */ P(() => /* @__PURE__ */ o("div", { class: "i-la-image" }, null, -1)), z = { class: "button fixed text-2xl opacity-40 hover-opacity-100 m-4" }, U = { class: "button fixed text-2xl opacity-40 hover-opacity-100 mt-4 ml-18" }, j = ["src"], E = {
  __name: "FormPicture",
  props: {
    field: { type: String, default: "cover" },
    options: {
      type: Object,
      default: () => ({
        picSize: 800,
        preserveRatio: !0
      })
    }
  },
  emits: ["update"],
  setup(l, { emit: m }) {
    const r = l, u = x(() => `${r.field}_upload`), s = d(!1), a = d(), { state: _, handleChange: c } = h(r.options);
    return p(() => _.output, (t) => {
      t != null && t.content && (s.value = !0, a.value = t.content);
    }), p(a, (t) => {
      m("update", t);
    }), (t, e) => (v(), f("div", B, [
      a.value ? y("", !0) : (v(), f("input", {
        key: 0,
        class: "hidden",
        id: i(u),
        type: "file",
        accept: "image/*",
        onChange: e[0] || (e[0] = (...n) => i(c) && i(c)(...n))
      }, null, 40, F)),
      o("label", {
        class: C(["m-1 button cursor-pointer", { active: a.value }]),
        for: i(u),
        onClick: e[1] || (e[1] = (n) => s.value = !0)
      }, [
        b(t.$slots, "default", {}, () => [
          V
        ], !0)
      ], 10, N),
      g(i(w), {
        class: "max-h-60vh mt-20",
        open: s.value,
        onClose: e[4] || (e[4] = (n) => s.value = !1)
      }, {
        default: k(() => [
          o("button", z, [
            o("div", {
              class: "i-la-check",
              onClick: e[2] || (e[2] = (n) => s.value = !1)
            })
          ]),
          o("button", U, [
            o("div", {
              class: "i-la-trash-alt",
              onClick: e[3] || (e[3] = (n) => {
                a.value = "", s.value = !1;
              })
            })
          ]),
          o("img", { src: a.value }, null, 8, j)
        ]),
        _: 1
      }, 8, ["open"])
    ]));
  }
}, q = /* @__PURE__ */ I(E, [["__scopeId", "data-v-8b3f873f"]]);
export {
  q as default
};
//# sourceMappingURL=FormPicture-75db487b.js.map
