import { defineComponent as S, ref as m, useUser as g, usePass as $, useClipboard as P, useShare as N, computed as k, unref as t, openBlock as o, createElementBlock as l, createVNode as p, createBaseVNode as e, toDisplayString as q, normalizeStyle as B, normalizeClass as T, createCommentVNode as c, withCtx as x, Transition as j, downloadFile as V, createBlock as z, TransitionGroup as A, renderSlot as E } from "./composables-108ad332.js";
import { AuthPass as J, QrShow as O } from "./components.js";
const Q = {
  key: 0,
  class: "flex flex-col items-stretch pb-4 border-1 border-dark-100 border-opacity-10 max-w-120 mx-auto dark-bg-dark-200"
}, D = /* @__PURE__ */ e("div", { class: "mt-4 mx-6" }, "Please make sure to safely store your cryptographic keypair to be able to use it again later", -1), F = {
  key: 0,
  class: "flex p-4 items-center bg-dark-100 bg-opacity-20 mt-2 shadow-inset"
}, G = {
  key: 0,
  class: "i-la-lock"
}, K = {
  key: 1,
  class: "i-la-unlock"
}, L = { class: "text-sm" }, R = /* @__PURE__ */ e("div", { class: "text-m" }, "Key Pair", -1), U = { class: "flex flex-wrap" }, Y = /* @__PURE__ */ e("div", { class: "i-la-share" }, null, -1), H = /* @__PURE__ */ e("div", { class: "px-1" }, "Share", -1), I = [
  Y,
  H
], M = /* @__PURE__ */ e("div", { class: "i-la-copy" }, null, -1), W = {
  key: 0,
  class: "px-2"
}, X = {
  key: 1,
  class: "px-2"
}, Z = ["href"], ee = /* @__PURE__ */ e("div", { class: "i-la-link" }, null, -1), te = /* @__PURE__ */ e("div", { class: "px-2" }, "Link", -1), se = [
  ee,
  te
], oe = /* @__PURE__ */ e("div", { class: "i-la-qrcode" }, null, -1), le = /* @__PURE__ */ e("div", { class: "px-2" }, "QR", -1), ne = [
  oe,
  le
], ie = /* @__PURE__ */ e("div", { class: "i-la-envelope-open-text" }, null, -1), ae = /* @__PURE__ */ e("div", { class: "px-2" }, "Text", -1), re = [
  ie,
  ae
], ce = /* @__PURE__ */ e("div", { class: "i-la-file-code" }, null, -1), de = /* @__PURE__ */ e("div", { class: "px-2" }, "JSON", -1), ue = [
  ce,
  de
], _e = {
  key: 1,
  class: "flex w-full justify-center mt-4"
}, ve = ["value"], he = /* @__PURE__ */ S({
  __name: "AuthCredentials",
  emits: ["close"],
  setup(pe, { emit: me }) {
    const n = m("pass"), { user: _ } = g();
    function v(r) {
      n.value != r ? n.value = r : n.value = null;
    }
    const { pass: a } = $(), { text: ke, copy: f, copied: h, isSupported: y } = P(), { share: b, isSupported: C } = N(), i = m(!0), u = k(() => {
      var r;
      return i.value ? (r = a == null ? void 0 : a.safe) == null ? void 0 : r.enc : JSON.stringify(_.pair());
    }), w = k(() => i.value ? a.links.pass : a.links.pair);
    return (r, s) => t(_).is ? (o(), l("div", Q, [
      D,
      p(t(J)),
      t(u) ? (o(), l("div", F, [
        e("div", {
          class: "flex flex-col w-34 items-center",
          style: B({ color: i.value ? "green" : "red" })
        }, [
          e("button", {
            class: "m-2 button text-2xl",
            onClick: s[0] || (s[0] = (d) => i.value = !i.value)
          }, [
            i.value ? (o(), l("div", G)) : (o(), l("div", K))
          ]),
          e("div", L, q(i.value ? "Encrypted" : "Plain Text"), 1),
          R
        ], 4),
        e("div", U, [
          t(C) ? (o(), l("button", {
            key: 0,
            class: T(["m-2 button items-center", { active: n.value == "pass" }]),
            onClick: s[1] || (s[1] = (d) => t(b)({ title: "Your key pair", text: t(u) }))
          }, I, 2)) : c("", !0),
          t(y) ? (o(), l("button", {
            key: 1,
            class: "m-2 button items-center",
            onClick: s[2] || (s[2] = (d) => t(f)(t(u)))
          }, [
            M,
            p(j, { name: "fade" }, {
              default: x(() => [
                t(h) ? (o(), l("div", W, "Copied!")) : (o(), l("div", X, "Copy"))
              ]),
              _: 1
            })
          ])) : c("", !0),
          e("a", {
            class: "m-2 button items-center",
            href: t(w),
            target: "_blank",
            onClick: s[3] || (s[3] = (d) => v("links"))
          }, se, 8, Z),
          e("button", {
            class: "m-2 button items-center",
            onClick: s[4] || (s[4] = (d) => v("qr"))
          }, ne),
          e("button", {
            class: "m-2 button items-center",
            onClick: s[5] || (s[5] = (d) => v("key"))
          }, re),
          e("button", {
            class: "m-2 button items-center",
            onClick: s[6] || (s[6] = (d) => {
              t(V)(t(u), "text/json", (t(_).name || "account") + ".json", !1), n.value = null;
            })
          }, ue)
        ])
      ])) : c("", !0),
      n.value ? (o(), l("div", _e, [
        p(A, { name: "fade" }, {
          default: x(() => [
            n.value == "key" ? (o(), l("textarea", {
              class: "p-4 text-sm flex-1 rounded-xl",
              key: "text",
              rows: "9",
              value: t(u)
            }, null, 8, ve)) : c("", !0),
            n.value == "qr" ? (o(), z(t(O), {
              class: "max-w-600px",
              key: "qr",
              data: i.value ? t(a).links.pass : t(a).links.pair
            }, null, 8, ["data"])) : c("", !0)
          ]),
          _: 1
        })
      ])) : c("", !0),
      E(r.$slots, "default")
    ])) : c("", !0);
  }
});
export {
  he as default
};
//# sourceMappingURL=AuthCredentials-a6bf0300.js.map
