import { useProjectGifts as _, useUser as B, openBlock as e, createElementBlock as s, createBaseVNode as o, Fragment as r, unref as t, createBlock as b, renderList as h, toDisplayString as u, withCtx as w, withDirectives as C, vShow as $, createCommentVNode as v } from "./composables-Ci32s3jE.js";
import { GiftButton as j, AccountBadge as F, GiftCard as S } from "./components.js";
const G = { class: "flex flex-col" }, P = { class: "text-xl my-4 p-2 flex items-center" }, D = /* @__PURE__ */ o("div", { class: "font-bold" }, "Project funding", -1), E = /* @__PURE__ */ o("div", { class: "flex-1" }, null, -1), V = {
  key: 1,
  class: "text-xs"
}, A = {
  key: 0,
  class: "p-2 flex flex-col gap-4"
}, L = { class: "p-2 w-full flex items-center gap-2" }, U = { class: "text-xl font-bold" }, z = { class: "text-xl" }, H = /* @__PURE__ */ o("div", { class: "opacity-50" }, "by", -1), I = { class: "flex flex-wrap gap-2" }, J = { class: "mr-2" }, R = {
  __name: "ProjectFunding",
  props: {
    path: { type: String, default: "" },
    enabled: { type: Boolean, default: !1 }
  },
  emits: ["enable", "gift", "open"],
  setup(n, { emit: K }) {
    const k = n, { gifts: M, collections: m } = _(k.path), { user: i } = B();
    return (f, d) => (e(), s("div", G, [
      o("div", P, [
        D,
        E,
        n.enabled ? (e(), b(t(j), {
          key: 1,
          gift: { project: n.path, to: n.path.slice(-87) },
          onSent: d[1] || (d[1] = (l) => f.$emit("gift", l))
        }, null, 8, ["gift"])) : (e(), s(r, { key: 0 }, [
          n.path.includes(t(i).pub) ? (e(), s("button", {
            key: 0,
            class: "button",
            onClick: d[0] || (d[0] = (l) => f.$emit("enable"))
          }, "Enable Funding")) : (e(), s("div", V, "Funding not yet enabled by the author"))
        ], 64))
      ]),
      n.enabled ? (e(), s("div", A, [
        (e(!0), s(r, null, h(t(m), (l, p) => {
          var x, g, y;
          return e(), s("div", {
            class: "flex flex-col gap-2 p-2 bg-dark-50 rounded-xl bg-opacity-10 shadow-xl",
            key: l
          }, [
            o("div", L, [
              o("div", U, u(l.sum), 1),
              o("div", z, u(p), 1),
              H,
              o("div", I, [
                (e(!0), s(r, null, h(l.from, (c, a) => (e(), b(t(F), {
                  key: c,
                  pub: a
                }, {
                  default: w(() => [
                    o("div", J, u(c) + " " + u(p), 1)
                  ]),
                  _: 2
                }, 1032, ["pub"]))), 128))
              ])
            ]),
            (y = (g = (x = t(m)) == null ? void 0 : x[p]) == null ? void 0 : g.from) != null && y[t(i).pub] || n.path.includes(t(i).pub) ? (e(!0), s(r, { key: 0 }, h(l.list, (c, a) => C((e(), b(t(S), {
              class: "cursor-pointer",
              key: a,
              hash: a,
              onClick: (N) => f.$emit("open", a)
            }, null, 8, ["hash", "onClick"])), [
              [$, c.from == t(i).pub || c.to == t(i).pub]
            ])), 128)) : v("", !0)
          ]);
        }), 128))
      ])) : v("", !0)
    ]));
  }
};
export {
  R as default
};
//# sourceMappingURL=ProjectFunding-Bu48TDX6.js.map
