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