@luno-kit/ui 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +1 -1820
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +1 -1791
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1377
- package/package.json +26 -23
package/dist/index.js
CHANGED
|
@@ -1,1793 +1,3 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
|
-
// src/components/AccountDetailsModal/index.tsx
|
|
4
|
-
import { useCallback as useCallback5, useMemo as useMemo4 } from "react";
|
|
5
|
-
import { useAccount as useAccount3, useActiveConnector as useActiveConnector2, useBalance as useBalance2, useChain as useChain4 } from "@luno-kit/react";
|
|
6
|
-
|
|
7
|
-
// src/components/Dialog/index.tsx
|
|
8
|
-
import React from "react";
|
|
9
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
10
|
-
|
|
11
|
-
// src/utils/cs.ts
|
|
12
|
-
import { clsx } from "clsx";
|
|
13
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
14
|
-
var customTwMerge = extendTailwindMerge({
|
|
15
|
-
extend: {
|
|
16
|
-
classGroups: {
|
|
17
|
-
"font-size": [
|
|
18
|
-
"text-xs",
|
|
19
|
-
"text-sm",
|
|
20
|
-
"text-base",
|
|
21
|
-
"text-lg"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
function cs(...inputs) {
|
|
27
|
-
return customTwMerge(clsx(inputs));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/utils/debounce.ts
|
|
31
|
-
function debounce(fn, ms) {
|
|
32
|
-
let timer;
|
|
33
|
-
return () => {
|
|
34
|
-
if (timer) {
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
}
|
|
37
|
-
timer = setTimeout(() => {
|
|
38
|
-
timer = null;
|
|
39
|
-
fn();
|
|
40
|
-
}, ms);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/components/Dialog/index.tsx
|
|
45
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
46
|
-
var DialogRoot = ({
|
|
47
|
-
open,
|
|
48
|
-
onOpenChange,
|
|
49
|
-
children,
|
|
50
|
-
contentClassName,
|
|
51
|
-
overlayClassName
|
|
52
|
-
}) => {
|
|
53
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogPrimitive.Portal, { children: [
|
|
54
|
-
React.createElement(DialogPrimitive.Overlay, {
|
|
55
|
-
className: cs(
|
|
56
|
-
"fixed inset-0 z-[100] bg-modalBackdrop luno-kit",
|
|
57
|
-
"data-[state=open]:[animation:overlay-in_150ms_ease-out]",
|
|
58
|
-
overlayClassName
|
|
59
|
-
)
|
|
60
|
-
}),
|
|
61
|
-
/* @__PURE__ */ jsx(
|
|
62
|
-
DialogPrimitive.Content,
|
|
63
|
-
{
|
|
64
|
-
className: cs(
|
|
65
|
-
"luno-kit font-body fixed z-[200] text-modalText text-base leading-base",
|
|
66
|
-
"bg-modalBackground shadow-primary focus:outline-none overflow-hidden",
|
|
67
|
-
"transition-all duration-200",
|
|
68
|
-
"rounded-t-modalMobile bottom-0 left-0 w-full",
|
|
69
|
-
"translate-y-0 -translate-x-0",
|
|
70
|
-
"data-[state=open]:[animation:slide-up_200ms_ease-out]",
|
|
71
|
-
"md:bottom-auto md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",
|
|
72
|
-
"md:w-auto md:rounded-modal",
|
|
73
|
-
"md:data-[state=open]:[animation:dialog-in_150ms_ease-out]",
|
|
74
|
-
contentClassName
|
|
75
|
-
),
|
|
76
|
-
children
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
] }) });
|
|
80
|
-
};
|
|
81
|
-
var DialogTitleWrapper = ({ children, className }) => React.createElement(DialogPrimitive.Title, { className: cs("font-heading", className) }, children);
|
|
82
|
-
var DialogCloseWrapper = ({ children, className, onClick }) => React.createElement(DialogPrimitive.Close, { className, onClick }, children);
|
|
83
|
-
var Dialog = DialogRoot;
|
|
84
|
-
var DialogClose = DialogCloseWrapper;
|
|
85
|
-
var DialogTitle = DialogTitleWrapper;
|
|
86
|
-
|
|
87
|
-
// src/providers/ModalContext.tsx
|
|
88
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
89
|
-
import { ConnectionStatus, useStatus } from "@luno-kit/react";
|
|
90
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
91
|
-
function useModalVisibility() {
|
|
92
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
93
|
-
const open = useCallback(() => setIsOpen(true), []);
|
|
94
|
-
const close = useCallback(() => setIsOpen(false), []);
|
|
95
|
-
return { isOpen, open, close };
|
|
96
|
-
}
|
|
97
|
-
var ModalContext = createContext(void 0);
|
|
98
|
-
var ModalProvider = ({ children }) => {
|
|
99
|
-
const { isOpen: isConnectModalOpen, open: openConnectModal, close: closeConnectModal } = useModalVisibility();
|
|
100
|
-
const { isOpen: isAccountModalOpen, open: openAccountModal, close: closeAccountModal } = useModalVisibility();
|
|
101
|
-
const { isOpen: isChainModalOpen, open: openChainModal, close: closeChainModal } = useModalVisibility();
|
|
102
|
-
const connectionStatus = useStatus();
|
|
103
|
-
const closeAllModals = useCallback(() => {
|
|
104
|
-
closeConnectModal();
|
|
105
|
-
closeAccountModal();
|
|
106
|
-
closeChainModal();
|
|
107
|
-
}, [closeConnectModal, closeAccountModal, closeChainModal]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (connectionStatus === ConnectionStatus.Disconnected) {
|
|
110
|
-
closeAccountModal();
|
|
111
|
-
closeChainModal();
|
|
112
|
-
}
|
|
113
|
-
}, [connectionStatus, closeAccountModal, closeChainModal]);
|
|
114
|
-
const contextValue = useMemo(() => ({
|
|
115
|
-
isConnectModalOpen,
|
|
116
|
-
isAccountModalOpen,
|
|
117
|
-
isChainModalOpen,
|
|
118
|
-
openConnectModal: connectionStatus !== ConnectionStatus.Connected ? openConnectModal : void 0,
|
|
119
|
-
closeConnectModal,
|
|
120
|
-
openAccountModal: connectionStatus === ConnectionStatus.Connected ? openAccountModal : void 0,
|
|
121
|
-
closeAccountModal,
|
|
122
|
-
openChainModal: connectionStatus === ConnectionStatus.Connected ? openChainModal : void 0,
|
|
123
|
-
closeChainModal,
|
|
124
|
-
closeAllModals
|
|
125
|
-
}), [
|
|
126
|
-
isConnectModalOpen,
|
|
127
|
-
openConnectModal,
|
|
128
|
-
closeConnectModal,
|
|
129
|
-
isAccountModalOpen,
|
|
130
|
-
openAccountModal,
|
|
131
|
-
closeAccountModal,
|
|
132
|
-
isChainModalOpen,
|
|
133
|
-
openChainModal,
|
|
134
|
-
closeChainModal,
|
|
135
|
-
closeAllModals,
|
|
136
|
-
connectionStatus
|
|
137
|
-
]);
|
|
138
|
-
return /* @__PURE__ */ jsx2(ModalContext.Provider, { value: contextValue, children });
|
|
139
|
-
};
|
|
140
|
-
var useConnectModal = () => {
|
|
141
|
-
const context = useContext(ModalContext);
|
|
142
|
-
if (!context) throw new Error("[ModalContext]: useConnectModal must be used within a ModalProvider");
|
|
143
|
-
return {
|
|
144
|
-
isOpen: context.isConnectModalOpen,
|
|
145
|
-
open: context.openConnectModal,
|
|
146
|
-
close: context.closeConnectModal
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
var useAccountModal = () => {
|
|
150
|
-
const context = useContext(ModalContext);
|
|
151
|
-
if (!context) throw new Error("[ModalContext]: useAccountModal must be used within a ModalProvider");
|
|
152
|
-
return {
|
|
153
|
-
isOpen: context.isAccountModalOpen,
|
|
154
|
-
open: context.openAccountModal,
|
|
155
|
-
close: context.closeAccountModal
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
var useChainModal = () => {
|
|
159
|
-
const context = useContext(ModalContext);
|
|
160
|
-
if (!context) throw new Error("[ModalContext]: useChainModal must be used within a ModalProvider");
|
|
161
|
-
return {
|
|
162
|
-
isOpen: context.isChainModalOpen,
|
|
163
|
-
open: context.openChainModal,
|
|
164
|
-
close: context.closeChainModal
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// src/assets/icons/Arrow.tsx
|
|
169
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
170
|
-
var SvgArrow = (props) => /* @__PURE__ */ jsx3(
|
|
171
|
-
"svg",
|
|
172
|
-
{
|
|
173
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
174
|
-
className: "arrow_svg__icon",
|
|
175
|
-
viewBox: "0 0 256 256",
|
|
176
|
-
width: "20",
|
|
177
|
-
height: "20",
|
|
178
|
-
fill: "currentColor",
|
|
179
|
-
...props,
|
|
180
|
-
children: /* @__PURE__ */ jsx3("path", { d: "M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z" })
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
var Arrow_default = SvgArrow;
|
|
184
|
-
|
|
185
|
-
// src/assets/icons/Back.tsx
|
|
186
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
187
|
-
var SvgBack = (props) => /* @__PURE__ */ jsx4(
|
|
188
|
-
"svg",
|
|
189
|
-
{
|
|
190
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
191
|
-
width: "20",
|
|
192
|
-
height: "20",
|
|
193
|
-
fill: "currentColor",
|
|
194
|
-
viewBox: "0 0 256 256",
|
|
195
|
-
...props,
|
|
196
|
-
children: /* @__PURE__ */ jsx4("path", { d: "M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z" })
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
var Back_default = SvgBack;
|
|
200
|
-
|
|
201
|
-
// src/assets/icons/Close.tsx
|
|
202
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
203
|
-
var SvgClose = (props) => /* @__PURE__ */ jsx5(
|
|
204
|
-
"svg",
|
|
205
|
-
{
|
|
206
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
207
|
-
width: "20",
|
|
208
|
-
height: "20",
|
|
209
|
-
fill: "currentColor",
|
|
210
|
-
viewBox: "0 0 256 256",
|
|
211
|
-
...props,
|
|
212
|
-
children: /* @__PURE__ */ jsx5("path", { d: "M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z" })
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
var Close_default = SvgClose;
|
|
216
|
-
|
|
217
|
-
// src/assets/icons/Copy.tsx
|
|
218
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
219
|
-
var SvgCopy = (props) => /* @__PURE__ */ jsx6(
|
|
220
|
-
"svg",
|
|
221
|
-
{
|
|
222
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
223
|
-
className: "copy_svg__icon",
|
|
224
|
-
width: "16",
|
|
225
|
-
height: "16",
|
|
226
|
-
fill: "currentColor",
|
|
227
|
-
viewBox: "0 0 256 256",
|
|
228
|
-
...props,
|
|
229
|
-
children: /* @__PURE__ */ jsx6("path", { d: "M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z" })
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
var Copy_default = SvgCopy;
|
|
233
|
-
|
|
234
|
-
// src/assets/icons/Disconnect.tsx
|
|
235
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
236
|
-
var SvgDisconnect = (props) => /* @__PURE__ */ jsx7(
|
|
237
|
-
"svg",
|
|
238
|
-
{
|
|
239
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
240
|
-
fill: "currentColor",
|
|
241
|
-
viewBox: "0 0 256 256",
|
|
242
|
-
width: "20",
|
|
243
|
-
height: "20",
|
|
244
|
-
...props,
|
|
245
|
-
children: /* @__PURE__ */ jsx7("path", { d: "M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z" })
|
|
246
|
-
}
|
|
247
|
-
);
|
|
248
|
-
var Disconnect_default = SvgDisconnect;
|
|
249
|
-
|
|
250
|
-
// src/assets/icons/List.tsx
|
|
251
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
252
|
-
var SvgList = (props) => /* @__PURE__ */ jsx8(
|
|
253
|
-
"svg",
|
|
254
|
-
{
|
|
255
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
256
|
-
className: "list_svg__icon",
|
|
257
|
-
viewBox: "0 0 256 256",
|
|
258
|
-
width: "20",
|
|
259
|
-
height: "20",
|
|
260
|
-
fill: "currentColor",
|
|
261
|
-
...props,
|
|
262
|
-
children: /* @__PURE__ */ jsx8("path", { d: "M232,48V88a8,8,0,0,1-16,0V56H184a8,8,0,0,1,0-16h40A8,8,0,0,1,232,48ZM72,200H40V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16Zm152-40a8,8,0,0,0-8,8v32H184a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,224,160ZM32,96a8,8,0,0,0,8-8V56H72a8,8,0,0,0,0-16H32a8,8,0,0,0-8,8V88A8,8,0,0,0,32,96ZM188,167l-56,32a8,8,0,0,1-7.94,0L68,167A8,8,0,0,1,64,160V96a8,8,0,0,1,4-7l56-32a8,8,0,0,1,7.94,0l56,32a8,8,0,0,1,4,7v64A8,8,0,0,1,188,167ZM88.12,96,128,118.79,167.88,96,128,73.21ZM80,155.36l40,22.85V132.64L80,109.79Zm96,0V109.79l-40,22.85v45.57Z" })
|
|
263
|
-
}
|
|
264
|
-
);
|
|
265
|
-
var List_default = SvgList;
|
|
266
|
-
|
|
267
|
-
// src/assets/icons/Loading.tsx
|
|
268
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
269
|
-
var SvgLoading = (props) => /* @__PURE__ */ jsx9(
|
|
270
|
-
"svg",
|
|
271
|
-
{
|
|
272
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
273
|
-
width: "20",
|
|
274
|
-
height: "20",
|
|
275
|
-
fill: "currentColor",
|
|
276
|
-
className: "loading_svg__icon",
|
|
277
|
-
viewBox: "0 0 256 256",
|
|
278
|
-
...props,
|
|
279
|
-
children: /* @__PURE__ */ jsx9("path", { d: "M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z" })
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
var Loading_default = SvgLoading;
|
|
283
|
-
|
|
284
|
-
// src/assets/icons/Success.tsx
|
|
285
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
286
|
-
var SvgSuccess = (props) => /* @__PURE__ */ jsx10(
|
|
287
|
-
"svg",
|
|
288
|
-
{
|
|
289
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
290
|
-
className: "success_svg__icon",
|
|
291
|
-
viewBox: "0 0 256 256",
|
|
292
|
-
width: "20",
|
|
293
|
-
height: "20",
|
|
294
|
-
fill: "currentColor",
|
|
295
|
-
...props,
|
|
296
|
-
children: /* @__PURE__ */ jsx10("path", { d: "M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z" })
|
|
297
|
-
}
|
|
298
|
-
);
|
|
299
|
-
var Success_default = SvgSuccess;
|
|
300
|
-
|
|
301
|
-
// src/assets/icons/Switch.tsx
|
|
302
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
303
|
-
var SvgSwitch = (props) => /* @__PURE__ */ jsx11(
|
|
304
|
-
"svg",
|
|
305
|
-
{
|
|
306
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
307
|
-
width: "20",
|
|
308
|
-
height: "20",
|
|
309
|
-
className: "switch_svg__icon",
|
|
310
|
-
viewBox: "0 0 256 256",
|
|
311
|
-
fill: "currentColor",
|
|
312
|
-
...props,
|
|
313
|
-
children: /* @__PURE__ */ jsx11("path", { d: "M253.66,133.66l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L216,132.69V128A88,88,0,0,0,56.49,76.67a8,8,0,0,1-13-9.34A104,104,0,0,1,232,128v4.69l10.34-10.35a8,8,0,0,1,11.32,11.32Zm-41.18,55A104,104,0,0,1,24,128v-4.69L13.66,133.66A8,8,0,0,1,2.34,122.34l24-24a8,8,0,0,1,11.32,0l24,24a8,8,0,0,1-11.32,11.32L40,123.31V128a87.62,87.62,0,0,0,22.24,58.41A79.66,79.66,0,0,1,98.3,157.66a48,48,0,1,1,59.4,0,79.59,79.59,0,0,1,36.08,28.78,89.68,89.68,0,0,0,5.71-7.11,8,8,0,0,1,13,9.34ZM128,152a32,32,0,1,0-32-32A32,32,0,0,0,128,152Zm0,64a88.2,88.2,0,0,0,53.92-18.49,64,64,0,0,0-107.84,0A87.57,87.57,0,0,0,128,216Z" })
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
var Switch_default = SvgSwitch;
|
|
317
|
-
|
|
318
|
-
// src/components/AccountDetailsModal/MainView.tsx
|
|
319
|
-
import { useMemo as useMemo2 } from "react";
|
|
320
|
-
|
|
321
|
-
// src/components/ChainIcon/index.tsx
|
|
322
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
323
|
-
var ChainIcon = ({
|
|
324
|
-
chainIconUrl,
|
|
325
|
-
chainName,
|
|
326
|
-
className
|
|
327
|
-
}) => {
|
|
328
|
-
if (chainIconUrl) {
|
|
329
|
-
return /* @__PURE__ */ jsx12(
|
|
330
|
-
"img",
|
|
331
|
-
{
|
|
332
|
-
src: chainIconUrl,
|
|
333
|
-
alt: chainName || "Chain icon",
|
|
334
|
-
className: cs("w-full h-full object-cover rounded-full", className)
|
|
335
|
-
}
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
return /* @__PURE__ */ jsx12("div", { className: cs(
|
|
339
|
-
"w-full h-full bg-gray-500 text-modalText font-semibold",
|
|
340
|
-
"flex items-center justify-center rounded-full",
|
|
341
|
-
className
|
|
342
|
-
), children: chainName ? chainName.charAt(0).toUpperCase() : "C" });
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
// src/components/AccountDetailsModal/MainView.tsx
|
|
346
|
-
import { useAccount, useChain, useDisconnect, getExplorerUrl } from "@luno-kit/react";
|
|
347
|
-
import { Fragment, jsx as jsx13, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
348
|
-
var MainView = ({
|
|
349
|
-
onViewChange,
|
|
350
|
-
onModalClose
|
|
351
|
-
}) => {
|
|
352
|
-
const { address } = useAccount();
|
|
353
|
-
const { chain } = useChain();
|
|
354
|
-
const { disconnectAsync } = useDisconnect();
|
|
355
|
-
const items = useMemo2(() => {
|
|
356
|
-
return [
|
|
357
|
-
{
|
|
358
|
-
key: "Chain Name",
|
|
359
|
-
content: /* @__PURE__ */ jsxs2("div", { className: "flex items-stretch w-full justify-between", children: [
|
|
360
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
|
|
361
|
-
/* @__PURE__ */ jsx13(
|
|
362
|
-
ChainIcon,
|
|
363
|
-
{
|
|
364
|
-
className: "w-[20px] h-[20px]",
|
|
365
|
-
chainIconUrl: chain?.chainIconUrl,
|
|
366
|
-
chainName: chain?.name
|
|
367
|
-
}
|
|
368
|
-
),
|
|
369
|
-
/* @__PURE__ */ jsx13("span", { className: "text-base text-modalText", children: chain?.name || "Polkadot" })
|
|
370
|
-
] }),
|
|
371
|
-
/* @__PURE__ */ jsx13(
|
|
372
|
-
"div",
|
|
373
|
-
{
|
|
374
|
-
className: "flex items-center justify-center",
|
|
375
|
-
children: /* @__PURE__ */ jsx13(Arrow_default, { className: "w-[16px] h-[16px] " })
|
|
376
|
-
}
|
|
377
|
-
)
|
|
378
|
-
] }),
|
|
379
|
-
onClick: () => onViewChange("switchChain" /* switchChain */)
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
key: "View on Explorer",
|
|
383
|
-
content: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
384
|
-
/* @__PURE__ */ jsx13(List_default, {}),
|
|
385
|
-
/* @__PURE__ */ jsx13("span", { className: "text-base text-accountActionItemText", children: "View on Explorer" })
|
|
386
|
-
] }),
|
|
387
|
-
onClick: () => window.open(getExplorerUrl(chain?.blockExplorers?.default?.url, address, "address"))
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
key: "Switch Account",
|
|
391
|
-
content: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
392
|
-
/* @__PURE__ */ jsx13(Switch_default, {}),
|
|
393
|
-
/* @__PURE__ */ jsx13("span", { className: "text-base text-accountActionItemText", children: "Switch Account" })
|
|
394
|
-
] }),
|
|
395
|
-
onClick: () => onViewChange("switchAccount" /* switchAccount */)
|
|
396
|
-
}
|
|
397
|
-
];
|
|
398
|
-
}, [onViewChange, chain, address]);
|
|
399
|
-
const handleDisconnect = async () => {
|
|
400
|
-
await disconnectAsync();
|
|
401
|
-
onModalClose();
|
|
402
|
-
};
|
|
403
|
-
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-3 w-full", children: [
|
|
404
|
-
/* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-1.5 w-full px-4", children: items.map((i) => /* @__PURE__ */ jsx13(SelectItem, { onClick: i.onClick, children: i.content }, i.key)) }),
|
|
405
|
-
/* @__PURE__ */ jsx13("div", { className: "w-full mx-[-100px] h-[1px] bg-cutLine" }),
|
|
406
|
-
/* @__PURE__ */ jsx13("div", { className: "w-full px-4 pb-4", children: /* @__PURE__ */ jsxs2(SelectItem, { onClick: handleDisconnect, children: [
|
|
407
|
-
/* @__PURE__ */ jsx13(Disconnect_default, {}),
|
|
408
|
-
/* @__PURE__ */ jsx13("span", { className: "font-medium text-base text-accountActionItemText", children: "Disconnect" })
|
|
409
|
-
] }) })
|
|
410
|
-
] });
|
|
411
|
-
};
|
|
412
|
-
var SelectItem = ({ children, onClick }) => {
|
|
413
|
-
return /* @__PURE__ */ jsx13(
|
|
414
|
-
"button",
|
|
415
|
-
{
|
|
416
|
-
type: "button",
|
|
417
|
-
onClick: () => onClick?.(),
|
|
418
|
-
className: cs(
|
|
419
|
-
"w-full p-3.5 rounded-accountActionItem border-none text-left flex items-center gap-2 font-medium",
|
|
420
|
-
"bg-accountActionItemBackground hover:bg-accountActionItemBackgroundHover",
|
|
421
|
-
"transition-colors duration-200",
|
|
422
|
-
onClick ? "cursor-pointer" : "cursor-auto"
|
|
423
|
-
),
|
|
424
|
-
"aria-label": typeof children === "string" ? children : void 0,
|
|
425
|
-
children
|
|
426
|
-
}
|
|
427
|
-
);
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
// src/components/AccountDetailsModal/SwitchAccountView.tsx
|
|
431
|
-
import React4, { useCallback as useCallback2 } from "react";
|
|
432
|
-
import { useAccount as useAccount2, useAccounts, useActiveConnector, useBalance, useChain as useChain2 } from "@luno-kit/react";
|
|
433
|
-
import { formatAddress } from "@luno-kit/react";
|
|
434
|
-
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
435
|
-
var SwitchAccountView = ({ onBack }) => {
|
|
436
|
-
const { accounts, selectAccount } = useAccounts();
|
|
437
|
-
const { address: currentAddress } = useAccount2();
|
|
438
|
-
const _selectAccount = useCallback2((acc) => {
|
|
439
|
-
selectAccount(acc);
|
|
440
|
-
onBack();
|
|
441
|
-
}, [onBack]);
|
|
442
|
-
return /* @__PURE__ */ jsx14("div", { className: "flex flex-col gap-1.5 pt-3 overflow-auto max-h-[400px] no-scrollbar p-4 pt-0", children: accounts.map((acc) => /* @__PURE__ */ jsx14(
|
|
443
|
-
AccountItem,
|
|
444
|
-
{
|
|
445
|
-
account: acc,
|
|
446
|
-
isSelected: acc.address === currentAddress,
|
|
447
|
-
selectAccount: _selectAccount
|
|
448
|
-
},
|
|
449
|
-
acc.address
|
|
450
|
-
)) });
|
|
451
|
-
};
|
|
452
|
-
SwitchAccountView.title = "Switch Accounts";
|
|
453
|
-
var AccountItem = React4.memo(({
|
|
454
|
-
isSelected,
|
|
455
|
-
account,
|
|
456
|
-
selectAccount
|
|
457
|
-
}) => {
|
|
458
|
-
const { chain } = useChain2();
|
|
459
|
-
const address = account.address;
|
|
460
|
-
const { data: balance } = useBalance({ address });
|
|
461
|
-
const connector = useActiveConnector();
|
|
462
|
-
return /* @__PURE__ */ jsxs3(
|
|
463
|
-
"button",
|
|
464
|
-
{
|
|
465
|
-
type: "button",
|
|
466
|
-
onClick: () => selectAccount(account),
|
|
467
|
-
className: cs(
|
|
468
|
-
"px-3.5 py-2.5 w-full rounded-accountSelectItem border-none",
|
|
469
|
-
"bg-accountSelectItemBackground",
|
|
470
|
-
"text-left flex items-center justify-between gap-2",
|
|
471
|
-
"transition-colors duration-200",
|
|
472
|
-
isSelected ? "cursor-auto" : "cursor-pointer hover:bg-accountSelectItemBackgroundHover"
|
|
473
|
-
),
|
|
474
|
-
"aria-label": account.name || address,
|
|
475
|
-
disabled: isSelected,
|
|
476
|
-
children: [
|
|
477
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
478
|
-
/* @__PURE__ */ jsx14("div", { className: "shrink-0 w-[24px] h-[24px] bg-pink-500 rounded-full flex items-center justify-center", children: connector?.icon && /* @__PURE__ */ jsx14("img", { src: connector?.icon, alt: "luno account" }) }),
|
|
479
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-start", children: [
|
|
480
|
-
/* @__PURE__ */ jsx14("span", { className: "font-medium text-sm leading-sm text-accountSelectItemText", children: account.name || formatAddress(address) }),
|
|
481
|
-
/* @__PURE__ */ jsx14("span", { className: "text-xs text-modalTextSecondary font-medium", children: balance === void 0 ? /* @__PURE__ */ jsx14("div", { className: "animate-pulse rounded w-[60px] h-[18px] bg-skeleton" }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
482
|
-
balance?.formattedTransferable || "0.00",
|
|
483
|
-
" ",
|
|
484
|
-
chain?.nativeCurrency?.symbol || "DOT"
|
|
485
|
-
] }) })
|
|
486
|
-
] })
|
|
487
|
-
] }),
|
|
488
|
-
isSelected && /* @__PURE__ */ jsx14("div", { className: "border-[1px] border-solid border-accentColor rounded-full overflow-hidden flex items-center justify-center w-[18px] h-[18px]", children: /* @__PURE__ */ jsx14("div", { className: "rounded-full bg-accentColor w-[10px] h-[10px]" }) })
|
|
489
|
-
]
|
|
490
|
-
}
|
|
491
|
-
);
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// src/components/ChainList/index.tsx
|
|
495
|
-
import React5, { useMemo as useMemo3, useState as useState2 } from "react";
|
|
496
|
-
import { useApi, useChain as useChain3, useChains, useSwitchChain } from "@luno-kit/react";
|
|
497
|
-
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
498
|
-
var FILTER_TABS = [
|
|
499
|
-
{ key: "All" /* all */, label: "All" /* all */ },
|
|
500
|
-
{ key: "Mainnets" /* mainnets */, label: "Mainnets" /* mainnets */ },
|
|
501
|
-
{ key: "Testnets" /* testnets */, label: "Testnets" /* testnets */ }
|
|
502
|
-
];
|
|
503
|
-
var ChainList = ({ onChainSwitched }) => {
|
|
504
|
-
const { chain: currentChain } = useChain3();
|
|
505
|
-
const chains = useChains();
|
|
506
|
-
const { switchChainAsync } = useSwitchChain();
|
|
507
|
-
const { isApiReady, apiError } = useApi();
|
|
508
|
-
const [activeFilter, setActiveFilter] = useState2("All" /* all */);
|
|
509
|
-
const [switchingChain, setSwitchingChain] = useState2(null);
|
|
510
|
-
const filteredChains = useMemo3(() => {
|
|
511
|
-
switch (activeFilter) {
|
|
512
|
-
case "Mainnets" /* mainnets */:
|
|
513
|
-
return chains.filter((chain) => !chain.testnet);
|
|
514
|
-
case "Testnets" /* testnets */:
|
|
515
|
-
return chains.filter((chain) => chain.testnet);
|
|
516
|
-
case "All" /* all */:
|
|
517
|
-
default:
|
|
518
|
-
return chains;
|
|
519
|
-
}
|
|
520
|
-
}, [chains, activeFilter]);
|
|
521
|
-
const handleChainSelect = async (chain) => {
|
|
522
|
-
if (chain.genesisHash === currentChain?.genesisHash) return;
|
|
523
|
-
if (!isApiReady && !apiError) return;
|
|
524
|
-
setSwitchingChain(chain.genesisHash);
|
|
525
|
-
try {
|
|
526
|
-
await switchChainAsync({ chainId: chain.genesisHash });
|
|
527
|
-
onChainSwitched?.(chain);
|
|
528
|
-
} catch (error) {
|
|
529
|
-
console.error("Failed to switch chain:", error);
|
|
530
|
-
} finally {
|
|
531
|
-
setSwitchingChain(null);
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
535
|
-
/* @__PURE__ */ jsx15("div", { className: "flex items-center gap-1.5 w-full", children: FILTER_TABS.map((tab) => /* @__PURE__ */ jsx15(
|
|
536
|
-
"button",
|
|
537
|
-
{
|
|
538
|
-
onClick: () => setActiveFilter(tab.key),
|
|
539
|
-
className: cs(
|
|
540
|
-
"px-3.5 flex items-center justify-center cursor-pointer min-w-[48px] min-h-[24px] rounded-networkSelectItem text-[12px] leading-[16px] font-medium transition-colors",
|
|
541
|
-
activeFilter === tab.key ? "bg-navigationButtonBackground text-modalText" : "bg-transparent text-modalTextSecondary hover:text-modalText"
|
|
542
|
-
),
|
|
543
|
-
children: tab.label
|
|
544
|
-
},
|
|
545
|
-
tab.key
|
|
546
|
-
)) }),
|
|
547
|
-
/* @__PURE__ */ jsx15("div", { className: "flex flex-col gap-1.5 overflow-y-auto custom-scrollbar max-h-[450px]", children: filteredChains.map((chain) => /* @__PURE__ */ jsx15(
|
|
548
|
-
ChainItem,
|
|
549
|
-
{
|
|
550
|
-
chain,
|
|
551
|
-
isSelected: chain.genesisHash === currentChain?.genesisHash,
|
|
552
|
-
onSelect: handleChainSelect,
|
|
553
|
-
isLoading: (switchingChain === chain.genesisHash || !isApiReady) && !apiError
|
|
554
|
-
},
|
|
555
|
-
chain.genesisHash
|
|
556
|
-
)) }),
|
|
557
|
-
filteredChains.length === 0 && /* @__PURE__ */ jsx15("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxs4("span", { className: "text-modalTextSecondary text-xs", children: [
|
|
558
|
-
"No ",
|
|
559
|
-
activeFilter === "All" /* all */ ? "chains" : activeFilter.toLowerCase(),
|
|
560
|
-
" available"
|
|
561
|
-
] }) })
|
|
562
|
-
] });
|
|
563
|
-
};
|
|
564
|
-
var ChainItem = React5.memo(({
|
|
565
|
-
chain,
|
|
566
|
-
isSelected,
|
|
567
|
-
isLoading,
|
|
568
|
-
onSelect
|
|
569
|
-
}) => {
|
|
570
|
-
return /* @__PURE__ */ jsxs4(
|
|
571
|
-
"button",
|
|
572
|
-
{
|
|
573
|
-
onClick: () => onSelect(chain),
|
|
574
|
-
disabled: isSelected || isLoading,
|
|
575
|
-
className: cs(
|
|
576
|
-
"flex items-center justify-between p-2 rounded-sm",
|
|
577
|
-
"bg-networkSelectItemBackground",
|
|
578
|
-
"transition-colors duration-200",
|
|
579
|
-
isSelected || isLoading ? "cursor-default" : "cursor-pointer hover:bg-networkSelectItemBackgroundHover",
|
|
580
|
-
isLoading && "opacity-80"
|
|
581
|
-
),
|
|
582
|
-
children: [
|
|
583
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
584
|
-
/* @__PURE__ */ jsx15(
|
|
585
|
-
ChainIcon,
|
|
586
|
-
{
|
|
587
|
-
className: "w-[24px] bg-modal-bg h-[24px] flex items-center justify-center",
|
|
588
|
-
chainIconUrl: chain?.chainIconUrl,
|
|
589
|
-
chainName: chain?.name
|
|
590
|
-
}
|
|
591
|
-
),
|
|
592
|
-
/* @__PURE__ */ jsx15("div", { className: "flex flex-col items-start", children: /* @__PURE__ */ jsx15("span", { className: "font-medium text-base text-modalText", children: chain.name }) })
|
|
593
|
-
] }),
|
|
594
|
-
/* @__PURE__ */ jsx15("div", { className: "flex items-center justify-center h-[20px]", children: isSelected ? isLoading ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
595
|
-
/* @__PURE__ */ jsx15("span", { className: "text-accentColor text-xs leading-xs mr-1.5", children: "Switching" }),
|
|
596
|
-
/* @__PURE__ */ jsx15(
|
|
597
|
-
Loading_default,
|
|
598
|
-
{
|
|
599
|
-
className: "text-accentColor animate-[spin_2s_linear_infinite]",
|
|
600
|
-
width: "15px",
|
|
601
|
-
height: "15px"
|
|
602
|
-
}
|
|
603
|
-
)
|
|
604
|
-
] }) : /* @__PURE__ */ jsxs4("span", { className: "status-dot-container", children: [
|
|
605
|
-
/* @__PURE__ */ jsx15("span", { className: "ping-animation" }),
|
|
606
|
-
/* @__PURE__ */ jsx15("span", { className: "status-dot" })
|
|
607
|
-
] }) : null })
|
|
608
|
-
]
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
// src/components/AccountDetailsModal/SwitchChainView.tsx
|
|
614
|
-
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
615
|
-
var SwitchChainView = ({ onBack }) => {
|
|
616
|
-
return /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-3.5 p-4 pt-0", children: /* @__PURE__ */ jsx16(ChainList, {}) });
|
|
617
|
-
};
|
|
618
|
-
SwitchChainView.title = "Select Networks";
|
|
619
|
-
|
|
620
|
-
// src/components/Copy/index.tsx
|
|
621
|
-
import { useCallback as useCallback3, useState as useState3 } from "react";
|
|
622
|
-
import { jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
623
|
-
var Copy = ({ copyText, label, className = "" }) => {
|
|
624
|
-
const [isCopied, setIsCopied] = useState3(false);
|
|
625
|
-
const copyToClipboard = useCallback3(async (text) => {
|
|
626
|
-
try {
|
|
627
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
628
|
-
await navigator.clipboard.writeText(text);
|
|
629
|
-
setIsCopied(true);
|
|
630
|
-
setTimeout(() => setIsCopied(false), 2e3);
|
|
631
|
-
return true;
|
|
632
|
-
}
|
|
633
|
-
return false;
|
|
634
|
-
} catch (err) {
|
|
635
|
-
console.error("Copy failed:", err);
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
}, []);
|
|
639
|
-
return /* @__PURE__ */ jsxs5(
|
|
640
|
-
"button",
|
|
641
|
-
{
|
|
642
|
-
type: "button",
|
|
643
|
-
className: cs("cursor-pointer bg-transparent border-none p-0 m-0 inline-flex items-center justify-center gap-1", className),
|
|
644
|
-
onClick: () => !isCopied && copyText && copyToClipboard(copyText),
|
|
645
|
-
"aria-label": "Copy address to clipboard",
|
|
646
|
-
disabled: isCopied,
|
|
647
|
-
children: [
|
|
648
|
-
isCopied ? /* @__PURE__ */ jsx17(Success_default, { className: "text-accentColor", width: 16, height: 16 }) : /* @__PURE__ */ jsx17(Copy_default, { width: 16, height: 16 }),
|
|
649
|
-
label
|
|
650
|
-
]
|
|
651
|
-
}
|
|
652
|
-
);
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
// src/components/AccountDetailsModal/index.tsx
|
|
656
|
-
import { formatAddress as formatAddress2 } from "@luno-kit/react";
|
|
657
|
-
|
|
658
|
-
// src/hooks/useAnimatedViews.ts
|
|
659
|
-
import { useCallback as useCallback4, useState as useState4, useRef } from "react";
|
|
660
|
-
function useAnimatedViews({
|
|
661
|
-
initialView,
|
|
662
|
-
animationDuration = 200,
|
|
663
|
-
animationEasing = "ease-out"
|
|
664
|
-
}) {
|
|
665
|
-
const [currentView, setCurrentView] = useState4(initialView);
|
|
666
|
-
const [isAnimating, setIsAnimating] = useState4(false);
|
|
667
|
-
const containerRef = useRef(null);
|
|
668
|
-
const currentViewRef = useRef(null);
|
|
669
|
-
const handleViewChange = useCallback4((view) => {
|
|
670
|
-
if (view === currentView || isAnimating) return;
|
|
671
|
-
setIsAnimating(true);
|
|
672
|
-
if (!containerRef.current) {
|
|
673
|
-
setCurrentView(view);
|
|
674
|
-
setIsAnimating(false);
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
const container = containerRef.current;
|
|
678
|
-
const currentHeight = container.offsetHeight;
|
|
679
|
-
setCurrentView(view);
|
|
680
|
-
requestAnimationFrame(() => {
|
|
681
|
-
if (!container || !currentViewRef.current) {
|
|
682
|
-
setIsAnimating(false);
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const newHeight = currentViewRef.current.offsetHeight;
|
|
686
|
-
container.animate([
|
|
687
|
-
{ height: currentHeight + "px" },
|
|
688
|
-
{ height: newHeight + "px" }
|
|
689
|
-
], {
|
|
690
|
-
duration: animationDuration,
|
|
691
|
-
easing: animationEasing,
|
|
692
|
-
fill: "forwards"
|
|
693
|
-
}).addEventListener("finish", () => {
|
|
694
|
-
setIsAnimating(false);
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
}, [currentView, isAnimating, animationDuration, animationEasing]);
|
|
698
|
-
const resetView = useCallback4(() => {
|
|
699
|
-
setCurrentView(initialView);
|
|
700
|
-
setIsAnimating(false);
|
|
701
|
-
}, [initialView]);
|
|
702
|
-
return {
|
|
703
|
-
currentView,
|
|
704
|
-
isAnimating,
|
|
705
|
-
containerRef,
|
|
706
|
-
currentViewRef,
|
|
707
|
-
handleViewChange,
|
|
708
|
-
resetView
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
// src/components/AccountDetailsModal/index.tsx
|
|
713
|
-
import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
714
|
-
var AccountDetailsModal = () => {
|
|
715
|
-
const { isOpen, close } = useAccountModal();
|
|
716
|
-
const { address } = useAccount3();
|
|
717
|
-
const { chain } = useChain4();
|
|
718
|
-
const { data: balance } = useBalance2({ address });
|
|
719
|
-
const activeConnector = useActiveConnector2();
|
|
720
|
-
const {
|
|
721
|
-
currentView,
|
|
722
|
-
containerRef,
|
|
723
|
-
currentViewRef,
|
|
724
|
-
handleViewChange,
|
|
725
|
-
resetView
|
|
726
|
-
} = useAnimatedViews({ initialView: "main" /* main */ });
|
|
727
|
-
const handleModalClose = useCallback5(() => {
|
|
728
|
-
close();
|
|
729
|
-
resetView();
|
|
730
|
-
}, [close]);
|
|
731
|
-
const viewTitle = useMemo4(() => {
|
|
732
|
-
if (currentView === "switchAccount" /* switchAccount */) return "Switch Account";
|
|
733
|
-
if (currentView === "switchChain" /* switchChain */) return SwitchChainView.title;
|
|
734
|
-
return null;
|
|
735
|
-
}, [currentView]);
|
|
736
|
-
const viewComponents = useMemo4(() => ({
|
|
737
|
-
["main" /* main */]: /* @__PURE__ */ jsx18(
|
|
738
|
-
MainView,
|
|
739
|
-
{
|
|
740
|
-
onViewChange: handleViewChange,
|
|
741
|
-
onModalClose: handleModalClose
|
|
742
|
-
}
|
|
743
|
-
),
|
|
744
|
-
["switchAccount" /* switchAccount */]: /* @__PURE__ */ jsx18(SwitchAccountView, { onBack: () => handleViewChange("main" /* main */) }),
|
|
745
|
-
["switchChain" /* switchChain */]: /* @__PURE__ */ jsx18(SwitchChainView, { onBack: () => handleViewChange("main" /* main */) })
|
|
746
|
-
}), [handleViewChange, handleModalClose]);
|
|
747
|
-
return /* @__PURE__ */ jsx18(
|
|
748
|
-
Dialog,
|
|
749
|
-
{
|
|
750
|
-
open: isOpen,
|
|
751
|
-
onOpenChange: handleModalClose,
|
|
752
|
-
children: /* @__PURE__ */ jsxs6("div", { className: cs(
|
|
753
|
-
"flex flex-col w-full md:w-[360px] max-h-[500px] text-modalText",
|
|
754
|
-
"bg-modalBackground shadow-modal",
|
|
755
|
-
currentView === "main" /* main */ ? "gap-6" : "gap-3.5"
|
|
756
|
-
), children: [
|
|
757
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex items-stretch justify-between w-full px-4 pt-4", children: [
|
|
758
|
-
currentView === "main" /* main */ ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
|
|
759
|
-
activeConnector?.icon && /* @__PURE__ */ jsx18("div", { className: "flex items-center justify-center w-[55px] h-[55px]", children: /* @__PURE__ */ jsx18("img", { src: activeConnector.icon, alt: "" }) }),
|
|
760
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-start gap-2 w-full", children: [
|
|
761
|
-
/* @__PURE__ */ jsx18(DialogTitle, { className: "sr-only", children: "Account Details" }),
|
|
762
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1.5 w-full", children: [
|
|
763
|
-
/* @__PURE__ */ jsx18("span", { className: "text-base text-modalText font-semibold", children: formatAddress2(address) }),
|
|
764
|
-
/* @__PURE__ */ jsx18(Copy, { copyText: address })
|
|
765
|
-
] }),
|
|
766
|
-
/* @__PURE__ */ jsx18("div", { className: "text-sm text-modalTextSecondary font-medium min-h-[20px]", children: balance === void 0 ? /* @__PURE__ */ jsx18("div", { className: "animate-pulse rounded w-[80px] h-[20px] bg-skeleton" }) : /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
767
|
-
balance?.formattedTransferable || "0.00",
|
|
768
|
-
" ",
|
|
769
|
-
chain?.nativeCurrency?.symbol || "DOT"
|
|
770
|
-
] }) })
|
|
771
|
-
] })
|
|
772
|
-
] }) : /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
773
|
-
/* @__PURE__ */ jsx18(
|
|
774
|
-
"button",
|
|
775
|
-
{
|
|
776
|
-
className: "flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",
|
|
777
|
-
onClick: () => handleViewChange("main" /* main */),
|
|
778
|
-
"aria-label": "Back",
|
|
779
|
-
children: /* @__PURE__ */ jsx18(Back_default, {})
|
|
780
|
-
}
|
|
781
|
-
),
|
|
782
|
-
/* @__PURE__ */ jsx18(
|
|
783
|
-
DialogTitle,
|
|
784
|
-
{
|
|
785
|
-
className: "text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",
|
|
786
|
-
children: viewTitle
|
|
787
|
-
}
|
|
788
|
-
)
|
|
789
|
-
] }),
|
|
790
|
-
/* @__PURE__ */ jsx18(DialogClose, { className: "z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer", children: /* @__PURE__ */ jsx18(Close_default, {}) })
|
|
791
|
-
] }),
|
|
792
|
-
/* @__PURE__ */ jsx18(
|
|
793
|
-
"div",
|
|
794
|
-
{
|
|
795
|
-
ref: containerRef,
|
|
796
|
-
className: "relative overflow-hidden",
|
|
797
|
-
children: /* @__PURE__ */ jsx18("div", { ref: currentViewRef, children: viewComponents[currentView] })
|
|
798
|
-
}
|
|
799
|
-
)
|
|
800
|
-
] })
|
|
801
|
-
}
|
|
802
|
-
);
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
// src/components/ChainModal/index.tsx
|
|
806
|
-
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
807
|
-
var ChainModal = () => {
|
|
808
|
-
const { isOpen, close } = useChainModal();
|
|
809
|
-
return /* @__PURE__ */ jsx19(Dialog, { open: isOpen, onOpenChange: (open) => !open && close(), children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-col w-full md:w-[360px] max-h-[500px] p-4 gap-3.5 text-modalText", children: [
|
|
810
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between w-full", children: [
|
|
811
|
-
/* @__PURE__ */ jsx19("div", { className: "w-[30px]" }),
|
|
812
|
-
" ",
|
|
813
|
-
/* @__PURE__ */ jsx19(DialogTitle, { className: "text-lg leading-lg text-modalText font-semibold transition-opacity duration-300", children: "Select Network" }),
|
|
814
|
-
/* @__PURE__ */ jsx19(DialogClose, { className: "z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer", children: /* @__PURE__ */ jsx19(Close_default, {}) })
|
|
815
|
-
] }),
|
|
816
|
-
/* @__PURE__ */ jsx19(ChainList, {})
|
|
817
|
-
] }) });
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
// src/components/ConnectModal/index.tsx
|
|
821
|
-
import { useEffect as useEffect4, useMemo as useMemo5, useState as useState7 } from "react";
|
|
822
|
-
import { useConnect, isMobileDevice as isMobileDevice2 } from "@luno-kit/react";
|
|
823
|
-
|
|
824
|
-
// src/hooks/useConnectButton.ts
|
|
825
|
-
import {
|
|
826
|
-
useStatus as useStatus2,
|
|
827
|
-
useAccount as useAccount4,
|
|
828
|
-
useChain as useChain5,
|
|
829
|
-
useBalance as useBalance3,
|
|
830
|
-
ConnectionStatus as ConnectionStatus2,
|
|
831
|
-
useChains as useChains2,
|
|
832
|
-
useActiveConnector as useActiveConnector3,
|
|
833
|
-
formatAddress as formatAddress3
|
|
834
|
-
} from "@luno-kit/react";
|
|
835
|
-
function useLunoWallet() {
|
|
836
|
-
const connectionStatus = useStatus2();
|
|
837
|
-
const { account, address } = useAccount4();
|
|
838
|
-
const { chain: currentChain } = useChain5();
|
|
839
|
-
const configuredChains = useChains2();
|
|
840
|
-
const { data: balance } = useBalance3({ address });
|
|
841
|
-
const activeConnector = useActiveConnector3();
|
|
842
|
-
const { open: openConnectModal, isOpen: isConnectModalOpen } = useConnectModal();
|
|
843
|
-
const { open: openAccountModal, isOpen: isAccountModalOpen } = useAccountModal();
|
|
844
|
-
const { open: openChainModal, isOpen: isChainModalOpen } = useChainModal();
|
|
845
|
-
const isConnecting = connectionStatus === ConnectionStatus2.Connecting;
|
|
846
|
-
const isConnected = connectionStatus === ConnectionStatus2.Connected;
|
|
847
|
-
const isDisconnected = connectionStatus === ConnectionStatus2.Disconnected || connectionStatus === ConnectionStatus2.Disconnecting;
|
|
848
|
-
const isChainSupported = !!currentChain && configuredChains.some((c) => c.genesisHash.toLowerCase() === currentChain.genesisHash.toLowerCase());
|
|
849
|
-
return {
|
|
850
|
-
activeConnector,
|
|
851
|
-
connectionStatus,
|
|
852
|
-
isConnected,
|
|
853
|
-
isDisconnected,
|
|
854
|
-
isConnecting,
|
|
855
|
-
account,
|
|
856
|
-
address,
|
|
857
|
-
displayAddress: formatAddress3(address),
|
|
858
|
-
currentChain,
|
|
859
|
-
configuredChains,
|
|
860
|
-
isChainSupported,
|
|
861
|
-
chainIconUrl: currentChain?.chainIconUrl,
|
|
862
|
-
chainName: currentChain?.name,
|
|
863
|
-
balance,
|
|
864
|
-
openConnectModal,
|
|
865
|
-
openAccountModal,
|
|
866
|
-
openChainModal,
|
|
867
|
-
isConnectModalOpen,
|
|
868
|
-
isAccountModalOpen,
|
|
869
|
-
isChainModalOpen
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// src/hooks/useWindowSize.ts
|
|
874
|
-
import { useEffect as useEffect2, useState as useState6 } from "react";
|
|
875
|
-
var useWindowSize = () => {
|
|
876
|
-
const [windowSize, setWindowSize] = useState6({
|
|
877
|
-
height: void 0,
|
|
878
|
-
width: void 0
|
|
879
|
-
});
|
|
880
|
-
useEffect2(() => {
|
|
881
|
-
const handleResize = debounce(() => {
|
|
882
|
-
setWindowSize({
|
|
883
|
-
height: window.innerHeight,
|
|
884
|
-
width: window.innerWidth
|
|
885
|
-
});
|
|
886
|
-
}, 500);
|
|
887
|
-
window.addEventListener("resize", handleResize);
|
|
888
|
-
handleResize();
|
|
889
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
890
|
-
}, []);
|
|
891
|
-
return windowSize;
|
|
892
|
-
};
|
|
893
|
-
|
|
894
|
-
// src/components/ConnectModal/WalletView.tsx
|
|
895
|
-
import React10 from "react";
|
|
896
|
-
|
|
897
|
-
// src/components/QRCode/index.tsx
|
|
898
|
-
import { Cuer } from "cuer";
|
|
899
|
-
import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
900
|
-
var QRCode = ({
|
|
901
|
-
logoBackground,
|
|
902
|
-
uri,
|
|
903
|
-
size
|
|
904
|
-
}) => {
|
|
905
|
-
if (!uri) {
|
|
906
|
-
const QR_GRID_SIZE = 57;
|
|
907
|
-
const FINDER_SIZE_WITH_MARGIN = 8;
|
|
908
|
-
const ARENA_GRID_SIZE = Math.floor(QR_GRID_SIZE / 4);
|
|
909
|
-
const cellSize = size / QR_GRID_SIZE;
|
|
910
|
-
const arenaSize = ARENA_GRID_SIZE * cellSize;
|
|
911
|
-
const arenaStart = Math.floor(QR_GRID_SIZE / 2 - ARENA_GRID_SIZE / 2);
|
|
912
|
-
const arenaEnd = arenaStart + ARENA_GRID_SIZE;
|
|
913
|
-
const generateSkeletonDots = () => {
|
|
914
|
-
const dots = [];
|
|
915
|
-
for (let i = 0; i < QR_GRID_SIZE; i++) {
|
|
916
|
-
for (let j = 0; j < QR_GRID_SIZE; j++) {
|
|
917
|
-
if (i >= arenaStart && i <= arenaEnd && j >= arenaStart && j <= arenaEnd) continue;
|
|
918
|
-
const isInFinder = i < FINDER_SIZE_WITH_MARGIN && j < FINDER_SIZE_WITH_MARGIN || i < FINDER_SIZE_WITH_MARGIN && j >= QR_GRID_SIZE - FINDER_SIZE_WITH_MARGIN || i >= QR_GRID_SIZE - FINDER_SIZE_WITH_MARGIN && j < FINDER_SIZE_WITH_MARGIN;
|
|
919
|
-
if (isInFinder) continue;
|
|
920
|
-
const cx = j + 0.5;
|
|
921
|
-
const cy = i + 0.5;
|
|
922
|
-
dots.push(
|
|
923
|
-
/* @__PURE__ */ jsx20(
|
|
924
|
-
"rect",
|
|
925
|
-
{
|
|
926
|
-
x: cx - 0.4,
|
|
927
|
-
y: cy - 0.4,
|
|
928
|
-
width: 0.8,
|
|
929
|
-
height: 0.8,
|
|
930
|
-
rx: 0.4,
|
|
931
|
-
fill: "var(--color-walletSelectItemBackground)"
|
|
932
|
-
},
|
|
933
|
-
`${i}-${j}`
|
|
934
|
-
)
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
return dots;
|
|
939
|
-
};
|
|
940
|
-
const renderFinderPattern = ({ position }) => {
|
|
941
|
-
const finderSize = 7 * cellSize;
|
|
942
|
-
const positionStyles = {
|
|
943
|
-
"top-left": { top: 0, left: 0 },
|
|
944
|
-
"top-right": { top: 0, right: 0 },
|
|
945
|
-
"bottom-left": { bottom: 0, left: 0 }
|
|
946
|
-
};
|
|
947
|
-
return /* @__PURE__ */ jsxs8(
|
|
948
|
-
"div",
|
|
949
|
-
{
|
|
950
|
-
className: "absolute z-[4]",
|
|
951
|
-
style: {
|
|
952
|
-
width: `${finderSize}px`,
|
|
953
|
-
height: `${finderSize}px`,
|
|
954
|
-
...positionStyles[position]
|
|
955
|
-
},
|
|
956
|
-
children: [
|
|
957
|
-
/* @__PURE__ */ jsx20(
|
|
958
|
-
"div",
|
|
959
|
-
{
|
|
960
|
-
className: "absolute inset-0",
|
|
961
|
-
style: {
|
|
962
|
-
borderRadius: `${2 * cellSize}px`,
|
|
963
|
-
border: `${cellSize}px solid var(--color-walletSelectItemBackground)`
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
),
|
|
967
|
-
/* @__PURE__ */ jsx20(
|
|
968
|
-
"div",
|
|
969
|
-
{
|
|
970
|
-
className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
971
|
-
style: {
|
|
972
|
-
width: `${3 * cellSize}px`,
|
|
973
|
-
height: `${3 * cellSize}px`,
|
|
974
|
-
borderRadius: `${0.5 * cellSize}px`,
|
|
975
|
-
backgroundColor: "var(--color-walletSelectItemBackground)"
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
)
|
|
979
|
-
]
|
|
980
|
-
}
|
|
981
|
-
);
|
|
982
|
-
};
|
|
983
|
-
const renderArenaLogo = () => {
|
|
984
|
-
const logoStart = Math.ceil(QR_GRID_SIZE / 2 - ARENA_GRID_SIZE / 2) * cellSize;
|
|
985
|
-
return /* @__PURE__ */ jsx20(
|
|
986
|
-
"div",
|
|
987
|
-
{
|
|
988
|
-
className: "absolute z-[4] flex items-center justify-center box-border",
|
|
989
|
-
style: {
|
|
990
|
-
width: `${arenaSize}px`,
|
|
991
|
-
height: `${arenaSize}px`,
|
|
992
|
-
left: `${logoStart}px`,
|
|
993
|
-
top: `${logoStart}px`,
|
|
994
|
-
borderRadius: `${cellSize}px`,
|
|
995
|
-
padding: `${cellSize / 2}px`
|
|
996
|
-
},
|
|
997
|
-
children: /* @__PURE__ */ jsx20(
|
|
998
|
-
"img",
|
|
999
|
-
{
|
|
1000
|
-
src: logoBackground,
|
|
1001
|
-
alt: "QR Code Logo",
|
|
1002
|
-
className: "h-full w-full object-cover",
|
|
1003
|
-
style: {
|
|
1004
|
-
borderRadius: `${cellSize}px`
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
)
|
|
1008
|
-
}
|
|
1009
|
-
);
|
|
1010
|
-
};
|
|
1011
|
-
return /* @__PURE__ */ jsxs8(
|
|
1012
|
-
"div",
|
|
1013
|
-
{
|
|
1014
|
-
className: "relative overflow-hidden flex items-center justify-center",
|
|
1015
|
-
style: {
|
|
1016
|
-
width: size,
|
|
1017
|
-
height: size,
|
|
1018
|
-
borderRadius: `${2 * cellSize}px`
|
|
1019
|
-
},
|
|
1020
|
-
children: [
|
|
1021
|
-
/* @__PURE__ */ jsx20(
|
|
1022
|
-
"svg",
|
|
1023
|
-
{
|
|
1024
|
-
className: "absolute inset-0 z-[3]",
|
|
1025
|
-
width: size,
|
|
1026
|
-
height: size,
|
|
1027
|
-
viewBox: `0 0 ${QR_GRID_SIZE} ${QR_GRID_SIZE}`,
|
|
1028
|
-
children: generateSkeletonDots()
|
|
1029
|
-
}
|
|
1030
|
-
),
|
|
1031
|
-
/* @__PURE__ */ jsx20(
|
|
1032
|
-
"div",
|
|
1033
|
-
{
|
|
1034
|
-
className: "absolute inset-0 z-[100]",
|
|
1035
|
-
style: {
|
|
1036
|
-
background: "linear-gradient(90deg, transparent 50%, var(--color-walletSelectItemBackgroundHover), transparent)",
|
|
1037
|
-
backgroundSize: "200% 100%",
|
|
1038
|
-
transform: "scale(1.5) rotate(45deg)",
|
|
1039
|
-
animation: "shimmer 1000ms linear infinite both"
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
),
|
|
1043
|
-
renderFinderPattern({ position: "top-left" }),
|
|
1044
|
-
renderFinderPattern({ position: "top-right" }),
|
|
1045
|
-
renderFinderPattern({ position: "bottom-left" }),
|
|
1046
|
-
logoBackground && renderArenaLogo()
|
|
1047
|
-
]
|
|
1048
|
-
}
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
|
-
return /* @__PURE__ */ jsx20(Cuer, { arena: logoBackground, value: uri });
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
// src/components/ConnectButton/index.tsx
|
|
1055
|
-
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1056
|
-
var transitionClassName = "transition-transform transition-[125] hover:scale-[1.03] transition-ease";
|
|
1057
|
-
var ConnectButton = ({
|
|
1058
|
-
className,
|
|
1059
|
-
label = "Connect Wallet",
|
|
1060
|
-
accountStatus = "full",
|
|
1061
|
-
chainStatus = "full",
|
|
1062
|
-
showBalance = true
|
|
1063
|
-
}) => {
|
|
1064
|
-
const {
|
|
1065
|
-
isConnected,
|
|
1066
|
-
isDisconnected,
|
|
1067
|
-
displayAddress,
|
|
1068
|
-
balance,
|
|
1069
|
-
openConnectModal,
|
|
1070
|
-
openAccountModal,
|
|
1071
|
-
openChainModal,
|
|
1072
|
-
chainIconUrl,
|
|
1073
|
-
chainName,
|
|
1074
|
-
currentChain,
|
|
1075
|
-
activeConnector
|
|
1076
|
-
} = useLunoWallet();
|
|
1077
|
-
const { width: windowWidth } = useWindowSize();
|
|
1078
|
-
const isLargeWindow = windowWidth && windowWidth > 768;
|
|
1079
|
-
if (isDisconnected || !isConnected || !activeConnector) {
|
|
1080
|
-
return /* @__PURE__ */ jsx21(
|
|
1081
|
-
"button",
|
|
1082
|
-
{
|
|
1083
|
-
type: "button",
|
|
1084
|
-
onClick: () => openConnectModal?.(),
|
|
1085
|
-
className: cs(
|
|
1086
|
-
"cursor-pointer font-semibold inline-flex items-center justify-center focus:outline-none",
|
|
1087
|
-
"text-connectButtonText bg-connectButtonBackground shadow-button active:scale-[0.95]",
|
|
1088
|
-
"rounded-connectButton",
|
|
1089
|
-
transitionClassName,
|
|
1090
|
-
"px-3.5 text-base leading-base min-h-[40px]",
|
|
1091
|
-
className
|
|
1092
|
-
),
|
|
1093
|
-
children: label
|
|
1094
|
-
}
|
|
1095
|
-
);
|
|
1096
|
-
}
|
|
1097
|
-
return /* @__PURE__ */ jsxs9("div", { className: cs("text-modalText flex items-stretch bg-transparent font-semibold text-base leading-base gap-3", className), children: [
|
|
1098
|
-
chainStatus !== "none" && /* @__PURE__ */ jsxs9(
|
|
1099
|
-
"button",
|
|
1100
|
-
{
|
|
1101
|
-
type: "button",
|
|
1102
|
-
onClick: () => openChainModal?.(),
|
|
1103
|
-
className: cs(
|
|
1104
|
-
"flex items-center rounded-currentNetworkButton cursor-pointer",
|
|
1105
|
-
"bg-currentNetworkButtonBackground shadow-button",
|
|
1106
|
-
"py-2 px-2.5 gap-1.5",
|
|
1107
|
-
transitionClassName
|
|
1108
|
-
),
|
|
1109
|
-
"aria-label": "Switch chain",
|
|
1110
|
-
children: [
|
|
1111
|
-
chainStatus === "full" || chainStatus === "icon" ? /* @__PURE__ */ jsx21(ChainIcon, { chainIconUrl, chainName, className: "w-[24px] h-[24px]" }) : null,
|
|
1112
|
-
(chainStatus === "full" || chainStatus === "name") && isLargeWindow && /* @__PURE__ */ jsx21("span", { children: currentChain?.name || "Unknown Chain" })
|
|
1113
|
-
]
|
|
1114
|
-
}
|
|
1115
|
-
),
|
|
1116
|
-
/* @__PURE__ */ jsxs9(
|
|
1117
|
-
"button",
|
|
1118
|
-
{
|
|
1119
|
-
type: "button",
|
|
1120
|
-
onClick: () => openAccountModal?.(),
|
|
1121
|
-
className: cs(
|
|
1122
|
-
"flex items-center cursor-pointer rounded-connectButton bg-connectButtonBackground shadow-button",
|
|
1123
|
-
transitionClassName
|
|
1124
|
-
),
|
|
1125
|
-
"aria-label": "Open account modal",
|
|
1126
|
-
children: [
|
|
1127
|
-
showBalance && isLargeWindow && /* @__PURE__ */ jsx21("div", { className: "p-2 pl-3", children: balance === void 0 ? /* @__PURE__ */ jsx21("div", { className: "animate-pulse rounded w-[80px] h-[20px] bg-accountActionItemBackgroundHover" }) : /* @__PURE__ */ jsxs9("span", { className: "", children: [
|
|
1128
|
-
balance?.formattedTransferable || balance?.formattedTotal || 0,
|
|
1129
|
-
" ",
|
|
1130
|
-
currentChain?.nativeCurrency?.symbol || ""
|
|
1131
|
-
] }) }),
|
|
1132
|
-
/* @__PURE__ */ jsxs9("div", { className: cs(
|
|
1133
|
-
"flex items-center bg-connectButtonInnerBackground border-2 border-connectButtonBackground rounded-connectButton gap-1.5 max-h-[40px]",
|
|
1134
|
-
showBalance && isLargeWindow ? "bg-connectButtonInnerBackground py-1.5 px-2" : "bg-connectButtonBackground py-2 px-2.5"
|
|
1135
|
-
), children: [
|
|
1136
|
-
accountStatus === "full" && /* @__PURE__ */ jsx21("span", { className: "w-[24px] h-[24px]", children: /* @__PURE__ */ jsx21("img", { src: activeConnector.icon, alt: "luno" }) }),
|
|
1137
|
-
/* @__PURE__ */ jsx21(
|
|
1138
|
-
"span",
|
|
1139
|
-
{
|
|
1140
|
-
"aria-label": "Wallet icon placeholder",
|
|
1141
|
-
className: "",
|
|
1142
|
-
children: displayAddress
|
|
1143
|
-
}
|
|
1144
|
-
)
|
|
1145
|
-
] })
|
|
1146
|
-
]
|
|
1147
|
-
}
|
|
1148
|
-
)
|
|
1149
|
-
] });
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
// src/components/SpiralAnimation/index.tsx
|
|
1153
|
-
import { useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
1154
|
-
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1155
|
-
var SpiralAnimation = ({
|
|
1156
|
-
size = 160,
|
|
1157
|
-
dotCount = 300,
|
|
1158
|
-
duration = 3,
|
|
1159
|
-
className = ""
|
|
1160
|
-
}) => {
|
|
1161
|
-
const containerRef = useRef3(null);
|
|
1162
|
-
useEffect3(() => {
|
|
1163
|
-
if (!containerRef.current) return;
|
|
1164
|
-
const DOT_RADIUS = 1;
|
|
1165
|
-
const MARGIN = 2;
|
|
1166
|
-
const GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
|
|
1167
|
-
const CENTER = size / 2;
|
|
1168
|
-
const MAX_RADIUS = CENTER - MARGIN - DOT_RADIUS;
|
|
1169
|
-
const svgNS = "http://www.w3.org/2000/svg";
|
|
1170
|
-
containerRef.current.innerHTML = "";
|
|
1171
|
-
const svg = document.createElementNS(svgNS, "svg");
|
|
1172
|
-
svg.setAttribute("width", size.toString());
|
|
1173
|
-
svg.setAttribute("height", size.toString());
|
|
1174
|
-
svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
|
|
1175
|
-
svg.style.display = "block";
|
|
1176
|
-
containerRef.current.appendChild(svg);
|
|
1177
|
-
for (let i = 0; i < dotCount; i++) {
|
|
1178
|
-
const idx = i + 0.5;
|
|
1179
|
-
const frac = idx / dotCount;
|
|
1180
|
-
const r = Math.sqrt(frac) * MAX_RADIUS;
|
|
1181
|
-
const theta = idx * GOLDEN_ANGLE;
|
|
1182
|
-
const x = CENTER + r * Math.cos(theta);
|
|
1183
|
-
const y = CENTER + r * Math.sin(theta);
|
|
1184
|
-
const circle = document.createElementNS(svgNS, "circle");
|
|
1185
|
-
circle.setAttribute("cx", x.toString());
|
|
1186
|
-
circle.setAttribute("cy", y.toString());
|
|
1187
|
-
circle.setAttribute("r", DOT_RADIUS.toString());
|
|
1188
|
-
circle.setAttribute("fill", "currentColor");
|
|
1189
|
-
circle.setAttribute("opacity", "0.6");
|
|
1190
|
-
svg.appendChild(circle);
|
|
1191
|
-
const animR = document.createElementNS(svgNS, "animate");
|
|
1192
|
-
animR.setAttribute("attributeName", "r");
|
|
1193
|
-
animR.setAttribute(
|
|
1194
|
-
"values",
|
|
1195
|
-
`${DOT_RADIUS * 0.5};${DOT_RADIUS * 1.8};${DOT_RADIUS * 0.5}`
|
|
1196
|
-
);
|
|
1197
|
-
animR.setAttribute("dur", `${duration}s`);
|
|
1198
|
-
animR.setAttribute("begin", `${frac * duration}s`);
|
|
1199
|
-
animR.setAttribute("repeatCount", "indefinite");
|
|
1200
|
-
animR.setAttribute("calcMode", "spline");
|
|
1201
|
-
animR.setAttribute("keySplines", "0.4 0 0.6 1;0.4 0 0.6 1");
|
|
1202
|
-
circle.appendChild(animR);
|
|
1203
|
-
const animO = document.createElementNS(svgNS, "animate");
|
|
1204
|
-
animO.setAttribute("attributeName", "opacity");
|
|
1205
|
-
animO.setAttribute("values", "0.2;1;0.2");
|
|
1206
|
-
animO.setAttribute("dur", `${duration}s`);
|
|
1207
|
-
animO.setAttribute("begin", `${frac * duration}s`);
|
|
1208
|
-
animO.setAttribute("repeatCount", "indefinite");
|
|
1209
|
-
animO.setAttribute("calcMode", "spline");
|
|
1210
|
-
animO.setAttribute("keySplines", "0.4 0 0.6 1;0.4 0 0.6 1");
|
|
1211
|
-
circle.appendChild(animO);
|
|
1212
|
-
}
|
|
1213
|
-
}, [size, dotCount, duration]);
|
|
1214
|
-
return /* @__PURE__ */ jsx22(
|
|
1215
|
-
"div",
|
|
1216
|
-
{
|
|
1217
|
-
ref: containerRef,
|
|
1218
|
-
className: cs("text-accentColor inline-flex w-full h-full justify-center align-center", className)
|
|
1219
|
-
}
|
|
1220
|
-
);
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
// src/components/ConnectModal/WalletView.tsx
|
|
1224
|
-
import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1225
|
-
var WalletView = React10.memo(({ selectedConnector, onConnect, qrCode, isWide, connectState }) => {
|
|
1226
|
-
const showQRCode = selectedConnector?.hasConnectionUri();
|
|
1227
|
-
return /* @__PURE__ */ jsxs10("div", { className: cs(
|
|
1228
|
-
"flex flex-col items-center",
|
|
1229
|
-
isWide ? "w-[400px] p-4 min-h-[472px]" : "justify-center w-full min-h-[400px]"
|
|
1230
|
-
), children: [
|
|
1231
|
-
isWide && /* @__PURE__ */ jsx23("div", { className: "w-full", children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1232
|
-
/* @__PURE__ */ jsx23("div", {}),
|
|
1233
|
-
/* @__PURE__ */ jsx23(
|
|
1234
|
-
DialogClose,
|
|
1235
|
-
{
|
|
1236
|
-
className: "z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",
|
|
1237
|
-
children: /* @__PURE__ */ jsx23(Close_default, {})
|
|
1238
|
-
}
|
|
1239
|
-
)
|
|
1240
|
-
] }) }),
|
|
1241
|
-
/* @__PURE__ */ jsx23("div", { className: cs(
|
|
1242
|
-
"flex items-center py-12 flex-col grow justify-start",
|
|
1243
|
-
selectedConnector && showQRCode ? "max-w-[220px]" : "max-w-[360px]"
|
|
1244
|
-
), children: selectedConnector ? showQRCode ? /* @__PURE__ */ jsxs10("div", { className: "flex flex-col items-center gap-4", children: [
|
|
1245
|
-
/* @__PURE__ */ jsx23(QRCode, { size: 220, logoBackground: selectedConnector.icon, uri: qrCode }),
|
|
1246
|
-
/* @__PURE__ */ jsxs10("div", { className: "text-secondaryFont leading-secondary font-[500] text-center", children: [
|
|
1247
|
-
"Scan the QR Code with ",
|
|
1248
|
-
selectedConnector.id === "nova" ? "the Nova app" : "your phone"
|
|
1249
|
-
] }),
|
|
1250
|
-
selectedConnector.links?.browserExtension ? /* @__PURE__ */ jsxs10(
|
|
1251
|
-
"p",
|
|
1252
|
-
{
|
|
1253
|
-
onClick: () => window.open(selectedConnector.links.browserExtension),
|
|
1254
|
-
className: "cursor-pointer pt-[16px] text-base leading-base text-accentColor font-bold text-center",
|
|
1255
|
-
children: [
|
|
1256
|
-
"Don\u2018t have ",
|
|
1257
|
-
selectedConnector.name,
|
|
1258
|
-
"?"
|
|
1259
|
-
]
|
|
1260
|
-
}
|
|
1261
|
-
) : qrCode ? /* @__PURE__ */ jsx23(Copy, { className: "text-sm leading-sm text-accentColor", copyText: qrCode, label: "Copy Link" }) : null
|
|
1262
|
-
] }) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
1263
|
-
/* @__PURE__ */ jsx23("div", { className: "w-[102px] h-[102px] pb-[16px]", children: /* @__PURE__ */ jsx23("img", { src: selectedConnector.icon, className: "w-full h-full", alt: "" }) }),
|
|
1264
|
-
/* @__PURE__ */ jsxs10("p", { className: "pb-[10px] text-primary leading-primary text-modalFont font-[600]", children: [
|
|
1265
|
-
"Opening ",
|
|
1266
|
-
selectedConnector.name,
|
|
1267
|
-
"..."
|
|
1268
|
-
] }),
|
|
1269
|
-
/* @__PURE__ */ jsx23("p", { className: "pb-[10px] text-secondaryFont text-secondary leading-secondary font-[500] text-center", children: "Confirm connection in the extension" }),
|
|
1270
|
-
connectState.isConnecting && /* @__PURE__ */ jsx23(Loading_default, { className: "w-[24px] h-[24px] text-secondaryFont animate-[spin_3s_linear_infinite]" }),
|
|
1271
|
-
!selectedConnector.isInstalled() && selectedConnector.links.browserExtension && /* @__PURE__ */ jsxs10(
|
|
1272
|
-
"p",
|
|
1273
|
-
{
|
|
1274
|
-
onClick: () => window.open(selectedConnector.links.browserExtension),
|
|
1275
|
-
className: "cursor-pointer pt-[16px] text-base leading-base text-accentColor font-bold text-center",
|
|
1276
|
-
children: [
|
|
1277
|
-
"Don\u2018t have ",
|
|
1278
|
-
selectedConnector.name,
|
|
1279
|
-
"?"
|
|
1280
|
-
]
|
|
1281
|
-
}
|
|
1282
|
-
),
|
|
1283
|
-
!connectState.isConnecting && connectState.isError && selectedConnector.isInstalled() && /* @__PURE__ */ jsx23(
|
|
1284
|
-
"button",
|
|
1285
|
-
{
|
|
1286
|
-
className: cs(
|
|
1287
|
-
"rounded-connectButton focus:outline-none py-[4px] px-[12px] cursor-pointer font-[600] text-primaryFont bg-connectButtonBackground shadow-connectButton active:scale-[0.95]",
|
|
1288
|
-
transitionClassName
|
|
1289
|
-
),
|
|
1290
|
-
onClick: () => onConnect(selectedConnector),
|
|
1291
|
-
children: "Retry"
|
|
1292
|
-
}
|
|
1293
|
-
)
|
|
1294
|
-
] }) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
1295
|
-
/* @__PURE__ */ jsx23("div", { className: "w-[160px] h-[160px] mb-4", children: /* @__PURE__ */ jsx23(SpiralAnimation, {}) }),
|
|
1296
|
-
/* @__PURE__ */ jsx23("p", { className: "cursor-pointer pb-[16px] text-base leading-base text-accentColor font-bold text-center", children: "New to wallets?" }),
|
|
1297
|
-
/* @__PURE__ */ jsx23("p", { className: "text-modalTextSecondary text-sm leading-sm font-medium text-center", children: "Your gateway to the decentralized world Connect a wallet to get started" })
|
|
1298
|
-
] }) }),
|
|
1299
|
-
/* @__PURE__ */ jsx23("div", {})
|
|
1300
|
-
] });
|
|
1301
|
-
});
|
|
1302
|
-
|
|
1303
|
-
// src/components/ConnectModal/ConnectOptions.tsx
|
|
1304
|
-
import React11 from "react";
|
|
1305
|
-
import { useConnectors, isMobileDevice } from "@luno-kit/react";
|
|
1306
|
-
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1307
|
-
var ConnectOptions = React11.memo(({ onConnect }) => {
|
|
1308
|
-
const connectors = useConnectors();
|
|
1309
|
-
if (isMobileDevice()) {
|
|
1310
|
-
const filteredConnectors = connectors.filter((i) => i.links.deepLink);
|
|
1311
|
-
return /* @__PURE__ */ jsx24("div", { className: "flex flex-col items-start gap-1 w-full", children: filteredConnectors.map((i) => /* @__PURE__ */ jsx24(ConnectorItem, { connector: i, onConnect: () => onConnect(i) }, `${i.id}-${i.name}`)) });
|
|
1312
|
-
}
|
|
1313
|
-
const installedConnectors = connectors.filter((c) => c.isInstalled());
|
|
1314
|
-
const moreConnectors = connectors.filter((c) => !c.isInstalled());
|
|
1315
|
-
return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-start gap-4 w-full", children: [
|
|
1316
|
-
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-start gap-3 w-full", children: [
|
|
1317
|
-
/* @__PURE__ */ jsx24("div", { className: "text-base text-modalText font-semibold leading-base", children: "Installed" }),
|
|
1318
|
-
/* @__PURE__ */ jsx24("div", { className: "flex flex-col items-start gap-1.5 w-full", children: installedConnectors.map((i) => /* @__PURE__ */ jsx24(ConnectorItem, { connector: i, onConnect: () => onConnect(i) }, i.id)) })
|
|
1319
|
-
] }),
|
|
1320
|
-
moreConnectors.length > 0 && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-start gap-3 w-full", children: [
|
|
1321
|
-
/* @__PURE__ */ jsx24("div", { className: "text-base text-modalText font-semibold leading-base", children: "More" }),
|
|
1322
|
-
/* @__PURE__ */ jsx24("div", { className: "flex flex-col items-start gap-1 w-full", children: moreConnectors.map((i) => /* @__PURE__ */ jsx24(ConnectorItem, { connector: i, onConnect: () => onConnect(i) }, i.id)) })
|
|
1323
|
-
] })
|
|
1324
|
-
] });
|
|
1325
|
-
});
|
|
1326
|
-
var ConnectorItem = React11.memo(({ connector, onConnect }) => {
|
|
1327
|
-
return /* @__PURE__ */ jsxs11(
|
|
1328
|
-
"button",
|
|
1329
|
-
{
|
|
1330
|
-
onClick: onConnect,
|
|
1331
|
-
className: cs(
|
|
1332
|
-
"cursor-pointer bg-walletSelectItemBackground p-2 w-full flex items-center gap-3 rounded-walletSelectItem border-none",
|
|
1333
|
-
"hover:bg-walletSelectItemBackgroundHover transition-transform active:scale-[0.95]",
|
|
1334
|
-
"text-left"
|
|
1335
|
-
),
|
|
1336
|
-
children: [
|
|
1337
|
-
/* @__PURE__ */ jsx24("div", { className: "w-[24px] h-[24px]", children: /* @__PURE__ */ jsx24(
|
|
1338
|
-
"img",
|
|
1339
|
-
{
|
|
1340
|
-
src: connector.icon,
|
|
1341
|
-
alt: connector.name,
|
|
1342
|
-
className: "w-full h-full"
|
|
1343
|
-
}
|
|
1344
|
-
) }),
|
|
1345
|
-
/* @__PURE__ */ jsx24("span", { className: "font-semibold leading-base text-base text-modalText", children: connector.name })
|
|
1346
|
-
]
|
|
1347
|
-
}
|
|
1348
|
-
);
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
// src/components/ConnectModal/index.tsx
|
|
1352
|
-
import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1353
|
-
var ConnectModal = ({
|
|
1354
|
-
size = "wide"
|
|
1355
|
-
}) => {
|
|
1356
|
-
const { isOpen, close } = useConnectModal();
|
|
1357
|
-
const { connectAsync, reset: resetConnect, isPending: isConnecting, isError: connectError } = useConnect();
|
|
1358
|
-
const [selectedConnector, setSelectedConnector] = useState7(null);
|
|
1359
|
-
const [qrCode, setQrCode] = useState7();
|
|
1360
|
-
const { width: windowWidth } = useWindowSize();
|
|
1361
|
-
const isLargeWindow = windowWidth && windowWidth > 768;
|
|
1362
|
-
const isWide = !!(size === "wide" && isLargeWindow);
|
|
1363
|
-
const {
|
|
1364
|
-
containerRef,
|
|
1365
|
-
currentViewRef,
|
|
1366
|
-
resetView,
|
|
1367
|
-
handleViewChange,
|
|
1368
|
-
currentView
|
|
1369
|
-
} = useAnimatedViews({ initialView: "Connect Wallet" /* connectOptions */ });
|
|
1370
|
-
const onQrCode = async (connector) => {
|
|
1371
|
-
const uri = await connector.getConnectionUri();
|
|
1372
|
-
setQrCode(uri);
|
|
1373
|
-
};
|
|
1374
|
-
const handleConnect = async (connector) => {
|
|
1375
|
-
if (isMobileDevice2() && connector.links.deepLink) {
|
|
1376
|
-
try {
|
|
1377
|
-
await connectAsync({ connectorId: connector.id });
|
|
1378
|
-
_onOpenChange(false);
|
|
1379
|
-
return;
|
|
1380
|
-
} catch (error) {
|
|
1381
|
-
window.location.href = `${connector.links.deepLink}?url=${window.location.href}`;
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
!isWide && handleViewChange("walletView" /* walletView */);
|
|
1386
|
-
setSelectedConnector(connector);
|
|
1387
|
-
setQrCode(void 0);
|
|
1388
|
-
if (connector.hasConnectionUri()) {
|
|
1389
|
-
onQrCode(connector);
|
|
1390
|
-
}
|
|
1391
|
-
await connectAsync({ connectorId: connector.id });
|
|
1392
|
-
_onOpenChange(false);
|
|
1393
|
-
};
|
|
1394
|
-
const _onOpenChange = (open) => {
|
|
1395
|
-
!open && close();
|
|
1396
|
-
resetConnect();
|
|
1397
|
-
resetView();
|
|
1398
|
-
setSelectedConnector(null);
|
|
1399
|
-
setQrCode(void 0);
|
|
1400
|
-
};
|
|
1401
|
-
const viewComponents = useMemo5(() => {
|
|
1402
|
-
return {
|
|
1403
|
-
["Connect Wallet" /* connectOptions */]: /* @__PURE__ */ jsx25(ConnectOptions, { onConnect: handleConnect }),
|
|
1404
|
-
["walletView" /* walletView */]: /* @__PURE__ */ jsx25(
|
|
1405
|
-
WalletView,
|
|
1406
|
-
{
|
|
1407
|
-
connectState: { isConnecting, isError: connectError },
|
|
1408
|
-
isWide,
|
|
1409
|
-
selectedConnector,
|
|
1410
|
-
qrCode,
|
|
1411
|
-
onConnect: handleConnect
|
|
1412
|
-
}
|
|
1413
|
-
)
|
|
1414
|
-
};
|
|
1415
|
-
}, [isWide, selectedConnector, qrCode, handleConnect, isConnecting, connectError]);
|
|
1416
|
-
useEffect4(() => {
|
|
1417
|
-
if (isWide && currentView === "walletView" /* walletView */) {
|
|
1418
|
-
handleViewChange("Connect Wallet" /* connectOptions */);
|
|
1419
|
-
}
|
|
1420
|
-
}, [isWide, currentView]);
|
|
1421
|
-
useEffect4(() => {
|
|
1422
|
-
if (isWide && currentView === "walletView" /* walletView */) {
|
|
1423
|
-
handleViewChange("Connect Wallet" /* connectOptions */);
|
|
1424
|
-
}
|
|
1425
|
-
}, [isWide, currentView]);
|
|
1426
|
-
useEffect4(() => {
|
|
1427
|
-
if (isWide && currentView === "walletView" /* walletView */) {
|
|
1428
|
-
handleViewChange("Connect Wallet" /* connectOptions */);
|
|
1429
|
-
}
|
|
1430
|
-
}, [isWide, currentView]);
|
|
1431
|
-
return /* @__PURE__ */ jsx25(Dialog, { open: isOpen, onOpenChange: _onOpenChange, children: /* @__PURE__ */ jsxs12("div", { className: cs("flex items-stretch justify-between w-full md:max-h-[504px] md:max-w-[724px]"), children: [
|
|
1432
|
-
/* @__PURE__ */ jsxs12("div", { className: cs(
|
|
1433
|
-
"flex flex-col items-start py-4 px-5 md:min-w-[360px] w-full md:w-auto",
|
|
1434
|
-
isWide && "border-r-[1px] border-r-solid border-r-separatorLine"
|
|
1435
|
-
), children: [
|
|
1436
|
-
/* @__PURE__ */ jsxs12("div", { className: cs("flex items-center justify-between w-full", !isWide && "pb-4"), children: [
|
|
1437
|
-
currentView === "Connect Wallet" /* connectOptions */ ? /* @__PURE__ */ jsx25(DialogTitle, { className: cs("text-lg leading-lg text-modalText font-bold", isWide && "pb-6"), children: "Connect Wallet" }) : /* @__PURE__ */ jsxs12(Fragment6, { children: [
|
|
1438
|
-
/* @__PURE__ */ jsx25(
|
|
1439
|
-
"button",
|
|
1440
|
-
{
|
|
1441
|
-
className: "flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",
|
|
1442
|
-
onClick: () => handleViewChange("Connect Wallet" /* connectOptions */),
|
|
1443
|
-
"aria-label": "Back",
|
|
1444
|
-
children: /* @__PURE__ */ jsx25(Back_default, {})
|
|
1445
|
-
}
|
|
1446
|
-
),
|
|
1447
|
-
/* @__PURE__ */ jsx25(
|
|
1448
|
-
DialogTitle,
|
|
1449
|
-
{
|
|
1450
|
-
className: cs(
|
|
1451
|
-
"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",
|
|
1452
|
-
!selectedConnector?.hasConnectionUri() && "sr-only"
|
|
1453
|
-
),
|
|
1454
|
-
children: selectedConnector?.hasConnectionUri() && "Scan by your phone"
|
|
1455
|
-
}
|
|
1456
|
-
)
|
|
1457
|
-
] }),
|
|
1458
|
-
!isWide && /* @__PURE__ */ jsx25(
|
|
1459
|
-
DialogClose,
|
|
1460
|
-
{
|
|
1461
|
-
className: "z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",
|
|
1462
|
-
children: /* @__PURE__ */ jsx25(Close_default, {})
|
|
1463
|
-
}
|
|
1464
|
-
)
|
|
1465
|
-
] }),
|
|
1466
|
-
/* @__PURE__ */ jsx25(
|
|
1467
|
-
"div",
|
|
1468
|
-
{
|
|
1469
|
-
ref: containerRef,
|
|
1470
|
-
className: "relative overflow-hidden w-full",
|
|
1471
|
-
children: /* @__PURE__ */ jsx25("div", { ref: currentViewRef, children: viewComponents[currentView] })
|
|
1472
|
-
}
|
|
1473
|
-
)
|
|
1474
|
-
] }),
|
|
1475
|
-
isWide && /* @__PURE__ */ jsx25(
|
|
1476
|
-
WalletView,
|
|
1477
|
-
{
|
|
1478
|
-
connectState: { isConnecting, isError: connectError },
|
|
1479
|
-
isWide,
|
|
1480
|
-
selectedConnector,
|
|
1481
|
-
qrCode,
|
|
1482
|
-
onConnect: handleConnect
|
|
1483
|
-
}
|
|
1484
|
-
)
|
|
1485
|
-
] }) });
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
|
-
// src/providers/LunoKitProvider.tsx
|
|
1489
|
-
import { useState as useState9 } from "react";
|
|
1490
|
-
import { LunoProvider } from "@luno-kit/react";
|
|
1491
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
1492
|
-
|
|
1493
|
-
// src/theme/context.tsx
|
|
1494
|
-
import { createContext as createContext2, useState as useState8, useContext as useContext2, useMemo as useMemo6, useCallback as useCallback6, useEffect as useEffect6 } from "react";
|
|
1495
|
-
|
|
1496
|
-
// src/hooks/useCSSVariableInjection.ts
|
|
1497
|
-
import { useEffect as useEffect5 } from "react";
|
|
1498
|
-
var ALL_THEME_VARS = [
|
|
1499
|
-
"--color-accentColor",
|
|
1500
|
-
"--color-walletSelectItemBackground",
|
|
1501
|
-
"--color-walletSelectItemBackgroundHover",
|
|
1502
|
-
"--color-walletSelectItemText",
|
|
1503
|
-
"--color-connectButtonBackground",
|
|
1504
|
-
"--color-connectButtonInnerBackground",
|
|
1505
|
-
"--color-connectButtonText",
|
|
1506
|
-
"--color-accountActionItemBackground",
|
|
1507
|
-
"--color-accountActionItemBackgroundHover",
|
|
1508
|
-
"--color-accountActionItemText",
|
|
1509
|
-
"--color-accountSelectItemBackground",
|
|
1510
|
-
"--color-accountSelectItemBackgroundHover",
|
|
1511
|
-
"--color-accountSelectItemText",
|
|
1512
|
-
"--color-currentNetworkButtonBackground",
|
|
1513
|
-
"--color-currentNetworkButtonText",
|
|
1514
|
-
"--color-networkSelectItemBackground",
|
|
1515
|
-
"--color-networkSelectItemBackgroundHover",
|
|
1516
|
-
"--color-networkSelectItemText",
|
|
1517
|
-
"--color-navigationButtonBackground",
|
|
1518
|
-
"--color-separatorLine",
|
|
1519
|
-
"--color-modalBackground",
|
|
1520
|
-
"--color-modalBackdrop",
|
|
1521
|
-
"--color-modalBorder",
|
|
1522
|
-
"--color-modalText",
|
|
1523
|
-
"--color-modalTextSecondary",
|
|
1524
|
-
"--color-modalControlButtonBackgroundHover",
|
|
1525
|
-
"--color-modalControlButtonText",
|
|
1526
|
-
"--color-success",
|
|
1527
|
-
"--color-successForeground",
|
|
1528
|
-
"--color-warning",
|
|
1529
|
-
"--color-warningForeground",
|
|
1530
|
-
"--color-error",
|
|
1531
|
-
"--color-errorForeground",
|
|
1532
|
-
"--color-info",
|
|
1533
|
-
"--color-infoForeground",
|
|
1534
|
-
"--color-skeleton",
|
|
1535
|
-
"--color-cutLine",
|
|
1536
|
-
"--font-body",
|
|
1537
|
-
"--font-heading",
|
|
1538
|
-
"--font-mono",
|
|
1539
|
-
"--radius-walletSelectItem",
|
|
1540
|
-
"--radius-connectButton",
|
|
1541
|
-
"--radius-modalControlButton",
|
|
1542
|
-
"--radius-accountActionItem",
|
|
1543
|
-
"--radius-accountSelectItem",
|
|
1544
|
-
"--radius-currentNetworkButton",
|
|
1545
|
-
"--radius-networkSelectItem",
|
|
1546
|
-
"--radius-modal",
|
|
1547
|
-
"--radius-modalMobile",
|
|
1548
|
-
"--shadow-button",
|
|
1549
|
-
"--shadow-modal",
|
|
1550
|
-
"--blur-modalOverlay"
|
|
1551
|
-
];
|
|
1552
|
-
var useCSSVariableInjection = (themeInfo, themeMode) => {
|
|
1553
|
-
useEffect5(() => {
|
|
1554
|
-
if (typeof window === "undefined") return;
|
|
1555
|
-
const root = document.documentElement;
|
|
1556
|
-
if (themeInfo.type === "complete" && themeInfo.completeTheme) {
|
|
1557
|
-
Object.entries(themeInfo.completeTheme.colors).forEach(([key, value]) => {
|
|
1558
|
-
if (value) {
|
|
1559
|
-
root.style.setProperty(`--color-${key}`, value);
|
|
1560
|
-
}
|
|
1561
|
-
});
|
|
1562
|
-
Object.entries(themeInfo.completeTheme.fonts).forEach(([key, value]) => {
|
|
1563
|
-
if (value) {
|
|
1564
|
-
root.style.setProperty(`--font-${key}`, value);
|
|
1565
|
-
}
|
|
1566
|
-
});
|
|
1567
|
-
Object.entries(themeInfo.completeTheme.radii).forEach(([key, value]) => {
|
|
1568
|
-
if (value) {
|
|
1569
|
-
root.style.setProperty(`--radius-${key}`, value);
|
|
1570
|
-
}
|
|
1571
|
-
});
|
|
1572
|
-
Object.entries(themeInfo.completeTheme.shadows).forEach(([key, value]) => {
|
|
1573
|
-
if (value) {
|
|
1574
|
-
root.style.setProperty(`--shadow-${key}`, value);
|
|
1575
|
-
}
|
|
1576
|
-
});
|
|
1577
|
-
Object.entries(themeInfo.completeTheme.blurs).forEach(([key, value]) => {
|
|
1578
|
-
if (value) {
|
|
1579
|
-
root.style.setProperty(`--blur-${key}`, value);
|
|
1580
|
-
}
|
|
1581
|
-
});
|
|
1582
|
-
root.removeAttribute("data-theme");
|
|
1583
|
-
} else if (themeInfo.type === "partial" && themeInfo.partialOverrides) {
|
|
1584
|
-
root.setAttribute("data-theme", themeMode);
|
|
1585
|
-
const hasOverrides = Object.keys(themeInfo.partialOverrides).length > 0;
|
|
1586
|
-
if (hasOverrides) {
|
|
1587
|
-
ALL_THEME_VARS.forEach((varName) => {
|
|
1588
|
-
root.style.removeProperty(varName);
|
|
1589
|
-
});
|
|
1590
|
-
if (themeInfo.partialOverrides.colors) {
|
|
1591
|
-
Object.entries(themeInfo.partialOverrides.colors).forEach(([key, value]) => {
|
|
1592
|
-
if (value) {
|
|
1593
|
-
root.style.setProperty(`--color-${key}`, value);
|
|
1594
|
-
}
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
if (themeInfo.partialOverrides.fonts) {
|
|
1598
|
-
Object.entries(themeInfo.partialOverrides.fonts).forEach(([key, value]) => {
|
|
1599
|
-
if (value) {
|
|
1600
|
-
root.style.setProperty(`--font-${key}`, value);
|
|
1601
|
-
}
|
|
1602
|
-
});
|
|
1603
|
-
}
|
|
1604
|
-
if (themeInfo.partialOverrides.radii) {
|
|
1605
|
-
Object.entries(themeInfo.partialOverrides.radii).forEach(([key, value]) => {
|
|
1606
|
-
if (value) {
|
|
1607
|
-
root.style.setProperty(`--radius-${key}`, value);
|
|
1608
|
-
}
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
if (themeInfo.partialOverrides.shadows) {
|
|
1612
|
-
Object.entries(themeInfo.partialOverrides.shadows).forEach(([key, value]) => {
|
|
1613
|
-
if (value) {
|
|
1614
|
-
root.style.setProperty(`--shadow-${key}`, value);
|
|
1615
|
-
}
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
if (themeInfo.partialOverrides.blurs) {
|
|
1619
|
-
Object.entries(themeInfo.partialOverrides.blurs).forEach(([key, value]) => {
|
|
1620
|
-
if (value) {
|
|
1621
|
-
root.style.setProperty(`--blur-${key}`, value);
|
|
1622
|
-
}
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
} else {
|
|
1627
|
-
root.setAttribute("data-theme", themeMode);
|
|
1628
|
-
ALL_THEME_VARS.forEach((varName) => {
|
|
1629
|
-
root.style.removeProperty(varName);
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
}, [themeInfo, themeMode]);
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
// src/theme/context.tsx
|
|
1636
|
-
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1637
|
-
var THEME_STORAGE_KEY = "luno.lastThemePreference";
|
|
1638
|
-
var saveThemePreference = (preference) => {
|
|
1639
|
-
try {
|
|
1640
|
-
localStorage.setItem(THEME_STORAGE_KEY, JSON.stringify(preference));
|
|
1641
|
-
} catch (e) {
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
|
-
var ThemeContext = createContext2(void 0);
|
|
1645
|
-
var isCompleteTheme = (theme) => {
|
|
1646
|
-
return "colors" in theme && "fonts" in theme && "radii" in theme && "shadows" in theme && "blurs" in theme;
|
|
1647
|
-
};
|
|
1648
|
-
var useSystemTheme = () => {
|
|
1649
|
-
const [systemTheme, setSystemTheme] = useState8(() => {
|
|
1650
|
-
if (typeof window === "undefined") return "light";
|
|
1651
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1652
|
-
});
|
|
1653
|
-
useEffect6(() => {
|
|
1654
|
-
if (typeof window === "undefined") return;
|
|
1655
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1656
|
-
const updateTheme = (e) => {
|
|
1657
|
-
setSystemTheme(e.matches ? "dark" : "light");
|
|
1658
|
-
};
|
|
1659
|
-
updateTheme(mediaQuery);
|
|
1660
|
-
mediaQuery.addEventListener("change", updateTheme);
|
|
1661
|
-
return () => mediaQuery.removeEventListener("change", updateTheme);
|
|
1662
|
-
}, []);
|
|
1663
|
-
return systemTheme;
|
|
1664
|
-
};
|
|
1665
|
-
var ThemeProvider = ({
|
|
1666
|
-
children,
|
|
1667
|
-
theme: themeOverrides
|
|
1668
|
-
}) => {
|
|
1669
|
-
const systemTheme = useSystemTheme();
|
|
1670
|
-
const [themeMode, setThemeMode] = useState8(() => {
|
|
1671
|
-
if (typeof window !== "undefined") {
|
|
1672
|
-
try {
|
|
1673
|
-
const saved = localStorage.getItem(THEME_STORAGE_KEY);
|
|
1674
|
-
if (saved) {
|
|
1675
|
-
const preference = JSON.parse(saved);
|
|
1676
|
-
if (preference?.isAuto) {
|
|
1677
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1678
|
-
} else if (preference?.preferredTheme) {
|
|
1679
|
-
return preference.preferredTheme;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
} catch (e) {
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
if (!themeOverrides || isCompleteTheme(themeOverrides)) {
|
|
1686
|
-
return "light";
|
|
1687
|
-
}
|
|
1688
|
-
const overrides = themeOverrides;
|
|
1689
|
-
return overrides.defaultMode || "light";
|
|
1690
|
-
});
|
|
1691
|
-
const [isAutoMode, setIsAutoMode] = useState8(() => {
|
|
1692
|
-
if (typeof window !== "undefined") {
|
|
1693
|
-
try {
|
|
1694
|
-
const saved = localStorage.getItem(THEME_STORAGE_KEY);
|
|
1695
|
-
if (saved) {
|
|
1696
|
-
const preference = JSON.parse(saved);
|
|
1697
|
-
return preference?.isAuto ?? false;
|
|
1698
|
-
}
|
|
1699
|
-
} catch (e) {
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
if (!themeOverrides || isCompleteTheme(themeOverrides)) {
|
|
1703
|
-
return false;
|
|
1704
|
-
}
|
|
1705
|
-
const overrides = themeOverrides;
|
|
1706
|
-
return overrides.autoMode ?? false;
|
|
1707
|
-
});
|
|
1708
|
-
const themeInfo = useMemo6(() => {
|
|
1709
|
-
if (!themeOverrides) {
|
|
1710
|
-
return { type: "default", completeTheme: null, partialOverrides: null };
|
|
1711
|
-
}
|
|
1712
|
-
if (isCompleteTheme(themeOverrides)) {
|
|
1713
|
-
return { type: "complete", completeTheme: themeOverrides, partialOverrides: null };
|
|
1714
|
-
}
|
|
1715
|
-
const overrides = themeOverrides;
|
|
1716
|
-
if (overrides.theme) {
|
|
1717
|
-
return { type: "complete", completeTheme: overrides.theme, partialOverrides: null };
|
|
1718
|
-
}
|
|
1719
|
-
let partialOverrides = null;
|
|
1720
|
-
if (themeMode === "light" && overrides.light) {
|
|
1721
|
-
partialOverrides = overrides.light;
|
|
1722
|
-
} else if (themeMode === "dark" && overrides.dark) {
|
|
1723
|
-
partialOverrides = overrides.dark;
|
|
1724
|
-
} else {
|
|
1725
|
-
partialOverrides = { ...overrides };
|
|
1726
|
-
}
|
|
1727
|
-
return { type: "partial", completeTheme: null, partialOverrides };
|
|
1728
|
-
}, [themeMode, themeOverrides]);
|
|
1729
|
-
const currentTheme = useMemo6(() => {
|
|
1730
|
-
return themeInfo.type === "complete" ? themeInfo.completeTheme : null;
|
|
1731
|
-
}, [themeInfo]);
|
|
1732
|
-
useCSSVariableInjection(themeInfo, themeMode);
|
|
1733
|
-
const setThemeChoice = useCallback6((choice) => {
|
|
1734
|
-
const isAuto = choice === "auto";
|
|
1735
|
-
setIsAutoMode(isAuto);
|
|
1736
|
-
if (isAuto) {
|
|
1737
|
-
setThemeMode(systemTheme || "light");
|
|
1738
|
-
} else {
|
|
1739
|
-
setThemeMode(choice);
|
|
1740
|
-
}
|
|
1741
|
-
const preference = {
|
|
1742
|
-
isAuto,
|
|
1743
|
-
...isAuto ? {} : { preferredTheme: choice }
|
|
1744
|
-
};
|
|
1745
|
-
saveThemePreference(preference);
|
|
1746
|
-
}, [systemTheme]);
|
|
1747
|
-
useEffect6(() => {
|
|
1748
|
-
if (isAutoMode) {
|
|
1749
|
-
setThemeMode(systemTheme || "light");
|
|
1750
|
-
}
|
|
1751
|
-
}, [systemTheme, isAutoMode]);
|
|
1752
|
-
const contextValue = useMemo6(() => ({
|
|
1753
|
-
themeMode,
|
|
1754
|
-
setThemeChoice,
|
|
1755
|
-
currentTheme
|
|
1756
|
-
}), [themeMode, setThemeChoice, currentTheme]);
|
|
1757
|
-
return /* @__PURE__ */ jsx26(ThemeContext.Provider, { value: contextValue, children });
|
|
1758
|
-
};
|
|
1759
|
-
var useLunoTheme = () => {
|
|
1760
|
-
const context = useContext2(ThemeContext);
|
|
1761
|
-
if (!context) {
|
|
1762
|
-
throw new Error("useLunoTheme must be used within a ThemeProvider (which is part of LunoKitProvider)");
|
|
1763
|
-
}
|
|
1764
|
-
return context;
|
|
1765
|
-
};
|
|
1766
|
-
|
|
1767
|
-
// src/providers/LunoKitProvider.tsx
|
|
1768
|
-
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1769
|
-
var LunoKitProvider = ({
|
|
1770
|
-
children,
|
|
1771
|
-
config,
|
|
1772
|
-
queryClientConfig,
|
|
1773
|
-
theme
|
|
1774
|
-
}) => {
|
|
1775
|
-
const [queryClient] = useState9(() => new QueryClient(queryClientConfig));
|
|
1776
|
-
return /* @__PURE__ */ jsx27(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx27(LunoProvider, { config, children: /* @__PURE__ */ jsx27(ThemeProvider, { theme, children: /* @__PURE__ */ jsxs13(ModalProvider, { children: [
|
|
1777
|
-
/* @__PURE__ */ jsx27("div", { className: "font-base luno-kit", children }),
|
|
1778
|
-
/* @__PURE__ */ jsx27(RenderModals, { modalSize: config.modalSize })
|
|
1779
|
-
] }) }) }) });
|
|
1780
|
-
};
|
|
1781
|
-
var RenderModals = ({ modalSize }) => {
|
|
1782
|
-
return /* @__PURE__ */ jsxs13(Fragment7, { children: [
|
|
1783
|
-
/* @__PURE__ */ jsx27(ConnectModal, { size: modalSize }),
|
|
1784
|
-
/* @__PURE__ */ jsx27(AccountDetailsModal, {}),
|
|
1785
|
-
/* @__PURE__ */ jsx27(ChainModal, {})
|
|
1786
|
-
] });
|
|
1787
|
-
};
|
|
1788
|
-
export {
|
|
1789
|
-
ConnectButton,
|
|
1790
|
-
LunoKitProvider,
|
|
1791
|
-
useLunoTheme
|
|
1792
|
-
};
|
|
2
|
+
import{useCallback as lo,useMemo as je}from"react";import{useAccount as co,useActiveConnector as mo,useBalance as uo,useChain as po}from"@luno-kit/react";import ce from"react";import*as M from"@radix-ui/react-dialog";import{clsx as ht}from"clsx";import{extendTailwindMerge as xt}from"tailwind-merge";var gt=xt({extend:{classGroups:{"font-size":["text-xs","text-sm","text-base","text-lg"]}}});function d(...e){return gt(ht(e))}function Ae(e,n){let t;return()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,e()},n)}}import{jsx as Te,jsxs as bt}from"react/jsx-runtime";var wt=({open:e,onOpenChange:n,children:t,contentClassName:r,overlayClassName:o})=>Te(M.Root,{open:e,onOpenChange:n,children:bt(M.Portal,{children:[ce.createElement(M.Overlay,{className:d("fixed inset-0 z-[100] bg-modalBackdrop luno-kit","data-[state=open]:[animation:overlay-in_150ms_ease-out]",o)}),Te(M.Content,{className:d("luno-kit font-body fixed z-[200] text-modalText text-base leading-base","bg-modalBackground shadow-modal focus:outline-none overflow-hidden border border-modalBorder","transition-all duration-200","rounded-t-modalMobile bottom-0 left-0 w-full","translate-y-0 -translate-x-0","data-[state=open]:[animation:slide-up_200ms_ease-out]","md:bottom-auto md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2","md:w-auto md:rounded-modal","md:data-[state=open]:[animation:dialog-in_150ms_ease-out]",r),children:t})]})}),Ct=({children:e,className:n})=>ce.createElement(M.Title,{className:n},e),vt=({children:e,className:n,onClick:t})=>ce.createElement(M.Close,{className:n,onClick:t},e),G=wt,E=vt,D=Ct;import{createContext as yt,useCallback as me,useContext as ee,useEffect as St,useMemo as Nt,useState as Mt}from"react";import{ConnectionStatus as Y,useStatus as kt}from"@luno-kit/react";import{jsx as Tt}from"react/jsx-runtime";function de(){let[e,n]=Mt(!1),t=me(()=>n(!0),[]),r=me(()=>n(!1),[]);return{isOpen:e,open:t,close:r}}var z=yt(void 0),Re=({children:e})=>{let{isOpen:n,open:t,close:r}=de(),{isOpen:o,open:a,close:i}=de(),{isOpen:m,open:p,close:u}=de(),f=kt(),l=me(()=>{r(),i(),u()},[r,i,u]);St(()=>{f===Y.Disconnected&&(i(),u())},[f,i,u]);let s=Nt(()=>({isConnectModalOpen:n,isAccountModalOpen:o,isChainModalOpen:m,openConnectModal:f!==Y.Connected?t:void 0,closeConnectModal:r,openAccountModal:f===Y.Connected?a:void 0,closeAccountModal:i,openChainModal:f===Y.Connected?p:void 0,closeChainModal:u,closeAllModals:l}),[n,t,r,o,a,i,m,p,u,l,f]);return Tt(z.Provider,{value:s,children:e})},W=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useConnectModal must be used within a ModalProvider");return{isOpen:e.isConnectModalOpen,open:e.openConnectModal,close:e.closeConnectModal}},Q=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useAccountModal must be used within a ModalProvider");return{isOpen:e.isAccountModalOpen,open:e.openAccountModal,close:e.closeAccountModal}},U=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useChainModal must be used within a ModalProvider");return{isOpen:e.isChainModalOpen,open:e.openChainModal,close:e.closeChainModal}},At=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useCloseAllModals must be used within a ModalProvider");return e.closeAllModals};import{jsx as Pe}from"react/jsx-runtime";var Rt=e=>Pe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Pe("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"})}),j=Rt;import{jsx as Ve}from"react/jsx-runtime";var Pt=e=>Ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Ve("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})}),V=Pt;import{jsx as Ie}from"react/jsx-runtime";var Vt=e=>Ie("svg",{xmlns:"http://www.w3.org/2000/svg",className:"copy_svg__icon",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Ie("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"})}),ue=Vt;import{jsx as Be}from"react/jsx-runtime";var It=e=>Be("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 256 256",width:"20",height:"20",...e,children:Be("path",{d:"M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z"})}),pe=It;import{jsx as Ee}from"react/jsx-runtime";var Bt=e=>Ee("svg",{xmlns:"http://www.w3.org/2000/svg",className:"list_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:Ee("path",{d:"M232,48V88a8,8,0,0,1-16,0V56H184a8,8,0,0,1,0-16h40A8,8,0,0,1,232,48ZM72,200H40V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16Zm152-40a8,8,0,0,0-8,8v32H184a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,224,160ZM32,96a8,8,0,0,0,8-8V56H72a8,8,0,0,0,0-16H32a8,8,0,0,0-8,8V88A8,8,0,0,0,32,96ZM188,167l-56,32a8,8,0,0,1-7.94,0L68,167A8,8,0,0,1,64,160V96a8,8,0,0,1,4-7l56-32a8,8,0,0,1,7.94,0l56,32a8,8,0,0,1,4,7v64A8,8,0,0,1,188,167ZM88.12,96,128,118.79,167.88,96,128,73.21ZM80,155.36l40,22.85V132.64L80,109.79Zm96,0V109.79l-40,22.85v45.57Z"})}),fe=Bt;import{jsx as De}from"react/jsx-runtime";var Et=e=>De("svg",{xmlns:"http://www.w3.org/2000/svg",className:"success_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:De("path",{d:"M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z"})}),he=Et;import{jsx as Le}from"react/jsx-runtime";var Dt=e=>Le("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",className:"switch_svg__icon",viewBox:"0 0 256 256",fill:"currentColor",...e,children:Le("path",{d:"M253.66,133.66l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L216,132.69V128A88,88,0,0,0,56.49,76.67a8,8,0,0,1-13-9.34A104,104,0,0,1,232,128v4.69l10.34-10.35a8,8,0,0,1,11.32,11.32Zm-41.18,55A104,104,0,0,1,24,128v-4.69L13.66,133.66A8,8,0,0,1,2.34,122.34l24-24a8,8,0,0,1,11.32,0l24,24a8,8,0,0,1-11.32,11.32L40,123.31V128a87.62,87.62,0,0,0,22.24,58.41A79.66,79.66,0,0,1,98.3,157.66a48,48,0,1,1,59.4,0,79.59,79.59,0,0,1,36.08,28.78,89.68,89.68,0,0,0,5.71-7.11,8,8,0,0,1,13,9.34ZM128,152a32,32,0,1,0-32-32A32,32,0,0,0,128,152Zm0,64a88.2,88.2,0,0,0,53.92-18.49,64,64,0,0,0-107.84,0A87.57,87.57,0,0,0,128,216Z"})}),xe=Dt;import{useMemo as Lt}from"react";import{jsx as Oe}from"react/jsx-runtime";var F=({chainIconUrl:e,chainName:n,className:t})=>e?Oe("img",{src:e,alt:n||"Chain icon",className:d("w-full h-full object-cover rounded-full",t)}):Oe("div",{className:d("w-full h-full bg-gray-500 text-modalText font-semibold","flex items-center justify-center rounded-full",t),children:n?n.charAt(0).toUpperCase():"C"});import{useAccount as Ot,useChain as _t,useDisconnect as Ht,getExplorerUrl as Gt}from"@luno-kit/react";import{Fragment as He,jsx as C,jsxs as q}from"react/jsx-runtime";var Ge=({onViewChange:e,onModalClose:n})=>{let{address:t}=Ot(),{chain:r}=_t(),{disconnectAsync:o}=Ht(),a=Lt(()=>[{key:"Chain Name",content:C("div",{className:"flex items-stretch w-full justify-between",children:q("div",{className:"flex items-center gap-2",children:[C("div",{className:"relative",children:C(F,{className:"w-[20px] h-[20px]",chainIconUrl:r?.chainIconUrl,chainName:r?.name})}),C("span",{className:"text-base text-modalText",children:r?.name||"Polkadot"})]})}),onClick:()=>e("switchChain")},{key:"View on Explorer",content:q(He,{children:[C(fe,{}),C("span",{className:"text-base text-accountActionItemText",children:"View on Explorer"})]}),onClick:()=>window.open(Gt(r?.blockExplorers?.default?.url,t,"address"))},{key:"Switch Account",content:q(He,{children:[C(xe,{}),C("span",{className:"text-base text-accountActionItemText",children:"Switch Account"})]}),onClick:()=>e("switchAccount")}],[e,r,t]),i=async()=>{await o(),n()};return q("div",{className:"flex flex-col items-center gap-3 w-full",children:[C("div",{className:"flex flex-col gap-1.5 w-full px-4",children:a.map(m=>C(_e,{onClick:m.onClick,children:m.content},m.key))}),C("div",{className:"w-full mx-[-100px] h-[1px] bg-separatorLine"}),C("div",{className:"w-full px-4 pb-4",children:q(_e,{onClick:i,children:[C(pe,{}),C("span",{className:"font-medium text-base text-accountActionItemText",children:"Disconnect"})]})})]})},_e=({children:e,onClick:n})=>C("button",{type:"button",onClick:()=>n?.(),className:d("w-full p-2.5 rounded-accountActionItem border-none text-left flex items-center gap-2 font-medium","bg-accountActionItemBackground hover:bg-accountActionItemBackgroundHover","transition-colors duration-200",n?"cursor-pointer":"cursor-auto"),"aria-label":typeof e=="string"?e:void 0,children:e});import Ft,{useCallback as $t}from"react";import{useAccount as Zt,useAccounts as zt,useActiveConnector as Wt,useBalance as Qt,useChain as Ut}from"@luno-kit/react";import{formatAddress as jt}from"@luno-kit/react";import{Fragment as Kt,jsx as I,jsxs as te}from"react/jsx-runtime";var ge=({onBack:e})=>{let{accounts:n,selectAccount:t}=zt(),{address:r}=Zt(),o=$t(a=>{t(a),e()},[e]);return I("div",{className:"flex flex-col gap-1.5 pt-3 overflow-auto max-h-[400px] no-scrollbar p-4 pt-0",children:n.map(a=>I(qt,{account:a,isSelected:a.address===r,selectAccount:o},a.address))})};ge.title="Switch Accounts";var qt=Ft.memo(({isSelected:e,account:n,selectAccount:t})=>{let{chain:r}=Ut(),o=n.address,{data:a}=Qt({address:o}),i=Wt();return te("button",{type:"button",onClick:()=>t(n),className:d("px-3.5 py-2.5 w-full rounded-accountSelectItem border-none","bg-accountSelectItemBackground","text-left flex items-center justify-between gap-2","transition-colors duration-200",e?"cursor-auto":"cursor-pointer hover:bg-accountSelectItemBackgroundHover"),"aria-label":n.name||o,disabled:e,children:[te("div",{className:"flex items-center gap-2",children:[I("div",{className:"shrink-0 w-[24px] h-[24px] rounded-full flex items-center justify-center",children:i?.icon&&I("img",{src:i?.icon,alt:"luno account"})}),te("div",{className:"flex flex-col items-start",children:[I("span",{className:"font-medium text-sm leading-sm text-accountSelectItemText",children:n.name||jt(o)}),I("span",{className:"text-xs text-modalTextSecondary font-medium",children:a===void 0?I("div",{className:"animate-pulse rounded w-[60px] h-[18px] bg-skeleton"}):te(Kt,{children:[a?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}),e&&I("div",{className:"border-[1px] border-solid border-accentColor rounded-full overflow-hidden flex items-center justify-center w-[18px] h-[18px]",children:I("div",{className:"rounded-full bg-accentColor w-[10px] h-[10px]"})})]})});import Jt,{useMemo as Xt,useState as Fe}from"react";import{useApi as Yt,useChain as eo,useChains as to,useSwitchChain as oo}from"@luno-kit/react";import{Fragment as $e,jsx as S,jsxs as $}from"react/jsx-runtime";var no=[{key:"All",label:"All"},{key:"Mainnets",label:"Mainnets"},{key:"Testnets",label:"Testnets"}],oe=({onChainSwitched:e})=>{let{chain:n}=eo(),t=to(),{switchChainAsync:r}=oo(),{isApiReady:o,apiError:a}=Yt(),[i,m]=Fe("All"),[p,u]=Fe(null),f=Xt(()=>{switch(i){case"Mainnets":return t.filter(s=>!s.testnet);case"Testnets":return t.filter(s=>s.testnet);case"All":default:return t}},[t,i]),l=async s=>{if(s.genesisHash!==n?.genesisHash&&!(!o&&!a)){u(s.genesisHash);try{await r({chainId:s.genesisHash}),e?.(s)}catch(c){console.error("Failed to switch chain:",c)}finally{u(null)}}};return $($e,{children:[S("div",{className:"flex items-center gap-1.5 w-full",children:no.map(s=>S("button",{onClick:()=>m(s.key),className:d("px-3.5 flex items-center justify-center cursor-pointer min-w-[48px] min-h-[24px] rounded-networkSelectItem text-[12px] leading-[16px] font-medium transition-colors",i===s.key?"bg-navigationButtonBackground text-modalText":"bg-transparent text-modalTextSecondary hover:text-modalText"),children:s.label},s.key))}),S("div",{className:"flex flex-col gap-1.5 overflow-y-auto custom-scrollbar max-h-[450px]",children:f.map(s=>S(ro,{chain:s,isSelected:s.genesisHash===n?.genesisHash,onSelect:l,isLoading:(p===s.genesisHash||!o)&&!a},s.genesisHash))}),f.length===0&&S("div",{className:"flex items-center justify-center py-12",children:$("span",{className:"text-modalTextSecondary text-xs",children:["No ",i==="All"?"chains":i.toLowerCase()," available"]})})]})},ro=Jt.memo(({chain:e,isSelected:n,isLoading:t,onSelect:r})=>$("button",{onClick:()=>r(e),disabled:n||t,className:d("flex items-center justify-between p-2.5 rounded-networkSelectItem","bg-networkSelectItemBackground","transition-colors duration-200",n||t?"cursor-default":"cursor-pointer hover:bg-networkSelectItemBackgroundHover",t&&"opacity-80"),children:[$("div",{className:"flex items-center gap-2",children:[S(F,{className:"w-[20px] bg-modal-bg h-[20px] flex items-center justify-center",chainIconUrl:e?.chainIconUrl,chainName:e?.name}),S("div",{className:"flex flex-col items-start",children:S("span",{className:"font-medium text-base text-modalText",children:e.name})})]}),S("div",{className:"flex items-center justify-center h-[20px]",children:n?t?$($e,{children:[S("span",{className:"text-accentColor text-xs leading-xs mr-1.5",children:"Switching"}),S("div",{className:"loading text-accentColor w-[15px] h-[15px]"})]}):$("span",{className:"status-dot-container",children:[S("span",{className:"ping-animation"}),S("span",{className:"status-dot"})]}):null})]}));import{jsx as Ze}from"react/jsx-runtime";var ne=({onBack:e})=>Ze("div",{className:"flex flex-col gap-3.5 p-4 pt-0",children:Ze(oe,{})});ne.title="Select Networks";import{useCallback as ao,useState as io}from"react";import{jsx as ze,jsxs as so}from"react/jsx-runtime";var re=({copyText:e,label:n,className:t=""})=>{let[r,o]=io(!1),a=ao(async i=>{try{return navigator.clipboard&&navigator.clipboard.writeText?(await navigator.clipboard.writeText(i),o(!0),setTimeout(()=>o(!1),2e3),!0):!1}catch(m){return console.error("Copy failed:",m),!1}},[]);return so("button",{type:"button",className:d("cursor-pointer bg-transparent border-none p-0 m-0 inline-flex items-center justify-center gap-1",t),onClick:()=>!r&&e&&a(e),"aria-label":"Copy address to clipboard",disabled:r,children:[r?ze(he,{className:"text-accentColor",width:16,height:16}):ze(ue,{width:16,height:16}),n]})};import{formatAddress as fo}from"@luno-kit/react";import{useCallback as We,useState as Qe,useRef as Ue}from"react";function ae({initialView:e,animationDuration:n=200,animationEasing:t="ease-out"}){let[r,o]=Qe(e),[a,i]=Qe(!1),m=Ue(null),p=Ue(null),u=We(l=>{if(l===r||a)return;if(i(!0),!m.current){o(l),i(!1);return}let s=m.current,c=s.offsetHeight;o(l),requestAnimationFrame(()=>{if(!s||!p.current){i(!1);return}let h=p.current.offsetHeight;s.animate([{height:c+"px"},{height:h+"px"}],{duration:n,easing:t,fill:"forwards"}).addEventListener("finish",()=>{i(!1)})})},[r,a,n,t]),f=We(()=>{o(e),i(!1)},[e]);return{currentView:r,isAnimating:a,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}}import{Fragment as qe,jsx as g,jsxs as H}from"react/jsx-runtime";var Ke=()=>{let{isOpen:e,close:n}=Q(),{address:t}=co(),{chain:r}=po(),{data:o}=uo({address:t}),a=mo(),{currentView:i,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}=ae({initialView:"main"}),l=lo(()=>{n(),f()},[n]),s=je(()=>i==="switchAccount"?"Switch Account":i==="switchChain"?ne.title:null,[i]),c=je(()=>({main:g(Ge,{onViewChange:u,onModalClose:l}),switchAccount:g(ge,{onBack:()=>u("main")}),switchChain:g(ne,{onBack:()=>u("main")})}),[u,l]);return g(G,{open:e,onOpenChange:l,children:H("div",{className:d("flex flex-col w-full md:w-[360px] max-h-[500px] text-modalText","bg-modalBackground shadow-modal",i==="main"?"gap-6":"gap-3.5"),children:[H("div",{className:"flex items-stretch justify-between w-full px-4 pt-4",children:[i==="main"?H("div",{className:"flex items-center gap-3",children:[a?.icon&&g("div",{className:"flex items-center justify-center w-[55px] h-[55px]",children:g("img",{src:a.icon,alt:""})}),H("div",{className:"flex flex-col items-start gap-1 w-full",children:[g(D,{className:"sr-only",children:"Account Details"}),H("div",{className:"flex items-center gap-1.5 w-full",children:[g("span",{className:"text-base text-modalText font-semibold",children:fo(t)}),g(re,{copyText:t})]}),g("div",{className:"text-sm text-modalTextSecondary font-medium min-h-[20px]",children:o===void 0?g("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-skeleton"}):H(qe,{children:[o?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}):H(qe,{children:[g("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>u("main"),"aria-label":"Back",children:g(j,{})}),g(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:s})]}),g(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:g(V,{})})]}),g("div",{ref:m,className:"relative overflow-hidden",children:g("div",{ref:p,children:c[i]})})]})})};import{jsx as Z,jsxs as Je}from"react/jsx-runtime";var Xe=()=>{let{isOpen:e,close:n}=U();return Z(G,{open:e,onOpenChange:t=>!t&&n(),children:Je("div",{className:"flex flex-col w-full md:w-[360px] max-h-[500px] p-4 gap-3.5 text-modalText",children:[Je("div",{className:"flex items-center justify-between w-full",children:[Z("div",{className:"w-[30px]"})," ",Z(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:"Select Network"}),Z(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:Z(V,{})})]}),Z(oe,{})]})})};import{useEffect as Io,useMemo as Bo,useState as it}from"react";import{useConnect as Eo,isMobileDevice as Do}from"@luno-kit/react";import{useStatus as ho,useAccount as xo,useChain as go,useBalance as wo,ConnectionStatus as ie,useChains as Co,useActiveConnector as vo,formatAddress as bo}from"@luno-kit/react";function Ye(){let e=ho(),{account:n,address:t}=xo(),{chain:r}=go(),o=Co(),{data:a}=wo({address:t}),i=vo(),{open:m,isOpen:p}=W(),{open:u,isOpen:f}=Q(),{open:l,isOpen:s}=U(),c=e===ie.Connecting,h=e===ie.Connected,x=e===ie.Disconnected||e===ie.Disconnecting,T=!!r&&o.some(b=>b.genesisHash.toLowerCase()===r.genesisHash.toLowerCase());return{activeConnector:i,connectionStatus:e,isConnected:h,isDisconnected:x,isConnecting:c,account:n,address:t,displayAddress:bo(t),currentChain:r,configuredChains:o,isChainSupported:T,chainIconUrl:r?.chainIconUrl,chainName:r?.name,balance:a,openConnectModal:m,openAccountModal:u,openChainModal:l,isConnectModalOpen:p,isAccountModalOpen:f,isChainModalOpen:s}}import{useEffect as yo,useState as So}from"react";var se=()=>{let[e,n]=So({height:void 0,width:void 0});return yo(()=>{let t=Ae(()=>{n({height:window.innerHeight,width:window.innerWidth})},500);return window.addEventListener("resize",t),t(),()=>window.removeEventListener("resize",t)},[]),e};import Ro from"react";import{Cuer as No}from"cuer";import{jsx as L,jsxs as et}from"react/jsx-runtime";var tt=({logoBackground:e,uri:n,size:t})=>{if(!n){let a=Math.floor(14.25),i=t/57,m=a*i,p=Math.ceil(57/2-a/2),u=p+a,f=()=>{let c=[];for(let h=0;h<57;h++)for(let x=0;x<57;x++){if(h>=p&&h<u&&x>=p&&x<u||h<8&&x<8||h<8&&x>=49||h>=49&&x<8)continue;let b=x+.5,P=h+.5;c.push(L("rect",{x:b-.4,y:P-.4,width:.8,height:.8,rx:.4,fill:"var(--color-walletSelectItemBackground)"},`${h}-${x}`))}return c},l=({position:c})=>{let h=7*i,x={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0}};return et("div",{className:"absolute z-[4]",style:{width:`${h}px`,height:`${h}px`,...x[c]},children:[L("div",{className:"absolute inset-0",style:{borderRadius:`${2*i}px`,border:`${i}px solid var(--color-walletSelectItemBackground)`}}),L("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:`${3*i}px`,height:`${3*i}px`,borderRadius:`${.5*i}px`,backgroundColor:"var(--color-walletSelectItemBackground)"}})]})},s=()=>{let c=p*i;return L("div",{className:"absolute z-[4] flex items-center justify-center box-border",style:{width:`${m}px`,height:`${m}px`,left:`${c}px`,top:`${c}px`,borderRadius:`${i}px`,padding:`${i/2}px`},children:L("img",{src:e,alt:"QR Code Logo",className:"h-full w-full object-cover",style:{borderRadius:`${i}px`}})})};return et("div",{className:"relative overflow-hidden flex items-center justify-center",style:{width:t,height:t,borderRadius:`${2*i}px`},children:[L("svg",{className:"absolute inset-0 z-[3]",width:t,height:t,viewBox:"0 0 57 57",children:f()}),L("div",{className:"absolute inset-0 z-[100]",style:{background:"linear-gradient(90deg, transparent 50%, var(--color-walletSelectItemBackgroundHover), transparent)",backgroundSize:"200% 100%",transform:"scale(1.5) rotate(45deg)",animation:"shimmer 1000ms linear infinite both"}}),l({position:"top-left"}),l({position:"top-right"}),l({position:"bottom-left"}),e&&s()]})}return L(No,{arena:e,value:n})};import{jsx as O,jsxs as K}from"react/jsx-runtime";var J="transition-transform transition-[125] hover:scale-[1.03] transition-ease",Mo=({className:e,label:n="Connect Wallet",accountStatus:t="full",chainStatus:r="full",showBalance:o=!0})=>{let{isConnected:a,isDisconnected:i,displayAddress:m,balance:p,openConnectModal:u,openAccountModal:f,openChainModal:l,chainIconUrl:s,chainName:c,currentChain:h,activeConnector:x}=Ye(),{width:T}=se(),b=T&&T>768;return i||!a||!x?O("button",{type:"button",onClick:()=>u?.(),className:d("cursor-pointer font-semibold inline-flex items-center justify-center focus:outline-none","text-connectButtonText bg-connectButtonBackground shadow-button active:scale-[0.95]","rounded-connectButton",J,"px-3.5 text-base leading-base min-h-[40px]",e),children:n}):K("div",{className:d("text-modalText flex items-stretch bg-transparent font-semibold text-base leading-base gap-3",e),children:[r!=="none"&&K("button",{type:"button",onClick:()=>l?.(),className:d("flex items-center rounded-currentNetworkButton cursor-pointer","bg-currentNetworkButtonBackground shadow-button","py-2 px-2.5 gap-1.5",J),"aria-label":"Switch chain",children:[r==="full"||r==="icon"?O(F,{chainIconUrl:s,chainName:c,className:"w-[24px] h-[24px]"}):null,(r==="full"||r==="name")&&b&&O("span",{children:h?.name||"Unknown Chain"})]}),K("button",{type:"button",onClick:()=>f?.(),className:d("flex items-center cursor-pointer rounded-connectButton bg-connectButtonBackground shadow-button",J),"aria-label":"Open account modal",children:[o&&b&&O("div",{className:"p-2 pl-3",children:p===void 0?O("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-accountActionItemBackgroundHover"}):K("span",{className:"",children:[p?.formattedTransferable||p?.formattedTotal||0," ",h?.nativeCurrency?.symbol||""]})}),K("div",{className:d("flex items-center bg-connectButtonInnerBackground border-2 border-connectButtonBackground rounded-connectButton gap-1.5 max-h-[40px]",o&&b?"bg-connectButtonInnerBackground py-1.5 px-2":"bg-connectButtonBackground py-2 px-2.5"),children:[t==="full"&&O("span",{className:"w-[24px] h-[24px]",children:O("img",{src:x.icon,alt:"luno"})}),O("span",{"aria-label":"Wallet icon placeholder",className:"",children:m})]})]})]})};import{useEffect as ko,useRef as Ao}from"react";import{jsx as To}from"react/jsx-runtime";var ot=({size:e=160,dotCount:n=300,duration:t=3,className:r=""})=>{let o=Ao(null);return ko(()=>{if(!o.current)return;let a=1,i=2,m=Math.PI*(3-Math.sqrt(5)),p=e/2,u=p-i-a,f="http://www.w3.org/2000/svg";o.current.innerHTML="";let l=document.createElementNS(f,"svg");l.setAttribute("width",e.toString()),l.setAttribute("height",e.toString()),l.setAttribute("viewBox",`0 0 ${e} ${e}`),l.style.display="block",o.current.appendChild(l);for(let s=0;s<n;s++){let c=s+.5,h=c/n,x=Math.sqrt(h)*u,T=c*m,b=p+x*Math.cos(T),P=p+x*Math.sin(T),R=document.createElementNS(f,"circle");R.setAttribute("cx",b.toString()),R.setAttribute("cy",P.toString()),R.setAttribute("r",a.toString()),R.setAttribute("fill","currentColor"),R.setAttribute("opacity","0.6"),l.appendChild(R);let y=document.createElementNS(f,"animate");y.setAttribute("attributeName","r"),y.setAttribute("values",`${a*.5};${a*1.8};${a*.5}`),y.setAttribute("dur",`${t}s`),y.setAttribute("begin",`${h*t}s`),y.setAttribute("repeatCount","indefinite"),y.setAttribute("calcMode","spline"),y.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),R.appendChild(y);let N=document.createElementNS(f,"animate");N.setAttribute("attributeName","opacity"),N.setAttribute("values","0.2;1;0.2"),N.setAttribute("dur",`${t}s`),N.setAttribute("begin",`${h*t}s`),N.setAttribute("repeatCount","indefinite"),N.setAttribute("calcMode","spline"),N.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),R.appendChild(N)}},[e,n,t]),To("div",{ref:o,className:d("text-accentColor inline-flex w-full h-full justify-center align-center",r)})};import{Fragment as nt,jsx as w,jsxs as B}from"react/jsx-runtime";var we=Ro.memo(({selectedConnector:e,onConnect:n,qrCode:t,isWide:r,connectState:o})=>{let a=e?.hasConnectionUri();return B("div",{className:d("flex flex-col items-center",r?"w-[450px] p-4 min-h-[472px]":"justify-center w-full min-h-[400px]"),children:[r&&w("div",{className:"w-full",children:B("div",{className:"flex items-center justify-between",children:[w("div",{}),w(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:w(V,{})})]})}),w("div",{className:d("flex items-center gap-4 flex-col grow justify-center",e&&a?"max-w-[300px]":"max-w-[360px]"),children:e?a?B("div",{className:"flex flex-col items-center gap-2.5",children:[w(tt,{size:300,logoBackground:e.icon,uri:t}),B("div",{className:"text-base leading-base font-medium text-center text-modalTextSecondary",children:["Scan the QR code with ",e.id==="nova"?"the Nova":"your phone"]}),w("div",{className:"min-h-[20px] flex items-center justify-center ",children:e.links?.browserExtension?B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer text-sm text-accentColor font-medium text-center hover:text-modalText",children:["Don't have ",e.name,"?"]}):t?w(re,{className:"text-sm leading-sm font-medium text-accentColor hover:text-modalText",copyText:t,label:"Copy Link"}):null})]}):B(nt,{children:[w("div",{className:"w-[80px] h-[80px]",children:w("img",{src:e.icon,className:"w-full h-full",alt:""})}),B("p",{className:"text-lg leading-lg text-modalFont font-bold",children:["Opening ",e.name,"..."]}),w("p",{className:"pb-[10px] text-base text-modalTextSecondary leading-base font-medium text-center",children:"Confirm connection in the extension"}),o.isConnecting&&w("div",{className:"loading text-modalText"}),!e.isInstalled()&&e.links.browserExtension&&B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer pt-6 text-sm text-accentColor font-medium text-center hover:text-modalText",children:["Don\u2018t have ",e.name,"?"]}),!o.isConnecting&&o.isError&&e.isInstalled()&&w("button",{className:d("rounded-connectButton focus:outline-none py-[4px] px-[12px] cursor-pointer font-semibold text-sm text-modalText bg-connectButtonBackground shadow-connectButton active:scale-[0.95]",J),onClick:()=>n(e),children:"Retry"})]}):B(nt,{children:[w("div",{className:"w-[160px] h-[160px] mb-4",children:w(ot,{})}),w("p",{className:"cursor-pointer text-base leading-base text-accentColor font-semibold text-center",onClick:()=>window.open("https://polkadot.com/get-started/wallets/"),children:"New to wallets?"}),w("p",{className:"text-modalTextSecondary w-[250px] text-sm leading-sm font-medium text-center",children:"Connect your wallet to sign in and start using your assets."})]})}),w("div",{})]})});import rt from"react";import{useConnectors as Po,isMobileDevice as Vo}from"@luno-kit/react";import{jsx as A,jsxs as le}from"react/jsx-runtime";var at=rt.memo(({onConnect:e})=>{let n=Po();if(Vo()){let o=n.filter(a=>a.links.deepLink);return A("div",{className:"flex flex-col items-start gap-1 w-full",children:o.map(a=>A(Ce,{connector:a,onConnect:()=>e(a)},`${a.id}-${a.name}`))})}let t=n.filter(o=>o.isInstalled()),r=n.filter(o=>!o.isInstalled());return le("div",{className:"flex flex-col items-start gap-4 w-full",children:[le("div",{className:"flex flex-col items-start gap-2 w-full",children:[A("div",{className:"text-sm text-accentColor font-semibold leading-base",children:"Installed"}),A("div",{className:"flex flex-col items-start gap-1.5 w-full",children:t.map(o=>A(Ce,{connector:o,onConnect:()=>e(o)},o.id))})]}),r.length>0&&le("div",{className:"flex flex-col items-start gap-2 w-full",children:[A("div",{className:"text-sm text-modalTextSecondary font-semibold leading-base",children:"More"}),A("div",{className:"flex flex-col items-start gap-1 w-full",children:r.map(o=>A(Ce,{connector:o,onConnect:()=>e(o)},o.id))})]})]})}),Ce=rt.memo(({connector:e,onConnect:n})=>le("button",{onClick:n,className:d("cursor-pointer bg-walletSelectItemBackground p-2 w-full flex items-center gap-3 rounded-walletSelectItem border-none","hover:bg-walletSelectItemBackgroundHover transition-transform active:scale-[0.95]","text-left"),children:[A("div",{className:"w-[28px] h-[28px]",children:A("img",{src:e.icon,alt:e.name,className:"w-full h-full"})}),A("span",{className:"font-semibold leading-base text-base text-modalText",children:e.name})]}));import{Fragment as ve,jsx as v,jsxs as X}from"react/jsx-runtime";var st=({size:e="wide"})=>{let{isOpen:n,close:t}=W(),{connectAsync:r,reset:o,isPending:a,isError:i}=Eo(),[m,p]=it(null),[u,f]=it(),{width:l}=se(),s=l&&l>768,c=!!(e==="wide"&&s),{containerRef:h,currentViewRef:x,resetView:T,handleViewChange:b,currentView:P}=ae({initialView:"Connect Wallet"}),R=async k=>{let ke=await k.getConnectionUri();f(ke)},y=async k=>{if(Do()&&k.links.deepLink)try{await r({connectorId:k.id}),N(!1);return}catch{window.location.href=`${k.links.deepLink}?url=${window.location.href}`;return}!c&&b("walletView"),p(k),f(void 0),k.hasConnectionUri()&&R(k),await r({connectorId:k.id}),N(!1)},N=k=>{!k&&t(),o(),T(),p(null),f(void 0)},ft=Bo(()=>({"Connect Wallet":v(at,{onConnect:y}),walletView:v(we,{connectState:{isConnecting:a,isError:i},isWide:c,selectedConnector:m,qrCode:u,onConnect:y})}),[c,m,u,y,a,i]);return Io(()=>{c&&P==="walletView"&&b("Connect Wallet")},[c,P]),v(G,{open:n,onOpenChange:N,children:X("div",{className:d("flex items-stretch justify-between w-full md:max-h-[504px] md:max-w-[724px]"),children:[X("div",{className:d("flex flex-col items-start py-4 px-5 w-full md:w-auto",c?"md:min-w-[300px] border-r-[1px] border-r-solid border-r-separatorLine":"md:min-w-[360px]"),children:[X("div",{className:d("flex items-center justify-between w-full",!c&&"pb-4"),children:[P==="Connect Wallet"?X(ve,{children:[!c&&v("div",{className:"w-[30px] h-[30px]","aria-hidden":!0}),v(D,{className:d("text-lg leading-lg text-modalText font-bold",c?"pb-6":"flex-1 text-center"),children:"Connect Wallet"})]}):X(ve,{children:[v("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>b("Connect Wallet"),"aria-label":"Back",children:v(j,{})}),v(D,{className:d("text-lg leading-lg text-modalText font-semibold transition-opacity duration-300"),children:m?.name})]}),!c&&v(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:v(V,{})})]}),v("div",{ref:h,className:"relative overflow-hidden w-full",children:v("div",{ref:x,children:ft[P]})}),!c&&P==="Connect Wallet"&&v(ve,{children:v("p",{className:"cursor-pointer w-full pt-4 text-sm leading-sm text-accentColor font-medium text-center hover:text-modalText",onClick:()=>window.open("https://polkadot.com/get-started/wallets/"),children:"New to wallets?"})})]}),c&&v(we,{connectState:{isConnecting:a,isError:i},isWide:c,selectedConnector:m,qrCode:u,onConnect:y})]})})};import{useState as Zo}from"react";import{LunoProvider as zo}from"@luno-kit/react";import{QueryClient as Wo,QueryClientProvider as Qo}from"@tanstack/react-query";import{createContext as Oo,useState as Se,useContext as _o,useMemo as be,useCallback as Ho,useEffect as dt}from"react";import{useEffect as Lo}from"react";var lt=["--color-accentColor","--color-walletSelectItemBackground","--color-walletSelectItemBackgroundHover","--color-walletSelectItemText","--color-connectButtonBackground","--color-connectButtonInnerBackground","--color-connectButtonText","--color-accountActionItemBackground","--color-accountActionItemBackgroundHover","--color-accountActionItemText","--color-accountSelectItemBackground","--color-accountSelectItemBackgroundHover","--color-accountSelectItemText","--color-currentNetworkButtonBackground","--color-currentNetworkButtonText","--color-networkSelectItemBackground","--color-networkSelectItemBackgroundHover","--color-networkSelectItemText","--color-navigationButtonBackground","--color-separatorLine","--color-modalBackground","--color-modalBackdrop","--color-modalBorder","--color-modalText","--color-modalTextSecondary","--color-modalControlButtonBackgroundHover","--color-modalControlButtonText","--color-success","--color-successForeground","--color-warning","--color-warningForeground","--color-error","--color-errorForeground","--color-info","--color-infoForeground","--color-skeleton","--font-body","--radius-walletSelectItem","--radius-connectButton","--radius-modalControlButton","--radius-accountActionItem","--radius-accountSelectItem","--radius-currentNetworkButton","--radius-networkSelectItem","--radius-modal","--radius-modalMobile","--shadow-button","--shadow-modal","--blur-modalOverlay"],ct=(e,n)=>{Lo(()=>{if(typeof window>"u")return;let t=document.documentElement;e.type==="complete"&&e.completeTheme?(Object.entries(e.completeTheme.colors).forEach(([r,o])=>{o&&t.style.setProperty(`--color-${r}`,o)}),Object.entries(e.completeTheme.fonts).forEach(([r,o])=>{o&&t.style.setProperty(`--font-${r}`,o)}),Object.entries(e.completeTheme.radii).forEach(([r,o])=>{o&&t.style.setProperty(`--radius-${r}`,o)}),Object.entries(e.completeTheme.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--shadow-${r}`,o)}),Object.entries(e.completeTheme.blurs).forEach(([r,o])=>{o&&t.style.setProperty(`--blur-${r}`,o)}),t.removeAttribute("data-theme")):e.type==="partial"&&e.partialOverrides?(t.setAttribute("data-theme",n),Object.keys(e.partialOverrides).length>0&&(lt.forEach(o=>{t.style.removeProperty(o)}),e.partialOverrides.colors&&Object.entries(e.partialOverrides.colors).forEach(([o,a])=>{a&&t.style.setProperty(`--color-${o}`,a)}),e.partialOverrides.fonts&&Object.entries(e.partialOverrides.fonts).forEach(([o,a])=>{a&&t.style.setProperty(`--font-${o}`,a)}),e.partialOverrides.radii&&Object.entries(e.partialOverrides.radii).forEach(([o,a])=>{a&&t.style.setProperty(`--radius-${o}`,a)}),e.partialOverrides.shadows&&Object.entries(e.partialOverrides.shadows).forEach(([o,a])=>{a&&t.style.setProperty(`--shadow-${o}`,a)}),e.partialOverrides.blurs&&Object.entries(e.partialOverrides.blurs).forEach(([o,a])=>{a&&t.style.setProperty(`--blur-${o}`,a)}))):(t.setAttribute("data-theme",n),lt.forEach(r=>{t.style.removeProperty(r)}))},[e,n])};import{jsx as $o}from"react/jsx-runtime";var Ne="luno.lastThemePreference",Go=e=>{try{localStorage.setItem(Ne,JSON.stringify(e))}catch{}},mt=Oo(void 0),ye=e=>"colors"in e&&"fonts"in e&&"radii"in e&&"shadows"in e&&"blurs"in e,Fo=()=>{let[e,n]=Se(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return dt(()=>{if(typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),r=o=>{n(o.matches?"dark":"light")};return r(t),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e},Me=({children:e,theme:n})=>{let t=Fo(),[r,o]=Se(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ne);if(s){let c=JSON.parse(s);if(c?.isAuto)return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(c?.preferredTheme)return c.preferredTheme}}catch{}return!n||ye(n)?"light":n.defaultMode||"light"}),[a,i]=Se(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ne);if(s)return JSON.parse(s)?.isAuto??!1}catch{}return!n||ye(n)?!1:n.autoMode??!1}),m=be(()=>{if(!n)return{type:"default",completeTheme:null,partialOverrides:null};if(ye(n))return{type:"complete",completeTheme:n,partialOverrides:null};let l=n;if(l.theme)return{type:"complete",completeTheme:l.theme,partialOverrides:null};let s=null;return r==="light"&&l.light?s=l.light:r==="dark"&&l.dark?s=l.dark:s={...l},{type:"partial",completeTheme:null,partialOverrides:s}},[r,n]),p=be(()=>m.type==="complete"?m.completeTheme:null,[m]);ct(m,r);let u=Ho(l=>{let s=l==="auto";i(s),o(s?t||"light":l);let c={isAuto:s,...s?{}:{preferredTheme:l}};Go(c)},[t]);dt(()=>{a&&o(t||"light")},[t,a]);let f=be(()=>({themeMode:r,setThemeChoice:u,currentTheme:p}),[r,u,p]);return $o(mt.Provider,{value:f,children:e})},ut=()=>{let e=_o(mt);if(!e)throw new Error("useLunoTheme must be used within a ThemeProvider (which is part of LunoKitProvider)");return e};import{Fragment as jo,jsx as _,jsxs as pt}from"react/jsx-runtime";var Ja=({children:e,config:n,queryClientConfig:t,theme:r})=>{let[o]=Zo(()=>new Wo(t));return _(Qo,{client:o,children:_(zo,{config:n,children:_(Me,{theme:r,children:pt(Re,{children:[_("div",{className:"font-base luno-kit",children:e}),_(Uo,{modalSize:n.modalSize})]})})})})},Uo=({modalSize:e})=>pt(jo,{children:[_(st,{size:e}),_(Ke,{}),_(Xe,{})]});export{Mo as ConnectButton,Ja as LunoKitProvider,Q as useAccountModal,U as useChainModal,At as useCloseAllModals,W as useConnectModal,ut as useLunoTheme};
|
|
1793
3
|
//# sourceMappingURL=index.js.map
|