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