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