import { useUser as B, useColor as G, useGift as D, computed as p, ref as O, useGun as R, useProject as N, unref as t, openBlock as l, createElementBlock as n, createBaseVNode as e, normalizeStyle as f, toDisplayString as c, createVNode as x, withCtx as _, renderSlot as P, currentRoom as T, createCommentVNode as i, Fragment as y, withModifiers as v, giftState as m } from "./composables-Ci32s3jE.js";
import { GiftStatus as b, AccountBadge as k } from "./components.js";
const V = { class: "flex flex-wrap gap-2 items-center px-2" }, q = { class: "flex-0 flex flex-wrap px-2 gap-2" }, A = { class: "flex flex-col" }, E = { class: "text-xl font-bold" }, L = { class: "flex flex-col" }, M = { class: "text-lg font-bold" }, z = { class: "flex items-center gap-2 flex-0" }, F = { class: "flex flex-col gap-2 text-xs" }, J = /* @__PURE__ */ e("div", { class: "i-la-arrow-right m-2" }, null, -1), U = { class: "flex flex-col gap-2 text-xs" }, H = { class: "flex gap-2 flex-wrap" }, I = {
  key: 0,
  class: "flex flex-col gap-1"
}, K = /* @__PURE__ */ e("div", { class: "text-xs" }, "ROOM ", -1), Q = { class: "p-0" }, W = {
  key: 1,
  class: "flex flex-col gap-1"
}, X = { class: "text-xs" }, Y = { class: "p-0" }, Z = {
  key: 2,
  class: "flex flex-col gap-1"
}, tt = /* @__PURE__ */ e("div", { class: "text-xs" }, "PROJECT", -1), et = {
  class: "flex flex-1 gap-2 p-2 items-center flex-wrap leading-tight text-xs",
  style: { flex: "1 1 20%" }
}, st = { class: "flex gap-2" }, at = {
  __name: "GiftCard",
  props: {
    hash: { type: String, default: "" }
  },
  emits: ["project"],
  setup(r, { emit: ot }) {
    const w = r, { user: h } = B(), C = G(), { gift: s, state: a } = D(w.hash), j = p(() => new Date(s.date).toLocaleTimeString("en-GB")), S = p(() => new Date(s.date).toLocaleDateString("en-GB")), $ = p(() => {
      const u = O();
      return R().user(s.room).get("profile").get("name").on((d) => u.value = d), u.value;
    }), { project: g } = N(p(() => s.project));
    return (u, o) => Object.keys(t(s)).length > 0 ? (l(), n("div", {
      key: 0,
      class: "flex p-0 rounded-xl shadow-lg border-2 relative overflow-hidden",
      style: f({ opacity: t(a).complete ? 1 : 0.5 })
    }, [
      e("div", {
        class: "w-3 min-w-3 h-full flex-0",
        style: f({ backgroundColor: t(C).hex(r.hash) })
      }, null, 4),
      e("div", V, [
        e("div", q, [
          e("div", A, [
            e("div", E, c(t(s).qn), 1)
          ]),
          e("div", L, [
            e("div", M, c(t(s).ql), 1)
          ])
        ]),
        e("div", z, [
          e("div", F, [
            x(t(k), {
              pub: t(s).from,
              style: f({ opacity: t(a).from ? 1 : 0.4 })
            }, {
              default: _(() => [
                x(t(b), {
                  class: "mr-2",
                  state: t(a).from
                }, null, 8, ["state"])
              ]),
              _: 1
            }, 8, ["pub", "style"])
          ]),
          J,
          e("div", U, [
            x(t(k), {
              pub: t(s).to,
              style: f({ opacity: t(a).to ? 1 : 0.4 })
            }, {
              default: _(() => [
                x(t(b), {
                  class: "mr-2",
                  state: t(a).to
                }, null, 8, ["state"])
              ]),
              _: 1
            }, 8, ["pub", "style"])
          ])
        ]),
        P(u.$slots, "default"),
        e("div", H, [
          t(s).room != t(T).pub ? (l(), n("div", I, [
            K,
            e("div", Q, c($.value), 1)
          ])) : i("", !0),
          t(s).date ? (l(), n("div", W, [
            e("div", X, c(S.value), 1),
            e("div", Y, c(j.value), 1)
          ])) : i("", !0),
          t(s).project ? (l(), n("div", Z, [
            tt,
            e("div", {
              class: "py-1 px-2 rounded-lg text-sm",
              style: f({ backgroundColor: t(g).color }),
              onClick: o[0] || (o[0] = (d) => u.$emit("project", t(s).project))
            }, c(t(g).title), 5)
          ])) : i("", !0),
          e("div", et, c(t(s).wish), 1)
        ]),
        e("div", st, [
          t(s).from == t(h).pub ? (l(), n(y, { key: 0 }, [
            t(a).from ? (l(), n("button", {
              key: 1,
              class: "button",
              onClick: o[2] || (o[2] = v((d) => t(m)(r.hash, !1), ["stop", "prevent"]))
            }, "Cancel")) : (l(), n("button", {
              key: 0,
              class: "button",
              onClick: o[1] || (o[1] = v((d) => t(m)(r.hash, !0), ["stop", "prevent"]))
            }, "Propose"))
          ], 64)) : i("", !0),
          t(s).to == t(h).pub ? (l(), n(y, { key: 1 }, [
            t(a).to ? i("", !0) : (l(), n("button", {
              key: 0,
              class: "button",
              onClick: o[3] || (o[3] = v((d) => t(m)(r.hash, !0), ["stop", "prevent"]))
            }, "Accept")),
            t(a).to ? (l(), n("button", {
              key: 1,
              class: "button",
              onClick: o[4] || (o[4] = v((d) => t(m)(r.hash, !1), ["stop", "prevent"]))
            }, "Reject")) : i("", !0)
          ], 64)) : i("", !0)
        ])
      ])
    ], 4)) : i("", !0);
  }
};
export {
  at as default
};
//# sourceMappingURL=GiftCard-_us1p3d_.js.map
