coinley-checkout 0.2.9 → 0.3.1

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.
@@ -1,178 +1,441 @@
1
- import React, { createContext, useContext, useState, useEffect, forwardRef, useImperativeHandle } from "react";
2
- const styles = "";
3
- let apiConfig = {
4
- apiKey: null,
5
- apiSecret: null,
6
- apiUrl: "https://coinleyserver-production.up.railway.app",
7
- merchantWalletAddress: null,
8
- merchantSolWalletAddress: null
9
- };
10
- const initializeApi = (config) => {
11
- apiConfig = { ...apiConfig, ...config };
12
- console.log("API initialized with:", {
13
- apiUrl: apiConfig.apiUrl,
14
- apiKey: apiConfig.apiKey ? `${apiConfig.apiKey.substring(0, 6)}...` : null,
15
- hasWalletAddress: !!apiConfig.merchantWalletAddress,
16
- hasSolWalletAddress: !!apiConfig.merchantSolWalletAddress
17
- });
1
+ var Ke = Object.defineProperty, Ve = Object.defineProperties;
2
+ var qe = Object.getOwnPropertyDescriptors;
3
+ var fe = Object.getOwnPropertySymbols;
4
+ var $e = Object.prototype.hasOwnProperty, _e = Object.prototype.propertyIsEnumerable;
5
+ var ge = (s, r, t) => r in s ? Ke(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t, z = (s, r) => {
6
+ for (var t in r || (r = {}))
7
+ $e.call(r, t) && ge(s, t, r[t]);
8
+ if (fe)
9
+ for (var t of fe(r))
10
+ _e.call(r, t) && ge(s, t, r[t]);
11
+ return s;
12
+ }, we = (s, r) => Ve(s, qe(r));
13
+ var R = (s, r, t) => new Promise((c, u) => {
14
+ var h = (e) => {
15
+ try {
16
+ w(t.next(e));
17
+ } catch (n) {
18
+ u(n);
19
+ }
20
+ }, y = (e) => {
21
+ try {
22
+ w(t.throw(e));
23
+ } catch (n) {
24
+ u(n);
25
+ }
26
+ }, w = (e) => e.done ? c(e.value) : Promise.resolve(e.value).then(h, y);
27
+ w((t = t.apply(s, r)).next());
28
+ });
29
+ import S, { createContext as ye, useContext as xe, useState as U, useEffect as Z, forwardRef as Ye, useImperativeHandle as Je } from "react";
30
+ const A = {
31
+ ETHEREUM: "ethereum",
32
+ BSC: "bsc",
33
+ TRON: "tron",
34
+ ALGORAND: "algorand"
35
+ }, N = {
36
+ METAMASK: "metamask",
37
+ TRONLINK: "tronlink",
38
+ TRUST_WALLET: "trust_wallet",
39
+ LUTE: "lute"
40
+ }, de = {
41
+ [A.ETHEREUM]: {
42
+ chainId: "0x1",
43
+ chainName: "Ethereum Mainnet",
44
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
45
+ rpcUrls: ["https://mainnet.infura.io/v3/"],
46
+ blockExplorerUrls: ["https://etherscan.io/"],
47
+ supportedWallets: [N.METAMASK, N.TRUST_WALLET]
48
+ },
49
+ [A.BSC]: {
50
+ chainId: "0x38",
51
+ chainName: "BNB Smart Chain",
52
+ nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
53
+ rpcUrls: ["https://bsc-dataseed.binance.org/"],
54
+ blockExplorerUrls: ["https://bscscan.com/"],
55
+ supportedWallets: [N.METAMASK, N.TRUST_WALLET]
56
+ },
57
+ [A.TRON]: {
58
+ fullHost: "https://api.trongrid.io",
59
+ explorerUrl: "https://tronscan.org",
60
+ supportedWallets: [N.TRONLINK]
61
+ },
62
+ [A.ALGORAND]: {
63
+ network: "mainnet",
64
+ explorerUrl: "https://algoexplorer.io",
65
+ supportedWallets: [N.LUTE]
66
+ }
67
+ }, Xe = {
68
+ USDT: {
69
+ [A.ETHEREUM]: {
70
+ address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
71
+ decimals: 6
72
+ },
73
+ [A.BSC]: {
74
+ address: "0x55d398326f99059fF775485246999027B3197955",
75
+ decimals: 18
76
+ },
77
+ [A.TRON]: {
78
+ address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
79
+ decimals: 6
80
+ }
81
+ },
82
+ USDC: {
83
+ [A.ETHEREUM]: {
84
+ address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
85
+ decimals: 6
86
+ },
87
+ [A.BSC]: {
88
+ address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
89
+ decimals: 18
90
+ },
91
+ [A.TRON]: {
92
+ address: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
93
+ decimals: 6
94
+ }
95
+ },
96
+ ALGO: {
97
+ [A.ALGORAND]: {
98
+ address: "native",
99
+ decimals: 6
100
+ }
101
+ }
18
102
  };
19
- const getHeaders = () => {
103
+ let _ = null;
104
+ const Ze = () => R(void 0, null, function* () {
105
+ if (_)
106
+ return _;
107
+ try {
108
+ if (typeof window != "undefined" && window.Web3)
109
+ return _ = window.Web3, _;
110
+ const s = yield import("web3");
111
+ return _ = s.default || s.Web3 || s, _;
112
+ } catch (s) {
113
+ throw console.error("Failed to load Web3:", s), new Error("Web3 is required for blockchain transactions. Please ensure web3 is installed: npm install web3");
114
+ }
115
+ }), ue = () => {
116
+ const s = {
117
+ [N.METAMASK]: !1,
118
+ [N.TRUST_WALLET]: !1,
119
+ [N.TRONLINK]: !1,
120
+ [N.LUTE]: !1
121
+ };
122
+ if (typeof window == "undefined")
123
+ return s;
124
+ try {
125
+ s[N.METAMASK] = !!(window.ethereum && window.ethereum.isMetaMask), s[N.TRONLINK] = !!window.tronWeb, s[N.TRUST_WALLET] = !!(window.ethereum && window.ethereum.isTrust), s[N.LUTE] = !!(window.algorand && window.algorand.isLute);
126
+ } catch (r) {
127
+ console.warn("Error detecting wallets:", r);
128
+ }
129
+ return s;
130
+ }, Ne = (s) => {
131
+ const r = de[s];
132
+ if (!r)
133
+ return [];
134
+ const t = ue();
135
+ return r.supportedWallets.filter((c) => t[c]);
136
+ }, et = (s, r) => R(void 0, null, function* () {
137
+ switch (s) {
138
+ case N.METAMASK:
139
+ return yield tt(r);
140
+ case N.TRONLINK:
141
+ return yield rt();
142
+ case N.TRUST_WALLET:
143
+ return yield st(r);
144
+ case N.LUTE:
145
+ return yield nt();
146
+ default:
147
+ throw new Error(`Unsupported wallet type: ${s}`);
148
+ }
149
+ }), tt = (s) => R(void 0, null, function* () {
150
+ if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isMetaMask)
151
+ throw new Error("MetaMask is not installed. Please install MetaMask extension.");
152
+ try {
153
+ const r = yield window.ethereum.request({
154
+ method: "eth_requestAccounts"
155
+ });
156
+ if (!r || r.length === 0)
157
+ throw new Error("No accounts found. Please unlock MetaMask.");
158
+ const t = de[s];
159
+ return t && t.chainId && (yield Ee(t)), {
160
+ address: r[0],
161
+ network: s,
162
+ walletType: N.METAMASK
163
+ };
164
+ } catch (r) {
165
+ throw r.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect MetaMask: ${r.message}`);
166
+ }
167
+ }), rt = () => R(void 0, null, function* () {
168
+ var c;
169
+ if (typeof window == "undefined" || !window.tronWeb)
170
+ throw new Error("TronLink is not installed. Please install TronLink extension.");
171
+ let s = 0;
172
+ const r = 10;
173
+ for (; !window.tronWeb.ready && s < r; )
174
+ yield new Promise((u) => setTimeout(u, 1e3)), s++;
175
+ if (!window.tronWeb.ready)
176
+ throw new Error("TronLink is not ready. Please unlock your TronLink wallet and try again.");
177
+ const t = (c = window.tronWeb.defaultAddress) == null ? void 0 : c.base58;
178
+ if (!t)
179
+ throw new Error("No account found in TronLink. Please make sure you have an account set up.");
20
180
  return {
21
- "Content-Type": "application/json",
22
- "x-api-key": apiConfig.apiKey,
23
- "x-api-secret": apiConfig.apiSecret
181
+ address: t,
182
+ network: A.TRON,
183
+ walletType: N.TRONLINK
24
184
  };
25
- };
26
- const createPayment = async (paymentData) => {
185
+ }), st = (s) => R(void 0, null, function* () {
186
+ if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isTrust)
187
+ throw new Error("Trust Wallet is not installed. Please install Trust Wallet extension.");
27
188
  try {
28
- console.log("Creating payment with data:", paymentData);
29
- console.log("API URL:", `${apiConfig.apiUrl}/api/payments/create`);
30
- const enhancedPaymentData = { ...paymentData };
31
- if (apiConfig.merchantWalletAddress && !enhancedPaymentData.walletAddress) {
32
- enhancedPaymentData.walletAddress = apiConfig.merchantWalletAddress;
33
- }
34
- if (apiConfig.merchantSolWalletAddress && !enhancedPaymentData.solWalletAddress) {
35
- enhancedPaymentData.solWalletAddress = apiConfig.merchantSolWalletAddress;
36
- }
37
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/create`, {
38
- method: "POST",
39
- headers: getHeaders(),
40
- body: JSON.stringify(enhancedPaymentData)
189
+ const r = yield window.ethereum.request({
190
+ method: "eth_requestAccounts"
41
191
  });
42
- console.log("Create payment response status:", response.status);
43
- if (!response.ok) {
44
- const errorData = await response.json();
45
- console.error("Error creating payment:", errorData);
46
- throw new Error(errorData.error || `Failed to create payment: ${response.status}`);
47
- }
48
- const data = await response.json();
49
- console.log("Create payment response data:", data);
50
- if (data && data.payment) {
51
- if (!data.payment.walletAddress && apiConfig.merchantWalletAddress) {
52
- data.payment.walletAddress = apiConfig.merchantWalletAddress;
53
- }
54
- if (!data.payment.solWalletAddress && apiConfig.merchantSolWalletAddress) {
55
- data.payment.solWalletAddress = apiConfig.merchantSolWalletAddress;
56
- }
57
- }
58
- return data;
59
- } catch (error) {
60
- console.error("Create payment error:", error);
61
- throw error;
192
+ if (!r || r.length === 0)
193
+ throw new Error("No accounts found. Please unlock Trust Wallet.");
194
+ const t = de[s];
195
+ return t && t.chainId && (yield Ee(t)), {
196
+ address: r[0],
197
+ network: s,
198
+ walletType: N.TRUST_WALLET
199
+ };
200
+ } catch (r) {
201
+ throw r.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect Trust Wallet: ${r.message}`);
62
202
  }
63
- };
64
- const getPayment = async (paymentId) => {
203
+ }), nt = () => R(void 0, null, function* () {
204
+ if (typeof window == "undefined" || !window.algorand || !window.algorand.isLute)
205
+ throw new Error("Lute wallet is not installed. Please install Lute wallet extension.");
65
206
  try {
66
- console.log("Getting payment:", paymentId);
67
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/${paymentId}`, {
68
- method: "GET",
69
- headers: getHeaders()
207
+ const s = yield window.algorand.connect();
208
+ if (!s || s.length === 0)
209
+ throw new Error("No accounts found. Please unlock Lute wallet.");
210
+ return {
211
+ address: s[0],
212
+ network: A.ALGORAND,
213
+ walletType: N.LUTE
214
+ };
215
+ } catch (s) {
216
+ throw new Error(`Failed to connect Lute wallet: ${s.message}`);
217
+ }
218
+ }), Ee = (s) => R(void 0, null, function* () {
219
+ if (typeof window == "undefined" || !window.ethereum)
220
+ throw new Error("Ethereum provider not found");
221
+ try {
222
+ yield window.ethereum.request({
223
+ method: "wallet_switchEthereumChain",
224
+ params: [{ chainId: s.chainId }]
70
225
  });
71
- if (!response.ok) {
72
- const errorData = await response.json();
73
- console.error("Error getting payment:", errorData);
74
- throw new Error(errorData.error || `Failed to get payment: ${response.status}`);
75
- }
76
- const data = await response.json();
77
- console.log("Get payment response:", data);
78
- if (data && data.payment) {
79
- if (!data.payment.walletAddress && apiConfig.merchantWalletAddress) {
80
- data.payment.walletAddress = apiConfig.merchantWalletAddress;
81
- }
82
- if (!data.payment.solWalletAddress && apiConfig.merchantSolWalletAddress) {
83
- data.payment.solWalletAddress = apiConfig.merchantSolWalletAddress;
226
+ } catch (r) {
227
+ if (r.code === 4902)
228
+ try {
229
+ yield window.ethereum.request({
230
+ method: "wallet_addEthereumChain",
231
+ params: [s]
232
+ });
233
+ } catch (t) {
234
+ throw new Error(`Failed to add ${s.chainName} to wallet: ${t.message}`);
84
235
  }
85
- }
86
- return data;
87
- } catch (error) {
88
- console.error("Get payment error:", error);
89
- throw error;
236
+ else
237
+ throw r.code === 4001 ? new Error("User rejected network switch request") : new Error(`Failed to switch to ${s.chainName}: ${r.message}`);
90
238
  }
239
+ }), ot = (s, r) => R(void 0, null, function* () {
240
+ const { walletType: t, network: c, address: u } = s, { to: h, amount: y, tokenAddress: w, tokenDecimals: e } = r;
241
+ switch (t) {
242
+ case N.METAMASK:
243
+ case N.TRUST_WALLET:
244
+ return yield at(u, h, y, w, e);
245
+ case N.TRONLINK:
246
+ return yield lt(h, y, w, e);
247
+ case N.LUTE:
248
+ return yield it(u, h, y);
249
+ default:
250
+ throw new Error(`Unsupported wallet type: ${t}`);
251
+ }
252
+ }), at = (s, r, t, c, u) => R(void 0, null, function* () {
253
+ if (typeof window == "undefined" || !window.ethereum)
254
+ throw new Error("Ethereum provider not found");
255
+ try {
256
+ const h = yield Ze(), y = new h(window.ethereum), w = y.utils.toBN(
257
+ Math.floor(parseFloat(t) * Math.pow(10, u || 18))
258
+ );
259
+ if (c && c !== "native") {
260
+ const e = [
261
+ {
262
+ constant: !1,
263
+ inputs: [
264
+ { name: "_to", type: "address" },
265
+ { name: "_value", type: "uint256" }
266
+ ],
267
+ name: "transfer",
268
+ outputs: [{ name: "", type: "bool" }],
269
+ payable: !1,
270
+ stateMutability: "nonpayable",
271
+ type: "function"
272
+ }
273
+ ];
274
+ return (yield new y.eth.Contract(e, c).methods.transfer(r, w).send({ from: s })).transactionHash;
275
+ } else
276
+ return (yield y.eth.sendTransaction({
277
+ from: s,
278
+ to: r,
279
+ value: w
280
+ })).transactionHash;
281
+ } catch (h) {
282
+ throw h.code === 4001 ? new Error("Transaction was rejected by user") : new Error(`Transaction failed: ${h.message}`);
283
+ }
284
+ }), lt = (s, r, t, c) => R(void 0, null, function* () {
285
+ if (typeof window == "undefined" || !window.tronWeb || !window.tronWeb.ready)
286
+ throw new Error("TronLink is not ready");
287
+ try {
288
+ const u = Math.floor(parseFloat(r) * Math.pow(10, c || 6));
289
+ return t && t !== "native" ? yield (yield window.tronWeb.contract().at(t)).transfer(s, u).send({
290
+ feeLimit: 1e8,
291
+ callValue: 0
292
+ }) : (yield window.tronWeb.trx.sendTransaction(s, u)).txid;
293
+ } catch (u) {
294
+ throw new Error(`TRON transaction failed: ${u.message}`);
295
+ }
296
+ }), it = (s, r, t) => R(void 0, null, function* () {
297
+ if (typeof window == "undefined" || !window.algorand)
298
+ throw new Error("Algorand wallet is not available");
299
+ try {
300
+ const c = Math.floor(parseFloat(t) * 1e6), u = {
301
+ from: s,
302
+ to: r,
303
+ amount: c,
304
+ type: "pay"
305
+ }, h = yield window.algorand.signTransaction(u);
306
+ return (yield window.algorand.sendTransaction(h)).txId;
307
+ } catch (c) {
308
+ throw new Error(`Algorand transaction failed: ${c.message}`);
309
+ }
310
+ }), ct = (s) => ({
311
+ [N.METAMASK]: "https://metamask.io/",
312
+ [N.TRONLINK]: "https://www.tronlink.org/",
313
+ [N.TRUST_WALLET]: "https://trustwallet.com/",
314
+ [N.LUTE]: "https://lute.app/"
315
+ })[s] || "";
316
+ let P = {
317
+ apiKey: null,
318
+ apiSecret: null,
319
+ apiUrl: "http://localhost:9000",
320
+ merchantWalletAddresses: {}
321
+ // Changed to object for multi-network support
91
322
  };
92
- const processPayment = async (processData) => {
323
+ const dt = (s) => {
324
+ P = z(z({}, P), s), console.log("API initialized with:", {
325
+ apiUrl: P.apiUrl,
326
+ apiKey: P.apiKey ? `${P.apiKey.substring(0, 6)}...` : null,
327
+ hasWalletAddresses: Object.keys(P.merchantWalletAddresses || {}).length > 0
328
+ });
329
+ }, J = () => ({
330
+ "Content-Type": "application/json",
331
+ "x-api-key": P.apiKey,
332
+ "x-api-secret": P.apiSecret
333
+ }), ut = (s) => R(void 0, null, function* () {
93
334
  try {
94
- console.log("Processing payment with data:", processData);
95
- console.log("API URL:", `${apiConfig.apiUrl}/api/payments/process`);
96
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/process`, {
335
+ console.log("Creating payment with data:", s), console.log("API URL:", `${P.apiUrl}/api/payments/create`);
336
+ const r = we(z({}, s), {
337
+ merchantWalletAddresses: z(z({}, P.merchantWalletAddresses), s.merchantWalletAddresses)
338
+ }), t = yield fetch(`${P.apiUrl}/api/payments/create`, {
97
339
  method: "POST",
98
- headers: getHeaders(),
99
- body: JSON.stringify(processData)
340
+ headers: J(),
341
+ body: JSON.stringify(r)
100
342
  });
101
- console.log("Process payment response status:", response.status);
102
- if (!response.ok) {
103
- const errorData = await response.json();
104
- console.error("Error processing payment:", errorData);
105
- throw new Error(errorData.error || `Failed to process payment: ${response.status}`);
106
- }
107
- const data = await response.json();
108
- console.log("Process payment response data:", data);
109
- return data;
110
- } catch (error) {
111
- console.error("Process payment error:", error);
112
- throw error;
343
+ if (console.log("Create payment response status:", t.status), !t.ok) {
344
+ const u = yield t.json();
345
+ throw console.error("Error creating payment:", u), new Error(u.error || `Failed to create payment: ${t.status}`);
346
+ }
347
+ const c = yield t.json();
348
+ return console.log("Create payment response data:", c), c;
349
+ } catch (r) {
350
+ throw console.error("Create payment error:", r), r;
113
351
  }
114
- };
115
- const getMerchantWalletAddresses = async () => {
116
- var _a, _b;
352
+ }), It = (s) => R(void 0, null, function* () {
117
353
  try {
118
- const response = await fetch(`${apiConfig.apiUrl}/api/merchants/profile`, {
354
+ console.log("Getting payment:", s);
355
+ const r = yield fetch(`${P.apiUrl}/api/payments/${s}`, {
119
356
  method: "GET",
120
- headers: getHeaders()
357
+ headers: J()
121
358
  });
122
- if (!response.ok) {
123
- const errorData = await response.json();
124
- throw new Error(errorData.error || `Failed to get merchant profile: ${response.status}`);
125
- }
126
- const data = await response.json();
127
- if (data.merchant) {
128
- if (data.merchant.walletAddress) {
129
- apiConfig.merchantWalletAddress = data.merchant.walletAddress;
130
- }
131
- if (data.merchant.solWalletAddress) {
132
- apiConfig.merchantSolWalletAddress = data.merchant.solWalletAddress;
133
- }
134
- }
135
- return {
136
- walletAddress: ((_a = data.merchant) == null ? void 0 : _a.walletAddress) || null,
137
- solWalletAddress: ((_b = data.merchant) == null ? void 0 : _b.solWalletAddress) || null
138
- };
139
- } catch (error) {
140
- console.error("Get merchant wallet addresses error:", error);
141
- throw error;
359
+ if (!r.ok) {
360
+ const c = yield r.json();
361
+ throw console.error("Error getting payment:", c), new Error(c.error || `Failed to get payment: ${r.status}`);
362
+ }
363
+ const t = yield r.json();
364
+ return console.log("Get payment response:", t), t;
365
+ } catch (r) {
366
+ throw console.error("Get payment error:", r), r;
142
367
  }
143
- };
144
- const isMetaMaskInstalled = () => {
145
- return typeof window !== "undefined" && typeof window.ethereum !== "undefined";
146
- };
147
- const connectWallet = async () => {
148
- if (!isMetaMaskInstalled()) {
149
- throw new Error("MetaMask is not installed");
368
+ }), ht = (s) => R(void 0, null, function* () {
369
+ try {
370
+ console.log("Processing payment with data:", s), console.log("API URL:", `${P.apiUrl}/api/payments/process`);
371
+ const r = yield fetch(`${P.apiUrl}/api/payments/process`, {
372
+ method: "POST",
373
+ headers: J(),
374
+ body: JSON.stringify(s)
375
+ });
376
+ if (console.log("Process payment response status:", r.status), !r.ok) {
377
+ const c = yield r.json();
378
+ throw console.error("Error processing payment:", c), new Error(c.error || `Failed to process payment: ${r.status}`);
379
+ }
380
+ const t = yield r.json();
381
+ return console.log("Process payment response data:", t), t;
382
+ } catch (r) {
383
+ throw console.error("Process payment error:", r), r;
150
384
  }
385
+ }), Ft = () => R(void 0, null, function* () {
151
386
  try {
152
- const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
153
- return accounts;
154
- } catch (error) {
155
- console.error("Error connecting to wallet:", error);
156
- throw error;
387
+ const s = yield fetch(`${P.apiUrl}/api/networks`, {
388
+ method: "GET",
389
+ headers: J()
390
+ });
391
+ if (!s.ok) {
392
+ const t = yield s.json();
393
+ throw new Error(t.error || `Failed to get networks: ${s.status}`);
394
+ }
395
+ return yield s.json();
396
+ } catch (s) {
397
+ throw console.error("Get supported networks error:", s), s;
157
398
  }
158
- };
159
- const sendTransaction = async (txParams) => {
160
- if (!isMetaMaskInstalled()) {
161
- throw new Error("MetaMask is not installed");
399
+ }), Bt = () => R(void 0, null, function* () {
400
+ try {
401
+ const s = yield fetch(`${P.apiUrl}/api/merchants/profile`, {
402
+ method: "GET",
403
+ headers: J()
404
+ });
405
+ if (!s.ok) {
406
+ const t = yield s.json();
407
+ throw new Error(t.error || `Failed to get merchant profile: ${s.status}`);
408
+ }
409
+ const r = yield s.json();
410
+ return r.merchant && r.merchant.walletAddresses && (P.merchantWalletAddresses = z(z({}, P.merchantWalletAddresses), r.merchant.walletAddresses)), r;
411
+ } catch (s) {
412
+ throw console.error("Get merchant profile error:", s), s;
162
413
  }
414
+ }), Wt = (s, r) => R(void 0, null, function* () {
163
415
  try {
164
- const txHash = await window.ethereum.request({
165
- method: "eth_sendTransaction",
166
- params: [txParams]
416
+ const t = yield fetch(`${P.apiUrl}/api/wallets/validate`, {
417
+ method: "POST",
418
+ headers: J(),
419
+ body: JSON.stringify({ address: s, network: r })
167
420
  });
168
- return txHash;
169
- } catch (error) {
170
- console.error("Error sending transaction:", error);
171
- throw error;
421
+ if (!t.ok) {
422
+ const u = yield t.json();
423
+ throw new Error(u.error || `Failed to validate address: ${t.status}`);
424
+ }
425
+ return yield t.json();
426
+ } catch (t) {
427
+ throw console.error("Validate wallet address error:", t), t;
172
428
  }
429
+ }), Qt = (s = "ethereum") => {
430
+ const t = {
431
+ ethereum: "0x",
432
+ bsc: "0x",
433
+ tron: "",
434
+ algorand: ""
435
+ }[s] || "0x", c = Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
436
+ return `${t}${c}`;
173
437
  };
174
- var jsxRuntime = { exports: {} };
175
- var reactJsxRuntime_production_min = {};
438
+ var be = { exports: {} }, ne = {};
176
439
  /**
177
440
  * @license React
178
441
  * react-jsx-runtime.production.min.js
@@ -182,1093 +445,129 @@ var reactJsxRuntime_production_min = {};
182
445
  * This source code is licensed under the MIT license found in the
183
446
  * LICENSE file in the root directory of this source tree.
184
447
  */
185
- var hasRequiredReactJsxRuntime_production_min;
186
- function requireReactJsxRuntime_production_min() {
187
- if (hasRequiredReactJsxRuntime_production_min)
188
- return reactJsxRuntime_production_min;
189
- hasRequiredReactJsxRuntime_production_min = 1;
190
- var f = React, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
191
- function q(c, a, g) {
192
- var b, d = {}, e = null, h = null;
193
- void 0 !== g && (e = "" + g);
194
- void 0 !== a.key && (e = "" + a.key);
195
- void 0 !== a.ref && (h = a.ref);
196
- for (b in a)
197
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
198
- if (c && c.defaultProps)
199
- for (b in a = c.defaultProps, a)
200
- void 0 === d[b] && (d[b] = a[b]);
201
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
202
- }
203
- reactJsxRuntime_production_min.Fragment = l;
204
- reactJsxRuntime_production_min.jsx = q;
205
- reactJsxRuntime_production_min.jsxs = q;
206
- return reactJsxRuntime_production_min;
448
+ var mt = S, ft = Symbol.for("react.element"), gt = Symbol.for("react.fragment"), wt = Object.prototype.hasOwnProperty, pt = mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, yt = { key: !0, ref: !0, __self: !0, __source: !0 };
449
+ function Ae(s, r, t) {
450
+ var c, u = {}, h = null, y = null;
451
+ t !== void 0 && (h = "" + t), r.key !== void 0 && (h = "" + r.key), r.ref !== void 0 && (y = r.ref);
452
+ for (c in r)
453
+ wt.call(r, c) && !yt.hasOwnProperty(c) && (u[c] = r[c]);
454
+ if (s && s.defaultProps)
455
+ for (c in r = s.defaultProps, r)
456
+ u[c] === void 0 && (u[c] = r[c]);
457
+ return { $$typeof: ft, type: s, key: h, ref: y, props: u, _owner: pt.current };
207
458
  }
208
- var reactJsxRuntime_development = {};
209
- /**
210
- * @license React
211
- * react-jsx-runtime.development.js
212
- *
213
- * Copyright (c) Facebook, Inc. and its affiliates.
214
- *
215
- * This source code is licensed under the MIT license found in the
216
- * LICENSE file in the root directory of this source tree.
217
- */
218
- var hasRequiredReactJsxRuntime_development;
219
- function requireReactJsxRuntime_development() {
220
- if (hasRequiredReactJsxRuntime_development)
221
- return reactJsxRuntime_development;
222
- hasRequiredReactJsxRuntime_development = 1;
223
- if (process.env.NODE_ENV !== "production") {
224
- (function() {
225
- var React$1 = React;
226
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
227
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
228
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
229
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
230
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
231
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
232
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
233
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
234
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
235
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
236
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
237
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
238
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
239
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
240
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
241
- function getIteratorFn(maybeIterable) {
242
- if (maybeIterable === null || typeof maybeIterable !== "object") {
243
- return null;
244
- }
245
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
246
- if (typeof maybeIterator === "function") {
247
- return maybeIterator;
248
- }
249
- return null;
250
- }
251
- var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
252
- function error(format) {
253
- {
254
- {
255
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
256
- args[_key2 - 1] = arguments[_key2];
257
- }
258
- printWarning("error", format, args);
259
- }
260
- }
261
- }
262
- function printWarning(level, format, args) {
263
- {
264
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
265
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
266
- if (stack !== "") {
267
- format += "%s";
268
- args = args.concat([stack]);
269
- }
270
- var argsWithFormat = args.map(function(item) {
271
- return String(item);
272
- });
273
- argsWithFormat.unshift("Warning: " + format);
274
- Function.prototype.apply.call(console[level], console, argsWithFormat);
275
- }
276
- }
277
- var enableScopeAPI = false;
278
- var enableCacheElement = false;
279
- var enableTransitionTracing = false;
280
- var enableLegacyHidden = false;
281
- var enableDebugTracing = false;
282
- var REACT_MODULE_REFERENCE;
283
- {
284
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
285
- }
286
- function isValidElementType(type) {
287
- if (typeof type === "string" || typeof type === "function") {
288
- return true;
289
- }
290
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
291
- return true;
292
- }
293
- if (typeof type === "object" && type !== null) {
294
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
295
- // types supported by any Flight configuration anywhere since
296
- // we don't know which Flight build this will end up being used
297
- // with.
298
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
299
- return true;
300
- }
301
- }
302
- return false;
303
- }
304
- function getWrappedName(outerType, innerType, wrapperName) {
305
- var displayName = outerType.displayName;
306
- if (displayName) {
307
- return displayName;
308
- }
309
- var functionName = innerType.displayName || innerType.name || "";
310
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
311
- }
312
- function getContextName(type) {
313
- return type.displayName || "Context";
314
- }
315
- function getComponentNameFromType(type) {
316
- if (type == null) {
317
- return null;
318
- }
319
- {
320
- if (typeof type.tag === "number") {
321
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
322
- }
323
- }
324
- if (typeof type === "function") {
325
- return type.displayName || type.name || null;
326
- }
327
- if (typeof type === "string") {
328
- return type;
329
- }
330
- switch (type) {
331
- case REACT_FRAGMENT_TYPE:
332
- return "Fragment";
333
- case REACT_PORTAL_TYPE:
334
- return "Portal";
335
- case REACT_PROFILER_TYPE:
336
- return "Profiler";
337
- case REACT_STRICT_MODE_TYPE:
338
- return "StrictMode";
339
- case REACT_SUSPENSE_TYPE:
340
- return "Suspense";
341
- case REACT_SUSPENSE_LIST_TYPE:
342
- return "SuspenseList";
343
- }
344
- if (typeof type === "object") {
345
- switch (type.$$typeof) {
346
- case REACT_CONTEXT_TYPE:
347
- var context = type;
348
- return getContextName(context) + ".Consumer";
349
- case REACT_PROVIDER_TYPE:
350
- var provider = type;
351
- return getContextName(provider._context) + ".Provider";
352
- case REACT_FORWARD_REF_TYPE:
353
- return getWrappedName(type, type.render, "ForwardRef");
354
- case REACT_MEMO_TYPE:
355
- var outerName = type.displayName || null;
356
- if (outerName !== null) {
357
- return outerName;
358
- }
359
- return getComponentNameFromType(type.type) || "Memo";
360
- case REACT_LAZY_TYPE: {
361
- var lazyComponent = type;
362
- var payload = lazyComponent._payload;
363
- var init = lazyComponent._init;
364
- try {
365
- return getComponentNameFromType(init(payload));
366
- } catch (x) {
367
- return null;
368
- }
369
- }
370
- }
371
- }
372
- return null;
373
- }
374
- var assign = Object.assign;
375
- var disabledDepth = 0;
376
- var prevLog;
377
- var prevInfo;
378
- var prevWarn;
379
- var prevError;
380
- var prevGroup;
381
- var prevGroupCollapsed;
382
- var prevGroupEnd;
383
- function disabledLog() {
384
- }
385
- disabledLog.__reactDisabledLog = true;
386
- function disableLogs() {
387
- {
388
- if (disabledDepth === 0) {
389
- prevLog = console.log;
390
- prevInfo = console.info;
391
- prevWarn = console.warn;
392
- prevError = console.error;
393
- prevGroup = console.group;
394
- prevGroupCollapsed = console.groupCollapsed;
395
- prevGroupEnd = console.groupEnd;
396
- var props = {
397
- configurable: true,
398
- enumerable: true,
399
- value: disabledLog,
400
- writable: true
401
- };
402
- Object.defineProperties(console, {
403
- info: props,
404
- log: props,
405
- warn: props,
406
- error: props,
407
- group: props,
408
- groupCollapsed: props,
409
- groupEnd: props
410
- });
411
- }
412
- disabledDepth++;
413
- }
414
- }
415
- function reenableLogs() {
416
- {
417
- disabledDepth--;
418
- if (disabledDepth === 0) {
419
- var props = {
420
- configurable: true,
421
- enumerable: true,
422
- writable: true
423
- };
424
- Object.defineProperties(console, {
425
- log: assign({}, props, {
426
- value: prevLog
427
- }),
428
- info: assign({}, props, {
429
- value: prevInfo
430
- }),
431
- warn: assign({}, props, {
432
- value: prevWarn
433
- }),
434
- error: assign({}, props, {
435
- value: prevError
436
- }),
437
- group: assign({}, props, {
438
- value: prevGroup
439
- }),
440
- groupCollapsed: assign({}, props, {
441
- value: prevGroupCollapsed
442
- }),
443
- groupEnd: assign({}, props, {
444
- value: prevGroupEnd
445
- })
446
- });
447
- }
448
- if (disabledDepth < 0) {
449
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
450
- }
451
- }
452
- }
453
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
454
- var prefix;
455
- function describeBuiltInComponentFrame(name, source, ownerFn) {
456
- {
457
- if (prefix === void 0) {
458
- try {
459
- throw Error();
460
- } catch (x) {
461
- var match = x.stack.trim().match(/\n( *(at )?)/);
462
- prefix = match && match[1] || "";
463
- }
464
- }
465
- return "\n" + prefix + name;
466
- }
467
- }
468
- var reentry = false;
469
- var componentFrameCache;
470
- {
471
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
472
- componentFrameCache = new PossiblyWeakMap();
473
- }
474
- function describeNativeComponentFrame(fn, construct) {
475
- if (!fn || reentry) {
476
- return "";
477
- }
478
- {
479
- var frame = componentFrameCache.get(fn);
480
- if (frame !== void 0) {
481
- return frame;
482
- }
483
- }
484
- var control;
485
- reentry = true;
486
- var previousPrepareStackTrace = Error.prepareStackTrace;
487
- Error.prepareStackTrace = void 0;
488
- var previousDispatcher;
489
- {
490
- previousDispatcher = ReactCurrentDispatcher.current;
491
- ReactCurrentDispatcher.current = null;
492
- disableLogs();
493
- }
494
- try {
495
- if (construct) {
496
- var Fake = function() {
497
- throw Error();
498
- };
499
- Object.defineProperty(Fake.prototype, "props", {
500
- set: function() {
501
- throw Error();
502
- }
503
- });
504
- if (typeof Reflect === "object" && Reflect.construct) {
505
- try {
506
- Reflect.construct(Fake, []);
507
- } catch (x) {
508
- control = x;
509
- }
510
- Reflect.construct(fn, [], Fake);
511
- } else {
512
- try {
513
- Fake.call();
514
- } catch (x) {
515
- control = x;
516
- }
517
- fn.call(Fake.prototype);
518
- }
519
- } else {
520
- try {
521
- throw Error();
522
- } catch (x) {
523
- control = x;
524
- }
525
- fn();
526
- }
527
- } catch (sample) {
528
- if (sample && control && typeof sample.stack === "string") {
529
- var sampleLines = sample.stack.split("\n");
530
- var controlLines = control.stack.split("\n");
531
- var s = sampleLines.length - 1;
532
- var c = controlLines.length - 1;
533
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
534
- c--;
535
- }
536
- for (; s >= 1 && c >= 0; s--, c--) {
537
- if (sampleLines[s] !== controlLines[c]) {
538
- if (s !== 1 || c !== 1) {
539
- do {
540
- s--;
541
- c--;
542
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
543
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
544
- if (fn.displayName && _frame.includes("<anonymous>")) {
545
- _frame = _frame.replace("<anonymous>", fn.displayName);
546
- }
547
- {
548
- if (typeof fn === "function") {
549
- componentFrameCache.set(fn, _frame);
550
- }
551
- }
552
- return _frame;
553
- }
554
- } while (s >= 1 && c >= 0);
555
- }
556
- break;
557
- }
558
- }
559
- }
560
- } finally {
561
- reentry = false;
562
- {
563
- ReactCurrentDispatcher.current = previousDispatcher;
564
- reenableLogs();
565
- }
566
- Error.prepareStackTrace = previousPrepareStackTrace;
567
- }
568
- var name = fn ? fn.displayName || fn.name : "";
569
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
570
- {
571
- if (typeof fn === "function") {
572
- componentFrameCache.set(fn, syntheticFrame);
573
- }
574
- }
575
- return syntheticFrame;
576
- }
577
- function describeFunctionComponentFrame(fn, source, ownerFn) {
578
- {
579
- return describeNativeComponentFrame(fn, false);
580
- }
581
- }
582
- function shouldConstruct(Component) {
583
- var prototype = Component.prototype;
584
- return !!(prototype && prototype.isReactComponent);
585
- }
586
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
587
- if (type == null) {
588
- return "";
589
- }
590
- if (typeof type === "function") {
591
- {
592
- return describeNativeComponentFrame(type, shouldConstruct(type));
593
- }
594
- }
595
- if (typeof type === "string") {
596
- return describeBuiltInComponentFrame(type);
597
- }
598
- switch (type) {
599
- case REACT_SUSPENSE_TYPE:
600
- return describeBuiltInComponentFrame("Suspense");
601
- case REACT_SUSPENSE_LIST_TYPE:
602
- return describeBuiltInComponentFrame("SuspenseList");
603
- }
604
- if (typeof type === "object") {
605
- switch (type.$$typeof) {
606
- case REACT_FORWARD_REF_TYPE:
607
- return describeFunctionComponentFrame(type.render);
608
- case REACT_MEMO_TYPE:
609
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
610
- case REACT_LAZY_TYPE: {
611
- var lazyComponent = type;
612
- var payload = lazyComponent._payload;
613
- var init = lazyComponent._init;
614
- try {
615
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
616
- } catch (x) {
617
- }
618
- }
619
- }
620
- }
621
- return "";
622
- }
623
- var hasOwnProperty = Object.prototype.hasOwnProperty;
624
- var loggedTypeFailures = {};
625
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
626
- function setCurrentlyValidatingElement(element) {
627
- {
628
- if (element) {
629
- var owner = element._owner;
630
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
631
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
632
- } else {
633
- ReactDebugCurrentFrame.setExtraStackFrame(null);
634
- }
635
- }
636
- }
637
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
638
- {
639
- var has = Function.call.bind(hasOwnProperty);
640
- for (var typeSpecName in typeSpecs) {
641
- if (has(typeSpecs, typeSpecName)) {
642
- var error$1 = void 0;
643
- try {
644
- if (typeof typeSpecs[typeSpecName] !== "function") {
645
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
646
- err.name = "Invariant Violation";
647
- throw err;
648
- }
649
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
650
- } catch (ex) {
651
- error$1 = ex;
652
- }
653
- if (error$1 && !(error$1 instanceof Error)) {
654
- setCurrentlyValidatingElement(element);
655
- error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
656
- setCurrentlyValidatingElement(null);
657
- }
658
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
659
- loggedTypeFailures[error$1.message] = true;
660
- setCurrentlyValidatingElement(element);
661
- error("Failed %s type: %s", location, error$1.message);
662
- setCurrentlyValidatingElement(null);
663
- }
664
- }
665
- }
666
- }
667
- }
668
- var isArrayImpl = Array.isArray;
669
- function isArray(a) {
670
- return isArrayImpl(a);
671
- }
672
- function typeName(value) {
673
- {
674
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
675
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
676
- return type;
677
- }
678
- }
679
- function willCoercionThrow(value) {
680
- {
681
- try {
682
- testStringCoercion(value);
683
- return false;
684
- } catch (e) {
685
- return true;
686
- }
687
- }
688
- }
689
- function testStringCoercion(value) {
690
- return "" + value;
691
- }
692
- function checkKeyStringCoercion(value) {
693
- {
694
- if (willCoercionThrow(value)) {
695
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
696
- return testStringCoercion(value);
697
- }
698
- }
699
- }
700
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
701
- var RESERVED_PROPS = {
702
- key: true,
703
- ref: true,
704
- __self: true,
705
- __source: true
706
- };
707
- var specialPropKeyWarningShown;
708
- var specialPropRefWarningShown;
709
- var didWarnAboutStringRefs;
710
- {
711
- didWarnAboutStringRefs = {};
712
- }
713
- function hasValidRef(config) {
714
- {
715
- if (hasOwnProperty.call(config, "ref")) {
716
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
717
- if (getter && getter.isReactWarning) {
718
- return false;
719
- }
720
- }
721
- }
722
- return config.ref !== void 0;
723
- }
724
- function hasValidKey(config) {
725
- {
726
- if (hasOwnProperty.call(config, "key")) {
727
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
728
- if (getter && getter.isReactWarning) {
729
- return false;
730
- }
731
- }
732
- }
733
- return config.key !== void 0;
734
- }
735
- function warnIfStringRefCannotBeAutoConverted(config, self) {
736
- {
737
- if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
738
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
739
- if (!didWarnAboutStringRefs[componentName]) {
740
- error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
741
- didWarnAboutStringRefs[componentName] = true;
742
- }
743
- }
744
- }
745
- }
746
- function defineKeyPropWarningGetter(props, displayName) {
747
- {
748
- var warnAboutAccessingKey = function() {
749
- if (!specialPropKeyWarningShown) {
750
- specialPropKeyWarningShown = true;
751
- error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
752
- }
753
- };
754
- warnAboutAccessingKey.isReactWarning = true;
755
- Object.defineProperty(props, "key", {
756
- get: warnAboutAccessingKey,
757
- configurable: true
758
- });
759
- }
760
- }
761
- function defineRefPropWarningGetter(props, displayName) {
762
- {
763
- var warnAboutAccessingRef = function() {
764
- if (!specialPropRefWarningShown) {
765
- specialPropRefWarningShown = true;
766
- error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
767
- }
768
- };
769
- warnAboutAccessingRef.isReactWarning = true;
770
- Object.defineProperty(props, "ref", {
771
- get: warnAboutAccessingRef,
772
- configurable: true
773
- });
774
- }
775
- }
776
- var ReactElement = function(type, key, ref, self, source, owner, props) {
777
- var element = {
778
- // This tag allows us to uniquely identify this as a React Element
779
- $$typeof: REACT_ELEMENT_TYPE,
780
- // Built-in properties that belong on the element
781
- type,
782
- key,
783
- ref,
784
- props,
785
- // Record the component responsible for creating this element.
786
- _owner: owner
787
- };
788
- {
789
- element._store = {};
790
- Object.defineProperty(element._store, "validated", {
791
- configurable: false,
792
- enumerable: false,
793
- writable: true,
794
- value: false
795
- });
796
- Object.defineProperty(element, "_self", {
797
- configurable: false,
798
- enumerable: false,
799
- writable: false,
800
- value: self
801
- });
802
- Object.defineProperty(element, "_source", {
803
- configurable: false,
804
- enumerable: false,
805
- writable: false,
806
- value: source
807
- });
808
- if (Object.freeze) {
809
- Object.freeze(element.props);
810
- Object.freeze(element);
811
- }
812
- }
813
- return element;
814
- };
815
- function jsxDEV(type, config, maybeKey, source, self) {
816
- {
817
- var propName;
818
- var props = {};
819
- var key = null;
820
- var ref = null;
821
- if (maybeKey !== void 0) {
822
- {
823
- checkKeyStringCoercion(maybeKey);
824
- }
825
- key = "" + maybeKey;
826
- }
827
- if (hasValidKey(config)) {
828
- {
829
- checkKeyStringCoercion(config.key);
830
- }
831
- key = "" + config.key;
832
- }
833
- if (hasValidRef(config)) {
834
- ref = config.ref;
835
- warnIfStringRefCannotBeAutoConverted(config, self);
836
- }
837
- for (propName in config) {
838
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
839
- props[propName] = config[propName];
840
- }
841
- }
842
- if (type && type.defaultProps) {
843
- var defaultProps = type.defaultProps;
844
- for (propName in defaultProps) {
845
- if (props[propName] === void 0) {
846
- props[propName] = defaultProps[propName];
847
- }
848
- }
849
- }
850
- if (key || ref) {
851
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
852
- if (key) {
853
- defineKeyPropWarningGetter(props, displayName);
854
- }
855
- if (ref) {
856
- defineRefPropWarningGetter(props, displayName);
857
- }
858
- }
859
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
860
- }
861
- }
862
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
863
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
864
- function setCurrentlyValidatingElement$1(element) {
865
- {
866
- if (element) {
867
- var owner = element._owner;
868
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
869
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
870
- } else {
871
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
872
- }
873
- }
874
- }
875
- var propTypesMisspellWarningShown;
876
- {
877
- propTypesMisspellWarningShown = false;
878
- }
879
- function isValidElement(object) {
880
- {
881
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
882
- }
883
- }
884
- function getDeclarationErrorAddendum() {
885
- {
886
- if (ReactCurrentOwner$1.current) {
887
- var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
888
- if (name) {
889
- return "\n\nCheck the render method of `" + name + "`.";
890
- }
891
- }
892
- return "";
893
- }
894
- }
895
- function getSourceInfoErrorAddendum(source) {
896
- {
897
- if (source !== void 0) {
898
- var fileName = source.fileName.replace(/^.*[\\\/]/, "");
899
- var lineNumber = source.lineNumber;
900
- return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
901
- }
902
- return "";
903
- }
904
- }
905
- var ownerHasKeyUseWarning = {};
906
- function getCurrentComponentErrorInfo(parentType) {
907
- {
908
- var info = getDeclarationErrorAddendum();
909
- if (!info) {
910
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
911
- if (parentName) {
912
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
913
- }
914
- }
915
- return info;
916
- }
917
- }
918
- function validateExplicitKey(element, parentType) {
919
- {
920
- if (!element._store || element._store.validated || element.key != null) {
921
- return;
922
- }
923
- element._store.validated = true;
924
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
925
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
926
- return;
927
- }
928
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
929
- var childOwner = "";
930
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
931
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
932
- }
933
- setCurrentlyValidatingElement$1(element);
934
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
935
- setCurrentlyValidatingElement$1(null);
936
- }
937
- }
938
- function validateChildKeys(node, parentType) {
939
- {
940
- if (typeof node !== "object") {
941
- return;
942
- }
943
- if (isArray(node)) {
944
- for (var i = 0; i < node.length; i++) {
945
- var child = node[i];
946
- if (isValidElement(child)) {
947
- validateExplicitKey(child, parentType);
948
- }
949
- }
950
- } else if (isValidElement(node)) {
951
- if (node._store) {
952
- node._store.validated = true;
953
- }
954
- } else if (node) {
955
- var iteratorFn = getIteratorFn(node);
956
- if (typeof iteratorFn === "function") {
957
- if (iteratorFn !== node.entries) {
958
- var iterator = iteratorFn.call(node);
959
- var step;
960
- while (!(step = iterator.next()).done) {
961
- if (isValidElement(step.value)) {
962
- validateExplicitKey(step.value, parentType);
963
- }
964
- }
965
- }
966
- }
967
- }
968
- }
969
- }
970
- function validatePropTypes(element) {
971
- {
972
- var type = element.type;
973
- if (type === null || type === void 0 || typeof type === "string") {
974
- return;
975
- }
976
- var propTypes;
977
- if (typeof type === "function") {
978
- propTypes = type.propTypes;
979
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
980
- // Inner props are checked in the reconciler.
981
- type.$$typeof === REACT_MEMO_TYPE)) {
982
- propTypes = type.propTypes;
983
- } else {
984
- return;
985
- }
986
- if (propTypes) {
987
- var name = getComponentNameFromType(type);
988
- checkPropTypes(propTypes, element.props, "prop", name, element);
989
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
990
- propTypesMisspellWarningShown = true;
991
- var _name = getComponentNameFromType(type);
992
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
993
- }
994
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
995
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
996
- }
997
- }
998
- }
999
- function validateFragmentProps(fragment) {
1000
- {
1001
- var keys = Object.keys(fragment.props);
1002
- for (var i = 0; i < keys.length; i++) {
1003
- var key = keys[i];
1004
- if (key !== "children" && key !== "key") {
1005
- setCurrentlyValidatingElement$1(fragment);
1006
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
1007
- setCurrentlyValidatingElement$1(null);
1008
- break;
1009
- }
1010
- }
1011
- if (fragment.ref !== null) {
1012
- setCurrentlyValidatingElement$1(fragment);
1013
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
1014
- setCurrentlyValidatingElement$1(null);
1015
- }
1016
- }
1017
- }
1018
- var didWarnAboutKeySpread = {};
1019
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1020
- {
1021
- var validType = isValidElementType(type);
1022
- if (!validType) {
1023
- var info = "";
1024
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
1025
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
1026
- }
1027
- var sourceInfo = getSourceInfoErrorAddendum(source);
1028
- if (sourceInfo) {
1029
- info += sourceInfo;
1030
- } else {
1031
- info += getDeclarationErrorAddendum();
1032
- }
1033
- var typeString;
1034
- if (type === null) {
1035
- typeString = "null";
1036
- } else if (isArray(type)) {
1037
- typeString = "array";
1038
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
1039
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
1040
- info = " Did you accidentally export a JSX literal instead of a component?";
1041
- } else {
1042
- typeString = typeof type;
1043
- }
1044
- error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
1045
- }
1046
- var element = jsxDEV(type, props, key, source, self);
1047
- if (element == null) {
1048
- return element;
1049
- }
1050
- if (validType) {
1051
- var children = props.children;
1052
- if (children !== void 0) {
1053
- if (isStaticChildren) {
1054
- if (isArray(children)) {
1055
- for (var i = 0; i < children.length; i++) {
1056
- validateChildKeys(children[i], type);
1057
- }
1058
- if (Object.freeze) {
1059
- Object.freeze(children);
1060
- }
1061
- } else {
1062
- error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1063
- }
1064
- } else {
1065
- validateChildKeys(children, type);
1066
- }
1067
- }
1068
- }
1069
- {
1070
- if (hasOwnProperty.call(props, "key")) {
1071
- var componentName = getComponentNameFromType(type);
1072
- var keys = Object.keys(props).filter(function(k) {
1073
- return k !== "key";
1074
- });
1075
- var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1076
- if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1077
- var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
1078
- error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1079
- didWarnAboutKeySpread[componentName + beforeExample] = true;
1080
- }
1081
- }
1082
- }
1083
- if (type === REACT_FRAGMENT_TYPE) {
1084
- validateFragmentProps(element);
1085
- } else {
1086
- validatePropTypes(element);
1087
- }
1088
- return element;
1089
- }
1090
- }
1091
- function jsxWithValidationStatic(type, props, key) {
1092
- {
1093
- return jsxWithValidation(type, props, key, true);
1094
- }
1095
- }
1096
- function jsxWithValidationDynamic(type, props, key) {
1097
- {
1098
- return jsxWithValidation(type, props, key, false);
1099
- }
1100
- }
1101
- var jsx = jsxWithValidationDynamic;
1102
- var jsxs = jsxWithValidationStatic;
1103
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1104
- reactJsxRuntime_development.jsx = jsx;
1105
- reactJsxRuntime_development.jsxs = jsxs;
1106
- })();
1107
- }
1108
- return reactJsxRuntime_development;
1109
- }
1110
- if (process.env.NODE_ENV === "production") {
1111
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
1112
- } else {
1113
- jsxRuntime.exports = requireReactJsxRuntime_development();
1114
- }
1115
- var jsxRuntimeExports = jsxRuntime.exports;
1116
- const ThemeContext = createContext();
1117
- const useTheme = () => useContext(ThemeContext);
1118
- const ThemeProvider = ({ initialTheme = "light", children }) => {
1119
- const [theme, setTheme] = useState(initialTheme);
1120
- const toggleTheme = () => {
1121
- setTheme((prevTheme) => prevTheme === "light" ? "dark" : "light");
459
+ ne.Fragment = gt;
460
+ ne.jsx = Ae;
461
+ ne.jsxs = Ae;
462
+ be.exports = ne;
463
+ var a = be.exports;
464
+ const ve = ye(), xt = () => xe(ve), zt = ({ initialTheme: s = "light", children: r }) => {
465
+ const [t, c] = U(s), u = () => {
466
+ c((h) => h === "light" ? "dark" : "light");
1122
467
  };
1123
- useEffect(() => {
1124
- document.documentElement.classList.remove("light", "dark");
1125
- document.documentElement.classList.add(theme);
1126
- }, [theme]);
1127
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeContext.Provider, { value: { theme, setTheme, toggleTheme }, children });
1128
- };
1129
- const CoinleyContext = createContext();
1130
- const useCoinley = () => useContext(CoinleyContext);
1131
- const CoinleyProvider = ({
1132
- apiKey,
1133
- apiSecret,
1134
- apiUrl = "https://coinleyserver-production.up.railway.app",
1135
- merchantWalletAddress = null,
468
+ return Z(() => {
469
+ document.documentElement.classList.remove("light", "dark"), document.documentElement.classList.add(t);
470
+ }, [t]), /* @__PURE__ */ a.jsx(ve.Provider, { value: { theme: t, setTheme: c, toggleTheme: u }, children: r });
471
+ }, Te = ye(), Nt = () => xe(Te), Gt = ({
472
+ apiKey: s,
473
+ apiSecret: r,
474
+ apiUrl: t = "http://localhost:9000",
475
+ merchantWalletAddress: c = null,
1136
476
  // New prop for merchant wallet address
1137
- merchantSolWalletAddress = null,
477
+ merchantSolWalletAddress: u = null,
1138
478
  // New prop for Solana wallet address
1139
- debug = false,
1140
- children
479
+ debug: h = !1,
480
+ children: y
1141
481
  }) => {
1142
- const [isInitialized, setIsInitialized] = useState(false);
1143
- const [error, setError] = useState(null);
1144
- const [paymentData, setPaymentData] = useState(null);
1145
- useEffect(() => {
1146
- if (!apiKey || !apiSecret) {
1147
- setError("API key and secret are required");
482
+ const [w, e] = U(!1), [n, o] = U(null), [i, l] = U(null);
483
+ Z(() => {
484
+ if (!s || !r) {
485
+ o("API key and secret are required");
1148
486
  return;
1149
487
  }
1150
488
  try {
1151
- initializeApi({
1152
- apiKey,
1153
- apiSecret,
1154
- apiUrl,
1155
- merchantWalletAddress,
489
+ dt({
490
+ apiKey: s,
491
+ apiSecret: r,
492
+ apiUrl: t,
493
+ merchantWalletAddress: c,
1156
494
  // Pass wallet address to API service
1157
- merchantSolWalletAddress
495
+ merchantSolWalletAddress: u
496
+ }), e(!0), h && console.log("Coinley SDK initialized with:", {
497
+ apiKey: s,
498
+ apiUrl: t,
499
+ merchantWalletAddress: c ? `${c.substring(0, 6)}...${c.substring(c.length - 4)}` : "Not provided",
500
+ merchantSolWalletAddress: u ? `${u.substring(0, 6)}...${u.substring(u.length - 4)}` : "Not provided"
1158
501
  });
1159
- setIsInitialized(true);
1160
- if (debug) {
1161
- console.log("Coinley SDK initialized with:", {
1162
- apiKey,
1163
- apiUrl,
1164
- merchantWalletAddress: merchantWalletAddress ? `${merchantWalletAddress.substring(0, 6)}...${merchantWalletAddress.substring(merchantWalletAddress.length - 4)}` : "Not provided",
1165
- merchantSolWalletAddress: merchantSolWalletAddress ? `${merchantSolWalletAddress.substring(0, 6)}...${merchantSolWalletAddress.substring(merchantSolWalletAddress.length - 4)}` : "Not provided"
1166
- });
1167
- }
1168
- } catch (err) {
1169
- setError(err.message);
1170
- if (debug) {
1171
- console.error("Coinley SDK initialization error:", err);
1172
- }
1173
- }
1174
- }, [apiKey, apiSecret, apiUrl, merchantWalletAddress, merchantSolWalletAddress, debug]);
1175
- const storePaymentData = (data) => {
1176
- setPaymentData(data);
1177
- return data;
502
+ } catch (m) {
503
+ o(m.message), h && console.error("Coinley SDK initialization error:", m);
504
+ }
505
+ }, [s, r, t, c, u, h]);
506
+ const d = {
507
+ apiKey: s,
508
+ apiSecret: r,
509
+ apiUrl: t,
510
+ merchantWalletAddress: c,
511
+ merchantSolWalletAddress: u,
512
+ isInitialized: w,
513
+ error: n,
514
+ debug: h,
515
+ paymentData: i,
516
+ storePaymentData: (m) => (l(m), m)
1178
517
  };
1179
- const value = {
1180
- apiKey,
1181
- apiSecret,
1182
- apiUrl,
1183
- merchantWalletAddress,
1184
- merchantSolWalletAddress,
1185
- isInitialized,
1186
- error,
1187
- debug,
1188
- paymentData,
1189
- storePaymentData
1190
- };
1191
- return /* @__PURE__ */ jsxRuntimeExports.jsx(CoinleyContext.Provider, { value, children });
1192
- };
1193
- var __defProp = Object.defineProperty;
1194
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1195
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1196
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1197
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1198
- var __spreadValues = (a, b) => {
1199
- for (var prop in b || (b = {}))
1200
- if (__hasOwnProp.call(b, prop))
1201
- __defNormalProp(a, prop, b[prop]);
1202
- if (__getOwnPropSymbols)
1203
- for (var prop of __getOwnPropSymbols(b)) {
1204
- if (__propIsEnum.call(b, prop))
1205
- __defNormalProp(a, prop, b[prop]);
1206
- }
1207
- return a;
518
+ return /* @__PURE__ */ a.jsx(Te.Provider, { value: d, children: y });
1208
519
  };
1209
- var __objRest = (source, exclude) => {
1210
- var target = {};
1211
- for (var prop in source)
1212
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
1213
- target[prop] = source[prop];
1214
- if (source != null && __getOwnPropSymbols)
1215
- for (var prop of __getOwnPropSymbols(source)) {
1216
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
1217
- target[prop] = source[prop];
1218
- }
1219
- return target;
520
+ var Et = Object.defineProperty, se = Object.getOwnPropertySymbols, Ce = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable, pe = (s, r, t) => r in s ? Et(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t, ie = (s, r) => {
521
+ for (var t in r || (r = {}))
522
+ Ce.call(r, t) && pe(s, t, r[t]);
523
+ if (se)
524
+ for (var t of se(r))
525
+ je.call(r, t) && pe(s, t, r[t]);
526
+ return s;
527
+ }, ce = (s, r) => {
528
+ var t = {};
529
+ for (var c in s)
530
+ Ce.call(s, c) && r.indexOf(c) < 0 && (t[c] = s[c]);
531
+ if (s != null && se)
532
+ for (var c of se(s))
533
+ r.indexOf(c) < 0 && je.call(s, c) && (t[c] = s[c]);
534
+ return t;
1220
535
  };
1221
536
  /**
1222
537
  * @license QR Code generator library (TypeScript)
1223
538
  * Copyright (c) Project Nayuki.
1224
539
  * SPDX-License-Identifier: MIT
1225
540
  */
1226
- var qrcodegen;
1227
- ((qrcodegen2) => {
1228
- const _QrCode = class _QrCode2 {
541
+ var K;
542
+ ((s) => {
543
+ const r = class E {
1229
544
  /*-- Constructor (low level) and fields --*/
1230
545
  // Creates a new QR Code with the given version number,
1231
546
  // error correction level, data codeword bytes, and mask number.
1232
547
  // This is a low-level API that most users should not use directly.
1233
548
  // A mid-level API is the encodeSegments() function.
1234
- constructor(version, errorCorrectionLevel, dataCodewords, msk) {
1235
- this.version = version;
1236
- this.errorCorrectionLevel = errorCorrectionLevel;
1237
- this.modules = [];
1238
- this.isFunction = [];
1239
- if (version < _QrCode2.MIN_VERSION || version > _QrCode2.MAX_VERSION)
549
+ constructor(e, n, o, i) {
550
+ if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < E.MIN_VERSION || e > E.MAX_VERSION)
1240
551
  throw new RangeError("Version value out of range");
1241
- if (msk < -1 || msk > 7)
552
+ if (i < -1 || i > 7)
1242
553
  throw new RangeError("Mask value out of range");
1243
- this.size = version * 4 + 17;
1244
- let row = [];
1245
- for (let i = 0; i < this.size; i++)
1246
- row.push(false);
1247
- for (let i = 0; i < this.size; i++) {
1248
- this.modules.push(row.slice());
1249
- this.isFunction.push(row.slice());
1250
- }
554
+ this.size = e * 4 + 17;
555
+ let l = [];
556
+ for (let d = 0; d < this.size; d++)
557
+ l.push(!1);
558
+ for (let d = 0; d < this.size; d++)
559
+ this.modules.push(l.slice()), this.isFunction.push(l.slice());
1251
560
  this.drawFunctionPatterns();
1252
- const allCodewords = this.addEccAndInterleave(dataCodewords);
1253
- this.drawCodewords(allCodewords);
1254
- if (msk == -1) {
1255
- let minPenalty = 1e9;
1256
- for (let i = 0; i < 8; i++) {
1257
- this.applyMask(i);
1258
- this.drawFormatBits(i);
1259
- const penalty = this.getPenaltyScore();
1260
- if (penalty < minPenalty) {
1261
- msk = i;
1262
- minPenalty = penalty;
1263
- }
1264
- this.applyMask(i);
561
+ const f = this.addEccAndInterleave(o);
562
+ if (this.drawCodewords(f), i == -1) {
563
+ let d = 1e9;
564
+ for (let m = 0; m < 8; m++) {
565
+ this.applyMask(m), this.drawFormatBits(m);
566
+ const g = this.getPenaltyScore();
567
+ g < d && (i = m, d = g), this.applyMask(m);
1265
568
  }
1266
569
  }
1267
- assert(0 <= msk && msk <= 7);
1268
- this.mask = msk;
1269
- this.applyMask(msk);
1270
- this.drawFormatBits(msk);
1271
- this.isFunction = [];
570
+ u(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
1272
571
  }
1273
572
  /*-- Static factory functions (high level) --*/
1274
573
  // Returns a QR Code representing the given Unicode text string at the given error correction level.
@@ -1276,17 +575,17 @@ var qrcodegen;
1276
575
  // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
1277
576
  // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
1278
577
  // ecl argument if it can be done without increasing the version.
1279
- static encodeText(text, ecl) {
1280
- const segs = qrcodegen2.QrSegment.makeSegments(text);
1281
- return _QrCode2.encodeSegments(segs, ecl);
578
+ static encodeText(e, n) {
579
+ const o = s.QrSegment.makeSegments(e);
580
+ return E.encodeSegments(o, n);
1282
581
  }
1283
582
  // Returns a QR Code representing the given binary data at the given error correction level.
1284
583
  // This function always encodes using the binary segment mode, not any text mode. The maximum number of
1285
584
  // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
1286
585
  // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
1287
- static encodeBinary(data, ecl) {
1288
- const seg = qrcodegen2.QrSegment.makeBytes(data);
1289
- return _QrCode2.encodeSegments([seg], ecl);
586
+ static encodeBinary(e, n) {
587
+ const o = s.QrSegment.makeBytes(e);
588
+ return E.encodeSegments([o], n);
1290
589
  }
1291
590
  /*-- Static factory functions (mid level) --*/
1292
591
  // Returns a QR Code representing the given segments with the given encoding parameters.
@@ -1298,52 +597,43 @@ var qrcodegen;
1298
597
  // This function allows the user to create a custom sequence of segments that switches
1299
598
  // between modes (such as alphanumeric and byte) to encode text in less space.
1300
599
  // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
1301
- static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
1302
- if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7)
600
+ static encodeSegments(e, n, o = 1, i = 40, l = -1, f = !0) {
601
+ if (!(E.MIN_VERSION <= o && o <= i && i <= E.MAX_VERSION) || l < -1 || l > 7)
1303
602
  throw new RangeError("Invalid value");
1304
- let version;
1305
- let dataUsedBits;
1306
- for (version = minVersion; ; version++) {
1307
- const dataCapacityBits2 = _QrCode2.getNumDataCodewords(version, ecl) * 8;
1308
- const usedBits = QrSegment.getTotalBits(segs, version);
1309
- if (usedBits <= dataCapacityBits2) {
1310
- dataUsedBits = usedBits;
603
+ let d, m;
604
+ for (d = o; ; d++) {
605
+ const p = E.getNumDataCodewords(d, n) * 8, j = y.getTotalBits(e, d);
606
+ if (j <= p) {
607
+ m = j;
1311
608
  break;
1312
609
  }
1313
- if (version >= maxVersion)
610
+ if (d >= i)
1314
611
  throw new RangeError("Data too long");
1315
612
  }
1316
- for (const newEcl of [_QrCode2.Ecc.MEDIUM, _QrCode2.Ecc.QUARTILE, _QrCode2.Ecc.HIGH]) {
1317
- if (boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version, newEcl) * 8)
1318
- ecl = newEcl;
1319
- }
1320
- let bb = [];
1321
- for (const seg of segs) {
1322
- appendBits(seg.mode.modeBits, 4, bb);
1323
- appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
1324
- for (const b of seg.getData())
1325
- bb.push(b);
1326
- }
1327
- assert(bb.length == dataUsedBits);
1328
- const dataCapacityBits = _QrCode2.getNumDataCodewords(version, ecl) * 8;
1329
- assert(bb.length <= dataCapacityBits);
1330
- appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
1331
- appendBits(0, (8 - bb.length % 8) % 8, bb);
1332
- assert(bb.length % 8 == 0);
1333
- for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
1334
- appendBits(padByte, 8, bb);
1335
- let dataCodewords = [];
1336
- while (dataCodewords.length * 8 < bb.length)
1337
- dataCodewords.push(0);
1338
- bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
1339
- return new _QrCode2(version, ecl, dataCodewords, mask);
613
+ for (const p of [E.Ecc.MEDIUM, E.Ecc.QUARTILE, E.Ecc.HIGH])
614
+ f && m <= E.getNumDataCodewords(d, p) * 8 && (n = p);
615
+ let g = [];
616
+ for (const p of e) {
617
+ t(p.mode.modeBits, 4, g), t(p.numChars, p.mode.numCharCountBits(d), g);
618
+ for (const j of p.getData())
619
+ g.push(j);
620
+ }
621
+ u(g.length == m);
622
+ const b = E.getNumDataCodewords(d, n) * 8;
623
+ u(g.length <= b), t(0, Math.min(4, b - g.length), g), t(0, (8 - g.length % 8) % 8, g), u(g.length % 8 == 0);
624
+ for (let p = 236; g.length < b; p ^= 253)
625
+ t(p, 8, g);
626
+ let v = [];
627
+ for (; v.length * 8 < g.length; )
628
+ v.push(0);
629
+ return g.forEach((p, j) => v[j >>> 3] |= p << 7 - (j & 7)), new E(d, n, v, l);
1340
630
  }
1341
631
  /*-- Accessor methods --*/
1342
632
  // Returns the color of the module (pixel) at the given coordinates, which is false
1343
633
  // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
1344
634
  // If the given coordinates are out of bounds, then false (light) is returned.
1345
- getModule(x, y) {
1346
- return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
635
+ getModule(e, n) {
636
+ return 0 <= e && e < this.size && 0 <= n && n < this.size && this.modules[n][e];
1347
637
  }
1348
638
  // Modified to expose modules for easy access
1349
639
  getModules() {
@@ -1352,253 +642,178 @@ var qrcodegen;
1352
642
  /*-- Private helper methods for constructor: Drawing function modules --*/
1353
643
  // Reads this object's version field, and draws and marks all function modules.
1354
644
  drawFunctionPatterns() {
1355
- for (let i = 0; i < this.size; i++) {
1356
- this.setFunctionModule(6, i, i % 2 == 0);
1357
- this.setFunctionModule(i, 6, i % 2 == 0);
1358
- }
1359
- this.drawFinderPattern(3, 3);
1360
- this.drawFinderPattern(this.size - 4, 3);
1361
- this.drawFinderPattern(3, this.size - 4);
1362
- const alignPatPos = this.getAlignmentPatternPositions();
1363
- const numAlign = alignPatPos.length;
1364
- for (let i = 0; i < numAlign; i++) {
1365
- for (let j = 0; j < numAlign; j++) {
1366
- if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))
1367
- this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
1368
- }
1369
- }
1370
- this.drawFormatBits(0);
1371
- this.drawVersion();
645
+ for (let o = 0; o < this.size; o++)
646
+ this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 2 == 0);
647
+ this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
648
+ const e = this.getAlignmentPatternPositions(), n = e.length;
649
+ for (let o = 0; o < n; o++)
650
+ for (let i = 0; i < n; i++)
651
+ o == 0 && i == 0 || o == 0 && i == n - 1 || o == n - 1 && i == 0 || this.drawAlignmentPattern(e[o], e[i]);
652
+ this.drawFormatBits(0), this.drawVersion();
1372
653
  }
1373
654
  // Draws two copies of the format bits (with its own error correction code)
1374
655
  // based on the given mask and this object's error correction level field.
1375
- drawFormatBits(mask) {
1376
- const data = this.errorCorrectionLevel.formatBits << 3 | mask;
1377
- let rem = data;
1378
- for (let i = 0; i < 10; i++)
1379
- rem = rem << 1 ^ (rem >>> 9) * 1335;
1380
- const bits = (data << 10 | rem) ^ 21522;
1381
- assert(bits >>> 15 == 0);
1382
- for (let i = 0; i <= 5; i++)
1383
- this.setFunctionModule(8, i, getBit(bits, i));
1384
- this.setFunctionModule(8, 7, getBit(bits, 6));
1385
- this.setFunctionModule(8, 8, getBit(bits, 7));
1386
- this.setFunctionModule(7, 8, getBit(bits, 8));
1387
- for (let i = 9; i < 15; i++)
1388
- this.setFunctionModule(14 - i, 8, getBit(bits, i));
1389
- for (let i = 0; i < 8; i++)
1390
- this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
1391
- for (let i = 8; i < 15; i++)
1392
- this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
1393
- this.setFunctionModule(8, this.size - 8, true);
656
+ drawFormatBits(e) {
657
+ const n = this.errorCorrectionLevel.formatBits << 3 | e;
658
+ let o = n;
659
+ for (let l = 0; l < 10; l++)
660
+ o = o << 1 ^ (o >>> 9) * 1335;
661
+ const i = (n << 10 | o) ^ 21522;
662
+ u(i >>> 15 == 0);
663
+ for (let l = 0; l <= 5; l++)
664
+ this.setFunctionModule(8, l, c(i, l));
665
+ this.setFunctionModule(8, 7, c(i, 6)), this.setFunctionModule(8, 8, c(i, 7)), this.setFunctionModule(7, 8, c(i, 8));
666
+ for (let l = 9; l < 15; l++)
667
+ this.setFunctionModule(14 - l, 8, c(i, l));
668
+ for (let l = 0; l < 8; l++)
669
+ this.setFunctionModule(this.size - 1 - l, 8, c(i, l));
670
+ for (let l = 8; l < 15; l++)
671
+ this.setFunctionModule(8, this.size - 15 + l, c(i, l));
672
+ this.setFunctionModule(8, this.size - 8, !0);
1394
673
  }
1395
674
  // Draws two copies of the version bits (with its own error correction code),
1396
675
  // based on this object's version field, iff 7 <= version <= 40.
1397
676
  drawVersion() {
1398
677
  if (this.version < 7)
1399
678
  return;
1400
- let rem = this.version;
1401
- for (let i = 0; i < 12; i++)
1402
- rem = rem << 1 ^ (rem >>> 11) * 7973;
1403
- const bits = this.version << 12 | rem;
1404
- assert(bits >>> 18 == 0);
1405
- for (let i = 0; i < 18; i++) {
1406
- const color = getBit(bits, i);
1407
- const a = this.size - 11 + i % 3;
1408
- const b = Math.floor(i / 3);
1409
- this.setFunctionModule(a, b, color);
1410
- this.setFunctionModule(b, a, color);
679
+ let e = this.version;
680
+ for (let o = 0; o < 12; o++)
681
+ e = e << 1 ^ (e >>> 11) * 7973;
682
+ const n = this.version << 12 | e;
683
+ u(n >>> 18 == 0);
684
+ for (let o = 0; o < 18; o++) {
685
+ const i = c(n, o), l = this.size - 11 + o % 3, f = Math.floor(o / 3);
686
+ this.setFunctionModule(l, f, i), this.setFunctionModule(f, l, i);
1411
687
  }
1412
688
  }
1413
689
  // Draws a 9*9 finder pattern including the border separator,
1414
690
  // with the center module at (x, y). Modules can be out of bounds.
1415
- drawFinderPattern(x, y) {
1416
- for (let dy = -4; dy <= 4; dy++) {
1417
- for (let dx = -4; dx <= 4; dx++) {
1418
- const dist = Math.max(Math.abs(dx), Math.abs(dy));
1419
- const xx = x + dx;
1420
- const yy = y + dy;
1421
- if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
1422
- this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
691
+ drawFinderPattern(e, n) {
692
+ for (let o = -4; o <= 4; o++)
693
+ for (let i = -4; i <= 4; i++) {
694
+ const l = Math.max(Math.abs(i), Math.abs(o)), f = e + i, d = n + o;
695
+ 0 <= f && f < this.size && 0 <= d && d < this.size && this.setFunctionModule(f, d, l != 2 && l != 4);
1423
696
  }
1424
- }
1425
697
  }
1426
698
  // Draws a 5*5 alignment pattern, with the center module
1427
699
  // at (x, y). All modules must be in bounds.
1428
- drawAlignmentPattern(x, y) {
1429
- for (let dy = -2; dy <= 2; dy++) {
1430
- for (let dx = -2; dx <= 2; dx++)
1431
- this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
1432
- }
700
+ drawAlignmentPattern(e, n) {
701
+ for (let o = -2; o <= 2; o++)
702
+ for (let i = -2; i <= 2; i++)
703
+ this.setFunctionModule(e + i, n + o, Math.max(Math.abs(i), Math.abs(o)) != 1);
1433
704
  }
1434
705
  // Sets the color of a module and marks it as a function module.
1435
706
  // Only used by the constructor. Coordinates must be in bounds.
1436
- setFunctionModule(x, y, isDark) {
1437
- this.modules[y][x] = isDark;
1438
- this.isFunction[y][x] = true;
707
+ setFunctionModule(e, n, o) {
708
+ this.modules[n][e] = o, this.isFunction[n][e] = !0;
1439
709
  }
1440
710
  /*-- Private helper methods for constructor: Codewords and masking --*/
1441
711
  // Returns a new byte string representing the given data with the appropriate error correction
1442
712
  // codewords appended to it, based on this object's version and error correction level.
1443
- addEccAndInterleave(data) {
1444
- const ver = this.version;
1445
- const ecl = this.errorCorrectionLevel;
1446
- if (data.length != _QrCode2.getNumDataCodewords(ver, ecl))
713
+ addEccAndInterleave(e) {
714
+ const n = this.version, o = this.errorCorrectionLevel;
715
+ if (e.length != E.getNumDataCodewords(n, o))
1447
716
  throw new RangeError("Invalid argument");
1448
- const numBlocks = _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
1449
- const blockEccLen = _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
1450
- const rawCodewords = Math.floor(_QrCode2.getNumRawDataModules(ver) / 8);
1451
- const numShortBlocks = numBlocks - rawCodewords % numBlocks;
1452
- const shortBlockLen = Math.floor(rawCodewords / numBlocks);
1453
- let blocks = [];
1454
- const rsDiv = _QrCode2.reedSolomonComputeDivisor(blockEccLen);
1455
- for (let i = 0, k = 0; i < numBlocks; i++) {
1456
- let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
1457
- k += dat.length;
1458
- const ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
1459
- if (i < numShortBlocks)
1460
- dat.push(0);
1461
- blocks.push(dat.concat(ecc));
1462
- }
1463
- let result = [];
1464
- for (let i = 0; i < blocks[0].length; i++) {
1465
- blocks.forEach((block, j) => {
1466
- if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
1467
- result.push(block[i]);
717
+ const i = E.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][n], l = E.ECC_CODEWORDS_PER_BLOCK[o.ordinal][n], f = Math.floor(E.getNumRawDataModules(n) / 8), d = i - f % i, m = Math.floor(f / i);
718
+ let g = [];
719
+ const b = E.reedSolomonComputeDivisor(l);
720
+ for (let p = 0, j = 0; p < i; p++) {
721
+ let M = e.slice(j, j + m - l + (p < d ? 0 : 1));
722
+ j += M.length;
723
+ const F = E.reedSolomonComputeRemainder(M, b);
724
+ p < d && M.push(0), g.push(M.concat(F));
725
+ }
726
+ let v = [];
727
+ for (let p = 0; p < g[0].length; p++)
728
+ g.forEach((j, M) => {
729
+ (p != m - l || M >= d) && v.push(j[p]);
1468
730
  });
1469
- }
1470
- assert(result.length == rawCodewords);
1471
- return result;
731
+ return u(v.length == f), v;
1472
732
  }
1473
733
  // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
1474
734
  // data area of this QR Code. Function modules need to be marked off before this is called.
1475
- drawCodewords(data) {
1476
- if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8))
735
+ drawCodewords(e) {
736
+ if (e.length != Math.floor(E.getNumRawDataModules(this.version) / 8))
1477
737
  throw new RangeError("Invalid argument");
1478
- let i = 0;
1479
- for (let right = this.size - 1; right >= 1; right -= 2) {
1480
- if (right == 6)
1481
- right = 5;
1482
- for (let vert = 0; vert < this.size; vert++) {
1483
- for (let j = 0; j < 2; j++) {
1484
- const x = right - j;
1485
- const upward = (right + 1 & 2) == 0;
1486
- const y = upward ? this.size - 1 - vert : vert;
1487
- if (!this.isFunction[y][x] && i < data.length * 8) {
1488
- this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
1489
- i++;
1490
- }
738
+ let n = 0;
739
+ for (let o = this.size - 1; o >= 1; o -= 2) {
740
+ o == 6 && (o = 5);
741
+ for (let i = 0; i < this.size; i++)
742
+ for (let l = 0; l < 2; l++) {
743
+ const f = o - l, m = (o + 1 & 2) == 0 ? this.size - 1 - i : i;
744
+ !this.isFunction[m][f] && n < e.length * 8 && (this.modules[m][f] = c(e[n >>> 3], 7 - (n & 7)), n++);
1491
745
  }
1492
- }
1493
746
  }
1494
- assert(i == data.length * 8);
747
+ u(n == e.length * 8);
1495
748
  }
1496
749
  // XORs the codeword modules in this QR Code with the given mask pattern.
1497
750
  // The function modules must be marked and the codeword bits must be drawn
1498
751
  // before masking. Due to the arithmetic of XOR, calling applyMask() with
1499
752
  // the same mask value a second time will undo the mask. A final well-formed
1500
753
  // QR Code needs exactly one (not zero, two, etc.) mask applied.
1501
- applyMask(mask) {
1502
- if (mask < 0 || mask > 7)
754
+ applyMask(e) {
755
+ if (e < 0 || e > 7)
1503
756
  throw new RangeError("Mask value out of range");
1504
- for (let y = 0; y < this.size; y++) {
1505
- for (let x = 0; x < this.size; x++) {
1506
- let invert;
1507
- switch (mask) {
757
+ for (let n = 0; n < this.size; n++)
758
+ for (let o = 0; o < this.size; o++) {
759
+ let i;
760
+ switch (e) {
1508
761
  case 0:
1509
- invert = (x + y) % 2 == 0;
762
+ i = (o + n) % 2 == 0;
1510
763
  break;
1511
764
  case 1:
1512
- invert = y % 2 == 0;
765
+ i = n % 2 == 0;
1513
766
  break;
1514
767
  case 2:
1515
- invert = x % 3 == 0;
768
+ i = o % 3 == 0;
1516
769
  break;
1517
770
  case 3:
1518
- invert = (x + y) % 3 == 0;
771
+ i = (o + n) % 3 == 0;
1519
772
  break;
1520
773
  case 4:
1521
- invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;
774
+ i = (Math.floor(o / 3) + Math.floor(n / 2)) % 2 == 0;
1522
775
  break;
1523
776
  case 5:
1524
- invert = x * y % 2 + x * y % 3 == 0;
777
+ i = o * n % 2 + o * n % 3 == 0;
1525
778
  break;
1526
779
  case 6:
1527
- invert = (x * y % 2 + x * y % 3) % 2 == 0;
780
+ i = (o * n % 2 + o * n % 3) % 2 == 0;
1528
781
  break;
1529
782
  case 7:
1530
- invert = ((x + y) % 2 + x * y % 3) % 2 == 0;
783
+ i = ((o + n) % 2 + o * n % 3) % 2 == 0;
1531
784
  break;
1532
785
  default:
1533
786
  throw new Error("Unreachable");
1534
787
  }
1535
- if (!this.isFunction[y][x] && invert)
1536
- this.modules[y][x] = !this.modules[y][x];
788
+ !this.isFunction[n][o] && i && (this.modules[n][o] = !this.modules[n][o]);
1537
789
  }
1538
- }
1539
790
  }
1540
791
  // Calculates and returns the penalty score based on state of this QR Code's current modules.
1541
792
  // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
1542
793
  getPenaltyScore() {
1543
- let result = 0;
1544
- for (let y = 0; y < this.size; y++) {
1545
- let runColor = false;
1546
- let runX = 0;
1547
- let runHistory = [0, 0, 0, 0, 0, 0, 0];
1548
- for (let x = 0; x < this.size; x++) {
1549
- if (this.modules[y][x] == runColor) {
1550
- runX++;
1551
- if (runX == 5)
1552
- result += _QrCode2.PENALTY_N1;
1553
- else if (runX > 5)
1554
- result++;
1555
- } else {
1556
- this.finderPenaltyAddHistory(runX, runHistory);
1557
- if (!runColor)
1558
- result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
1559
- runColor = this.modules[y][x];
1560
- runX = 1;
1561
- }
1562
- }
1563
- result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
1564
- }
1565
- for (let x = 0; x < this.size; x++) {
1566
- let runColor = false;
1567
- let runY = 0;
1568
- let runHistory = [0, 0, 0, 0, 0, 0, 0];
1569
- for (let y = 0; y < this.size; y++) {
1570
- if (this.modules[y][x] == runColor) {
1571
- runY++;
1572
- if (runY == 5)
1573
- result += _QrCode2.PENALTY_N1;
1574
- else if (runY > 5)
1575
- result++;
1576
- } else {
1577
- this.finderPenaltyAddHistory(runY, runHistory);
1578
- if (!runColor)
1579
- result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
1580
- runColor = this.modules[y][x];
1581
- runY = 1;
1582
- }
1583
- }
1584
- result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
1585
- }
1586
- for (let y = 0; y < this.size - 1; y++) {
1587
- for (let x = 0; x < this.size - 1; x++) {
1588
- const color = this.modules[y][x];
1589
- if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])
1590
- result += _QrCode2.PENALTY_N2;
1591
- }
1592
- }
1593
- let dark = 0;
1594
- for (const row of this.modules)
1595
- dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
1596
- const total = this.size * this.size;
1597
- const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
1598
- assert(0 <= k && k <= 9);
1599
- result += k * _QrCode2.PENALTY_N4;
1600
- assert(0 <= result && result <= 2568888);
1601
- return result;
794
+ let e = 0;
795
+ for (let l = 0; l < this.size; l++) {
796
+ let f = !1, d = 0, m = [0, 0, 0, 0, 0, 0, 0];
797
+ for (let g = 0; g < this.size; g++)
798
+ this.modules[l][g] == f ? (d++, d == 5 ? e += E.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, m), f || (e += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), f = this.modules[l][g], d = 1);
799
+ e += this.finderPenaltyTerminateAndCount(f, d, m) * E.PENALTY_N3;
800
+ }
801
+ for (let l = 0; l < this.size; l++) {
802
+ let f = !1, d = 0, m = [0, 0, 0, 0, 0, 0, 0];
803
+ for (let g = 0; g < this.size; g++)
804
+ this.modules[g][l] == f ? (d++, d == 5 ? e += E.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, m), f || (e += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), f = this.modules[g][l], d = 1);
805
+ e += this.finderPenaltyTerminateAndCount(f, d, m) * E.PENALTY_N3;
806
+ }
807
+ for (let l = 0; l < this.size - 1; l++)
808
+ for (let f = 0; f < this.size - 1; f++) {
809
+ const d = this.modules[l][f];
810
+ d == this.modules[l][f + 1] && d == this.modules[l + 1][f] && d == this.modules[l + 1][f + 1] && (e += E.PENALTY_N2);
811
+ }
812
+ let n = 0;
813
+ for (const l of this.modules)
814
+ n = l.reduce((f, d) => f + (d ? 1 : 0), n);
815
+ const o = this.size * this.size, i = Math.ceil(Math.abs(n * 20 - o * 10) / o) - 1;
816
+ return u(0 <= i && i <= 9), e += i * E.PENALTY_N4, u(0 <= e && e <= 2568888), e;
1602
817
  }
1603
818
  /*-- Private helper functions --*/
1604
819
  // Returns an ascending list of positions of alignment patterns for this version number.
@@ -1607,113 +822,87 @@ var qrcodegen;
1607
822
  getAlignmentPatternPositions() {
1608
823
  if (this.version == 1)
1609
824
  return [];
1610
- else {
1611
- const numAlign = Math.floor(this.version / 7) + 2;
1612
- const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
1613
- let result = [6];
1614
- for (let pos = this.size - 7; result.length < numAlign; pos -= step)
1615
- result.splice(1, 0, pos);
1616
- return result;
825
+ {
826
+ const e = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
827
+ let o = [6];
828
+ for (let i = this.size - 7; o.length < e; i -= n)
829
+ o.splice(1, 0, i);
830
+ return o;
1617
831
  }
1618
832
  }
1619
833
  // Returns the number of data bits that can be stored in a QR Code of the given version number, after
1620
834
  // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
1621
835
  // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
1622
- static getNumRawDataModules(ver) {
1623
- if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION)
836
+ static getNumRawDataModules(e) {
837
+ if (e < E.MIN_VERSION || e > E.MAX_VERSION)
1624
838
  throw new RangeError("Version number out of range");
1625
- let result = (16 * ver + 128) * ver + 64;
1626
- if (ver >= 2) {
1627
- const numAlign = Math.floor(ver / 7) + 2;
1628
- result -= (25 * numAlign - 10) * numAlign - 55;
1629
- if (ver >= 7)
1630
- result -= 36;
839
+ let n = (16 * e + 128) * e + 64;
840
+ if (e >= 2) {
841
+ const o = Math.floor(e / 7) + 2;
842
+ n -= (25 * o - 10) * o - 55, e >= 7 && (n -= 36);
1631
843
  }
1632
- assert(208 <= result && result <= 29648);
1633
- return result;
844
+ return u(208 <= n && n <= 29648), n;
1634
845
  }
1635
846
  // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
1636
847
  // QR Code of the given version number and error correction level, with remainder bits discarded.
1637
848
  // This stateless pure function could be implemented as a (40*4)-cell lookup table.
1638
- static getNumDataCodewords(ver, ecl) {
1639
- return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
849
+ static getNumDataCodewords(e, n) {
850
+ return Math.floor(E.getNumRawDataModules(e) / 8) - E.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * E.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e];
1640
851
  }
1641
852
  // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
1642
853
  // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
1643
- static reedSolomonComputeDivisor(degree) {
1644
- if (degree < 1 || degree > 255)
854
+ static reedSolomonComputeDivisor(e) {
855
+ if (e < 1 || e > 255)
1645
856
  throw new RangeError("Degree out of range");
1646
- let result = [];
1647
- for (let i = 0; i < degree - 1; i++)
1648
- result.push(0);
1649
- result.push(1);
1650
- let root = 1;
1651
- for (let i = 0; i < degree; i++) {
1652
- for (let j = 0; j < result.length; j++) {
1653
- result[j] = _QrCode2.reedSolomonMultiply(result[j], root);
1654
- if (j + 1 < result.length)
1655
- result[j] ^= result[j + 1];
1656
- }
1657
- root = _QrCode2.reedSolomonMultiply(root, 2);
1658
- }
1659
- return result;
857
+ let n = [];
858
+ for (let i = 0; i < e - 1; i++)
859
+ n.push(0);
860
+ n.push(1);
861
+ let o = 1;
862
+ for (let i = 0; i < e; i++) {
863
+ for (let l = 0; l < n.length; l++)
864
+ n[l] = E.reedSolomonMultiply(n[l], o), l + 1 < n.length && (n[l] ^= n[l + 1]);
865
+ o = E.reedSolomonMultiply(o, 2);
866
+ }
867
+ return n;
1660
868
  }
1661
869
  // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
1662
- static reedSolomonComputeRemainder(data, divisor) {
1663
- let result = divisor.map((_) => 0);
1664
- for (const b of data) {
1665
- const factor = b ^ result.shift();
1666
- result.push(0);
1667
- divisor.forEach((coef, i) => result[i] ^= _QrCode2.reedSolomonMultiply(coef, factor));
870
+ static reedSolomonComputeRemainder(e, n) {
871
+ let o = n.map((i) => 0);
872
+ for (const i of e) {
873
+ const l = i ^ o.shift();
874
+ o.push(0), n.forEach((f, d) => o[d] ^= E.reedSolomonMultiply(f, l));
1668
875
  }
1669
- return result;
876
+ return o;
1670
877
  }
1671
878
  // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
1672
879
  // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
1673
- static reedSolomonMultiply(x, y) {
1674
- if (x >>> 8 != 0 || y >>> 8 != 0)
880
+ static reedSolomonMultiply(e, n) {
881
+ if (e >>> 8 || n >>> 8)
1675
882
  throw new RangeError("Byte out of range");
1676
- let z = 0;
1677
- for (let i = 7; i >= 0; i--) {
1678
- z = z << 1 ^ (z >>> 7) * 285;
1679
- z ^= (y >>> i & 1) * x;
1680
- }
1681
- assert(z >>> 8 == 0);
1682
- return z;
883
+ let o = 0;
884
+ for (let i = 7; i >= 0; i--)
885
+ o = o << 1 ^ (o >>> 7) * 285, o ^= (n >>> i & 1) * e;
886
+ return u(o >>> 8 == 0), o;
1683
887
  }
1684
888
  // Can only be called immediately after a light run is added, and
1685
889
  // returns either 0, 1, or 2. A helper function for getPenaltyScore().
1686
- finderPenaltyCountPatterns(runHistory) {
1687
- const n = runHistory[1];
1688
- assert(n <= this.size * 3);
1689
- const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
1690
- return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
890
+ finderPenaltyCountPatterns(e) {
891
+ const n = e[1];
892
+ u(n <= this.size * 3);
893
+ const o = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
894
+ return (o && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (o && e[6] >= n * 4 && e[0] >= n ? 1 : 0);
1691
895
  }
1692
896
  // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
1693
- finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
1694
- if (currentRunColor) {
1695
- this.finderPenaltyAddHistory(currentRunLength, runHistory);
1696
- currentRunLength = 0;
1697
- }
1698
- currentRunLength += this.size;
1699
- this.finderPenaltyAddHistory(currentRunLength, runHistory);
1700
- return this.finderPenaltyCountPatterns(runHistory);
897
+ finderPenaltyTerminateAndCount(e, n, o) {
898
+ return e && (this.finderPenaltyAddHistory(n, o), n = 0), n += this.size, this.finderPenaltyAddHistory(n, o), this.finderPenaltyCountPatterns(o);
1701
899
  }
1702
900
  // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
1703
- finderPenaltyAddHistory(currentRunLength, runHistory) {
1704
- if (runHistory[0] == 0)
1705
- currentRunLength += this.size;
1706
- runHistory.pop();
1707
- runHistory.unshift(currentRunLength);
901
+ finderPenaltyAddHistory(e, n) {
902
+ n[0] == 0 && (e += this.size), n.pop(), n.unshift(e);
1708
903
  }
1709
904
  };
1710
- _QrCode.MIN_VERSION = 1;
1711
- _QrCode.MAX_VERSION = 40;
1712
- _QrCode.PENALTY_N1 = 3;
1713
- _QrCode.PENALTY_N2 = 3;
1714
- _QrCode.PENALTY_N3 = 40;
1715
- _QrCode.PENALTY_N4 = 10;
1716
- _QrCode.ECC_CODEWORDS_PER_BLOCK = [
905
+ r.MIN_VERSION = 1, r.MAX_VERSION = 40, r.PENALTY_N1 = 3, r.PENALTY_N2 = 3, r.PENALTY_N3 = 40, r.PENALTY_N4 = 10, r.ECC_CODEWORDS_PER_BLOCK = [
1717
906
  // Version: (note that index 0 is for padding, and is set to an illegal value)
1718
907
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
1719
908
  [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
@@ -1724,8 +913,7 @@ var qrcodegen;
1724
913
  // Quartile
1725
914
  [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
1726
915
  // High
1727
- ];
1728
- _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
916
+ ], r.NUM_ERROR_CORRECTION_BLOCKS = [
1729
917
  // Version: (note that index 0 is for padding, and is set to an illegal value)
1730
918
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
1731
919
  [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
@@ -1736,113 +924,95 @@ var qrcodegen;
1736
924
  // Quartile
1737
925
  [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
1738
926
  // High
1739
- ];
1740
- qrcodegen2.QrCode = _QrCode;
1741
- function appendBits(val, len, bb) {
1742
- if (len < 0 || len > 31 || val >>> len != 0)
927
+ ], s.QrCode = r;
928
+ function t(w, e, n) {
929
+ if (e < 0 || e > 31 || w >>> e)
1743
930
  throw new RangeError("Value out of range");
1744
- for (let i = len - 1; i >= 0; i--)
1745
- bb.push(val >>> i & 1);
931
+ for (let o = e - 1; o >= 0; o--)
932
+ n.push(w >>> o & 1);
1746
933
  }
1747
- function getBit(x, i) {
1748
- return (x >>> i & 1) != 0;
934
+ function c(w, e) {
935
+ return (w >>> e & 1) != 0;
1749
936
  }
1750
- function assert(cond) {
1751
- if (!cond)
937
+ function u(w) {
938
+ if (!w)
1752
939
  throw new Error("Assertion error");
1753
940
  }
1754
- const _QrSegment = class _QrSegment2 {
941
+ const h = class k {
1755
942
  /*-- Constructor (low level) and fields --*/
1756
943
  // Creates a new QR Code segment with the given attributes and data.
1757
944
  // The character count (numChars) must agree with the mode and the bit buffer length,
1758
945
  // but the constraint isn't checked. The given bit buffer is cloned and stored.
1759
- constructor(mode, numChars, bitData) {
1760
- this.mode = mode;
1761
- this.numChars = numChars;
1762
- this.bitData = bitData;
1763
- if (numChars < 0)
946
+ constructor(e, n, o) {
947
+ if (this.mode = e, this.numChars = n, this.bitData = o, n < 0)
1764
948
  throw new RangeError("Invalid argument");
1765
- this.bitData = bitData.slice();
949
+ this.bitData = o.slice();
1766
950
  }
1767
951
  /*-- Static factory functions (mid level) --*/
1768
952
  // Returns a segment representing the given binary data encoded in
1769
953
  // byte mode. All input byte arrays are acceptable. Any text string
1770
954
  // can be converted to UTF-8 bytes and encoded as a byte mode segment.
1771
- static makeBytes(data) {
1772
- let bb = [];
1773
- for (const b of data)
1774
- appendBits(b, 8, bb);
1775
- return new _QrSegment2(_QrSegment2.Mode.BYTE, data.length, bb);
955
+ static makeBytes(e) {
956
+ let n = [];
957
+ for (const o of e)
958
+ t(o, 8, n);
959
+ return new k(k.Mode.BYTE, e.length, n);
1776
960
  }
1777
961
  // Returns a segment representing the given string of decimal digits encoded in numeric mode.
1778
- static makeNumeric(digits) {
1779
- if (!_QrSegment2.isNumeric(digits))
962
+ static makeNumeric(e) {
963
+ if (!k.isNumeric(e))
1780
964
  throw new RangeError("String contains non-numeric characters");
1781
- let bb = [];
1782
- for (let i = 0; i < digits.length; ) {
1783
- const n = Math.min(digits.length - i, 3);
1784
- appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
1785
- i += n;
965
+ let n = [];
966
+ for (let o = 0; o < e.length; ) {
967
+ const i = Math.min(e.length - o, 3);
968
+ t(parseInt(e.substring(o, o + i), 10), i * 3 + 1, n), o += i;
1786
969
  }
1787
- return new _QrSegment2(_QrSegment2.Mode.NUMERIC, digits.length, bb);
970
+ return new k(k.Mode.NUMERIC, e.length, n);
1788
971
  }
1789
972
  // Returns a segment representing the given text string encoded in alphanumeric mode.
1790
973
  // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
1791
974
  // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
1792
- static makeAlphanumeric(text) {
1793
- if (!_QrSegment2.isAlphanumeric(text))
975
+ static makeAlphanumeric(e) {
976
+ if (!k.isAlphanumeric(e))
1794
977
  throw new RangeError("String contains unencodable characters in alphanumeric mode");
1795
- let bb = [];
1796
- let i;
1797
- for (i = 0; i + 2 <= text.length; i += 2) {
1798
- let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
1799
- temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
1800
- appendBits(temp, 11, bb);
978
+ let n = [], o;
979
+ for (o = 0; o + 2 <= e.length; o += 2) {
980
+ let i = k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)) * 45;
981
+ i += k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o + 1)), t(i, 11, n);
1801
982
  }
1802
- if (i < text.length)
1803
- appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
1804
- return new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC, text.length, bb);
983
+ return o < e.length && t(k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)), 6, n), new k(k.Mode.ALPHANUMERIC, e.length, n);
1805
984
  }
1806
985
  // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
1807
986
  // The result may use various segment modes and switch modes to optimize the length of the bit stream.
1808
- static makeSegments(text) {
1809
- if (text == "")
1810
- return [];
1811
- else if (_QrSegment2.isNumeric(text))
1812
- return [_QrSegment2.makeNumeric(text)];
1813
- else if (_QrSegment2.isAlphanumeric(text))
1814
- return [_QrSegment2.makeAlphanumeric(text)];
1815
- else
1816
- return [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
987
+ static makeSegments(e) {
988
+ return e == "" ? [] : k.isNumeric(e) ? [k.makeNumeric(e)] : k.isAlphanumeric(e) ? [k.makeAlphanumeric(e)] : [k.makeBytes(k.toUtf8ByteArray(e))];
1817
989
  }
1818
990
  // Returns a segment representing an Extended Channel Interpretation
1819
991
  // (ECI) designator with the given assignment value.
1820
- static makeEci(assignVal) {
1821
- let bb = [];
1822
- if (assignVal < 0)
992
+ static makeEci(e) {
993
+ let n = [];
994
+ if (e < 0)
1823
995
  throw new RangeError("ECI assignment value out of range");
1824
- else if (assignVal < 1 << 7)
1825
- appendBits(assignVal, 8, bb);
1826
- else if (assignVal < 1 << 14) {
1827
- appendBits(2, 2, bb);
1828
- appendBits(assignVal, 14, bb);
1829
- } else if (assignVal < 1e6) {
1830
- appendBits(6, 3, bb);
1831
- appendBits(assignVal, 21, bb);
1832
- } else
996
+ if (e < 128)
997
+ t(e, 8, n);
998
+ else if (e < 16384)
999
+ t(2, 2, n), t(e, 14, n);
1000
+ else if (e < 1e6)
1001
+ t(6, 3, n), t(e, 21, n);
1002
+ else
1833
1003
  throw new RangeError("ECI assignment value out of range");
1834
- return new _QrSegment2(_QrSegment2.Mode.ECI, 0, bb);
1004
+ return new k(k.Mode.ECI, 0, n);
1835
1005
  }
1836
1006
  // Tests whether the given string can be encoded as a segment in numeric mode.
1837
1007
  // A string is encodable iff each character is in the range 0 to 9.
1838
- static isNumeric(text) {
1839
- return _QrSegment2.NUMERIC_REGEX.test(text);
1008
+ static isNumeric(e) {
1009
+ return k.NUMERIC_REGEX.test(e);
1840
1010
  }
1841
1011
  // Tests whether the given string can be encoded as a segment in alphanumeric mode.
1842
1012
  // A string is encodable iff each character is in the following set: 0 to 9, A to Z
1843
1013
  // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
1844
- static isAlphanumeric(text) {
1845
- return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
1014
+ static isAlphanumeric(e) {
1015
+ return k.ALPHANUMERIC_REGEX.test(e);
1846
1016
  }
1847
1017
  /*-- Methods --*/
1848
1018
  // Returns a new copy of the data bits of this segment.
@@ -1851,244 +1021,176 @@ var qrcodegen;
1851
1021
  }
1852
1022
  // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
1853
1023
  // the given version. The result is infinity if a segment has too many characters to fit its length field.
1854
- static getTotalBits(segs, version) {
1855
- let result = 0;
1856
- for (const seg of segs) {
1857
- const ccbits = seg.mode.numCharCountBits(version);
1858
- if (seg.numChars >= 1 << ccbits)
1859
- return Infinity;
1860
- result += 4 + ccbits + seg.bitData.length;
1024
+ static getTotalBits(e, n) {
1025
+ let o = 0;
1026
+ for (const i of e) {
1027
+ const l = i.mode.numCharCountBits(n);
1028
+ if (i.numChars >= 1 << l)
1029
+ return 1 / 0;
1030
+ o += 4 + l + i.bitData.length;
1861
1031
  }
1862
- return result;
1032
+ return o;
1863
1033
  }
1864
1034
  // Returns a new array of bytes representing the given string encoded in UTF-8.
1865
- static toUtf8ByteArray(str) {
1866
- str = encodeURI(str);
1867
- let result = [];
1868
- for (let i = 0; i < str.length; i++) {
1869
- if (str.charAt(i) != "%")
1870
- result.push(str.charCodeAt(i));
1871
- else {
1872
- result.push(parseInt(str.substring(i + 1, i + 3), 16));
1873
- i += 2;
1874
- }
1875
- }
1876
- return result;
1035
+ static toUtf8ByteArray(e) {
1036
+ e = encodeURI(e);
1037
+ let n = [];
1038
+ for (let o = 0; o < e.length; o++)
1039
+ e.charAt(o) != "%" ? n.push(e.charCodeAt(o)) : (n.push(parseInt(e.substring(o + 1, o + 3), 16)), o += 2);
1040
+ return n;
1877
1041
  }
1878
1042
  };
1879
- _QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
1880
- _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
1881
- _QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
1882
- let QrSegment = _QrSegment;
1883
- qrcodegen2.QrSegment = _QrSegment;
1884
- })(qrcodegen || (qrcodegen = {}));
1885
- ((qrcodegen2) => {
1886
- ((QrCode2) => {
1887
- const _Ecc = class _Ecc {
1043
+ h.NUMERIC_REGEX = /^[0-9]*$/, h.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, h.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
1044
+ let y = h;
1045
+ s.QrSegment = h;
1046
+ })(K || (K = {}));
1047
+ ((s) => {
1048
+ ((r) => {
1049
+ const t = class {
1888
1050
  // The QR Code can tolerate about 30% erroneous codewords
1889
1051
  /*-- Constructor and fields --*/
1890
- constructor(ordinal, formatBits) {
1891
- this.ordinal = ordinal;
1892
- this.formatBits = formatBits;
1052
+ constructor(u, h) {
1053
+ this.ordinal = u, this.formatBits = h;
1893
1054
  }
1894
1055
  };
1895
- _Ecc.LOW = new _Ecc(0, 1);
1896
- _Ecc.MEDIUM = new _Ecc(1, 0);
1897
- _Ecc.QUARTILE = new _Ecc(2, 3);
1898
- _Ecc.HIGH = new _Ecc(3, 2);
1899
- QrCode2.Ecc = _Ecc;
1900
- })(qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
1901
- })(qrcodegen || (qrcodegen = {}));
1902
- ((qrcodegen2) => {
1903
- ((QrSegment2) => {
1904
- const _Mode = class _Mode {
1056
+ t.LOW = new t(0, 1), t.MEDIUM = new t(1, 0), t.QUARTILE = new t(2, 3), t.HIGH = new t(3, 2), r.Ecc = t;
1057
+ })(s.QrCode || (s.QrCode = {}));
1058
+ })(K || (K = {}));
1059
+ ((s) => {
1060
+ ((r) => {
1061
+ const t = class {
1905
1062
  /*-- Constructor and fields --*/
1906
- constructor(modeBits, numBitsCharCount) {
1907
- this.modeBits = modeBits;
1908
- this.numBitsCharCount = numBitsCharCount;
1063
+ constructor(u, h) {
1064
+ this.modeBits = u, this.numBitsCharCount = h;
1909
1065
  }
1910
1066
  /*-- Method --*/
1911
1067
  // (Package-private) Returns the bit width of the character count field for a segment in
1912
1068
  // this mode in a QR Code at the given version number. The result is in the range [0, 16].
1913
- numCharCountBits(ver) {
1914
- return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
1069
+ numCharCountBits(u) {
1070
+ return this.numBitsCharCount[Math.floor((u + 7) / 17)];
1915
1071
  }
1916
1072
  };
1917
- _Mode.NUMERIC = new _Mode(1, [10, 12, 14]);
1918
- _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);
1919
- _Mode.BYTE = new _Mode(4, [8, 16, 16]);
1920
- _Mode.KANJI = new _Mode(8, [8, 10, 12]);
1921
- _Mode.ECI = new _Mode(7, [0, 0, 0]);
1922
- QrSegment2.Mode = _Mode;
1923
- })(qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
1924
- })(qrcodegen || (qrcodegen = {}));
1925
- var qrcodegen_default = qrcodegen;
1073
+ t.NUMERIC = new t(1, [10, 12, 14]), t.ALPHANUMERIC = new t(2, [9, 11, 13]), t.BYTE = new t(4, [8, 16, 16]), t.KANJI = new t(8, [8, 10, 12]), t.ECI = new t(7, [0, 0, 0]), r.Mode = t;
1074
+ })(s.QrSegment || (s.QrSegment = {}));
1075
+ })(K || (K = {}));
1076
+ var Y = K;
1926
1077
  /**
1927
1078
  * @license qrcode.react
1928
1079
  * Copyright (c) Paul O'Shannessy
1929
1080
  * SPDX-License-Identifier: ISC
1930
1081
  */
1931
- var ERROR_LEVEL_MAP = {
1932
- L: qrcodegen_default.QrCode.Ecc.LOW,
1933
- M: qrcodegen_default.QrCode.Ecc.MEDIUM,
1934
- Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
1935
- H: qrcodegen_default.QrCode.Ecc.HIGH
1936
- };
1937
- var DEFAULT_SIZE = 128;
1938
- var DEFAULT_LEVEL = "L";
1939
- var DEFAULT_BGCOLOR = "#FFFFFF";
1940
- var DEFAULT_FGCOLOR = "#000000";
1941
- var DEFAULT_INCLUDEMARGIN = false;
1942
- var DEFAULT_MINVERSION = 1;
1943
- var SPEC_MARGIN_SIZE = 4;
1944
- var DEFAULT_MARGIN_SIZE = 0;
1945
- var DEFAULT_IMG_SCALE = 0.1;
1946
- function generatePath(modules, margin = 0) {
1947
- const ops = [];
1948
- modules.forEach(function(row, y) {
1949
- let start = null;
1950
- row.forEach(function(cell, x) {
1951
- if (!cell && start !== null) {
1952
- ops.push(
1953
- `M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`
1954
- );
1955
- start = null;
1082
+ var bt = {
1083
+ L: Y.QrCode.Ecc.LOW,
1084
+ M: Y.QrCode.Ecc.MEDIUM,
1085
+ Q: Y.QrCode.Ecc.QUARTILE,
1086
+ H: Y.QrCode.Ecc.HIGH
1087
+ }, Me = 128, ke = "L", Re = "#FFFFFF", Se = "#000000", Le = !1, Pe = 1, At = 4, vt = 0, Tt = 0.1;
1088
+ function Oe(s, r = 0) {
1089
+ const t = [];
1090
+ return s.forEach(function(c, u) {
1091
+ let h = null;
1092
+ c.forEach(function(y, w) {
1093
+ if (!y && h !== null) {
1094
+ t.push(
1095
+ `M${h + r} ${u + r}h${w - h}v1H${h + r}z`
1096
+ ), h = null;
1956
1097
  return;
1957
1098
  }
1958
- if (x === row.length - 1) {
1959
- if (!cell) {
1099
+ if (w === c.length - 1) {
1100
+ if (!y)
1960
1101
  return;
1961
- }
1962
- if (start === null) {
1963
- ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);
1964
- } else {
1965
- ops.push(
1966
- `M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`
1967
- );
1968
- }
1102
+ h === null ? t.push(`M${w + r},${u + r} h1v1H${w + r}z`) : t.push(
1103
+ `M${h + r},${u + r} h${w + 1 - h}v1H${h + r}z`
1104
+ );
1969
1105
  return;
1970
1106
  }
1971
- if (cell && start === null) {
1972
- start = x;
1973
- }
1107
+ y && h === null && (h = w);
1974
1108
  });
1975
- });
1976
- return ops.join("");
1109
+ }), t.join("");
1977
1110
  }
1978
- function excavateModules(modules, excavation) {
1979
- return modules.slice().map((row, y) => {
1980
- if (y < excavation.y || y >= excavation.y + excavation.h) {
1981
- return row;
1982
- }
1983
- return row.map((cell, x) => {
1984
- if (x < excavation.x || x >= excavation.x + excavation.w) {
1985
- return cell;
1986
- }
1987
- return false;
1988
- });
1989
- });
1111
+ function De(s, r) {
1112
+ return s.slice().map((t, c) => c < r.y || c >= r.y + r.h ? t : t.map((u, h) => h < r.x || h >= r.x + r.w ? u : !1));
1990
1113
  }
1991
- function getImageSettings(cells, size, margin, imageSettings) {
1992
- if (imageSettings == null) {
1114
+ function Ct(s, r, t, c) {
1115
+ if (c == null)
1993
1116
  return null;
1117
+ const u = s.length + t * 2, h = Math.floor(r * Tt), y = u / r, w = (c.width || h) * y, e = (c.height || h) * y, n = c.x == null ? s.length / 2 - w / 2 : c.x * y, o = c.y == null ? s.length / 2 - e / 2 : c.y * y, i = c.opacity == null ? 1 : c.opacity;
1118
+ let l = null;
1119
+ if (c.excavate) {
1120
+ let d = Math.floor(n), m = Math.floor(o), g = Math.ceil(w + n - d), b = Math.ceil(e + o - m);
1121
+ l = { x: d, y: m, w: g, h: b };
1994
1122
  }
1995
- const numCells = cells.length + margin * 2;
1996
- const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
1997
- const scale = numCells / size;
1998
- const w = (imageSettings.width || defaultSize) * scale;
1999
- const h = (imageSettings.height || defaultSize) * scale;
2000
- const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
2001
- const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
2002
- const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
2003
- let excavation = null;
2004
- if (imageSettings.excavate) {
2005
- let floorX = Math.floor(x);
2006
- let floorY = Math.floor(y);
2007
- let ceilW = Math.ceil(w + x - floorX);
2008
- let ceilH = Math.ceil(h + y - floorY);
2009
- excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
2010
- }
2011
- const crossOrigin = imageSettings.crossOrigin;
2012
- return { x, y, h, w, excavation, opacity, crossOrigin };
1123
+ const f = c.crossOrigin;
1124
+ return { x: n, y: o, h: e, w, excavation: l, opacity: i, crossOrigin: f };
2013
1125
  }
2014
- function getMarginSize(includeMargin, marginSize) {
2015
- if (marginSize != null) {
2016
- return Math.max(Math.floor(marginSize), 0);
2017
- }
2018
- return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
1126
+ function jt(s, r) {
1127
+ return r != null ? Math.max(Math.floor(r), 0) : s ? At : vt;
2019
1128
  }
2020
- function useQRCode({
2021
- value,
2022
- level,
2023
- minVersion,
2024
- includeMargin,
2025
- marginSize,
2026
- imageSettings,
2027
- size,
2028
- boostLevel
1129
+ function Ue({
1130
+ value: s,
1131
+ level: r,
1132
+ minVersion: t,
1133
+ includeMargin: c,
1134
+ marginSize: u,
1135
+ imageSettings: h,
1136
+ size: y,
1137
+ boostLevel: w
2029
1138
  }) {
2030
- let qrcode = React.useMemo(() => {
2031
- const values = Array.isArray(value) ? value : [value];
2032
- const segments = values.reduce((accum, v) => {
2033
- accum.push(...qrcodegen_default.QrSegment.makeSegments(v));
2034
- return accum;
2035
- }, []);
2036
- return qrcodegen_default.QrCode.encodeSegments(
2037
- segments,
2038
- ERROR_LEVEL_MAP[level],
2039
- minVersion,
1139
+ let e = S.useMemo(() => {
1140
+ const d = (Array.isArray(s) ? s : [s]).reduce((m, g) => (m.push(...Y.QrSegment.makeSegments(g)), m), []);
1141
+ return Y.QrCode.encodeSegments(
1142
+ d,
1143
+ bt[r],
1144
+ t,
2040
1145
  void 0,
2041
1146
  void 0,
2042
- boostLevel
1147
+ w
2043
1148
  );
2044
- }, [value, level, minVersion, boostLevel]);
2045
- const { cells, margin, numCells, calculatedImageSettings } = React.useMemo(() => {
2046
- let cells2 = qrcode.getModules();
2047
- const margin2 = getMarginSize(includeMargin, marginSize);
2048
- const numCells2 = cells2.length + margin2 * 2;
2049
- const calculatedImageSettings2 = getImageSettings(
2050
- cells2,
2051
- size,
2052
- margin2,
2053
- imageSettings
1149
+ }, [s, r, t, w]);
1150
+ const { cells: n, margin: o, numCells: i, calculatedImageSettings: l } = S.useMemo(() => {
1151
+ let f = e.getModules();
1152
+ const d = jt(c, u), m = f.length + d * 2, g = Ct(
1153
+ f,
1154
+ y,
1155
+ d,
1156
+ h
2054
1157
  );
2055
1158
  return {
2056
- cells: cells2,
2057
- margin: margin2,
2058
- numCells: numCells2,
2059
- calculatedImageSettings: calculatedImageSettings2
1159
+ cells: f,
1160
+ margin: d,
1161
+ numCells: m,
1162
+ calculatedImageSettings: g
2060
1163
  };
2061
- }, [qrcode, size, imageSettings, includeMargin, marginSize]);
1164
+ }, [e, y, h, c, u]);
2062
1165
  return {
2063
- qrcode,
2064
- margin,
2065
- cells,
2066
- numCells,
2067
- calculatedImageSettings
1166
+ qrcode: e,
1167
+ margin: o,
1168
+ cells: n,
1169
+ numCells: i,
1170
+ calculatedImageSettings: l
2068
1171
  };
2069
1172
  }
2070
- var SUPPORTS_PATH2D = function() {
1173
+ var Mt = function() {
2071
1174
  try {
2072
1175
  new Path2D().addPath(new Path2D());
2073
- } catch (e) {
2074
- return false;
1176
+ } catch (s) {
1177
+ return !1;
2075
1178
  }
2076
- return true;
2077
- }();
2078
- var QRCodeCanvas = React.forwardRef(
2079
- function QRCodeCanvas2(props, forwardedRef) {
2080
- const _a = props, {
2081
- value,
2082
- size = DEFAULT_SIZE,
2083
- level = DEFAULT_LEVEL,
2084
- bgColor = DEFAULT_BGCOLOR,
2085
- fgColor = DEFAULT_FGCOLOR,
2086
- includeMargin = DEFAULT_INCLUDEMARGIN,
2087
- minVersion = DEFAULT_MINVERSION,
2088
- boostLevel,
2089
- marginSize,
2090
- imageSettings
2091
- } = _a, extraProps = __objRest(_a, [
1179
+ return !0;
1180
+ }(), kt = S.forwardRef(
1181
+ function(r, t) {
1182
+ const c = r, {
1183
+ value: u,
1184
+ size: h = Me,
1185
+ level: y = ke,
1186
+ bgColor: w = Re,
1187
+ fgColor: e = Se,
1188
+ includeMargin: n = Le,
1189
+ minVersion: o = Pe,
1190
+ boostLevel: i,
1191
+ marginSize: l,
1192
+ imageSettings: f
1193
+ } = c, m = ce(c, [
2092
1194
  "value",
2093
1195
  "size",
2094
1196
  "level",
@@ -2099,131 +1201,92 @@ var QRCodeCanvas = React.forwardRef(
2099
1201
  "boostLevel",
2100
1202
  "marginSize",
2101
1203
  "imageSettings"
2102
- ]);
2103
- const _b = extraProps, { style } = _b, otherProps = __objRest(_b, ["style"]);
2104
- const imgSrc = imageSettings == null ? void 0 : imageSettings.src;
2105
- const _canvas = React.useRef(null);
2106
- const _image = React.useRef(null);
2107
- const setCanvasRef = React.useCallback(
2108
- (node) => {
2109
- _canvas.current = node;
2110
- if (typeof forwardedRef === "function") {
2111
- forwardedRef(node);
2112
- } else if (forwardedRef) {
2113
- forwardedRef.current = node;
2114
- }
1204
+ ]), { style: g } = m, b = ce(m, ["style"]), v = f == null ? void 0 : f.src, p = S.useRef(null), j = S.useRef(null), M = S.useCallback(
1205
+ (W) => {
1206
+ p.current = W, typeof t == "function" ? t(W) : t && (t.current = W);
2115
1207
  },
2116
- [forwardedRef]
2117
- );
2118
- const [isImgLoaded, setIsImageLoaded] = React.useState(false);
2119
- const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
2120
- value,
2121
- level,
2122
- minVersion,
2123
- boostLevel,
2124
- includeMargin,
2125
- marginSize,
2126
- imageSettings,
2127
- size
1208
+ [t]
1209
+ ), [F, V] = S.useState(!1), { margin: x, cells: T, numCells: q, calculatedImageSettings: I } = Ue({
1210
+ value: u,
1211
+ level: y,
1212
+ minVersion: o,
1213
+ boostLevel: i,
1214
+ includeMargin: n,
1215
+ marginSize: l,
1216
+ imageSettings: f,
1217
+ size: h
2128
1218
  });
2129
- React.useEffect(() => {
2130
- if (_canvas.current != null) {
2131
- const canvas = _canvas.current;
2132
- const ctx = canvas.getContext("2d");
2133
- if (!ctx) {
1219
+ S.useEffect(() => {
1220
+ if (p.current != null) {
1221
+ const W = p.current, O = W.getContext("2d");
1222
+ if (!O)
2134
1223
  return;
2135
- }
2136
- let cellsToDraw = cells;
2137
- const image = _image.current;
2138
- const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
2139
- if (haveImageToRender) {
2140
- if (calculatedImageSettings.excavation != null) {
2141
- cellsToDraw = excavateModules(
2142
- cells,
2143
- calculatedImageSettings.excavation
2144
- );
2145
- }
2146
- }
2147
- const pixelRatio = window.devicePixelRatio || 1;
2148
- canvas.height = canvas.width = size * pixelRatio;
2149
- const scale = size / numCells * pixelRatio;
2150
- ctx.scale(scale, scale);
2151
- ctx.fillStyle = bgColor;
2152
- ctx.fillRect(0, 0, numCells, numCells);
2153
- ctx.fillStyle = fgColor;
2154
- if (SUPPORTS_PATH2D) {
2155
- ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));
2156
- } else {
2157
- cells.forEach(function(row, rdx) {
2158
- row.forEach(function(cell, cdx) {
2159
- if (cell) {
2160
- ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
2161
- }
2162
- });
1224
+ let $ = T;
1225
+ const H = j.current, te = I != null && H !== null && H.complete && H.naturalHeight !== 0 && H.naturalWidth !== 0;
1226
+ te && I.excavation != null && ($ = De(
1227
+ T,
1228
+ I.excavation
1229
+ ));
1230
+ const X = window.devicePixelRatio || 1;
1231
+ W.height = W.width = h * X;
1232
+ const G = h / q * X;
1233
+ O.scale(G, G), O.fillStyle = w, O.fillRect(0, 0, q, q), O.fillStyle = e, Mt ? O.fill(new Path2D(Oe($, x))) : T.forEach(function(oe, re) {
1234
+ oe.forEach(function(ae, L) {
1235
+ ae && O.fillRect(L + x, re + x, 1, 1);
2163
1236
  });
2164
- }
2165
- if (calculatedImageSettings) {
2166
- ctx.globalAlpha = calculatedImageSettings.opacity;
2167
- }
2168
- if (haveImageToRender) {
2169
- ctx.drawImage(
2170
- image,
2171
- calculatedImageSettings.x + margin,
2172
- calculatedImageSettings.y + margin,
2173
- calculatedImageSettings.w,
2174
- calculatedImageSettings.h
2175
- );
2176
- }
1237
+ }), I && (O.globalAlpha = I.opacity), te && O.drawImage(
1238
+ H,
1239
+ I.x + x,
1240
+ I.y + x,
1241
+ I.w,
1242
+ I.h
1243
+ );
2177
1244
  }
2178
- });
2179
- React.useEffect(() => {
2180
- setIsImageLoaded(false);
2181
- }, [imgSrc]);
2182
- const canvasStyle = __spreadValues({ height: size, width: size }, style);
2183
- let img = null;
2184
- if (imgSrc != null) {
2185
- img = /* @__PURE__ */ React.createElement(
2186
- "img",
2187
- {
2188
- src: imgSrc,
2189
- key: imgSrc,
2190
- style: { display: "none" },
2191
- onLoad: () => {
2192
- setIsImageLoaded(true);
2193
- },
2194
- ref: _image,
2195
- crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin
2196
- }
2197
- );
2198
- }
2199
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1245
+ }), S.useEffect(() => {
1246
+ V(!1);
1247
+ }, [v]);
1248
+ const B = ie({ height: h, width: h }, g);
1249
+ let ee = null;
1250
+ return v != null && (ee = /* @__PURE__ */ S.createElement(
1251
+ "img",
1252
+ {
1253
+ src: v,
1254
+ key: v,
1255
+ style: { display: "none" },
1256
+ onLoad: () => {
1257
+ V(!0);
1258
+ },
1259
+ ref: j,
1260
+ crossOrigin: I == null ? void 0 : I.crossOrigin
1261
+ }
1262
+ )), /* @__PURE__ */ S.createElement(S.Fragment, null, /* @__PURE__ */ S.createElement(
2200
1263
  "canvas",
2201
- __spreadValues({
2202
- style: canvasStyle,
2203
- height: size,
2204
- width: size,
2205
- ref: setCanvasRef,
1264
+ ie({
1265
+ style: B,
1266
+ height: h,
1267
+ width: h,
1268
+ ref: M,
2206
1269
  role: "img"
2207
- }, otherProps)
2208
- ), img);
1270
+ }, b)
1271
+ ), ee);
2209
1272
  }
2210
1273
  );
2211
- QRCodeCanvas.displayName = "QRCodeCanvas";
2212
- var QRCodeSVG = React.forwardRef(
2213
- function QRCodeSVG2(props, forwardedRef) {
2214
- const _a = props, {
2215
- value,
2216
- size = DEFAULT_SIZE,
2217
- level = DEFAULT_LEVEL,
2218
- bgColor = DEFAULT_BGCOLOR,
2219
- fgColor = DEFAULT_FGCOLOR,
2220
- includeMargin = DEFAULT_INCLUDEMARGIN,
2221
- minVersion = DEFAULT_MINVERSION,
2222
- boostLevel,
2223
- title,
2224
- marginSize,
2225
- imageSettings
2226
- } = _a, otherProps = __objRest(_a, [
1274
+ kt.displayName = "QRCodeCanvas";
1275
+ var Ie = S.forwardRef(
1276
+ function(r, t) {
1277
+ const c = r, {
1278
+ value: u,
1279
+ size: h = Me,
1280
+ level: y = ke,
1281
+ bgColor: w = Re,
1282
+ fgColor: e = Se,
1283
+ includeMargin: n = Le,
1284
+ minVersion: o = Pe,
1285
+ boostLevel: i,
1286
+ title: l,
1287
+ marginSize: f,
1288
+ imageSettings: d
1289
+ } = c, m = ce(c, [
2227
1290
  "value",
2228
1291
  "size",
2229
1292
  "level",
@@ -2235,152 +1298,126 @@ var QRCodeSVG = React.forwardRef(
2235
1298
  "title",
2236
1299
  "marginSize",
2237
1300
  "imageSettings"
2238
- ]);
2239
- const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
2240
- value,
2241
- level,
2242
- minVersion,
2243
- boostLevel,
2244
- includeMargin,
2245
- marginSize,
2246
- imageSettings,
2247
- size
1301
+ ]), { margin: g, cells: b, numCells: v, calculatedImageSettings: p } = Ue({
1302
+ value: u,
1303
+ level: y,
1304
+ minVersion: o,
1305
+ boostLevel: i,
1306
+ includeMargin: n,
1307
+ marginSize: f,
1308
+ imageSettings: d,
1309
+ size: h
2248
1310
  });
2249
- let cellsToDraw = cells;
2250
- let image = null;
2251
- if (imageSettings != null && calculatedImageSettings != null) {
2252
- if (calculatedImageSettings.excavation != null) {
2253
- cellsToDraw = excavateModules(
2254
- cells,
2255
- calculatedImageSettings.excavation
2256
- );
2257
- }
2258
- image = /* @__PURE__ */ React.createElement(
2259
- "image",
2260
- {
2261
- href: imageSettings.src,
2262
- height: calculatedImageSettings.h,
2263
- width: calculatedImageSettings.w,
2264
- x: calculatedImageSettings.x + margin,
2265
- y: calculatedImageSettings.y + margin,
2266
- preserveAspectRatio: "none",
2267
- opacity: calculatedImageSettings.opacity,
2268
- crossOrigin: calculatedImageSettings.crossOrigin
2269
- }
2270
- );
2271
- }
2272
- const fgPath = generatePath(cellsToDraw, margin);
2273
- return /* @__PURE__ */ React.createElement(
1311
+ let j = b, M = null;
1312
+ d != null && p != null && (p.excavation != null && (j = De(
1313
+ b,
1314
+ p.excavation
1315
+ )), M = /* @__PURE__ */ S.createElement(
1316
+ "image",
1317
+ {
1318
+ href: d.src,
1319
+ height: p.h,
1320
+ width: p.w,
1321
+ x: p.x + g,
1322
+ y: p.y + g,
1323
+ preserveAspectRatio: "none",
1324
+ opacity: p.opacity,
1325
+ crossOrigin: p.crossOrigin
1326
+ }
1327
+ ));
1328
+ const F = Oe(j, g);
1329
+ return /* @__PURE__ */ S.createElement(
2274
1330
  "svg",
2275
- __spreadValues({
2276
- height: size,
2277
- width: size,
2278
- viewBox: `0 0 ${numCells} ${numCells}`,
2279
- ref: forwardedRef,
1331
+ ie({
1332
+ height: h,
1333
+ width: h,
1334
+ viewBox: `0 0 ${v} ${v}`,
1335
+ ref: t,
2280
1336
  role: "img"
2281
- }, otherProps),
2282
- !!title && /* @__PURE__ */ React.createElement("title", null, title),
2283
- /* @__PURE__ */ React.createElement(
1337
+ }, m),
1338
+ !!l && /* @__PURE__ */ S.createElement("title", null, l),
1339
+ /* @__PURE__ */ S.createElement(
2284
1340
  "path",
2285
1341
  {
2286
- fill: bgColor,
2287
- d: `M0,0 h${numCells}v${numCells}H0z`,
1342
+ fill: w,
1343
+ d: `M0,0 h${v}v${v}H0z`,
2288
1344
  shapeRendering: "crispEdges"
2289
1345
  }
2290
1346
  ),
2291
- /* @__PURE__ */ React.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
2292
- image
1347
+ /* @__PURE__ */ S.createElement("path", { fill: e, d: F, shapeRendering: "crispEdges" }),
1348
+ M
2293
1349
  );
2294
1350
  }
2295
1351
  );
2296
- QRCodeSVG.displayName = "QRCodeSVG";
2297
- const QRCode = ({
2298
- walletAddress,
2299
- amount,
2300
- currency,
2301
- theme = "light",
2302
- size = 200
1352
+ Ie.displayName = "QRCodeSVG";
1353
+ const Vt = ({
1354
+ walletAddress: s,
1355
+ amount: r,
1356
+ currency: t,
1357
+ theme: c = "light",
1358
+ size: u = 200
2303
1359
  }) => {
2304
- const [qrData, setQrData] = useState("");
2305
- const [qrError, setQrError] = useState(null);
2306
- useEffect(() => {
2307
- if (!walletAddress) {
2308
- setQrError("No wallet address provided");
1360
+ const [h, y] = U(""), [w, e] = U(null);
1361
+ Z(() => {
1362
+ if (!s) {
1363
+ e("No wallet address provided");
2309
1364
  return;
2310
1365
  }
2311
1366
  try {
2312
- let paymentData;
2313
- if (currency === "SOL" || currency === "USDC_SOL") {
2314
- paymentData = `solana:${walletAddress}?amount=${amount}&spl-token=USDC`;
2315
- } else if (currency === "USDT" || currency === "USDC") {
2316
- const tokenAddress = getTokenAddressForCurrency(currency);
2317
- paymentData = `ethereum:${tokenAddress}/transfer?address=${walletAddress}&uint256=${convertToSmallestUnit(amount, currency)}`;
2318
- } else {
2319
- paymentData = `ethereum:${walletAddress}@1?value=${convertToWei(amount)}`;
2320
- }
2321
- setQrData(paymentData);
2322
- setQrError(null);
2323
- } catch (err) {
2324
- console.error("Error generating QR code:", err);
2325
- setQrError("Error generating payment QR code");
2326
- }
2327
- }, [walletAddress, amount, currency]);
2328
- const getTokenAddressForCurrency = (currency2) => {
2329
- const tokenAddresses = {
2330
- "USDT": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
2331
- "USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
2332
- "BNB": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52"
2333
- };
2334
- return tokenAddresses[currency2] || "";
2335
- };
2336
- const convertToSmallestUnit = (amount2, currency2) => {
2337
- const decimals = currency2 === "USDT" || currency2 === "USDC" ? 6 : 18;
2338
- return Math.floor(parseFloat(amount2) * Math.pow(10, decimals)).toString();
2339
- };
2340
- const convertToWei = (amount2) => {
2341
- return Math.floor(parseFloat(amount2) * 1e18).toString();
2342
- };
2343
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
2344
- qrError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg bg-red-100 mb-3 text-red-700", children: qrError }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg bg-white mb-3", children: qrData && /* @__PURE__ */ jsxRuntimeExports.jsx(
2345
- QRCodeSVG,
1367
+ let l;
1368
+ t === "SOL" || t === "USDC_SOL" ? l = `solana:${s}?amount=${r}&spl-token=USDC` : t === "USDT" || t === "USDC" ? l = `ethereum:${n(t)}/transfer?address=${s}&uint256=${o(r, t)}` : l = `ethereum:${s}@1?value=${i(r)}`, y(l), e(null);
1369
+ } catch (l) {
1370
+ console.error("Error generating QR code:", l), e("Error generating payment QR code");
1371
+ }
1372
+ }, [s, r, t]);
1373
+ const n = (l) => ({
1374
+ USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
1375
+ USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
1376
+ BNB: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52"
1377
+ })[l] || "", o = (l, f) => {
1378
+ const d = f === "USDT" || f === "USDC" ? 6 : 18;
1379
+ return Math.floor(parseFloat(l) * Math.pow(10, d)).toString();
1380
+ }, i = (l) => Math.floor(parseFloat(l) * 1e18).toString();
1381
+ return /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col items-center", children: [
1382
+ w ? /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-red-100 mb-3 text-red-700", children: w }) : /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-white mb-3", children: h && /* @__PURE__ */ a.jsx(
1383
+ Ie,
2346
1384
  {
2347
- value: qrData,
2348
- size,
2349
- bgColor: theme === "dark" ? "#374151" : "#FFFFFF",
2350
- fgColor: theme === "dark" ? "#FFFFFF" : "#000000",
1385
+ value: h,
1386
+ size: u,
1387
+ bgColor: c === "dark" ? "#374151" : "#FFFFFF",
1388
+ fgColor: c === "dark" ? "#FFFFFF" : "#000000",
2351
1389
  level: "H",
2352
- includeMargin: true
1390
+ includeMargin: !0
2353
1391
  }
2354
1392
  ) }),
2355
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center text-sm text-gray-700", children: [
2356
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-semibold text-gray-800", children: "Pay with QR Code" }),
1393
+ /* @__PURE__ */ a.jsxs("div", { className: "text-center text-sm text-gray-700", children: [
1394
+ /* @__PURE__ */ a.jsx("p", { className: "font-semibold text-gray-800", children: "Pay with QR Code" }),
2357
1395
  "Scan with your wallet app to pay"
2358
1396
  ] }),
2359
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 w-full" }),
2360
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 rounded bg-gray-100", children: [
2361
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium mb-2 text-gray-800", children: "Payment Instructions" }),
2362
- /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "text-xs space-y-2 text-gray-600", children: [
2363
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "1. Open your crypto wallet app (MetaMask, Trust Wallet, etc.)" }),
2364
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "2. Scan the QR code above" }),
2365
- /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
1397
+ /* @__PURE__ */ a.jsx("div", { className: "mt-3 w-full" }),
1398
+ /* @__PURE__ */ a.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ a.jsxs("div", { className: "p-3 rounded bg-gray-100", children: [
1399
+ /* @__PURE__ */ a.jsx("h4", { className: "text-sm font-medium mb-2 text-gray-800", children: "Payment Instructions" }),
1400
+ /* @__PURE__ */ a.jsxs("ol", { className: "text-xs space-y-2 text-gray-600", children: [
1401
+ /* @__PURE__ */ a.jsx("li", { children: "1. Open your crypto wallet app (MetaMask, Trust Wallet, etc.)" }),
1402
+ /* @__PURE__ */ a.jsx("li", { children: "2. Scan the QR code above" }),
1403
+ /* @__PURE__ */ a.jsxs("li", { children: [
2366
1404
  "3. Confirm the payment amount (",
2367
- amount,
1405
+ r,
2368
1406
  " ",
2369
- currency,
1407
+ t,
2370
1408
  ")"
2371
1409
  ] }),
2372
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: '4. Click "Pay Now" button below after sending the payment' })
1410
+ /* @__PURE__ */ a.jsx("li", { children: '4. Click "Pay Now" button below after sending the payment' })
2373
1411
  ] })
2374
1412
  ] }) })
2375
1413
  ] });
2376
- };
2377
- const PaymentStatus = ({ status, message, theme = "light" }) => {
2378
- const renderIcon = () => {
2379
- switch (status) {
1414
+ }, le = ({ status: s, message: r, theme: t = "light" }) => {
1415
+ const c = () => {
1416
+ switch (s) {
2380
1417
  case "processing":
2381
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
1418
+ return /* @__PURE__ */ a.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
2382
1419
  case "success":
2383
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1420
+ return /* @__PURE__ */ a.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ a.jsx(
2384
1421
  "svg",
2385
1422
  {
2386
1423
  xmlns: "http://www.w3.org/2000/svg",
@@ -2389,11 +1426,11 @@ const PaymentStatus = ({ status, message, theme = "light" }) => {
2389
1426
  viewBox: "0 0 24 24",
2390
1427
  stroke: "currentColor",
2391
1428
  strokeWidth: 2,
2392
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
1429
+ children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
2393
1430
  }
2394
1431
  ) });
2395
1432
  case "error":
2396
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1433
+ return /* @__PURE__ */ a.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ a.jsx(
2397
1434
  "svg",
2398
1435
  {
2399
1436
  xmlns: "http://www.w3.org/2000/svg",
@@ -2402,15 +1439,14 @@ const PaymentStatus = ({ status, message, theme = "light" }) => {
2402
1439
  viewBox: "0 0 24 24",
2403
1440
  stroke: "currentColor",
2404
1441
  strokeWidth: 2,
2405
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
1442
+ children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
2406
1443
  }
2407
1444
  ) });
2408
1445
  default:
2409
1446
  return null;
2410
1447
  }
2411
- };
2412
- const getStatusTitle = () => {
2413
- switch (status) {
1448
+ }, u = () => {
1449
+ switch (s) {
2414
1450
  case "processing":
2415
1451
  return "Processing Payment";
2416
1452
  case "success":
@@ -2420,675 +1456,596 @@ const PaymentStatus = ({ status, message, theme = "light" }) => {
2420
1456
  default:
2421
1457
  return "Unknown Status";
2422
1458
  }
2423
- };
2424
- const getMessageClasses = () => {
2425
- switch (status) {
1459
+ }, h = () => {
1460
+ switch (s) {
2426
1461
  case "processing":
2427
- return theme === "dark" ? "text-blue-300" : "text-blue-600";
1462
+ return t === "dark" ? "text-blue-300" : "text-blue-600";
2428
1463
  case "success":
2429
- return theme === "dark" ? "text-green-300" : "text-green-600";
1464
+ return t === "dark" ? "text-green-300" : "text-green-600";
2430
1465
  case "error":
2431
- return theme === "dark" ? "text-red-300" : "text-red-600";
1466
+ return t === "dark" ? "text-red-300" : "text-red-600";
2432
1467
  default:
2433
- return theme === "dark" ? "text-gray-300" : "text-gray-600";
1468
+ return t === "dark" ? "text-gray-300" : "text-gray-600";
2434
1469
  }
2435
1470
  };
2436
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
2437
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
2438
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: getStatusTitle() }),
2439
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message }),
2440
- status === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
2441
- status === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 p-2 rounded ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
1471
+ return /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
1472
+ /* @__PURE__ */ a.jsx("div", { className: "mb-4", children: c() }),
1473
+ /* @__PURE__ */ a.jsx("h3", { className: `text-xl font-bold mb-2 ${t === "dark" ? "text-white" : "text-gray-900"}`, children: u() }),
1474
+ /* @__PURE__ */ a.jsx("p", { className: `text-center ${h()}`, children: r }),
1475
+ s === "processing" && /* @__PURE__ */ a.jsx("div", { className: `mt-4 text-xs ${t === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
1476
+ s === "success" && /* @__PURE__ */ a.jsx("div", { className: `mt-4 p-2 rounded ${t === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ a.jsx("p", { className: `text-xs ${t === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
2442
1477
  ] });
2443
- };
2444
- const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
2445
- const paymentMethods = [
1478
+ }, Rt = ({ onSelect: s, selected: r, theme: t = "light", supportedNetworks: c = [] }) => {
1479
+ const [u, h] = U({}), [y, w] = U(A.ETHEREUM);
1480
+ Z(() => {
1481
+ h(ue());
1482
+ }, []);
1483
+ const e = [
2446
1484
  {
2447
1485
  id: "USDT",
2448
1486
  name: "USDT",
2449
1487
  description: "Tether USD",
2450
- logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s"
1488
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
1489
+ networks: [A.ETHEREUM, A.BSC, A.TRON]
2451
1490
  },
2452
1491
  {
2453
1492
  id: "USDC",
2454
1493
  name: "USDC",
2455
1494
  description: "USD Coin",
2456
- logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s"
1495
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
1496
+ networks: [A.ETHEREUM, A.BSC, A.TRON]
2457
1497
  },
2458
1498
  {
2459
1499
  id: "BNB",
2460
1500
  name: "BNB",
2461
1501
  description: "Binance Coin",
2462
- logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s"
1502
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",
1503
+ networks: [A.BSC]
2463
1504
  },
2464
1505
  {
2465
- id: "SOL",
2466
- name: "SOL",
2467
- description: "Solana",
2468
- logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTsIsJL3zRgUrkD3yE3lD7LK0wZWSiRyY1GVg&s"
2469
- }
2470
- ];
2471
- const handleSelectPaymentMethod = (id) => {
2472
- onSelect(id);
1506
+ id: "ETH",
1507
+ name: "ETH",
1508
+ description: "Ethereum",
1509
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",
1510
+ networks: [A.ETHEREUM]
1511
+ },
1512
+ {
1513
+ id: "TRX",
1514
+ name: "TRX",
1515
+ description: "Tron",
1516
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",
1517
+ networks: [A.TRON]
1518
+ },
1519
+ {
1520
+ id: "ALGO",
1521
+ name: "ALGO",
1522
+ description: "Algorand",
1523
+ logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",
1524
+ networks: [A.ALGORAND]
1525
+ }
1526
+ ], n = e.filter((d) => c.length === 0 ? !0 : d.networks.some((m) => c.includes(m))), o = (d) => {
1527
+ const m = e.find((g) => g.id === d);
1528
+ return m ? m.networks : [];
1529
+ }, i = (d) => ({
1530
+ [A.ETHEREUM]: "Ethereum",
1531
+ [A.BSC]: "BSC",
1532
+ [A.TRON]: "Tron",
1533
+ [A.ALGORAND]: "Algorand"
1534
+ })[d] || d, l = (d) => Ne(d).length > 0, f = (d, m) => {
1535
+ var g;
1536
+ w(m), s({
1537
+ currency: d,
1538
+ network: m,
1539
+ tokenConfig: (g = Xe[d]) == null ? void 0 : g[m]
1540
+ });
2473
1541
  };
2474
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2475
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-3 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
2476
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: paymentMethods.map((method) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2477
- "button",
2478
- {
2479
- onClick: () => handleSelectPaymentMethod(method.id),
2480
- className: `w-full flex items-center p-3 rounded-lg transition-colors ${selected === method.id ? theme === "dark" ? "bg-blue-900/30 border-2 border-[#7042D2]" : "bg-blue-50 border-2 border-[#7042D2]" : theme === "dark" ? "bg-gray-700 hover:bg-gray-600 border border-gray-700" : "bg-white hover:bg-gray-50 border border-gray-200"}`,
2481
- children: [
2482
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: method.logo, alt: method.name, className: "h-6 w-6" }) }),
2483
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 text-left", children: [
2484
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: method.name }),
2485
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-500"}`, children: method.description })
2486
- ] }),
2487
- selected === method.id && /* @__PURE__ */ jsxRuntimeExports.jsx(
2488
- "svg",
2489
- {
2490
- xmlns: "http://www.w3.org/2000/svg",
2491
- className: "h-5 w-5 text-[#7042D2]",
2492
- viewBox: "0 0 20 20",
2493
- fill: "currentColor",
2494
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2495
- "path",
1542
+ return /* @__PURE__ */ a.jsxs("div", { children: [
1543
+ /* @__PURE__ */ a.jsx("h3", { className: `text-lg font-medium mb-3 ${t === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
1544
+ /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: n.map((d) => {
1545
+ const m = o(d.id), g = (r == null ? void 0 : r.currency) === d.id;
1546
+ return /* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
1547
+ /* @__PURE__ */ a.jsxs("div", { className: `flex items-center p-3 rounded-lg border-2 transition-colors ${g ? t === "dark" ? "bg-blue-900/30 border-[#7042D2]" : "bg-blue-50 border-[#7042D2]" : t === "dark" ? "bg-gray-700 border-gray-700" : "bg-white border-gray-200"}`, children: [
1548
+ /* @__PURE__ */ a.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ a.jsx("img", { src: d.logo, alt: d.name, className: "h-6 w-6" }) }),
1549
+ /* @__PURE__ */ a.jsxs("div", { className: "flex-1", children: [
1550
+ /* @__PURE__ */ a.jsx("h4", { className: `font-medium ${t === "dark" ? "text-white" : "text-gray-900"}`, children: d.name }),
1551
+ /* @__PURE__ */ a.jsx("p", { className: `text-sm ${t === "dark" ? "text-gray-300" : "text-gray-500"}`, children: d.description })
1552
+ ] })
1553
+ ] }),
1554
+ m.length > 1 && /* @__PURE__ */ a.jsxs("div", { className: "ml-4 space-y-2", children: [
1555
+ /* @__PURE__ */ a.jsx("p", { className: `text-sm font-medium ${t === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Select Network:" }),
1556
+ /* @__PURE__ */ a.jsx("div", { className: "grid grid-cols-2 gap-2", children: m.map((b) => {
1557
+ const v = g && (r == null ? void 0 : r.network) === b, p = l(b);
1558
+ return /* @__PURE__ */ a.jsx(
1559
+ "button",
1560
+ {
1561
+ onClick: () => f(d.id, b),
1562
+ disabled: !p,
1563
+ className: `p-2 rounded-md text-sm font-medium transition-colors ${v ? "bg-[#7042D2] text-white" : p ? t === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : t === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
1564
+ children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-center space-x-1", children: [
1565
+ /* @__PURE__ */ a.jsx("span", { children: i(b) }),
1566
+ !p && /* @__PURE__ */ a.jsx("span", { className: "text-xs", children: "(No wallet)" })
1567
+ ] })
1568
+ },
1569
+ b
1570
+ );
1571
+ }) })
1572
+ ] }),
1573
+ m.length === 1 && /* @__PURE__ */ a.jsx("div", { className: "ml-4", children: /* @__PURE__ */ a.jsx(
1574
+ "button",
1575
+ {
1576
+ onClick: () => f(d.id, m[0]),
1577
+ disabled: !l(m[0]),
1578
+ className: `w-full p-2 rounded-md text-sm font-medium transition-colors ${g ? "bg-[#7042D2] text-white" : l(m[0]) ? t === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : t === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
1579
+ children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
1580
+ /* @__PURE__ */ a.jsx("span", { children: i(m[0]) }),
1581
+ !l(m[0]) && /* @__PURE__ */ a.jsx("span", { className: "text-xs", children: "No wallet detected" }),
1582
+ g && /* @__PURE__ */ a.jsx(
1583
+ "svg",
2496
1584
  {
2497
- fillRule: "evenodd",
2498
- d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
2499
- clipRule: "evenodd"
1585
+ xmlns: "http://www.w3.org/2000/svg",
1586
+ className: "h-4 w-4",
1587
+ viewBox: "0 0 20 20",
1588
+ fill: "currentColor",
1589
+ children: /* @__PURE__ */ a.jsx(
1590
+ "path",
1591
+ {
1592
+ fillRule: "evenodd",
1593
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
1594
+ clipRule: "evenodd"
1595
+ }
1596
+ )
2500
1597
  }
2501
1598
  )
2502
- }
2503
- )
2504
- ]
2505
- },
2506
- method.id
2507
- )) })
1599
+ ] })
1600
+ }
1601
+ ) })
1602
+ ] }, d.id);
1603
+ }) }),
1604
+ /* @__PURE__ */ a.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-50 dark:bg-gray-800", children: [
1605
+ /* @__PURE__ */ a.jsx("h4", { className: `text-sm font-medium mb-2 ${t === "dark" ? "text-white" : "text-gray-800"}`, children: "Detected Wallets:" }),
1606
+ /* @__PURE__ */ a.jsx("div", { className: "space-y-1", children: Object.entries(u).map(([d, m]) => /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between text-xs", children: [
1607
+ /* @__PURE__ */ a.jsx("span", { className: `capitalize ${t === "dark" ? "text-gray-300" : "text-gray-600"}`, children: d.replace("_", " ") }),
1608
+ /* @__PURE__ */ a.jsx("span", { className: `px-2 py-1 rounded-full ${m ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: m ? "Available" : "Not detected" })
1609
+ ] }, d)) })
1610
+ ] })
2508
1611
  ] });
2509
- };
2510
- const logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsNnj664MiAH9rBLkKlJa6IU+4LsnyNyu7t7/n6rxUBvgAxj9jizWZSMNJdAd1lgjMH6IPA5gBGgXOX7SUk9hrbsK/JFpcM3eUruq47NIvd3xIEVyyOp/QDu9Z/nJJKL0K4ys6RYAlcZaItAdcabGh0kSHk3R/rIsXi4nO39p8FBU3paa5NclEA9V1oMeokoo0xBDdMLTt1oHZPWhGv0NdLr9rv8YoxmfiuY8E9aDzgpWle+RzUiu7T8pQpgq0V0dkmJmVGL6oPTu1zfJA+ZG2m3I7CZp0M+eYmF5otCyji821xlrPZqI378BTnqr0qz2mAXjv6eBYJdKcNG3R4A1q5Ejb/n+oDia128QemoTRBtLKy/fphFOH+jJEe4JcoNovaa+T2uuIwLXGMH1PbUqccyNbFgLfWpvq6yqyZA3p0U5f2tfU1iG5IcflAGavzE00LYia+o9O3T9smfDIoXpJQI5gcvLk1r9j5wbOOV/bKfz7fX0Ue4LufedIPPft3ie/zgThfUWqfx2Ql3hk1T1D3kc9g8T5iqwGQqWr4fG3Ea3w2i73N+QWGLG8RGHg+jCFMWzz4zf2NyQnDcgJXWeE1SBRaDkOKuMLFXqQr9EMfj8pjGab19yHa5ATBAwZUlTHI6Ql+QpSwi5eYmt8f0YjsvH/j39r08lNgVS0YGX0kJuIStPuIczAUd18t95F0yoQ8Hu/E6wWVdA0vr7l/Bs0Y8Dy5y3a+Izw3Ljm90lTpK+/3BhP84M9q0kGaoqa2s1dv/GrbKqf7/7zO54PguVTtF9Su6tTbn9JFMv7JqQobKscCcKuhDo5TZDoZownLD8PlPswD8iawthkOYly49ztb+7jcrEk8tIPZT3bqbV9DhS5hGKRUAa7uvhilnu+nxGcCPdYDYLlJbrhVyZDYDvQ9+TvsBqEc0zay51KScm4hDph1y5p15IfypBpj8hEKu29dhH04lOVPw1EHzwnNmGTESTWwyYWG5vA97qPCcpjnaCs9U5Z/dL0WfihlNFNEQYmGkAbY8bwyjLSFAO7n/ecg8kJtCn77aBj/Z9YXmI7sKkXjMuiY25L5VOcQHVKTd1MTJpHbbN8JaMb9ax/7jdTsvwJVsOM5QW69SVheYntAO8XEYH2VaMV0ismi9uIpJVye8rFFGw8YqV5RlYLNUBvqWzyrWhCCh4h2t7ZN0BhF8w8ctou/0cok2+Odgb2c0Bi9fFpQopyP/OVMp/uvvCG8TJqIATtMc8o+uD18Ojh7uzdt1b7PMMkGPXZFr6HRw+4ifxU5wrl/Sq+TKaBP22QQ+fHrKzr6u57w7cHJ9AMqtdEvnNPm8TJS3jGg/xQHz3OTao8VcpQOQkjaSIsFUPV9kyWZZNW/qg4O9DBebS1szpoq4O/heRVpvsRrG4Cs8oZO2V0TJ2eoDpVTeHfN6NrXKDqWpBo5+d5TnADOl/pDQL1875N7O9jTd0UPC6uer6CyM2QRsk3cL2BcTkWT+RgnKnzVxSqQnt6tv6Fyp8tZRzdf1VkVRolGk9u/7vqw6A3KbTjL+1vH367iAbk0NZLEF5W59OiQPgNJw+8+0Z2DV9JUQ8uL2+ToHzfEmWnJ72w1x55VC9f0vdR7Of1PfVCTtQxwubBITwxXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+aFvNwYU1QIpWJOliHVGNU96DqkML/Bk3RLf6b6h2hvWf9n8IY9XucPhARDxva+FwIhMtQg0rEJiNLGSZI7lyvDMsXhbG1LKLeMvTBTodH9vN0IhVWnP6mNg1gDOaEnc+N+DxsIwQJQ6qBlcOnAZJDRPyMeiJ9QflhSHbuJyazCVze3JE79ZRzpCj6RY7pBH6NRNe5QfvVqgxcy4uIF5hPzCO/JlG2k44pP36g8Ip+qYyM78yZyxdPr1w3g/5yJoqv9apSGfuTX95uYgoRzrHE6hAbkrNtcG3LOVZzhnLbboqaT8aqU17mnermS+KY6Yzv5QBP7LOoOB64WR2MRxGgWsvhakNed+mkbZCzbSACSVR9Vm3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==";
2511
- const CoinleyModal = (props) => {
2512
- const {
2513
- isOpen,
2514
- onClose,
2515
- payment,
2516
- paymentStatus,
2517
- selectedCurrency,
2518
- onCurrencySelect,
2519
- onPayment,
2520
- error,
2521
- theme = "light",
2522
- merchantName,
2523
- transactionHash,
2524
- walletConnected,
2525
- onConnectWallet,
2526
- testMode = false
2527
- } = props;
2528
- const [step, setStep] = useState("select-currency");
2529
- const [isMetaMaskAvailable, setIsMetaMaskAvailable] = useState(false);
2530
- const [paymentMethod, setPaymentMethod] = useState("wallet");
2531
- useEffect(() => {
2532
- if (typeof window !== "undefined") {
2533
- setIsMetaMaskAvailable(isMetaMaskInstalled());
2534
- }
2535
- }, []);
2536
- useEffect(() => {
2537
- if (paymentStatus === "loading") {
2538
- setStep("processing");
2539
- } else if (paymentStatus === "success") {
2540
- setStep("success");
2541
- } else if (paymentStatus === "error") {
2542
- setStep("error");
2543
- } else if (paymentStatus === "idle" && payment) {
2544
- setStep("select-currency");
2545
- }
2546
- }, [paymentStatus, payment]);
2547
- const handleCurrencySelect = (currency) => {
2548
- onCurrencySelect(currency);
2549
- setStep("confirm");
2550
- };
2551
- const handlePaymentConfirm = () => {
2552
- onPayment(paymentMethod === "qrcode");
2553
- };
2554
- const handleBack = () => {
2555
- if (step === "confirm") {
2556
- setStep("select-currency");
2557
- }
2558
- };
2559
- const togglePaymentMethod = (method) => {
2560
- setPaymentMethod(method);
2561
- };
2562
- const formatAmount = (amount) => {
2563
- return parseFloat(amount).toFixed(2);
2564
- };
2565
- const formatTransactionHash = (hash) => {
2566
- if (!hash)
2567
- return "";
2568
- if (hash.length <= 14)
2569
- return hash;
2570
- return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
2571
- };
2572
- const getWalletAddressForCurrency = () => {
2573
- if (!payment)
2574
- return null;
2575
- const isSolana = selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL";
2576
- return isSolana ? payment.solWalletAddress : payment.walletAddress;
2577
- };
2578
- if (!isOpen)
2579
- return null;
2580
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto bg-black/50", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800", children: [
2581
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
2582
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-xl font-bold text-gray-900", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: logo, className: "w-32" }) }) }),
2583
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1612
+ }, St = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsNnj664MiAH9rBLkKlJa6IU+4LsnyNyu7t7/n6rxUBvgAxj9jizWZSMNJdAd1lgjMH6IPA5gBGgXOX7SUk9hrbsK/JFpcM3eUruq47NIvd3xIEVyyOp/QDu9Z/nJJKL0K4ys6RYAlcZaItAdcabGh0kSHk3R/rIsXi4nO39p8FBU3paa5NclEA9V1oMeokoo0xBDdMLTt1oHZPWhGv0NdLr9rv8YoxmfiuY8E9aDzgpWle+RzUiu7T8pQpgq0V0dkmJmVGL6oPTu1zfJA+ZG2m3I7CZp0M+eYmF5otCyji821xlrPZqI378BTnqr0qz2mAXjv6eBYJdKcNG3R4A1q5Ejb/n+oDia128QemoTRBtLKy/fphFOH+jJEe4JcoNovaa+T2uuIwLXGMH1PbUqccyNbFgLfWpvq6yqyZA3p0U5f2tfU1iG5IcflAGavzE00LYia+o9O3T9smfDIoXpJQI5gcvLk1r9j5wbOOV/bKfz7fX0Ue4LufedIPPft3ie/zgThfUWqfx2Ql3hk1T1D3kc9g8T5iqwGQqWr4fG3Ea3w2i73N+QWGLG8RGHg+jCFMWzz4zf2NyQnDcgJXWeE1SBRaDkOKuMLFXqQr9EMfj8pjGab19yHa5ATBAwZUlTHI6Ql+QpSwi5eYmt8f0YjsvH/j39r08lNgVS0YGX0kJuIStPuIczAUd18t95F0yoQ8Hu/E6wWVdA0vr7l/Bs0Y8Dy5y3a+Izw3Ljm90lTpK+/3BhP84M9q0kGaoqa2s1dv/GrbKqf7/7zO54PguVTtF9Su6tTbn9JFMv7JqQobKscCcKuhDo5TZDoZownLD8PlPswD8iawthkOYly49ztb+7jcrEk8tIPZT3bqbV9DhS5hGKRUAa7uvhilnu+nxGcCPdYDYLlJbrhVyZDYDvQ9+TvsBqEc0zay51KScm4hDph1y5p15IfypBpj8hEKu29dhH04lOVPw1EHzwnNmGTESTWwyYWG5vA97qPCcpjnaCs9U5Z/dL0WfihlNFNEQYmGkAbY8bwyjLSFAO7n/ecg8kJtCn77aBj/Z9YXmI7sKkXjMuiY25L5VOcQHVKTd1MTJpHbbN8JaMb9ax/7jdTsvwJVsOM5QW69SVheYntAO8XEYH2VaMV0ismi9uIpJVye8rFFGw8YqV5RlYLNUBvqWzyrWhCCh4h2t7ZN0BhF8w8ctou/0cok2+Odgb2c0Bi9fFpQopyP/OVMp/uvvCG8TJqIATtMc8o+uD18Ojh7uzdt1b7PMMkGPXZFr6HRw+4ifxU5wrl/Sq+TKaBP22QQ+fHrKzr6u57w7cHJ9AMqtdEvnNPm8TJS3jGg/xQHz3OTao8VcpQOQkjaSIsFUPV9kyWZZNW/qg4O9DBebS1szpoq4O/heRVpvsRrG4Cs8oZO2V0TJ2eoDpVTeHfN6NrXKDqWpBo5+d5TnADOl/pDQL1875N7O9jTd0UPC6uer6CyM2QRsk3cL2BcTkWT+RgnKnzVxSqQnt6tv6Fyp8tZRzdf1VkVRolGk9u/7vqw6A3KbTjL+1vH367iAbk0NZLEF5W59OiQPgNJw+8+0Z2DV9JUQ8uL2+ToHzfEmWnJ72w1x55VC9f0vdR7Of1PfVCTtQxwubBITwxXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+aFvNwYU1QIpWJOliHVGNU96DqkML/Bk3RLf6b6h2hvWf9n8IY9XucPhARDxva+FwIhMtQg0rEJiNLGSZI7lyvDMsXhbG1LKLeMvTBTodH9vN0IhVWnP6mNg1gDOaEnc+N+DxsIwQJQ6qBlcOnAZJDRPyMeiJ9QflhSHbuJyazCVze3JE79ZRzpCj6RY7pBH6NRNe5QfvVqgxcy4uIF5hPzCO/JlG2k44pP36g8Ip+qYyM78yZyxdPr1w3g/5yJoqv9apSGfuTX95uYgoRzrHE6hAbkrNtcG3LOVZzhnLbboqaT8aqU17mnermS+KY6Yzv5QBP7LOoOB64WR2MRxGgWsvhakNed+mkbZCzbSACSVR9Vm3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==", Lt = ({
1613
+ isOpen: s,
1614
+ onClose: r,
1615
+ payment: t,
1616
+ paymentStatus: c,
1617
+ selectedPaymentMethod: u,
1618
+ onPaymentMethodSelect: h,
1619
+ onPayment: y,
1620
+ onBack: w,
1621
+ error: e,
1622
+ theme: n = "light",
1623
+ merchantName: o,
1624
+ transactionHash: i,
1625
+ walletConnection: l,
1626
+ onConnectWallet: f,
1627
+ testMode: d = !1,
1628
+ supportedNetworks: m = [],
1629
+ availableWallets: g = {},
1630
+ supportedWallets: b = [],
1631
+ step: v = "select-currency"
1632
+ }) => {
1633
+ const p = (x) => parseFloat(x).toFixed(2), j = (x) => x ? x.length <= 14 ? x : `${x.slice(0, 8)}...${x.slice(-6)}` : "", M = (x) => ({
1634
+ ethereum: "Ethereum",
1635
+ bsc: "BSC",
1636
+ tron: "Tron",
1637
+ algorand: "Algorand"
1638
+ })[x] || x, F = (x) => ({
1639
+ [N.METAMASK]: "MetaMask",
1640
+ [N.TRONLINK]: "TronLink",
1641
+ [N.TRUST_WALLET]: "Trust Wallet",
1642
+ [N.LUTE]: "Lute Wallet"
1643
+ })[x] || x, V = (x) => ({
1644
+ [N.METAMASK]: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",
1645
+ [N.TRONLINK]: "https://www.tronlink.org/images/logo.png",
1646
+ [N.TRUST_WALLET]: "https://trustwallet.com/assets/images/trust_logotype.svg",
1647
+ [N.LUTE]: "https://lute.app/logo.png"
1648
+ })[x] || "";
1649
+ return s ? /* @__PURE__ */ a.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto bg-black/50", children: /* @__PURE__ */ a.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ a.jsxs("div", { className: "relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800", children: [
1650
+ /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
1651
+ /* @__PURE__ */ a.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ a.jsx("h2", { className: "text-xl font-bold text-gray-900", children: /* @__PURE__ */ a.jsx("img", { src: St, className: "w-32", alt: "Coinley Logo" }) }) }),
1652
+ /* @__PURE__ */ a.jsx(
2584
1653
  "button",
2585
1654
  {
2586
- onClick: onClose,
1655
+ onClick: r,
2587
1656
  className: "text-gray-500 hover:text-gray-700 focus:outline-none",
2588
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1657
+ children: /* @__PURE__ */ a.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
2589
1658
  }
2590
1659
  )
2591
1660
  ] }),
2592
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
2593
- payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 p-4 rounded-lg", children: [
2594
- /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-lg text-gray-800 font-semibold", children: [
1661
+ /* @__PURE__ */ a.jsxs("div", { className: "mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
1662
+ t && /* @__PURE__ */ a.jsxs("div", { className: "mb-6 p-4 rounded-lg", children: [
1663
+ /* @__PURE__ */ a.jsxs("p", { className: "text-lg text-gray-800 font-semibold", children: [
2595
1664
  "PAY: ",
2596
- merchantName
1665
+ o
2597
1666
  ] }),
2598
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg", children: [
2599
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
2600
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl text-[#7042D2]", children: [
1667
+ /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg", children: [
1668
+ /* @__PURE__ */ a.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
1669
+ /* @__PURE__ */ a.jsxs("span", { className: "font-bold text-xl text-[#7042D2]", children: [
2601
1670
  "$",
2602
- formatAmount(payment.totalAmount || payment.amount)
1671
+ p(t.totalAmount || t.amount)
2603
1672
  ] })
2604
1673
  ] }),
2605
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-500", children: [
1674
+ /* @__PURE__ */ a.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ a.jsxs("span", { className: "text-gray-500", children: [
2606
1675
  "Payment ID: ",
2607
- payment.id ? payment.id.slice(0, 8) : "",
1676
+ t.id ? t.id.slice(0, 8) : "",
2608
1677
  "..."
2609
1678
  ] }) })
2610
1679
  ] }),
2611
- step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
2612
- PaymentMethods,
1680
+ v === "select-currency" && /* @__PURE__ */ a.jsx(
1681
+ Rt,
2613
1682
  {
2614
- onSelect: handleCurrencySelect,
2615
- selected: selectedCurrency,
2616
- theme
1683
+ onSelect: h,
1684
+ selected: u,
1685
+ theme: n,
1686
+ supportedNetworks: m
2617
1687
  }
2618
1688
  ),
2619
- step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2620
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
2621
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
2622
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
2623
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
2624
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Currency:" }),
2625
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
1689
+ v === "confirm" && u && t && /* @__PURE__ */ a.jsxs("div", { children: [
1690
+ /* @__PURE__ */ a.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
1691
+ /* @__PURE__ */ a.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
1692
+ /* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
1693
+ /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
1694
+ /* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Currency:" }),
1695
+ /* @__PURE__ */ a.jsx("span", { className: "font-medium", children: u.currency })
2626
1696
  ] }),
2627
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
2628
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Network:" }),
2629
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
1697
+ /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
1698
+ /* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Network:" }),
1699
+ /* @__PURE__ */ a.jsx("span", { className: "font-medium", children: M(u.network) })
2630
1700
  ] }),
2631
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
2632
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Fee:" }),
2633
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
1701
+ /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
1702
+ /* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Fee:" }),
1703
+ /* @__PURE__ */ a.jsx("span", { className: "font-medium", children: "1.75%" })
2634
1704
  ] })
2635
1705
  ] })
2636
1706
  ] }),
2637
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
2638
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2639
- "button",
2640
- {
2641
- onClick: () => togglePaymentMethod("wallet"),
2642
- className: `py-2 px-4 text-sm font-medium ${paymentMethod === "wallet" ? "border-b border-[#7042D2] text-[#7042D2] rounded-t-md" : "text-[#7042D2]"}`,
2643
- children: "Connect Wallet"
2644
- }
2645
- ),
2646
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2647
- "button",
2648
- {
2649
- onClick: () => togglePaymentMethod("qrcode"),
2650
- className: `py-2 px-4 text-sm font-medium ${paymentMethod === "qrcode" ? "border-b border-[#7042D2] text-[#7042D2] rounded-t-md" : "text-[#7042D2]"}`,
2651
- children: "QR Code"
2652
- }
2653
- )
2654
- ] }) }),
2655
- testMode ? (
1707
+ d ? (
2656
1708
  // Test mode payment option
2657
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
2658
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-[#7042D2] rounded-full p-2 mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
2659
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2660
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
2661
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
1709
+ /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
1710
+ /* @__PURE__ */ a.jsx("div", { className: "bg-[#7042D2] rounded-full p-2 mr-3", children: /* @__PURE__ */ a.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
1711
+ /* @__PURE__ */ a.jsxs("div", { children: [
1712
+ /* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
1713
+ /* @__PURE__ */ a.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
2662
1714
  ] })
2663
1715
  ] }) })
2664
- ) : paymentMethod === "qrcode" ? (
2665
- // QR Code payment option
2666
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2667
- QRCode,
2668
- {
2669
- walletAddress: getWalletAddressForCurrency(),
2670
- amount: payment.totalAmount || payment.amount,
2671
- currency: selectedCurrency,
2672
- theme
2673
- }
2674
- ) })
2675
- ) : isMetaMaskAvailable ? (
2676
- // MetaMask available option
2677
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: [
2678
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
2679
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2680
- "img",
2681
- {
2682
- src: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",
2683
- alt: "MetaMask",
2684
- className: "w-8 h-8 mr-2"
2685
- }
2686
- ),
2687
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2688
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Pay with MetaMask" }),
2689
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: walletConnected ? "Your wallet is connected. Click 'Pay Now' to proceed." : "Click 'Connect Wallet' to proceed with payment." })
2690
- ] })
2691
- ] }),
2692
- !walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
2693
- "button",
2694
- {
2695
- onClick: onConnectWallet,
2696
- className: "mt-3 w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
2697
- children: "Connect Wallet"
2698
- }
2699
- )
2700
- ] })
2701
1716
  ) : (
2702
- // MetaMask not available warning
2703
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-yellow-50", children: [
2704
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
2705
- /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-yellow-500 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
2706
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2707
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "MetaMask Not Detected" }),
2708
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: "Please install MetaMask extension to make payments" })
1717
+ // Real wallet connection
1718
+ /* @__PURE__ */ a.jsxs("div", { className: "space-y-3", children: [
1719
+ /* @__PURE__ */ a.jsx("h4", { className: "font-medium text-gray-800", children: "Select Wallet:" }),
1720
+ b.length === 0 ? /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-yellow-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
1721
+ /* @__PURE__ */ a.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-yellow-500 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
1722
+ /* @__PURE__ */ a.jsxs("div", { children: [
1723
+ /* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: "No Compatible Wallets" }),
1724
+ /* @__PURE__ */ a.jsxs("p", { className: "text-sm text-gray-600", children: [
1725
+ "No wallets detected for ",
1726
+ M(u.network),
1727
+ " network"
1728
+ ] })
2709
1729
  ] })
2710
- ] }),
2711
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2712
- "a",
2713
- {
2714
- href: "https://metamask.io/download/",
2715
- target: "_blank",
2716
- rel: "noopener noreferrer",
2717
- className: "block mt-3 text-center w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
2718
- children: "Install MetaMask"
2719
- }
2720
- )
1730
+ ] }) }) : b.map((x) => /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-blue-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
1731
+ /* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
1732
+ /* @__PURE__ */ a.jsx(
1733
+ "img",
1734
+ {
1735
+ src: V(x),
1736
+ alt: F(x),
1737
+ className: "w-8 h-8 mr-2",
1738
+ onError: (T) => {
1739
+ T.target.style.display = "none";
1740
+ }
1741
+ }
1742
+ ),
1743
+ /* @__PURE__ */ a.jsxs("div", { children: [
1744
+ /* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: F(x) }),
1745
+ /* @__PURE__ */ a.jsxs("p", { className: "text-sm text-gray-600", children: [
1746
+ "Pay with ",
1747
+ F(x)
1748
+ ] })
1749
+ ] })
1750
+ ] }),
1751
+ (l == null ? void 0 : l.walletType) === x ? /* @__PURE__ */ a.jsxs("div", { className: "flex items-center space-x-2", children: [
1752
+ /* @__PURE__ */ a.jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }),
1753
+ /* @__PURE__ */ a.jsx("span", { className: "text-sm text-green-600", children: "Connected" })
1754
+ ] }) : /* @__PURE__ */ a.jsx(
1755
+ "button",
1756
+ {
1757
+ onClick: () => f(x),
1758
+ className: "py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
1759
+ children: "Connect"
1760
+ }
1761
+ )
1762
+ ] }) }, x)),
1763
+ /* @__PURE__ */ a.jsx("div", { className: "space-y-2", children: Object.entries(g).filter(([x, T]) => !T).map(([x]) => /* @__PURE__ */ a.jsx("div", { className: "p-3 rounded-lg bg-gray-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
1764
+ /* @__PURE__ */ a.jsxs("span", { className: "text-sm text-gray-600", children: [
1765
+ F(x),
1766
+ " not detected"
1767
+ ] }),
1768
+ /* @__PURE__ */ a.jsx(
1769
+ "a",
1770
+ {
1771
+ href: ct(x),
1772
+ target: "_blank",
1773
+ rel: "noopener noreferrer",
1774
+ className: "text-sm text-[#7042D2] hover:underline",
1775
+ children: "Install"
1776
+ }
1777
+ )
1778
+ ] }) }, x)) })
2721
1779
  ] })
2722
1780
  ),
2723
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
2724
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1781
+ /* @__PURE__ */ a.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
1782
+ /* @__PURE__ */ a.jsx(
2725
1783
  "button",
2726
1784
  {
2727
1785
  type: "button",
2728
- onClick: handleBack,
1786
+ onClick: w,
2729
1787
  className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",
2730
1788
  children: "Back"
2731
1789
  }
2732
1790
  ),
2733
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1791
+ /* @__PURE__ */ a.jsx(
2734
1792
  "button",
2735
1793
  {
2736
1794
  type: "button",
2737
- onClick: handlePaymentConfirm,
1795
+ onClick: y,
2738
1796
  className: "w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
2739
- disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
2740
- children: "Proceed"
1797
+ disabled: !d && !l,
1798
+ children: "Pay Now"
2741
1799
  }
2742
1800
  )
2743
1801
  ] })
2744
1802
  ] }),
2745
- step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
2746
- PaymentStatus,
1803
+ v === "processing" && /* @__PURE__ */ a.jsx(
1804
+ le,
2747
1805
  {
2748
1806
  status: "processing",
2749
- theme,
1807
+ theme: n,
2750
1808
  message: "Processing your payment..."
2751
1809
  }
2752
1810
  ),
2753
- step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2754
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2755
- PaymentStatus,
1811
+ v === "success" && /* @__PURE__ */ a.jsxs("div", { children: [
1812
+ /* @__PURE__ */ a.jsx(
1813
+ le,
2756
1814
  {
2757
1815
  status: "success",
2758
- theme,
1816
+ theme: n,
2759
1817
  message: "Payment successful!"
2760
1818
  }
2761
1819
  ),
2762
- transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
2763
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
2764
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: formatTransactionHash(transactionHash) }),
2765
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1820
+ i && /* @__PURE__ */ a.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
1821
+ /* @__PURE__ */ a.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
1822
+ /* @__PURE__ */ a.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: j(i) }),
1823
+ u && /* @__PURE__ */ a.jsx(
2766
1824
  "a",
2767
1825
  {
2768
- href: `https://etherscan.io/tx/${transactionHash}`,
1826
+ href: `${Pt(u.network)}/tx/${i}`,
2769
1827
  target: "_blank",
2770
1828
  rel: "noopener noreferrer",
2771
1829
  className: "text-xs text-[#7042D2] mt-2 inline-block",
2772
- children: "View on Etherscan →"
1830
+ children: "View on Explorer →"
2773
1831
  }
2774
1832
  )
2775
1833
  ] })
