@algobright/solana-connector-kit 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.
Files changed (35) hide show
  1. package/dist/Avatar.module-P7KEBP7R.module.css +42 -0
  2. package/dist/Button.module-7TPMDOJN.module.css +145 -0
  3. package/dist/Collapsible.module-NXSN3MGI.module.css +24 -0
  4. package/dist/ConnectButton.d.mts +14 -0
  5. package/dist/ConnectButton.d.ts +14 -0
  6. package/dist/ConnectButton.js +1248 -0
  7. package/dist/ConnectButton.js.map +1 -0
  8. package/dist/ConnectButton.mjs +1216 -0
  9. package/dist/ConnectButton.mjs.map +1 -0
  10. package/dist/ConnectButton.module-UWQKSVTP.module.css +8 -0
  11. package/dist/CustomQRCode.module-FOXENMZG.module.css +176 -0
  12. package/dist/Dialog.module-HCRT743N.module.css +136 -0
  13. package/dist/Menu.module-GV627ZLI.module.css +79 -0
  14. package/dist/Spinner.module-G7GUQJZJ.module.css +16 -0
  15. package/dist/WalletDropdown.d.mts +14 -0
  16. package/dist/WalletDropdown.d.ts +14 -0
  17. package/dist/WalletDropdown.js +346 -0
  18. package/dist/WalletDropdown.js.map +1 -0
  19. package/dist/WalletDropdown.mjs +314 -0
  20. package/dist/WalletDropdown.mjs.map +1 -0
  21. package/dist/WalletDropdown.module-342MM7XM.module.css +220 -0
  22. package/dist/WalletModal.d.mts +13 -0
  23. package/dist/WalletModal.d.ts +13 -0
  24. package/dist/WalletModal.js +838 -0
  25. package/dist/WalletModal.js.map +1 -0
  26. package/dist/WalletModal.mjs +806 -0
  27. package/dist/WalletModal.mjs.map +1 -0
  28. package/dist/WalletModal.module-PVV5PRXU.module.css +341 -0
  29. package/dist/index.d.mts +70 -0
  30. package/dist/index.d.ts +70 -0
  31. package/dist/index.js +242 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/index.mjs +222 -0
  34. package/dist/index.mjs.map +1 -0
  35. package/package.json +70 -0
