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