@nowramp/form 0.1.46 → 0.1.47

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.
@@ -51,5 +51,5 @@ Error generating stack: `+o.message+`
51
51
  * @nowramp/sdk v0.1.13
52
52
  * (c) 2026 NowRamp
53
53
  * @license MIT
54
- */class Gl{constructor(t){this.config=t,this.baseUrl=t.apiUrl||"https://api.nowramp.com"}async getRate(t){var o,i,s,u,c,h;if(!this.config.apiKey)return this.getPublicRate(t);const n=await fetch(`${this.baseUrl}/v1/rates/convert`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),y=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${y}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.rate,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationAmount:l.destinationAmount,destinationCurrency:l.destinationCurrency,fees:{processingFee:((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:((u=l.fees)==null?void 0:u.processingFeePercent)||0,networkFee:((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:((h=l.fees)==null?void 0:h.totalFee)||0},provider:l.provider||"unknown",expiresAt:l.expiresAt}}async getPublicRate(t){var o,i,s,u,c,h;const n=await fetch(`${this.baseUrl}/public/wert/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),y=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${y}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.ticker||l.rate,sourceAmount:l.currencyAmount||l.sourceAmount||t.amount,sourceCurrency:t.from,destinationAmount:l.commodityAmount||l.destinationAmount,destinationCurrency:t.to,fees:{processingFee:l.feeAmount||((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:l.feePercent||((u=l.fees)==null?void 0:u.processingFeePercent)||0,networkFee:l.currencyMinerFee||((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:(l.feeAmount||0)+(l.currencyMinerFee||0)||((h=l.fees)==null?void 0:h.totalFee)||0},provider:"wert",expiresAt:l.expiresAt}}async getCurrencies(){var l,o;if(!this.config.apiKey)return this.getPublicCurrencies();const t=await fetch(`${this.baseUrl}/v1/rates/currencies`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async getPublicCurrencies(){var l,o;if(!this.config.projectId)throw new Error("projectId is required to fetch currencies without an API key");const t=await fetch(`${this.baseUrl}/public/projects/${this.config.projectId}/currencies`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async validateAddress(t){var l,o;const n=await fetch(`${this.baseUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate address: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async validateAddressBatch(t){var l,o;if(t.length>20)throw new Error("Maximum 20 addresses per batch");const n=await fetch(`${this.baseUrl}/public/validate/address/batch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addresses:t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate addresses: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getSupportedNetworks(){var r,l;const t=await fetch(`${this.baseUrl}/public/validate/networks`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const o=await t.json().catch(()=>({})),i=((r=o.error)==null?void 0:r.message)||o.message||`HTTP ${t.status}`;throw new Error(`Failed to get supported networks: ${i}`)}const n=await t.json();return((l=n.data)==null?void 0:l.attributes)||n.data||n}async createSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to create sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify(t)});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to create session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,clientSecret:l.clientSecret,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,expiresAt:l.expiresAt,createdAt:l.createdAt}}async getSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to get session details.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to get session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,fieldLocks:l.fieldLocks,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async cancelSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to cancel sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to cancel session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"cancelled",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async getSupported(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get supported config");const n=new URLSearchParams({projectId:this.config.projectId});t&&n.set("orderType",t);const r=await fetch(`${this.baseUrl}/public/v1/onramp/supported?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),u=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get supported config: ${u}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async getQuotes(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get quotes");const n=new URLSearchParams({projectId:this.config.projectId,fiatCurrency:t.fiatCurrency,cryptoCurrency:t.cryptoCurrency,network:t.network});t.fiatAmount&&n.set("fiatAmount",t.fiatAmount),t.cryptoAmount&&n.set("cryptoAmount",t.cryptoAmount),t.orderType&&n.set("orderType",t.orderType),t.paymentMethodId&&n.set("paymentMethodId",t.paymentMethodId),t.country&&n.set("country",t.country);const r=await fetch(`${this.baseUrl}/public/v1/onramp/quotes?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),u=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get quotes: ${u}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async createCheckoutIntent(t){var l,o;if(!this.config.projectId)throw new Error("projectId is required to create checkout intents");const n=await fetch(`${this.baseUrl}/public/v1/onramp/checkout-intent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:this.config.projectId,...t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=(typeof i.error=="string"?i.error:(l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;let u="";if(i.details)try{const c=typeof i.details=="string"?JSON.parse(i.details):i.details;if(c.errors&&typeof c.errors=="object"){const h=Object.values(c.errors).flat().filter(Boolean);h.length&&(u=h.join("; "))}}catch{}throw new Error(`Failed to create checkout intent: ${u||s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getTransaction(t){var l,o;const n=await fetch(`${this.baseUrl}/public/v1/onramp/transactions/${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to get transaction: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}}function em(e,t){const[n,r]=E.useState(null),[l,o]=E.useState(!0),[i,s]=E.useState(null),u=E.useRef(null);(!u.current||u.current!==e)&&(u.current=new Gl({apiKey:"",...e}));const c=E.useCallback(async()=>{if(!e.projectId){s(new Error("projectId is required")),o(!1);return}o(!0),s(null);try{const h=await u.current.getSupported(t);r(h)}catch(h){s(h instanceof Error?h:new Error("Failed to fetch config"))}finally{o(!1)}},[e.projectId,t]);return E.useEffect(()=>{c()},[c]),{config:n,loading:l,error:i,refetch:c}}function tm(e,t){const[n,r]=E.useState(null),[l,o]=E.useState(!1),[i,s]=E.useState(null),u=E.useRef(null),c=E.useRef(""),h=`${e.apiUrl}|${e.projectId}`;(!u.current||c.current!==h)&&(u.current=new Gl({apiKey:"",...e}),c.current=h);const m=E.useRef(0);E.useEffect(()=>{const x=++m.current;if(!t||!e.projectId){r(null),o(!1);return}o(!0),s(null),u.current.getQuotes(t).then(g=>{m.current===x&&(r(g),o(!1))},g=>{m.current===x&&(s(g instanceof Error?g:new Error("Failed to fetch quotes")),r(null),o(!1))})},[e.projectId,t==null?void 0:t.fiatCurrency,t==null?void 0:t.fiatAmount,t==null?void 0:t.cryptoAmount,t==null?void 0:t.cryptoCurrency,t==null?void 0:t.network,t==null?void 0:t.paymentMethodId,t==null?void 0:t.country,t==null?void 0:t.orderType]);const y=E.useCallback(async()=>{if(!(!t||!e.projectId)){o(!0),s(null);try{const x=await u.current.getQuotes(t);r(x)}catch(x){s(x instanceof Error?x:new Error("Failed to fetch quotes"))}finally{o(!1)}}},[e.projectId,t]);return{quotes:n,loading:l,error:i,refetch:y}}function nm(e){const[t,n]=E.useState(null),[r,l]=E.useState(!1),[o,i]=E.useState(null),s=E.useRef(null),u=E.useRef(""),c=`${e.apiUrl}|${e.projectId}`;(!s.current||u.current!==c)&&(s.current=new Gl({apiKey:"",...e}),u.current=c);const h=E.useCallback(async y=>{l(!0),i(null);try{const x=await s.current.createCheckoutIntent(y);return n(x),x}catch(x){const g=x instanceof Error?x:new Error("Failed to create checkout intent");throw i(g),g}finally{l(!1)}},[]),m=E.useCallback(()=>{n(null),i(null)},[]);return{order:t,loading:r,error:o,createOrder:h,reset:m}}function rm(e,t,n){const[r,l]=E.useState(null),[o,i]=E.useState(!1),[s,u]=E.useState(null),c=E.useRef(null);c.current||(c.current=new Gl({apiKey:"",projectId:"",...e}));const h=E.useCallback(async()=>{if(t){i(!0),u(null);try{const m=await c.current.getTransaction(t);l(m)}catch(m){u(m instanceof Error?m:new Error("Failed to fetch status"))}finally{i(!1)}}},[t]);return E.useEffect(()=>{if(!t)return;const m=n==null?void 0:n.initialDelay;{const y=setTimeout(h,m);return()=>clearTimeout(y)}},[h,t,n==null?void 0:n.initialDelay]),E.useEffect(()=>{if(!t||!(n!=null&&n.pollInterval)||!r||["completed","failed","cancelled","expired","refunded"].includes(r.status))return;const y=setInterval(h,n.pollInterval);return()=>clearInterval(y)},[t,n==null?void 0:n.pollInterval,r==null?void 0:r.status,h]),{status:r,loading:o,error:s,refetch:h}}function Jc(e,t){if(!e)return e;const n=e.indexOf(".");if(n===-1)return e;let r=e;return r.length-n-1>t&&(r=r.slice(0,n+t+1)),r=r.replace(/0+$/,"").replace(/\.$/,""),r}const qc={step:"amount",flowType:"buy",fiatCurrency:"USD",fiatAmount:"",cryptoCurrency:"",cryptoAmount:"",network:"",paymentMethodId:"",walletAddress:"",walletError:null,selectedProvider:null,selectedQuote:null,customerId:"",email:"",country:"",errorMessage:null};function lm(e,t){switch(t.type){case"SET_STEP":return{...e,step:t.step,errorMessage:null};case"SET_FLOW_TYPE":return{...e,flowType:t.flowType,fiatAmount:"",cryptoAmount:"",paymentMethodId:"",selectedQuote:null,selectedProvider:null,errorMessage:null};case"SET_FIAT_CURRENCY":return{...e,fiatCurrency:t.currency};case"SET_FIAT_AMOUNT":return{...e,fiatAmount:t.amount};case"SET_CRYPTO_CURRENCY":return{...e,cryptoCurrency:t.currency,network:""};case"SET_CRYPTO_AMOUNT":return{...e,cryptoAmount:t.amount};case"SET_NETWORK":return{...e,network:t.network};case"SET_CRYPTO_CHAIN":return{...e,network:t.chain};case"SET_PAYMENT_METHOD":return{...e,paymentMethodId:t.methodId};case"SET_WALLET_ADDRESS":return{...e,walletAddress:t.address,walletError:null};case"SET_WALLET_ERROR":return{...e,walletError:t.message};case"SELECT_QUOTE":return{...e,selectedQuote:t.quote,selectedProvider:t.quote.gatewayId};case"SET_CUSTOMER_ID":return{...e,customerId:t.customerId};case"SET_EMAIL":return{...e,email:t.email};case"SET_COUNTRY":return{...e,country:t.country};case"SET_ERROR":return{...e,step:"error",errorMessage:t.message};case"CLEAR_ERROR":return{...e,errorMessage:null};case"RESET":return qc;default:return e}}const bc=E.createContext(null);function om({projectId:e,apiUrl:t="https://api.nowramp.com",assetBaseUrl:n="",flowType:r="buy",customerId:l="",defaultFiatCurrency:o="USD",defaultCryptoCurrency:i="BTC",defaultNetwork:s="",defaultFiatAmount:u="",defaultCryptoAmount:c="",defaultWalletAddress:h="",defaultGateway:m,fieldLocks:y,statusPollInterval:x=5e3,onComplete:g,onError:S,children:L}){const f=E.useMemo(()=>({apiUrl:t,projectId:e}),[t,e]),d=s||(i?i.toLowerCase():""),p=r==="sell",w=p?!!c:!!u,R=(p?!!(w&&i&&d):!!(w&&i&&d&&h))&&m?"confirm":"amount",[v,T]=E.useReducer(lm,{...qc,step:R,flowType:r,fiatCurrency:o,cryptoCurrency:i,network:d,fiatAmount:Jc(u,2),cryptoAmount:Jc(c,6),walletAddress:h,customerId:l}),P=v.flowType==="sell",{config:A,loading:G,error:fe}=em(f,v.flowType);zn.useEffect(()=>{var ee,Z,Q;if(!A||!v.cryptoCurrency||v.network)return;const D=(ee=A.cryptos)==null?void 0:ee.find(Pe=>Pe.code===v.cryptoCurrency),z=((Z=D==null?void 0:D.networks)==null?void 0:Z.find(Pe=>Pe.isDefault))||((Q=D==null?void 0:D.networks)==null?void 0:Q[0]);z!=null&&z.id&&T({type:"SET_NETWORK",network:z.id})},[A,v.cryptoCurrency,v.network]),zn.useEffect(()=>{var Q,Pe;if(!((Q=A==null?void 0:A.paymentMethods)!=null&&Q.length))return;const D=v.fiatCurrency,z=A.paymentMethods;if(v.paymentMethodId&&z.some(vt=>vt.id===v.paymentMethodId&&vt.supportedFiats.includes(D)))return;const Z=z.find(Le=>Le.supportedFiats.includes(D)&&(Le.id.includes("card")||Le.id.includes("debit")))||z.find(Le=>Le.supportedFiats.includes(D));T({type:"SET_PAYMENT_METHOD",methodId:(Z==null?void 0:Z.id)||((Pe=z[0])==null?void 0:Pe.id)||""})},[A,v.fiatCurrency,v.paymentMethodId]);const pe=E.useMemo(()=>{if(P){if(!v.cryptoAmount)return null;const Q=parseFloat(v.cryptoAmount);return isNaN(Q)||Q<=0?"Enter a valid amount":null}if(!A||!v.fiatAmount)return null;const D=parseFloat(v.fiatAmount);if(isNaN(D))return null;const z=A.fiats.find(Q=>Q.code===v.fiatCurrency);if(!z)return null;const ee=parseFloat(z.minAmount),Z=parseFloat(z.maxAmount);return!isNaN(ee)&&D<ee?`Minimum amount is ${z.minAmount} ${v.fiatCurrency}`:!isNaN(Z)&&D>Z?`Maximum amount is ${z.maxAmount} ${v.fiatCurrency}`:null},[A,v.fiatAmount,v.fiatCurrency,v.cryptoAmount,P]),rn=E.useMemo(()=>{const D=P?!!v.cryptoAmount:!!v.fiatAmount;return!A||!D||!v.cryptoCurrency||!v.network||pe?null:{fiatCurrency:v.fiatCurrency,...P?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,paymentMethodId:v.paymentMethodId||void 0,country:v.country||void 0,orderType:v.flowType}},[A,v.fiatCurrency,v.fiatAmount,v.cryptoAmount,v.cryptoCurrency,v.network,v.paymentMethodId,v.country,pe,P,v.flowType]),{quotes:ln,loading:lt,error:ge,refetch:N}=tm(f,rn),{order:I,loading:M,error:H,createOrder:W}=nm(f),ht=15e3,{status:ae,loading:qe}=rm({apiUrl:t},(I==null?void 0:I.orderId)??null,{pollInterval:x,initialDelay:ht});zn.useEffect(()=>{(ae==null?void 0:ae.status)==="completed"&&g&&g(ae)},[ae==null?void 0:ae.status,g]),zn.useEffect(()=>{const D=fe||H;D&&S&&S(D)},[fe,H,S]);const Ce=m||(A==null?void 0:A.defaultGateway)||null,yt=E.useRef(Ce);yt.current=Ce;const bl=E.useRef(ln);bl.current=ln;const eo=E.useCallback(async()=>{var z,ee,Z;const D=((z=v.selectedQuote)==null?void 0:z.gatewayId)||((Z=(ee=bl.current)==null?void 0:ee.bestQuote)==null?void 0:Z.gatewayId)||yt.current;if(!D||!v.walletAddress){const Q=[!D&&"gateway",!v.walletAddress&&"walletAddress"].filter(Boolean).join(", ");T({type:"SET_ERROR",message:`Missing required fields: ${Q}`});return}try{await W({gateway:D,customerId:v.customerId||void 0,fiatCurrency:v.fiatCurrency,...P?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,walletAddress:v.walletAddress,paymentMethodId:v.paymentMethodId||void 0,email:v.email||void 0,orderType:v.flowType}),T({type:"SET_STEP",step:"checkout"})}catch(Q){const Pe=Q instanceof Error?Q.message:"Failed to create order";/wallet|address/i.test(Pe)?T({type:"SET_WALLET_ERROR",message:Pe.replace(/^Failed to create checkout intent:\s*/i,"")}):T({type:"SET_ERROR",message:Pe})}},[v,W,P]),Ht=E.useCallback(D=>{T({type:"SET_STEP",step:D})},[]),Fn=E.useCallback(()=>{const D=["confirm","amount","quotes","wallet","checkout","processing","complete"],z=D.indexOf(v.step);z>0&&T({type:"SET_STEP",step:D[z-1]})},[v.step,P]),Es=E.useMemo(()=>{const D=P?!!v.cryptoAmount:!!v.fiatAmount;switch(v.step){case"confirm":return!!(D&&v.cryptoCurrency&&v.network&&v.walletAddress&&!pe);case"amount":return!!(D&&v.cryptoCurrency&&v.network&&!pe);case"quotes":return!!v.selectedQuote;case"wallet":return!!v.walletAddress;default:return!1}},[v,pe,P]),Ir={apiConfig:f,assetBaseUrl:n,config:A,configLoading:G,configError:fe,state:v,dispatch:T,quotes:ln,quotesLoading:lt,quotesError:ge,fetchQuotes:N,order:I,orderLoading:M,orderError:H,createOrder:eo,orderStatus:ae,orderStatusLoading:qe,fieldLocks:y||null,defaultGateway:Ce,amountError:pe,goToStep:Ht,goBack:Fn,canProceed:Es};return a.jsx(bc.Provider,{value:Ir,children:L})}function Dn(){const e=E.useContext(bc);if(!e)throw new Error("useRamp must be used within a RampProvider");return e}const gs={ETH:{name:"Ethereum (ERC20)",shortName:"Ethereum",icon:"eth"},BSC:{name:"Binance Smart Chain (BEP20)",shortName:"Binance",icon:"bnb"},BTC:{name:"Bitcoin",icon:"btc"},SOL:{name:"Solana",icon:"sol"},MATIC:{name:"Polygon",icon:"pol"},ARB:{name:"Arbitrum",icon:"arb"},BASE:{name:"Base",icon:"base"},OPTIMISM:{name:"Optimism",icon:"op"},AVAX_C:{name:"Avalanche C-Chain",shortName:"Avalanche C",icon:"avax"},AVAX_X:{name:"Avalanche X-Chain",shortName:"Avalanche X",icon:"avax"},ADA:{name:"Cardano",icon:"ada"},DOT:{name:"Polkadot",icon:"dot"},TRON:{name:"Tron (TRC20)",shortName:"Tron",icon:"trx"},XRP:{name:"Ripple",icon:"xrp"},XLM:{name:"Stellar",icon:"xlm"},ALGO:{name:"Algorand",icon:"algo"},ATOM:{name:"Cosmos",icon:"atom"},NEAR:{name:"NEAR Protocol",shortName:"NEAR",icon:"near"},SUI:{name:"Sui",icon:"sui"},APT:{name:"Aptos",icon:"apt"},TON:{name:"Ton",icon:"ton"},FIL:{name:"Filecoin",icon:"fil"},FLOW:{name:"Flow",icon:"flow"},HBAR:{name:"Hedera Hashgraph",shortName:"Hedera",icon:"hbar"},INJ:{name:"Injective",icon:"inj"},SEI_EVM:{name:"SEI (EVM)",shortName:"SEI",icon:"sei"},ZKSYNC:{name:"zkSync",icon:"zksync"},LINEA:{name:"Linea",icon:"linea"},STARK:{name:"StarkNet",icon:"strk"},LN:{name:"Lightning",icon:"btc"},CELO:{name:"Celo",icon:"celo"},CRO:{name:"Cronos",icon:"cro"},FTM:{name:"Fantom",icon:"ftm"},GLMR:{name:"Moonbeam",icon:"glmr"},MOVR:{name:"Moonriver",icon:"movr"},KSM:{name:"Kusama",icon:"ksm"},EOS:{name:"EOS",icon:"eos"},ETC:{name:"Ethereum Classic",shortName:"ETH Classic",icon:"etc"},LTC:{name:"Litecoin",icon:"ltc"},BCH:{name:"Bitcoin Cash",shortName:"BTC Cash",icon:"bch"},DOGE:{name:"Dogecoin",icon:"doge"},BNB:{name:"Binance Chain (BEP2)",shortName:"Binance",icon:"bnb"},ONE:{name:"Harmony",icon:"one"},KLAY:{name:"Kaia",icon:"kaia"},RON:{name:"Ronin",icon:"ron"},LRC:{name:"Loopring",icon:"lrc"},ICP:{name:"Internet Computer",shortName:"ICP",icon:"icp"},EGLD:{name:"MultiversX",icon:"egld"},FLUX:{name:"Flux",icon:"flux"},KDA:{name:"Kadena",icon:"kda"},WAVES:{name:"Waves",icon:"waves"},XTZ:{name:"Tezos",icon:"xtz"},ACA:{name:"Acala",icon:"aca"},ALEO:{name:"Aleo",icon:"aleo"},ALPH:{name:"Alephium",icon:"alph"},APE:{name:"ApeChain",icon:"ape"},ASTR:{name:"Astar",icon:"astr"},AZERO:{name:"Aleph Zero",icon:"azero"},AZERO_EVM:{name:"Aleph Zero EVM",shortName:"Aleph Zero",icon:"azero"},BAJU:{name:"Bajun Network",shortName:"Bajun",icon:"baju"},BNCPOLKA:{name:"Bifrost Polkadot",shortName:"Bifrost",icon:"bnc"},BNC:{name:"Bifrost Kusama",shortName:"Bifrost",icon:"bnc"},BOBA:{name:"Boba Network",shortName:"Boba",icon:"boba"},BSX:{name:"Basilisk",icon:"bsx"},CHZ:{name:"Chiliz",icon:"chz"},VIC:{name:"Viction",icon:"vic"},CCD:{name:"Concordium",icon:"ccd"},COREUM:{name:"Coreum",icon:"coreum"},DINGO:{name:"Dingocoin",icon:"dingo"},HDX:{name:"Hydration",icon:"hdx"},PLMC:{name:"Polimec",icon:"plmc"},MNT:{name:"Mantle",icon:"mnt"},ERG:{name:"Ergo",icon:"erg"},ECLIPSE:{name:"Eclipse",icon:"eclipse"},FUEL:{name:"Fuel Ignition",shortName:"Fuel",icon:"fuel"},INK:{name:"Ink",icon:"ink"},SOPHON:{name:"Sophon",icon:"sophon"},UNICHAIN:{name:"Unichain",icon:"unichain"},WLD:{name:"Worldchain",icon:"wld"},ETHERLINK:{name:"Etherlink",icon:"etherlink"},MOB:{name:"MobileCoin",icon:"mob"},GALA:{name:"Gala",icon:"gala"},GUNZ:{name:"Gunz",icon:"gun"},HNT:{name:"Helium",icon:"hnt"},BITKUB:{name:"BitKub",icon:"kub"},IMMUTABLE_ZKEVM:{name:"Immutable-zkEVM",shortName:"Immutable",icon:"imx"},INIT:{name:"Initia",icon:"init"},INTR:{name:"Interlay",icon:"intr"},KINESIS:{name:"Kinesis",icon:"kag"},KAR:{name:"Karura",icon:"kar"},KCC:{name:"KuCoin Community Chain",shortName:"KuCoin",icon:"kcs"},KILT:{name:"KILT Spiritnet",shortName:"KILT",icon:"kilt"},KINT:{name:"Kintsugi",icon:"kint"},KMD:{name:"Komodo",icon:"kmd"},LSK:{name:"Lisk",icon:"lsk"},METIS:{name:"Metis Andromeda",shortName:"Metis",icon:"metis"},MYTH:{name:"Myth",icon:"myth"},OAS:{name:"Oasys",icon:"oas"},PEAQ_EVM:{name:"Peaq (EVM)",shortName:"Peaq",icon:"peaq"},PEN:{name:"Pendulum",icon:"pen"},PI:{name:"Pi",icon:"pi"},POLYX:{name:"Polymesh",icon:"polyx"},Q:{name:"QuantumCoin",icon:"q"},QRL:{name:"Quantum Resistant Ledger",shortName:"QRL",icon:"qrl"},QUBIC:{name:"Qubic",icon:"qubic"},RBX:{name:"ReserveBlock",icon:"rbx"},ROLLUX:{name:"Rollux",icon:"rollux"},THORCHAIN:{name:"Thorchain",icon:"rune"},S:{name:"Sonic",icon:"s"},SONIC:{name:"Sonic",icon:"s"},TERNOA:{name:"Ternoa",icon:"caps"},SX:{name:"SX Network",icon:"sol"},WAX:{name:"WAX",icon:"waxp"},XCH:{name:"Chia Chain",icon:"xch"},XPRT:{name:"Persistence",icon:"xprt"},ZETACHAIN:{name:"ZetaChain",icon:"zeta"},ZTG:{name:"Zeitgeist",icon:"ztg"},PLS:{name:"Pulsechain",icon:"pulsechain"},MEZO:{name:"Mezo",icon:"mezo"},BSV:{name:"Bitcoin SV",shortName:"BTC SV",icon:"btc"},MONAD:{name:"Monad",icon:"mon"},SUPRA:{name:"Supra",icon:"supra"},SOMI:{name:"Somnia",icon:"somi"},VERIFIEDX:{name:"VerifiedX",icon:"vfx"},MOVE:{name:"Movement",icon:"move"},FLR:{name:"Flare",icon:"flr"},ASSETHUB:{name:"Asset Hub Polkadot",shortName:"Asset Hub",icon:"dot"},BOB:{name:"BOB",icon:"btc"},GLUE:{name:"Glue",icon:"eth"},DYDX:{name:"StarkEx",icon:"stark"},OKC:{name:"OKX Chain",icon:"eth"},UNI_CHAIN:{name:"UNI",icon:"uni"},ZEC:{name:"ZCash",icon:"zec"}},im=[{code:"BTC",name:"Bitcoin",chains:["BTC","LN"],popular:!0},{code:"ETH",name:"Ethereum",chains:["ETH","ARB","BASE","BSC","OPTIMISM","LINEA","ZKSYNC","LRC","STARK","APE","ECLIPSE","FUEL","INK","SOPHON","UNICHAIN","WLD"],popular:!0},{code:"USDC",name:"USD Coin",chains:["ETH","SOL","ARB","BASE","BSC","MATIC","OPTIMISM","AVAX_C","ALGO","APT","CELO","FLOW","HBAR","LINEA","LRC","ZKSYNC","STARK","SUI","XLM","ECLIPSE","HDX","INK","LSK","METIS","MONAD","SEI_EVM","SONIC","SOPHON","SX","UNICHAIN","APE","BNCPOLKA","GLMR","PEAQ_EVM","PLMC","RON","UNI_CHAIN","WLD","BITKUB","BOB","DYDX","ETHERLINK","GLUE","ASSETHUB"],popular:!0},{code:"USDT",name:"Tether",chains:["ETH","BSC","TRON","ARB","MATIC","AVAX_C","SOL","OPTIMISM","ZKSYNC","STARK","APT","CELO","KLAY","LRC","LSK","ECLIPSE","ETHERLINK","OKC","PEAQ_EVM","BNCPOLKA","GLMR","HDX","PLMC","VIC","ASSETHUB"],popular:!0},{code:"SOL",name:"Solana",chains:["SOL"],popular:!0},{code:"XRP",name:"Ripple",chains:["XRP"],popular:!0},{code:"ADA",name:"Cardano",chains:["ADA"],popular:!0},{code:"DOGE",name:"Dogecoin",chains:["DOGE"],popular:!0},{code:"DOT",name:"Polkadot",chains:["DOT","BSC","BNCPOLKA","GLMR","HDX","PLMC"],popular:!0},{code:"AVAX",name:"Avalanche",chains:["AVAX_C","AVAX_X","BSC"],popular:!0},{code:"LINK",name:"ChainLink",chains:["ETH","BSC"],popular:!0},{code:"LTC",name:"Litecoin",chains:["LTC"],popular:!0},{code:"AAVE",name:"Aave",chains:["ETH","BSC"],popular:!1},{code:"ACA",name:"Acala",chains:["ACA"],popular:!1},{code:"ALEO",name:"Aleo",chains:["ALEO"],popular:!1},{code:"ALGO",name:"Algorand",chains:["ALGO"],popular:!1},{code:"ALPH",name:"Alephium",chains:["ALPH"],popular:!1},{code:"APE",name:"ApeCoin",chains:["APE","ETH"],popular:!1},{code:"APT",name:"Aptos",chains:["APT"],popular:!1},{code:"ARB",name:"Arbitrum",chains:["ARB"],popular:!1},{code:"ASTR",name:"Astar",chains:["ASTR"],popular:!1},{code:"ATOM",name:"Cosmos",chains:["ATOM"],popular:!1},{code:"AUDD",name:"Novatti Australian Digital Dollar",chains:["ETH"],popular:!1},{code:"AVT",name:"Aventus",chains:["ETH"],popular:!1},{code:"AXS",name:"Axie Infinity",chains:["ETH","RON"],popular:!1},{code:"AZERO",name:"Aleph Zero",chains:["AZERO","AZERO_EVM"],popular:!1},{code:"BAJU",name:"Bajun Network",chains:["BAJU"],popular:!1},{code:"BARSIK",name:"Hasbulla's Cat",chains:["SOL"],popular:!1},{code:"BAT",name:"Basic Attention Token",chains:["ETH","BSC"],popular:!1},{code:"BCH",name:"Bitcoin Cash",chains:["BCH"],popular:!1},{code:"BNB",name:"Binance Coin",chains:["BNB","BSC"],popular:!1},{code:"BNC",name:"Bifrost Native Coin",chains:["BNC","BNCPOLKA"],popular:!1},{code:"BOBA",name:"Boba Network",chains:["BOBA","ETH"],popular:!1},{code:"BORA",name:"Bora",chains:["KLAY"],popular:!1},{code:"BRETT",name:"Brett",chains:["BASE"],popular:!1},{code:"BSX",name:"Basilisk",chains:["BSX"],popular:!1},{code:"BZR",name:"Bazaars",chains:["ETH"],popular:!1},{code:"CAGA",name:"Crypto Asset Governance Alliance",chains:["ETH"],popular:!1},{code:"CAKE",name:"PancakeSwap",chains:["BSC"],popular:!1},{code:"CAPS",name:"Caps",chains:["TERNOA"],popular:!1},{code:"CELO",name:"Celo",chains:["CELO"],popular:!1},{code:"CHZ",name:"Chiliz",chains:["CHZ","BNB","ETH"],popular:!1},{code:"C98",name:"Coin98",chains:["VIC"],popular:!1},{code:"CCD",name:"Concordium",chains:["CCD"],popular:!1},{code:"COMP",name:"Compound",chains:["ETH","BSC"],popular:!1},{code:"COREUM",name:"Coreum",chains:["COREUM","XRP"],popular:!1},{code:"CRO",name:"Cronos",chains:["CRO"],popular:!1},{code:"CUSD",name:"Celo Dollar",chains:["CELO"],popular:!1},{code:"CVC",name:"Civic",chains:["ETH"],popular:!1},{code:"DAI",name:"Dai",chains:["ETH","BASE","MATIC"],popular:!1},{code:"DINGO",name:"Dingocoin",chains:["DINGO"],popular:!1},{code:"EGLD",name:"MultiversX",chains:["EGLD"],popular:!1},{code:"EMBER",name:"Ember Sword",chains:["MNT"],popular:!1},{code:"EOS",name:"EOS",chains:["EOS"],popular:!1},{code:"ERG",name:"Ergo",chains:["ERG"],popular:!1},{code:"ETC",name:"Ethereum Classic",chains:["ETC","BSC"],popular:!1},{code:"EUR",name:"EURC",chains:["BASE"],popular:!1},{code:"EUROC",name:"Euro Coin",chains:["ETH"],popular:!1},{code:"EURQ",name:"Quantoz EURQ",chains:["ETH"],popular:!1},{code:"EURR",name:"StablR EUR",chains:["ETH"],popular:!1},{code:"EUSD",name:"Electronic USD",chains:["MOB"],popular:!1},{code:"EXIT",name:"EXIT - Designer Token",chains:["BSC"],popular:!1},{code:"FDUSD",name:"First Digital USD",chains:["SUI"],popular:!1},{code:"FIL",name:"Filecoin",chains:["FIL","BSC"],popular:!1},{code:"FLOW",name:"Flow",chains:["FLOW"],popular:!1},{code:"FLR",name:"Flare",chains:["FLR"],popular:!1},{code:"FLUX",name:"Flux",chains:["FLUX"],popular:!1},{code:"FTM",name:"Fantom",chains:["FTM","ETH","BSC"],popular:!1},{code:"GALA",name:"Gala",chains:["GALA"],popular:!1},{code:"GLMR",name:"Moonbeam",chains:["GLMR"],popular:!1},{code:"GMX",name:"GMX",chains:["ARB"],popular:!1},{code:"GNUS",name:"Genius AI",chains:["ETH"],popular:!1},{code:"GRT",name:"The Graph",chains:["ETH","ARB"],popular:!1},{code:"GUN",name:"Gunz",chains:["GUNZ"],popular:!1},{code:"HBAR",name:"Hedera",chains:["HBAR"],popular:!1},{code:"HDX",name:"HydraDX",chains:["HDX"],popular:!1},{code:"HNT",name:"Helium",chains:["HNT"],popular:!1},{code:"HTP",name:"HowToPay",chains:["BSC"],popular:!1},{code:"HVLO",name:"Hivello",chains:["SOL"],popular:!1},{code:"ICP",name:"Internet Computer",chains:["ICP"],popular:!1},{code:"IMX",name:"Immutable X",chains:["ETH"],popular:!1},{code:"INIT",name:"Initia",chains:["INIT"],popular:!1},{code:"INJ",name:"Injective",chains:["INJ"],popular:!1},{code:"INTR",name:"Interlay",chains:["INTR"],popular:!1},{code:"JAM",name:"Jam Tune.FM",chains:["HBAR"],popular:!1},{code:"KAG",name:"Silver",chains:["KINESIS"],popular:!1},{code:"KAIA",name:"Kaia",chains:["KLAY"],popular:!1},{code:"KAR",name:"Karura",chains:["KAR"],popular:!1},{code:"KAU",name:"Gold",chains:["KINESIS"],popular:!1},{code:"KCS",name:"KuCoin Token",chains:["ETH","KCC"],popular:!1},{code:"KDA",name:"Kadena",chains:["KDA"],popular:!1},{code:"KILT",name:"KILT",chains:["KILT"],popular:!1},{code:"KINT",name:"Kintsugi",chains:["KINT"],popular:!1},{code:"KLV",name:"Klever",chains:["TRON"],popular:!1},{code:"KMD",name:"Komodo",chains:["KMD"],popular:!1},{code:"KSM",name:"Kusama",chains:["KSM"],popular:!1},{code:"KUB",name:"Bitkub Coin",chains:["BITKUB"],popular:!1},{code:"LOOKS",name:"LooksRare",chains:["ETH"],popular:!1},{code:"LRC",name:"Loopring",chains:["ETH","LRC"],popular:!1},{code:"LSK",name:"Lisk",chains:["LSK"],popular:!1},{code:"MANA",name:"Decentraland",chains:["ETH"],popular:!1},{code:"MBX",name:"Marblex",chains:["IMMUTABLE_ZKEVM","KLAY"],popular:!1},{code:"MELANIA",name:"Melania",chains:["SOL"],popular:!1},{code:"METAMASKUSD",name:"Metamask USD",chains:["ETH","LINEA"],popular:!1},{code:"METIS",name:"Metis",chains:["METIS"],popular:!1},{code:"MEZOUSD",name:"MUSD",chains:["ETH","MEZO"],popular:!1},{code:"MKR",name:"Maker",chains:["ETH","BSC"],popular:!1},{code:"MNEE",name:"MNEE",chains:["BSV","ETH"],popular:!1},{code:"MNT",name:"Mantle",chains:["ETH","MNT"],popular:!1},{code:"MOB",name:"MobileCoin",chains:["MOB"],popular:!1},{code:"MON",name:"Monad",chains:["MONAD"],popular:!1},{code:"MOVE",name:"Movement",chains:["MOVE"],popular:!1},{code:"MOVR",name:"Moonriver",chains:["MOVR"],popular:!1},{code:"MYTH",name:"Myth",chains:["MYTH"],popular:!1},{code:"NEAR",name:"NEAR Protocol",chains:["NEAR","BSC"],popular:!1},{code:"NEIRO",name:"NEIRO Ethereum",chains:["ETH"],popular:!1},{code:"OAS",name:"Oasys",chains:["OAS"],popular:!1},{code:"OMG",name:"OmiseGo",chains:["ETH"],popular:!1},{code:"OMUSD",name:"Open Money USD",chains:["ETH"],popular:!1},{code:"ONE",name:"Harmony",chains:["ONE","BNB","ETH"],popular:!1},{code:"OP",name:"Optimism",chains:["OPTIMISM"],popular:!1},{code:"ORDER",name:"Orderly Network",chains:["ETH"],popular:!1},{code:"PEAQ",name:"Peaq",chains:["PEAQ_EVM"],popular:!1},{code:"PEN",name:"Pendulum",chains:["PEN"],popular:!1},{code:"PERC",name:"Perion",chains:["ETH"],popular:!1},{code:"PI",name:"Pi",chains:["PI"],popular:!1},{code:"PLMC",name:"Polimec",chains:["PLMC"],popular:!1},{code:"POL",name:"Polygon",chains:["ETH","MATIC"],popular:!1},{code:"POLYX",name:"Polymesh",chains:["POLYX"],popular:!1},{code:"PROPC",name:"Propchain",chains:["ETH"],popular:!1},{code:"PSTAKE",name:"pSTAKE Finance",chains:["ETH"],popular:!1},{code:"Q",name:"QuantumCoin",chains:["Q"],popular:!1},{code:"QRDO",name:"Qredo",chains:["ETH"],popular:!1},{code:"QRL",name:"Quantum Resistant Ledger",chains:["QRL"],popular:!1},{code:"QUBIC",name:"QUBIC",chains:["QUBIC"],popular:!1},{code:"RBX",name:"ReserveBlock",chains:["RBX"],popular:!1},{code:"REVU",name:"Revuto",chains:["ADA"],popular:!1},{code:"RITE",name:"Ritestream",chains:["BSC"],popular:!1},{code:"RLUSD",name:"Ripple USD",chains:["ETH"],popular:!1},{code:"RON",name:"Ronin",chains:["RON"],popular:!1},{code:"RUNE",name:"THORChain",chains:["THORCHAIN"],popular:!1},{code:"S",name:"Sonic",chains:["S"],popular:!1},{code:"SAND",name:"The Sandbox",chains:["ETH","BSC"],popular:!1},{code:"SEI",name:"SEI",chains:["SEI_EVM"],popular:!1},{code:"SNX",name:"Synthetix",chains:["ETH"],popular:!1},{code:"SOIL",name:"Sun Minimeal",chains:["PLS"],popular:!1},{code:"SOLO",name:"Sologenic",chains:["XRP"],popular:!1},{code:"SOMI",name:"Somnia",chains:["SOMI"],popular:!1},{code:"STRK",name:"Starknet",chains:["STARK"],popular:!1},{code:"SUI",name:"Sui",chains:["SUI"],popular:!1},{code:"SUPR",name:"SuperDapp",chains:["ROLLUX"],popular:!1},{code:"SUPRA",name:"Supra",chains:["SUPRA"],popular:!1},{code:"SUSHI",name:"SushiSwap",chains:["ETH","BSC"],popular:!1},{code:"SYS",name:"Syscoin",chains:["ROLLUX"],popular:!1},{code:"TBTC",name:"tBTC",chains:["SUI","STARK"],popular:!1},{code:"TON",name:"Toncoin",chains:["TON"],popular:!1},{code:"TRUMP",name:"TRUMP",chains:["SOL"],popular:!1},{code:"TRX",name:"Tron",chains:["TRON","BSC"],popular:!1},{code:"TWT",name:"Trust Wallet Token",chains:["BSC"],popular:!1},{code:"UNI",name:"Uniswap",chains:["ETH","BSC"],popular:!1},{code:"URANIUM",name:"Uranium",chains:["ETHERLINK"],popular:!1},{code:"USD0",name:"Usual USD",chains:["ETH"],popular:!1},{code:"USD1",name:"World Liberty Financial USD",chains:["SOL"],popular:!1},{code:"USDE",name:"Ethena USDe",chains:["ETH"],popular:!1},{code:"USDP",name:"Pax Dollar",chains:["ETH"],popular:!1},{code:"USDQ",name:"Quantoz USDQ",chains:["ETH"],popular:!1},{code:"USDR",name:"StablR USD",chains:["ETH"],popular:!1},{code:"USDT0",name:"USDT0",chains:["INK"],popular:!1},{code:"VFX",name:"VerifiedX",chains:["VERIFIEDX"],popular:!1},{code:"VERSE",name:"Verse",chains:["ETH","MATIC"],popular:!1},{code:"VIC",name:"Viction",chains:["VIC"],popular:!1},{code:"WAL",name:"Walrus",chains:["SUI"],popular:!1},{code:"WAVES",name:"Waves",chains:["WAVES"],popular:!1},{code:"WAXP",name:"WAX",chains:["WAX"],popular:!1},{code:"WBTC",name:"Wrapped Bitcoin",chains:["ETH","STARK"],popular:!1},{code:"WETH",name:"Wrapped Ether",chains:["ETHERLINK"],popular:!1},{code:"WLD",name:"Worldcoin",chains:["WLD"],popular:!1},{code:"WLFI",name:"World Liberty Financial",chains:["ETH"],popular:!1},{code:"WOLF",name:"LandWolf",chains:["ETH"],popular:!1},{code:"WOMBAT",name:"Wombat",chains:["MATIC"],popular:!1},{code:"XCH",name:"Chia",chains:["XCH"],popular:!1},{code:"XLM",name:"Stellar Lumens",chains:["XLM","BSC"],popular:!1},{code:"XPRT",name:"Persistence",chains:["XPRT"],popular:!1},{code:"XTZ",name:"Tezos",chains:["XTZ","ETHERLINK"],popular:!1},{code:"YFI",name:"yearn.finance",chains:["ETH"],popular:!1},{code:"ZBU",name:"Zeebu",chains:["BSC"],popular:!1},{code:"ZEC",name:"ZCash",chains:["ZEC"],popular:!1},{code:"ZCHF",name:"Frankencoin",chains:["ETH"],popular:!1},{code:"ZETA",name:"Zeta",chains:["ETH","ZETACHAIN"],popular:!1},{code:"ZTG",name:"Zeitgeist",chains:["ZTG"],popular:!1}],sm={AED:"ae",ALL:"al",ARS:"ar",AUD:"au",BRL:"br",CAD:"ca",CHF:"ch",CLP:"cl",CZK:"cz",DKK:"dk",EUR:"eu",GBP:"gb",HKD:"hk",IDR:"id",INR:"in",JPY:"jp",KRW:"kr",MXN:"mx",NGN:"ng",NOK:"no",NZD:"nz",PHP:"ph",PLN:"pl",QAR:"qa",SAR:"sa",SEK:"se",SGD:"sg",THB:"th",TRY:"tr",TWD:"tw",USD:"us",VND:"vn",ZAR:"za"};function ed(e,t=""){return`${t}/crypto-icons/${e.toLowerCase()}.svg`}function am(e,t=""){const n=sm[e]||"us";return`${t}/flags/${n}.svg`}function Zl(e){return gs[e]||gs[e.toUpperCase()]||gs[e.toUpperCase().replace(/-/g,"_")]}function xs(e,t=""){const n=Zl(e);return n?`${t}/crypto-icons/${n.icon}.svg`:`${t}/crypto-icons/${e.toLowerCase()}.svg`}const td=[{code:"ALL",name:"Albania Lek"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australian Dollar"},{code:"BRL",name:"Brazilian Real"},{code:"CAD",name:"Canadian Dollar"},{code:"EUR",name:"Euro"},{code:"GBP",name:"British Pound"},{code:"JPY",name:"Japanese Yen"},{code:"USD",name:"US Dollar"},{code:"CHF",name:"Swiss Franc"},{code:"MXN",name:"Mexican Peso"},{code:"INR",name:"Indian Rupee"}],nd=[{id:"blue",name:"Blue",accent:"#0077FF"},{id:"violet",name:"Violet",accent:"#7C3AED"},{id:"green",name:"Green",accent:"#10B981"},{id:"orange",name:"Orange",accent:"#F59E0B"},{id:"rose",name:"Rose",accent:"#F43F5E"},{id:"mono",name:"Mono",accent:null}];function um(e){return parseFloat(e.replace(/,/g,""))||0}const ws=e=>/^#([0-9A-Fa-f]{3}){1,2}$/.test(e),rd=10,ld=1e-4,cm=(()=>{const e=[];for(const t of im)for(const n of t.chains)e.push({code:t.code,name:t.name,chain:n,popular:t.popular});return e})();function od({ticker:e,size:t=32,baseUrl:n=""}){return a.jsx("img",{src:ed(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function Ss({currencyCode:e,size:t=16,baseUrl:n=""}){return a.jsx("img",{src:am(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function id({size:e=32,color:t="#888"}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:[a.jsx("circle",{cx:"16",cy:"16",r:"16",fill:t}),a.jsx("circle",{cx:"16",cy:"16",r:"8",stroke:"white",strokeWidth:"1.5",fill:"none"})]})}function dm({size:e=24}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:[a.jsx("circle",{cx:"16",cy:"16",r:"16",fill:"#0077FF"}),a.jsx("path",{d:"M8 15l8-6 8 6H8z",fill:"white"}),a.jsx("rect",{x:"10",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"15",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"20",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"8",y:"22",width:"16",height:"2",rx:"0.5",fill:"white"})]})}function fm({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center text-white font-semibold shrink-0",style:{width:e,height:e,backgroundColor:"#333",fontSize:e*.45},children:"R"})}function pm({size:e=32}){return a.jsx("div",{className:"rounded-full bg-black border border-white/20 flex items-center justify-center text-white shrink-0",style:{width:e,height:e,fontSize:e*.3},children:a.jsx("span",{style:{fontFamily:"-apple-system, system-ui, sans-serif",fontWeight:600},children:"Pay"})})}function mm({size:e=32}){return a.jsxs("div",{className:"rounded-full bg-white flex items-center justify-center shrink-0",style:{width:e,height:e,fontSize:e*.28,fontWeight:700,color:"#333"},children:["G",a.jsx("span",{style:{color:"#4285F4",fontSize:e*.2},children:"Pay"})]})}function hm({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"#003087"},children:a.jsx("span",{className:"text-white font-bold",style:{fontSize:e*.38},children:"P"})})}function ym({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-card-icon-bg)"},children:a.jsxs("svg",{width:e*.55,height:e*.55,viewBox:"0 0 18 14",fill:"none",children:[a.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"13",rx:"2",stroke:"var(--t-card-icon-stroke)"}),a.jsx("rect",{y:"3",width:"18",height:"3",fill:"var(--t-card-icon-stroke)"})]})})}function Pr(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:a.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"var(--t-text-secondary)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function vm(){return a.jsx("svg",{width:"8",height:"14",viewBox:"0 0 8 14",fill:"none",children:a.jsx("path",{d:"M1 1L7 7L1 13",stroke:"var(--t-icon-stroke)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function gm({onClick:e}){return a.jsx("button",{onClick:e,className:"hover:opacity-70 transition-opacity",children:a.jsx("svg",{width:"24",height:"16",viewBox:"0 0 24 16",fill:"none",children:a.jsx("path",{d:"M22.4004 12V4C22.4004 2.67452 21.3255 1.59961 20 1.59961H6.7998V14.4004H20V16H4V14.4004H5.2002V1.59961H4C2.67452 1.59961 1.59961 2.67452 1.59961 4V12C1.59961 13.3255 2.67452 14.4004 4 14.4004V16L3.79395 15.9951C1.68056 15.8879 0 14.14 0 12V4C0 1.79086 1.79086 6.44266e-08 4 0H20C22.2091 0 24 1.79086 24 4V12L23.9951 12.2061C23.8913 14.2512 22.2512 15.8913 20.2061 15.9951L20 16V14.4004C21.3255 14.4004 22.4004 13.3255 22.4004 12Z",fill:"var(--t-icon-stroke)"})})})}function xm({size:e=40}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-surface)"},children:a.jsxs("svg",{width:e*.5,height:e*.5,viewBox:"0 0 20 20",fill:"none",children:[a.jsx("circle",{cx:"10",cy:"10",r:"7.5",stroke:"var(--t-text)",strokeWidth:"1.5"}),a.jsx("path",{d:"M10 2.5A7.5 7.5 0 0 1 10 17.5",fill:"var(--t-text)"})]})})}function wm(e,t=32){switch(e){case"revolut":return a.jsx(fm,{size:t});case"applepay":return a.jsx(pm,{size:t});case"card":return a.jsx(ym,{size:t});case"googlepay":return a.jsx(mm,{size:t});case"paypal":return a.jsx(hm,{size:t});case"bank":return a.jsx(dm,{size:t});default:return a.jsx(id,{size:t})}}const Sm={"debit-credit-card":"card","bank-transfer":"bank","apple-pay":"applepay","google-pay":"googlepay",paypal:"paypal",revolut:"revolut"},km={"debit-credit-card":"Card","bank-transfer":"Bank Transfer","ach-bank-transfer":"ACH","apple-pay":"Apple Pay","google-pay":"Google Pay","payid-bank-transfer":"PayID",paypal:"PayPal",revolut:"Revolut"};function sd(e,t){return km[e]||t}function ad(e,t,n=24){const r=Sm[e];return r?wm(r,n):t?a.jsx("img",{src:t,alt:"",width:n,height:n,style:{borderRadius:"50%"}}):a.jsx(id,{size:n})}function Em({methods:e,selectedId:t,onOpenModal:n,fiatCurrency:r}){const l=E.useMemo(()=>e.filter(i=>i.supportedFiats.includes(r)),[e,r]),o=l.find(i=>i.id===t)||l[0];return l.length===0?a.jsx("div",{className:"flex items-center justify-between px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderBottomLeftRadius:5,borderBottomRightRadius:5},children:a.jsxs("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:["No payment methods available for ",r]})}):a.jsx(a.Fragment,{children:a.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&n()},className:"flex items-center justify-between w-full px-[18px] transition-colors",style:{background:"var(--t-surface)",borderBottomLeftRadius:5,borderBottomRightRadius:5,cursor:"pointer",height:42},children:[a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:"Payment method"}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"flex items-center justify-center",style:{width:20,height:20},children:o&&ad(o.id,o.icon,20)}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:o?sd(o.id,o.name):"Select"}),a.jsx(Pr,{})]})]})})}function Cm({className:e="",autoRedirect:t=!1,redirectDelay:n=3e3}){var y;const{order:r,orderStatus:l,goToStep:o,goBack:i}=Dn(),[s,u]=E.useState(!1),[c,h]=E.useState(null),m=r!=null&&r.checkout.expiresAt?Date.now()>r.checkout.expiresAt:!1;if(E.useEffect(()=>{if((r==null?void 0:r.checkout.method)==="redirect"&&t&&!m){h(Math.ceil(n/1e3));const x=setTimeout(()=>{window.location.href=r.checkout.url},n),g=setInterval(()=>{h(S=>S&&S>1?S-1:null)},1e3);return()=>{clearTimeout(x),clearInterval(g)}}},[r,t,n,m]),E.useEffect(()=>{l&&(l.status==="completed"?o("complete"):["failed","cancelled","expired"].includes(l.status)&&o("error"))},[l==null?void 0:l.status,o]),!r)return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("p",{className:"text-[15px] mb-4",children:"No order found"}),a.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:i,children:"Go Back"})]});if(m)return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Checkout expired"}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:"The session has expired. Please try again."}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:i,children:"Start over"})]});if(r.checkout.method==="iframe"){const x=r.checkout.url,g=((y=r.checkout.allowedFeatures)==null?void 0:y.join("; "))||"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share";return vs.createPortal(a.jsxs("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",background:"#000"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",height:48,paddingLeft:8,paddingRight:16,background:"#111",flexShrink:0},children:a.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer",padding:"8px 12px",borderRadius:6},children:[a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Cancel"]})}),a.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:[!s&&a.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{style:{color:"#888",fontSize:14,marginTop:16},children:"Loading checkout..."})]}),a.jsx("iframe",{src:x,style:{display:s?"block":"none",width:"100%",height:"100%",border:"none"},allow:g,onLoad:()=>u(!0),title:"Provider Checkout"})]})]}),document.body)}if(r.checkout.method==="redirect")return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("div",{className:"text-[48px] mb-4",children:"🔗"}),a.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Complete Payment"}),a.jsxs("p",{className:"text-[14px] mb-4",style:{color:"var(--t-text-secondary)"},children:["You'll be redirected to ",r.gateway," to complete your payment."]}),c!==null&&a.jsxs("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:["Redirecting in ",c,"..."]}),a.jsxs("a",{href:r.checkout.url,className:"w-full font-semibold text-[16px] flex items-center justify-center transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",textDecoration:"none"},target:"_blank",rel:"noopener noreferrer",children:["Continue to ",r.gateway]}),a.jsx("button",{className:"w-full font-semibold text-[14px] mt-2 transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:i,children:"Cancel"})]});if(r.checkout.method==="widget"&&r.widgetConfig){const x=Nm(r.checkout.url,r.widgetConfig);return vs.createPortal(a.jsxs("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",background:"#000"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",height:48,paddingLeft:8,paddingRight:16,background:"#111",flexShrink:0},children:a.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer",padding:"8px 12px",borderRadius:6},children:[a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Cancel"]})}),a.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:[!s&&a.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{style:{color:"#888",fontSize:14,marginTop:16},children:"Loading checkout..."})]}),a.jsx("iframe",{src:x,style:{display:s?"block":"none",width:"100%",height:"100%",border:"none"},allow:"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>u(!0),title:"Payment Checkout"})]})]}),document.body)}return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("p",{className:"text-[15px] mb-4",children:"Unknown checkout method"}),a.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:i,children:"Go Back"})]})}function Nm(e,t){const n=new URL("/en/partner/widget",e);for(const[r,l]of Object.entries(t))l!=null&&l!==""&&n.searchParams.set(r,String(l));return n.toString()}function Tm({className:e=""}){const{orderStatus:t,orderStatusLoading:n,goToStep:r}=Dn();E.useEffect(()=>{t&&(t.status==="completed"?r("complete"):["failed","cancelled","expired","refunded"].includes(t.status)&&r("error"))},[t==null?void 0:t.status,r]);const l=()=>{if(!t)return"Processing your order...";switch(t.status){case"pending":return"Waiting for payment confirmation...";case"processing":return"Processing your transaction...";default:return"Processing..."}};return a.jsxs("div",{className:`flex flex-col items-center justify-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"mb-6",children:a.jsx("div",{className:"nramp-spinner-large nramp-spinner"})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-3",style:{color:"var(--t-text)"},children:l()}),n&&a.jsx("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:"Checking status..."}),t&&a.jsxs("div",{className:"w-full mt-6 text-left",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsx(Bn,{label:"Order ID",value:t.orderId,mono:!0}),a.jsx(Bn,{label:"Provider",value:t.gateway}),a.jsx(Bn,{label:"Amount",value:`${t.fiatAmount} ${t.fiatCurrency}`}),a.jsx(Bn,{label:"Receiving",value:`${t.cryptoAmount||"..."} ${t.cryptoCurrency}`}),a.jsx(Bn,{label:"Network",value:t.network}),a.jsx(Bn,{label:"To Address",value:`${t.walletAddress.slice(0,10)}...${t.walletAddress.slice(-8)}`,mono:!0})]}),a.jsxs("div",{className:"mt-6",children:[a.jsx("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"This usually takes a few minutes."}),a.jsx("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:"You can safely close this page - we'll send you an email when complete."})]})]})}function Bn({label:e,value:t,mono:n}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:"var(--t-text)"},children:t})]})}function jm({className:e="",explorerUrl:t,onDone:n,doneButtonText:r="Done"}){const{orderStatus:l,state:o,dispatch:i}=Dn(),s=o.flowType==="sell",u=()=>{if(!(l!=null&&l.transactionHash))return null;if(!t){const m={ethereum:"https://etherscan.io/tx/{txHash}",polygon:"https://polygonscan.com/tx/{txHash}",arbitrum:"https://arbiscan.io/tx/{txHash}",optimism:"https://optimistic.etherscan.io/tx/{txHash}",base:"https://basescan.org/tx/{txHash}",bitcoin:"https://mempool.space/tx/{txHash}",solana:"https://solscan.io/tx/{txHash}",avalanche:"https://snowtrace.io/tx/{txHash}",fantom:"https://ftmscan.com/tx/{txHash}"};return(m[o.network]||m.ethereum).replace("{txHash}",l.transactionHash)}return t.replace("{txHash}",l.transactionHash)},c=()=>{n?n():i({type:"RESET"})},h=u();return a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-success, #10b981)"},children:a.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:a.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:s?"Sale Complete!":"Purchase Complete!"}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:s?`Your ${(l==null?void 0:l.fiatCurrency)||o.fiatCurrency} payout is being processed.`:`Your ${(l==null?void 0:l.cryptoCurrency)||o.cryptoCurrency} has been sent to your wallet.`}),l&&a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsx(Ut,{label:s?"Amount Sold":"Amount Received",value:`${l.cryptoAmount} ${l.cryptoCurrency}`,highlight:!0}),a.jsx(Ut,{label:s?"Payout Amount":"Amount Paid",value:`${l.fiatAmount} ${l.fiatCurrency}`}),a.jsx(Ut,{label:"Network",value:l.network}),a.jsx(Ut,{label:"Wallet",value:`${l.walletAddress.slice(0,10)}...${l.walletAddress.slice(-8)}`,mono:!0}),l.transactionHash&&a.jsx(Ut,{label:"Transaction",value:`${l.transactionHash.slice(0,10)}...${l.transactionHash.slice(-8)}`,mono:!0}),a.jsx(Ut,{label:"Provider",value:l.gateway}),a.jsx(Ut,{label:"Order ID",value:l.orderId,mono:!0}),l.completedAt&&a.jsx(Ut,{label:"Completed",value:new Date(l.completedAt).toLocaleString()})]}),a.jsxs("div",{className:"w-full flex flex-col gap-2",children:[h&&a.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"w-full font-semibold text-[14px] flex items-center justify-center transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",textDecoration:"none"},children:"View on Explorer"}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:c,children:r})]})]})}function Ut({label:e,value:t,mono:n,highlight:r}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function Rm({className:e="",onRetry:t,supportEmail:n="support@nowramp.com"}){const{state:r,orderStatus:l,dispatch:o,goToStep:i}=Dn(),s=r.flowType==="sell",u=()=>{if(l)switch(l.status){case"failed":return"Payment Failed";case"cancelled":return"Order Cancelled";case"expired":return"Order Expired";case"refunded":return"Order Refunded";default:return"Something Went Wrong"}return"Something Went Wrong"},c=()=>{if(r.errorMessage)return r.errorMessage;if(l)switch(l.status){case"failed":return s?"Your sale could not be processed. Please try again.":"Your payment could not be processed. Please try again or use a different payment method.";case"cancelled":return s?"Your sale was cancelled. No crypto was transferred.":"Your order was cancelled. No payment was processed.";case"expired":return s?"Your order has expired. Please start a new sale.":"Your order has expired. Please start a new purchase.";case"refunded":return s?"Your crypto has been returned. The funds should appear in your wallet shortly.":"Your payment has been refunded. The funds should appear in your account within 5-10 business days.";default:return"An unexpected error occurred. Please try again."}return"An unexpected error occurred. Please try again."},h=()=>{o({type:"CLEAR_ERROR"}),t?t():(o({type:"RESET"}),i("amount"))},m=()=>{o({type:"RESET"}),i("amount")};return a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-error, #EF4444)"},children:a.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:a.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:u()}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:c()}),l&&a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Order ID"}),a.jsx("span",{className:"text-[13px] font-medium font-mono",style:{color:"var(--t-text)"},children:l.orderId})]}),a.jsxs("div",{className:"flex justify-between items-center py-2",children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Status"}),a.jsx("span",{className:"text-[12px] font-medium px-2 py-0.5",style:{background:"rgba(239,68,68,0.15)",color:"#EF4444",borderRadius:4},children:l.gatewayStatus})]})]}),a.jsxs("div",{className:"w-full flex flex-col gap-2",children:[a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:h,children:"Try Again"}),a.jsx("button",{className:"w-full font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:m,children:"Start Over"})]}),a.jsxs("div",{className:"mt-6",children:[a.jsxs("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:["Need help? Contact"," ",a.jsx("a",{href:`mailto:${n}`,className:"underline",style:{color:"var(--t-accent)"},children:n})]}),l&&a.jsxs("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:["Reference: ",l.orderId]})]})]})}function ud(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-6)}`}function Am({className:e=""}){const{config:t,configLoading:n,state:r,defaultGateway:l,fetchQuotes:o,createOrder:i,orderLoading:s}=Dn(),u=r.flowType==="sell",[c,h]=E.useState(null),m=t==null?void 0:t.gateways.find(x=>x.id===l),y=async()=>{h(null);try{o(),await i()}catch(x){const g=x instanceof Error?x.message:"Failed to create order";h(g)}};return n?a.jsxs("div",{className:`flex flex-col items-center justify-center p-12 ${e}`,children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading..."})]}):a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 ${e}`,children:[a.jsx("h2",{className:"text-[20px] font-semibold mb-6",style:{color:"var(--t-text)"},children:u?"Confirm Sale":"Confirm Purchase"}),a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[m&&a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Provider"}),a.jsxs("span",{className:"flex items-center gap-2",children:[m.logo&&a.jsx("img",{src:m.logo,alt:m.name,width:20,height:20,style:{borderRadius:4}}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:m.name})]})]}),u?a.jsxs(a.Fragment,{children:[a.jsx(nn,{label:"You sell",value:`${r.cryptoAmount} ${r.cryptoCurrency}`,highlight:!0}),a.jsx(nn,{label:"You receive",value:`${r.fiatCurrency} payout`})]}):a.jsxs(a.Fragment,{children:[a.jsx(nn,{label:"You pay",value:`${r.fiatAmount} ${r.fiatCurrency}`,highlight:!0}),a.jsx(nn,{label:"You receive",value:`${r.cryptoCurrency} on ${r.network}`}),a.jsx(nn,{label:"Wallet",value:ud(r.walletAddress),mono:!0})]}),a.jsx(nn,{label:"Network",value:r.network}),u&&r.walletAddress&&a.jsx(nn,{label:"Refund address",value:ud(r.walletAddress),mono:!0})]}),c&&a.jsx("p",{className:"text-[12px] mb-4",style:{color:"#EF4444"},children:c}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all flex items-center justify-center gap-2",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:s?.7:1},disabled:s,onClick:y,children:s?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"nramp-spinner-inline"}),"Processing..."]}):u?"Confirm & Sell":"Confirm & Pay"})]})}function nn({label:e,value:t,mono:n,highlight:r}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function Jl({isOpen:e,onClose:t,children:n}){const[r,l]=E.useState(!1),[o,i]=E.useState(!1);E.useEffect(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else if(r){i(!1);const u=setTimeout(()=>l(!1),250);return()=>clearTimeout(u)}},[e]);const s=E.useCallback(()=>{i(!1),setTimeout(()=>t(),250)},[t]);return E.useEffect(()=>{if(!e)return;const u=c=>{c.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),r?a.jsx("div",{className:"absolute inset-0 z-20 transition-opacity duration-250",style:{opacity:o?1:0},children:a.jsx("div",{className:"absolute inset-0 flex flex-col transition-transform duration-250 ease-out",style:{background:"var(--t-modal-bg)",transform:o?"translateY(0)":"translateY(24px)"},children:typeof n=="function"?n(s):n})}):null}function Pm({char:e,height:t=38}){const n="0123456789",r=n.indexOf(e);return r===-1?a.jsx("span",{children:e}):a.jsx("span",{className:"digit-slot",style:{height:t,lineHeight:`${t}px`},children:a.jsx("span",{className:"digit-slot-inner block",style:{transform:`translateY(-${r*t}px)`},children:n.split("").map(l=>a.jsx("span",{className:"block",style:{height:t,lineHeight:`${t}px`},children:l},l))})})}function Lm({value:e,height:t=38,className:n="",style:r={}}){return a.jsx("span",{className:n,style:{display:"inline-flex",...r},children:e.split("").map((l,o)=>a.jsx(Pm,{char:l,height:t},o))})}function Ve({w:e,h:t,className:n=""}){return a.jsx("div",{className:`skeleton ${n}`,style:{width:e,height:t}})}function Im(){return a.jsxs("div",{className:"flex-1 px-5 flex flex-col",children:[a.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5},children:[a.jsx(Ve,{w:70,h:14,className:"mb-3"}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx(Ve,{w:120,h:32}),a.jsx(Ve,{w:75,h:32})]})]}),a.jsxs("div",{className:"px-[18px] pt-[12px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,marginTop:4},children:[a.jsx(Ve,{w:50,h:14,className:"mb-3"}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx(Ve,{w:180,h:32}),a.jsx(Ve,{w:85,h:32})]})]}),a.jsxs("div",{className:"flex justify-between mt-3 px-[2px]",children:[a.jsx(Ve,{w:140,h:12}),a.jsx(Ve,{w:90,h:12})]}),a.jsxs("div",{className:"mt-8",children:[a.jsx(Ve,{w:65,h:14,className:"mb-2.5"}),a.jsx(Ve,{w:"100%",h:47})]}),a.jsx("div",{className:"flex-1"}),a.jsx(Ve,{w:"100%",h:60,className:"mb-2"}),a.jsx("div",{className:"text-center py-3",children:a.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]})}function ql({onClick:e}){return a.jsx("button",{onClick:e,className:"flex items-center justify-center transition-colors rounded-full shrink-0",style:{width:30,height:30,backgroundColor:"var(--t-close-bg)"},onMouseEnter:t=>t.currentTarget.style.backgroundColor="var(--t-close-hover)",onMouseLeave:t=>t.currentTarget.style.backgroundColor="var(--t-close-bg)",children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:a.jsx("path",{d:"M1 1L9 9M9 1L1 9",stroke:"var(--t-icon-close)",strokeWidth:"1.4",strokeLinecap:"round"})})})}function ks({value:e,onChange:t,placeholder:n=""}){return a.jsxs("div",{className:"relative mx-5 mb-5",children:[a.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,style:{height:47,borderRadius:4.5,border:"1px solid var(--t-border)",color:"var(--t-text)",padding:`0 ${e?40:14}px 0 14px`,fontSize:14,backgroundColor:"transparent"},className:"w-full outline-none transition-colors"}),e&&a.jsx("button",{onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center transition-colors rounded",style:{width:22,height:22,backgroundColor:"var(--t-close-bg)",borderRadius:4},children:a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:a.jsx("path",{d:"M1 1L7 7M7 1L1 7",stroke:"var(--t-icon-close)",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}function Mm({onClose:e,onSelect:t,currencies:n,assetBaseUrl:r=""}){const[l,o]=E.useState(""),i=E.useMemo(()=>{if(!n||n.length===0)return td;const u=new Map(td.map(c=>[c.code,c.name]));return n.map(c=>({code:c.code,name:c.name||u.get(c.code)||c.code}))},[n]),s=E.useMemo(()=>{const u=l.trim().toLowerCase();return u?i.filter(c=>c.code.toLowerCase().includes(u)||c.name.toLowerCase().includes(u)):i},[i,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Select fiat currency"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(u=>a.jsxs("button",{onClick:()=>t(u.code),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",style:{color:"var(--t-text)"},children:[a.jsx(Ss,{currencyCode:u.code,size:32,baseUrl:r}),a.jsxs("div",{className:"text-left",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",children:u.code}),a.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:u.name})]})]},u.code)),s.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function _m({onClose:e,onSelect:t,cryptos:n,assetBaseUrl:r=""}){const[l,o]=E.useState(""),i=E.useMemo(()=>{if(!n||n.length===0)return cm;const u=[];for(const c of n){const h=c.networks||[];if(h.length===0)u.push({code:c.code,name:c.name||c.code,chain:c.code,popular:!1});else for(const m of h){const y=m.code||m.id||m.name||c.code;u.push({code:c.code,name:c.name||c.code,chain:y,chainName:m.name,popular:!1})}}return u},[n]),s=E.useMemo(()=>{var m;const u=l.trim().toLowerCase();if(!u)return i;const c=u.split(/\s+/),h=[];for(const y of i){const x=Zl(y.chain),g=x?x.name.toLowerCase():"",S=((m=x==null?void 0:x.shortName)==null?void 0:m.toLowerCase())||"",L=y.chain.toLowerCase(),f=y.code.toLowerCase(),d=y.name.toLowerCase(),p=[f,d,g,S,L];if(!c.every(R=>p.some(v=>v.includes(R))))continue;let C=0;f===u?C+=100:f.startsWith(c[0])&&(C+=50),y.popular&&(C+=10),c.length>1&&(g.includes(c[1])||S.includes(c[1])||L.includes(c[1]))&&(C+=25),h.push({item:y,score:C})}return h.sort((y,x)=>x.score-y.score),h.map(y=>y.item)},[i,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Select crypto currency"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(u=>{const c=Zl(u.chain),h=(c==null?void 0:c.name)||u.chainName||u.chain;return a.jsxs("button",{onClick:()=>t(u.code,u.chain),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",children:[a.jsxs("div",{className:"relative shrink-0",style:{width:40,height:40},children:[a.jsx("img",{src:ed(u.code,r),alt:u.code,width:32,height:32,className:"rounded-full absolute top-0 left-0",style:{width:32,height:32}}),a.jsx("img",{src:xs(u.chain,r),alt:u.chain,width:16,height:16,className:"rounded-full absolute",style:{width:16,height:16,bottom:0,right:0,border:"2px solid var(--t-chain-border)"}})]}),a.jsxs("div",{className:"text-left flex-1 min-w-0",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:"var(--t-text)"},children:u.code}),a.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:u.name})]}),a.jsx("div",{className:"text-right shrink-0",children:a.jsx("div",{className:"text-[13px]",style:{color:"var(--t-text-muted)"},children:h})})]},`${u.code}-${u.chain}`)}),s.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function Om({methods:e,selectedId:t,onSelect:n,onClose:r}){const[l,o]=E.useState(""),i=E.useMemo(()=>{const s=l.trim().toLowerCase();return s?e.filter(u=>u.id.toLowerCase().includes(s)||u.name.toLowerCase().includes(s)||u.description&&u.description.toLowerCase().includes(s)):e},[e,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:r})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Choose payment method"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[i.map((s,u)=>{const c=s.id===t,h=sd(s.id,s.name);return a.jsxs("button",{onClick:()=>n(s.id),className:"flex items-start gap-3.5 w-full py-4 transition-colors",style:{color:"var(--t-text)",borderBottom:u<i.length-1?"1px solid var(--t-divider, rgba(128,128,128,0.12))":"none"},children:[a.jsx("span",{className:"flex items-center justify-center shrink-0 mt-0.5",style:{width:32,height:32},children:ad(s.id,s.icon,32)}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:c?"var(--t-accent)":"var(--t-text)"},children:h}),s.description&&a.jsx("div",{className:"text-[13px] leading-snug mt-1",style:{color:"var(--t-text-muted)"},children:s.description})]})]},s.id)}),i.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No payment methods found"})]})]})}function Dm({checked:e,onChange:t,accentColor:n="var(--t-accent)"}){return a.jsx("button",{onClick:()=>t(!e),className:"relative shrink-0 transition-colors duration-200",style:{width:48,height:28,borderRadius:14,backgroundColor:e?n:"var(--t-border)"},children:a.jsx("div",{className:"absolute top-[3px] rounded-full bg-white shadow transition-transform duration-200",style:{width:22,height:22,transform:e?"translateX(23px)":"translateX(3px)"}})})}const Bm=[{label:"Privacy policy",href:"https://nowramp.com/privacy-policy"},{label:"Terms of use",href:"https://nowramp.com/terms-and-conditions"}];function Fm({onClose:e,darkMode:t,onToggleDarkMode:n,skinId:r,onSelectSkin:l}){return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end items-center px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsxs("div",{className:"px-5 flex-1 pt-6 overflow-y-auto custom-scroll",children:[a.jsx("div",{style:{borderTop:"1px solid var(--t-divider)"},children:a.jsxs("div",{className:"flex items-center justify-between w-full py-5",children:[a.jsxs("div",{className:"flex items-center gap-3.5",children:[a.jsx(xm,{size:40}),a.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:"Dark Mode"})]}),a.jsx(Dm,{checked:t,onChange:n,accentColor:"#4CD964"})]})}),a.jsx("div",{style:{height:1,background:"var(--t-divider)"}}),Bm.map(o=>a.jsxs("div",{children:[a.jsxs("a",{href:o.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between w-full py-5 transition-colors",style:{color:"inherit",textDecoration:"none"},children:[a.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:o.label}),a.jsx(vm,{})]}),a.jsx("div",{style:{height:1,background:"var(--t-divider)"}})]},o.label))]})]})}function Um({className:e="",theme:t="dark",skinId:n="mono",accentColor:r,bgColor:l,bgImage:o,borderColor:i,borderRadius:s,showFlowToggle:u=!0,autoRedirect:c=!1,explorerUrl:h,doneButtonText:m="Done",supportEmail:y,onDone:x}){var xd,wd,Sd,kd,Ed,Cd,Nd,Td;const{state:g,dispatch:S,config:L,configLoading:f,quotes:d,quotesLoading:p,quotesError:w,fetchQuotes:C,createOrder:R,orderLoading:v,amountError:T,fieldLocks:P,apiConfig:A,assetBaseUrl:G}=Dn(),[fe,pe]=E.useState(t==="dark"),[rn,ln]=E.useState(n),[lt,ge]=E.useState(null),[N,I]=E.useState(!1),[M,H]=E.useState(!1),[W,ht]=E.useState(!1),[ae,qe]=E.useState(null),[Ce,yt]=E.useState(!0),[bl,eo]=E.useState(!1),[Ht,Fn]=E.useState(!1),Es=E.useRef(null),Ir=E.useRef(),D=E.useRef(g.flowType);E.useEffect(()=>{pe(t==="dark")},[t]),E.useEffect(()=>{const _=setTimeout(()=>yt(!1),f?0:800);return()=>clearTimeout(_)},[f]),E.useEffect(()=>{if(D.current!==g.flowType&&!Ce){D.current=g.flowType,eo(!0),I(!1),H(!1);const _=setTimeout(()=>eo(!1),350);return()=>clearTimeout(_)}D.current=g.flowType},[g.flowType,Ce]);const z=g.flowType,ee=z==="buy",Z=g.cryptoCurrency||"BTC",Q=g.fiatCurrency||"USD",Pe=ee?g.fiatAmount:g.cryptoAmount,Le=um(Pe),vt=(xd=d==null?void 0:d.bestQuote)!=null&&xd.exchangeRate?parseFloat(d.bestQuote.exchangeRate):null,to=E.useRef(null);vt&&Z&&Q&&(to.current={rate:vt,crypto:Z,fiat:Q});const $m=E.useMemo(()=>{if(d!=null&&d.bestQuote){const _=ee?d.bestQuote.cryptoAmount:d.bestQuote.fiatAmount;if(_)return _}return"0"},[d,ee]),Km=E.useMemo(()=>{var xe,zt,Ts;const _=vt||((xe=to.current)==null?void 0:xe.rate),F=vt?Z:(zt=to.current)==null?void 0:zt.crypto,X=vt?Q:(Ts=to.current)==null?void 0:Ts.fiat;return!_||!F||!X?"":`1 ${F} ≈ ${_.toFixed(2)} ${X}`},[Z,Q,vt]);E.useEffect(()=>{const _=g.walletAddress.trim(),F=g.network;if(!_||_.length<10){qe(null),S({type:"SET_WALLET_ERROR",message:""});return}return ht(!0),qe(null),clearTimeout(Ir.current),Ir.current=setTimeout(async()=>{var X,xe,zt;try{const js=await(await fetch(`${A.apiUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:_,...F?{network:F}:{}})})).json(),Rs=((X=js.data)==null?void 0:X.attributes)||js.data||js;if(Rs.isValid)qe(!0),S({type:"SET_WALLET_ERROR",message:""});else{qe(!1);const Jm=((xe=Rs.errors)==null?void 0:xe[0])||((zt=Rs.details)==null?void 0:zt.formatMessage)||"Invalid wallet address";S({type:"SET_WALLET_ERROR",message:Jm})}}catch{qe(null)}finally{ht(!1)}},500),()=>clearTimeout(Ir.current)},[g.walletAddress,g.network,A.apiUrl]);const dd=!Pe||Le===0,fd=Le>0&&(ee?Le<rd:Le<ld),pd=!!T||fd||N&&dd,Vm=Le>0&&!T&&!fd,Cs=g.walletAddress.trim().length>=10&&ae!==!1&&!W,no=Vm&&Cs&&!!g.cryptoCurrency&&!!g.network,Wm=_=>{let F=_.target.value.replace(/[^0-9.,]/g,"");const X=ee?2:6,xe=F.indexOf(".");xe!==-1&&F.length-xe-1>X&&(F=F.slice(0,xe+X+1)),S(ee?{type:"SET_FIAT_AMOUNT",amount:F}:{type:"SET_CRYPTO_AMOUNT",amount:F})},md=_=>{_!==z&&S({type:"SET_FLOW_TYPE",flowType:_})},Qm=E.useCallback(_=>{S({type:"SET_FIAT_CURRENCY",currency:_})},[S]),Xm=E.useCallback((_,F)=>{S({type:"SET_CRYPTO_CURRENCY",currency:_}),S({type:"SET_CRYPTO_CHAIN",chain:F})},[S]),Ym=E.useCallback(_=>{S({type:"SET_PAYMENT_METHOD",methodId:_})},[S]),Gm=()=>{no&&(Fn(!0),C())};E.useEffect(()=>{var _;if(!(!Ht||p)){if(d!=null&&d.bestQuote)Fn(!1),S({type:"SELECT_QUOTE",quote:d.bestQuote}),R().catch(()=>{});else if(w)Fn(!1),S({type:"SET_ERROR",message:w.message||"No quotes available"});else if(d&&!d.bestQuote){Fn(!1);const F=(_=d.unavailableGateways)==null?void 0:_.map(xe=>xe.reason).filter(Boolean),X=F!=null&&F.length?`No providers available: ${F.join("; ")}`:"No providers available for this currency/network combination";S({type:"SET_ERROR",message:X})}}},[Ht,d,p,w,S,R]);const hd=fe?"theme-dark":"theme-light",Ns=nd.find(_=>_.id===rn)||nd[0],Zm=Ns.accent===null,yd=(r?ws(r):!1)?{"--t-accent":r,"--t-cta-bg":r,"--t-cta-text":"#ffffff"}:Zm?{"--t-accent":fe?"#ffffff":"#111111","--t-cta-bg":fe?"#ffffff":"#111111","--t-cta-text":fe?"#000000":"#ffffff"}:{"--t-accent":Ns.accent,"--t-cta-bg":Ns.accent,"--t-cta-text":"#ffffff"},on={};l&&ws(l)?on.backgroundColor=l:on.backgroundColor="var(--t-bg)",o&&(on.backgroundImage=`url(${o})`,on.backgroundSize="cover",on.backgroundPosition="center");const ro={};i&&ws(i)&&(ro.border=`1px solid ${i}`),s&&(ro.borderRadius=s);const vd=g.step==="checkout"?a.jsx(Cm,{autoRedirect:c}):g.step==="processing"?a.jsx(Tm,{}):g.step==="complete"?a.jsx(jm,{explorerUrl:h,doneButtonText:m,onDone:x}):g.step==="error"?a.jsx(Rm,{supportEmail:y}):g.step==="confirm"?a.jsx(Am,{}):null;if(vd)return a.jsx("div",{className:`${hd} relative w-full max-w-[390px] h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...on,...yd,...ro},children:vd});const gt=g.network,Un=gt?Zl(gt):null,gd=(Un==null?void 0:Un.shortName)||(Un==null?void 0:Un.name)||gt;return a.jsxs("div",{className:`${hd} relative w-full max-w-[390px] min-h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...on,...yd,...ro},children:[a.jsx("div",{className:`flex justify-end items-center px-5 pt-3 ${u?"pb-1":"pb-5"}`,children:a.jsx(gm,{onClick:()=>ge("settings")})}),u?a.jsxs("div",{className:"flex flex-col items-center pt-3 pb-5",children:[a.jsxs("div",{className:"flex",style:{width:165},children:[a.jsx("button",{onClick:()=>md("buy"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:z==="buy"?"var(--t-text)":"var(--t-text-secondary)"},children:"Buy"}),a.jsx("button",{onClick:()=>md("sell"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:z==="sell"?"var(--t-text)":"var(--t-text-secondary)"},children:"Sell"})]}),a.jsxs("div",{className:"relative",style:{width:165,height:1},children:[a.jsx("div",{className:"absolute inset-0",style:{background:"var(--t-divider)"}}),a.jsx("div",{className:"absolute top-0 h-full transition-all duration-300 ease-in-out",style:{width:"50%",left:z==="buy"?"0%":"50%",background:"var(--t-accent)"}})]})]}):null,Ce||bl||f?a.jsx(Im,{}):a.jsxs("div",{className:"flex-1 overflow-hidden px-5 flex flex-col tab-fade-in",children:[a.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,border:N&&pd?"1px solid #EF4444":"1px solid transparent",minHeight:102},children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You spend"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("input",{ref:Es,type:"text",value:Pe,onChange:Wm,onBlur:()=>I(!0),placeholder:ee?"250":"0.01",className:"bg-transparent outline-none w-0 flex-1 mr-3",style:{color:"var(--t-text)",fontSize:24,fontWeight:600,lineHeight:"32px",padding:0,border:"none",borderRadius:0,backgroundColor:"transparent",height:"auto",width:0},inputMode:"decimal",disabled:!!((wd=P==null?void 0:P.sourceAmount)!=null&&wd.locked)}),ee?a.jsxs("button",{onClick:()=>ge("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Sd=P==null?void 0:P.sourceCurrency)!=null&&Sd.locked),children:[a.jsx(Ss,{currencyCode:Q,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Q}),a.jsx(Pr,{})]}):a.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[a.jsxs("button",{onClick:()=>ge("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((kd=P==null?void 0:P.destinationCurrency)!=null&&kd.locked),children:[a.jsx(od,{ticker:Z,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Z}),a.jsx(Pr,{})]}),gt&&a.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[a.jsx("img",{src:xs(gt,G),alt:gt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:gd})]})]})]})]}),N&&pd&&a.jsx("div",{className:"text-[12px] mt-1.5 px-[2px]",style:{color:"#EF4444"},children:T||(dd?"Amount should be more than 0":ee?`Minimum amount is ${rd} ${Q}`:`Minimum amount is ${ld} ${Z}`)}),a.jsxs("div",{className:"px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderTopLeftRadius:5,borderTopRightRadius:5,borderBottomLeftRadius:0,borderBottomRightRadius:0,marginTop:4,minHeight:102},children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You get"}),a.jsxs("div",{className:"flex items-start justify-between",children:[p?a.jsx(Ve,{w:180,h:32}):a.jsx(Lm,{value:Le>0?$m:"0",height:32,className:"font-semibold",style:{color:Le>0?"var(--t-text)":"var(--t-text-muted)",fontSize:24}}),ee?a.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[a.jsxs("button",{onClick:()=>ge("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Ed=P==null?void 0:P.destinationCurrency)!=null&&Ed.locked),children:[a.jsx(od,{ticker:Z,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Z}),a.jsx(Pr,{})]}),gt&&a.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[a.jsx("img",{src:xs(gt,G),alt:gt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:gd})]})]}):a.jsxs("button",{onClick:()=>ge("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Cd=P==null?void 0:P.sourceCurrency)!=null&&Cd.locked),children:[a.jsx(Ss,{currencyCode:Q,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Q}),a.jsx(Pr,{})]})]})]}),a.jsx("div",{className:"flex items-center justify-between mt-[2px] px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",...(Nd=L==null?void 0:L.paymentMethods)!=null&&Nd.length?{}:{borderBottomLeftRadius:5,borderBottomRightRadius:5}},children:a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:Km||" "})}),(L==null?void 0:L.paymentMethods)&&L.paymentMethods.length>0&&a.jsx("div",{className:"mt-[2px]",children:a.jsx(Em,{methods:L.paymentMethods,selectedId:g.paymentMethodId,onOpenModal:()=>ge("payment"),fiatCurrency:g.fiatCurrency})}),a.jsxs("div",{className:"mt-8",children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:ee?"Receiving wallet address":"Sending wallet address"}),a.jsx("input",{type:"text",value:g.walletAddress,onChange:_=>S({type:"SET_WALLET_ADDRESS",address:_.target.value}),onBlur:()=>H(!0),placeholder:ee?"Enter your receiving address":"Enter your sending address",spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-[13px] outline-none transition-colors",style:{border:g.walletError||M&&!Cs?"1px solid #EF4444":"1px solid var(--t-border)",borderRadius:3.5,height:47,padding:"0 14px",color:"var(--t-text)",fontSize:13,backgroundColor:"transparent"},disabled:!!((Td=P==null?void 0:P.destinationAddress)!=null&&Td.locked)}),g.walletError?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:g.walletError}):M&&!Cs&&!W?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:"Enter a valid wallet address"}):W&&g.walletAddress.trim().length>=10?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"var(--t-text-muted)"},children:"Validating address..."}):null]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{disabled:!no||v||Ht,onClick:Gm,className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:no&&!v&&!Ht?1:.4,cursor:no&&!v&&!Ht?"pointer":"not-allowed"},children:Ht?"Getting best price...":v?"Processing...":ee?`Buy ${Z}`:`Sell ${Z}`}),a.jsx("div",{className:"text-center py-3",children:a.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]},z),a.jsx(Jl,{isOpen:lt==="fiat",onClose:()=>ge(null),children:_=>{var F;return a.jsx(Mm,{onClose:_,onSelect:X=>{Qm(X),_()},currencies:(F=L==null?void 0:L.fiats)==null?void 0:F.map(X=>({code:X.code,name:X.code})),assetBaseUrl:G})}}),a.jsx(Jl,{isOpen:lt==="crypto",onClose:()=>ge(null),children:_=>{var F;return a.jsx(_m,{onClose:_,onSelect:(X,xe)=>{Xm(X,xe),_()},cryptos:(F=L==null?void 0:L.cryptos)==null?void 0:F.map(X=>{var xe;return{code:X.code,name:X.code,networks:(xe=X.networks)==null?void 0:xe.map(zt=>({code:zt.id,name:zt.name}))}}),assetBaseUrl:G})}}),a.jsx(Jl,{isOpen:lt==="payment",onClose:()=>ge(null),children:_=>{var F;return a.jsx(Om,{methods:((F=L==null?void 0:L.paymentMethods)==null?void 0:F.filter(X=>X.supportedFiats.includes(g.fiatCurrency)))||[],selectedId:g.paymentMethodId,onSelect:X=>{Ym(X),_()},onClose:_})}}),a.jsx(Jl,{isOpen:lt==="settings",onClose:()=>ge(null),children:_=>a.jsx(Fm,{onClose:_,darkMode:fe,onToggleDarkMode:pe,skinId:rn,onSelectSkin:F=>{ln(F)}})})]})}function cd({projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:u,defaultCryptoAmount:c,defaultWalletAddress:h,defaultGateway:m,fieldLocks:y,statusPollInterval:x,onComplete:g,onError:S,className:L,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:R,borderRadius:v,showFlowToggle:T,autoRedirect:P,explorerUrl:A,doneButtonText:G,supportEmail:fe,onDone:pe}){return a.jsx(om,{projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:u,defaultCryptoAmount:c,defaultWalletAddress:h,defaultGateway:m,fieldLocks:y,statusPollInterval:x,onComplete:g,onError:S,children:a.jsx(Um,{className:L,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:R,borderRadius:v,showFlowToggle:T,autoRedirect:P,explorerUrl:A,doneButtonText:G,supportEmail:fe,onDone:pe})})}const Lr=new Map;function Hm(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){console.error(`[NowRampForm] Element not found: ${e}`);return}const r=Lr.get(n);r&&(r.unmount(),Lr.delete(n));const l=Xc(n);Lr.set(n,l),l.render(zn.createElement(cd,t))}function zm(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)return;const n=Lr.get(t);n&&(n.unmount(),Lr.delete(t))}Mr.RampForm=cd,Mr.mount=Hm,Mr.unmount=zm,Object.defineProperty(Mr,Symbol.toStringTag,{value:"Module"})})(this.NowRampForm=this.NowRampForm||{});
54
+ */class Gl{constructor(t){this.config=t,this.baseUrl=t.apiUrl||"https://api.nowramp.com"}async getRate(t){var o,i,s,u,c,h;if(!this.config.apiKey)return this.getPublicRate(t);const n=await fetch(`${this.baseUrl}/v1/rates/convert`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),y=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${y}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.rate,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationAmount:l.destinationAmount,destinationCurrency:l.destinationCurrency,fees:{processingFee:((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:((u=l.fees)==null?void 0:u.processingFeePercent)||0,networkFee:((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:((h=l.fees)==null?void 0:h.totalFee)||0},provider:l.provider||"unknown",expiresAt:l.expiresAt}}async getPublicRate(t){var o,i,s,u,c,h;const n=await fetch(`${this.baseUrl}/public/wert/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:t.from,to:t.to,amount:t.amount,flowType:t.flowType||"buy"})});if(!n.ok){const m=await n.json().catch(()=>({})),y=((o=m.error)==null?void 0:o.message)||m.message||`HTTP ${n.status}`;throw new Error(`Failed to get rate: ${y}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{rate:l.ticker||l.rate,sourceAmount:l.currencyAmount||l.sourceAmount||t.amount,sourceCurrency:t.from,destinationAmount:l.commodityAmount||l.destinationAmount,destinationCurrency:t.to,fees:{processingFee:l.feeAmount||((s=l.fees)==null?void 0:s.processingFee)||0,processingFeePercent:l.feePercent||((u=l.fees)==null?void 0:u.processingFeePercent)||0,networkFee:l.currencyMinerFee||((c=l.fees)==null?void 0:c.networkFee)||0,totalFee:(l.feeAmount||0)+(l.currencyMinerFee||0)||((h=l.fees)==null?void 0:h.totalFee)||0},provider:"wert",expiresAt:l.expiresAt}}async getCurrencies(){var l,o;if(!this.config.apiKey)return this.getPublicCurrencies();const t=await fetch(`${this.baseUrl}/v1/rates/currencies`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async getPublicCurrencies(){var l,o;if(!this.config.projectId)throw new Error("projectId is required to fetch currencies without an API key");const t=await fetch(`${this.baseUrl}/public/projects/${this.config.projectId}/currencies`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const i=await t.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${t.status}`;throw new Error(`Failed to get currencies: ${s}`)}const n=await t.json(),r=((o=n.data)==null?void 0:o.attributes)||n.data||n;return{fiat:r.fiat||[],crypto:r.crypto||[],provider:r.provider||"unknown",environment:r.environment||"sandbox"}}async validateAddress(t){var l,o;const n=await fetch(`${this.baseUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate address: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async validateAddressBatch(t){var l,o;if(t.length>20)throw new Error("Maximum 20 addresses per batch");const n=await fetch(`${this.baseUrl}/public/validate/address/batch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addresses:t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to validate addresses: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getSupportedNetworks(){var r,l;const t=await fetch(`${this.baseUrl}/public/validate/networks`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok){const o=await t.json().catch(()=>({})),i=((r=o.error)==null?void 0:r.message)||o.message||`HTTP ${t.status}`;throw new Error(`Failed to get supported networks: ${i}`)}const n=await t.json();return((l=n.data)==null?void 0:l.attributes)||n.data||n}async createSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to create sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify(t)});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to create session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,clientSecret:l.clientSecret,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,expiresAt:l.expiresAt,createdAt:l.createdAt}}async getSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to get session details.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to get session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"pending",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,fieldLocks:l.fieldLocks,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async cancelSession(t){var o,i,s;if(!this.config.apiKey)throw new Error("API key is required to cancel sessions. Use a secret key (sk_) for this operation.");const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!n.ok){const u=await n.json().catch(()=>({})),c=((o=u.error)==null?void 0:o.message)||u.message||`HTTP ${n.status}`;throw new Error(`Failed to cancel session: ${c}`)}const r=await n.json(),l=((i=r.data)==null?void 0:i.attributes)||r.data||r;return{sessionId:((s=r.data)==null?void 0:s.id)||l.sessionId,type:l.type||"onramp",status:l.status||"cancelled",customerId:l.customerId,externalCustomerId:l.externalCustomerId,sourceAmount:l.sourceAmount,sourceCurrency:l.sourceCurrency,destinationCurrency:l.destinationCurrency,destinationAddress:l.destinationAddress,network:l.network,redirectUrl:l.redirectUrl,metadata:l.metadata,orderId:l.orderId,expiresAt:l.expiresAt,confirmedAt:l.confirmedAt,completedAt:l.completedAt,createdAt:l.createdAt}}async getSupported(t){var i,s;if(!this.config.projectId)throw new Error("projectId is required to get supported config");const n=typeof t=="string"?{orderType:t}:t,r=new URLSearchParams({projectId:this.config.projectId});n!=null&&n.orderType&&r.set("orderType",n.orderType),n!=null&&n.country&&r.set("country",n.country);const l=await fetch(`${this.baseUrl}/public/v1/onramp/supported?${r}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!l.ok){const u=await l.json().catch(()=>({})),c=((i=u.error)==null?void 0:i.message)||u.message||`HTTP ${l.status}`;throw new Error(`Failed to get supported config: ${c}`)}const o=await l.json();return((s=o.data)==null?void 0:s.attributes)||o.data||o}async getQuotes(t){var o,i;if(!this.config.projectId)throw new Error("projectId is required to get quotes");const n=new URLSearchParams({projectId:this.config.projectId,fiatCurrency:t.fiatCurrency,cryptoCurrency:t.cryptoCurrency,network:t.network});t.fiatAmount&&n.set("fiatAmount",t.fiatAmount),t.cryptoAmount&&n.set("cryptoAmount",t.cryptoAmount),t.orderType&&n.set("orderType",t.orderType),t.paymentMethodId&&n.set("paymentMethodId",t.paymentMethodId),t.country&&n.set("country",t.country);const r=await fetch(`${this.baseUrl}/public/v1/onramp/quotes?${n}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){const s=await r.json().catch(()=>({})),u=((o=s.error)==null?void 0:o.message)||s.message||`HTTP ${r.status}`;throw new Error(`Failed to get quotes: ${u}`)}const l=await r.json();return((i=l.data)==null?void 0:i.attributes)||l.data||l}async createCheckoutIntent(t){var l,o;if(!this.config.projectId)throw new Error("projectId is required to create checkout intents");const n=await fetch(`${this.baseUrl}/public/v1/onramp/checkout-intent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:this.config.projectId,...t})});if(!n.ok){const i=await n.json().catch(()=>({})),s=(typeof i.error=="string"?i.error:(l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;let u="";if(i.details)try{const c=typeof i.details=="string"?JSON.parse(i.details):i.details;if(c.errors&&typeof c.errors=="object"){const h=Object.values(c.errors).flat().filter(Boolean);h.length&&(u=h.join("; "))}}catch{}throw new Error(`Failed to create checkout intent: ${u||s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}async getTransaction(t){var l,o;const n=await fetch(`${this.baseUrl}/public/v1/onramp/transactions/${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({})),s=((l=i.error)==null?void 0:l.message)||i.message||`HTTP ${n.status}`;throw new Error(`Failed to get transaction: ${s}`)}const r=await n.json();return((o=r.data)==null?void 0:o.attributes)||r.data||r}}function em(e,t){const[n,r]=E.useState(null),[l,o]=E.useState(!0),[i,s]=E.useState(null),u=E.useRef(null);(!u.current||u.current!==e)&&(u.current=new Gl({apiKey:"",...e}));const c=E.useCallback(async()=>{if(!e.projectId){s(new Error("projectId is required")),o(!1);return}o(!0),s(null);try{const h=await u.current.getSupported(t);r(h)}catch(h){s(h instanceof Error?h:new Error("Failed to fetch config"))}finally{o(!1)}},[e.projectId,t]);return E.useEffect(()=>{c()},[c]),{config:n,loading:l,error:i,refetch:c}}function tm(e,t){const[n,r]=E.useState(null),[l,o]=E.useState(!1),[i,s]=E.useState(null),u=E.useRef(null),c=E.useRef(""),h=`${e.apiUrl}|${e.projectId}`;(!u.current||c.current!==h)&&(u.current=new Gl({apiKey:"",...e}),c.current=h);const m=E.useRef(0);E.useEffect(()=>{const x=++m.current;if(!t||!e.projectId){r(null),o(!1);return}o(!0),s(null),u.current.getQuotes(t).then(g=>{m.current===x&&(r(g),o(!1))},g=>{m.current===x&&(s(g instanceof Error?g:new Error("Failed to fetch quotes")),r(null),o(!1))})},[e.projectId,t==null?void 0:t.fiatCurrency,t==null?void 0:t.fiatAmount,t==null?void 0:t.cryptoAmount,t==null?void 0:t.cryptoCurrency,t==null?void 0:t.network,t==null?void 0:t.paymentMethodId,t==null?void 0:t.country,t==null?void 0:t.orderType]);const y=E.useCallback(async()=>{if(!(!t||!e.projectId)){o(!0),s(null);try{const x=await u.current.getQuotes(t);r(x)}catch(x){s(x instanceof Error?x:new Error("Failed to fetch quotes"))}finally{o(!1)}}},[e.projectId,t]);return{quotes:n,loading:l,error:i,refetch:y}}function nm(e){const[t,n]=E.useState(null),[r,l]=E.useState(!1),[o,i]=E.useState(null),s=E.useRef(null),u=E.useRef(""),c=`${e.apiUrl}|${e.projectId}`;(!s.current||u.current!==c)&&(s.current=new Gl({apiKey:"",...e}),u.current=c);const h=E.useCallback(async y=>{l(!0),i(null);try{const x=await s.current.createCheckoutIntent(y);return n(x),x}catch(x){const g=x instanceof Error?x:new Error("Failed to create checkout intent");throw i(g),g}finally{l(!1)}},[]),m=E.useCallback(()=>{n(null),i(null)},[]);return{order:t,loading:r,error:o,createOrder:h,reset:m}}function rm(e,t,n){const[r,l]=E.useState(null),[o,i]=E.useState(!1),[s,u]=E.useState(null),c=E.useRef(null);c.current||(c.current=new Gl({apiKey:"",projectId:"",...e}));const h=E.useCallback(async()=>{if(t){i(!0),u(null);try{const m=await c.current.getTransaction(t);l(m)}catch(m){u(m instanceof Error?m:new Error("Failed to fetch status"))}finally{i(!1)}}},[t]);return E.useEffect(()=>{if(!t)return;const m=n==null?void 0:n.initialDelay;{const y=setTimeout(h,m);return()=>clearTimeout(y)}},[h,t,n==null?void 0:n.initialDelay]),E.useEffect(()=>{if(!t||!(n!=null&&n.pollInterval)||!r||["completed","failed","cancelled","expired","refunded"].includes(r.status))return;const y=setInterval(h,n.pollInterval);return()=>clearInterval(y)},[t,n==null?void 0:n.pollInterval,r==null?void 0:r.status,h]),{status:r,loading:o,error:s,refetch:h}}function Jc(e,t){if(!e)return e;const n=e.indexOf(".");if(n===-1)return e;let r=e;return r.length-n-1>t&&(r=r.slice(0,n+t+1)),r=r.replace(/0+$/,"").replace(/\.$/,""),r}const qc={step:"amount",flowType:"buy",fiatCurrency:"USD",fiatAmount:"",cryptoCurrency:"",cryptoAmount:"",network:"",paymentMethodId:"",walletAddress:"",walletError:null,selectedProvider:null,selectedQuote:null,customerId:"",email:"",country:"",errorMessage:null};function lm(e,t){switch(t.type){case"SET_STEP":return{...e,step:t.step,errorMessage:null};case"SET_FLOW_TYPE":return{...e,flowType:t.flowType,fiatAmount:"",cryptoAmount:"",paymentMethodId:"",selectedQuote:null,selectedProvider:null,errorMessage:null};case"SET_FIAT_CURRENCY":return{...e,fiatCurrency:t.currency};case"SET_FIAT_AMOUNT":return{...e,fiatAmount:t.amount};case"SET_CRYPTO_CURRENCY":return{...e,cryptoCurrency:t.currency,network:""};case"SET_CRYPTO_AMOUNT":return{...e,cryptoAmount:t.amount};case"SET_NETWORK":return{...e,network:t.network};case"SET_CRYPTO_CHAIN":return{...e,network:t.chain};case"SET_PAYMENT_METHOD":return{...e,paymentMethodId:t.methodId};case"SET_WALLET_ADDRESS":return{...e,walletAddress:t.address,walletError:null};case"SET_WALLET_ERROR":return{...e,walletError:t.message};case"SELECT_QUOTE":return{...e,selectedQuote:t.quote,selectedProvider:t.quote.gatewayId};case"SET_CUSTOMER_ID":return{...e,customerId:t.customerId};case"SET_EMAIL":return{...e,email:t.email};case"SET_COUNTRY":return{...e,country:t.country};case"SET_ERROR":return{...e,step:"error",errorMessage:t.message};case"CLEAR_ERROR":return{...e,errorMessage:null};case"RESET":return qc;default:return e}}const bc=E.createContext(null);function om({projectId:e,apiUrl:t="https://api.nowramp.com",assetBaseUrl:n="",flowType:r="buy",customerId:l="",defaultFiatCurrency:o="USD",defaultCryptoCurrency:i="BTC",defaultNetwork:s="",defaultFiatAmount:u="",defaultCryptoAmount:c="",defaultWalletAddress:h="",defaultGateway:m,fieldLocks:y,statusPollInterval:x=5e3,onComplete:g,onError:S,children:L}){const f=E.useMemo(()=>({apiUrl:t,projectId:e}),[t,e]),d=s||(i?i.toLowerCase():""),p=r==="sell",w=p?!!c:!!u,R=(p?!!(w&&i&&d):!!(w&&i&&d&&h))&&m?"confirm":"amount",[v,T]=E.useReducer(lm,{...qc,step:R,flowType:r,fiatCurrency:o,cryptoCurrency:i,network:d,fiatAmount:Jc(u,2),cryptoAmount:Jc(c,6),walletAddress:h,customerId:l}),P=v.flowType==="sell",{config:A,loading:G,error:fe}=em(f,v.flowType);zn.useEffect(()=>{var ee,Z,Q;if(!A||!v.cryptoCurrency||v.network)return;const D=(ee=A.cryptos)==null?void 0:ee.find(Pe=>Pe.code===v.cryptoCurrency),z=((Z=D==null?void 0:D.networks)==null?void 0:Z.find(Pe=>Pe.isDefault))||((Q=D==null?void 0:D.networks)==null?void 0:Q[0]);z!=null&&z.id&&T({type:"SET_NETWORK",network:z.id})},[A,v.cryptoCurrency,v.network]),zn.useEffect(()=>{var Q,Pe;if(!((Q=A==null?void 0:A.paymentMethods)!=null&&Q.length))return;const D=v.fiatCurrency,z=A.paymentMethods;if(v.paymentMethodId&&z.some(vt=>vt.id===v.paymentMethodId&&vt.supportedFiats.includes(D)))return;const Z=z.find(Le=>Le.supportedFiats.includes(D)&&(Le.id.includes("card")||Le.id.includes("debit")))||z.find(Le=>Le.supportedFiats.includes(D));T({type:"SET_PAYMENT_METHOD",methodId:(Z==null?void 0:Z.id)||((Pe=z[0])==null?void 0:Pe.id)||""})},[A,v.fiatCurrency,v.paymentMethodId]);const pe=E.useMemo(()=>{if(P){if(!v.cryptoAmount)return null;const Q=parseFloat(v.cryptoAmount);return isNaN(Q)||Q<=0?"Enter a valid amount":null}if(!A||!v.fiatAmount)return null;const D=parseFloat(v.fiatAmount);if(isNaN(D))return null;const z=A.fiats.find(Q=>Q.code===v.fiatCurrency);if(!z)return null;const ee=parseFloat(z.minAmount),Z=parseFloat(z.maxAmount);return!isNaN(ee)&&D<ee?`Minimum amount is ${z.minAmount} ${v.fiatCurrency}`:!isNaN(Z)&&D>Z?`Maximum amount is ${z.maxAmount} ${v.fiatCurrency}`:null},[A,v.fiatAmount,v.fiatCurrency,v.cryptoAmount,P]),rn=E.useMemo(()=>{const D=P?!!v.cryptoAmount:!!v.fiatAmount;return!A||!D||!v.cryptoCurrency||!v.network||pe?null:{fiatCurrency:v.fiatCurrency,...P?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,paymentMethodId:v.paymentMethodId||void 0,country:v.country||void 0,orderType:v.flowType}},[A,v.fiatCurrency,v.fiatAmount,v.cryptoAmount,v.cryptoCurrency,v.network,v.paymentMethodId,v.country,pe,P,v.flowType]),{quotes:ln,loading:lt,error:ge,refetch:N}=tm(f,rn),{order:I,loading:M,error:H,createOrder:W}=nm(f),ht=15e3,{status:ae,loading:qe}=rm({apiUrl:t},(I==null?void 0:I.orderId)??null,{pollInterval:x,initialDelay:ht});zn.useEffect(()=>{(ae==null?void 0:ae.status)==="completed"&&g&&g(ae)},[ae==null?void 0:ae.status,g]),zn.useEffect(()=>{const D=fe||H;D&&S&&S(D)},[fe,H,S]);const Ce=m||(A==null?void 0:A.defaultGateway)||null,yt=E.useRef(Ce);yt.current=Ce;const bl=E.useRef(ln);bl.current=ln;const eo=E.useCallback(async()=>{var z,ee,Z;const D=((z=v.selectedQuote)==null?void 0:z.gatewayId)||((Z=(ee=bl.current)==null?void 0:ee.bestQuote)==null?void 0:Z.gatewayId)||yt.current;if(!D||!v.walletAddress){const Q=[!D&&"gateway",!v.walletAddress&&"walletAddress"].filter(Boolean).join(", ");T({type:"SET_ERROR",message:`Missing required fields: ${Q}`});return}try{await W({gateway:D,customerId:v.customerId||void 0,fiatCurrency:v.fiatCurrency,...P?{cryptoAmount:v.cryptoAmount}:{fiatAmount:v.fiatAmount},cryptoCurrency:v.cryptoCurrency,network:v.network,walletAddress:v.walletAddress,paymentMethodId:v.paymentMethodId||void 0,email:v.email||void 0,orderType:v.flowType}),T({type:"SET_STEP",step:"checkout"})}catch(Q){const Pe=Q instanceof Error?Q.message:"Failed to create order";/wallet|address/i.test(Pe)?T({type:"SET_WALLET_ERROR",message:Pe.replace(/^Failed to create checkout intent:\s*/i,"")}):T({type:"SET_ERROR",message:Pe})}},[v,W,P]),Ht=E.useCallback(D=>{T({type:"SET_STEP",step:D})},[]),Fn=E.useCallback(()=>{const D=["confirm","amount","quotes","wallet","checkout","processing","complete"],z=D.indexOf(v.step);z>0&&T({type:"SET_STEP",step:D[z-1]})},[v.step,P]),Es=E.useMemo(()=>{const D=P?!!v.cryptoAmount:!!v.fiatAmount;switch(v.step){case"confirm":return!!(D&&v.cryptoCurrency&&v.network&&v.walletAddress&&!pe);case"amount":return!!(D&&v.cryptoCurrency&&v.network&&!pe);case"quotes":return!!v.selectedQuote;case"wallet":return!!v.walletAddress;default:return!1}},[v,pe,P]),Ir={apiConfig:f,assetBaseUrl:n,config:A,configLoading:G,configError:fe,state:v,dispatch:T,quotes:ln,quotesLoading:lt,quotesError:ge,fetchQuotes:N,order:I,orderLoading:M,orderError:H,createOrder:eo,orderStatus:ae,orderStatusLoading:qe,fieldLocks:y||null,defaultGateway:Ce,amountError:pe,goToStep:Ht,goBack:Fn,canProceed:Es};return a.jsx(bc.Provider,{value:Ir,children:L})}function Dn(){const e=E.useContext(bc);if(!e)throw new Error("useRamp must be used within a RampProvider");return e}const gs={ETH:{name:"Ethereum (ERC20)",shortName:"Ethereum",icon:"eth"},BSC:{name:"Binance Smart Chain (BEP20)",shortName:"Binance",icon:"bnb"},BTC:{name:"Bitcoin",icon:"btc"},SOL:{name:"Solana",icon:"sol"},MATIC:{name:"Polygon",icon:"pol"},ARB:{name:"Arbitrum",icon:"arb"},BASE:{name:"Base",icon:"base"},OPTIMISM:{name:"Optimism",icon:"op"},AVAX_C:{name:"Avalanche C-Chain",shortName:"Avalanche C",icon:"avax"},AVAX_X:{name:"Avalanche X-Chain",shortName:"Avalanche X",icon:"avax"},ADA:{name:"Cardano",icon:"ada"},DOT:{name:"Polkadot",icon:"dot"},TRON:{name:"Tron (TRC20)",shortName:"Tron",icon:"trx"},XRP:{name:"Ripple",icon:"xrp"},XLM:{name:"Stellar",icon:"xlm"},ALGO:{name:"Algorand",icon:"algo"},ATOM:{name:"Cosmos",icon:"atom"},NEAR:{name:"NEAR Protocol",shortName:"NEAR",icon:"near"},SUI:{name:"Sui",icon:"sui"},APT:{name:"Aptos",icon:"apt"},TON:{name:"Ton",icon:"ton"},FIL:{name:"Filecoin",icon:"fil"},FLOW:{name:"Flow",icon:"flow"},HBAR:{name:"Hedera Hashgraph",shortName:"Hedera",icon:"hbar"},INJ:{name:"Injective",icon:"inj"},SEI_EVM:{name:"SEI (EVM)",shortName:"SEI",icon:"sei"},ZKSYNC:{name:"zkSync",icon:"zksync"},LINEA:{name:"Linea",icon:"linea"},STARK:{name:"StarkNet",icon:"strk"},LN:{name:"Lightning",icon:"btc"},CELO:{name:"Celo",icon:"celo"},CRO:{name:"Cronos",icon:"cro"},FTM:{name:"Fantom",icon:"ftm"},GLMR:{name:"Moonbeam",icon:"glmr"},MOVR:{name:"Moonriver",icon:"movr"},KSM:{name:"Kusama",icon:"ksm"},EOS:{name:"EOS",icon:"eos"},ETC:{name:"Ethereum Classic",shortName:"ETH Classic",icon:"etc"},LTC:{name:"Litecoin",icon:"ltc"},BCH:{name:"Bitcoin Cash",shortName:"BTC Cash",icon:"bch"},DOGE:{name:"Dogecoin",icon:"doge"},BNB:{name:"Binance Chain (BEP2)",shortName:"Binance",icon:"bnb"},ONE:{name:"Harmony",icon:"one"},KLAY:{name:"Kaia",icon:"kaia"},RON:{name:"Ronin",icon:"ron"},LRC:{name:"Loopring",icon:"lrc"},ICP:{name:"Internet Computer",shortName:"ICP",icon:"icp"},EGLD:{name:"MultiversX",icon:"egld"},FLUX:{name:"Flux",icon:"flux"},KDA:{name:"Kadena",icon:"kda"},WAVES:{name:"Waves",icon:"waves"},XTZ:{name:"Tezos",icon:"xtz"},ACA:{name:"Acala",icon:"aca"},ALEO:{name:"Aleo",icon:"aleo"},ALPH:{name:"Alephium",icon:"alph"},APE:{name:"ApeChain",icon:"ape"},ASTR:{name:"Astar",icon:"astr"},AZERO:{name:"Aleph Zero",icon:"azero"},AZERO_EVM:{name:"Aleph Zero EVM",shortName:"Aleph Zero",icon:"azero"},BAJU:{name:"Bajun Network",shortName:"Bajun",icon:"baju"},BNCPOLKA:{name:"Bifrost Polkadot",shortName:"Bifrost",icon:"bnc"},BNC:{name:"Bifrost Kusama",shortName:"Bifrost",icon:"bnc"},BOBA:{name:"Boba Network",shortName:"Boba",icon:"boba"},BSX:{name:"Basilisk",icon:"bsx"},CHZ:{name:"Chiliz",icon:"chz"},VIC:{name:"Viction",icon:"vic"},CCD:{name:"Concordium",icon:"ccd"},COREUM:{name:"Coreum",icon:"coreum"},DINGO:{name:"Dingocoin",icon:"dingo"},HDX:{name:"Hydration",icon:"hdx"},PLMC:{name:"Polimec",icon:"plmc"},MNT:{name:"Mantle",icon:"mnt"},ERG:{name:"Ergo",icon:"erg"},ECLIPSE:{name:"Eclipse",icon:"eclipse"},FUEL:{name:"Fuel Ignition",shortName:"Fuel",icon:"fuel"},INK:{name:"Ink",icon:"ink"},SOPHON:{name:"Sophon",icon:"sophon"},UNICHAIN:{name:"Unichain",icon:"unichain"},WLD:{name:"Worldchain",icon:"wld"},ETHERLINK:{name:"Etherlink",icon:"etherlink"},MOB:{name:"MobileCoin",icon:"mob"},GALA:{name:"Gala",icon:"gala"},GUNZ:{name:"Gunz",icon:"gun"},HNT:{name:"Helium",icon:"hnt"},BITKUB:{name:"BitKub",icon:"kub"},IMMUTABLE_ZKEVM:{name:"Immutable-zkEVM",shortName:"Immutable",icon:"imx"},INIT:{name:"Initia",icon:"init"},INTR:{name:"Interlay",icon:"intr"},KINESIS:{name:"Kinesis",icon:"kag"},KAR:{name:"Karura",icon:"kar"},KCC:{name:"KuCoin Community Chain",shortName:"KuCoin",icon:"kcs"},KILT:{name:"KILT Spiritnet",shortName:"KILT",icon:"kilt"},KINT:{name:"Kintsugi",icon:"kint"},KMD:{name:"Komodo",icon:"kmd"},LSK:{name:"Lisk",icon:"lsk"},METIS:{name:"Metis Andromeda",shortName:"Metis",icon:"metis"},MYTH:{name:"Myth",icon:"myth"},OAS:{name:"Oasys",icon:"oas"},PEAQ_EVM:{name:"Peaq (EVM)",shortName:"Peaq",icon:"peaq"},PEN:{name:"Pendulum",icon:"pen"},PI:{name:"Pi",icon:"pi"},POLYX:{name:"Polymesh",icon:"polyx"},Q:{name:"QuantumCoin",icon:"q"},QRL:{name:"Quantum Resistant Ledger",shortName:"QRL",icon:"qrl"},QUBIC:{name:"Qubic",icon:"qubic"},RBX:{name:"ReserveBlock",icon:"rbx"},ROLLUX:{name:"Rollux",icon:"rollux"},THORCHAIN:{name:"Thorchain",icon:"rune"},S:{name:"Sonic",icon:"s"},SONIC:{name:"Sonic",icon:"s"},TERNOA:{name:"Ternoa",icon:"caps"},SX:{name:"SX Network",icon:"sol"},WAX:{name:"WAX",icon:"waxp"},XCH:{name:"Chia Chain",icon:"xch"},XPRT:{name:"Persistence",icon:"xprt"},ZETACHAIN:{name:"ZetaChain",icon:"zeta"},ZTG:{name:"Zeitgeist",icon:"ztg"},PLS:{name:"Pulsechain",icon:"pulsechain"},MEZO:{name:"Mezo",icon:"mezo"},BSV:{name:"Bitcoin SV",shortName:"BTC SV",icon:"btc"},MONAD:{name:"Monad",icon:"mon"},SUPRA:{name:"Supra",icon:"supra"},SOMI:{name:"Somnia",icon:"somi"},VERIFIEDX:{name:"VerifiedX",icon:"vfx"},MOVE:{name:"Movement",icon:"move"},FLR:{name:"Flare",icon:"flr"},ASSETHUB:{name:"Asset Hub Polkadot",shortName:"Asset Hub",icon:"dot"},BOB:{name:"BOB",icon:"btc"},GLUE:{name:"Glue",icon:"eth"},DYDX:{name:"StarkEx",icon:"stark"},OKC:{name:"OKX Chain",icon:"eth"},UNI_CHAIN:{name:"UNI",icon:"uni"},ZEC:{name:"ZCash",icon:"zec"}},im=[{code:"BTC",name:"Bitcoin",chains:["BTC","LN"],popular:!0},{code:"ETH",name:"Ethereum",chains:["ETH","ARB","BASE","BSC","OPTIMISM","LINEA","ZKSYNC","LRC","STARK","APE","ECLIPSE","FUEL","INK","SOPHON","UNICHAIN","WLD"],popular:!0},{code:"USDC",name:"USD Coin",chains:["ETH","SOL","ARB","BASE","BSC","MATIC","OPTIMISM","AVAX_C","ALGO","APT","CELO","FLOW","HBAR","LINEA","LRC","ZKSYNC","STARK","SUI","XLM","ECLIPSE","HDX","INK","LSK","METIS","MONAD","SEI_EVM","SONIC","SOPHON","SX","UNICHAIN","APE","BNCPOLKA","GLMR","PEAQ_EVM","PLMC","RON","UNI_CHAIN","WLD","BITKUB","BOB","DYDX","ETHERLINK","GLUE","ASSETHUB"],popular:!0},{code:"USDT",name:"Tether",chains:["ETH","BSC","TRON","ARB","MATIC","AVAX_C","SOL","OPTIMISM","ZKSYNC","STARK","APT","CELO","KLAY","LRC","LSK","ECLIPSE","ETHERLINK","OKC","PEAQ_EVM","BNCPOLKA","GLMR","HDX","PLMC","VIC","ASSETHUB"],popular:!0},{code:"SOL",name:"Solana",chains:["SOL"],popular:!0},{code:"XRP",name:"Ripple",chains:["XRP"],popular:!0},{code:"ADA",name:"Cardano",chains:["ADA"],popular:!0},{code:"DOGE",name:"Dogecoin",chains:["DOGE"],popular:!0},{code:"DOT",name:"Polkadot",chains:["DOT","BSC","BNCPOLKA","GLMR","HDX","PLMC"],popular:!0},{code:"AVAX",name:"Avalanche",chains:["AVAX_C","AVAX_X","BSC"],popular:!0},{code:"LINK",name:"ChainLink",chains:["ETH","BSC"],popular:!0},{code:"LTC",name:"Litecoin",chains:["LTC"],popular:!0},{code:"AAVE",name:"Aave",chains:["ETH","BSC"],popular:!1},{code:"ACA",name:"Acala",chains:["ACA"],popular:!1},{code:"ALEO",name:"Aleo",chains:["ALEO"],popular:!1},{code:"ALGO",name:"Algorand",chains:["ALGO"],popular:!1},{code:"ALPH",name:"Alephium",chains:["ALPH"],popular:!1},{code:"APE",name:"ApeCoin",chains:["APE","ETH"],popular:!1},{code:"APT",name:"Aptos",chains:["APT"],popular:!1},{code:"ARB",name:"Arbitrum",chains:["ARB"],popular:!1},{code:"ASTR",name:"Astar",chains:["ASTR"],popular:!1},{code:"ATOM",name:"Cosmos",chains:["ATOM"],popular:!1},{code:"AUDD",name:"Novatti Australian Digital Dollar",chains:["ETH"],popular:!1},{code:"AVT",name:"Aventus",chains:["ETH"],popular:!1},{code:"AXS",name:"Axie Infinity",chains:["ETH","RON"],popular:!1},{code:"AZERO",name:"Aleph Zero",chains:["AZERO","AZERO_EVM"],popular:!1},{code:"BAJU",name:"Bajun Network",chains:["BAJU"],popular:!1},{code:"BARSIK",name:"Hasbulla's Cat",chains:["SOL"],popular:!1},{code:"BAT",name:"Basic Attention Token",chains:["ETH","BSC"],popular:!1},{code:"BCH",name:"Bitcoin Cash",chains:["BCH"],popular:!1},{code:"BNB",name:"Binance Coin",chains:["BNB","BSC"],popular:!1},{code:"BNC",name:"Bifrost Native Coin",chains:["BNC","BNCPOLKA"],popular:!1},{code:"BOBA",name:"Boba Network",chains:["BOBA","ETH"],popular:!1},{code:"BORA",name:"Bora",chains:["KLAY"],popular:!1},{code:"BRETT",name:"Brett",chains:["BASE"],popular:!1},{code:"BSX",name:"Basilisk",chains:["BSX"],popular:!1},{code:"BZR",name:"Bazaars",chains:["ETH"],popular:!1},{code:"CAGA",name:"Crypto Asset Governance Alliance",chains:["ETH"],popular:!1},{code:"CAKE",name:"PancakeSwap",chains:["BSC"],popular:!1},{code:"CAPS",name:"Caps",chains:["TERNOA"],popular:!1},{code:"CELO",name:"Celo",chains:["CELO"],popular:!1},{code:"CHZ",name:"Chiliz",chains:["CHZ","BNB","ETH"],popular:!1},{code:"C98",name:"Coin98",chains:["VIC"],popular:!1},{code:"CCD",name:"Concordium",chains:["CCD"],popular:!1},{code:"COMP",name:"Compound",chains:["ETH","BSC"],popular:!1},{code:"COREUM",name:"Coreum",chains:["COREUM","XRP"],popular:!1},{code:"CRO",name:"Cronos",chains:["CRO"],popular:!1},{code:"CUSD",name:"Celo Dollar",chains:["CELO"],popular:!1},{code:"CVC",name:"Civic",chains:["ETH"],popular:!1},{code:"DAI",name:"Dai",chains:["ETH","BASE","MATIC"],popular:!1},{code:"DINGO",name:"Dingocoin",chains:["DINGO"],popular:!1},{code:"EGLD",name:"MultiversX",chains:["EGLD"],popular:!1},{code:"EMBER",name:"Ember Sword",chains:["MNT"],popular:!1},{code:"EOS",name:"EOS",chains:["EOS"],popular:!1},{code:"ERG",name:"Ergo",chains:["ERG"],popular:!1},{code:"ETC",name:"Ethereum Classic",chains:["ETC","BSC"],popular:!1},{code:"EUR",name:"EURC",chains:["BASE"],popular:!1},{code:"EUROC",name:"Euro Coin",chains:["ETH"],popular:!1},{code:"EURQ",name:"Quantoz EURQ",chains:["ETH"],popular:!1},{code:"EURR",name:"StablR EUR",chains:["ETH"],popular:!1},{code:"EUSD",name:"Electronic USD",chains:["MOB"],popular:!1},{code:"EXIT",name:"EXIT - Designer Token",chains:["BSC"],popular:!1},{code:"FDUSD",name:"First Digital USD",chains:["SUI"],popular:!1},{code:"FIL",name:"Filecoin",chains:["FIL","BSC"],popular:!1},{code:"FLOW",name:"Flow",chains:["FLOW"],popular:!1},{code:"FLR",name:"Flare",chains:["FLR"],popular:!1},{code:"FLUX",name:"Flux",chains:["FLUX"],popular:!1},{code:"FTM",name:"Fantom",chains:["FTM","ETH","BSC"],popular:!1},{code:"GALA",name:"Gala",chains:["GALA"],popular:!1},{code:"GLMR",name:"Moonbeam",chains:["GLMR"],popular:!1},{code:"GMX",name:"GMX",chains:["ARB"],popular:!1},{code:"GNUS",name:"Genius AI",chains:["ETH"],popular:!1},{code:"GRT",name:"The Graph",chains:["ETH","ARB"],popular:!1},{code:"GUN",name:"Gunz",chains:["GUNZ"],popular:!1},{code:"HBAR",name:"Hedera",chains:["HBAR"],popular:!1},{code:"HDX",name:"HydraDX",chains:["HDX"],popular:!1},{code:"HNT",name:"Helium",chains:["HNT"],popular:!1},{code:"HTP",name:"HowToPay",chains:["BSC"],popular:!1},{code:"HVLO",name:"Hivello",chains:["SOL"],popular:!1},{code:"ICP",name:"Internet Computer",chains:["ICP"],popular:!1},{code:"IMX",name:"Immutable X",chains:["ETH"],popular:!1},{code:"INIT",name:"Initia",chains:["INIT"],popular:!1},{code:"INJ",name:"Injective",chains:["INJ"],popular:!1},{code:"INTR",name:"Interlay",chains:["INTR"],popular:!1},{code:"JAM",name:"Jam Tune.FM",chains:["HBAR"],popular:!1},{code:"KAG",name:"Silver",chains:["KINESIS"],popular:!1},{code:"KAIA",name:"Kaia",chains:["KLAY"],popular:!1},{code:"KAR",name:"Karura",chains:["KAR"],popular:!1},{code:"KAU",name:"Gold",chains:["KINESIS"],popular:!1},{code:"KCS",name:"KuCoin Token",chains:["ETH","KCC"],popular:!1},{code:"KDA",name:"Kadena",chains:["KDA"],popular:!1},{code:"KILT",name:"KILT",chains:["KILT"],popular:!1},{code:"KINT",name:"Kintsugi",chains:["KINT"],popular:!1},{code:"KLV",name:"Klever",chains:["TRON"],popular:!1},{code:"KMD",name:"Komodo",chains:["KMD"],popular:!1},{code:"KSM",name:"Kusama",chains:["KSM"],popular:!1},{code:"KUB",name:"Bitkub Coin",chains:["BITKUB"],popular:!1},{code:"LOOKS",name:"LooksRare",chains:["ETH"],popular:!1},{code:"LRC",name:"Loopring",chains:["ETH","LRC"],popular:!1},{code:"LSK",name:"Lisk",chains:["LSK"],popular:!1},{code:"MANA",name:"Decentraland",chains:["ETH"],popular:!1},{code:"MBX",name:"Marblex",chains:["IMMUTABLE_ZKEVM","KLAY"],popular:!1},{code:"MELANIA",name:"Melania",chains:["SOL"],popular:!1},{code:"METAMASKUSD",name:"Metamask USD",chains:["ETH","LINEA"],popular:!1},{code:"METIS",name:"Metis",chains:["METIS"],popular:!1},{code:"MEZOUSD",name:"MUSD",chains:["ETH","MEZO"],popular:!1},{code:"MKR",name:"Maker",chains:["ETH","BSC"],popular:!1},{code:"MNEE",name:"MNEE",chains:["BSV","ETH"],popular:!1},{code:"MNT",name:"Mantle",chains:["ETH","MNT"],popular:!1},{code:"MOB",name:"MobileCoin",chains:["MOB"],popular:!1},{code:"MON",name:"Monad",chains:["MONAD"],popular:!1},{code:"MOVE",name:"Movement",chains:["MOVE"],popular:!1},{code:"MOVR",name:"Moonriver",chains:["MOVR"],popular:!1},{code:"MYTH",name:"Myth",chains:["MYTH"],popular:!1},{code:"NEAR",name:"NEAR Protocol",chains:["NEAR","BSC"],popular:!1},{code:"NEIRO",name:"NEIRO Ethereum",chains:["ETH"],popular:!1},{code:"OAS",name:"Oasys",chains:["OAS"],popular:!1},{code:"OMG",name:"OmiseGo",chains:["ETH"],popular:!1},{code:"OMUSD",name:"Open Money USD",chains:["ETH"],popular:!1},{code:"ONE",name:"Harmony",chains:["ONE","BNB","ETH"],popular:!1},{code:"OP",name:"Optimism",chains:["OPTIMISM"],popular:!1},{code:"ORDER",name:"Orderly Network",chains:["ETH"],popular:!1},{code:"PEAQ",name:"Peaq",chains:["PEAQ_EVM"],popular:!1},{code:"PEN",name:"Pendulum",chains:["PEN"],popular:!1},{code:"PERC",name:"Perion",chains:["ETH"],popular:!1},{code:"PI",name:"Pi",chains:["PI"],popular:!1},{code:"PLMC",name:"Polimec",chains:["PLMC"],popular:!1},{code:"POL",name:"Polygon",chains:["ETH","MATIC"],popular:!1},{code:"POLYX",name:"Polymesh",chains:["POLYX"],popular:!1},{code:"PROPC",name:"Propchain",chains:["ETH"],popular:!1},{code:"PSTAKE",name:"pSTAKE Finance",chains:["ETH"],popular:!1},{code:"Q",name:"QuantumCoin",chains:["Q"],popular:!1},{code:"QRDO",name:"Qredo",chains:["ETH"],popular:!1},{code:"QRL",name:"Quantum Resistant Ledger",chains:["QRL"],popular:!1},{code:"QUBIC",name:"QUBIC",chains:["QUBIC"],popular:!1},{code:"RBX",name:"ReserveBlock",chains:["RBX"],popular:!1},{code:"REVU",name:"Revuto",chains:["ADA"],popular:!1},{code:"RITE",name:"Ritestream",chains:["BSC"],popular:!1},{code:"RLUSD",name:"Ripple USD",chains:["ETH"],popular:!1},{code:"RON",name:"Ronin",chains:["RON"],popular:!1},{code:"RUNE",name:"THORChain",chains:["THORCHAIN"],popular:!1},{code:"S",name:"Sonic",chains:["S"],popular:!1},{code:"SAND",name:"The Sandbox",chains:["ETH","BSC"],popular:!1},{code:"SEI",name:"SEI",chains:["SEI_EVM"],popular:!1},{code:"SNX",name:"Synthetix",chains:["ETH"],popular:!1},{code:"SOIL",name:"Sun Minimeal",chains:["PLS"],popular:!1},{code:"SOLO",name:"Sologenic",chains:["XRP"],popular:!1},{code:"SOMI",name:"Somnia",chains:["SOMI"],popular:!1},{code:"STRK",name:"Starknet",chains:["STARK"],popular:!1},{code:"SUI",name:"Sui",chains:["SUI"],popular:!1},{code:"SUPR",name:"SuperDapp",chains:["ROLLUX"],popular:!1},{code:"SUPRA",name:"Supra",chains:["SUPRA"],popular:!1},{code:"SUSHI",name:"SushiSwap",chains:["ETH","BSC"],popular:!1},{code:"SYS",name:"Syscoin",chains:["ROLLUX"],popular:!1},{code:"TBTC",name:"tBTC",chains:["SUI","STARK"],popular:!1},{code:"TON",name:"Toncoin",chains:["TON"],popular:!1},{code:"TRUMP",name:"TRUMP",chains:["SOL"],popular:!1},{code:"TRX",name:"Tron",chains:["TRON","BSC"],popular:!1},{code:"TWT",name:"Trust Wallet Token",chains:["BSC"],popular:!1},{code:"UNI",name:"Uniswap",chains:["ETH","BSC"],popular:!1},{code:"URANIUM",name:"Uranium",chains:["ETHERLINK"],popular:!1},{code:"USD0",name:"Usual USD",chains:["ETH"],popular:!1},{code:"USD1",name:"World Liberty Financial USD",chains:["SOL"],popular:!1},{code:"USDE",name:"Ethena USDe",chains:["ETH"],popular:!1},{code:"USDP",name:"Pax Dollar",chains:["ETH"],popular:!1},{code:"USDQ",name:"Quantoz USDQ",chains:["ETH"],popular:!1},{code:"USDR",name:"StablR USD",chains:["ETH"],popular:!1},{code:"USDT0",name:"USDT0",chains:["INK"],popular:!1},{code:"VFX",name:"VerifiedX",chains:["VERIFIEDX"],popular:!1},{code:"VERSE",name:"Verse",chains:["ETH","MATIC"],popular:!1},{code:"VIC",name:"Viction",chains:["VIC"],popular:!1},{code:"WAL",name:"Walrus",chains:["SUI"],popular:!1},{code:"WAVES",name:"Waves",chains:["WAVES"],popular:!1},{code:"WAXP",name:"WAX",chains:["WAX"],popular:!1},{code:"WBTC",name:"Wrapped Bitcoin",chains:["ETH","STARK"],popular:!1},{code:"WETH",name:"Wrapped Ether",chains:["ETHERLINK"],popular:!1},{code:"WLD",name:"Worldcoin",chains:["WLD"],popular:!1},{code:"WLFI",name:"World Liberty Financial",chains:["ETH"],popular:!1},{code:"WOLF",name:"LandWolf",chains:["ETH"],popular:!1},{code:"WOMBAT",name:"Wombat",chains:["MATIC"],popular:!1},{code:"XCH",name:"Chia",chains:["XCH"],popular:!1},{code:"XLM",name:"Stellar Lumens",chains:["XLM","BSC"],popular:!1},{code:"XPRT",name:"Persistence",chains:["XPRT"],popular:!1},{code:"XTZ",name:"Tezos",chains:["XTZ","ETHERLINK"],popular:!1},{code:"YFI",name:"yearn.finance",chains:["ETH"],popular:!1},{code:"ZBU",name:"Zeebu",chains:["BSC"],popular:!1},{code:"ZEC",name:"ZCash",chains:["ZEC"],popular:!1},{code:"ZCHF",name:"Frankencoin",chains:["ETH"],popular:!1},{code:"ZETA",name:"Zeta",chains:["ETH","ZETACHAIN"],popular:!1},{code:"ZTG",name:"Zeitgeist",chains:["ZTG"],popular:!1}],sm={AED:"ae",ALL:"al",ARS:"ar",AUD:"au",BRL:"br",CAD:"ca",CHF:"ch",CLP:"cl",CZK:"cz",DKK:"dk",EUR:"eu",GBP:"gb",HKD:"hk",IDR:"id",INR:"in",JPY:"jp",KRW:"kr",MXN:"mx",NGN:"ng",NOK:"no",NZD:"nz",PHP:"ph",PLN:"pl",QAR:"qa",SAR:"sa",SEK:"se",SGD:"sg",THB:"th",TRY:"tr",TWD:"tw",USD:"us",VND:"vn",ZAR:"za"};function ed(e,t=""){return`${t}/crypto-icons/${e.toLowerCase()}.svg`}function am(e,t=""){const n=sm[e]||"us";return`${t}/flags/${n}.svg`}function Zl(e){return gs[e]||gs[e.toUpperCase()]||gs[e.toUpperCase().replace(/-/g,"_")]}function xs(e,t=""){const n=Zl(e);return n?`${t}/crypto-icons/${n.icon}.svg`:`${t}/crypto-icons/${e.toLowerCase()}.svg`}const td=[{code:"ALL",name:"Albania Lek"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australian Dollar"},{code:"BRL",name:"Brazilian Real"},{code:"CAD",name:"Canadian Dollar"},{code:"EUR",name:"Euro"},{code:"GBP",name:"British Pound"},{code:"JPY",name:"Japanese Yen"},{code:"USD",name:"US Dollar"},{code:"CHF",name:"Swiss Franc"},{code:"MXN",name:"Mexican Peso"},{code:"INR",name:"Indian Rupee"}],nd=[{id:"blue",name:"Blue",accent:"#0077FF"},{id:"violet",name:"Violet",accent:"#7C3AED"},{id:"green",name:"Green",accent:"#10B981"},{id:"orange",name:"Orange",accent:"#F59E0B"},{id:"rose",name:"Rose",accent:"#F43F5E"},{id:"mono",name:"Mono",accent:null}];function um(e){return parseFloat(e.replace(/,/g,""))||0}const ws=e=>/^#([0-9A-Fa-f]{3}){1,2}$/.test(e),rd=10,ld=1e-4,cm=(()=>{const e=[];for(const t of im)for(const n of t.chains)e.push({code:t.code,name:t.name,chain:n,popular:t.popular});return e})();function od({ticker:e,size:t=32,baseUrl:n=""}){return a.jsx("img",{src:ed(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function Ss({currencyCode:e,size:t=16,baseUrl:n=""}){return a.jsx("img",{src:am(e,n),alt:e,width:t,height:t,className:"rounded-full shrink-0",style:{width:t,height:t}})}function id({size:e=32,color:t="#888"}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:[a.jsx("circle",{cx:"16",cy:"16",r:"16",fill:t}),a.jsx("circle",{cx:"16",cy:"16",r:"8",stroke:"white",strokeWidth:"1.5",fill:"none"})]})}function dm({size:e=24}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:[a.jsx("circle",{cx:"16",cy:"16",r:"16",fill:"#0077FF"}),a.jsx("path",{d:"M8 15l8-6 8 6H8z",fill:"white"}),a.jsx("rect",{x:"10",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"15",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"20",y:"16",width:"2",height:"6",fill:"white"}),a.jsx("rect",{x:"8",y:"22",width:"16",height:"2",rx:"0.5",fill:"white"})]})}function fm({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center text-white font-semibold shrink-0",style:{width:e,height:e,backgroundColor:"#333",fontSize:e*.45},children:"R"})}function pm({size:e=32}){return a.jsx("div",{className:"rounded-full bg-black border border-white/20 flex items-center justify-center text-white shrink-0",style:{width:e,height:e,fontSize:e*.3},children:a.jsx("span",{style:{fontFamily:"-apple-system, system-ui, sans-serif",fontWeight:600},children:"Pay"})})}function mm({size:e=32}){return a.jsxs("div",{className:"rounded-full bg-white flex items-center justify-center shrink-0",style:{width:e,height:e,fontSize:e*.28,fontWeight:700,color:"#333"},children:["G",a.jsx("span",{style:{color:"#4285F4",fontSize:e*.2},children:"Pay"})]})}function hm({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"#003087"},children:a.jsx("span",{className:"text-white font-bold",style:{fontSize:e*.38},children:"P"})})}function ym({size:e=32}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-card-icon-bg)"},children:a.jsxs("svg",{width:e*.55,height:e*.55,viewBox:"0 0 18 14",fill:"none",children:[a.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"13",rx:"2",stroke:"var(--t-card-icon-stroke)"}),a.jsx("rect",{y:"3",width:"18",height:"3",fill:"var(--t-card-icon-stroke)"})]})})}function Pr(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:a.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"var(--t-text-secondary)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function vm(){return a.jsx("svg",{width:"8",height:"14",viewBox:"0 0 8 14",fill:"none",children:a.jsx("path",{d:"M1 1L7 7L1 13",stroke:"var(--t-icon-stroke)",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function gm({onClick:e}){return a.jsx("button",{onClick:e,className:"hover:opacity-70 transition-opacity",children:a.jsx("svg",{width:"24",height:"16",viewBox:"0 0 24 16",fill:"none",children:a.jsx("path",{d:"M22.4004 12V4C22.4004 2.67452 21.3255 1.59961 20 1.59961H6.7998V14.4004H20V16H4V14.4004H5.2002V1.59961H4C2.67452 1.59961 1.59961 2.67452 1.59961 4V12C1.59961 13.3255 2.67452 14.4004 4 14.4004V16L3.79395 15.9951C1.68056 15.8879 0 14.14 0 12V4C0 1.79086 1.79086 6.44266e-08 4 0H20C22.2091 0 24 1.79086 24 4V12L23.9951 12.2061C23.8913 14.2512 22.2512 15.8913 20.2061 15.9951L20 16V14.4004C21.3255 14.4004 22.4004 13.3255 22.4004 12Z",fill:"var(--t-icon-stroke)"})})})}function xm({size:e=40}){return a.jsx("div",{className:"rounded-full flex items-center justify-center shrink-0",style:{width:e,height:e,background:"var(--t-surface)"},children:a.jsxs("svg",{width:e*.5,height:e*.5,viewBox:"0 0 20 20",fill:"none",children:[a.jsx("circle",{cx:"10",cy:"10",r:"7.5",stroke:"var(--t-text)",strokeWidth:"1.5"}),a.jsx("path",{d:"M10 2.5A7.5 7.5 0 0 1 10 17.5",fill:"var(--t-text)"})]})})}function wm(e,t=32){switch(e){case"revolut":return a.jsx(fm,{size:t});case"applepay":return a.jsx(pm,{size:t});case"card":return a.jsx(ym,{size:t});case"googlepay":return a.jsx(mm,{size:t});case"paypal":return a.jsx(hm,{size:t});case"bank":return a.jsx(dm,{size:t});default:return a.jsx(id,{size:t})}}const Sm={"debit-credit-card":"card","bank-transfer":"bank","apple-pay":"applepay","google-pay":"googlepay",paypal:"paypal",revolut:"revolut"},km={"debit-credit-card":"Card","bank-transfer":"Bank Transfer","ach-bank-transfer":"ACH","apple-pay":"Apple Pay","google-pay":"Google Pay","payid-bank-transfer":"PayID",paypal:"PayPal",revolut:"Revolut"};function sd(e,t){return km[e]||t}function ad(e,t,n=24){const r=Sm[e];return r?wm(r,n):t?a.jsx("img",{src:t,alt:"",width:n,height:n,style:{borderRadius:"50%"}}):a.jsx(id,{size:n})}function Em({methods:e,selectedId:t,onOpenModal:n,fiatCurrency:r}){const l=E.useMemo(()=>e.filter(i=>i.supportedFiats.includes(r)),[e,r]),o=l.find(i=>i.id===t)||l[0];return l.length===0?a.jsx("div",{className:"flex items-center justify-between px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderBottomLeftRadius:5,borderBottomRightRadius:5},children:a.jsxs("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:["No payment methods available for ",r]})}):a.jsx(a.Fragment,{children:a.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&n()},className:"flex items-center justify-between w-full px-[18px] transition-colors",style:{background:"var(--t-surface)",borderBottomLeftRadius:5,borderBottomRightRadius:5,cursor:"pointer",height:42},children:[a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:"Payment method"}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"flex items-center justify-center",style:{width:20,height:20},children:o&&ad(o.id,o.icon,20)}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:o?sd(o.id,o.name):"Select"}),a.jsx(Pr,{})]})]})})}function Cm({className:e="",autoRedirect:t=!1,redirectDelay:n=3e3}){var y;const{order:r,orderStatus:l,goToStep:o,goBack:i}=Dn(),[s,u]=E.useState(!1),[c,h]=E.useState(null),m=r!=null&&r.checkout.expiresAt?Date.now()>r.checkout.expiresAt:!1;if(E.useEffect(()=>{if((r==null?void 0:r.checkout.method)==="redirect"&&t&&!m){h(Math.ceil(n/1e3));const x=setTimeout(()=>{window.location.href=r.checkout.url},n),g=setInterval(()=>{h(S=>S&&S>1?S-1:null)},1e3);return()=>{clearTimeout(x),clearInterval(g)}}},[r,t,n,m]),E.useEffect(()=>{l&&(l.status==="completed"?o("complete"):["failed","cancelled","expired"].includes(l.status)&&o("error"))},[l==null?void 0:l.status,o]),!r)return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("p",{className:"text-[15px] mb-4",children:"No order found"}),a.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:i,children:"Go Back"})]});if(m)return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Checkout expired"}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:"The session has expired. Please try again."}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:i,children:"Start over"})]});if(r.checkout.method==="iframe"){const x=r.checkout.url,g=((y=r.checkout.allowedFeatures)==null?void 0:y.join("; "))||"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share";return vs.createPortal(a.jsxs("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",background:"#000"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",height:48,paddingLeft:8,paddingRight:16,background:"#111",flexShrink:0},children:a.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer",padding:"8px 12px",borderRadius:6},children:[a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Cancel"]})}),a.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:[!s&&a.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{style:{color:"#888",fontSize:14,marginTop:16},children:"Loading checkout..."})]}),a.jsx("iframe",{src:x,style:{display:s?"block":"none",width:"100%",height:"100%",border:"none"},allow:g,onLoad:()=>u(!0),title:"Provider Checkout"})]})]}),document.body)}if(r.checkout.method==="redirect")return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 text-center ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("div",{className:"text-[48px] mb-4",children:"🔗"}),a.jsx("h3",{className:"text-[18px] font-semibold mb-2",children:"Complete Payment"}),a.jsxs("p",{className:"text-[14px] mb-4",style:{color:"var(--t-text-secondary)"},children:["You'll be redirected to ",r.gateway," to complete your payment."]}),c!==null&&a.jsxs("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:["Redirecting in ",c,"..."]}),a.jsxs("a",{href:r.checkout.url,className:"w-full font-semibold text-[16px] flex items-center justify-center transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",textDecoration:"none"},target:"_blank",rel:"noopener noreferrer",children:["Continue to ",r.gateway]}),a.jsx("button",{className:"w-full font-semibold text-[14px] mt-2 transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:i,children:"Cancel"})]});if(r.checkout.method==="widget"&&r.widgetConfig){const x=Nm(r.checkout.url,r.widgetConfig);return vs.createPortal(a.jsxs("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",background:"#000"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",height:48,paddingLeft:8,paddingRight:16,background:"#111",flexShrink:0},children:a.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer",padding:"8px 12px",borderRadius:6},children:[a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Cancel"]})}),a.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:[!s&&a.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{style:{color:"#888",fontSize:14,marginTop:16},children:"Loading checkout..."})]}),a.jsx("iframe",{src:x,style:{display:s?"block":"none",width:"100%",height:"100%",border:"none"},allow:"payment; camera; microphone; geolocation; clipboard-read; clipboard-write; accelerometer; gyroscope; magnetometer; fullscreen; autoplay; encrypted-media; web-share",onLoad:()=>u(!0),title:"Payment Checkout"})]})]}),document.body)}return a.jsxs("div",{className:`flex flex-col items-center justify-center p-8 ${e}`,style:{color:"var(--t-text)"},children:[a.jsx("p",{className:"text-[15px] mb-4",children:"Unknown checkout method"}),a.jsx("button",{className:"font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",paddingLeft:24,paddingRight:24},onClick:i,children:"Go Back"})]})}function Nm(e,t){const n=new URL("/en/partner/widget",e);for(const[r,l]of Object.entries(t))l!=null&&l!==""&&n.searchParams.set(r,String(l));return n.toString()}function Tm({className:e=""}){const{orderStatus:t,orderStatusLoading:n,goToStep:r}=Dn();E.useEffect(()=>{t&&(t.status==="completed"?r("complete"):["failed","cancelled","expired","refunded"].includes(t.status)&&r("error"))},[t==null?void 0:t.status,r]);const l=()=>{if(!t)return"Processing your order...";switch(t.status){case"pending":return"Waiting for payment confirmation...";case"processing":return"Processing your transaction...";default:return"Processing..."}};return a.jsxs("div",{className:`flex flex-col items-center justify-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"mb-6",children:a.jsx("div",{className:"nramp-spinner-large nramp-spinner"})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-3",style:{color:"var(--t-text)"},children:l()}),n&&a.jsx("p",{className:"text-[13px] mb-4",style:{color:"var(--t-text-muted)"},children:"Checking status..."}),t&&a.jsxs("div",{className:"w-full mt-6 text-left",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsx(Bn,{label:"Order ID",value:t.orderId,mono:!0}),a.jsx(Bn,{label:"Provider",value:t.gateway}),a.jsx(Bn,{label:"Amount",value:`${t.fiatAmount} ${t.fiatCurrency}`}),a.jsx(Bn,{label:"Receiving",value:`${t.cryptoAmount||"..."} ${t.cryptoCurrency}`}),a.jsx(Bn,{label:"Network",value:t.network}),a.jsx(Bn,{label:"To Address",value:`${t.walletAddress.slice(0,10)}...${t.walletAddress.slice(-8)}`,mono:!0})]}),a.jsxs("div",{className:"mt-6",children:[a.jsx("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"This usually takes a few minutes."}),a.jsx("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:"You can safely close this page - we'll send you an email when complete."})]})]})}function Bn({label:e,value:t,mono:n}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:"var(--t-text)"},children:t})]})}function jm({className:e="",explorerUrl:t,onDone:n,doneButtonText:r="Done"}){const{orderStatus:l,state:o,dispatch:i}=Dn(),s=o.flowType==="sell",u=()=>{if(!(l!=null&&l.transactionHash))return null;if(!t){const m={ethereum:"https://etherscan.io/tx/{txHash}",polygon:"https://polygonscan.com/tx/{txHash}",arbitrum:"https://arbiscan.io/tx/{txHash}",optimism:"https://optimistic.etherscan.io/tx/{txHash}",base:"https://basescan.org/tx/{txHash}",bitcoin:"https://mempool.space/tx/{txHash}",solana:"https://solscan.io/tx/{txHash}",avalanche:"https://snowtrace.io/tx/{txHash}",fantom:"https://ftmscan.com/tx/{txHash}"};return(m[o.network]||m.ethereum).replace("{txHash}",l.transactionHash)}return t.replace("{txHash}",l.transactionHash)},c=()=>{n?n():i({type:"RESET"})},h=u();return a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-success, #10b981)"},children:a.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:a.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:s?"Sale Complete!":"Purchase Complete!"}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:s?`Your ${(l==null?void 0:l.fiatCurrency)||o.fiatCurrency} payout is being processed.`:`Your ${(l==null?void 0:l.cryptoCurrency)||o.cryptoCurrency} has been sent to your wallet.`}),l&&a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsx(Ut,{label:s?"Amount Sold":"Amount Received",value:`${l.cryptoAmount} ${l.cryptoCurrency}`,highlight:!0}),a.jsx(Ut,{label:s?"Payout Amount":"Amount Paid",value:`${l.fiatAmount} ${l.fiatCurrency}`}),a.jsx(Ut,{label:"Network",value:l.network}),a.jsx(Ut,{label:"Wallet",value:`${l.walletAddress.slice(0,10)}...${l.walletAddress.slice(-8)}`,mono:!0}),l.transactionHash&&a.jsx(Ut,{label:"Transaction",value:`${l.transactionHash.slice(0,10)}...${l.transactionHash.slice(-8)}`,mono:!0}),a.jsx(Ut,{label:"Provider",value:l.gateway}),a.jsx(Ut,{label:"Order ID",value:l.orderId,mono:!0}),l.completedAt&&a.jsx(Ut,{label:"Completed",value:new Date(l.completedAt).toLocaleString()})]}),a.jsxs("div",{className:"w-full flex flex-col gap-2",children:[h&&a.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"w-full font-semibold text-[14px] flex items-center justify-center transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)",textDecoration:"none"},children:"View on Explorer"}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:c,children:r})]})]})}function Ut({label:e,value:t,mono:n,highlight:r}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function Rm({className:e="",onRetry:t,supportEmail:n="support@nowramp.com"}){const{state:r,orderStatus:l,dispatch:o,goToStep:i}=Dn(),s=r.flowType==="sell",u=()=>{if(l)switch(l.status){case"failed":return"Payment Failed";case"cancelled":return"Order Cancelled";case"expired":return"Order Expired";case"refunded":return"Order Refunded";default:return"Something Went Wrong"}return"Something Went Wrong"},c=()=>{if(r.errorMessage)return r.errorMessage;if(l)switch(l.status){case"failed":return s?"Your sale could not be processed. Please try again.":"Your payment could not be processed. Please try again or use a different payment method.";case"cancelled":return s?"Your sale was cancelled. No crypto was transferred.":"Your order was cancelled. No payment was processed.";case"expired":return s?"Your order has expired. Please start a new sale.":"Your order has expired. Please start a new purchase.";case"refunded":return s?"Your crypto has been returned. The funds should appear in your wallet shortly.":"Your payment has been refunded. The funds should appear in your account within 5-10 business days.";default:return"An unexpected error occurred. Please try again."}return"An unexpected error occurred. Please try again."},h=()=>{o({type:"CLEAR_ERROR"}),t?t():(o({type:"RESET"}),i("amount"))},m=()=>{o({type:"RESET"}),i("amount")};return a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 text-center ${e}`,children:[a.jsx("div",{className:"flex items-center justify-center mb-5",style:{width:64,height:64,borderRadius:"50%",background:"var(--t-error, #EF4444)"},children:a.jsx("svg",{viewBox:"0 0 24 24",width:"32",height:"32",fill:"white",children:a.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})})}),a.jsx("h2",{className:"text-[20px] font-semibold mb-2",style:{color:"var(--t-text)"},children:u()}),a.jsx("p",{className:"text-[14px] mb-6",style:{color:"var(--t-text-secondary)"},children:c()}),l&&a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Order ID"}),a.jsx("span",{className:"text-[13px] font-medium font-mono",style:{color:"var(--t-text)"},children:l.orderId})]}),a.jsxs("div",{className:"flex justify-between items-center py-2",children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Status"}),a.jsx("span",{className:"text-[12px] font-medium px-2 py-0.5",style:{background:"rgba(239,68,68,0.15)",color:"#EF4444",borderRadius:4},children:l.gatewayStatus})]})]}),a.jsxs("div",{className:"w-full flex flex-col gap-2",children:[a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)"},onClick:h,children:"Try Again"}),a.jsx("button",{className:"w-full font-semibold text-[14px] transition-all",style:{height:48,borderRadius:5,background:"var(--t-surface)",color:"var(--t-text)"},onClick:m,children:"Start Over"})]}),a.jsxs("div",{className:"mt-6",children:[a.jsxs("p",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:["Need help? Contact"," ",a.jsx("a",{href:`mailto:${n}`,className:"underline",style:{color:"var(--t-accent)"},children:n})]}),l&&a.jsxs("p",{className:"text-[12px] mt-1",style:{color:"var(--t-text-muted)"},children:["Reference: ",l.orderId]})]})]})}function ud(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-6)}`}function Am({className:e=""}){const{config:t,configLoading:n,state:r,defaultGateway:l,fetchQuotes:o,createOrder:i,orderLoading:s}=Dn(),u=r.flowType==="sell",[c,h]=E.useState(null),m=t==null?void 0:t.gateways.find(x=>x.id===l),y=async()=>{h(null);try{o(),await i()}catch(x){const g=x instanceof Error?x.message:"Failed to create order";h(g)}};return n?a.jsxs("div",{className:`flex flex-col items-center justify-center p-12 ${e}`,children:[a.jsx("div",{className:"nramp-spinner"}),a.jsx("p",{className:"text-[14px] mt-4",style:{color:"var(--t-text-secondary)"},children:"Loading..."})]}):a.jsxs("div",{className:`flex flex-col items-center px-8 py-12 ${e}`,children:[a.jsx("h2",{className:"text-[20px] font-semibold mb-6",style:{color:"var(--t-text)"},children:u?"Confirm Sale":"Confirm Purchase"}),a.jsxs("div",{className:"w-full text-left mb-6",style:{background:"var(--t-surface)",borderRadius:5,padding:16},children:[m&&a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:"Provider"}),a.jsxs("span",{className:"flex items-center gap-2",children:[m.logo&&a.jsx("img",{src:m.logo,alt:m.name,width:20,height:20,style:{borderRadius:4}}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:m.name})]})]}),u?a.jsxs(a.Fragment,{children:[a.jsx(nn,{label:"You sell",value:`${r.cryptoAmount} ${r.cryptoCurrency}`,highlight:!0}),a.jsx(nn,{label:"You receive",value:`${r.fiatCurrency} payout`})]}):a.jsxs(a.Fragment,{children:[a.jsx(nn,{label:"You pay",value:`${r.fiatAmount} ${r.fiatCurrency}`,highlight:!0}),a.jsx(nn,{label:"You receive",value:`${r.cryptoCurrency} on ${r.network}`}),a.jsx(nn,{label:"Wallet",value:ud(r.walletAddress),mono:!0})]}),a.jsx(nn,{label:"Network",value:r.network}),u&&r.walletAddress&&a.jsx(nn,{label:"Refund address",value:ud(r.walletAddress),mono:!0})]}),c&&a.jsx("p",{className:"text-[12px] mb-4",style:{color:"#EF4444"},children:c}),a.jsx("button",{className:"w-full font-semibold text-[16px] transition-all flex items-center justify-center gap-2",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:s?.7:1},disabled:s,onClick:y,children:s?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"nramp-spinner-inline"}),"Processing..."]}):u?"Confirm & Sell":"Confirm & Pay"})]})}function nn({label:e,value:t,mono:n,highlight:r}){return a.jsxs("div",{className:"flex justify-between items-center py-2",style:{borderBottom:"1px solid var(--t-divider)"},children:[a.jsx("span",{className:"text-[13px]",style:{color:"var(--t-text-secondary)"},children:e}),a.jsx("span",{className:`text-[13px] font-medium ${n?"font-mono":""}`,style:{color:r?"var(--t-success, #10b981)":"var(--t-text)"},children:t})]})}function Jl({isOpen:e,onClose:t,children:n}){const[r,l]=E.useState(!1),[o,i]=E.useState(!1);E.useEffect(()=>{if(e)l(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>i(!0)));else if(r){i(!1);const u=setTimeout(()=>l(!1),250);return()=>clearTimeout(u)}},[e]);const s=E.useCallback(()=>{i(!1),setTimeout(()=>t(),250)},[t]);return E.useEffect(()=>{if(!e)return;const u=c=>{c.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),r?a.jsx("div",{className:"absolute inset-0 z-20 transition-opacity duration-250",style:{opacity:o?1:0},children:a.jsx("div",{className:"absolute inset-0 flex flex-col transition-transform duration-250 ease-out",style:{background:"var(--t-modal-bg)",transform:o?"translateY(0)":"translateY(24px)"},children:typeof n=="function"?n(s):n})}):null}function Pm({char:e,height:t=38}){const n="0123456789",r=n.indexOf(e);return r===-1?a.jsx("span",{children:e}):a.jsx("span",{className:"digit-slot",style:{height:t,lineHeight:`${t}px`},children:a.jsx("span",{className:"digit-slot-inner block",style:{transform:`translateY(-${r*t}px)`},children:n.split("").map(l=>a.jsx("span",{className:"block",style:{height:t,lineHeight:`${t}px`},children:l},l))})})}function Lm({value:e,height:t=38,className:n="",style:r={}}){return a.jsx("span",{className:n,style:{display:"inline-flex",...r},children:e.split("").map((l,o)=>a.jsx(Pm,{char:l,height:t},o))})}function Ve({w:e,h:t,className:n=""}){return a.jsx("div",{className:`skeleton ${n}`,style:{width:e,height:t}})}function Im(){return a.jsxs("div",{className:"flex-1 px-5 flex flex-col",children:[a.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5},children:[a.jsx(Ve,{w:70,h:14,className:"mb-3"}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx(Ve,{w:120,h:32}),a.jsx(Ve,{w:75,h:32})]})]}),a.jsxs("div",{className:"px-[18px] pt-[12px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,marginTop:4},children:[a.jsx(Ve,{w:50,h:14,className:"mb-3"}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx(Ve,{w:180,h:32}),a.jsx(Ve,{w:85,h:32})]})]}),a.jsxs("div",{className:"flex justify-between mt-3 px-[2px]",children:[a.jsx(Ve,{w:140,h:12}),a.jsx(Ve,{w:90,h:12})]}),a.jsxs("div",{className:"mt-8",children:[a.jsx(Ve,{w:65,h:14,className:"mb-2.5"}),a.jsx(Ve,{w:"100%",h:47})]}),a.jsx("div",{className:"flex-1"}),a.jsx(Ve,{w:"100%",h:60,className:"mb-2"}),a.jsx("div",{className:"text-center py-3",children:a.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]})}function ql({onClick:e}){return a.jsx("button",{onClick:e,className:"flex items-center justify-center transition-colors rounded-full shrink-0",style:{width:30,height:30,backgroundColor:"var(--t-close-bg)"},onMouseEnter:t=>t.currentTarget.style.backgroundColor="var(--t-close-hover)",onMouseLeave:t=>t.currentTarget.style.backgroundColor="var(--t-close-bg)",children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:a.jsx("path",{d:"M1 1L9 9M9 1L1 9",stroke:"var(--t-icon-close)",strokeWidth:"1.4",strokeLinecap:"round"})})})}function ks({value:e,onChange:t,placeholder:n=""}){return a.jsxs("div",{className:"relative mx-5 mb-5",children:[a.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,style:{height:47,borderRadius:4.5,border:"1px solid var(--t-border)",color:"var(--t-text)",padding:`0 ${e?40:14}px 0 14px`,fontSize:14,backgroundColor:"transparent"},className:"w-full outline-none transition-colors"}),e&&a.jsx("button",{onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center transition-colors rounded",style:{width:22,height:22,backgroundColor:"var(--t-close-bg)",borderRadius:4},children:a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:a.jsx("path",{d:"M1 1L7 7M7 1L1 7",stroke:"var(--t-icon-close)",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}function Mm({onClose:e,onSelect:t,currencies:n,assetBaseUrl:r=""}){const[l,o]=E.useState(""),i=E.useMemo(()=>{if(!n||n.length===0)return td;const u=new Map(td.map(c=>[c.code,c.name]));return n.map(c=>({code:c.code,name:c.name||u.get(c.code)||c.code}))},[n]),s=E.useMemo(()=>{const u=l.trim().toLowerCase();return u?i.filter(c=>c.code.toLowerCase().includes(u)||c.name.toLowerCase().includes(u)):i},[i,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Select fiat currency"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(u=>a.jsxs("button",{onClick:()=>t(u.code),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",style:{color:"var(--t-text)"},children:[a.jsx(Ss,{currencyCode:u.code,size:32,baseUrl:r}),a.jsxs("div",{className:"text-left",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",children:u.code}),a.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:u.name})]})]},u.code)),s.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function _m({onClose:e,onSelect:t,cryptos:n,assetBaseUrl:r=""}){const[l,o]=E.useState(""),i=E.useMemo(()=>{if(!n||n.length===0)return cm;const u=[];for(const c of n){const h=c.networks||[];if(h.length===0)u.push({code:c.code,name:c.name||c.code,chain:c.code,popular:!1});else for(const m of h){const y=m.code||m.id||m.name||c.code;u.push({code:c.code,name:c.name||c.code,chain:y,chainName:m.name,popular:!1})}}return u},[n]),s=E.useMemo(()=>{var m;const u=l.trim().toLowerCase();if(!u)return i;const c=u.split(/\s+/),h=[];for(const y of i){const x=Zl(y.chain),g=x?x.name.toLowerCase():"",S=((m=x==null?void 0:x.shortName)==null?void 0:m.toLowerCase())||"",L=y.chain.toLowerCase(),f=y.code.toLowerCase(),d=y.name.toLowerCase(),p=[f,d,g,S,L];if(!c.every(R=>p.some(v=>v.includes(R))))continue;let C=0;f===u?C+=100:f.startsWith(c[0])&&(C+=50),y.popular&&(C+=10),c.length>1&&(g.includes(c[1])||S.includes(c[1])||L.includes(c[1]))&&(C+=25),h.push({item:y,score:C})}return h.sort((y,x)=>x.score-y.score),h.map(y=>y.item)},[i,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Select crypto currency"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[s.map(u=>{const c=Zl(u.chain),h=(c==null?void 0:c.name)||u.chainName||u.chain;return a.jsxs("button",{onClick:()=>t(u.code,u.chain),className:"flex items-center gap-3.5 w-full py-3.5 transition-colors",children:[a.jsxs("div",{className:"relative shrink-0",style:{width:40,height:40},children:[a.jsx("img",{src:ed(u.code,r),alt:u.code,width:32,height:32,className:"rounded-full absolute top-0 left-0",style:{width:32,height:32}}),a.jsx("img",{src:xs(u.chain,r),alt:u.chain,width:16,height:16,className:"rounded-full absolute",style:{width:16,height:16,bottom:0,right:0,border:"2px solid var(--t-chain-border)"}})]}),a.jsxs("div",{className:"text-left flex-1 min-w-0",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:"var(--t-text)"},children:u.code}),a.jsx("div",{className:"text-[13px] mt-0.5",style:{color:"var(--t-text-secondary)"},children:u.name})]}),a.jsx("div",{className:"text-right shrink-0",children:a.jsx("div",{className:"text-[13px]",style:{color:"var(--t-text-muted)"},children:h})})]},`${u.code}-${u.chain}`)}),s.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No currencies found"})]})]})}function Om({methods:e,selectedId:t,onSelect:n,onClose:r}){const[l,o]=E.useState(""),i=E.useMemo(()=>{const s=l.trim().toLowerCase();return s?e.filter(u=>u.id.toLowerCase().includes(s)||u.name.toLowerCase().includes(s)||u.description&&u.description.toLowerCase().includes(s)):e},[e,l]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end px-5 pt-5",children:a.jsx(ql,{onClick:r})}),a.jsx("h2",{className:"text-center text-[17px] font-medium mt-2 mb-6",style:{color:"var(--t-text)",fontSize:17,fontWeight:500,marginTop:8,marginBottom:24},children:"Choose payment method"}),a.jsx(ks,{value:l,onChange:o}),a.jsxs("div",{className:"flex-1 overflow-y-auto custom-scroll px-5",children:[i.map((s,u)=>{const c=s.id===t,h=sd(s.id,s.name);return a.jsxs("button",{onClick:()=>n(s.id),className:"flex items-start gap-3.5 w-full py-4 transition-colors",style:{color:"var(--t-text)",borderBottom:u<i.length-1?"1px solid var(--t-divider, rgba(128,128,128,0.12))":"none"},children:[a.jsx("span",{className:"flex items-center justify-center shrink-0 mt-0.5",style:{width:32,height:32},children:ad(s.id,s.icon,32)}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsx("div",{className:"font-semibold text-[15px] leading-tight",style:{color:c?"var(--t-accent)":"var(--t-text)"},children:h}),s.description&&a.jsx("div",{className:"text-[13px] leading-snug mt-1",style:{color:"var(--t-text-muted)"},children:s.description})]})]},s.id)}),i.length===0&&a.jsx("div",{className:"text-center py-10 text-[14px]",style:{color:"var(--t-text-muted)"},children:"No payment methods found"})]})]})}function Dm({checked:e,onChange:t,accentColor:n="var(--t-accent)"}){return a.jsx("button",{onClick:()=>t(!e),className:"relative shrink-0 transition-colors duration-200",style:{width:48,height:28,borderRadius:14,backgroundColor:e?n:"var(--t-border)"},children:a.jsx("div",{className:"absolute top-[3px] rounded-full bg-white shadow transition-transform duration-200",style:{width:22,height:22,transform:e?"translateX(23px)":"translateX(3px)"}})})}const Bm=[{label:"Privacy policy",href:"https://nowramp.com/privacy-policy"},{label:"Terms of use",href:"https://nowramp.com/terms-and-conditions"}];function Fm({onClose:e,darkMode:t,onToggleDarkMode:n,skinId:r,onSelectSkin:l}){return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end items-center px-5 pt-5",children:a.jsx(ql,{onClick:e})}),a.jsxs("div",{className:"px-5 flex-1 pt-6 overflow-y-auto custom-scroll",children:[a.jsx("div",{style:{borderTop:"1px solid var(--t-divider)"},children:a.jsxs("div",{className:"flex items-center justify-between w-full py-5",children:[a.jsxs("div",{className:"flex items-center gap-3.5",children:[a.jsx(xm,{size:40}),a.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:"Dark Mode"})]}),a.jsx(Dm,{checked:t,onChange:n,accentColor:"#4CD964"})]})}),a.jsx("div",{style:{height:1,background:"var(--t-divider)"}}),Bm.map(o=>a.jsxs("div",{children:[a.jsxs("a",{href:o.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between w-full py-5 transition-colors",style:{color:"inherit",textDecoration:"none"},children:[a.jsx("span",{className:"font-medium text-[15px]",style:{color:"var(--t-text)"},children:o.label}),a.jsx(vm,{})]}),a.jsx("div",{style:{height:1,background:"var(--t-divider)"}})]},o.label))]})]})}function Um({className:e="",theme:t="dark",skinId:n="mono",accentColor:r,bgColor:l,bgImage:o,borderColor:i,borderRadius:s,showFlowToggle:u=!0,autoRedirect:c=!1,explorerUrl:h,doneButtonText:m="Done",supportEmail:y,onDone:x}){var xd,wd,Sd,kd,Ed,Cd,Nd,Td;const{state:g,dispatch:S,config:L,configLoading:f,quotes:d,quotesLoading:p,quotesError:w,fetchQuotes:C,createOrder:R,orderLoading:v,amountError:T,fieldLocks:P,apiConfig:A,assetBaseUrl:G}=Dn(),[fe,pe]=E.useState(t==="dark"),[rn,ln]=E.useState(n),[lt,ge]=E.useState(null),[N,I]=E.useState(!1),[M,H]=E.useState(!1),[W,ht]=E.useState(!1),[ae,qe]=E.useState(null),[Ce,yt]=E.useState(!0),[bl,eo]=E.useState(!1),[Ht,Fn]=E.useState(!1),Es=E.useRef(null),Ir=E.useRef(),D=E.useRef(g.flowType);E.useEffect(()=>{pe(t==="dark")},[t]),E.useEffect(()=>{const _=setTimeout(()=>yt(!1),f?0:800);return()=>clearTimeout(_)},[f]),E.useEffect(()=>{if(D.current!==g.flowType&&!Ce){D.current=g.flowType,eo(!0),I(!1),H(!1);const _=setTimeout(()=>eo(!1),350);return()=>clearTimeout(_)}D.current=g.flowType},[g.flowType,Ce]);const z=g.flowType,ee=z==="buy",Z=g.cryptoCurrency||"BTC",Q=g.fiatCurrency||"USD",Pe=ee?g.fiatAmount:g.cryptoAmount,Le=um(Pe),vt=(xd=d==null?void 0:d.bestQuote)!=null&&xd.exchangeRate?parseFloat(d.bestQuote.exchangeRate):null,to=E.useRef(null);vt&&Z&&Q&&(to.current={rate:vt,crypto:Z,fiat:Q});const $m=E.useMemo(()=>{if(d!=null&&d.bestQuote){const _=ee?d.bestQuote.cryptoAmount:d.bestQuote.fiatAmount;if(_)return _}return"0"},[d,ee]),Km=E.useMemo(()=>{var xe,zt,Ts;const _=vt||((xe=to.current)==null?void 0:xe.rate),F=vt?Z:(zt=to.current)==null?void 0:zt.crypto,X=vt?Q:(Ts=to.current)==null?void 0:Ts.fiat;return!_||!F||!X?"":`1 ${F} ≈ ${_.toFixed(2)} ${X}`},[Z,Q,vt]);E.useEffect(()=>{const _=g.walletAddress.trim(),F=g.network;if(!_||_.length<10){qe(null),S({type:"SET_WALLET_ERROR",message:""});return}return ht(!0),qe(null),clearTimeout(Ir.current),Ir.current=setTimeout(async()=>{var X,xe,zt;try{const js=await(await fetch(`${A.apiUrl}/public/validate/address`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:_,...F?{network:F}:{}})})).json(),Rs=((X=js.data)==null?void 0:X.attributes)||js.data||js;if(Rs.isValid)qe(!0),S({type:"SET_WALLET_ERROR",message:""});else{qe(!1);const Jm=((xe=Rs.errors)==null?void 0:xe[0])||((zt=Rs.details)==null?void 0:zt.formatMessage)||"Invalid wallet address";S({type:"SET_WALLET_ERROR",message:Jm})}}catch{qe(null)}finally{ht(!1)}},500),()=>clearTimeout(Ir.current)},[g.walletAddress,g.network,A.apiUrl]);const dd=!Pe||Le===0,fd=Le>0&&(ee?Le<rd:Le<ld),pd=!!T||fd||N&&dd,Vm=Le>0&&!T&&!fd,Cs=g.walletAddress.trim().length>=10&&ae!==!1&&!W,no=Vm&&Cs&&!!g.cryptoCurrency&&!!g.network,Wm=_=>{let F=_.target.value.replace(/[^0-9.,]/g,"");const X=ee?2:6,xe=F.indexOf(".");xe!==-1&&F.length-xe-1>X&&(F=F.slice(0,xe+X+1)),S(ee?{type:"SET_FIAT_AMOUNT",amount:F}:{type:"SET_CRYPTO_AMOUNT",amount:F})},md=_=>{_!==z&&S({type:"SET_FLOW_TYPE",flowType:_})},Qm=E.useCallback(_=>{S({type:"SET_FIAT_CURRENCY",currency:_})},[S]),Xm=E.useCallback((_,F)=>{S({type:"SET_CRYPTO_CURRENCY",currency:_}),S({type:"SET_CRYPTO_CHAIN",chain:F})},[S]),Ym=E.useCallback(_=>{S({type:"SET_PAYMENT_METHOD",methodId:_})},[S]),Gm=()=>{no&&(Fn(!0),C())};E.useEffect(()=>{var _;if(!(!Ht||p)){if(d!=null&&d.bestQuote)Fn(!1),S({type:"SELECT_QUOTE",quote:d.bestQuote}),R().catch(()=>{});else if(w)Fn(!1),S({type:"SET_ERROR",message:w.message||"No quotes available"});else if(d&&!d.bestQuote){Fn(!1);const F=(_=d.unavailableGateways)==null?void 0:_.map(xe=>xe.reason).filter(Boolean),X=F!=null&&F.length?`No providers available: ${F.join("; ")}`:"No providers available for this currency/network combination";S({type:"SET_ERROR",message:X})}}},[Ht,d,p,w,S,R]);const hd=fe?"theme-dark":"theme-light",Ns=nd.find(_=>_.id===rn)||nd[0],Zm=Ns.accent===null,yd=(r?ws(r):!1)?{"--t-accent":r,"--t-cta-bg":r,"--t-cta-text":"#ffffff"}:Zm?{"--t-accent":fe?"#ffffff":"#111111","--t-cta-bg":fe?"#ffffff":"#111111","--t-cta-text":fe?"#000000":"#ffffff"}:{"--t-accent":Ns.accent,"--t-cta-bg":Ns.accent,"--t-cta-text":"#ffffff"},on={};l&&ws(l)?on.backgroundColor=l:on.backgroundColor="var(--t-bg)",o&&(on.backgroundImage=`url(${o})`,on.backgroundSize="cover",on.backgroundPosition="center");const ro={};i&&ws(i)&&(ro.border=`1px solid ${i}`),s&&(ro.borderRadius=s);const vd=g.step==="checkout"?a.jsx(Cm,{autoRedirect:c}):g.step==="processing"?a.jsx(Tm,{}):g.step==="complete"?a.jsx(jm,{explorerUrl:h,doneButtonText:m,onDone:x}):g.step==="error"?a.jsx(Rm,{supportEmail:y}):g.step==="confirm"?a.jsx(Am,{}):null;if(vd)return a.jsx("div",{className:`${hd} relative w-full max-w-[390px] h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...on,...yd,...ro},children:vd});const gt=g.network,Un=gt?Zl(gt):null,gd=(Un==null?void 0:Un.shortName)||(Un==null?void 0:Un.name)||gt;return a.jsxs("div",{className:`${hd} relative w-full max-w-[390px] min-h-[640px] overflow-hidden flex flex-col select-none transition-colors duration-300 ${e}`,style:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...on,...yd,...ro},children:[a.jsx("div",{className:`flex justify-end items-center px-5 pt-3 ${u?"pb-1":"pb-5"}`,children:a.jsx(gm,{onClick:()=>ge("settings")})}),u?a.jsxs("div",{className:"flex flex-col items-center pt-3 pb-5",children:[a.jsxs("div",{className:"flex",style:{width:165},children:[a.jsx("button",{onClick:()=>md("buy"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:z==="buy"?"var(--t-text)":"var(--t-text-secondary)"},children:"Buy"}),a.jsx("button",{onClick:()=>md("sell"),className:"flex-1 pb-2.5 text-[16px] font-medium text-center transition-colors duration-200",style:{color:z==="sell"?"var(--t-text)":"var(--t-text-secondary)"},children:"Sell"})]}),a.jsxs("div",{className:"relative",style:{width:165,height:1},children:[a.jsx("div",{className:"absolute inset-0",style:{background:"var(--t-divider)"}}),a.jsx("div",{className:"absolute top-0 h-full transition-all duration-300 ease-in-out",style:{width:"50%",left:z==="buy"?"0%":"50%",background:"var(--t-accent)"}})]})]}):null,Ce||bl||f?a.jsx(Im,{}):a.jsxs("div",{className:"flex-1 overflow-hidden px-5 flex flex-col tab-fade-in",children:[a.jsxs("div",{className:"px-[18px] pt-[14px] pb-[18px]",style:{background:"var(--t-surface)",borderRadius:5,border:N&&pd?"1px solid #EF4444":"1px solid transparent",minHeight:102},children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You spend"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("input",{ref:Es,type:"text",value:Pe,onChange:Wm,onBlur:()=>I(!0),placeholder:ee?"250":"0.01",className:"bg-transparent outline-none w-0 flex-1 mr-3",style:{color:"var(--t-text)",fontSize:24,fontWeight:600,lineHeight:"32px",padding:0,border:"none",borderRadius:0,backgroundColor:"transparent",height:"auto",width:0},inputMode:"decimal",disabled:!!((wd=P==null?void 0:P.sourceAmount)!=null&&wd.locked)}),ee?a.jsxs("button",{onClick:()=>ge("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Sd=P==null?void 0:P.sourceCurrency)!=null&&Sd.locked),children:[a.jsx(Ss,{currencyCode:Q,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Q}),a.jsx(Pr,{})]}):a.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[a.jsxs("button",{onClick:()=>ge("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((kd=P==null?void 0:P.destinationCurrency)!=null&&kd.locked),children:[a.jsx(od,{ticker:Z,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Z}),a.jsx(Pr,{})]}),gt&&a.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[a.jsx("img",{src:xs(gt,G),alt:gt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:gd})]})]})]})]}),N&&pd&&a.jsx("div",{className:"text-[12px] mt-1.5 px-[2px]",style:{color:"#EF4444"},children:T||(dd?"Amount should be more than 0":ee?`Minimum amount is ${rd} ${Q}`:`Minimum amount is ${ld} ${Z}`)}),a.jsxs("div",{className:"px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",borderTopLeftRadius:5,borderTopRightRadius:5,borderBottomLeftRadius:0,borderBottomRightRadius:0,marginTop:4,minHeight:102},children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:"You get"}),a.jsxs("div",{className:"flex items-start justify-between",children:[p?a.jsx(Ve,{w:180,h:32}):a.jsx(Lm,{value:Le>0?$m:"0",height:32,className:"font-semibold",style:{color:Le>0?"var(--t-text)":"var(--t-text-muted)",fontSize:24}}),ee?a.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[a.jsxs("button",{onClick:()=>ge("crypto"),className:"flex items-center gap-1.5 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Ed=P==null?void 0:P.destinationCurrency)!=null&&Ed.locked),children:[a.jsx(od,{ticker:Z,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Z}),a.jsx(Pr,{})]}),gt&&a.jsxs("div",{className:"flex items-center gap-1 mt-1.5 mr-0.5",children:[a.jsx("img",{src:xs(gt,G),alt:gt,width:14,height:14,className:"rounded-full",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-muted)"},children:gd})]})]}):a.jsxs("button",{onClick:()=>ge("fiat"),className:"flex items-center gap-1.5 shrink-0 transition-colors",style:{background:"var(--t-pill-bg)",borderRadius:4,height:32,paddingLeft:10,paddingRight:10},disabled:!!((Cd=P==null?void 0:P.sourceCurrency)!=null&&Cd.locked),children:[a.jsx(Ss,{currencyCode:Q,size:16,baseUrl:G}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--t-text)"},children:Q}),a.jsx(Pr,{})]})]})]}),a.jsx("div",{className:"flex items-center justify-between mt-[2px] px-[18px] pt-[12px] pb-[14px]",style:{background:"var(--t-surface)",...(Nd=L==null?void 0:L.paymentMethods)!=null&&Nd.length?{}:{borderBottomLeftRadius:5,borderBottomRightRadius:5}},children:a.jsx("span",{className:"text-[12px]",style:{color:"var(--t-text-secondary)"},children:Km||" "})}),(L==null?void 0:L.paymentMethods)&&L.paymentMethods.length>0&&a.jsx("div",{className:"mt-[2px]",children:a.jsx(Em,{methods:L.paymentMethods,selectedId:g.paymentMethodId,onOpenModal:()=>ge("payment"),fiatCurrency:g.fiatCurrency})}),a.jsxs("div",{className:"mt-8",children:[a.jsx("div",{className:"text-[13px] mb-2.5",style:{color:"var(--t-text-secondary)"},children:ee?"Receiving wallet address":"Sending wallet address"}),a.jsx("input",{type:"text",value:g.walletAddress,onChange:_=>S({type:"SET_WALLET_ADDRESS",address:_.target.value}),onBlur:()=>H(!0),placeholder:ee?"Enter your receiving address":"Enter your sending address",spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-[13px] outline-none transition-colors",style:{border:g.walletError||M&&!Cs?"1px solid #EF4444":"1px solid var(--t-border)",borderRadius:3.5,height:47,padding:"0 14px",color:"var(--t-text)",fontSize:13,backgroundColor:"transparent"},disabled:!!((Td=P==null?void 0:P.destinationAddress)!=null&&Td.locked)}),g.walletError?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:g.walletError}):M&&!Cs&&!W?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"#EF4444"},children:"Enter a valid wallet address"}):W&&g.walletAddress.trim().length>=10?a.jsx("div",{className:"text-[12px] mt-1.5",style:{color:"var(--t-text-muted)"},children:"Validating address..."}):null]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{disabled:!no||v||Ht,onClick:Gm,className:"w-full font-semibold text-[16px] transition-all",style:{height:60,borderRadius:5,background:"var(--t-cta-bg)",color:"var(--t-cta-text)",opacity:no&&!v&&!Ht?1:.4,cursor:no&&!v&&!Ht?"pointer":"not-allowed"},children:Ht?"Getting best price...":v?"Processing...":ee?`Buy ${Z}`:`Sell ${Z}`}),a.jsx("div",{className:"text-center py-3",children:a.jsx("span",{className:"text-[11px]",style:{color:"var(--t-text-tertiary)"},children:"Powered by NowRamp"})})]},z),a.jsx(Jl,{isOpen:lt==="fiat",onClose:()=>ge(null),children:_=>{var F;return a.jsx(Mm,{onClose:_,onSelect:X=>{Qm(X),_()},currencies:(F=L==null?void 0:L.fiats)==null?void 0:F.map(X=>({code:X.code,name:X.code})),assetBaseUrl:G})}}),a.jsx(Jl,{isOpen:lt==="crypto",onClose:()=>ge(null),children:_=>{var F;return a.jsx(_m,{onClose:_,onSelect:(X,xe)=>{Xm(X,xe),_()},cryptos:(F=L==null?void 0:L.cryptos)==null?void 0:F.map(X=>{var xe;return{code:X.code,name:X.code,networks:(xe=X.networks)==null?void 0:xe.map(zt=>({code:zt.id,name:zt.name}))}}),assetBaseUrl:G})}}),a.jsx(Jl,{isOpen:lt==="payment",onClose:()=>ge(null),children:_=>{var F;return a.jsx(Om,{methods:((F=L==null?void 0:L.paymentMethods)==null?void 0:F.filter(X=>X.supportedFiats.includes(g.fiatCurrency)))||[],selectedId:g.paymentMethodId,onSelect:X=>{Ym(X),_()},onClose:_})}}),a.jsx(Jl,{isOpen:lt==="settings",onClose:()=>ge(null),children:_=>a.jsx(Fm,{onClose:_,darkMode:fe,onToggleDarkMode:pe,skinId:rn,onSelectSkin:F=>{ln(F)}})})]})}function cd({projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:u,defaultCryptoAmount:c,defaultWalletAddress:h,defaultGateway:m,fieldLocks:y,statusPollInterval:x,onComplete:g,onError:S,className:L,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:R,borderRadius:v,showFlowToggle:T,autoRedirect:P,explorerUrl:A,doneButtonText:G,supportEmail:fe,onDone:pe}){return a.jsx(om,{projectId:e,apiUrl:t,assetBaseUrl:n,flowType:r,customerId:l,defaultFiatCurrency:o,defaultCryptoCurrency:i,defaultNetwork:s,defaultFiatAmount:u,defaultCryptoAmount:c,defaultWalletAddress:h,defaultGateway:m,fieldLocks:y,statusPollInterval:x,onComplete:g,onError:S,children:a.jsx(Um,{className:L,theme:f,skinId:d,accentColor:p,bgColor:w,bgImage:C,borderColor:R,borderRadius:v,showFlowToggle:T,autoRedirect:P,explorerUrl:A,doneButtonText:G,supportEmail:fe,onDone:pe})})}const Lr=new Map;function Hm(e,t){const n=typeof e=="string"?document.querySelector(e):e;if(!n){console.error(`[NowRampForm] Element not found: ${e}`);return}const r=Lr.get(n);r&&(r.unmount(),Lr.delete(n));const l=Xc(n);Lr.set(n,l),l.render(zn.createElement(cd,t))}function zm(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)return;const n=Lr.get(t);n&&(n.unmount(),Lr.delete(t))}Mr.RampForm=cd,Mr.mount=Hm,Mr.unmount=zm,Object.defineProperty(Mr,Symbol.toStringTag,{value:"Module"})})(this.NowRampForm=this.NowRampForm||{});
55
55
  //# sourceMappingURL=nowramp-form.iife.js.map