@medialane/ui 0.335.0 → 0.336.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/wallet/export-key-section.cjs +10 -6
- package/dist/components/wallet/export-key-section.cjs.map +1 -1
- package/dist/components/wallet/export-key-section.d.cts +3 -1
- package/dist/components/wallet/export-key-section.d.ts +3 -1
- package/dist/components/wallet/export-key-section.js +10 -6
- package/dist/components/wallet/export-key-section.js.map +1 -1
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ var import_starknet = require("@medialane/sdk/starknet");
|
|
|
29
29
|
var import_describe_error = require("../../utils/describe-error.js");
|
|
30
30
|
var import_button = require("../button.js");
|
|
31
31
|
var import_alert = require("../alert.js");
|
|
32
|
-
function ExportKeySection({ loadSealed, unlock }) {
|
|
32
|
+
function ExportKeySection({ loadSealed, unlock, actions }) {
|
|
33
33
|
const [recoveryKey, setRecoveryKey] = (0, import_react.useState)(null);
|
|
34
34
|
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
35
35
|
const [error, setError] = (0, import_react.useState)(null);
|
|
@@ -75,7 +75,7 @@ function ExportKeySection({ loadSealed, unlock }) {
|
|
|
75
75
|
] })
|
|
76
76
|
] }),
|
|
77
77
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all", children: recoveryKey }),
|
|
78
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
79
79
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { onClick: copy, variant: "outline", size: "sm", children: [
|
|
80
80
|
copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Check, { className: "mr-1.5 h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Copy, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
81
81
|
copied ? "Copied" : "Copy key"
|
|
@@ -83,13 +83,17 @@ function ExportKeySection({ loadSealed, unlock }) {
|
|
|
83
83
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { onClick: hide, variant: "ghost", size: "sm", children: [
|
|
84
84
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.EyeOff, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
85
85
|
"Hide"
|
|
86
|
-
] })
|
|
86
|
+
] }),
|
|
87
|
+
actions
|
|
87
88
|
] })
|
|
88
89
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
89
90
|
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-destructive", children: error }),
|
|
90
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { onClick: reveal, disabled: busy, variant: "outline", size: "sm", children: [
|
|
93
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.KeyRound, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
94
|
+
"Show recovery key"
|
|
95
|
+
] }),
|
|
96
|
+
actions
|
|
93
97
|
] })
|
|
94
98
|
] })
|
|
95
99
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/wallet/export-key-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { KeyRound, Copy, Check, EyeOff, Loader2, ShieldAlert } from \"lucide-react\";\nimport { encodeRecoveryKey, type SealedOwner } from \"@medialane/sdk/starknet\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { Button } from \"../button.js\";\nimport { Alert, AlertDescription } from \"../alert.js\";\n\nexport interface ExportKeySectionProps {\n loadSealed: () => SealedOwner | null;\n unlock: (sealed: SealedOwner) => Promise<string>;\n}\n\nexport function ExportKeySection({ loadSealed, unlock }: ExportKeySectionProps) {\n const [recoveryKey, setRecoveryKey] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [copied, setCopied] = useState(false);\n\n const reveal = async () => {\n setBusy(true);\n setError(null);\n try {\n const sealed = loadSealed();\n if (!sealed) {\n setError(\"This browser has no wallet key stored.\");\n return;\n }\n setRecoveryKey(encodeRecoveryKey({ walletAddress: sealed.address, privateKey: await unlock(sealed) }));\n } catch (err) {\n setError(describeError(err).message);\n } finally {\n setBusy(false);\n }\n };\n\n const copy = async () => {\n if (!recoveryKey) return;\n await navigator.clipboard.writeText(recoveryKey);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n const hide = () => {\n setRecoveryKey(null);\n setCopied(false);\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div>\n <p className=\"text-sm font-semibold\">Recovery key</p>\n <p className=\"mt-1 text-xs text-muted-foreground leading-relaxed\">\n Save this somewhere private, such as a password manager. Paste it when you sign in on a\n new phone or browser, or if you lose access to every device you use.\n </p>\n </div>\n\n {recoveryKey ? (\n <>\n <Alert variant=\"destructive\">\n <ShieldAlert className=\"h-4 w-4\" />\n <AlertDescription className=\"text-xs leading-relaxed\">\n <span className=\"font-semibold\">Anyone with this key controls your wallet.</span>{\" \"}\n Medialane will never ask you for it. Treat any message requesting it as an attempt to\n take your assets.\n </AlertDescription>\n </Alert>\n <code className=\"block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all\">\n {recoveryKey}\n </code>\n <div className=\"flex items-center gap-2\">\n <Button onClick={copy} variant=\"outline\" size=\"sm\">\n {copied ? <Check className=\"mr-1.5 h-3.5 w-3.5\" /> : <Copy className=\"mr-1.5 h-3.5 w-3.5\" />}\n {copied ? \"Copied\" : \"Copy key\"}\n </Button>\n <Button onClick={hide} variant=\"ghost\" size=\"sm\">\n <EyeOff className=\"mr-1.5 h-3.5 w-3.5\" />\n Hide\n </Button>\n </div>\n </>\n ) : (\n <>\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n <Button onClick={reveal} disabled={busy} variant=\"outline\" size=\"sm\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/wallet/export-key-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport { KeyRound, Copy, Check, EyeOff, Loader2, ShieldAlert } from \"lucide-react\";\nimport { encodeRecoveryKey, type SealedOwner } from \"@medialane/sdk/starknet\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { Button } from \"../button.js\";\nimport { Alert, AlertDescription } from \"../alert.js\";\n\nexport interface ExportKeySectionProps {\n loadSealed: () => SealedOwner | null;\n unlock: (sealed: SealedOwner) => Promise<string>;\n actions?: ReactNode;\n}\n\nexport function ExportKeySection({ loadSealed, unlock, actions }: ExportKeySectionProps) {\n const [recoveryKey, setRecoveryKey] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [copied, setCopied] = useState(false);\n\n const reveal = async () => {\n setBusy(true);\n setError(null);\n try {\n const sealed = loadSealed();\n if (!sealed) {\n setError(\"This browser has no wallet key stored.\");\n return;\n }\n setRecoveryKey(encodeRecoveryKey({ walletAddress: sealed.address, privateKey: await unlock(sealed) }));\n } catch (err) {\n setError(describeError(err).message);\n } finally {\n setBusy(false);\n }\n };\n\n const copy = async () => {\n if (!recoveryKey) return;\n await navigator.clipboard.writeText(recoveryKey);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n const hide = () => {\n setRecoveryKey(null);\n setCopied(false);\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div>\n <p className=\"text-sm font-semibold\">Recovery key</p>\n <p className=\"mt-1 text-xs text-muted-foreground leading-relaxed\">\n Save this somewhere private, such as a password manager. Paste it when you sign in on a\n new phone or browser, or if you lose access to every device you use.\n </p>\n </div>\n\n {recoveryKey ? (\n <>\n <Alert variant=\"destructive\">\n <ShieldAlert className=\"h-4 w-4\" />\n <AlertDescription className=\"text-xs leading-relaxed\">\n <span className=\"font-semibold\">Anyone with this key controls your wallet.</span>{\" \"}\n Medialane will never ask you for it. Treat any message requesting it as an attempt to\n take your assets.\n </AlertDescription>\n </Alert>\n <code className=\"block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all\">\n {recoveryKey}\n </code>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button onClick={copy} variant=\"outline\" size=\"sm\">\n {copied ? <Check className=\"mr-1.5 h-3.5 w-3.5\" /> : <Copy className=\"mr-1.5 h-3.5 w-3.5\" />}\n {copied ? \"Copied\" : \"Copy key\"}\n </Button>\n <Button onClick={hide} variant=\"ghost\" size=\"sm\">\n <EyeOff className=\"mr-1.5 h-3.5 w-3.5\" />\n Hide\n </Button>\n {actions}\n </div>\n </>\n ) : (\n <>\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button onClick={reveal} disabled={busy} variant=\"outline\" size=\"sm\">\n {busy ? <Loader2 className=\"mr-1.5 h-3.5 w-3.5 animate-spin\" /> : <KeyRound className=\"mr-1.5 h-3.5 w-3.5\" />}\n Show recovery key\n </Button>\n {actions}\n </div>\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDM;AAlDN,mBAAyC;AACzC,0BAAoE;AACpE,sBAAoD;AACpD,4BAA8B;AAC9B,oBAAuB;AACvB,mBAAwC;AAQjC,SAAS,iBAAi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K,WAAU,gFACb,uBACH;AAAA,MACA,6CAAC,SAAI,WAAU,qCACb;AAAA,qDAAC,wBAAO,SAAS,MAAM,SAAQ,WAAU,MAAK,MAC3C;AAAA,mBAAS,4CAAC,6BAAM,WAAU,sBAAqB,IAAK,4CAAC,4BAAK,WAAU,sBAAqB;AAAA,UACzF,SAAS,WAAW;AAAA,WACvB;AAAA,QACA,6CAAC,wBAAO,SAAS,MAAM,SAAQ,SAAQ,MAAK,MAC1C;AAAA,sDAAC,8BAAO,WAAU,sBAAqB;AAAA,UAAE;AAAA,WAE3C;AAAA,QACC;AAAA,SACH;AAAA,OACF,IAEA,4EACG;AAAA,eAAS,4CAAC,OAAE,WAAU,4BAA4B,iBAAM;AAAA,MACzD,6CAAC,SAAI,WAAU,qCACb;AAAA,qDAAC,wBAAO,SAAS,QAAQ,UAAU,MAAM,SAAQ,WAAU,MAAK,MAC7D;AAAA,iBAAO,4CAAC,+BAAQ,WAAU,mCAAkC,IAAK,4CAAC,gCAAS,WAAU,sBAAqB;AAAA,UAAG;AAAA,WAEhH;AAAA,QACC;AAAA,SACH;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { SealedOwner } from '@medialane/sdk/starknet';
|
|
3
4
|
|
|
4
5
|
interface ExportKeySectionProps {
|
|
5
6
|
loadSealed: () => SealedOwner | null;
|
|
6
7
|
unlock: (sealed: SealedOwner) => Promise<string>;
|
|
8
|
+
actions?: ReactNode;
|
|
7
9
|
}
|
|
8
|
-
declare function ExportKeySection({ loadSealed, unlock }: ExportKeySectionProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare function ExportKeySection({ loadSealed, unlock, actions }: ExportKeySectionProps): react_jsx_runtime.JSX.Element;
|
|
9
11
|
|
|
10
12
|
export { ExportKeySection, type ExportKeySectionProps };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { SealedOwner } from '@medialane/sdk/starknet';
|
|
3
4
|
|
|
4
5
|
interface ExportKeySectionProps {
|
|
5
6
|
loadSealed: () => SealedOwner | null;
|
|
6
7
|
unlock: (sealed: SealedOwner) => Promise<string>;
|
|
8
|
+
actions?: ReactNode;
|
|
7
9
|
}
|
|
8
|
-
declare function ExportKeySection({ loadSealed, unlock }: ExportKeySectionProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare function ExportKeySection({ loadSealed, unlock, actions }: ExportKeySectionProps): react_jsx_runtime.JSX.Element;
|
|
9
11
|
|
|
10
12
|
export { ExportKeySection, type ExportKeySectionProps };
|
|
@@ -6,7 +6,7 @@ import { encodeRecoveryKey } from "@medialane/sdk/starknet";
|
|
|
6
6
|
import { describeError } from "../../utils/describe-error.js";
|
|
7
7
|
import { Button } from "../button.js";
|
|
8
8
|
import { Alert, AlertDescription } from "../alert.js";
|
|
9
|
-
function ExportKeySection({ loadSealed, unlock }) {
|
|
9
|
+
function ExportKeySection({ loadSealed, unlock, actions }) {
|
|
10
10
|
const [recoveryKey, setRecoveryKey] = useState(null);
|
|
11
11
|
const [busy, setBusy] = useState(false);
|
|
12
12
|
const [error, setError] = useState(null);
|
|
@@ -52,7 +52,7 @@ function ExportKeySection({ loadSealed, unlock }) {
|
|
|
52
52
|
] })
|
|
53
53
|
] }),
|
|
54
54
|
/* @__PURE__ */ jsx("code", { className: "block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all", children: recoveryKey }),
|
|
55
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
56
56
|
/* @__PURE__ */ jsxs(Button, { onClick: copy, variant: "outline", size: "sm", children: [
|
|
57
57
|
copied ? /* @__PURE__ */ jsx(Check, { className: "mr-1.5 h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
58
58
|
copied ? "Copied" : "Copy key"
|
|
@@ -60,13 +60,17 @@ function ExportKeySection({ loadSealed, unlock }) {
|
|
|
60
60
|
/* @__PURE__ */ jsxs(Button, { onClick: hide, variant: "ghost", size: "sm", children: [
|
|
61
61
|
/* @__PURE__ */ jsx(EyeOff, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
62
62
|
"Hide"
|
|
63
|
-
] })
|
|
63
|
+
] }),
|
|
64
|
+
actions
|
|
64
65
|
] })
|
|
65
66
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
67
|
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
|
|
67
|
-
/* @__PURE__ */ jsxs(
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
69
|
+
/* @__PURE__ */ jsxs(Button, { onClick: reveal, disabled: busy, variant: "outline", size: "sm", children: [
|
|
70
|
+
busy ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx(KeyRound, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
71
|
+
"Show recovery key"
|
|
72
|
+
] }),
|
|
73
|
+
actions
|
|
70
74
|
] })
|
|
71
75
|
] })
|
|
72
76
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/wallet/export-key-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { KeyRound, Copy, Check, EyeOff, Loader2, ShieldAlert } from \"lucide-react\";\nimport { encodeRecoveryKey, type SealedOwner } from \"@medialane/sdk/starknet\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { Button } from \"../button.js\";\nimport { Alert, AlertDescription } from \"../alert.js\";\n\nexport interface ExportKeySectionProps {\n loadSealed: () => SealedOwner | null;\n unlock: (sealed: SealedOwner) => Promise<string>;\n}\n\nexport function ExportKeySection({ loadSealed, unlock }: ExportKeySectionProps) {\n const [recoveryKey, setRecoveryKey] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [copied, setCopied] = useState(false);\n\n const reveal = async () => {\n setBusy(true);\n setError(null);\n try {\n const sealed = loadSealed();\n if (!sealed) {\n setError(\"This browser has no wallet key stored.\");\n return;\n }\n setRecoveryKey(encodeRecoveryKey({ walletAddress: sealed.address, privateKey: await unlock(sealed) }));\n } catch (err) {\n setError(describeError(err).message);\n } finally {\n setBusy(false);\n }\n };\n\n const copy = async () => {\n if (!recoveryKey) return;\n await navigator.clipboard.writeText(recoveryKey);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n const hide = () => {\n setRecoveryKey(null);\n setCopied(false);\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div>\n <p className=\"text-sm font-semibold\">Recovery key</p>\n <p className=\"mt-1 text-xs text-muted-foreground leading-relaxed\">\n Save this somewhere private, such as a password manager. Paste it when you sign in on a\n new phone or browser, or if you lose access to every device you use.\n </p>\n </div>\n\n {recoveryKey ? (\n <>\n <Alert variant=\"destructive\">\n <ShieldAlert className=\"h-4 w-4\" />\n <AlertDescription className=\"text-xs leading-relaxed\">\n <span className=\"font-semibold\">Anyone with this key controls your wallet.</span>{\" \"}\n Medialane will never ask you for it. Treat any message requesting it as an attempt to\n take your assets.\n </AlertDescription>\n </Alert>\n <code className=\"block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all\">\n {recoveryKey}\n </code>\n <div className=\"flex items-center gap-2\">\n <Button onClick={copy} variant=\"outline\" size=\"sm\">\n {copied ? <Check className=\"mr-1.5 h-3.5 w-3.5\" /> : <Copy className=\"mr-1.5 h-3.5 w-3.5\" />}\n {copied ? \"Copied\" : \"Copy key\"}\n </Button>\n <Button onClick={hide} variant=\"ghost\" size=\"sm\">\n <EyeOff className=\"mr-1.5 h-3.5 w-3.5\" />\n Hide\n </Button>\n </div>\n </>\n ) : (\n <>\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n <Button onClick={reveal} disabled={busy} variant=\"outline\" size=\"sm\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/wallet/export-key-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport { KeyRound, Copy, Check, EyeOff, Loader2, ShieldAlert } from \"lucide-react\";\nimport { encodeRecoveryKey, type SealedOwner } from \"@medialane/sdk/starknet\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { Button } from \"../button.js\";\nimport { Alert, AlertDescription } from \"../alert.js\";\n\nexport interface ExportKeySectionProps {\n loadSealed: () => SealedOwner | null;\n unlock: (sealed: SealedOwner) => Promise<string>;\n actions?: ReactNode;\n}\n\nexport function ExportKeySection({ loadSealed, unlock, actions }: ExportKeySectionProps) {\n const [recoveryKey, setRecoveryKey] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [copied, setCopied] = useState(false);\n\n const reveal = async () => {\n setBusy(true);\n setError(null);\n try {\n const sealed = loadSealed();\n if (!sealed) {\n setError(\"This browser has no wallet key stored.\");\n return;\n }\n setRecoveryKey(encodeRecoveryKey({ walletAddress: sealed.address, privateKey: await unlock(sealed) }));\n } catch (err) {\n setError(describeError(err).message);\n } finally {\n setBusy(false);\n }\n };\n\n const copy = async () => {\n if (!recoveryKey) return;\n await navigator.clipboard.writeText(recoveryKey);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n const hide = () => {\n setRecoveryKey(null);\n setCopied(false);\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div>\n <p className=\"text-sm font-semibold\">Recovery key</p>\n <p className=\"mt-1 text-xs text-muted-foreground leading-relaxed\">\n Save this somewhere private, such as a password manager. Paste it when you sign in on a\n new phone or browser, or if you lose access to every device you use.\n </p>\n </div>\n\n {recoveryKey ? (\n <>\n <Alert variant=\"destructive\">\n <ShieldAlert className=\"h-4 w-4\" />\n <AlertDescription className=\"text-xs leading-relaxed\">\n <span className=\"font-semibold\">Anyone with this key controls your wallet.</span>{\" \"}\n Medialane will never ask you for it. Treat any message requesting it as an attempt to\n take your assets.\n </AlertDescription>\n </Alert>\n <code className=\"block break-all rounded-xl bg-muted px-3 py-2.5 font-mono text-xs select-all\">\n {recoveryKey}\n </code>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button onClick={copy} variant=\"outline\" size=\"sm\">\n {copied ? <Check className=\"mr-1.5 h-3.5 w-3.5\" /> : <Copy className=\"mr-1.5 h-3.5 w-3.5\" />}\n {copied ? \"Copied\" : \"Copy key\"}\n </Button>\n <Button onClick={hide} variant=\"ghost\" size=\"sm\">\n <EyeOff className=\"mr-1.5 h-3.5 w-3.5\" />\n Hide\n </Button>\n {actions}\n </div>\n </>\n ) : (\n <>\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button onClick={reveal} disabled={busy} variant=\"outline\" size=\"sm\">\n {busy ? <Loader2 className=\"mr-1.5 h-3.5 w-3.5 animate-spin\" /> : <KeyRound className=\"mr-1.5 h-3.5 w-3.5\" />}\n Show recovery key\n </Button>\n {actions}\n </div>\n </>\n )}\n </div>\n );\n}\n"],"mappings":";AAoDM,SASE,UARA,KADF;AAlDN,SAAS,gBAAgC;AACzC,SAAS,UAAU,MAAM,OAAO,QAAQ,SAAS,mBAAmB;AACpE,SAAS,yBAA2C;AACpD,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,OAAO,wBAAwB;AAQjC,SAAS,iBAAiB,EAAE,YAAY,QAAQ,QAAQ,GAA0B;AACvF,QAAM,CAAC,aAAa,cAAc,IAAI,SAAwB,IAAI;AAClE,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACt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