2776
1834
  ] }),
2777
- step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
2778
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2779
- PaymentStatus,
1835
+ v === "error" && /* @__PURE__ */ a.jsxs("div", { children: [
1836
+ /* @__PURE__ */ a.jsx(
1837
+ le,
2780
1838
  {
2781
1839
  status: "error",
2782
- theme,
2783
- message: error || "An error occurred while processing your payment."
1840
+ theme: n,
1841
+ message: e || "An error occurred while processing your payment."
2784
1842
  }
2785
1843
  ),
2786
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1844
+ /* @__PURE__ */ a.jsx(
2787
1845
  "button",
2788
1846
  {
2789
1847
  type: "button",
2790
- onClick: handleBack,
1848
+ onClick: w,
2791
1849
  className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
2792
1850
  children: "Try Again"
2793
1851
  }
2794
1852
  )
2795
1853
  ] })
2796
1854
  ] }),
2797
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { children: [
1855
+ /* @__PURE__ */ a.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ a.jsxs("p", { children: [
2798
1856
  "Powered by ",
2799
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[#7042D2]", children: "Coinley" }),
1857
+ /* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2]", children: "Coinley" }),
2800
1858
  " - Secure Cryptocurrency Payments"
2801
1859
  ] }) })
2802
- ] }) }) });
2803
- };
2804
- const CoinleyCheckout = forwardRef(({
2805
- apiKey,
2806
- apiSecret,
2807
- apiUrl,
2808
- customerEmail,
2809
- merchantName = "Merchant",
2810
- merchantWalletAddress,
2811
- // New prop for direct wallet address passing
2812
- merchantSolWalletAddress,
2813
- // New prop for direct Solana wallet address passing
2814
- onSuccess,
2815
- onError,
2816
- onClose,
2817
- theme,
2818
- autoOpen = false,
2819
- debug = false,
2820
- testMode = false,
2821
- preferredNetwork = "ethereum",
2822
- preferredWallet = "metamask"
2823
- }, ref) => {
2824
- const coinleyContext = useCoinley();
2825
- const { theme: contextTheme } = useTheme();
2826
- const [isOpen, setIsOpen] = useState(autoOpen);
2827
- const [payment, setPayment] = useState(null);
2828
- const [paymentStatus, setPaymentStatus] = useState("idle");
2829
- const [selectedCurrency, setSelectedCurrency] = useState("USDT");
2830
- const [error, setError] = useState(null);
2831
- const [transactionHash, setTransactionHash] = useState(null);
2832
- const [walletConnected, setWalletConnected] = useState(false);
2833
- const [walletAddresses, setWalletAddresses] = useState({
2834
- ethereum: null,
2835
- solana: null
2836
- });
2837
- apiKey || (coinleyContext == null ? void 0 : coinleyContext.apiKey);
2838
- apiSecret || (coinleyContext == null ? void 0 : coinleyContext.apiSecret);
2839
- apiUrl || (coinleyContext == null ? void 0 : coinleyContext.apiUrl);
2840
- const effectiveTheme = theme || contextTheme;
2841
- const effectiveDebug = debug || (coinleyContext == null ? void 0 : coinleyContext.debug);
2842
- const effectiveWalletAddress = merchantWalletAddress || (coinleyContext == null ? void 0 : coinleyContext.merchantWalletAddress) || walletAddresses.ethereum;
2843
- const effectiveSolWalletAddress = merchantSolWalletAddress || (coinleyContext == null ? void 0 : coinleyContext.merchantSolWalletAddress) || walletAddresses.solana;
2844
- useImperativeHandle(ref, () => ({
2845
- open: (paymentDetails) => {
2846
- handleOpen(paymentDetails);
1860
+ ] }) }) }) : null;
1861
+ }, Pt = (s) => ({
1862
+ ethereum: "https://etherscan.io",
1863
+ bsc: "https://bscscan.com",
1864
+ tron: "https://tronscan.org",
1865
+ algorand: "https://algoexplorer.io"
1866
+ })[s] || "https://etherscan.io", Ot = Ye(({
1867
+ apiKey: s,
1868
+ apiSecret: r,
1869
+ apiUrl: t,
1870
+ customerEmail: c,
1871
+ merchantName: u = "Merchant",
1872
+ merchantWalletAddresses: h = {},
1873
+ // Object with network-specific addresses
1874
+ onSuccess: y,
1875
+ onError: w,
1876
+ onClose: e,
1877
+ theme: n,
1878
+ autoOpen: o = !1,
1879
+ debug: i = !1,
1880
+ testMode: l = !1,
1881
+ supportedNetworks: f = [],
1882
+ // Array of supported networks
1883
+ preferredNetwork: d = A.ETHEREUM,
1884
+ preferredWallet: m = N.METAMASK
1885
+ }, g) => {
1886
+ const b = Nt(), { theme: v } = xt(), [p, j] = U(o), [M, F] = U(null), [V, x] = U("idle"), [T, q] = U(null), [I, B] = U(null), [ee, W] = U(null), [O, $] = U(null), [H, te] = U({}), [X, G] = U("select-currency");
1887
+ s || (b == null || b.apiKey), r || (b == null || b.apiSecret), t || (b == null || b.apiUrl);
1888
+ const oe = n || v, re = i || (b == null ? void 0 : b.debug), ae = f.length > 0 ? f : [A.ETHEREUM, A.BSC, A.TRON, A.ALGORAND];
1889
+ Je(g, () => ({
1890
+ open: (C) => {
1891
+ Fe(C);
2847
1892
  },
2848
1893
  close: () => {
2849
- handleClose();
1894
+ he();
2850
1895
  },
2851
- getPayment: () => payment
1896
+ getPayment: () => M,
1897
+ getWalletConnection: () => O
2852
1898
  }));
2853
- const log = (message, data) => {
2854
- if (effectiveDebug) {
2855
- console.log(`[Coinley SDK] ${message}`, data);
2856
- }
2857
- };
2858
- useEffect(() => {
2859
- if (typeof window !== "undefined") {
2860
- const checkWalletConnection = async () => {
2861
- if (isMetaMaskInstalled()) {
2862
- try {
2863
- const accounts = await window.ethereum.request({ method: "eth_accounts" });
2864
- setWalletConnected(accounts && accounts.length > 0);
2865
- } catch (err) {
2866
- log("Error checking wallet connection:", err);
2867
- setWalletConnected(false);
2868
- }
2869
- } else {
2870
- setWalletConnected(false);
2871
- }
2872
- };
2873
- checkWalletConnection();
2874
- if (!effectiveWalletAddress || !effectiveSolWalletAddress) {
2875
- fetchMerchantWalletAddresses();
2876
- }
2877
- }
2878
- }, [effectiveDebug]);
2879
- const fetchMerchantWalletAddresses = async () => {
2880
- try {
2881
- log("Fetching merchant wallet addresses...");
2882
- const addresses = await getMerchantWalletAddresses();
2883
- log("Received merchant wallet addresses:", addresses);
2884
- setWalletAddresses({
2885
- ethereum: addresses.walletAddress,
2886
- solana: addresses.solWalletAddress
2887
- });
2888
- } catch (err) {
2889
- log("Error fetching merchant wallet addresses:", err);
2890
- }
1899
+ const L = (C, D) => {
1900
+ re && console.log(`[Coinley SDK] ${C}`, D);
2891
1901
  };
2892
- useEffect(() => {
2893
- if (typeof window !== "undefined" && window.ethereum) {
2894
- const handleAccountsChanged = (accounts) => {
2895
- setWalletConnected(accounts.length > 0);
2896
- };
2897
- window.ethereum.on("accountsChanged", handleAccountsChanged);
2898
- return () => {
2899
- window.ethereum.removeListener("accountsChanged", handleAccountsChanged);
2900
- };
2901
- }
2902
- return () => {
2903
- };
2904
- }, []);
2905
- const handleOpen = async (paymentDetails) => {
2906
- if (!paymentDetails || !paymentDetails.amount) {
2907
- setError("Payment amount is required");
2908
- if (onError)
2909
- onError(new Error("Payment amount is required"));
1902
+ Z(() => {
1903
+ if (typeof window != "undefined") {
1904
+ const C = ue();
1905
+ te(C), L("Available wallets detected:", C);
1906
+ }
1907
+ }, [re]);
1908
+ const Fe = (C) => R(void 0, null, function* () {
1909
+ if (!C || !C.amount) {
1910
+ B("Payment amount is required"), w && w(new Error("Payment amount is required"));
2910
1911
  return;
2911
1912
  }
2912
- setPaymentStatus("loading");
2913
- setIsOpen(true);
1913
+ x("loading"), j(!0), G("select-currency");
2914
1914
  try {
2915
- log("Creating payment with details:", paymentDetails);
2916
- const paymentResponse = await createPayment({
2917
- amount: paymentDetails.amount,
2918
- currency: paymentDetails.currency || "USDT",
2919
- customerEmail: paymentDetails.customerEmail || customerEmail,
2920
- callbackUrl: paymentDetails.callbackUrl,
2921
- metadata: paymentDetails.metadata || {},
2922
- // Add wallet addresses if available
2923
- walletAddress: effectiveWalletAddress,
2924
- solWalletAddress: effectiveSolWalletAddress
2925
- });
2926
- log("Payment created:", paymentResponse);
2927
- const enhancedPayment = {
2928
- ...paymentResponse.payment,
2929
- walletAddress: paymentResponse.payment.walletAddress || effectiveWalletAddress,
2930
- solWalletAddress: paymentResponse.payment.solWalletAddress || effectiveSolWalletAddress
2931
- };
2932
- setPayment(enhancedPayment);
2933
- setPaymentStatus("idle");
2934
- setError(null);
2935
- if (preferredNetwork === "solana") {
2936
- setSelectedCurrency("SOL");
2937
- }
2938
- log("Payment created and state updated:", {
2939
- payment: enhancedPayment,
2940
- status: "idle"
1915
+ L("Creating payment with details:", C);
1916
+ const D = yield ut({
1917
+ amount: C.amount,
1918
+ currency: C.currency || "USDT",
1919
+ network: C.network || d,
1920
+ customerEmail: C.customerEmail || c,
1921
+ callbackUrl: C.callbackUrl,
1922
+ metadata: C.metadata || {},
1923
+ merchantWalletAddresses: z(z({}, h), C.merchantWalletAddresses)
2941
1924
  });
2942
- } catch (err) {
2943
- log("Error creating payment:", err);
2944
- setError(err.message || "Failed to create payment");
2945
- setPaymentStatus("error");
2946
- if (onError)
2947
- onError(err);
2948
- }
2949
- };
2950
- const handleClose = () => {
2951
- setIsOpen(false);
2952
- setTransactionHash(null);
2953
- if (onClose)
2954
- onClose();
2955
- };
2956
- const handlePaymentMethodSelect = (currency) => {
2957
- log("Currency selected:", currency);
2958
- setSelectedCurrency(currency);
2959
- };
2960
- const connectToWallet = async () => {
2961
- if (!isMetaMaskInstalled()) {
2962
- setError("MetaMask is not installed. Please install MetaMask to make payments.");
2963
- return false;
1925
+ L("Payment created:", D), F(D.payment), x("idle"), B(null), L("Payment created and state updated");
1926
+ } catch (D) {
1927
+ L("Error creating payment:", D), B(D.message || "Failed to create payment"), x("error"), w && w(D);
1928
+ }
1929
+ }), he = () => {
1930
+ j(!1), W(null), $(null), q(null), G("select-currency"), e && e();
1931
+ }, Be = (C) => {
1932
+ L("Payment method selected:", C), q(C), G("confirm");
1933
+ }, We = () => {
1934
+ X === "confirm" && (G("select-currency"), $(null));
1935
+ }, Qe = (C) => R(void 0, null, function* () {
1936
+ if (!T) {
1937
+ B("Please select a payment method first");
1938
+ return;
2964
1939
  }
2965
1940
  try {
2966
- const accounts = await connectWallet();
2967
- setWalletConnected(accounts.length > 0);
2968
- return accounts.length > 0;
2969
- } catch (err) {
2970
- log("Error connecting to wallet:", err);
2971
- setError(err.message || "Failed to connect to wallet");
2972
- return false;
1941
+ L("Connecting wallet:", { walletType: C, network: T.network });
1942
+ const D = yield et(C, T.network);
1943
+ $(D), B(null), L("Wallet connected successfully:", D);
1944
+ } catch (D) {
1945
+ L("Wallet connection error:", D), B(D.message || "Failed to connect wallet");
1946
+ }
1947
+ }), ze = () => R(void 0, null, function* () {
1948
+ var C, D;
1949
+ if (!M || !T) {
1950
+ B("Missing payment information");
1951
+ return;
2973
1952
  }
2974
- };
2975
- const handlePayment = async (isQrCodeMode = false) => {
2976
- if (!payment) {
2977
- setError("No active payment to process");
1953
+ if (!O && !l) {
1954
+ B("Please connect your wallet first");
2978
1955
  return;
2979
1956
  }
2980
- log("Starting payment process...", { isQrCodeMode });
2981
- setPaymentStatus("loading");
2982
- setTransactionHash(null);
1957
+ L("Starting payment process..."), x("loading"), W(null);
2983
1958
  try {
2984
- log("Processing payment:", {
2985
- paymentId: payment.id,
2986
- currency: selectedCurrency,
2987
- isQrCodeMode,
2988
- walletAddress: payment.walletAddress,
2989
- solWalletAddress: payment.solWalletAddress
2990
- });
2991
- let txHash;
2992
- if (testMode) {
2993
- log("Test mode: Generating mock transaction...");
2994
- txHash = `0x${Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`;
2995
- } else if (isQrCodeMode) {
2996
- log("QR code payment: User confirms payment was sent");
2997
- txHash = `qrcode_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
2998
- } else {
2999
- if (!walletConnected) {
3000
- const connected = await connectToWallet();
3001
- if (!connected) {
3002
- throw new Error("Please connect your wallet to proceed with payment");
3003
- }
3004
- }
3005
- const isSolana = selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL";
3006
- const merchantAddress = isSolana ? payment.solWalletAddress || effectiveSolWalletAddress : payment.walletAddress || effectiveWalletAddress;
3007
- if (!merchantAddress) {
3008
- throw new Error(`No ${isSolana ? "Solana" : "Ethereum"} wallet address is configured for the merchant. Please contact support.`);
3009
- }
3010
- const txParams = {
3011
- from: await window.ethereum.request({ method: "eth_requestAccounts" }).then((accounts) => accounts[0]),
3012
- to: merchantAddress,
3013
- value: "0x0",
3014
- // For ERC-20 tokens, value is 0
3015
- data: "0x"
3016
- // Would include token transfer data for ERC-20
3017
- };
3018
- log("Sending transaction to wallet for approval...");
3019
- txHash = await sendTransaction(txParams);
1959
+ let Q;
1960
+ if (l)
1961
+ L("Test mode: Generating mock transaction..."), Q = `test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
1962
+ else {
1963
+ const me = h[T.network];
1964
+ if (!me)
1965
+ throw new Error(`No merchant wallet address configured for ${T.network}`);
1966
+ L("Sending transaction through wallet..."), Q = yield ot(O, {
1967
+ to: me,
1968
+ amount: M.amount,
1969
+ tokenAddress: (C = T.tokenConfig) == null ? void 0 : C.address,
1970
+ tokenDecimals: (D = T.tokenConfig) == null ? void 0 : D.decimals
1971
+ });
3020
1972
  }
3021
- log("Transaction hash:", txHash);
3022
- setTransactionHash(txHash);
3023
- log("Sending process payment request to API...");
3024
- const processResponse = await processPayment({
3025
- paymentId: payment.id,
3026
- transactionHash: txHash,
3027
- network: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "solana" : "ethereum"
1973
+ L("Transaction hash:", Q), W(Q), L("Processing payment with backend...");
1974
+ const He = yield ht({
1975
+ paymentId: M.id,
1976
+ transactionHash: Q,
1977
+ network: T.network,
1978
+ currency: T.currency,
1979
+ senderAddress: O == null ? void 0 : O.address
3028
1980
  });
3029
- log("Payment processed successfully:", processResponse);
3030
- setPaymentStatus("success");
3031
- if (onSuccess) {
3032
- log("Calling onSuccess callback...");
3033
- onSuccess(payment.id, txHash);
3034
- }
3035
- } catch (err) {
3036
- log("Payment error:", err);
3037
- setError(err.message || "Failed to process payment");
3038
- setPaymentStatus("error");
3039
- if (onError)
3040
- onError(err);
3041
- }
3042
- };
3043
- useEffect(() => {
3044
- if (autoOpen && payment) {
3045
- setIsOpen(true);
3046
- }
3047
- }, [autoOpen, payment]);
3048
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
3049
- CoinleyModal,
1981
+ L("Payment processed successfully:", He), x("success"), G("success"), y && (L("Calling onSuccess callback..."), y(M.id, Q, {
1982
+ network: T.network,
1983
+ currency: T.currency,
1984
+ amount: M.amount
1985
+ }));
1986
+ } catch (Q) {
1987
+ L("Payment error:", Q), B(Q.message || "Failed to process payment"), x("error"), G("error"), w && w(Q);
1988
+ }
1989
+ }), Ge = () => T ? Ne(T.network) : [];
1990
+ return /* @__PURE__ */ a.jsx(a.Fragment, { children: p && /* @__PURE__ */ a.jsx(
1991
+ Lt,
3050
1992
  {
3051
- isOpen,
3052
- onClose: handleClose,
3053
- payment,
3054
- paymentStatus,
3055
- selectedCurrency,
3056
- onCurrencySelect: handlePaymentMethodSelect,
3057
- onPayment: handlePayment,
3058
- error,
3059
- theme: effectiveTheme,
3060
- merchantName,
3061
- transactionHash,
3062
- walletConnected,
3063
- onConnectWallet: connectToWallet,
3064
- testMode,
3065
- preferredNetwork,
3066
- preferredWallet
1993
+ isOpen: p,
1994
+ onClose: he,
1995
+ payment: M,
1996
+ paymentStatus: V,
1997
+ selectedPaymentMethod: T,
1998
+ onPaymentMethodSelect: Be,
1999
+ onPayment: ze,
2000
+ onBack: We,
2001
+ error: I,
2002
+ theme: oe,
2003
+ merchantName: u,
2004
+ transactionHash: ee,
2005
+ walletConnection: O,
2006
+ onConnectWallet: Qe,
2007
+ testMode: l,
2008
+ supportedNetworks: ae,
2009
+ availableWallets: H,
2010
+ supportedWallets: Ge(),
2011
+ step: X
3067
2012
  }
3068
2013
  ) });
3069
2014
  });
3070
- CoinleyCheckout.displayName = "CoinleyCheckout";
3071
- const DEFAULT_CONFIG = {
3072
- apiUrl: "https://coinleyserver-production.up.railway.app",
3073
- debug: false,
3074
- testMode: false,
3075
- theme: "light"
3076
- };
3077
- const VERSION = "0.2.9";
2015
+ Ot.displayName = "CoinleyCheckout";
2016
+ const qt = {
2017
+ apiUrl: "http://localhost:9000",
2018
+ debug: !1,
2019
+ testMode: !1,
2020
+ theme: "light",
2021
+ supportedNetworks: ["ethereum", "bsc", "tron", "algorand"]
2022
+ }, $t = "0.3.1";
3078
2023
  export {
3079
- CoinleyCheckout,
3080
- CoinleyModal,
3081
- CoinleyProvider,
3082
- DEFAULT_CONFIG,
3083
- PaymentMethods,
3084
- PaymentStatus,
3085
- QRCode,
3086
- ThemeProvider,
3087
- VERSION,
3088
- connectWallet,
3089
- createPayment,
3090
- getPayment,
3091
- isMetaMaskInstalled,
3092
- processPayment
2024
+ Ot as CoinleyCheckout,
2025
+ Lt as CoinleyModal,
2026
+ Gt as CoinleyProvider,
2027
+ qt as DEFAULT_CONFIG,
2028
+ de as NETWORK_CONFIG,
2029
+ A as NETWORK_TYPES,
2030
+ Rt as PaymentMethods,
2031
+ le as PaymentStatus,
2032
+ Vt as QRCode,
2033
+ Xe as TOKEN_CONFIG,
2034
+ zt as ThemeProvider,
2035
+ $t as VERSION,
2036
+ N as WALLET_TYPES,
2037
+ et as connectWallet,
2038
+ ut as createPayment,
2039
+ ue as detectWallets,
2040
+ Qt as generateMockTransactionHash,
2041
+ Bt as getMerchantProfile,
2042
+ It as getPayment,
2043
+ Ft as getSupportedNetworks,
2044
+ Ne as getSupportedWalletsForNetwork,
2045
+ ct as getWalletInstallUrl,
2046
+ ht as processPayment,
2047
+ ot as sendTransaction,
2048
+ Nt as useCoinley,
2049
+ Wt as validateWalletAddress
3093
2050
  };
3094
2051
  //# sourceMappingURL=coinley-checkout.es.js.map