import { computed as B, ref as U, watch as D, resolveComponent as E, createElementBlock as d, openBlock as r, createElementVNode as n, createVNode as u, normalizeStyle as N, unref as e, createBlock as S, createCommentVNode as x, toDisplayString as v, withDirectives as H, vModelText as L } from "vue";
import { useUser as G, useMd as I, useProject as O, useDebounceFn as _ } from "./composables-BAZQlC3e.js";
import { FormPicture as q, FormTitle as $, ProjectFunding as A, ProjectForm as J } from "./components.js";
const K = { class: "flex flex-col max-w-65ch" }, Q = ["value"], R = { class: "rounded p-2 bg-light-100 bg-opacity-80 dark-bg-dark-300 dark-bg-opacity-60 flex items-center" }, W = { class: "flex flex-col" }, X = { class: "flex items-center gap-2" }, Y = { class: "capitalize font-mono text-xs" }, Z = { class: "px-2 px-1 bg-light-300 dark-bg-dark-300 rounded-lg font-mono text-xs" }, ee = { class: "px-2 px-1 bg-light-700 dark-bg-dark-700 rounded-lg font-mono text-xs mr-auto" }, te = { class: "flex flex-col gap-2 px-4 bg-light-200 dark-bg-dark-400 relative" }, oe = ["innerHTML"], le = { class: "text-xs max-w-full overflow-scroll" }, ie = {
  __name: "ProjectPage",
  props: {
    path: {
      type: String,
      default: ""
    }
  },
  emits: ["gift", "user"],
  setup(a, { emit: ne }) {
    const b = a, { user: w } = G(), T = I(), { project: l, updateField: i, updateCover: M } = O(b.path), s = B(() => b.path.includes(w.pub)), g = U(!1), p = U(l.content);
    D(() => l.content, (c) => {
      p.value = c;
    });
    const V = _(i, 1e3);
    return (c, t) => {
      var m, f, k, y, h, j, C, F, P;
      const z = E("account-badge");
      return r(), d("div", K, [
        n("div", {
          class: "p-2 relative",
          style: N({ background: `url(${e(l).cover}) center`, backgroundColor: (m = e(l)) == null ? void 0 : m.color, paddingTop: (f = e(l)) != null && f.cover || (k = e(l)) != null && k.color ? "220px" : "60px" })
        }, [
          s.value ? (r(), S(e(q), {
            key: 0,
            class: "absolute top-2",
            onUpdate: t[0] || (t[0] = (o) => e(M)(o))
          })) : x("", !0),
          s.value ? (r(), d("input", {
            key: 1,
            class: "absolute top-4 right-4",
            type: "color",
            value: (y = e(l)) == null ? void 0 : y.color,
            onInput: t[1] || (t[1] = (o) => e(i)("color", o.target.value))
          }, null, 40, Q)) : x("", !0),
          n("div", R, [
            n("div", W, [
              n("div", X, [
                n("div", Y, v((h = e(l)) == null ? void 0 : h.type), 1),
                n("div", Z, v((j = e(l)) == null ? void 0 : j.id), 1),
                n("div", ee, v((C = e(l)) == null ? void 0 : C.status), 1)
              ]),
              u(e($), {
                class: "text-2xl font-bold",
                text: (F = e(l)) == null ? void 0 : F.title,
                editable: s.value,
                onUpdate: t[2] || (t[2] = (o) => e(i)("title", o))
              }, null, 8, ["text", "editable"]),
              u(e($), {
                class: "text-md",
                text: (P = e(l)) == null ? void 0 : P.description,
                editable: s.value,
                onUpdate: t[3] || (t[3] = (o) => e(i)("description", o))
              }, null, 8, ["text", "editable"])
            ]),
            t[10] || (t[10] = n("div", { class: "flex-1" }, null, -1)),
            u(z, {
              pub: a.path.slice(-87),
              onClick: t[4] || (t[4] = (o) => c.$emit("user", a.path.slice(-87)))
            }, null, 8, ["pub"])
          ])
        ], 4),
        n("div", te, [
          s.value ? (r(), d("div", {
            key: 0,
            class: "i-la-pen cursor-pointer text-2xl absolute top-2 right-2 z-2",
            onClick: t[5] || (t[5] = (o) => g.value = !g.value)
          })) : x("", !0),
          !g.value || !s.value ? (r(), d("div", {
            key: 1,
            class: "p-2 text-base prose prose-truegray dark-prose-light dark-bg-dark-400",
            innerHTML: e(T).render(p.value || "")
          }, null, 8, oe)) : H((r(), d("textarea", {
            key: 2,
            class: "dark-bg-dark-400",
            "onUpdate:modelValue": [
              t[6] || (t[6] = (o) => p.value = o),
              t[7] || (t[7] = (o) => e(V)("content", o))
            ]
          }, null, 512)), [
            [L, p.value]
          ]),
          n("pre", le, v(Object.keys(e(l))), 1)
        ]),
        u(e(A), {
          path: a.path,
          enabled: !!e(l).funding,
          onEnable: t[8] || (t[8] = (o) => e(i)("funding", "true")),
          onGift: t[9] || (t[9] = (o) => c.$emit("gift", o))
        }, null, 8, ["path", "enabled"]),
        u(e(J), { source: a.path }, null, 8, ["source"])
      ]);
    };
  }
};
export {
  ie as default
};
//# sourceMappingURL=ProjectPage-D36qSoHu.js.map
