@emblemvault/emblem-auth-react 1.0.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.
@@ -0,0 +1,906 @@
1
+ import { createContext, useState, useCallback, useContext } from 'react';
2
+ import 'emblem-auth-sdk';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
+
5
+ var EmblemAuthContext = createContext(void 0);
6
+ function useEmblemAuth() {
7
+ const context = useContext(EmblemAuthContext);
8
+ if (context === void 0) {
9
+ throw new Error("useEmblemAuth must be used within an EmblemAuthProvider");
10
+ }
11
+ return context;
12
+ }
13
+
14
+ // src/styles/tokens.ts
15
+ var defaults = {
16
+ colors: {
17
+ // Backgrounds
18
+ bgPrimary: "#0b0d10",
19
+ bgSecondary: "#12161b",
20
+ bgTertiary: "#1a1f25",
21
+ bgHover: "#252b33",
22
+ bgOverlay: "rgba(0, 0, 0, 0.7)",
23
+ // Borders
24
+ borderPrimary: "#222b35",
25
+ borderSecondary: "#333",
26
+ borderHover: "#444",
27
+ // Text
28
+ textPrimary: "#e6eef8",
29
+ textSecondary: "#8892a4",
30
+ textTertiary: "#6b7280",
31
+ textInverse: "#fff",
32
+ // Accent - Primary (blue)
33
+ accentPrimary: "#4c9aff",
34
+ accentPrimaryHover: "#7bb6ff",
35
+ accentPrimaryBg: "rgba(76, 154, 255, 0.1)",
36
+ // Accent - Success (green)
37
+ accentSuccess: "#10b981",
38
+ accentSuccessHover: "#34d399",
39
+ accentSuccessBg: "rgba(16, 185, 129, 0.1)",
40
+ // Accent - Warning (yellow/orange)
41
+ accentWarning: "#f59e0b",
42
+ accentWarningBg: "rgba(245, 158, 11, 0.1)",
43
+ // Accent - Error (red)
44
+ accentError: "#dc2626",
45
+ accentErrorHover: "#ef4444",
46
+ accentErrorBg: "rgba(239, 68, 68, 0.1)",
47
+ // Messages
48
+ msgUser: "#1e3a5f",
49
+ msgAssistant: "#1a2633"
50
+ },
51
+ typography: {
52
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
53
+ fontFamilyMono: '"SF Mono", Monaco, monospace',
54
+ fontSizeXs: "11px",
55
+ fontSizeSm: "13px",
56
+ fontSizeMd: "14px",
57
+ fontSizeLg: "16px",
58
+ fontSizeXl: "18px",
59
+ fontWeightNormal: "400",
60
+ fontWeightMedium: "500",
61
+ fontWeightSemibold: "600",
62
+ lineHeightTight: "1.3",
63
+ lineHeightNormal: "1.5",
64
+ lineHeightRelaxed: "1.7"
65
+ },
66
+ spacing: {
67
+ xs: "4px",
68
+ sm: "8px",
69
+ md: "12px",
70
+ lg: "16px",
71
+ xl: "20px",
72
+ xxl: "24px"
73
+ },
74
+ radius: {
75
+ sm: "4px",
76
+ md: "6px",
77
+ lg: "8px",
78
+ xl: "12px",
79
+ pill: "20px",
80
+ full: "50%"
81
+ },
82
+ shadows: {
83
+ sm: "0 2px 8px rgba(0,0,0,0.2)",
84
+ md: "0 4px 16px rgba(0,0,0,0.3)",
85
+ lg: "0 8px 32px rgba(0,0,0,0.4)",
86
+ xl: "0 16px 48px rgba(0,0,0,0.5)"
87
+ },
88
+ // Glow effects (for enhanced themes)
89
+ glows: {
90
+ primary: "rgba(76, 154, 255, 0.4)",
91
+ success: "rgba(16, 185, 129, 0.4)",
92
+ error: "rgba(239, 68, 68, 0.4)",
93
+ ambient: "rgba(76, 154, 255, 0.08)"
94
+ },
95
+ transitions: {
96
+ fast: "0.15s ease",
97
+ normal: "0.2s ease",
98
+ slow: "0.3s ease"
99
+ },
100
+ zIndex: {
101
+ dropdown: "100",
102
+ modal: "1000",
103
+ fullscreen: "1000",
104
+ modalOverFullscreen: "10000"
105
+ }
106
+ };
107
+ function toVarName(category, key) {
108
+ const kebab = key.replace(/([A-Z])/g, "-$1").toLowerCase();
109
+ return `--hustle-${category}-${kebab}`;
110
+ }
111
+ function generateCSSVariables() {
112
+ const lines = [":root {"];
113
+ for (const [key, value] of Object.entries(defaults.colors)) {
114
+ lines.push(` ${toVarName("color", key)}: ${value};`);
115
+ }
116
+ for (const [key, value] of Object.entries(defaults.typography)) {
117
+ lines.push(` ${toVarName("font", key)}: ${value};`);
118
+ }
119
+ for (const [key, value] of Object.entries(defaults.spacing)) {
120
+ lines.push(` ${toVarName("space", key)}: ${value};`);
121
+ }
122
+ for (const [key, value] of Object.entries(defaults.radius)) {
123
+ lines.push(` ${toVarName("radius", key)}: ${value};`);
124
+ }
125
+ for (const [key, value] of Object.entries(defaults.shadows)) {
126
+ lines.push(` ${toVarName("shadow", key)}: ${value};`);
127
+ }
128
+ for (const [key, value] of Object.entries(defaults.glows)) {
129
+ lines.push(` ${toVarName("glow", key)}: ${value};`);
130
+ }
131
+ for (const [key, value] of Object.entries(defaults.transitions)) {
132
+ lines.push(` ${toVarName("transition", key)}: ${value};`);
133
+ }
134
+ for (const [key, value] of Object.entries(defaults.zIndex)) {
135
+ lines.push(` ${toVarName("z", key)}: ${value};`);
136
+ }
137
+ lines.push("}");
138
+ return lines.join("\n");
139
+ }
140
+ generateCSSVariables();
141
+ function createColorTokens() {
142
+ const result = {};
143
+ for (const [key, defaultValue] of Object.entries(defaults.colors)) {
144
+ result[key] = `var(${toVarName("color", key)}, ${defaultValue})`;
145
+ }
146
+ return result;
147
+ }
148
+ function createTypographyTokens() {
149
+ const result = {};
150
+ for (const [key, defaultValue] of Object.entries(defaults.typography)) {
151
+ result[key] = `var(${toVarName("font", key)}, ${defaultValue})`;
152
+ }
153
+ return result;
154
+ }
155
+ function createSpacingTokens() {
156
+ const result = {};
157
+ for (const [key, defaultValue] of Object.entries(defaults.spacing)) {
158
+ result[key] = `var(${toVarName("space", key)}, ${defaultValue})`;
159
+ }
160
+ return result;
161
+ }
162
+ function createRadiusTokens() {
163
+ const result = {};
164
+ for (const [key, defaultValue] of Object.entries(defaults.radius)) {
165
+ result[key] = `var(${toVarName("radius", key)}, ${defaultValue})`;
166
+ }
167
+ return result;
168
+ }
169
+ function createShadowTokens() {
170
+ const result = {};
171
+ for (const [key, defaultValue] of Object.entries(defaults.shadows)) {
172
+ result[key] = `var(${toVarName("shadow", key)}, ${defaultValue})`;
173
+ }
174
+ return result;
175
+ }
176
+ function createGlowTokens() {
177
+ const result = {};
178
+ for (const [key, defaultValue] of Object.entries(defaults.glows)) {
179
+ result[key] = `var(${toVarName("glow", key)}, ${defaultValue})`;
180
+ }
181
+ return result;
182
+ }
183
+ function createTransitionTokens() {
184
+ const result = {};
185
+ for (const [key, defaultValue] of Object.entries(defaults.transitions)) {
186
+ result[key] = `var(${toVarName("transition", key)}, ${defaultValue})`;
187
+ }
188
+ return result;
189
+ }
190
+ function createZIndexTokens() {
191
+ const result = {};
192
+ for (const [key, defaultValue] of Object.entries(defaults.zIndex)) {
193
+ result[key] = parseInt(defaultValue, 10);
194
+ }
195
+ return result;
196
+ }
197
+ var tokens = {
198
+ colors: createColorTokens(),
199
+ typography: createTypographyTokens(),
200
+ spacing: createSpacingTokens(),
201
+ radius: createRadiusTokens(),
202
+ shadows: createShadowTokens(),
203
+ glows: createGlowTokens(),
204
+ transitions: createTransitionTokens(),
205
+ zIndex: createZIndexTokens()
206
+ };
207
+ var presets = {
208
+ base: {
209
+ fontFamily: tokens.typography.fontFamily,
210
+ fontSize: tokens.typography.fontSizeMd,
211
+ lineHeight: tokens.typography.lineHeightNormal,
212
+ color: tokens.colors.textPrimary
213
+ },
214
+ card: {
215
+ background: tokens.colors.bgSecondary,
216
+ border: `1px solid ${tokens.colors.borderPrimary}`,
217
+ borderRadius: tokens.radius.xl
218
+ },
219
+ input: {
220
+ background: tokens.colors.bgTertiary,
221
+ border: `1px solid ${tokens.colors.borderSecondary}`,
222
+ borderRadius: tokens.radius.lg,
223
+ color: tokens.colors.textPrimary,
224
+ fontSize: tokens.typography.fontSizeMd,
225
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
226
+ transition: `border-color ${tokens.transitions.normal}`
227
+ },
228
+ button: {
229
+ display: "inline-flex",
230
+ alignItems: "center",
231
+ justifyContent: "center",
232
+ gap: tokens.spacing.sm,
233
+ padding: `${tokens.spacing.sm} ${tokens.spacing.lg}`,
234
+ borderRadius: tokens.radius.lg,
235
+ fontSize: tokens.typography.fontSizeMd,
236
+ fontWeight: tokens.typography.fontWeightMedium,
237
+ cursor: "pointer",
238
+ transition: `all ${tokens.transitions.normal}`,
239
+ border: `1px solid ${tokens.colors.borderSecondary}`,
240
+ outline: "none"
241
+ },
242
+ buttonPrimary: {
243
+ background: tokens.colors.accentPrimary,
244
+ color: tokens.colors.textInverse,
245
+ borderColor: tokens.colors.accentPrimary
246
+ },
247
+ buttonSecondary: {
248
+ background: tokens.colors.bgTertiary,
249
+ color: tokens.colors.textPrimary,
250
+ borderColor: tokens.colors.borderSecondary
251
+ },
252
+ buttonIcon: {
253
+ width: "36px",
254
+ height: "36px",
255
+ padding: 0,
256
+ // background inherited from global button styles
257
+ color: tokens.colors.textSecondary
258
+ },
259
+ mono: {
260
+ fontFamily: tokens.typography.fontFamilyMono,
261
+ fontSize: tokens.typography.fontSizeSm
262
+ },
263
+ label: {
264
+ fontSize: tokens.typography.fontSizeXs,
265
+ color: tokens.colors.textTertiary,
266
+ marginBottom: tokens.spacing.xs
267
+ }
268
+ };
269
+ var animations = `
270
+ @keyframes hustle-spin {
271
+ to { transform: rotate(360deg); }
272
+ }
273
+ @keyframes hustle-pulse {
274
+ 0%, 100% { opacity: 1; }
275
+ 50% { opacity: 0.5; }
276
+ }
277
+ @keyframes hustle-glow {
278
+ 0%, 100% {
279
+ opacity: 1;
280
+ text-shadow: 0 0 4px ${defaults.colors.accentPrimaryBg};
281
+ }
282
+ 50% {
283
+ opacity: 0.6;
284
+ text-shadow: 0 0 8px ${defaults.colors.accentPrimary};
285
+ }
286
+ }
287
+ `;
288
+ function truncateAddress(address) {
289
+ if (!address || address.length < 10) return address || "";
290
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
291
+ }
292
+ async function copyToClipboard(text) {
293
+ try {
294
+ await navigator.clipboard.writeText(text);
295
+ return true;
296
+ } catch {
297
+ return false;
298
+ }
299
+ }
300
+ var styles = {
301
+ wrapper: {
302
+ position: "relative",
303
+ display: "inline-flex",
304
+ alignItems: "center",
305
+ gap: tokens.spacing.sm
306
+ },
307
+ button: {
308
+ ...presets.button,
309
+ padding: `${tokens.spacing.sm} ${tokens.spacing.xl}`
310
+ },
311
+ disconnected: {
312
+ background: tokens.colors.bgTertiary,
313
+ color: tokens.colors.textPrimary,
314
+ borderColor: tokens.colors.borderSecondary
315
+ },
316
+ disconnectedHover: {
317
+ background: tokens.colors.bgHover,
318
+ borderColor: tokens.colors.borderHover
319
+ },
320
+ connected: {
321
+ background: "transparent",
322
+ color: tokens.colors.accentSuccess,
323
+ borderColor: tokens.colors.accentSuccess,
324
+ borderRadius: tokens.radius.pill
325
+ },
326
+ connectedHover: {
327
+ background: tokens.colors.accentSuccessBg
328
+ },
329
+ loading: {
330
+ background: tokens.colors.borderSecondary,
331
+ color: tokens.colors.textSecondary,
332
+ cursor: "wait"
333
+ },
334
+ disabled: {
335
+ background: tokens.colors.borderSecondary,
336
+ color: tokens.colors.textTertiary,
337
+ cursor: "not-allowed",
338
+ opacity: 0.5
339
+ },
340
+ icon: {
341
+ fontSize: tokens.typography.fontSizeLg
342
+ },
343
+ spinner: {
344
+ display: "inline-block",
345
+ width: "14px",
346
+ height: "14px",
347
+ border: "2px solid currentColor",
348
+ borderTopColor: "transparent",
349
+ borderRadius: tokens.radius.full,
350
+ animation: "hustle-spin 0.8s linear infinite"
351
+ },
352
+ address: {
353
+ ...presets.mono,
354
+ color: tokens.colors.textPrimary
355
+ },
356
+ dot: {
357
+ color: tokens.colors.textSecondary
358
+ },
359
+ check: {
360
+ color: tokens.colors.accentSuccess
361
+ },
362
+ arrow: {
363
+ fontSize: "10px",
364
+ color: tokens.colors.textSecondary,
365
+ marginLeft: tokens.spacing.xs
366
+ },
367
+ // Disconnect button
368
+ disconnectBtn: {
369
+ display: "flex",
370
+ alignItems: "center",
371
+ justifyContent: "center",
372
+ width: "36px",
373
+ height: "36px",
374
+ background: "transparent",
375
+ border: `1px solid ${tokens.colors.borderSecondary}`,
376
+ borderRadius: tokens.radius.lg,
377
+ color: tokens.colors.textSecondary,
378
+ cursor: "pointer",
379
+ fontSize: "16px",
380
+ transition: `all ${tokens.transitions.normal}`
381
+ },
382
+ disconnectBtnHover: {
383
+ borderColor: tokens.colors.accentError,
384
+ color: tokens.colors.accentError
385
+ },
386
+ // Vault info dropdown
387
+ dropdown: {
388
+ position: "absolute",
389
+ top: "100%",
390
+ left: 0,
391
+ marginTop: tokens.spacing.xs,
392
+ background: tokens.colors.bgPrimary,
393
+ border: `1px solid ${tokens.colors.accentSuccess}`,
394
+ borderRadius: tokens.radius.xl,
395
+ padding: tokens.spacing.lg,
396
+ minWidth: "300px",
397
+ zIndex: tokens.zIndex.dropdown,
398
+ boxShadow: `0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px ${tokens.colors.accentSuccessBg}`
399
+ },
400
+ dropdownHeader: {
401
+ fontSize: tokens.typography.fontSizeXs,
402
+ fontWeight: tokens.typography.fontWeightSemibold,
403
+ color: tokens.colors.textSecondary,
404
+ letterSpacing: "0.5px",
405
+ marginBottom: tokens.spacing.lg,
406
+ textTransform: "uppercase"
407
+ },
408
+ dropdownRow: {
409
+ marginBottom: tokens.spacing.md
410
+ },
411
+ dropdownLabel: {
412
+ display: "block",
413
+ fontSize: tokens.typography.fontSizeXs,
414
+ color: tokens.colors.textTertiary,
415
+ marginBottom: tokens.spacing.xs
416
+ },
417
+ dropdownValueRow: {
418
+ display: "flex",
419
+ alignItems: "center",
420
+ justifyContent: "space-between",
421
+ gap: tokens.spacing.sm
422
+ },
423
+ dropdownValue: {
424
+ fontSize: tokens.typography.fontSizeMd,
425
+ color: tokens.colors.textPrimary,
426
+ fontWeight: tokens.typography.fontWeightMedium,
427
+ flex: 1
428
+ },
429
+ dropdownValueMono: {
430
+ ...presets.mono,
431
+ wordBreak: "break-all"
432
+ },
433
+ copyBtn: {
434
+ background: "transparent",
435
+ border: `1px solid ${tokens.colors.borderSecondary}`,
436
+ color: tokens.colors.textSecondary,
437
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
438
+ borderRadius: tokens.radius.sm,
439
+ cursor: "pointer",
440
+ fontSize: tokens.typography.fontSizeXs,
441
+ transition: `all ${tokens.transitions.normal}`,
442
+ whiteSpace: "nowrap"
443
+ },
444
+ copyBtnHover: {
445
+ background: tokens.colors.bgHover,
446
+ borderColor: tokens.colors.accentPrimary,
447
+ color: tokens.colors.accentPrimary
448
+ },
449
+ copyBtnCopied: {
450
+ background: tokens.colors.accentSuccess,
451
+ borderColor: tokens.colors.accentSuccess,
452
+ color: tokens.colors.textInverse
453
+ }
454
+ };
455
+ function ConnectButton({
456
+ className = "",
457
+ style,
458
+ connectLabel = "Connect",
459
+ loadingLabel = "Connecting...",
460
+ onConnect,
461
+ onDisconnect,
462
+ showVaultInfo = true,
463
+ disabled = false
464
+ }) {
465
+ const {
466
+ isAuthenticated,
467
+ isLoading,
468
+ walletAddress,
469
+ vaultId,
470
+ openAuthModal,
471
+ logout
472
+ } = useEmblemAuth();
473
+ const [isHovered, setIsHovered] = useState(false);
474
+ const [showDropdown, setShowDropdown] = useState(false);
475
+ const [disconnectHovered, setDisconnectHovered] = useState(false);
476
+ const [copiedField, setCopiedField] = useState(null);
477
+ const [copyHovered, setCopyHovered] = useState(null);
478
+ const handleClick = useCallback(async () => {
479
+ if (disabled) return;
480
+ if (!isAuthenticated && !isLoading) {
481
+ await openAuthModal();
482
+ onConnect?.();
483
+ }
484
+ }, [disabled, isAuthenticated, isLoading, openAuthModal, onConnect]);
485
+ const handleDisconnect = useCallback(() => {
486
+ logout();
487
+ onDisconnect?.();
488
+ setShowDropdown(false);
489
+ }, [logout, onDisconnect]);
490
+ const handleCopy = useCallback(async (field, value) => {
491
+ const success = await copyToClipboard(value);
492
+ if (success) {
493
+ setCopiedField(field);
494
+ setTimeout(() => setCopiedField(null), 1500);
495
+ }
496
+ }, []);
497
+ let buttonStyle = { ...styles.button };
498
+ let content = connectLabel;
499
+ if (disabled) {
500
+ buttonStyle = { ...buttonStyle, ...styles.disconnected, ...styles.disabled };
501
+ } else if (isLoading) {
502
+ buttonStyle = { ...buttonStyle, ...styles.disconnected, ...styles.loading };
503
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
504
+ /* @__PURE__ */ jsx("span", { style: styles.spinner }),
505
+ loadingLabel
506
+ ] });
507
+ } else if (isAuthenticated) {
508
+ buttonStyle = { ...buttonStyle, ...styles.connected };
509
+ if (isHovered || showDropdown) {
510
+ buttonStyle = { ...buttonStyle, ...styles.connectedHover };
511
+ }
512
+ const truncated = truncateAddress(walletAddress || "");
513
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
514
+ /* @__PURE__ */ jsx("span", { style: styles.check, children: "\u2713" }),
515
+ /* @__PURE__ */ jsx("span", { children: "Connected" }),
516
+ /* @__PURE__ */ jsx("span", { style: styles.dot, children: "\u2022" }),
517
+ /* @__PURE__ */ jsx("span", { style: styles.address, children: truncated }),
518
+ /* @__PURE__ */ jsx("span", { style: styles.arrow, children: "\u25BE" })
519
+ ] });
520
+ } else {
521
+ buttonStyle = { ...buttonStyle, ...styles.disconnected };
522
+ if (isHovered) {
523
+ buttonStyle = { ...buttonStyle, ...styles.disconnectedHover };
524
+ }
525
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
526
+ /* @__PURE__ */ jsx("span", { style: styles.icon, children: "\u2192" }),
527
+ connectLabel
528
+ ] });
529
+ }
530
+ if (style) {
531
+ buttonStyle = { ...buttonStyle, ...style };
532
+ }
533
+ const renderCopyBtn = (field, value) => {
534
+ const isCopied = copiedField === field;
535
+ const isHover = copyHovered === field;
536
+ return /* @__PURE__ */ jsx(
537
+ "button",
538
+ {
539
+ type: "button",
540
+ onClick: (e) => {
541
+ e.stopPropagation();
542
+ handleCopy(field, value);
543
+ },
544
+ style: {
545
+ ...styles.copyBtn,
546
+ ...isCopied ? styles.copyBtnCopied : isHover ? styles.copyBtnHover : {}
547
+ },
548
+ onMouseEnter: () => setCopyHovered(field),
549
+ onMouseLeave: () => setCopyHovered(null),
550
+ children: isCopied ? "Copied!" : "Copy"
551
+ }
552
+ );
553
+ };
554
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
555
+ /* @__PURE__ */ jsx("style", { children: animations }),
556
+ /* @__PURE__ */ jsxs(
557
+ "div",
558
+ {
559
+ style: styles.wrapper,
560
+ onMouseEnter: () => isAuthenticated && showVaultInfo && setShowDropdown(true),
561
+ onMouseLeave: () => setShowDropdown(false),
562
+ children: [
563
+ /* @__PURE__ */ jsx(
564
+ "button",
565
+ {
566
+ type: "button",
567
+ onClick: handleClick,
568
+ disabled: disabled || isLoading,
569
+ className,
570
+ style: buttonStyle,
571
+ onMouseEnter: () => setIsHovered(true),
572
+ onMouseLeave: () => setIsHovered(false),
573
+ children: content
574
+ }
575
+ ),
576
+ isAuthenticated && /* @__PURE__ */ jsx(
577
+ "button",
578
+ {
579
+ type: "button",
580
+ onClick: handleDisconnect,
581
+ style: {
582
+ ...styles.disconnectBtn,
583
+ ...disconnectHovered ? styles.disconnectBtnHover : {}
584
+ },
585
+ onMouseEnter: () => setDisconnectHovered(true),
586
+ onMouseLeave: () => setDisconnectHovered(false),
587
+ title: "Disconnect",
588
+ children: "\u23FB"
589
+ }
590
+ ),
591
+ isAuthenticated && showVaultInfo && showDropdown && /* @__PURE__ */ jsxs("div", { style: styles.dropdown, children: [
592
+ /* @__PURE__ */ jsx("div", { style: styles.dropdownHeader, children: "Vault Information" }),
593
+ /* @__PURE__ */ jsxs("div", { style: styles.dropdownRow, children: [
594
+ /* @__PURE__ */ jsx("span", { style: styles.dropdownLabel, children: "Vault ID" }),
595
+ /* @__PURE__ */ jsxs("div", { style: styles.dropdownValueRow, children: [
596
+ /* @__PURE__ */ jsxs("span", { style: styles.dropdownValue, children: [
597
+ "#",
598
+ vaultId
599
+ ] }),
600
+ renderCopyBtn("vaultId", vaultId || "")
601
+ ] })
602
+ ] }),
603
+ /* @__PURE__ */ jsxs("div", { style: { ...styles.dropdownRow, marginBottom: 0 }, children: [
604
+ /* @__PURE__ */ jsx("span", { style: styles.dropdownLabel, children: "Connected Wallet" }),
605
+ /* @__PURE__ */ jsxs("div", { style: styles.dropdownValueRow, children: [
606
+ /* @__PURE__ */ jsx("span", { style: { ...styles.dropdownValue, ...styles.dropdownValueMono }, children: walletAddress }),
607
+ renderCopyBtn("wallet", walletAddress || "")
608
+ ] })
609
+ ] })
610
+ ] })
611
+ ]
612
+ }
613
+ )
614
+ ] });
615
+ }
616
+ async function copyToClipboard2(text) {
617
+ try {
618
+ await navigator.clipboard.writeText(text);
619
+ return true;
620
+ } catch {
621
+ return false;
622
+ }
623
+ }
624
+ var s = {
625
+ container: {
626
+ position: "relative",
627
+ display: "inline-flex",
628
+ alignItems: "center",
629
+ gap: tokens.spacing.sm,
630
+ fontFamily: tokens.typography.fontFamily
631
+ },
632
+ disconnected: {
633
+ display: "inline-flex",
634
+ alignItems: "center",
635
+ gap: tokens.spacing.sm,
636
+ color: tokens.colors.textSecondary,
637
+ fontSize: tokens.typography.fontSizeMd
638
+ },
639
+ dot: {
640
+ display: "inline-block",
641
+ width: "8px",
642
+ height: "8px",
643
+ borderRadius: tokens.radius.full,
644
+ backgroundColor: tokens.colors.textTertiary
645
+ },
646
+ dotConnected: {
647
+ backgroundColor: tokens.colors.accentSuccess
648
+ },
649
+ spinner: {
650
+ display: "inline-block",
651
+ width: "12px",
652
+ height: "12px",
653
+ border: `2px solid ${tokens.colors.textSecondary}`,
654
+ borderTopColor: "transparent",
655
+ borderRadius: tokens.radius.full,
656
+ animation: "hustle-spin 0.8s linear infinite"
657
+ },
658
+ logoutBtn: {
659
+ ...presets.buttonIcon,
660
+ border: `1px solid ${tokens.colors.borderSecondary}`,
661
+ borderRadius: tokens.radius.lg,
662
+ transition: `all ${tokens.transitions.normal}`
663
+ },
664
+ logoutBtnHover: {
665
+ borderColor: tokens.colors.accentError,
666
+ color: tokens.colors.accentError
667
+ },
668
+ vaultInfoWrapper: {
669
+ position: "relative"
670
+ },
671
+ vaultInfo: {
672
+ position: "absolute",
673
+ top: "100%",
674
+ right: 0,
675
+ marginTop: tokens.spacing.sm,
676
+ background: tokens.colors.bgSecondary,
677
+ border: `1px solid ${tokens.colors.borderPrimary}`,
678
+ borderRadius: tokens.radius.xl,
679
+ padding: tokens.spacing.lg,
680
+ minWidth: "380px",
681
+ zIndex: tokens.zIndex.dropdown,
682
+ boxShadow: tokens.shadows.lg
683
+ },
684
+ vaultInfoHeader: {
685
+ fontSize: tokens.typography.fontSizeXs,
686
+ fontWeight: tokens.typography.fontWeightSemibold,
687
+ color: tokens.colors.textSecondary,
688
+ letterSpacing: "0.5px",
689
+ marginBottom: tokens.spacing.lg,
690
+ textTransform: "uppercase"
691
+ },
692
+ vaultInfoRow: {
693
+ marginBottom: tokens.spacing.md
694
+ },
695
+ vaultLabel: {
696
+ display: "block",
697
+ fontSize: "12px",
698
+ color: tokens.colors.textTertiary,
699
+ marginBottom: tokens.spacing.xs
700
+ },
701
+ vaultValueRow: {
702
+ display: "flex",
703
+ alignItems: "center",
704
+ justifyContent: "space-between",
705
+ gap: tokens.spacing.sm
706
+ },
707
+ vaultValue: {
708
+ fontSize: tokens.typography.fontSizeMd,
709
+ color: tokens.colors.textPrimary,
710
+ fontWeight: tokens.typography.fontWeightMedium,
711
+ flex: 1
712
+ },
713
+ vaultValueMono: {
714
+ ...presets.mono,
715
+ wordBreak: "break-all"
716
+ },
717
+ copyBtn: {
718
+ background: "transparent",
719
+ border: `1px solid ${tokens.colors.borderSecondary}`,
720
+ color: tokens.colors.textSecondary,
721
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
722
+ borderRadius: tokens.radius.sm,
723
+ cursor: "pointer",
724
+ fontSize: tokens.typography.fontSizeXs,
725
+ transition: `all ${tokens.transitions.normal}`,
726
+ whiteSpace: "nowrap"
727
+ },
728
+ copyBtnHover: {
729
+ background: tokens.colors.bgHover,
730
+ borderColor: tokens.colors.accentPrimary,
731
+ color: tokens.colors.accentPrimary
732
+ },
733
+ copyBtnCopied: {
734
+ background: tokens.colors.accentSuccess,
735
+ borderColor: tokens.colors.accentSuccess,
736
+ color: tokens.colors.textInverse
737
+ }
738
+ };
739
+ function AuthStatus({
740
+ className = "",
741
+ style,
742
+ showVaultInfo = false,
743
+ showLogout = false
744
+ }) {
745
+ const {
746
+ isAuthenticated,
747
+ isLoading,
748
+ walletAddress,
749
+ vaultId,
750
+ vaultInfo,
751
+ logout
752
+ } = useEmblemAuth();
753
+ const [isHovered, setIsHovered] = useState(false);
754
+ const [logoutHovered, setLogoutHovered] = useState(false);
755
+ const [copiedField, setCopiedField] = useState(null);
756
+ const [copyHovered, setCopyHovered] = useState(null);
757
+ const handleCopy = useCallback(async (field, value) => {
758
+ const success = await copyToClipboard2(value);
759
+ if (success) {
760
+ setCopiedField(field);
761
+ setTimeout(() => setCopiedField(null), 1500);
762
+ }
763
+ }, []);
764
+ if (!isAuthenticated) {
765
+ if (isLoading) {
766
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
767
+ /* @__PURE__ */ jsx("style", { children: animations }),
768
+ /* @__PURE__ */ jsxs("div", { className, style: { ...s.disconnected, ...style }, children: [
769
+ /* @__PURE__ */ jsx("span", { style: s.spinner }),
770
+ /* @__PURE__ */ jsx("span", { children: "Connecting..." })
771
+ ] })
772
+ ] });
773
+ }
774
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...s.disconnected, ...style }, children: [
775
+ /* @__PURE__ */ jsx("span", { style: s.dot }),
776
+ /* @__PURE__ */ jsx("span", { children: "Not connected" })
777
+ ] });
778
+ }
779
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
780
+ /* @__PURE__ */ jsx("style", { children: animations }),
781
+ /* @__PURE__ */ jsxs("div", { className, style: { ...s.container, ...style }, children: [
782
+ /* @__PURE__ */ jsxs(
783
+ "div",
784
+ {
785
+ style: s.vaultInfoWrapper,
786
+ onMouseEnter: () => showVaultInfo && setIsHovered(true),
787
+ onMouseLeave: () => showVaultInfo && setIsHovered(false),
788
+ children: [
789
+ /* @__PURE__ */ jsx("span", { style: { ...s.dot, ...s.dotConnected }, title: "Connected" }),
790
+ showVaultInfo && isHovered && /* @__PURE__ */ jsxs("div", { style: s.vaultInfo, children: [
791
+ /* @__PURE__ */ jsx("div", { style: s.vaultInfoHeader, children: "Vault Information" }),
792
+ /* @__PURE__ */ jsxs("div", { style: s.vaultInfoRow, children: [
793
+ /* @__PURE__ */ jsx("span", { style: s.vaultLabel, children: "Vault ID" }),
794
+ /* @__PURE__ */ jsxs("div", { style: s.vaultValueRow, children: [
795
+ /* @__PURE__ */ jsxs("span", { style: s.vaultValue, children: [
796
+ "#",
797
+ vaultId
798
+ ] }),
799
+ /* @__PURE__ */ jsx(
800
+ CopyButton,
801
+ {
802
+ field: "vaultId",
803
+ value: vaultId || "",
804
+ copiedField,
805
+ copyHovered,
806
+ setCopyHovered,
807
+ onCopy: handleCopy
808
+ }
809
+ )
810
+ ] })
811
+ ] }),
812
+ /* @__PURE__ */ jsxs("div", { style: s.vaultInfoRow, children: [
813
+ /* @__PURE__ */ jsx("span", { style: s.vaultLabel, children: "Connected Wallet" }),
814
+ /* @__PURE__ */ jsxs("div", { style: s.vaultValueRow, children: [
815
+ /* @__PURE__ */ jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: walletAddress }),
816
+ /* @__PURE__ */ jsx(
817
+ CopyButton,
818
+ {
819
+ field: "wallet",
820
+ value: walletAddress || "",
821
+ copiedField,
822
+ copyHovered,
823
+ setCopyHovered,
824
+ onCopy: handleCopy
825
+ }
826
+ )
827
+ ] })
828
+ ] }),
829
+ vaultInfo?.evmAddress && /* @__PURE__ */ jsxs("div", { style: s.vaultInfoRow, children: [
830
+ /* @__PURE__ */ jsx("span", { style: s.vaultLabel, children: "Vault EVM Address" }),
831
+ /* @__PURE__ */ jsxs("div", { style: s.vaultValueRow, children: [
832
+ /* @__PURE__ */ jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: vaultInfo.evmAddress }),
833
+ /* @__PURE__ */ jsx(
834
+ CopyButton,
835
+ {
836
+ field: "evmAddress",
837
+ value: vaultInfo.evmAddress,
838
+ copiedField,
839
+ copyHovered,
840
+ setCopyHovered,
841
+ onCopy: handleCopy
842
+ }
843
+ )
844
+ ] })
845
+ ] }),
846
+ vaultInfo?.solanaAddress && /* @__PURE__ */ jsxs("div", { style: s.vaultInfoRow, children: [
847
+ /* @__PURE__ */ jsx("span", { style: s.vaultLabel, children: "Vault Solana Address" }),
848
+ /* @__PURE__ */ jsxs("div", { style: s.vaultValueRow, children: [
849
+ /* @__PURE__ */ jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: vaultInfo.solanaAddress }),
850
+ /* @__PURE__ */ jsx(
851
+ CopyButton,
852
+ {
853
+ field: "solAddress",
854
+ value: vaultInfo.solanaAddress,
855
+ copiedField,
856
+ copyHovered,
857
+ setCopyHovered,
858
+ onCopy: handleCopy
859
+ }
860
+ )
861
+ ] })
862
+ ] })
863
+ ] })
864
+ ]
865
+ }
866
+ ),
867
+ showLogout && /* @__PURE__ */ jsx(
868
+ "button",
869
+ {
870
+ type: "button",
871
+ onClick: logout,
872
+ style: {
873
+ ...s.logoutBtn,
874
+ ...logoutHovered ? s.logoutBtnHover : {}
875
+ },
876
+ onMouseEnter: () => setLogoutHovered(true),
877
+ onMouseLeave: () => setLogoutHovered(false),
878
+ title: "Disconnect",
879
+ children: "\u23FB"
880
+ }
881
+ )
882
+ ] })
883
+ ] });
884
+ }
885
+ function CopyButton({ field, value, copiedField, copyHovered, setCopyHovered, onCopy }) {
886
+ const isCopied = copiedField === field;
887
+ const isHovered = copyHovered === field;
888
+ return /* @__PURE__ */ jsx(
889
+ "button",
890
+ {
891
+ type: "button",
892
+ onClick: () => onCopy(field, value),
893
+ style: {
894
+ ...s.copyBtn,
895
+ ...isCopied ? s.copyBtnCopied : isHovered ? s.copyBtnHover : {}
896
+ },
897
+ onMouseEnter: () => setCopyHovered(field),
898
+ onMouseLeave: () => setCopyHovered(null),
899
+ children: isCopied ? "Copied!" : "Copy"
900
+ }
901
+ );
902
+ }
903
+
904
+ export { AuthStatus, ConnectButton };
905
+ //# sourceMappingURL=index.js.map
906
+ //# sourceMappingURL=index.js.map