@flapsdk/vault-runtime 0.1.24 → 0.1.26

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.
@@ -0,0 +1,544 @@
1
+ import { shortenAddress } from './chunk-GA5VEHC2.js';
2
+ import { getTaxVaultHostChainConfig } from './chunk-CPAMDXX7.js';
3
+ import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck } from 'lucide-react';
4
+ import { clsx } from 'clsx';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import * as React4 from 'react';
7
+ import { createContext, useState, useEffect, useMemo, useContext } from 'react';
8
+ import { Slot } from '@radix-ui/react-slot';
9
+ import { cva } from 'class-variance-authority';
10
+ import { createPortal } from 'react-dom';
11
+
12
+ // src/sdk/ipfsImage.ts
13
+ var DEFAULT_IPFS_IMAGE_GATEWAY = "https://flap.mypinata.cloud";
14
+ var IPFS_IMAGE_GATEWAYS = ["https://flap.mypinata.cloud", "https://magenta-naval-penguin-822.mypinata.cloud"];
15
+ var CID_RE = /^(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/;
16
+ var PATH_SEGMENT_RE = /^[A-Za-z0-9._~-]+$/;
17
+ function isIpfsImageCid(value) {
18
+ return CID_RE.test(value.trim());
19
+ }
20
+ function normalizeIpfsImagePath(value) {
21
+ if (value === void 0) return "";
22
+ const trimmed = value.trim();
23
+ if (!trimmed || trimmed.length > 512 || trimmed.startsWith("/") || trimmed.endsWith("/")) return void 0;
24
+ const segments = trimmed.split("/");
25
+ if (segments.some((segment) => !segment || segment === "." || segment === ".." || !PATH_SEGMENT_RE.test(segment))) return void 0;
26
+ return segments.join("/");
27
+ }
28
+ function resolveIpfsImageUrl(cid, chainId = 56, path) {
29
+ const normalizedPath = normalizeIpfsImagePath(path);
30
+ if (!isIpfsImageCid(cid) || normalizedPath === void 0) return void 0;
31
+ const gateway = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\/+$/, "");
32
+ return `${gateway}/ipfs/${cid.trim()}${normalizedPath ? `/${normalizedPath}` : ""}`;
33
+ }
34
+ function resolveIpfsImageUrls(cid, chainId = 56, path) {
35
+ const normalizedPath = normalizeIpfsImagePath(path);
36
+ if (!isIpfsImageCid(cid) || normalizedPath === void 0) return [];
37
+ const preferred = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\/+$/, "");
38
+ const gateways = [preferred, ...IPFS_IMAGE_GATEWAYS.map((gateway) => gateway.replace(/\/+$/, ""))];
39
+ return [...new Set(gateways)].map((gateway) => `${gateway}/ipfs/${cid.trim()}${normalizedPath ? `/${normalizedPath}` : ""}`);
40
+ }
41
+ function AddressLink({ address, explorerBaseUrl, label }) {
42
+ if (!address) return /* @__PURE__ */ React.createElement("span", null, "-");
43
+ const href = explorerBaseUrl ? `${explorerBaseUrl.replace(/\/$/, "")}/address/${address}` : void 0;
44
+ const content = /* @__PURE__ */ React.createElement("span", { className: "inline-flex min-w-0 items-center gap-1 text-primary" }, /* @__PURE__ */ React.createElement("span", { className: "truncate" }, label || shortenAddress(address)), href ? /* @__PURE__ */ React.createElement(ExternalLink, { className: "h-3.5 w-3.5 shrink-0" }) : null);
45
+ return href ? /* @__PURE__ */ React.createElement("a", { href, target: "_blank", rel: "noreferrer" }, content) : content;
46
+ }
47
+ function cn(...inputs) {
48
+ return twMerge(clsx(inputs));
49
+ }
50
+
51
+ // src/ui/Alert.tsx
52
+ var toneClass = {
53
+ info: "border-[#303236] bg-black text-[#D4D4D4]",
54
+ success: "border-[#D0FF00]/45 bg-[#101400] text-[#D0FF00]",
55
+ warning: "border-[#FFD166]/45 bg-[#1A1305] text-[#FFD166]",
56
+ danger: "border-[#FF4A55]/55 bg-[#1D0709] text-[#FF8A91]"
57
+ };
58
+ var iconMap = {
59
+ info: Info,
60
+ success: CheckCircle2,
61
+ warning: AlertTriangle,
62
+ danger: AlertTriangle
63
+ };
64
+ function Alert({ children, tone = "info", className }) {
65
+ const Icon = iconMap[tone];
66
+ return /* @__PURE__ */ React.createElement("div", { "data-flap-ui": "alert", className: cn("flex gap-3 rounded-[6px] border p-3 text-sm font-medium leading-6", toneClass[tone], className) }, /* @__PURE__ */ React.createElement(Icon, { className: "mt-0.5 h-4 w-4 shrink-0 opacity-90" }), /* @__PURE__ */ React.createElement("div", { className: "min-w-0 break-words" }, children));
67
+ }
68
+ var buttonVariants = cva(
69
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-semibold uppercase leading-[1.4] tracking-normal duration-0 hover:transition-colors hover:duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#D0FF00]/45 disabled:pointer-events-none disabled:opacity-50",
70
+ {
71
+ variants: {
72
+ variant: {
73
+ default: "ui20-connect-chamfer text-[#070808] [--ui20-chamfer-bg:#D0FF00] [--ui20-chamfer-border:#D0FF00] hover:[--ui20-chamfer-bg:#BDE800] hover:[--ui20-chamfer-border:#BDE800]",
74
+ secondary: "ui20-connect-chamfer text-white [--ui20-chamfer-bg:#262626] [--ui20-chamfer-border:#262626] hover:text-[#D0FF00] hover:[--ui20-chamfer-bg:#303030] hover:[--ui20-chamfer-border:#303030]",
75
+ outline: "ui20-connect-chamfer text-[#D4D4D4] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#303236] hover:text-[#D0FF00] hover:[--ui20-chamfer-border:#D0FF00]",
76
+ ghost: "rounded-[6px] text-[#D4D4D4] hover:bg-[#131516] hover:text-[#D0FF00]",
77
+ destructive: "ui20-connect-chamfer text-[#FF4A55] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#FF4A55] hover:text-black hover:[--ui20-chamfer-bg:#FF4A55]"
78
+ },
79
+ size: {
80
+ default: "h-10 px-4",
81
+ sm: "h-8 px-3 text-xs",
82
+ lg: "h-12 px-5",
83
+ icon: "h-10 w-10 px-0"
84
+ }
85
+ },
86
+ defaultVariants: {
87
+ variant: "default",
88
+ size: "default"
89
+ }
90
+ }
91
+ );
92
+ var Button = React4.forwardRef(
93
+ ({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
94
+ const Comp = asChild ? Slot : "button";
95
+ if (asChild) {
96
+ return /* @__PURE__ */ React4.createElement(Comp, { "data-flap-ui": "button", className: cn(buttonVariants({ variant, size, className })), ref, ...props }, children);
97
+ }
98
+ return /* @__PURE__ */ React4.createElement(
99
+ Comp,
100
+ {
101
+ "data-flap-ui": "button",
102
+ className: cn(buttonVariants({ variant, size, className })),
103
+ ref,
104
+ disabled: disabled || loading,
105
+ ...props
106
+ },
107
+ loading ? /* @__PURE__ */ React4.createElement(Loader2, { className: "relative z-10 h-4 w-4 animate-spin" }) : null,
108
+ /* @__PURE__ */ React4.createElement("span", { className: "relative z-10 inline-flex min-w-0 items-center justify-center gap-2" }, children)
109
+ );
110
+ }
111
+ );
112
+ Button.displayName = "Button";
113
+ var Card = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement(
114
+ "div",
115
+ {
116
+ "data-flap-ui": "card",
117
+ ref,
118
+ className: cn(
119
+ "rounded-[8px] border border-[#303236] bg-[#070808] text-white shadow-[0_18px_60px_-42px_rgba(208,255,0,0.45)]",
120
+ className
121
+ ),
122
+ ...props
123
+ }
124
+ ));
125
+ Card.displayName = "Card";
126
+ var CardHeader = React4.forwardRef(
127
+ ({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement("div", { "data-flap-ui": "card-header", ref, className: cn("flex flex-col gap-1.5 p-4 sm:p-5", className), ...props })
128
+ );
129
+ CardHeader.displayName = "CardHeader";
130
+ var CardTitle = React4.forwardRef(
131
+ ({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement("h3", { "data-flap-ui": "card-title", ref, className: cn("text-base font-semibold uppercase leading-tight tracking-normal text-white sm:text-lg", className), ...props })
132
+ );
133
+ CardTitle.displayName = "CardTitle";
134
+ var CardDescription = React4.forwardRef(
135
+ ({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
136
+ );
137
+ CardDescription.displayName = "CardDescription";
138
+ var CardContent = React4.forwardRef(
139
+ ({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement("div", { "data-flap-ui": "card-content", ref, className: cn("p-4 pt-0 sm:p-5 sm:pt-0", className), ...props })
140
+ );
141
+ CardContent.displayName = "CardContent";
142
+ function formatMs(ms) {
143
+ const safe = Math.max(0, ms);
144
+ const totalSeconds = Math.floor(safe / 1e3);
145
+ const days = Math.floor(totalSeconds / 86400);
146
+ const hours = Math.floor(totalSeconds % 86400 / 3600);
147
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
148
+ const seconds = totalSeconds % 60;
149
+ if (days > 0) return `${days}d ${hours}h ${minutes}m`;
150
+ if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
151
+ return `${minutes}m ${seconds}s`;
152
+ }
153
+ function Countdown({ targetTimeMs, fallback = "-" }) {
154
+ const [now, setNow] = useState(() => Date.now());
155
+ useEffect(() => {
156
+ const timer = window.setInterval(() => setNow(Date.now()), 1e3);
157
+ return () => window.clearInterval(timer);
158
+ }, []);
159
+ const text = useMemo(() => {
160
+ if (!targetTimeMs) return fallback;
161
+ return formatMs(targetTimeMs - now);
162
+ }, [fallback, now, targetTimeMs]);
163
+ return /* @__PURE__ */ React.createElement("span", null, text);
164
+ }
165
+
166
+ // src/ui/DataRow.tsx
167
+ function DataRow({ label, value, detail, className }) {
168
+ return /* @__PURE__ */ React.createElement("div", { className: cn("flex items-start justify-between gap-4 border-b border-white/8 py-3 last:border-0", className) }, /* @__PURE__ */ React.createElement("div", { className: "min-w-0 text-sm text-white/54" }, label), /* @__PURE__ */ React.createElement("div", { className: "min-w-0 text-right" }, /* @__PURE__ */ React.createElement("div", { className: "break-words text-sm font-semibold text-white" }, value), detail ? /* @__PURE__ */ React.createElement("div", { className: "mt-1 text-xs text-white/42" }, detail) : null));
169
+ }
170
+
171
+ // src/ui/DetailTile.tsx
172
+ var toneClass2 = {
173
+ default: "border-[#303236] bg-[#0B0D0E]",
174
+ primary: "border-[#D0FF00]/70 bg-[#101400]",
175
+ success: "border-[#2EDEDB]/45 bg-[#061615]",
176
+ warning: "border-[#FFD166]/45 bg-[#1A1305]",
177
+ muted: "border-[#303236] bg-black"
178
+ };
179
+ function DetailTile({ label, value, detail, icon, tone = "default", className, valueClassName }) {
180
+ return /* @__PURE__ */ React.createElement("div", { "data-flap-ui": "detail-tile", className: cn("min-w-0 rounded-[6px] border p-3", toneClass2[tone], className) }, /* @__PURE__ */ React.createElement("div", { className: "flex min-w-0 items-center gap-2 text-xs font-medium uppercase leading-[1.4] text-[#84888C]" }, icon ? /* @__PURE__ */ React.createElement("span", { className: "shrink-0 text-[#D0FF00]" }, icon) : null, /* @__PURE__ */ React.createElement("span", { className: "min-w-0 truncate" }, label)), /* @__PURE__ */ React.createElement("div", { className: cn("mt-2 min-w-0 break-words text-base font-semibold leading-snug text-white", valueClassName) }, value), detail ? /* @__PURE__ */ React.createElement("div", { className: "mt-1 min-w-0 break-words text-xs leading-5 text-[#84888C]" }, detail) : null);
181
+ }
182
+ var COPY = {
183
+ en: {
184
+ title: "THIRD-PARTY WARNING",
185
+ heading: "YOU ARE LEAVING FLAP",
186
+ description: "You are about to visit a third-party page maintained by an external developer. This site is not operated by FLAP and may contain unknown security or privacy risks.",
187
+ destinationLabel: "Destination",
188
+ invalidDestination: "Unsupported destination",
189
+ acknowledge: "I understand the risks and want to proceed",
190
+ cancel: "CLOSE",
191
+ proceed: "CONTINUE"
192
+ },
193
+ zh: {
194
+ title: "\u7B2C\u4E09\u65B9\u98CE\u9669\u63D0\u793A",
195
+ heading: "\u60A8\u5373\u5C06\u79BB\u5F00 FLAP",
196
+ description: "\u60A8\u5373\u5C06\u8BBF\u95EE\u7531\u5916\u90E8\u5F00\u53D1\u8005\u7EF4\u62A4\u7684\u7B2C\u4E09\u65B9\u9875\u9762\u3002\u8BE5\u7AD9\u70B9\u4E0D\u7531 FLAP \u8FD0\u8425\uFF0C\u53EF\u80FD\u5B58\u5728\u672A\u77E5\u7684\u5B89\u5168\u6216\u9690\u79C1\u98CE\u9669\u3002",
197
+ destinationLabel: "\u76EE\u6807\u5730\u5740",
198
+ invalidDestination: "\u4E0D\u652F\u6301\u7684\u76EE\u6807\u5730\u5740",
199
+ acknowledge: "\u6211\u5DF2\u4E86\u89E3\u98CE\u9669\u5E76\u5E0C\u671B\u7EE7\u7EED",
200
+ cancel: "\u5173\u95ED",
201
+ proceed: "\u7EE7\u7EED"
202
+ }
203
+ };
204
+ function resolveLocale(locale) {
205
+ return locale && locale.toLowerCase().startsWith("zh") ? "zh" : "en";
206
+ }
207
+ function normalizeExternalUrl(url) {
208
+ try {
209
+ const parsed = new URL(url);
210
+ if (parsed.protocol !== "https:" || parsed.username || parsed.password) return null;
211
+ return parsed.href;
212
+ } catch {
213
+ return null;
214
+ }
215
+ }
216
+ function WarningIcon({ className }) {
217
+ return /* @__PURE__ */ React4.createElement("svg", { viewBox: "0 0 80 80", fill: "currentColor", "aria-hidden": "true", shapeRendering: "crispEdges", className }, /* @__PURE__ */ React4.createElement("rect", { x: "32.4395", y: "11.7969", width: "2.62997", height: "6.57492" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "6.57492", transform: "matrix(-1 0 0 1 47.5605 11.7969)" }), /* @__PURE__ */ React4.createElement("rect", { x: "35.0693", y: "9.16699", width: "2.62997", height: "5.25994" }), /* @__PURE__ */ React4.createElement("rect", { x: "37.6982", y: "9.16699", width: "4.60245", height: "2.62997" }), /* @__PURE__ */ React4.createElement("rect", { x: "38.333", y: "6.66699", width: "3.33333", height: "2.5" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.25994", transform: "matrix(-1 0 0 1 44.9307 9.16699)" }), /* @__PURE__ */ React4.createElement("rect", { x: "29.8086", y: "16.3989", width: "2.62997", height: "6.57492" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "6.57492", transform: "matrix(-1 0 0 1 50.1914 16.3989)" }), /* @__PURE__ */ React4.createElement("rect", { x: "27.1787", y: "21.6592", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 52.8213 21.6592)" }), /* @__PURE__ */ React4.createElement("rect", { x: "24.5488", y: "24.2891", width: "2.62997", height: "7.23242" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "7.23242", transform: "matrix(-1 0 0 1 55.4512 24.2891)" }), /* @__PURE__ */ React4.createElement("rect", { x: "21.9189", y: "29.5488", width: "2.62997", height: "7.23242" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "7.23242", transform: "matrix(-1 0 0 1 58.0811 29.5488)" }), /* @__PURE__ */ React4.createElement("rect", { x: "19.2891", y: "34.8086", width: "2.62997", height: "7.23242" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "7.23242", transform: "matrix(-1 0 0 1 60.7109 34.8086)" }), /* @__PURE__ */ React4.createElement("rect", { x: "16.6592", y: "40.0693", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 63.3408 40.0693)" }), /* @__PURE__ */ React4.createElement("rect", { x: "14.0293", y: "44.6709", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 65.9707 44.6709)" }), /* @__PURE__ */ React4.createElement("rect", { x: "11.3984", y: "48.6165", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 68.6016 48.6165)" }), /* @__PURE__ */ React4.createElement("rect", { x: "8.76855", y: "53.8762", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 71.2314 53.8762)" }), /* @__PURE__ */ React4.createElement("rect", { x: "6.13965", y: "58.4783", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 73.8604 58.4783)" }), /* @__PURE__ */ React4.createElement("rect", { x: "4.16699", y: "62.4236", width: "2.62997", height: "5.91743" }), /* @__PURE__ */ React4.createElement("rect", { width: "2.62997", height: "5.91743", transform: "matrix(-1 0 0 1 75.833 62.4236)" }), /* @__PURE__ */ React4.createElement("rect", { x: "6.79688", y: "68.3406", width: "2.62997", height: "2.62997" }), /* @__PURE__ */ React4.createElement("rect", { x: "70.5742", y: "68.3406", width: "2.62997", height: "2.62997" }), /* @__PURE__ */ React4.createElement("rect", { x: "9.42578", y: "70.9709", width: "61.1468", height: "2.62997" }), /* @__PURE__ */ React4.createElement("rect", { x: "38.333", y: "30.833", width: "4.16667", height: "22.5" }), /* @__PURE__ */ React4.createElement("rect", { x: "38.333", y: "57.5", width: "4.16667", height: "4.16667" }));
218
+ }
219
+ function ExternalLink2({ url, children, locale, className, copy }) {
220
+ const [open, setOpen] = React4.useState(false);
221
+ const [acknowledged, setAcknowledged] = React4.useState(false);
222
+ const [mounted, setMounted] = React4.useState(false);
223
+ const text = { ...COPY[resolveLocale(locale)], ...copy };
224
+ const safeUrl = React4.useMemo(() => normalizeExternalUrl(url), [url]);
225
+ const canProceed = acknowledged && Boolean(safeUrl);
226
+ React4.useEffect(() => {
227
+ setMounted(true);
228
+ }, []);
229
+ const close = React4.useCallback(() => {
230
+ setOpen(false);
231
+ setAcknowledged(false);
232
+ }, []);
233
+ React4.useEffect(() => {
234
+ if (!open) return;
235
+ const onKey = (event) => {
236
+ if (event.key === "Escape") close();
237
+ };
238
+ document.addEventListener("keydown", onKey);
239
+ const previousOverflow = document.body.style.overflow;
240
+ document.body.style.overflow = "hidden";
241
+ return () => {
242
+ document.removeEventListener("keydown", onKey);
243
+ document.body.style.overflow = previousOverflow;
244
+ };
245
+ }, [open, close]);
246
+ const proceed = () => {
247
+ if (!canProceed || !safeUrl) return;
248
+ window.open(safeUrl, "_blank", "noopener,noreferrer");
249
+ close();
250
+ };
251
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
252
+ "button",
253
+ {
254
+ type: "button",
255
+ "data-flap-ui": "external-link",
256
+ onClick: () => setOpen(true),
257
+ className: cn("inline-flex min-w-0 items-center gap-1 text-[#d0ff00] hover:underline", className)
258
+ },
259
+ /* @__PURE__ */ React4.createElement("span", { className: "truncate" }, children),
260
+ /* @__PURE__ */ React4.createElement(ExternalLink, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": "true" })
261
+ ), open && mounted ? createPortal(
262
+ /* @__PURE__ */ React4.createElement(
263
+ "div",
264
+ {
265
+ className: "fixed inset-0 z-[2147483647] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",
266
+ style: { zIndex: 2147483647 },
267
+ onClick: close
268
+ },
269
+ /* @__PURE__ */ React4.createElement(
270
+ "div",
271
+ {
272
+ role: "dialog",
273
+ "aria-modal": "true",
274
+ "aria-label": text.title,
275
+ onClick: (event) => event.stopPropagation(),
276
+ style: {
277
+ width: "min(540px, 100%)",
278
+ maxHeight: "calc(100vh - 2rem)",
279
+ fontFamily: "'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace",
280
+ backgroundColor: "#070808",
281
+ border: "1px solid #414141"
282
+ },
283
+ className: "flex w-[min(540px,100%)] max-h-[calc(100vh-2rem)] flex-col overflow-hidden rounded-[4px] text-white shadow-panel"
284
+ },
285
+ /* @__PURE__ */ React4.createElement(
286
+ "div",
287
+ {
288
+ className: "flex items-center justify-between border-b border-[#484b51] px-6 py-[14px]",
289
+ style: { boxSizing: "border-box", height: "49px", lineHeight: 1 }
290
+ },
291
+ /* @__PURE__ */ React4.createElement(
292
+ "span",
293
+ {
294
+ className: "truncate text-[18px] font-medium uppercase leading-none tracking-[-0.4px]",
295
+ style: { lineHeight: 1 }
296
+ },
297
+ /* @__PURE__ */ React4.createElement("span", { className: "text-[#d0ff00]" }, "//"),
298
+ text.title
299
+ ),
300
+ /* @__PURE__ */ React4.createElement(
301
+ "button",
302
+ {
303
+ type: "button",
304
+ onClick: close,
305
+ "aria-label": text.cancel,
306
+ className: "flex size-5 shrink-0 items-center justify-center border border-[#484b51] text-white/80 hover:text-white"
307
+ },
308
+ /* @__PURE__ */ React4.createElement(X, { className: "h-3.5 w-3.5" })
309
+ )
310
+ ),
311
+ /* @__PURE__ */ React4.createElement("div", { className: "flex flex-col gap-6 overflow-y-auto p-6" }, /* @__PURE__ */ React4.createElement("div", { className: "flex flex-col items-center gap-5" }, /* @__PURE__ */ React4.createElement(WarningIcon, { className: "h-20 w-20 text-[#f68f15]" }), /* @__PURE__ */ React4.createElement("h2", { className: "text-center text-[18px] font-medium uppercase leading-[1.4] tracking-[-0.4px]" }, text.heading)), /* @__PURE__ */ React4.createElement("p", { className: "text-[14px] leading-[1.4] tracking-[-0.4px] text-[#a0a3a7]" }, text.description), /* @__PURE__ */ React4.createElement("div", { className: "min-w-0 border border-[#262626] bg-[#0a0a0a] px-3 py-2 text-[13px]" }, /* @__PURE__ */ React4.createElement("div", { className: "mb-1 uppercase tracking-[-0.4px] text-[#6b7280]" }, text.destinationLabel), /* @__PURE__ */ React4.createElement("div", { className: "truncate text-[#d4d4d4]", title: safeUrl ?? url }, safeUrl ? new URL(safeUrl).host : text.invalidDestination)), /* @__PURE__ */ React4.createElement("label", { className: "flex cursor-pointer items-center gap-2 text-[14px] leading-[1.4] tracking-[-0.4px] text-white" }, /* @__PURE__ */ React4.createElement(
312
+ "input",
313
+ {
314
+ type: "checkbox",
315
+ checked: acknowledged,
316
+ onChange: (event) => setAcknowledged(event.target.checked),
317
+ className: "sr-only"
318
+ }
319
+ ), /* @__PURE__ */ React4.createElement(
320
+ "span",
321
+ {
322
+ "aria-hidden": "true",
323
+ className: cn(
324
+ "flex size-4 shrink-0 items-center justify-center border",
325
+ acknowledged ? "border-[#d0ff00] bg-[#d0ff00] text-[#070808]" : "border-[#a0a3a7] bg-transparent"
326
+ )
327
+ },
328
+ acknowledged ? /* @__PURE__ */ React4.createElement("svg", { viewBox: "0 0 12 12", className: "h-3 w-3", fill: "none", stroke: "currentColor", strokeWidth: 2 }, /* @__PURE__ */ React4.createElement("path", { d: "M2 6.5 L5 9 L10 3", strokeLinecap: "square" })) : null
329
+ ), /* @__PURE__ */ React4.createElement("span", { className: "min-w-0" }, text.acknowledge)), /* @__PURE__ */ React4.createElement("div", { className: "flex gap-6" }, /* @__PURE__ */ React4.createElement(
330
+ "button",
331
+ {
332
+ type: "button",
333
+ onClick: close,
334
+ className: "flex flex-1 items-center justify-center rounded-[2px] border border-[#84888c] bg-transparent py-3 text-[14px] font-bold uppercase tracking-[-0.4px] text-white transition-colors hover:border-white"
335
+ },
336
+ text.cancel
337
+ ), /* @__PURE__ */ React4.createElement(
338
+ "button",
339
+ {
340
+ type: "button",
341
+ onClick: proceed,
342
+ disabled: !canProceed,
343
+ style: { backgroundColor: canProceed ? "#d0ff00" : "#536600", color: "#070808" },
344
+ className: "flex flex-1 items-center justify-center rounded-[2px] py-3 text-[14px] font-bold uppercase tracking-[-0.4px] transition-colors"
345
+ },
346
+ text.proceed
347
+ )))
348
+ )
349
+ ),
350
+ document.body
351
+ ) : null);
352
+ }
353
+ var Input = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React4.createElement(
354
+ "input",
355
+ {
356
+ "data-flap-ui": "input",
357
+ ref,
358
+ className: cn(
359
+ "flex h-11 w-full rounded-[6px] border border-[#303236] bg-black px-3 py-2 text-sm font-semibold text-white caret-[#D0FF00] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] outline-none duration-0 selection:bg-[#D0FF00]/35 selection:text-white placeholder:text-[#84888C] focus:border-[#D0FF00] focus:ring-2 focus:ring-[#D0FF00]/25 disabled:cursor-not-allowed disabled:bg-[#131516] disabled:text-[#84888C] disabled:opacity-80",
360
+ className
361
+ ),
362
+ ...props
363
+ }
364
+ ));
365
+ Input.displayName = "Input";
366
+ function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
367
+ const urls = React4.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
368
+ const [urlIndex, setUrlIndex] = React4.useState(0);
369
+ const src = urls[urlIndex];
370
+ React4.useEffect(() => {
371
+ setUrlIndex(0);
372
+ }, [cid, path]);
373
+ if (!src) return null;
374
+ return (
375
+ // eslint-disable-next-line @next/next/no-img-element -- IpfsImage owns CID-to-gateway fallback; next/image cannot represent this boundary.
376
+ /* @__PURE__ */ React4.createElement(
377
+ "img",
378
+ {
379
+ ...props,
380
+ alt,
381
+ className: cn("block max-w-full", className),
382
+ decoding,
383
+ loading,
384
+ onError: (event) => {
385
+ if (urlIndex < urls.length - 1) {
386
+ setUrlIndex((index) => Math.min(index + 1, urls.length - 1));
387
+ return;
388
+ }
389
+ onError?.(event);
390
+ },
391
+ src
392
+ }
393
+ )
394
+ );
395
+ }
396
+ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...props }) {
397
+ return /* @__PURE__ */ React4.createElement("div", { ...props, "aria-hidden": "true", className: cn("pointer-events-none absolute inset-0 overflow-hidden", className) }, /* @__PURE__ */ React4.createElement(IpfsImage, { alt: "", cid, className: cn("h-full w-full object-cover", imageClassName), loading: "eager" }), overlayClassName ? /* @__PURE__ */ React4.createElement("div", { className: cn("absolute inset-0", overlayClassName) }) : null);
398
+ }
399
+ var RuntimeContext = createContext(null);
400
+ function useFlapSdk() {
401
+ const sdk = useContext(RuntimeContext);
402
+ if (!sdk) throw new Error("useFlapSdk must be used within VaultRuntimeProvider.");
403
+ return sdk;
404
+ }
405
+ function useVaultContext() {
406
+ return useFlapSdk().context;
407
+ }
408
+ function useFlapI18n() {
409
+ return useFlapSdk().i18n;
410
+ }
411
+ function useFlapNotify() {
412
+ return useFlapSdk().notify;
413
+ }
414
+ function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
415
+ const sdk = useFlapSdk();
416
+ const [metadata, setMetadata] = React4.useState(null);
417
+ const [state, setState] = React4.useState("loading");
418
+ React4.useEffect(() => {
419
+ let cancelled = false;
420
+ setState("loading");
421
+ setMetadata(null);
422
+ sdk.readNftMetadata({ tokenId }).then((nextMetadata) => {
423
+ if (cancelled) return;
424
+ setMetadata(nextMetadata);
425
+ setState("ready");
426
+ }).catch(() => {
427
+ if (!cancelled) setState("error");
428
+ });
429
+ return () => {
430
+ cancelled = true;
431
+ };
432
+ }, [sdk, sdk.refetchNonce, tokenId]);
433
+ if (state !== "ready" || !metadata) {
434
+ return /* @__PURE__ */ React4.createElement("span", { "data-flap-nft-media-state": state, className: cn("block", className) }, fallback);
435
+ }
436
+ return (
437
+ // eslint-disable-next-line @next/next/no-img-element -- shared runtime resolves tokenURI metadata to a validated, size-limited data image.
438
+ /* @__PURE__ */ React4.createElement(
439
+ "img",
440
+ {
441
+ ...props,
442
+ alt,
443
+ className: cn("block max-w-full", className),
444
+ "data-flap-nft-media-source": metadata.source,
445
+ "data-flap-nft-media-state": state,
446
+ decoding,
447
+ loading,
448
+ onError: (event) => {
449
+ setState("error");
450
+ onError?.(event);
451
+ },
452
+ src: metadata.imageDataUrl
453
+ }
454
+ )
455
+ );
456
+ }
457
+
458
+ // src/ui/Metric.tsx
459
+ var toneClass3 = {
460
+ default: "border-[#303236] bg-[#0B0D0E]",
461
+ primary: "border-[#D0FF00]/70 bg-[#101400]",
462
+ success: "border-[#2EDEDB]/45 bg-[#061615]",
463
+ warning: "border-[#FFD166]/45 bg-[#1A1305]",
464
+ muted: "border-[#303236] bg-black"
465
+ };
466
+ var valueToneClass = {
467
+ default: "text-white",
468
+ primary: "text-[#D0FF00]",
469
+ success: "text-[#2EDEDB]",
470
+ warning: "text-[#FFD166]",
471
+ muted: "text-white"
472
+ };
473
+ function Metric({ label, value, hint, tone = "default", className }) {
474
+ return /* @__PURE__ */ React.createElement("div", { "data-flap-ui": "metric", className: cn("rounded-[6px] border p-3", toneClass3[tone], className) }, /* @__PURE__ */ React.createElement("div", { className: "truncate text-xs font-medium uppercase leading-[1.4] text-[#84888C]" }, label), /* @__PURE__ */ React.createElement("div", { className: cn("mt-2 break-words text-xl font-semibold tracking-normal", valueToneClass[tone]) }, value), hint ? /* @__PURE__ */ React.createElement("div", { className: "mt-1 truncate text-xs text-[#D4D4D4]" }, hint) : null);
475
+ }
476
+ function ReviewedFrame({ className, frameId, provider, src, title, ...props }) {
477
+ const {
478
+ allow: _allow,
479
+ referrerPolicy: _referrerPolicy,
480
+ sandbox: _sandbox,
481
+ src: _src,
482
+ srcDoc: _srcDoc,
483
+ title: _title,
484
+ ...safeProps
485
+ } = props;
486
+ return /* @__PURE__ */ React4.createElement(
487
+ "iframe",
488
+ {
489
+ ...safeProps,
490
+ "data-frame-id": frameId,
491
+ "data-frame-provider": provider,
492
+ src,
493
+ title,
494
+ loading: "lazy",
495
+ referrerPolicy: "no-referrer",
496
+ sandbox: "allow-scripts allow-same-origin",
497
+ className: cn("min-h-[360px] w-full rounded-lg border border-[#3a4d66] bg-[#0b111a]", className)
498
+ }
499
+ );
500
+ }
501
+
502
+ // src/ui/StatusBadge.tsx
503
+ var toneClass4 = {
504
+ neutral: "border-[#303236] bg-black text-[#D4D4D4]",
505
+ success: "border-[#D0FF00]/65 bg-[#101400] text-[#D0FF00]",
506
+ warning: "border-[#FFD166]/55 bg-[#1A1305] text-[#FFD166]",
507
+ danger: "border-[#FF4A55]/65 bg-[#1D0709] text-[#FF8A91]"
508
+ };
509
+ function StatusBadge({ children, tone = "neutral" }) {
510
+ return /* @__PURE__ */ React.createElement("span", { "data-flap-ui": "status-badge", className: cn("inline-flex items-center rounded-[6px] border px-2.5 py-1 text-xs font-semibold uppercase leading-none", toneClass4[tone]) }, children);
511
+ }
512
+
513
+ // src/ui/TxButton.tsx
514
+ var labels = {
515
+ idle: "",
516
+ validating: "Validating",
517
+ approving: "Approving",
518
+ approval_confirming: "Confirming approval",
519
+ simulating: "Simulating",
520
+ writing: "Sending",
521
+ confirming: "Confirming",
522
+ success: "Done",
523
+ failed: "Retry"
524
+ };
525
+ function TxButton({ state = "idle", idleLabel, children, ...props }) {
526
+ const loading = ["validating", "approving", "approval_confirming", "simulating", "writing", "confirming"].includes(state);
527
+ return /* @__PURE__ */ React.createElement(Button, { loading, ...props }, children || labels[state] || idleLabel);
528
+ }
529
+ function VaultBanner({ title, description, badges, meta, action, icon, className }) {
530
+ return /* @__PURE__ */ React.createElement(
531
+ "section",
532
+ {
533
+ className: cn(
534
+ "rounded-lg border border-[#3b82f6] bg-[#172a5a] p-4 shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",
535
+ className
536
+ )
537
+ },
538
+ /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between" }, /* @__PURE__ */ React.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap items-center gap-3" }, /* @__PURE__ */ React.createElement("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-[#8fc8ff]" }, icon ?? /* @__PURE__ */ React.createElement(ShieldCheck, { className: "h-4 w-4" })), /* @__PURE__ */ React.createElement("h3", { className: "min-w-0 text-base font-semibold leading-tight text-white" }, title), badges), /* @__PURE__ */ React.createElement("p", { className: "mt-3 max-w-3xl text-sm font-medium leading-6 text-[#d8e2ef]" }, description), meta ? /* @__PURE__ */ React.createElement("div", { className: "mt-2 text-xs font-medium leading-5 text-[#92a4bd]" }, meta) : null), action ? /* @__PURE__ */ React.createElement("div", { className: "shrink-0" }, action) : null)
539
+ );
540
+ }
541
+
542
+ export { AddressLink, Alert, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, Metric, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, buttonVariants, isIpfsImageCid, normalizeIpfsImagePath, resolveIpfsImageUrl, resolveIpfsImageUrls, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
543
+ //# sourceMappingURL=chunk-ZK3O6QPF.js.map
544
+ //# sourceMappingURL=chunk-ZK3O6QPF.js.map