import { computed as A, reactive as g, ref as $, resolveComponent as y, openBlock as u, createElementBlock as c, Fragment as b, createElementVNode as l, renderList as D, createBlock as B, normalizeStyle as E, withCtx as w, unref as d, createCommentVNode as _, createVNode as v, withDirectives as k, vModelText as x } from "vue";
import { useUser as q, useGun as I, genUUID as R } from "./composables-5f691338.js";
import { Ce as S, currencies as j } from "./currencies-e056bc02.js";
const L = { class: "flex flex-col gap-2" }, N = { class: "flex flex-col gap-2" }, O = ["onClick"], Y = { class: "p-2" }, G = /* @__PURE__ */ l("div", { class: "text-xl" }, "Add a new wallet", -1), M = {
  class: "grid grid-cols-2 gap-2",
  style: { "grid-template-columns": "1fr 6fr" }
}, T = /* @__PURE__ */ l("div", { class: "p-2" }, "Currency", -1), z = /* @__PURE__ */ l("div", { class: "p-2" }, "Account", -1), F = /* @__PURE__ */ l("div", { class: "p-2" }, "URL", -1), H = /* @__PURE__ */ l("div", { class: "p-2" }, "PREVIEW", -1), X = {
  __name: "GiftWallets",
  props: {
    pub: {
      type: String,
      default: "OKrDaDeD8VeA27d673RqlodSnebnaDq6Ci23Ys_ABWE.q8fI2lkxO46R8TMjeUeAf7I0yBS5mdH_Cb9_285Wkqk"
    },
    activeWallet: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["wallet", "clear"],
  setup(s, { emit: K }) {
    const f = s, { user: i } = q(), p = I();
    A(() => i.pub == f.pub);
    const m = g({});
    p.user(f.pub).get("wallets").map().on((o, e) => {
      if (!o) {
        delete m[e];
        return;
      }
      let a = { ...o };
      delete a._, m[e] = a;
    });
    const r = $(), n = g({
      currency: "",
      account: "",
      url: ""
    });
    function C() {
      const o = R();
      p.user().get("wallets").get(o).put(n), r.value = !1;
    }
    function h(o) {
      console.log(o), p.user().get("wallets").get(o).put(null);
    }
    return (o, e) => {
      const a = y("gift-wallet"), V = y("ui-layer");
      return u(), c(b, null, [
        l("div", L, [
          l("div", N, [
            (u(!0), c(b, null, D(m, (t, W) => (u(), B(a, {
              class: "cursor-pointer",
              key: t,
              wallet: t,
              style: E({ backgroundColor: t == s.activeWallet ? "#3333" : "" }),
              onClick: (U) => t != s.activeWallet ? o.$emit("wallet", t) : o.$emit("clear")
            }, {
              default: w(() => [
                d(i).pub == s.pub ? (u(), c("div", {
                  key: 0,
                  class: "i-la-trash-alt opacity-40 hover-opacity-90",
                  onClick: (U) => h(W)
                }, null, 8, O)) : _("", !0)
              ]),
              _: 2
            }, 1032, ["wallet", "style", "onClick"]))), 128))
          ]),
          d(i).pub == s.pub ? (u(), c("button", {
            key: 0,
            class: "button",
            onClick: e[0] || (e[0] = (t) => r.value = !0)
          }, "Add a wallet")) : _("", !0)
        ]),
        v(V, {
          open: r.value,
          onClose: e[5] || (e[5] = (t) => r.value = !1)
        }, {
          default: w(() => [
            l("div", Y, [
              G,
              l("div", M, [
                T,
                v(d(S), {
                  class: "rounded-xl",
                  modelValue: n.currency,
                  "onUpdate:modelValue": e[1] || (e[1] = (t) => n.currency = t),
                  options: d(j),
                  "append-to-body": !0,
                  placeholder: "Your account currency",
                  taggable: !0,
                  "push-tags": !0
                }, null, 8, ["modelValue", "options"]),
                z,
                k(l("textarea", {
                  class: "shadow-lg rounded-xl p-2",
                  "onUpdate:modelValue": e[2] || (e[2] = (t) => n.account = t),
                  type: "text",
                  placeholder: "Your account details"
                }, null, 512), [
                  [x, n.account]
                ]),
                F,
                k(l("input", {
                  class: "shadow-lg rounded-xl p-2",
                  "onUpdate:modelValue": e[3] || (e[3] = (t) => n.url = t),
                  type: "text",
                  placeholder: "Link to the payment gateway"
                }, null, 512), [
                  [x, n.url]
                ]),
                H,
                v(a, { wallet: n }, null, 8, ["wallet"]),
                l("button", {
                  class: "button col-span-2",
                  onClick: e[4] || (e[4] = (t) => C())
                }, "Add the wallet")
              ])
            ])
          ]),
          _: 1
        }, 8, ["open"])
      ], 64);
    };
  }
};
export {
  X as default
};
//# sourceMappingURL=GiftWallets-8adffb45.js.map
