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