@micro-cms/crypto-payments 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVMProvider-XRVRSEAC.mjs +2 -0
- package/dist/EVMProvider-XRVRSEAC.mjs.map +1 -0
- package/dist/SolanaProvider-NYVHYJTF.mjs +2 -0
- package/dist/SolanaProvider-NYVHYJTF.mjs.map +1 -0
- package/dist/chunk-73SFLUWV.mjs +2 -0
- package/dist/chunk-73SFLUWV.mjs.map +1 -0
- package/dist/index.d.mts +3 -46
- package/dist/index.d.ts +3 -46
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-73SFLUWV.mjs";var u=()=>{let r=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},a=async()=>{let e=r();if(e)try{return(await e.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or EVM wallet not found")},s=async e=>{let t=r();if(!t)throw new Error("Wallet not connected");let n=await t.request({method:"eth_accounts"});if(!n||n.length===0)throw new Error("No accounts found. Please connect your wallet first.");let c=e.currency.toUpperCase()==="USDC"?6:18,i="0x"+BigInt(Math.floor(Number(e.amount)*Math.pow(10,c))).toString(16);try{return await t.request({method:"eth_sendTransaction",params:[{from:n[0],to:e.paymentAddress,value:e.currency.toUpperCase()==="ETH"?i:"0x0"}]})}catch(o){throw o.code===4001?new Error("Transaction rejected by user"):new Error(o.message||"Failed to send transaction")}};return{isAvailable:!!r(),connect:a,sendPayment:s}};export{u as useEVMWallet};
|
|
2
|
+
//# sourceMappingURL=EVMProvider-XRVRSEAC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/EVMProvider.ts"],"sourcesContent":["import { PaymentIntent } from '@micro-cms/types';\n\nexport interface EthereumWindow extends Window {\n ethereum?: {\n isMetaMask?: boolean;\n request: (request: { method: string; params?: any[] }) => Promise<any>;\n on: (event: string, callback: (...args: any[]) => void) => void;\n removeListener: (event: string, callback: (...args: any[]) => void) => void;\n };\n}\n\nexport const useEVMWallet = () => {\n const getProvider = (): (EthereumWindow['ethereum']) => {\n if (typeof window !== 'undefined' && 'ethereum' in window) {\n return (window as EthereumWindow).ethereum;\n }\n return undefined;\n };\n\n const connect = async () => {\n const provider = getProvider();\n if (provider) {\n try {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n return accounts[0];\n } catch (err) {\n throw new Error('User rejected the connection');\n }\n } else {\n throw new Error('MetaMask or EVM wallet not found');\n }\n };\n\n const sendPayment = async (intent: PaymentIntent) => {\n const provider = getProvider();\n if (!provider) throw new Error('Wallet not connected');\n\n const accounts = await provider.request({ method: 'eth_accounts' });\n if (!accounts || accounts.length === 0) {\n throw new Error('No accounts found. Please connect your wallet first.');\n }\n\n // Convert amount to Wei (assuming 18 decimals for ETH/Standard tokens)\n // For USDC on EVM, it's usually 6 decimals. \n // This logic should ideally be more robust based on the token.\n const decimals = intent.currency.toUpperCase() === 'USDC' ? 6 : 18;\n const value = '0x' + (BigInt(Math.floor(Number(intent.amount) * Math.pow(10, decimals)))).toString(16);\n\n try {\n const txHash = await provider.request({\n method: 'eth_sendTransaction',\n params: [{\n from: accounts[0],\n to: intent.paymentAddress,\n value: intent.currency.toUpperCase() === 'ETH' ? value : '0x0', // Only value for native currency\n // If it was a token transfer, we would need the data field with transfer(address,uint256)\n }],\n });\n\n return txHash;\n } catch (err: any) {\n if (err.code === 4001) {\n throw new Error('Transaction rejected by user');\n }\n throw new Error(err.message || 'Failed to send transaction');\n }\n };\n\n return { isAvailable: !!getProvider(), connect, sendPayment };\n};\n"],"mappings":"6BAWO,IAAMA,EAAe,IAAM,CAChC,IAAMC,EAAc,IAAoC,CACtD,GAAI,OAAO,OAAW,KAAe,aAAc,OACjD,OAAQ,OAA0B,QAGtC,EAEMC,EAAU,SAAY,CAC1B,IAAMC,EAAWF,EAAY,EAC7B,GAAIE,EACF,GAAI,CAEF,OADiB,MAAMA,EAAS,QAAQ,CAAE,OAAQ,qBAAsB,CAAC,GACzD,CAAC,CACnB,MAAc,CACZ,MAAM,IAAI,MAAM,8BAA8B,CAChD,KAEA,OAAM,IAAI,MAAM,kCAAkC,CAEtD,EAEMC,EAAc,MAAOC,GAA0B,CACnD,IAAMF,EAAWF,EAAY,EAC7B,GAAI,CAACE,EAAU,MAAM,IAAI,MAAM,sBAAsB,EAErD,IAAMG,EAAW,MAAMH,EAAS,QAAQ,CAAE,OAAQ,cAAe,CAAC,EAClE,GAAI,CAACG,GAAYA,EAAS,SAAW,EACnC,MAAM,IAAI,MAAM,sDAAsD,EAMxE,IAAMC,EAAWF,EAAO,SAAS,YAAY,IAAM,OAAS,EAAI,GAC1DG,EAAQ,KAAQ,OAAO,KAAK,MAAM,OAAOH,EAAO,MAAM,EAAI,KAAK,IAAI,GAAIE,CAAQ,CAAC,CAAC,EAAG,SAAS,EAAE,EAErG,GAAI,CAWF,OAVe,MAAMJ,EAAS,QAAQ,CACpC,OAAQ,sBACR,OAAQ,CAAC,CACP,KAAMG,EAAS,CAAC,EAChB,GAAID,EAAO,eACX,MAAOA,EAAO,SAAS,YAAY,IAAM,MAAQG,EAAQ,KAE3D,CAAC,CACH,CAAC,CAGH,OAASC,EAAU,CACjB,MAAIA,EAAI,OAAS,KACT,IAAI,MAAM,8BAA8B,EAE1C,IAAI,MAAMA,EAAI,SAAW,4BAA4B,CAC7D,CACF,EAEA,MAAO,CAAE,YAAa,CAAC,CAACR,EAAY,EAAG,QAAAC,EAAS,YAAAE,CAAY,CAC9D","names":["useEVMWallet","getProvider","connect","provider","sendPayment","intent","accounts","decimals","value","err"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-73SFLUWV.mjs";import{Connection as A,PublicKey as a,Transaction as E,SystemProgram as b,LAMPORTS_PER_SOL as M}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as k,createTransferInstruction as v,getMint as U}from"@solana/spl-token";var C=new a("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),I=new a("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),_=()=>{let r=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},u=async()=>{let n=r();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},m=async(n,s)=>{let c=r();if(!c)throw new Error("Wallet not connected");try{let t=n.network?.toLowerCase().includes("mainnet")||n.network==="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"||!window.location.host.includes("localhost")&&!window.location.host.includes("dev.")&&!n.network?.toLowerCase().includes("devnet"),p=s||(t?"https://api.mainnet-beta.solana.com":"https://api.devnet.solana.com"),d=new A(p,"confirmed"),y=await c.connect({onlyIfTrusted:!0}),e=new a(y.publicKey.toString()),l=new a(n.paymentAddress),o=new E;if(n.currency?.toUpperCase()==="USDC"){let i=t?I:C,P=await U(d,i),g=Math.round(Number(n.amount)*Math.pow(10,P.decimals)),{getAssociatedTokenAddress:w}=await import("@solana/spl-token"),T=await w(i,e),S=await w(i,l);o.add(v(T,S,e,g,[],k))}else o.add(b.transfer({fromPubkey:e,toPubkey:l,lamports:Math.round(Number(n.amount)*M)}));let{blockhash:h}=await d.getLatestBlockhash();o.recentBlockhash=h,o.feePayer=e;let{signature:f}=await c.signAndSendTransaction(o);return f}catch(t){throw console.error("Solana Transaction Error:",t),t.message?.includes("User rejected")?new Error("Transaction rejected by user"):new Error(t.message||"Failed to send Solana transaction")}};return{isAvailable:!!r(),connect:u,sendPayment:m}};export{_ as useSolanaWallet};
|
|
2
|
+
//# sourceMappingURL=SolanaProvider-NYVHYJTF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/SolanaProvider.ts"],"sourcesContent":["import { PaymentIntent } from '@micro-cms/types';\nimport { \n Connection, \n PublicKey, \n Transaction, \n SystemProgram, \n LAMPORTS_PER_SOL \n} from '@solana/web3.js';\nimport { \n TOKEN_PROGRAM_ID, \n getOrCreateAssociatedTokenAccount, \n createTransferInstruction, \n getMint \n} from '@solana/spl-token';\n\nexport interface SolanaWindow extends Window {\n solana?: {\n isPhantom?: boolean;\n connect: (options?: { onlyIfTrusted?: boolean }) => Promise<{ publicKey: { toString: () => string } }>;\n signTransaction: (transaction: Transaction) => Promise<Transaction>;\n signAndSendTransaction: (transaction: Transaction) => Promise<{ signature: string }>;\n request: (request: { method: string; params?: any }) => Promise<any>;\n };\n}\n\n// USDC Mint Addresses\nconst USDC_MINT_DEVNET = new PublicKey('4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU');\nconst USDC_MINT_MAINNET = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');\n\nexport const useSolanaWallet = () => {\n const getProvider = (): (SolanaWindow['solana']) => {\n if (typeof window !== 'undefined' && 'solana' in window) {\n const anyWindow = window as SolanaWindow;\n if (anyWindow.solana?.isPhantom) {\n return anyWindow.solana;\n }\n }\n return undefined;\n };\n\n const connect = async () => {\n const provider = getProvider();\n if (provider) {\n try {\n const resp = await provider.connect();\n return resp.publicKey.toString();\n } catch (err) {\n throw new Error('User rejected the connection');\n }\n } else {\n throw new Error('Phantom wallet not found');\n }\n };\n\n const sendPayment = async (intent: PaymentIntent, customRpcUrl?: string) => {\n const provider = getProvider();\n if (!provider) throw new Error('Wallet not connected');\n\n try {\n // Determine if this is a Devnet or Mainnet transaction\n const isMainnet = \n intent.network?.toLowerCase().includes('mainnet') || \n intent.network === 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' || // Mainnet genesis hash\n (!window.location.host.includes('localhost') && \n !window.location.host.includes('dev.') && \n !intent.network?.toLowerCase().includes('devnet'));\n \n const defaultRpcUrl = isMainnet ? 'https://api.mainnet-beta.solana.com' : 'https://api.devnet.solana.com';\n const rpcUrl = customRpcUrl || defaultRpcUrl;\n const connection = new Connection(rpcUrl, 'confirmed');\n \n const accounts = await provider.connect({ onlyIfTrusted: true });\n const fromPubkey = new PublicKey(accounts.publicKey.toString());\n const toPubkey = new PublicKey(intent.paymentAddress);\n\n const transaction = new Transaction();\n\n // Handle USDC vs SOL\n if (intent.currency?.toUpperCase() === 'USDC') {\n const mintAddress = isMainnet ? USDC_MINT_MAINNET : USDC_MINT_DEVNET;\n \n // 1. Get decimals from mint (USDC is usually 6)\n const mintInfo = await getMint(connection, mintAddress);\n const amount = Math.round(Number(intent.amount) * Math.pow(10, mintInfo.decimals));\n\n // Note: For production use with real Phantom, we'd need to handle ATA creation carefully.\n // For simplicity in the widget, we assume the destination has an ATA.\n // We'll use the browser wallet's signAndSendTransaction.\n\n // In a real-world scenario, you'd use getAssociatedTokenAddress for sender and receiver.\n // We need to fetch/create the receiver's ATA if it doesn't exist.\n // Since we can't easily sign for the fee of creating receiver ATA in the widget without knowing the fee payer's full context,\n // we'll use a simplified version for now.\n\n // Get Associated Token Addresses\n const { getAssociatedTokenAddress } = await import('@solana/spl-token');\n const fromAta = await getAssociatedTokenAddress(mintAddress, fromPubkey);\n const toAta = await getAssociatedTokenAddress(mintAddress, toPubkey);\n\n transaction.add(\n createTransferInstruction(\n fromAta,\n toAta,\n fromPubkey,\n amount,\n [],\n TOKEN_PROGRAM_ID\n )\n );\n } else {\n // Fallback to Native SOL\n transaction.add(\n SystemProgram.transfer({\n fromPubkey,\n toPubkey,\n lamports: Math.round(Number(intent.amount) * LAMPORTS_PER_SOL),\n })\n );\n }\n\n // 3. Set latest blockhash\n const { blockhash } = await connection.getLatestBlockhash();\n transaction.recentBlockhash = blockhash;\n transaction.feePayer = fromPubkey;\n\n // 4. Sign and Send\n const { signature } = await provider.signAndSendTransaction(transaction);\n \n return signature;\n } catch (err: any) {\n console.error('Solana Transaction Error:', err);\n if (err.message?.includes('User rejected')) {\n throw new Error('Transaction rejected by user');\n }\n throw new Error(err.message || 'Failed to send Solana transaction');\n }\n };\n\n return { isAvailable: !!getProvider(), connect, sendPayment };\n};\n"],"mappings":"6BACA,OACE,cAAAA,EACA,aAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,oBAAAC,MACK,kBACP,OACE,oBAAAC,EAEA,6BAAAC,EACA,WAAAC,MACK,oBAaP,IAAMC,EAAmB,IAAIP,EAAU,8CAA8C,EAC/EQ,EAAoB,IAAIR,EAAU,8CAA8C,EAEzES,EAAkB,IAAM,CACnC,IAAMC,EAAc,IAAgC,CAClD,GAAI,OAAO,OAAW,KAAe,WAAY,OAAQ,CACvD,IAAMC,EAAY,OAClB,GAAIA,EAAU,QAAQ,UACpB,OAAOA,EAAU,MAErB,CAEF,EAEMC,EAAU,SAAY,CAC1B,IAAMC,EAAWH,EAAY,EAC7B,GAAIG,EACF,GAAI,CAEF,OADa,MAAMA,EAAS,QAAQ,GACxB,UAAU,SAAS,CACjC,MAAc,CACZ,MAAM,IAAI,MAAM,8BAA8B,CAChD,KAEA,OAAM,IAAI,MAAM,0BAA0B,CAE9C,EAEMC,EAAc,MAAOC,EAAuBC,IAA0B,CAC1E,IAAMH,EAAWH,EAAY,EAC7B,GAAI,CAACG,EAAU,MAAM,IAAI,MAAM,sBAAsB,EAErD,GAAI,CAEF,IAAMI,EACJF,EAAO,SAAS,YAAY,EAAE,SAAS,SAAS,GAChDA,EAAO,UAAY,2CAClB,CAAC,OAAO,SAAS,KAAK,SAAS,WAAW,GAC1C,CAAC,OAAO,SAAS,KAAK,SAAS,MAAM,GACrC,CAACA,EAAO,SAAS,YAAY,EAAE,SAAS,QAAQ,EAG7CG,EAASF,IADOC,EAAY,sCAAwC,iCAEpEE,EAAa,IAAIpB,EAAWmB,EAAQ,WAAW,EAE/CE,EAAW,MAAMP,EAAS,QAAQ,CAAE,cAAe,EAAK,CAAC,EACzDQ,EAAa,IAAIrB,EAAUoB,EAAS,UAAU,SAAS,CAAC,EACxDE,EAAW,IAAItB,EAAUe,EAAO,cAAc,EAE9CQ,EAAc,IAAItB,EAGxB,GAAIc,EAAO,UAAU,YAAY,IAAM,OAAQ,CAC7C,IAAMS,EAAcP,EAAYT,EAAoBD,EAG9CkB,EAAW,MAAMnB,EAAQa,EAAYK,CAAW,EAChDE,EAAS,KAAK,MAAM,OAAOX,EAAO,MAAM,EAAI,KAAK,IAAI,GAAIU,EAAS,QAAQ,CAAC,EAY3E,CAAE,0BAAAE,CAA0B,EAAI,KAAM,QAAO,mBAAmB,EAChEC,EAAU,MAAMD,EAA0BH,EAAaH,CAAU,EACjEQ,EAAQ,MAAMF,EAA0BH,EAAaF,CAAQ,EAEnEC,EAAY,IACVlB,EACEuB,EACAC,EACAR,EACAK,EACA,CAAC,EACDtB,CACF,CACF,CACF,MAEEmB,EAAY,IACVrB,EAAc,SAAS,CACrB,WAAAmB,EACA,SAAAC,EACA,SAAU,KAAK,MAAM,OAAOP,EAAO,MAAM,EAAIZ,CAAgB,CAC/D,CAAC,CACH,EAIF,GAAM,CAAE,UAAA2B,CAAU,EAAI,MAAMX,EAAW,mBAAmB,EAC1DI,EAAY,gBAAkBO,EAC9BP,EAAY,SAAWF,EAGvB,GAAM,CAAE,UAAAU,CAAU,EAAI,MAAMlB,EAAS,uBAAuBU,CAAW,EAEvE,OAAOQ,CACT,OAASC,EAAU,CAEjB,MADA,QAAQ,MAAM,4BAA6BA,CAAG,EAC1CA,EAAI,SAAS,SAAS,eAAe,EACjC,IAAI,MAAM,8BAA8B,EAE1C,IAAI,MAAMA,EAAI,SAAW,mCAAmC,CACpE,CACF,EAEA,MAAO,CAAE,YAAa,CAAC,CAACtB,EAAY,EAAG,QAAAE,EAAS,YAAAE,CAAY,CAC9D","names":["Connection","PublicKey","Transaction","SystemProgram","LAMPORTS_PER_SOL","TOKEN_PROGRAM_ID","createTransferInstruction","getMint","USDC_MINT_DEVNET","USDC_MINT_MAINNET","useSolanaWallet","getProvider","anyWindow","connect","provider","sendPayment","intent","customRpcUrl","isMainnet","rpcUrl","connection","accounts","fromPubkey","toPubkey","transaction","mintAddress","mintInfo","amount","getAssociatedTokenAddress","fromAta","toAta","blockhash","signature","err"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|
|
2
|
+
//# sourceMappingURL=chunk-73SFLUWV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import react__default from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { Transaction } from '@solana/web3.js';
|
|
5
|
-
|
|
6
|
-
interface SolanaWindow extends Window {
|
|
7
|
-
solana?: {
|
|
8
|
-
isPhantom?: boolean;
|
|
9
|
-
connect: (options?: {
|
|
10
|
-
onlyIfTrusted?: boolean;
|
|
11
|
-
}) => Promise<{
|
|
12
|
-
publicKey: {
|
|
13
|
-
toString: () => string;
|
|
14
|
-
};
|
|
15
|
-
}>;
|
|
16
|
-
signTransaction: (transaction: Transaction) => Promise<Transaction>;
|
|
17
|
-
signAndSendTransaction: (transaction: Transaction) => Promise<{
|
|
18
|
-
signature: string;
|
|
19
|
-
}>;
|
|
20
|
-
request: (request: {
|
|
21
|
-
method: string;
|
|
22
|
-
params?: any;
|
|
23
|
-
}) => Promise<any>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
declare const useSolanaWallet: () => {
|
|
27
|
-
isAvailable: boolean;
|
|
28
|
-
connect: () => Promise<string>;
|
|
29
|
-
sendPayment: (intent: PaymentIntent) => Promise<string>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
interface EthereumWindow extends Window {
|
|
33
|
-
ethereum?: {
|
|
34
|
-
isMetaMask?: boolean;
|
|
35
|
-
request: (request: {
|
|
36
|
-
method: string;
|
|
37
|
-
params?: any[];
|
|
38
|
-
}) => Promise<any>;
|
|
39
|
-
on: (event: string, callback: (...args: any[]) => void) => void;
|
|
40
|
-
removeListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
declare const useEVMWallet: () => {
|
|
44
|
-
isAvailable: boolean;
|
|
45
|
-
connect: () => Promise<any>;
|
|
46
|
-
sendPayment: (intent: PaymentIntent) => Promise<any>;
|
|
47
|
-
};
|
|
3
|
+
import { PaymentVerification, PaymentProvider, PaymentIntent } from '@micro-cms/types';
|
|
48
4
|
|
|
49
5
|
declare const PaymentWidget: react__default.FC<PaymentWidgetProps>;
|
|
50
6
|
|
|
@@ -58,6 +14,7 @@ interface PaymentWidgetProps {
|
|
|
58
14
|
onSuccess?: (verification: PaymentVerification) => void;
|
|
59
15
|
onError?: (error: Error) => void;
|
|
60
16
|
provider?: PaymentProvider;
|
|
17
|
+
solanaRpcUrl?: string;
|
|
61
18
|
endpoints?: {
|
|
62
19
|
initiate?: string;
|
|
63
20
|
verify?: string;
|
|
@@ -79,4 +36,4 @@ declare const usePayment: (props: PaymentWidgetProps) => {
|
|
|
79
36
|
handleEVMPay: () => Promise<void>;
|
|
80
37
|
};
|
|
81
38
|
|
|
82
|
-
export { CSS_CONTENT, type
|
|
39
|
+
export { CSS_CONTENT, type PaymentStatus, PaymentWidget, type PaymentWidgetProps, injectStyles, usePayment };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import react__default from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { Transaction } from '@solana/web3.js';
|
|
5
|
-
|
|
6
|
-
interface SolanaWindow extends Window {
|
|
7
|
-
solana?: {
|
|
8
|
-
isPhantom?: boolean;
|
|
9
|
-
connect: (options?: {
|
|
10
|
-
onlyIfTrusted?: boolean;
|
|
11
|
-
}) => Promise<{
|
|
12
|
-
publicKey: {
|
|
13
|
-
toString: () => string;
|
|
14
|
-
};
|
|
15
|
-
}>;
|
|
16
|
-
signTransaction: (transaction: Transaction) => Promise<Transaction>;
|
|
17
|
-
signAndSendTransaction: (transaction: Transaction) => Promise<{
|
|
18
|
-
signature: string;
|
|
19
|
-
}>;
|
|
20
|
-
request: (request: {
|
|
21
|
-
method: string;
|
|
22
|
-
params?: any;
|
|
23
|
-
}) => Promise<any>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
declare const useSolanaWallet: () => {
|
|
27
|
-
isAvailable: boolean;
|
|
28
|
-
connect: () => Promise<string>;
|
|
29
|
-
sendPayment: (intent: PaymentIntent) => Promise<string>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
interface EthereumWindow extends Window {
|
|
33
|
-
ethereum?: {
|
|
34
|
-
isMetaMask?: boolean;
|
|
35
|
-
request: (request: {
|
|
36
|
-
method: string;
|
|
37
|
-
params?: any[];
|
|
38
|
-
}) => Promise<any>;
|
|
39
|
-
on: (event: string, callback: (...args: any[]) => void) => void;
|
|
40
|
-
removeListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
declare const useEVMWallet: () => {
|
|
44
|
-
isAvailable: boolean;
|
|
45
|
-
connect: () => Promise<any>;
|
|
46
|
-
sendPayment: (intent: PaymentIntent) => Promise<any>;
|
|
47
|
-
};
|
|
3
|
+
import { PaymentVerification, PaymentProvider, PaymentIntent } from '@micro-cms/types';
|
|
48
4
|
|
|
49
5
|
declare const PaymentWidget: react__default.FC<PaymentWidgetProps>;
|
|
50
6
|
|
|
@@ -58,6 +14,7 @@ interface PaymentWidgetProps {
|
|
|
58
14
|
onSuccess?: (verification: PaymentVerification) => void;
|
|
59
15
|
onError?: (error: Error) => void;
|
|
60
16
|
provider?: PaymentProvider;
|
|
17
|
+
solanaRpcUrl?: string;
|
|
61
18
|
endpoints?: {
|
|
62
19
|
initiate?: string;
|
|
63
20
|
verify?: string;
|
|
@@ -79,4 +36,4 @@ declare const usePayment: (props: PaymentWidgetProps) => {
|
|
|
79
36
|
handleEVMPay: () => Promise<void>;
|
|
80
37
|
};
|
|
81
38
|
|
|
82
|
-
export { CSS_CONTENT, type
|
|
39
|
+
export { CSS_CONTENT, type PaymentStatus, PaymentWidget, type PaymentWidgetProps, injectStyles, usePayment };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Rt=Object.create;var j=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),jt=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},ct=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lt(t))!$t.call(e,i)&&i!==r&&j(e,i,{get:()=>t[i],enumerable:!(n=_t(t,i))||n.enumerable});return e};var st=(e,t,r)=>(r=e!=null?Rt(Dt(e)):{},ct(t||!e||!e.__esModule?j(r,"default",{value:e,enumerable:!0}):r,e)),Wt=e=>ct(j({},"__esModule",{value:!0}),e);var ut=q(W=>{"use strict";W.byteLength=Vt;W.toByteArray=Gt;W.fromByteArray=zt;var I=[],E=[],Ot=typeof Uint8Array<"u"?Uint8Array:Array,G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(S=0,at=G.length;S<at;++S)I[S]=G[S],E[G.charCodeAt(S)]=S;var S,at;E[45]=62;E[95]=63;function mt(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Vt(e){var t=mt(e),r=t[0],n=t[1];return(r+n)*3/4-n}function qt(e,t,r){return(t+r)*3/4-r}function Gt(e){var t,r=mt(e),n=r[0],i=r[1],o=new Ot(qt(e,n,i)),c=0,a=i>0?n-4:n,m;for(m=0;m<a;m+=4)t=E[e.charCodeAt(m)]<<18|E[e.charCodeAt(m+1)]<<12|E[e.charCodeAt(m+2)]<<6|E[e.charCodeAt(m+3)],o[c++]=t>>16&255,o[c++]=t>>8&255,o[c++]=t&255;return i===2&&(t=E[e.charCodeAt(m)]<<2|E[e.charCodeAt(m+1)]>>4,o[c++]=t&255),i===1&&(t=E[e.charCodeAt(m)]<<10|E[e.charCodeAt(m+1)]<<4|E[e.charCodeAt(m+2)]>>2,o[c++]=t>>8&255,o[c++]=t&255),o}function Ht(e){return I[e>>18&63]+I[e>>12&63]+I[e>>6&63]+I[e&63]}function Yt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Ht(n));return i.join("")}function zt(e){for(var t,r=e.length,n=r%3,i=[],o=16383,c=0,a=r-n;c<a;c+=o)i.push(Yt(e,c,c+o>a?a:c+o));return n===1?(t=e[r-1],i.push(I[t>>2]+I[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(I[t>>10]+I[t>>4&63]+I[t<<2&63]+"=")),i.join("")}});var lt=q(H=>{"use strict";H.read=function(e,t,r,n,i){var o,c,a=i*8-n-1,m=(1<<a)-1,f=m>>1,l=-7,u=r?i-1:0,B=r?-1:1,y=e[t+u];for(u+=B,o=y&(1<<-l)-1,y>>=-l,l+=a;l>0;o=o*256+e[t+u],u+=B,l-=8);for(c=o&(1<<-l)-1,o>>=-l,l+=n;l>0;c=c*256+e[t+u],u+=B,l-=8);if(o===0)o=1-f;else{if(o===m)return c?NaN:(y?-1:1)*(1/0);c=c+Math.pow(2,n),o=o-f}return(y?-1:1)*c*Math.pow(2,o-n)};H.write=function(e,t,r,n,i,o){var c,a,m,f=o*8-i-1,l=(1<<f)-1,u=l>>1,B=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:o-1,F=n?1:-1,L=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,c=l):(c=Math.floor(Math.log(t)/Math.LN2),t*(m=Math.pow(2,-c))<1&&(c--,m*=2),c+u>=1?t+=B/m:t+=B*Math.pow(2,1-u),t*m>=2&&(c++,m/=2),c+u>=l?(a=0,c=l):c+u>=1?(a=(t*m-1)*Math.pow(2,i),c=c+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),c=0));i>=8;e[r+y]=a&255,y+=F,a/=256,i-=8);for(c=c<<i|a,f+=i;f>0;e[r+y]=c&255,y+=F,c/=256,f-=8);e[r+y-F]|=L*128}});var Ct=q(R=>{"use strict";var Y=ut(),M=lt(),ht=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=s;R.SlowBuffer=tr;R.INSPECT_MAX_BYTES=50;var O=2147483647;R.kMaxLength=O;s.TYPED_ARRAY_SUPPORT=Kt();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Kt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function P(e){if(e>O)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return X(e)}return yt(e,t,r)}s.poolSize=8192;function yt(e,t,r){if(typeof e=="string")return Xt(e,t);if(ArrayBuffer.isView(e))return Zt(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(A(e,ArrayBuffer)||e&&A(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(A(e,SharedArrayBuffer)||e&&A(e.buffer,SharedArrayBuffer)))return K(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return s.from(n,t,r);let i=Qt(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,t,r){return yt(e,t,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function wt(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Jt(e,t,r){return wt(e),e<=0?P(e):t!==void 0?typeof r=="string"?P(e).fill(t,r):P(e).fill(t):P(e)}s.alloc=function(e,t,r){return Jt(e,t,r)};function X(e){return wt(e),P(e<0?0:Z(e)|0)}s.allocUnsafe=function(e){return X(e)};s.allocUnsafeSlow=function(e){return X(e)};function Xt(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=gt(e,t)|0,n=P(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function z(e){let t=e.length<0?0:Z(e.length)|0,r=P(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function Zt(e){if(A(e,Uint8Array)){let t=new Uint8Array(e);return K(t.buffer,t.byteOffset,t.byteLength)}return z(e)}function K(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function Qt(e){if(s.isBuffer(e)){let t=Z(e.length)|0,r=P(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||tt(e.length)?P(0):z(e);if(e.type==="Buffer"&&Array.isArray(e.data))return z(e.data)}function Z(e){if(e>=O)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+O.toString(16)+" bytes");return e|0}function tr(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype};s.compare=function(t,r){if(A(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),A(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(t)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,c=Math.min(n,i);o<c;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=s.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let c=t[n];if(A(c,Uint8Array))o+c.length>i.length?(s.isBuffer(c)||(c=s.from(c)),c.copy(i,o)):Uint8Array.prototype.set.call(i,c,o);else if(s.isBuffer(c))c.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=c.length}return i};function gt(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||A(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return J(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Pt(e).length;default:if(i)return n?-1:J(e).length;t=(""+t).toLowerCase(),i=!0}}s.byteLength=gt;function rr(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return lr(this,t,r);case"utf8":case"utf-8":return Et(this,t,r);case"ascii":return mr(this,t,r);case"latin1":case"binary":return ur(this,t,r);case"base64":return sr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function N(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}s.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)N(this,r,r+1);return this};s.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)N(this,r,r+3),N(this,r+1,r+2);return this};s.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)N(this,r,r+7),N(this,r+1,r+6),N(this,r+2,r+5),N(this,r+3,r+4);return this};s.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Et(this,0,t):rr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0};s.prototype.inspect=function(){let t="",r=R.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};ht&&(s.prototype[ht]=s.prototype.inspect);s.prototype.compare=function(t,r,n,i,o){if(A(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let c=o-i,a=n-r,m=Math.min(c,a),f=this.slice(i,o),l=t.slice(r,n);for(let u=0;u<m;++u)if(f[u]!==l[u]){c=f[u],a=l[u];break}return c<a?-1:a<c?1:0};function xt(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,tt(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=s.from(t,n)),s.isBuffer(t))return t.length===0?-1:ft(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ft(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ft(e,t,r,n,i){let o=1,c=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,c/=2,a/=2,r/=2}function m(l,u){return o===1?l[u]:l.readUInt16BE(u*o)}let f;if(i){let l=-1;for(f=r;f<c;f++)if(m(e,f)===m(t,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===a)return l*o}else l!==-1&&(f-=f-l),l=-1}else for(r+a>c&&(r=c-a),f=r;f>=0;f--){let l=!0;for(let u=0;u<a;u++)if(m(e,f+u)!==m(t,u)){l=!1;break}if(l)return f}return-1}s.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};s.prototype.indexOf=function(t,r,n){return xt(this,t,r,n,!0)};s.prototype.lastIndexOf=function(t,r,n){return xt(this,t,r,n,!1)};function er(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let c;for(c=0;c<n;++c){let a=parseInt(t.substr(c*2,2),16);if(tt(a))return c;e[r+c]=a}return c}function nr(e,t,r,n){return V(J(t,e.length-r),e,r,n)}function ir(e,t,r,n){return V(yr(t),e,r,n)}function or(e,t,r,n){return V(Pt(t),e,r,n)}function cr(e,t,r,n){return V(wr(t,e.length-r),e,r,n)}s.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let c=!1;for(;;)switch(i){case"hex":return er(this,t,r,n);case"utf8":case"utf-8":return nr(this,t,r,n);case"ascii":case"latin1":case"binary":return ir(this,t,r,n);case"base64":return or(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r,n);default:if(c)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),c=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function sr(e,t,r){return t===0&&r===e.length?Y.fromByteArray(e):Y.fromByteArray(e.slice(t,r))}function Et(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],c=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let m,f,l,u;switch(a){case 1:o<128&&(c=o);break;case 2:m=e[i+1],(m&192)===128&&(u=(o&31)<<6|m&63,u>127&&(c=u));break;case 3:m=e[i+1],f=e[i+2],(m&192)===128&&(f&192)===128&&(u=(o&15)<<12|(m&63)<<6|f&63,u>2047&&(u<55296||u>57343)&&(c=u));break;case 4:m=e[i+1],f=e[i+2],l=e[i+3],(m&192)===128&&(f&192)===128&&(l&192)===128&&(u=(o&15)<<18|(m&63)<<12|(f&63)<<6|l&63,u>65535&&u<1114112&&(c=u))}}c===null?(c=65533,a=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c),i+=a}return ar(n)}var pt=4096;function ar(e){let t=e.length;if(t<=pt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=pt));return r}function mr(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function ur(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function lr(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=gr[e[o]];return i}function hr(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,s.prototype),i};function d(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(t,r){return t=t>>>0,r||d(t,1,this.length),this[t]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||d(t,2,this.length),this[t]|this[t+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||d(t,2,this.length),this[t]<<8|this[t+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||d(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};s.prototype.readBigUInt64LE=C(function(t){t=t>>>0,v(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=C(function(t){t=t>>>0,v(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};s.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=r,o=1,c=this[t+--i];for(;i>0&&(o*=256);)c+=this[t+--i]*o;return o*=128,c>=o&&(c-=Math.pow(2,8*r)),c};s.prototype.readInt8=function(t,r){return t=t>>>0,r||d(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};s.prototype.readInt16LE=function(t,r){t=t>>>0,r||d(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(t,r){t=t>>>0,r||d(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};s.prototype.readInt32BE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};s.prototype.readBigInt64LE=C(function(t){t=t>>>0,v(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});s.prototype.readBigInt64BE=C(function(t){t=t>>>0,v(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&$(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});s.prototype.readFloatLE=function(t,r){return t=t>>>0,r||d(t,4,this.length),M.read(this,t,!0,23,4)};s.prototype.readFloatBE=function(t,r){return t=t>>>0,r||d(t,4,this.length),M.read(this,t,!1,23,4)};s.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||d(t,8,this.length),M.read(this,t,!0,52,8)};s.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||d(t,8,this.length),M.read(this,t,!1,52,8)};function g(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=1,c=0;for(this[r]=t&255;++c<n&&(o*=256);)this[r+c]=t/o&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=n-1,c=1;for(this[r+o]=t&255;--o>=0&&(c*=256);)this[r+o]=t/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,255,0),this[r]=t&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function bt(e,t,r,n,i){Ut(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,r}function Bt(e,t,r,n,i){Ut(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=c,c=c>>8,e[r+2]=c,c=c>>8,e[r+1]=c,c=c>>8,e[r]=c,r+8}s.prototype.writeBigUInt64LE=C(function(t,r=0){return bt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=C(function(t,r=0){return Bt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let m=Math.pow(2,8*n-1);g(this,t,r,n,m-1,-m)}let o=0,c=1,a=0;for(this[r]=t&255;++o<n&&(c*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let m=Math.pow(2,8*n-1);g(this,t,r,n,m-1,-m)}let o=n-1,c=1,a=0;for(this[r+o]=t&255;--o>=0&&(c*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};s.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};s.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};s.prototype.writeBigInt64LE=C(function(t,r=0){return bt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=C(function(t,r=0){return Bt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function It(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function At(e,t,r,n,i){return t=+t,r=r>>>0,i||It(e,t,r,4,34028234663852886e22,-34028234663852886e22),M.write(e,t,r,n,23,4),r+4}s.prototype.writeFloatLE=function(t,r,n){return At(this,t,r,!0,n)};s.prototype.writeFloatBE=function(t,r,n){return At(this,t,r,!1,n)};function Ft(e,t,r,n,i){return t=+t,r=r>>>0,i||It(e,t,r,8,17976931348623157e292,-17976931348623157e292),M.write(e,t,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(t,r,n){return Ft(this,t,r,!0,n)};s.prototype.writeDoubleBE=function(t,r,n){return Ft(this,t,r,!1,n)};s.prototype.copy=function(t,r,n,i){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};s.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let c=t.charCodeAt(0);(i==="utf8"&&c<128||i==="latin1")&&(t=c)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let c=s.isBuffer(t)?t:s.from(t,i),a=c.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=c[o%a]}return this};var T={};function Q(e,t,r){T[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Q("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Q("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Q("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=dt(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=dt(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function dt(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function fr(e,t,r){v(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&$(t,e.length-(r+1))}function Ut(e,t,r,n,i,o){if(e>r||e<t){let c=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${c} and < 2${c} ** ${(o+1)*8}${c}`:a=`>= -(2${c} ** ${(o+1)*8-1}${c}) and < 2 ** ${(o+1)*8-1}${c}`:a=`>= ${t}${c} and <= ${r}${c}`,new T.ERR_OUT_OF_RANGE("value",a,e)}fr(n,i,o)}function v(e,t){if(typeof e!="number")throw new T.ERR_INVALID_ARG_TYPE(t,"number",e)}function $(e,t,r){throw Math.floor(e)!==e?(v(e,r),new T.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new T.ERR_BUFFER_OUT_OF_BOUNDS:new T.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var pr=/[^+/0-9A-Za-z-_]/g;function dr(e){if(e=e.split("=")[0],e=e.trim().replace(pr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function J(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let c=0;c<n;++c){if(r=e.charCodeAt(c),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(c+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function yr(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function wr(e,t){let r,n,i,o=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)r=e.charCodeAt(c),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Pt(e){return Y.toByteArray(dr(e))}function V(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function A(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function tt(e){return e!==e}var gr=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function C(e){return typeof BigInt>"u"?xr:e}function xr(){throw new Error("BigInt not supported")}});var Ir={};jt(Ir,{CSS_CONTENT:()=>St,PaymentWidget:()=>Br,injectStyles:()=>nt,useEVMWallet:()=>et,usePayment:()=>it,useSolanaWallet:()=>rt});module.exports=Wt(Ir);var vt=st(Ct()),k=require("react");var x=require("@solana/web3.js"),_=require("@solana/spl-token"),Er=new x.PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),br=new x.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),rt=()=>{let e=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},t=async()=>{let n=e();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");try{let o=!window.location.host.includes("localhost")&&!window.location.host.includes("dev."),c=o?"https://api.mainnet-beta.solana.com":"https://api.devnet.solana.com",a=new x.Connection(c,"confirmed"),m=await i.connect({onlyIfTrusted:!0}),f=new x.PublicKey(m.publicKey.toString()),l=new x.PublicKey(n.paymentAddress),u=new x.Transaction;if(n.currency?.toUpperCase()==="USDC"){let F=o?br:Er,L=await(0,_.getMint)(a,F),ot=Math.round(Number(n.amount)*Math.pow(10,L.decimals)),{getAssociatedTokenAddress:p}=await import("@solana/spl-token"),w=await p(F,f),U=await p(F,l);u.add((0,_.createTransferInstruction)(w,U,f,ot,[],_.TOKEN_PROGRAM_ID))}else u.add(x.SystemProgram.transfer({fromPubkey:f,toPubkey:l,lamports:Math.round(Number(n.amount)*x.LAMPORTS_PER_SOL)}));let{blockhash:B}=await a.getLatestBlockhash();u.recentBlockhash=B,u.feePayer=f;let{signature:y}=await i.signAndSendTransaction(u);return y}catch(o){throw console.error("Solana Transaction Error:",o),o.message?.includes("User rejected")?new Error("Transaction rejected by user"):new Error(o.message||"Failed to send Solana transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}};var et=()=>{let e=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},t=async()=>{let n=e();if(n)try{return(await n.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or EVM wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");let o=await i.request({method:"eth_accounts"});if(!o||o.length===0)throw new Error("No accounts found. Please connect your wallet first.");let c=n.currency.toUpperCase()==="USDC"?6:18,a="0x"+BigInt(Math.floor(Number(n.amount)*Math.pow(10,c))).toString(16);try{return await i.request({method:"eth_sendTransaction",params:[{from:o[0],to:n.paymentAddress,value:n.currency.toUpperCase()==="ETH"?a:"0x0"}]})}catch(m){throw m.code===4001?new Error("Transaction rejected by user"):new Error(m.message||"Failed to send transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}};var kt=require("react"),b=require("lucide-react"),Tt=require("clsx"),Mt=require("tailwind-merge");var St=".mcms-mx-auto{margin-left:auto;margin-right:auto}.mcms-mb-3{margin-bottom:.75rem}.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-1{margin-top:.25rem}.mcms-flex{display:flex}.mcms-h-12{height:3rem}.mcms-h-3{height:.75rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-8{height:2rem}.mcms-w-12{width:3rem}.mcms-w-3{width:.75rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-8{width:2rem}.mcms-w-full{width:100%}.mcms-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-1{gap:.25rem}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.mcms-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.mcms-overflow-hidden{overflow:hidden}.mcms-break-all{word-break:break-all}.mcms-rounded-2xl{border-radius:1rem}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-t{border-top-width:1px}.mcms-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity,1))}.mcms-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-indigo-50{--tw-bg-opacity:1;background-color:rgb(238 242 255/var(--tw-bg-opacity,1))}.mcms-bg-indigo-600{--tw-bg-opacity:1;background-color:rgb(79 70 229/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-slate-100{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.mcms-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.mcms-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-px-4{padding-left:1rem;padding-right:1rem}.mcms-px-6{padding-left:1.5rem;padding-right:1.5rem}.mcms-py-3{padding-top:.75rem;padding-bottom:.75rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-center{text-align:center}.mcms-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-font-semibold{font-weight:600}.mcms-uppercase{text-transform:uppercase}.mcms-tracking-wider{letter-spacing:.05em}.mcms-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-indigo-600{--tw-text-opacity:1;color:rgb(79 70 229/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.mcms-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.mcms-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.mcms-text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-bg-black:hover{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.hover:mcms-bg-indigo-700:hover{--tw-bg-opacity:1;background-color:rgb(67 56 202/var(--tw-bg-opacity,1))}.hover:mcms-bg-orange-600:hover{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity,1))}.hover:mcms-text-indigo-700:hover{--tw-text-opacity:1;color:rgb(67 56 202/var(--tw-text-opacity,1))}",nt=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=St,document.head.appendChild(e)};var h=require("react/jsx-runtime");function Nt(...e){return(0,Mt.twMerge)((0,Tt.clsx)(e))}var Br=({className:e,...t})=>{(0,kt.useLayoutEffect)(()=>{nt()},[]);let{status:r,intent:n,error:i,initiate:o,verify:c,setStatus:a,isSolanaAvailable:m,handleSolanaPay:f,isEVMAvailable:l,handleEVMPay:u}=it(t);return r==="success"?(0,h.jsxs)("div",{className:Nt("mcms-p-6 mcms-text-center mcms-bg-green-50 mcms-rounded-xl mcms-border mcms-border-green-200",e),children:[(0,h.jsx)(b.CheckCircle,{className:"mcms-mx-auto mcms-w-12 mcms-h-12 mcms-text-green-500 mcms-mb-4"}),(0,h.jsx)("h3",{className:"mcms-text-lg mcms-font-semibold mcms-green-900",children:"Payment Successful"}),(0,h.jsx)("p",{className:"mcms-text-green-700 mcms-mt-1",children:"Your order has been confirmed."})]}):(0,h.jsxs)("div",{className:Nt("mcms-bg-white mcms-rounded-2xl mcms-border mcms-border-slate-200 mcms-shadow-sm mcms-overflow-hidden",e),children:[(0,h.jsxs)("div",{className:"mcms-p-6",children:[(0,h.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[(0,h.jsx)("div",{className:"mcms-p-2 mcms-bg-indigo-50 mcms-rounded-lg",children:(0,h.jsx)(b.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-indigo-600"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("h3",{className:"mcms-font-semibold mcms-text-slate-900",children:"Crypto Payment"}),(0,h.jsx)("p",{className:"mcms-text-sm mcms-text-slate-500",children:"Pay securely using your wallet"})]})]}),i&&(0,h.jsxs)("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-border mcms-border-red-100 mcms-rounded-lg mcms-flex mcms-gap-3 mcms-text-red-700 mcms-text-sm",children:[(0,h.jsx)(b.AlertCircle,{className:"mcms-w-4 mcms-h-4 mcms-shrink-0"}),(0,h.jsx)("p",{children:i})]}),r==="idle"&&(0,h.jsx)("button",{onClick:o,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Start Payment"}),(r==="connecting"||r==="initiating"||r==="verifying")&&(0,h.jsxs)("div",{className:"mcms-py-8 mcms-text-center",children:[(0,h.jsx)(b.Loader2,{className:"mcms-w-8 mcms-h-8 mcms-text-indigo-600 mcms-animate-spin mcms-mx-auto mcms-mb-3"}),(0,h.jsx)("p",{className:"mcms-text-slate-600 mcms-font-medium",children:r==="connecting"?"Connecting wallet...":r==="initiating"?"Preparing transaction...":"Verifying on-chain..."})]}),r==="pending_signature"&&n&&(0,h.jsxs)("div",{className:"mcms-space-y-4",children:[(0,h.jsxs)("div",{className:"mcms-p-4 mcms-bg-slate-50 mcms-rounded-xl mcms-space-y-2",children:[(0,h.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,h.jsx)("span",{className:"mcms-text-slate-500",children:"Amount to pay"}),(0,h.jsxs)("span",{className:"mcms-font-mono mcms-font-medium mcms-text-slate-900",children:[n.amount," ",n.currency]})]}),(0,h.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,h.jsx)("span",{className:"mcms-text-slate-500",children:"Order ID"}),(0,h.jsx)("span",{className:"mcms-font-mono mcms-text-slate-900",children:n.orderId})]}),(0,h.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,h.jsx)("span",{className:"mcms-text-slate-500",children:"Network"}),(0,h.jsx)("span",{className:"mcms-text-slate-900 mcms-font-medium",children:n.network})]})]}),(0,h.jsxs)("div",{className:"mcms-space-y-2",children:[(0,h.jsx)("p",{className:"mcms-text-xs mcms-text-slate-500 mcms-uppercase mcms-font-bold mcms-tracking-wider",children:"Destination Address"}),(0,h.jsx)("div",{className:"mcms-p-3 mcms-bg-slate-100 mcms-rounded-lg mcms-font-mono mcms-text-xs mcms-break-all mcms-text-slate-600 mcms-border mcms-border-slate-200 mcms-flex mcms-justify-center",children:n.paymentAddress?`${n.paymentAddress.slice(0,6)}...${n.paymentAddress.slice(-4)}`:"Establishing..."})]}),(0,h.jsx)("div",{className:"mcms-flex mcms-flex-col mcms-gap-2",children:n.network?.toLowerCase().includes("solana")&&m?(0,h.jsxs)("button",{onClick:f,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[(0,h.jsx)(b.Cpu,{className:"mcms-w-4 mcms-h-4"}),"Pay with Phantom"]}):(n.network?.toLowerCase().includes("ethereum")||n.network?.toLowerCase().includes("evm")||n.network?.toLowerCase().includes("polygon"))&&l?(0,h.jsxs)("button",{onClick:u,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-orange-500 hover:mcms-bg-orange-600 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[(0,h.jsx)("img",{src:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Mirror_Logo.svg",className:"mcms-w-4 mcms-h-4",alt:"MetaMask"}),"Pay with MetaMask"]}):(0,h.jsx)("button",{onClick:()=>{a("verifying"),setTimeout(()=>c("0x_mock_transaction_hash_generic"),2e3)},className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-slate-900 hover:mcms-bg-black mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Confirm in Wallet"})})]})]}),(0,h.jsxs)("div",{className:"mcms-bg-slate-50 mcms-px-6 mcms-py-3 mcms-border-t mcms-border-slate-100 mcms-flex mcms-justify-between mcms-items-center",children:[(0,h.jsx)("span",{className:"mcms-text-xs mcms-text-slate-400",children:"Powered by Micro-CMS Crypto"}),(0,h.jsxs)("a",{href:"#",className:"mcms-text-xs mcms-text-indigo-600 hover:mcms-text-indigo-700 mcms-font-medium mcms-flex mcms-items-center mcms-gap-1",children:["Help ",(0,h.jsx)(b.ExternalLink,{className:"mcms-w-3 mcms-h-3"})]})]})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=vt.Buffer),window.global||(window.global=window));var it=e=>{let[t,r]=(0,k.useState)("idle"),[n,i]=(0,k.useState)(null),[o,c]=(0,k.useState)(null),a=(0,k.useCallback)(async()=>{try{if(r("initiating"),i(null),e.provider){let U=await e.provider.initiatePayment(e.orderId,{amount:e.amount,currency:e.currency});c(U),r("pending_signature");return}let p=await fetch(e.endpoints?.initiate||"/api/orders/initiate",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({productId:e.orderId,amount:e.amount,currency:e.currency,paymentProvider:"crypto"})});if(!p.ok){let U=await p.json();throw new Error(U.error||"Failed to initiate payment intent")}let w=await p.json();c(w),r("pending_signature")}catch(p){i(p.message),r("error"),e.onError?.(p)}},[e.provider,e.endpoints?.initiate,e.orderId,e.amount,e.currency,e.onError,e.headers]),m=(0,k.useCallback)(async p=>{try{if(r("verifying"),e.provider){let D=await e.provider.verifyPayment(p,e.orderId);if(D.status==="confirmed")r("success"),e.onSuccess?.(D);else throw new Error("Payment not confirmed yet, status: "+D.status);return}let w=await fetch(e.endpoints?.verify||"/api/orders/verify-payment",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({orderId:o?.orderId||e.orderId,transactionHash:p})});if(!w.ok){let D=await w.json();throw new Error(D.error||"Payment verification failed")}let U=await w.json();if(U.status==="confirmed")r("success"),e.onSuccess?.(U);else throw new Error("Payment not confirmed yet, status: "+U.status)}catch(w){i(w.message),r("error"),e.onError?.(w)}},[e.provider,e.endpoints?.verify,e.orderId,e.onSuccess,e.onError,e.headers,o?.orderId]),{isAvailable:f,connect:l,sendPayment:u}=rt(),B=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let p=await l();console.log("Connected to Solana with public key:",p),r("pending_signature");let w=await u(o);r("verifying"),await m(w)}catch(p){i(p.message||"Failed to connect to Phantom or sign transaction."),r("error"),e.onError?.(p instanceof Error?p:new Error(String(p)))}},{isAvailable:y,connect:F,sendPayment:L}=et();return{status:t,intent:o,error:n,initiate:a,verify:m,setStatus:r,isSolanaAvailable:f,handleSolanaPay:B,isEVMAvailable:y,handleEVMPay:async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let p=await F();console.log("Connected to EVM with account:",p),r("pending_signature");let w=await L(o);r("verifying"),await m(w)}catch(p){i(p.message||"Failed to connect to MetaMask or sign transaction."),r("error"),e.onError?.(p instanceof Error?p:new Error(String(p)))}}}};0&&(module.exports={CSS_CONTENT,PaymentWidget,injectStyles,useEVMWallet,usePayment,useSolanaWallet});
|
|
1
|
+
"use strict";var jt=Object.create;var R=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var et=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),O=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ot(t))!Vt.call(e,i)&&i!==r&&R(e,i,{get:()=>t[i],enumerable:!(n=Wt(t,i))||n.enumerable});return e};var it=(e,t,r)=>(r=e!=null?jt(qt(e)):{},nt(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),Gt=e=>nt(R({},"__esModule",{value:!0}),e);var ct=W(_=>{"use strict";_.byteLength=Ht;_.toByteArray=Kt;_.fromByteArray=Zt;var B=[],E=[],Yt=typeof Uint8Array<"u"?Uint8Array:Array,q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,ot=q.length;U<ot;++U)B[U]=q[U],E[q.charCodeAt(U)]=U;var U,ot;E[45]=62;E[95]=63;function st(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Ht(e){var t=st(e),r=t[0],n=t[1];return(r+n)*3/4-n}function zt(e,t,r){return(t+r)*3/4-r}function Kt(e){var t,r=st(e),n=r[0],i=r[1],o=new Yt(zt(e,n,i)),s=0,m=i>0?n-4:n,u;for(u=0;u<m;u+=4)t=E[e.charCodeAt(u)]<<18|E[e.charCodeAt(u+1)]<<12|E[e.charCodeAt(u+2)]<<6|E[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=E[e.charCodeAt(u)]<<2|E[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=E[e.charCodeAt(u)]<<10|E[e.charCodeAt(u+1)]<<4|E[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Jt(e){return B[e>>18&63]+B[e>>12&63]+B[e>>6&63]+B[e&63]}function Xt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Jt(n));return i.join("")}function Zt(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,m=r-n;s<m;s+=o)i.push(Xt(e,s,s+o>m?m:s+o));return n===1?(t=e[r-1],i.push(B[t>>2]+B[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+"=")),i.join("")}});var at=W(V=>{"use strict";V.read=function(e,t,r,n,i){var o,s,m=i*8-n-1,u=(1<<m)-1,f=u>>1,h=-7,a=r?i-1:0,d=r?-1:1,p=e[t+a];for(a+=d,o=p&(1<<-h)-1,p>>=-h,h+=m;h>0;o=o*256+e[t+a],a+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+a],a+=d,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(p?-1:1)*s*Math.pow(2,o-n)};V.write=function(e,t,r,n,i,o){var s,m,u,f=o*8-i-1,h=(1<<f)-1,a=h>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,w=n?1:-1,$=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(m=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+a>=1?t+=d/u:t+=d*Math.pow(2,1-a),t*u>=2&&(s++,u/=2),s+a>=h?(m=0,s=h):s+a>=1?(m=(t*u-1)*Math.pow(2,i),s=s+a):(m=t*Math.pow(2,a-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=m&255,p+=w,m/=256,i-=8);for(s=s<<i|m,f+=i;f>0;e[r+p]=s&255,p+=w,s/=256,f-=8);e[r+p-w]|=$*128}});var At=W(T=>{"use strict";var G=ct(),N=at(),mt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;T.Buffer=c;T.SlowBuffer=ir;T.INSPECT_MAX_BYTES=50;var L=2147483647;T.kMaxLength=L;c.TYPED_ARRAY_SUPPORT=Qt();!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Qt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function F(e){if(e>L)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return K(e)}return ft(e,t,r)}c.poolSize=8192;function ft(e,t,r){if(typeof e=="string")return rr(e,t);if(ArrayBuffer.isView(e))return er(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(I(e,ArrayBuffer)||e&&I(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(I(e,SharedArrayBuffer)||e&&I(e.buffer,SharedArrayBuffer)))return H(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return c.from(n,t,r);let i=nr(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,t,r){return ft(e,t,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function pt(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function tr(e,t,r){return pt(e),e<=0?F(e):t!==void 0?typeof r=="string"?F(e).fill(t,r):F(e).fill(t):F(e)}c.alloc=function(e,t,r){return tr(e,t,r)};function K(e){return pt(e),F(e<0?0:J(e)|0)}c.allocUnsafe=function(e){return K(e)};c.allocUnsafeSlow=function(e){return K(e)};function rr(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=dt(e,t)|0,n=F(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Y(e){let t=e.length<0?0:J(e.length)|0,r=F(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function er(e){if(I(e,Uint8Array)){let t=new Uint8Array(e);return H(t.buffer,t.byteOffset,t.byteLength)}return Y(e)}function H(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function nr(e){if(c.isBuffer(e)){let t=J(e.length)|0,r=F(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Z(e.length)?F(0):Y(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Y(e.data)}function J(e){if(e>=L)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+L.toString(16)+" bytes");return e|0}function ir(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype};c.compare=function(t,r){if(I(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),I(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(t)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};c.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=c.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(I(s,Uint8Array))o+s.length>i.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(c.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function dt(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||I(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ft(e).length;default:if(i)return n?-1:z(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=dt;function or(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return dr(this,t,r);case"utf8":case"utf-8":return wt(this,t,r);case"ascii":return fr(this,t,r);case"latin1":case"binary":return pr(this,t,r);case"base64":return lr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function P(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}c.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)P(this,r,r+1);return this};c.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)P(this,r,r+3),P(this,r+1,r+2);return this};c.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)P(this,r,r+7),P(this,r+1,r+6),P(this,r+2,r+5),P(this,r+3,r+4);return this};c.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?wt(this,0,t):or.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0};c.prototype.inspect=function(){let t="",r=T.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};mt&&(c.prototype[mt]=c.prototype.inspect);c.prototype.compare=function(t,r,n,i,o){if(I(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,m=n-r,u=Math.min(s,m),f=this.slice(i,o),h=t.slice(r,n);for(let a=0;a<u;++a)if(f[a]!==h[a]){s=f[a],m=h[a];break}return s<m?-1:m<s?1:0};function yt(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Z(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=c.from(t,n)),c.isBuffer(t))return t.length===0?-1:ut(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ut(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ut(e,t,r,n,i){let o=1,s=e.length,m=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,m/=2,r/=2}function u(h,a){return o===1?h[a]:h.readUInt16BE(a*o)}let f;if(i){let h=-1;for(f=r;f<s;f++)if(u(e,f)===u(t,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===m)return h*o}else h!==-1&&(f-=f-h),h=-1}else for(r+m>s&&(r=s-m),f=r;f>=0;f--){let h=!0;for(let a=0;a<m;a++)if(u(e,f+a)!==u(t,a)){h=!1;break}if(h)return f}return-1}c.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};c.prototype.indexOf=function(t,r,n){return yt(this,t,r,n,!0)};c.prototype.lastIndexOf=function(t,r,n){return yt(this,t,r,n,!1)};function sr(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let m=parseInt(t.substr(s*2,2),16);if(Z(m))return s;e[r+s]=m}return s}function cr(e,t,r,n){return D(z(t,e.length-r),e,r,n)}function ar(e,t,r,n){return D(Er(t),e,r,n)}function mr(e,t,r,n){return D(Ft(t),e,r,n)}function ur(e,t,r,n){return D(br(t,e.length-r),e,r,n)}c.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return sr(this,t,r,n);case"utf8":case"utf-8":return cr(this,t,r,n);case"ascii":case"latin1":case"binary":return ar(this,t,r,n);case"base64":return mr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ur(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lr(e,t,r){return t===0&&r===e.length?G.fromByteArray(e):G.fromByteArray(e.slice(t,r))}function wt(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,m=o>239?4:o>223?3:o>191?2:1;if(i+m<=r){let u,f,h,a;switch(m){case 1:o<128&&(s=o);break;case 2:u=e[i+1],(u&192)===128&&(a=(o&31)<<6|u&63,a>127&&(s=a));break;case 3:u=e[i+1],f=e[i+2],(u&192)===128&&(f&192)===128&&(a=(o&15)<<12|(u&63)<<6|f&63,a>2047&&(a<55296||a>57343)&&(s=a));break;case 4:u=e[i+1],f=e[i+2],h=e[i+3],(u&192)===128&&(f&192)===128&&(h&192)===128&&(a=(o&15)<<18|(u&63)<<12|(f&63)<<6|h&63,a>65535&&a<1114112&&(s=a))}}s===null?(s=65533,m=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=m}return hr(n)}var lt=4096;function hr(e){let t=e.length;if(t<=lt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=lt));return r}function fr(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function pr(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function dr(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=Br[e[o]];return i}function yr(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}c.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,c.prototype),i};function y(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(t,r){return t=t>>>0,r||y(t,1,this.length),this[t]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||y(t,2,this.length),this[t]|this[t+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||y(t,2,this.length),this[t]<<8|this[t+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readBigUInt64LE=A(function(t){t=t>>>0,S(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&M(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=A(function(t){t=t>>>0,S(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&M(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(t,r){return t=t>>>0,r||y(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};c.prototype.readInt16LE=function(t,r){t=t>>>0,r||y(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(t,r){t=t>>>0,r||y(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readBigInt64LE=A(function(t){t=t>>>0,S(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&M(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});c.prototype.readBigInt64BE=A(function(t){t=t>>>0,S(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&M(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});c.prototype.readFloatLE=function(t,r){return t=t>>>0,r||y(t,4,this.length),N.read(this,t,!0,23,4)};c.prototype.readFloatBE=function(t,r){return t=t>>>0,r||y(t,4,this.length),N.read(this,t,!1,23,4)};c.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||y(t,8,this.length),N.read(this,t,!0,52,8)};c.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||y(t,8,this.length),N.read(this,t,!1,52,8)};function g(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let m=Math.pow(2,8*n)-1;g(this,t,r,n,m,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let m=Math.pow(2,8*n)-1;g(this,t,r,n,m,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,255,0),this[r]=t&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function gt(e,t,r,n,i){It(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function xt(e,t,r,n,i){It(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}c.prototype.writeBigUInt64LE=A(function(t,r=0){return gt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=A(function(t,r=0){return xt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=0,s=1,m=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&m===0&&this[r+o-1]!==0&&(m=1),this[r+o]=(t/s>>0)-m&255;return r+n};c.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=n-1,s=1,m=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&m===0&&this[r+o+1]!==0&&(m=1),this[r+o]=(t/s>>0)-m&255;return r+n};c.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};c.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};c.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};c.prototype.writeBigInt64LE=A(function(t,r=0){return gt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=A(function(t,r=0){return xt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Et(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function bt(e,t,r,n,i){return t=+t,r=r>>>0,i||Et(e,t,r,4,34028234663852886e22,-34028234663852886e22),N.write(e,t,r,n,23,4),r+4}c.prototype.writeFloatLE=function(t,r,n){return bt(this,t,r,!0,n)};c.prototype.writeFloatBE=function(t,r,n){return bt(this,t,r,!1,n)};function Bt(e,t,r,n,i){return t=+t,r=r>>>0,i||Et(e,t,r,8,17976931348623157e292,-17976931348623157e292),N.write(e,t,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,n){return Bt(this,t,r,!0,n)};c.prototype.writeDoubleBE=function(t,r,n){return Bt(this,t,r,!1,n)};c.prototype.copy=function(t,r,n,i){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};c.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=c.isBuffer(t)?t:c.from(t,i),m=s.length;if(m===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%m]}return this};var k={};function X(e,t,r){k[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}X("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);X("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);X("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=ht(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=ht(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function ht(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function wr(e,t,r){S(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&M(t,e.length-(r+1))}function It(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",m;throw o>3?t===0||t===BigInt(0)?m=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:m=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:m=`>= ${t}${s} and <= ${r}${s}`,new k.ERR_OUT_OF_RANGE("value",m,e)}wr(n,i,o)}function S(e,t){if(typeof e!="number")throw new k.ERR_INVALID_ARG_TYPE(t,"number",e)}function M(e,t,r){throw Math.floor(e)!==e?(S(e,r),new k.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new k.ERR_BUFFER_OUT_OF_BOUNDS:new k.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var gr=/[^+/0-9A-Za-z-_]/g;function xr(e){if(e=e.split("=")[0],e=e.trim().replace(gr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function z(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Er(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function br(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Ft(e){return G.toByteArray(xr(e))}function D(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function I(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Z(e){return e!==e}var Br=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function A(e){return typeof BigInt>"u"?Ir:e}function Ir(){throw new Error("BigInt not supported")}});var St={};O(St,{useSolanaWallet:()=>Pr});var x,v,Ar,Ur,Pr,Tt=et(()=>{"use strict";x=require("@solana/web3.js"),v=require("@solana/spl-token"),Ar=new x.PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),Ur=new x.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Pr=()=>{let e=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},t=async()=>{let n=e();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},r=async(n,i)=>{let o=e();if(!o)throw new Error("Wallet not connected");try{let s=n.network?.toLowerCase().includes("mainnet")||n.network==="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"||!window.location.host.includes("localhost")&&!window.location.host.includes("dev.")&&!n.network?.toLowerCase().includes("devnet"),u=i||(s?"https://api.mainnet-beta.solana.com":"https://api.devnet.solana.com"),f=new x.Connection(u,"confirmed"),h=await o.connect({onlyIfTrusted:!0}),a=new x.PublicKey(h.publicKey.toString()),d=new x.PublicKey(n.paymentAddress),p=new x.Transaction;if(n.currency?.toUpperCase()==="USDC"){let j=s?Ur:Ar,_t=await(0,v.getMint)(f,j),Lt=Math.round(Number(n.amount)*Math.pow(10,_t.decimals)),{getAssociatedTokenAddress:rt}=await import("@solana/spl-token"),Dt=await rt(j,a),$t=await rt(j,d);p.add((0,v.createTransferInstruction)(Dt,$t,a,Lt,[],v.TOKEN_PROGRAM_ID))}else p.add(x.SystemProgram.transfer({fromPubkey:a,toPubkey:d,lamports:Math.round(Number(n.amount)*x.LAMPORTS_PER_SOL)}));let{blockhash:w}=await f.getLatestBlockhash();p.recentBlockhash=w,p.feePayer=a;let{signature:$}=await o.signAndSendTransaction(p);return $}catch(s){throw console.error("Solana Transaction Error:",s),s.message?.includes("User rejected")?new Error("Transaction rejected by user"):new Error(s.message||"Failed to send Solana transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}}});var vt={};O(vt,{useEVMWallet:()=>Cr});var Cr,Mt=et(()=>{"use strict";Cr=()=>{let e=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},t=async()=>{let n=e();if(n)try{return(await n.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or EVM wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");let o=await i.request({method:"eth_accounts"});if(!o||o.length===0)throw new Error("No accounts found. Please connect your wallet first.");let s=n.currency.toUpperCase()==="USDC"?6:18,m="0x"+BigInt(Math.floor(Number(n.amount)*Math.pow(10,s))).toString(16);try{return await i.request({method:"eth_sendTransaction",params:[{from:o[0],to:n.paymentAddress,value:n.currency.toUpperCase()==="ETH"?m:"0x0"}]})}catch(u){throw u.code===4001?new Error("Transaction rejected by user"):new Error(u.message||"Failed to send transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}}});var kr={};O(kr,{CSS_CONTENT:()=>Ut,PaymentWidget:()=>Fr,injectStyles:()=>Q,usePayment:()=>tt});module.exports=Gt(kr);var Rt=it(At()),C=require("react");var Ct=require("react"),b=require("lucide-react"),kt=require("clsx"),Nt=require("tailwind-merge");var Ut=".mcms-mx-auto{margin-left:auto;margin-right:auto}.mcms-mb-3{margin-bottom:.75rem}.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-1{margin-top:.25rem}.mcms-flex{display:flex}.mcms-h-12{height:3rem}.mcms-h-3{height:.75rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-8{height:2rem}.mcms-w-12{width:3rem}.mcms-w-3{width:.75rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-8{width:2rem}.mcms-w-full{width:100%}.mcms-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-1{gap:.25rem}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.mcms-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.mcms-overflow-hidden{overflow:hidden}.mcms-break-all{word-break:break-all}.mcms-rounded-2xl{border-radius:1rem}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-t{border-top-width:1px}.mcms-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity,1))}.mcms-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-indigo-50{--tw-bg-opacity:1;background-color:rgb(238 242 255/var(--tw-bg-opacity,1))}.mcms-bg-indigo-600{--tw-bg-opacity:1;background-color:rgb(79 70 229/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-slate-100{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.mcms-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.mcms-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-px-4{padding-left:1rem;padding-right:1rem}.mcms-px-6{padding-left:1.5rem;padding-right:1.5rem}.mcms-py-3{padding-top:.75rem;padding-bottom:.75rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-center{text-align:center}.mcms-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-font-semibold{font-weight:600}.mcms-uppercase{text-transform:uppercase}.mcms-tracking-wider{letter-spacing:.05em}.mcms-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-indigo-600{--tw-text-opacity:1;color:rgb(79 70 229/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.mcms-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.mcms-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.mcms-text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-bg-black:hover{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.hover:mcms-bg-indigo-700:hover{--tw-bg-opacity:1;background-color:rgb(67 56 202/var(--tw-bg-opacity,1))}.hover:mcms-bg-orange-600:hover{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity,1))}.hover:mcms-text-indigo-700:hover{--tw-text-opacity:1;color:rgb(67 56 202/var(--tw-text-opacity,1))}",Q=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=Ut,document.head.appendChild(e)};var l=require("react/jsx-runtime");function Pt(...e){return(0,Nt.twMerge)((0,kt.clsx)(e))}var Fr=({className:e,...t})=>{(0,Ct.useLayoutEffect)(()=>{typeof window<"u"&&Q()},[]);let{status:r,intent:n,error:i,initiate:o,verify:s,setStatus:m,handleSolanaPay:u,handleEVMPay:f}=tt(t);return r==="success"?(0,l.jsxs)("div",{className:Pt("mcms-p-6 mcms-text-center mcms-bg-green-50 mcms-rounded-xl mcms-border mcms-border-green-200",e),children:[(0,l.jsx)(b.CheckCircle,{className:"mcms-mx-auto mcms-w-12 mcms-h-12 mcms-text-green-500 mcms-mb-4"}),(0,l.jsx)("h3",{className:"mcms-text-lg mcms-font-semibold mcms-green-900",children:"Payment Successful"}),(0,l.jsx)("p",{className:"mcms-text-green-700 mcms-mt-1",children:"Your order has been confirmed."})]}):(0,l.jsxs)("div",{className:Pt("mcms-bg-white mcms-rounded-2xl mcms-border mcms-border-slate-200 mcms-shadow-sm mcms-overflow-hidden",e),children:[(0,l.jsxs)("div",{className:"mcms-p-6",children:[(0,l.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[(0,l.jsx)("div",{className:"mcms-p-2 mcms-bg-indigo-50 mcms-rounded-lg",children:(0,l.jsx)(b.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-indigo-600"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"mcms-font-semibold mcms-text-slate-900",children:"Crypto Payment"}),(0,l.jsx)("p",{className:"mcms-text-sm mcms-text-slate-500",children:"Pay securely using your wallet"})]})]}),i&&(0,l.jsxs)("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-border mcms-border-red-100 mcms-rounded-lg mcms-flex mcms-gap-3 mcms-text-red-700 mcms-text-sm",children:[(0,l.jsx)(b.AlertCircle,{className:"mcms-w-4 mcms-h-4 mcms-shrink-0"}),(0,l.jsx)("p",{children:i})]}),r==="idle"&&(0,l.jsx)("button",{onClick:o,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Start Payment"}),(r==="connecting"||r==="initiating"||r==="verifying")&&(0,l.jsxs)("div",{className:"mcms-py-8 mcms-text-center",children:[(0,l.jsx)(b.Loader2,{className:"mcms-w-8 mcms-h-8 mcms-text-indigo-600 mcms-animate-spin mcms-mx-auto mcms-mb-3"}),(0,l.jsx)("p",{className:"mcms-text-slate-600 mcms-font-medium",children:r==="connecting"?"Connecting wallet...":r==="initiating"?"Preparing transaction...":"Verifying on-chain..."})]}),r==="pending_signature"&&n&&(0,l.jsxs)("div",{className:"mcms-space-y-4",children:[(0,l.jsxs)("div",{className:"mcms-p-4 mcms-bg-slate-50 mcms-rounded-xl mcms-space-y-2",children:[(0,l.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,l.jsx)("span",{className:"mcms-text-slate-500",children:"Amount to pay"}),(0,l.jsxs)("span",{className:"mcms-font-mono mcms-font-medium mcms-text-slate-900",children:[n.amount," ",n.currency]})]}),(0,l.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,l.jsx)("span",{className:"mcms-text-slate-500",children:"Order ID"}),(0,l.jsx)("span",{className:"mcms-font-mono mcms-text-slate-900",children:n.orderId})]}),(0,l.jsxs)("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[(0,l.jsx)("span",{className:"mcms-text-slate-500",children:"Network"}),(0,l.jsx)("span",{className:"mcms-text-slate-900 mcms-font-medium",children:n.network})]})]}),(0,l.jsxs)("div",{className:"mcms-space-y-2",children:[(0,l.jsx)("p",{className:"mcms-text-xs mcms-text-slate-500 mcms-uppercase mcms-font-bold mcms-tracking-wider",children:"Destination Address"}),(0,l.jsx)("div",{className:"mcms-p-3 mcms-bg-slate-100 mcms-rounded-lg mcms-font-mono mcms-text-xs mcms-break-all mcms-text-slate-600 mcms-border mcms-border-slate-200 mcms-flex mcms-justify-center",children:n.paymentAddress?`${n.paymentAddress.slice(0,6)}...${n.paymentAddress.slice(-4)}`:"Establishing..."})]}),(0,l.jsx)("div",{className:"mcms-flex mcms-flex-col mcms-gap-2",children:n.network?.toLowerCase().includes("solana")?(0,l.jsxs)("button",{onClick:u,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[(0,l.jsx)(b.Cpu,{className:"mcms-w-4 mcms-h-4"}),"Pay with Phantom"]}):n.network?.toLowerCase().includes("ethereum")||n.network?.toLowerCase().includes("evm")||n.network?.toLowerCase().includes("polygon")?(0,l.jsxs)("button",{onClick:f,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-orange-500 hover:mcms-bg-orange-600 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[(0,l.jsx)("img",{src:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Mirror_Logo.svg",className:"mcms-w-4 mcms-h-4",alt:"MetaMask"}),"Pay with MetaMask"]}):(0,l.jsx)("button",{onClick:()=>{m("verifying"),setTimeout(()=>s("0x_mock_transaction_hash_generic"),2e3)},className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-slate-900 hover:mcms-bg-black mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Confirm in Wallet"})})]})]}),(0,l.jsxs)("div",{className:"mcms-bg-slate-50 mcms-px-6 mcms-py-3 mcms-border-t mcms-border-slate-100 mcms-flex mcms-justify-between mcms-items-center",children:[(0,l.jsx)("span",{className:"mcms-text-xs mcms-text-slate-400",children:"Powered by Micro-CMS Crypto"}),(0,l.jsxs)("a",{href:"#",className:"mcms-text-xs mcms-text-indigo-600 hover:mcms-text-indigo-700 mcms-font-medium mcms-flex mcms-items-center mcms-gap-1",children:["Help ",(0,l.jsx)(b.ExternalLink,{className:"mcms-w-3 mcms-h-3"})]})]})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=Rt.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}));var tt=e=>{let[t,r]=(0,C.useState)("idle"),[n,i]=(0,C.useState)(null),[o,s]=(0,C.useState)(null),m=(0,C.useCallback)(async a=>{try{if(r("verifying"),e.provider){let w=await e.provider.verifyPayment(a,e.orderId);if(w.status==="confirmed")r("success"),e.onSuccess?.(w);else throw new Error("Payment not confirmed yet, status: "+w.status);return}let d=await fetch(e.endpoints?.verify||"/api/orders/verify-payment",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({orderId:o?.orderId||e.orderId,transactionHash:a})});if(!d.ok){let w=await d.json();throw new Error(w.error||"Payment verification failed")}let p=await d.json();if(p.status==="confirmed")r("success"),e.onSuccess?.(p);else throw new Error("Payment not confirmed yet, status: "+p.status)}catch(d){i(d.message),r("error"),e.onError?.(d)}},[e.provider,e.endpoints?.verify,e.orderId,e.onSuccess,e.onError,e.headers,o?.orderId]),u=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let{useSolanaWallet:a}=await Promise.resolve().then(()=>(Tt(),St)),d=a(),p=await d.connect();r("pending_signature");let w=await d.sendPayment(o,e.solanaRpcUrl);r("verifying"),await m(w)}catch(a){i(a.message||"Failed to connect to Phantom or sign transaction."),r("error"),e.onError?.(a instanceof Error?a:new Error(String(a)))}},f=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let{useEVMWallet:a}=await Promise.resolve().then(()=>(Mt(),vt)),d=a(),p=await d.connect();r("pending_signature");let w=await d.sendPayment(o);r("verifying"),await m(w)}catch(a){i(a.message||"Failed to connect to MetaMask or sign transaction."),r("error"),e.onError?.(a instanceof Error?a:new Error(String(a)))}},h=(0,C.useCallback)(async()=>{try{if(r("initiating"),i(null),e.provider){let p=await e.provider.initiatePayment(e.orderId,{amount:e.amount,currency:e.currency});s(p),r("pending_signature");return}let a=await fetch(e.endpoints?.initiate||"/api/orders/initiate",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({productId:e.orderId,amount:e.amount,currency:e.currency,paymentProvider:"crypto"})});if(!a.ok){let p=await a.json();throw new Error(p.error||"Failed to initiate payment intent")}let d=await a.json();s(d),r("pending_signature")}catch(a){i(a.message),r("error"),e.onError?.(a)}},[e.provider,e.endpoints?.initiate,e.orderId,e.amount,e.currency,e.onError,e.headers]);return{status:t,intent:o,error:n,initiate:h,verify:m,setStatus:r,isSolanaAvailable:!0,handleSolanaPay:u,isEVMAvailable:!0,handleEVMPay:f}};0&&(module.exports={CSS_CONTENT,PaymentWidget,injectStyles,usePayment});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
ieee754/index.js:
|