@@ -0,0 +1,838 @@
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/components/WalletModal/index.ts
32
+ var WalletModal_exports = {};
33
+ __export(WalletModal_exports, {
34
+ default: () => WalletModal_default2
35
+ });
36
+ module.exports = __toCommonJS(WalletModal_exports);
37
+
38
+ // src/components/WalletModal/WalletModal.tsx
39
+ var import_connector = require("@solana/connector");
40
+ var import_lucide_react3 = require("lucide-react");
41
+ var import_react3 = require("react");
42
+ var import_WalletModal = __toESM(require("./WalletModal.module-PVV5PRXU.module.css"));
43
+
44
+ // src/components/shared/Dialog/Dialog.tsx
45
+ var React = __toESM(require("react"));
46
+ var import_dialog = require("@base-ui/react/dialog");
47
+ var import_lucide_react = require("lucide-react");
48
+ var import_Dialog = __toESM(require("./Dialog.module-HCRT743N.module.css"));
49
+ var import_clsx = __toESM(require("clsx"));
50
+ var import_jsx_runtime = require("react/jsx-runtime");
51
+ var Dialog = import_dialog.Dialog.Root;
52
+ var DialogTrigger = import_dialog.Dialog.Trigger;
53
+ var DialogPortal = import_dialog.Dialog.Portal;
54
+ var DialogClose = import_dialog.Dialog.Close;
55
+ var DialogBackdrop = React.forwardRef(
56
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
+ import_dialog.Dialog.Backdrop,
58
+ {
59
+ ref,
60
+ className: `${import_Dialog.default.backdrop} ${className || ""}`,
61
+ ...props
62
+ }
63
+ )
64
+ );
65
+ DialogBackdrop.displayName = "DialogBackdrop";
66
+ var DialogContent = React.forwardRef(
67
+ ({ className, children, theme, showCloseButton = true, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogPortal, { children: [
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogBackdrop, { "data-theme": theme }),
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
70
+ import_dialog.Dialog.Popup,
71
+ {
72
+ ref,
73
+ "data-theme": theme,
74
+ className: (0, import_clsx.default)(import_Dialog.default.content, className),
75
+ ...props,
76
+ children: [
77
+ children,
78
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, { className: import_Dialog.default.closeButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.X, {}) })
79
+ ]
80
+ }
81
+ )
82
+ ] })
83
+ );
84
+ DialogContent.displayName = "DialogContent";
85
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${import_Dialog.default.header} ${className || ""}`, ...props });
86
+ DialogHeader.displayName = "DialogHeader";
87
+ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${import_Dialog.default.footer} ${className || ""}`, ...props });
88
+ DialogFooter.displayName = "DialogFooter";
89
+ var DialogTitle = React.forwardRef(
90
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
+ import_dialog.Dialog.Title,
92
+ {
93
+ ref,
94
+ className: `${import_Dialog.default.title} ${className || ""}`,
95
+ ...props
96
+ }
97
+ )
98
+ );
99
+ DialogTitle.displayName = "DialogTitle";
100
+ var DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
+ import_dialog.Dialog.Description,
102
+ {
103
+ ref,
104
+ className: `${import_Dialog.default.description} ${className || ""}`,
105
+ ...props
106
+ }
107
+ ));
108
+ DialogDescription.displayName = "DialogDescription";
109
+
110
+ // src/components/shared/Button/Button.tsx
111
+ var React2 = __toESM(require("react"));
112
+ var import_button = require("@base-ui/react/button");
113
+ var import_Button = __toESM(require("./Button.module-7TPMDOJN.module.css"));
114
+ var import_jsx_runtime2 = require("react/jsx-runtime");
115
+ var Button = React2.forwardRef(
116
+ ({ className, variant = "default", size = "default", ...props }, ref) => {
117
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
118
+ import_button.Button,
119
+ {
120
+ ref,
121
+ className: `${import_Button.default.button} ${className || ""}`,
122
+ "data-variant": variant,
123
+ "data-size": size,
124
+ ...props
125
+ }
126
+ );
127
+ }
128
+ );
129
+ Button.displayName = "Button";
130
+ var Button_default = Button;
131
+
132
+ // src/components/shared/Button/index.ts
133
+ var Button_default2 = Button_default;
134
+
135
+ // src/components/shared/CustomQRCode/CustomQRCode.tsx
136
+ var import_react = require("react");
137
+ var import_qrcode = __toESM(require("qrcode"));
138
+ var import_CustomQRCode = __toESM(require("./CustomQRCode.module-FOXENMZG.module.css"));
139
+ var import_jsx_runtime3 = require("react/jsx-runtime");
140
+ function generateMatrix(value, errorCorrectionLevel) {
141
+ const arr = Array.prototype.slice.call(import_qrcode.default.create(value, { errorCorrectionLevel }).modules.data, 0);
142
+ const sqrt = Math.sqrt(arr.length);
143
+ return arr.reduce(
144
+ (rows, key, index) => (index % sqrt === 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) && rows,
145
+ []
146
+ );
147
+ }
148
+ function QRCodeSVG({
149
+ value,
150
+ size: sizeProp = 200,
151
+ ecl = "M",
152
+ clearArea = false,
153
+ dotColor = "currentColor",
154
+ backgroundColor = "#ffffff"
155
+ }) {
156
+ const logoSize = clearArea ? 76 : 0;
157
+ const size = sizeProp - 10 * 2;
158
+ const dots = (0, import_react.useMemo)(() => {
159
+ const dots2 = [];
160
+ const matrix = generateMatrix(value, ecl);
161
+ const cellSize = size / matrix.length;
162
+ const qrList = [
163
+ { x: 0, y: 0 },
164
+ { x: 1, y: 0 },
165
+ { x: 0, y: 1 }
166
+ ];
167
+ qrList.forEach(({ x, y }) => {
168
+ const x1 = (matrix.length - 7) * cellSize * x;
169
+ const y1 = (matrix.length - 7) * cellSize * y;
170
+ for (let i = 0; i < 3; i++) {
171
+ dots2.push(
172
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
173
+ "rect",
174
+ {
175
+ fill: i % 2 !== 0 ? backgroundColor : dotColor,
176
+ rx: (i - 2) * -5 + (i === 0 ? 2 : 3),
177
+ ry: (i - 2) * -5 + (i === 0 ? 2 : 3),
178
+ width: cellSize * (7 - i * 2),
179
+ height: cellSize * (7 - i * 2),
180
+ x: x1 + cellSize * i,
181
+ y: y1 + cellSize * i
182
+ },
183
+ `finder-${i}-${x}-${y}`
184
+ )
185
+ );
186
+ }
187
+ });
188
+ const clearArenaSize = Math.floor((logoSize + 25) / cellSize);
189
+ const matrixMiddleStart = matrix.length / 2 - clearArenaSize / 2;
190
+ const matrixMiddleEnd = matrix.length / 2 + clearArenaSize / 2 - 1;
191
+ matrix.forEach((row, i) => {
192
+ row.forEach((_, j) => {
193
+ if (matrix[i][j]) {
194
+ if (!(i < 7 && j < 7 || i > matrix.length - 8 && j < 7 || i < 7 && j > matrix.length - 8)) {
195
+ if (!clearArea || !(i > matrixMiddleStart && i < matrixMiddleEnd && j > matrixMiddleStart && j < matrixMiddleEnd)) {
196
+ dots2.push(
197
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
198
+ "circle",
199
+ {
200
+ cx: j * cellSize + cellSize / 2,
201
+ cy: i * cellSize + cellSize / 2,
202
+ fill: dotColor,
203
+ r: cellSize / 3
204
+ },
205
+ `dot-${i}-${j}`
206
+ )
207
+ );
208
+ }
209
+ }
210
+ }
211
+ });
212
+ });
213
+ return dots2;
214
+ }, [value, ecl, size, clearArea, logoSize, dotColor, backgroundColor]);
215
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
216
+ "svg",
217
+ {
218
+ height: size,
219
+ width: size,
220
+ viewBox: `0 0 ${size} ${size}`,
221
+ className: import_CustomQRCode.default.svgFull,
222
+ style: { maxWidth: size, maxHeight: size },
223
+ children: [
224
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { fill: "transparent", height: size, width: size }),
225
+ dots
226
+ ]
227
+ }
228
+ );
229
+ }
230
+ function ViewfinderFrame({
231
+ size,
232
+ color = "#2D2D2D",
233
+ opacity = 0.01
234
+ }) {
235
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
236
+ "svg",
237
+ {
238
+ width: size,
239
+ height: size,
240
+ viewBox: "0 0 283 283",
241
+ fill: "none",
242
+ xmlns: "http://www.w3.org/2000/svg",
243
+ className: import_CustomQRCode.default.viewfinder,
244
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
245
+ "path",
246
+ {
247
+ d: "M3.5 264.06C3.5 272.587 10.4127 279.5 18.9399 279.5H32.8799C33.7083 279.5 34.3799 280.172 34.3799 281V281C34.3799 281.828 33.7083 282.5 32.8799 282.5H17.4399C8.08427 282.5 0.5 274.916 0.5 265.56V250.12C0.5 249.292 1.17157 248.62 2 248.62V248.62C2.82843 248.62 3.5 249.292 3.5 250.12V264.06ZM282.5 266.058C282.5 275.139 275.139 282.5 266.058 282.5H251.116C250.288 282.5 249.616 281.828 249.616 281V281C249.616 280.172 250.288 279.5 251.116 279.5H264.558C272.81 279.5 279.5 272.81 279.5 264.558V250.12C279.5 249.292 280.172 248.62 281 248.62V248.62C281.828 248.62 282.5 249.292 282.5 250.12V266.058ZM34.3799 2C34.3799 2.82843 33.7083 3.5 32.8799 3.5H18.9399C10.4127 3.5 3.5 10.4127 3.5 18.9399V32.8799C3.5 33.7083 2.82843 34.3799 2 34.3799V34.3799C1.17157 34.3799 0.5 33.7083 0.5 32.8799V17.4399C0.5 8.08427 8.08427 0.5 17.4399 0.5H32.8799C33.7083 0.5 34.3799 1.17157 34.3799 2V2ZM282.5 32.8799C282.5 33.7083 281.828 34.3799 281 34.3799V34.3799C280.172 34.3799 279.5 33.7083 279.5 32.8799V18.4419C279.5 10.1897 272.81 3.5 264.558 3.5H251.116C250.288 3.5 249.616 2.82843 249.616 2V2C249.616 1.17157 250.288 0.5 251.116 0.5H266.058C275.139 0.5 282.5 7.86129 282.5 16.9419V32.8799Z",
248
+ fill: color,
249
+ fillOpacity: opacity
250
+ }
251
+ )
252
+ }
253
+ );
254
+ }
255
+ function CustomQRCode({
256
+ value,
257
+ size = 280,
258
+ ecl = "M",
259
+ clearArea = false,
260
+ image,
261
+ imageBackground = "transparent",
262
+ dotColor,
263
+ backgroundColor,
264
+ className,
265
+ style,
266
+ loading = false,
267
+ scanning = true,
268
+ error = false,
269
+ frameColor
270
+ }) {
271
+ const showPlaceholder = loading || !value;
272
+ const resolvedBackground = backgroundColor || "#ffffff";
273
+ const resolvedDotColor = dotColor || "#000000";
274
+ const resolvedFrameColor = error ? "#FF0000" : frameColor || "#2D2D2D";
275
+ const frameOpacity = error ? 0.56 : 0.01;
276
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
277
+ "div",
278
+ {
279
+ className: `${import_CustomQRCode.default.container} ${className || ""}`,
280
+ style: {
281
+ width: size,
282
+ height: size,
283
+ ...style
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ViewfinderFrame, { size, color: resolvedFrameColor, opacity: frameOpacity }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
288
+ "div",
289
+ {
290
+ className: import_CustomQRCode.default.contentArea,
291
+ style: { background: resolvedBackground },
292
+ "data-error": error,
293
+ children: [
294
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: import_CustomQRCode.default.glow, "data-error": error }),
295
+ scanning && !showPlaceholder && !error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: import_CustomQRCode.default.shine }),
296
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: import_CustomQRCode.default.qrWrapper, children: showPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(QRPlaceholder, { size, dotColor: resolvedDotColor, backgroundColor: resolvedBackground }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
297
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
298
+ QRCodeSVG,
299
+ {
300
+ value,
301
+ size: size - 40,
302
+ ecl,
303
+ clearArea: clearArea || !!image,
304
+ dotColor: resolvedDotColor,
305
+ backgroundColor: resolvedBackground
306
+ }
307
+ ),
308
+ image && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
309
+ "div",
310
+ {
311
+ className: import_CustomQRCode.default.logoWrapper,
312
+ style: {
313
+ width: "28%",
314
+ height: "28%",
315
+ background: imageBackground || resolvedBackground
316
+ },
317
+ children: image
318
+ }
319
+ )
320
+ ] }) })
321
+ ]
322
+ }
323
+ )
324
+ ]
325
+ }
326
+ );
327
+ }
328
+ function QRPlaceholder({
329
+ size,
330
+ dotColor,
331
+ backgroundColor
332
+ }) {
333
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: import_CustomQRCode.default.placeholderContainer, style: { width: size - 40, height: size - 40 }, children: [
334
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
335
+ "div",
336
+ {
337
+ className: import_CustomQRCode.default.placeholderPattern,
338
+ style: {
339
+ backgroundImage: `radial-gradient(${dotColor} 41%, transparent 41%)`
340
+ }
341
+ }
342
+ ),
343
+ [
344
+ { top: 0, left: 0 },
345
+ { top: 0, right: 0 },
346
+ { bottom: 0, left: 0 }
347
+ ].map((pos, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
348
+ "span",
349
+ {
350
+ className: import_CustomQRCode.default.cornerSquare,
351
+ style: {
352
+ ...pos,
353
+ background: dotColor
354
+ }
355
+ },
356
+ i
357
+ )),
358
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
359
+ "div",
360
+ {
361
+ className: import_CustomQRCode.default.centerArea,
362
+ style: {
363
+ background: backgroundColor,
364
+ boxShadow: `0 0 0 7px ${backgroundColor}`
365
+ }
366
+ }
367
+ ),
368
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: import_CustomQRCode.default.loaderWrapper, children: [
369
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
370
+ "div",
371
+ {
372
+ className: import_CustomQRCode.default.spinner,
373
+ style: { color: `${dotColor}40` }
374
+ }
375
+ ),
376
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: import_CustomQRCode.default.loadingText, style: { color: `${dotColor}70` }, children: "Generating QR code..." })
377
+ ] })
378
+ ] });
379
+ }
380
+ CustomQRCode.displayName = "CustomQRCode";
381
+
382
+ // src/components/shared/CustomQRCode/index.ts
383
+ var CustomQRCode_default = CustomQRCode;
384
+
385
+ // src/components/shared/Spinner/Spinner.tsx
386
+ var import_Spinner = __toESM(require("./Spinner.module-G7GUQJZJ.module.css"));
387
+ var import_jsx_runtime4 = require("react/jsx-runtime");
388
+ var Spinner = () => {
389
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: import_Spinner.default.spinner });
390
+ };
391
+ var Spinner_default = Spinner;
392
+
393
+ // src/components/shared/Spinner/index.ts
394
+ var Spinner_default2 = Spinner_default;
395
+
396
+ // src/components/WalletModal/WalletModal.tsx
397
+ var import_si = require("react-icons/si");
398
+
399
+ // src/components/shared/Collapsible/Collapsible.tsx
400
+ var React3 = __toESM(require("react"));
401
+ var import_collapsible = require("@base-ui/react/collapsible");
402
+ var import_Collapsible = __toESM(require("./Collapsible.module-NXSN3MGI.module.css"));
403
+ var import_jsx_runtime5 = require("react/jsx-runtime");
404
+ var Collapsible = import_collapsible.Collapsible.Root;
405
+ var CollapsibleTrigger = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
406
+ import_collapsible.Collapsible.Trigger,
407
+ {
408
+ ref,
409
+ className: `${import_Collapsible.default.trigger} ${className || ""}`,
410
+ ...props
411
+ }
412
+ ));
413
+ CollapsibleTrigger.displayName = "CollapsibleTrigger";
414
+ var CollapsibleContent = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
415
+ import_collapsible.Collapsible.Panel,
416
+ {
417
+ ref,
418
+ className: `${import_Collapsible.default.content} ${className || ""}`,
419
+ ...props
420
+ }
421
+ ));
422
+ CollapsibleContent.displayName = "CollapsibleContent";
423
+
424
+ // src/components/shared/Avatar/Avatar.tsx
425
+ var import_react2 = require("react");
426
+ var import_Avatar = __toESM(require("./Avatar.module-P7KEBP7R.module.css"));
427
+ var import_lucide_react2 = require("lucide-react");
428
+ var import_jsx_runtime6 = require("react/jsx-runtime");
429
+ function Avatar({
430
+ height,
431
+ width,
432
+ src,
433
+ alt,
434
+ theme = "light"
435
+ }) {
436
+ const [hasError, setHasError] = (0, import_react2.useState)(false);
437
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: import_Avatar.default.avatar, "data-theme": theme, children: src && !hasError ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
438
+ "img",
439
+ {
440
+ height,
441
+ width,
442
+ src,
443
+ alt: alt || "Avatar",
444
+ onError: () => setHasError(true)
445
+ }
446
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: import_Avatar.default.fallback, style: { height, width }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Wallet, {}) }) });
447
+ }
448
+
449
+ // src/components/shared/Avatar/index.ts
450
+ var Avatar_default = Avatar;
451
+
452
+ // src/components/WalletModal/WalletModal.tsx
453
+ var import_clsx2 = require("clsx");
454
+ var import_jsx_runtime7 = require("react/jsx-runtime");
455
+ function WalletModal(props) {
456
+ var _a;
457
+ const {
458
+ CN_Modal,
459
+ theme = "light",
460
+ open,
461
+ onOpenChange,
462
+ walletConnectUri,
463
+ onClearWalletConnectUri
464
+ } = props;
465
+ const { walletStatus: { status }, isConnecting, connectorId, connectors, connectWallet, disconnectWallet } = (0, import_connector.useConnector)();
466
+ const [connectingConnectorId, setConnectingConnectorId] = (0, import_react3.useState)(null);
467
+ const [isOtherWalletsOpen, setIsOtherWalletsOpen] = (0, import_react3.useState)(false);
468
+ const [errorConnectorId, setErrorConnectorId] = (0, import_react3.useState)(null);
469
+ const [errorMessage, setErrorMessage] = (0, import_react3.useState)(null);
470
+ const [copied, setCopied] = (0, import_react3.useState)(false);
471
+ const isClient = (0, import_react3.useSyncExternalStore)(
472
+ () => () => {
473
+ },
474
+ () => true,
475
+ () => false
476
+ );
477
+ const recentlyConnectedConnectorId = (0, import_react3.useSyncExternalStore)(
478
+ () => () => {
479
+ },
480
+ () => localStorage.getItem("recentlyConnectedConnectorId"),
481
+ () => null
482
+ );
483
+ (0, import_react3.useEffect)(() => {
484
+ if (status === "connected" && connectorId) {
485
+ localStorage.setItem("recentlyConnectedConnectorId", connectorId);
486
+ }
487
+ }, [status, connectorId]);
488
+ const walletConnectConnector = (_a = connectors.find((c) => c.name === "WalletConnect")) != null ? _a : null;
489
+ const isWalletConnectFlow = !!walletConnectConnector && (connectingConnectorId === walletConnectConnector.id || status === "connecting" && connectorId === walletConnectConnector.id) || !!walletConnectUri;
490
+ function cancelConnection() {
491
+ onClearWalletConnectUri == null ? void 0 : onClearWalletConnectUri();
492
+ setConnectingConnectorId(null);
493
+ disconnectWallet().catch(() => {
494
+ });
495
+ }
496
+ const clearError = () => {
497
+ setErrorConnectorId(null);
498
+ setErrorMessage(null);
499
+ };
500
+ const handleSelectWallet = async (connector) => {
501
+ clearError();
502
+ setConnectingConnectorId(connector.id);
503
+ try {
504
+ if (connector.name === "WalletConnect") {
505
+ onClearWalletConnectUri == null ? void 0 : onClearWalletConnectUri();
506
+ }
507
+ await connectWallet(connector.id);
508
+ localStorage.setItem("recentlyConnectedConnectorId", connector.id);
509
+ if (connector.name !== "WalletConnect") {
510
+ onOpenChange(false);
511
+ }
512
+ } catch (error) {
513
+ const message = error instanceof Error ? error.message : "An unexpected error occurred";
514
+ if (message.includes("Connection cancelled")) return;
515
+ setErrorConnectorId(connector.id);
516
+ setErrorMessage(message);
517
+ console.error("Failed to connect wallet:", {
518
+ wallet: connector.name,
519
+ connectorId: connector.id,
520
+ error,
521
+ message,
522
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
523
+ });
524
+ } finally {
525
+ setConnectingConnectorId(null);
526
+ }
527
+ };
528
+ const handleCopyUri = async () => {
529
+ if (!walletConnectUri) return;
530
+ try {
531
+ await navigator.clipboard.writeText(walletConnectUri);
532
+ setCopied(true);
533
+ setTimeout(() => setCopied(false), 2e3);
534
+ } catch (err) {
535
+ console.error("Failed to copy URI:", err);
536
+ }
537
+ };
538
+ const handleBackFromWalletConnect = () => {
539
+ cancelConnection();
540
+ };
541
+ const readyConnectors = connectors.filter((c) => c.ready);
542
+ const notReadyConnectors = connectors.filter((c) => !c.ready);
543
+ const sortedReadyConnectors = [...readyConnectors].sort((a, b) => {
544
+ const aIsRecent = recentlyConnectedConnectorId === a.id;
545
+ const bIsRecent = recentlyConnectedConnectorId === b.id;
546
+ if (aIsRecent && !bIsRecent) return -1;
547
+ if (!aIsRecent && bIsRecent) return 1;
548
+ return 0;
549
+ });
550
+ const primaryWallets = sortedReadyConnectors.slice(0, 3);
551
+ const otherWallets = sortedReadyConnectors.slice(3);
552
+ const primayOuterHr = otherWallets.length > 0 && primaryWallets.length > 0;
553
+ const getInstallUrl = (walletName, walletUrl) => {
554
+ if (walletUrl) return walletUrl;
555
+ const name = walletName.toLowerCase();
556
+ if (name.includes("phantom")) return "https://phantom.app";
557
+ if (name.includes("solflare")) return "https://solflare.com";
558
+ if (name.includes("backpack")) return "https://backpack.app";
559
+ if (name.includes("glow")) return "https://glow.app";
560
+ if (name.includes("coinbase")) return "https://www.coinbase.com/wallet";
561
+ if (name.includes("ledger")) return "https://www.ledger.com";
562
+ if (name.includes("trust")) return "https://trustwallet.com";
563
+ if (name.includes("exodus")) return "https://www.exodus.com";
564
+ return void 0;
565
+ };
566
+ const handleOpenChange = (isOpen) => {
567
+ if (!isOpen) {
568
+ clearError();
569
+ if (isConnecting || connectingConnectorId || walletConnectUri) {
570
+ cancelConnection();
571
+ }
572
+ }
573
+ onOpenChange(isOpen);
574
+ };
575
+ const walletLinkOpen = (walletName) => {
576
+ const installUrl = getInstallUrl(walletName);
577
+ if (installUrl) {
578
+ window.open(installUrl, "_blank");
579
+ }
580
+ };
581
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Dialog, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
582
+ DialogContent,
583
+ {
584
+ showCloseButton: false,
585
+ className: (0, import_clsx2.clsx)(import_WalletModal.default.dialogContent, CN_Modal),
586
+ theme,
587
+ children: [
588
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.dialogHeader, children: [
589
+ isWalletConnectFlow ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
590
+ "button",
591
+ {
592
+ onClick: handleBackFromWalletConnect,
593
+ className: import_WalletModal.default.iconButton,
594
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.ChevronLeft, {})
595
+ }
596
+ ) : null,
597
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogTitle, { className: import_WalletModal.default.dialogTitle, children: isWalletConnectFlow ? "WalletConnect" : "Connect your wallet" }),
598
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogClose, { className: import_WalletModal.default.iconButton, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.X, {}) })
599
+ ] }),
600
+ isWalletConnectFlow && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.walletsContainer, children: [
601
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.tooltipBubble, children: [
602
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Use a WalletConnect" }),
603
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.tooltipIconWrapper, children: [
604
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_si.SiWalletconnect, { className: import_WalletModal.default.tooltipIcon }),
605
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.tooltipCaret })
606
+ ] }),
607
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "supported wallet to scan" })
608
+ ] }),
609
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.qrWrapper, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
610
+ CustomQRCode_default,
611
+ {
612
+ value: walletConnectUri != null ? walletConnectUri : "",
613
+ size: 280,
614
+ ecl: "M",
615
+ loading: !walletConnectUri,
616
+ scanning: !!walletConnectUri
617
+ }
618
+ ) }),
619
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
620
+ Button_default2,
621
+ {
622
+ variant: "outline",
623
+ onClick: handleCopyUri,
624
+ disabled: !walletConnectUri,
625
+ className: import_WalletModal.default.copyButton,
626
+ "data-theme": theme,
627
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
628
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.Check, { className: `${import_WalletModal.default.icon} ${import_WalletModal.default.successIcon}` }),
629
+ "Copy to Clipboard"
630
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
631
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.Copy, { className: import_WalletModal.default.icon }),
632
+ "Copy to Clipboard"
633
+ ] })
634
+ }
635
+ )
636
+ ] }),
637
+ !isWalletConnectFlow && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.walletsContainer, children: [
638
+ !isClient && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.detectingWallets, children: [
639
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner_default2, {}),
640
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: "Detecting wallets..." })
641
+ ] }),
642
+ connectors.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.emptyStateContainer, children: [
643
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.Wallet, { className: import_WalletModal.default.emptyStateIcon }),
644
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: import_WalletModal.default.emptyStateTitle, children: "No Wallets Detected" }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: import_WalletModal.default.emptyStateDesc, children: "Install a Solana wallet extension to get started" }),
646
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.emptyStateActions, children: [
647
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
648
+ Button_default2,
649
+ {
650
+ variant: "outline",
651
+ "data-theme": theme,
652
+ onClick: () => walletLinkOpen("Phantom"),
653
+ children: "Get Phantom"
654
+ }
655
+ ),
656
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
657
+ Button_default2,
658
+ {
659
+ "data-theme": theme,
660
+ variant: "outline",
661
+ onClick: () => walletLinkOpen("Backpack"),
662
+ children: "Get Backpack"
663
+ }
664
+ )
665
+ ] })
666
+ ] }),
667
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.allWallets, children: primaryWallets.map((connector) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
668
+ WalletButton,
669
+ {
670
+ theme,
671
+ connector,
672
+ isThisConnecting: isConnecting && connectingConnectorId === connector.id,
673
+ hasError: errorConnectorId === connector.id,
674
+ isRecent: recentlyConnectedConnectorId === connector.id,
675
+ onSelect: () => handleSelectWallet(connector),
676
+ getInstallUrl
677
+ },
678
+ connector.id
679
+ )) }),
680
+ otherWallets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
681
+ primayOuterHr && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.seprator }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
683
+ Collapsible,
684
+ {
685
+ open: isOtherWalletsOpen,
686
+ onOpenChange: setIsOtherWalletsOpen,
687
+ className: import_WalletModal.default.Collapsible,
688
+ children: [
689
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(CollapsibleTrigger, { className: import_WalletModal.default.hiddenExpand, children: [
690
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: import_WalletModal.default.textContainer, children: "Other Wallets" }),
691
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HiddenWalletIcons, { wallets: otherWallets, className: "shrink-0" })
692
+ ] }),
693
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleContent, { className: import_WalletModal.default.allWallets, children: otherWallets.map((connector) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
694
+ WalletButton,
695
+ {
696
+ theme,
697
+ connector,
698
+ isThisConnecting: isConnecting && connectingConnectorId === connector.id,
699
+ hasError: errorConnectorId === connector.id,
700
+ isRecent: recentlyConnectedConnectorId === connector.id,
701
+ onSelect: () => handleSelectWallet(connector),
702
+ getInstallUrl
703
+ },
704
+ connector.id
705
+ )) })
706
+ ]
707
+ }
708
+ )
709
+ ] }),
710
+ notReadyConnectors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
711
+ (primaryWallets.length > 0 || otherWallets.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.seprator }),
712
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
713
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: import_WalletModal.default.sectionHeader, children: readyConnectors.length > 0 ? "Unavailable Wallets" : "Wallets" }),
714
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.grid, children: notReadyConnectors.slice(0, 3).map((connector) => {
715
+ const installUrl = getInstallUrl(connector.name);
716
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.unavailableRow, children: [
717
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.walletInfo, children: [
718
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
719
+ Avatar_default,
720
+ {
721
+ width: 40,
722
+ height: 40,
723
+ src: connector.icon,
724
+ alt: connector.name,
725
+ theme
726
+ }
727
+ ),
728
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "text-left", children: [
729
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.walletName, children: connector.name }),
730
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.unavailableLabel, children: "Not available" })
731
+ ] })
732
+ ] }),
733
+ installUrl && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
734
+ Button_default2,
735
+ {
736
+ "data-theme": theme,
737
+ variant: "ghost",
738
+ size: "sm",
739
+ className: import_WalletModal.default.installButton,
740
+ onClick: () => window.open(installUrl, "_blank"),
741
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react3.ExternalLink, {})
742
+ }
743
+ )
744
+ ] }, connector.id);
745
+ }) })
746
+ ] })
747
+ ] })
748
+ ] })
749
+ ]
750
+ }
751
+ ) });
752
+ }
753
+ var WalletModal_default = WalletModal;
754
+ function WalletButton(props) {
755
+ const { connector, isThisConnecting, hasError, isRecent, theme, onSelect, getInstallUrl } = props;
756
+ const handleSelectWallet = () => {
757
+ onSelect();
758
+ };
759
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
760
+ Button_default2,
761
+ {
762
+ variant: "outline",
763
+ "data-error": hasError,
764
+ "data-theme": theme,
765
+ className: import_WalletModal.default.walletButton,
766
+ onClick: handleSelectWallet,
767
+ disabled: isThisConnecting,
768
+ children: [
769
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.textContainer, children: [
770
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.nameRow, children: [
771
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: connector.name }),
772
+ isRecent && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: import_WalletModal.default.recentBadge, children: "Recent" })
773
+ ] }),
774
+ isThisConnecting && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.statusText, children: "Connecting..." }),
775
+ hasError && !isThisConnecting && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_WalletModal.default.statusText, "data-type": "error", children: "Click to retry" })
776
+ ] }),
777
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_WalletModal.default.iconContainer, children: [
778
+ isThisConnecting && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner_default2, {}),
779
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
780
+ Avatar_default,
781
+ {
782
+ width: 40,
783
+ height: 40,
784
+ src: connector.icon,
785
+ alt: connector.name,
786
+ theme
787
+ }
788
+ )
789
+ ] })
790
+ ]
791
+ },
792
+ connector.id
793
+ );
794
+ }
795
+ function HiddenWalletIcons({ wallets, maxIcons = 4, className }) {
796
+ const previewWallets = wallets.slice(0, maxIcons);
797
+ const placeholderCount = Math.max(0, maxIcons - previewWallets.length);
798
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
799
+ "div",
800
+ {
801
+ className: `${import_WalletModal.default.hiddenWalletGrid} ${className || ""}`,
802
+ "aria-hidden": "true",
803
+ children: [
804
+ previewWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
805
+ "div",
806
+ {
807
+ className: import_WalletModal.default.hiddenWalletIconWrapper,
808
+ children: wallet.icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
809
+ "img",
810
+ {
811
+ height: 10,
812
+ width: 10,
813
+ src: wallet.icon,
814
+ alt: wallet.name,
815
+ draggable: false,
816
+ onError: (e) => {
817
+ e.currentTarget.style.display = "none";
818
+ }
819
+ }
820
+ )
821
+ },
822
+ wallet.id
823
+ )),
824
+ Array.from({ length: placeholderCount }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
825
+ "div",
826
+ {
827
+ className: import_WalletModal.default.hiddenWalletIconWrapper
828
+ },
829
+ `placeholder-${index}`
830
+ ))
831
+ ]
832
+ }
833
+ );
834
+ }
835
+
836
+ // src/components/WalletModal/index.ts
837
+ var WalletModal_default2 = WalletModal_default;
838
+ //# sourceMappingURL=WalletModal.js.map