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