@unifold/connect-react-native 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stripe.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var react=require('react'),reactNative=require('react-native'),stripeReactNative=require('@stripe/stripe-react-native'),jsxRuntime=require('react/jsx-runtime'),fn=require('react-native-svg');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fn__default=/*#__PURE__*/_interopDefault(fn);var Jr="#00D924",Zr="#000000",Xr="#1C1C1E",It="#FFFFFF",Bt="#8E8E93",nr="#636366",en=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function ht({initialAmount:e="",currency:a="USD",onConfirm:o,onCancel:l}){let[c,x]=react.useState(e),B=T=>{if(T==="\u232B"){x(S=>S.slice(0,-1));return}if(T==="."){if(c.includes("."))return;x(S=>S===""?"0.":S+".");return}x(S=>{let k=S.indexOf(".");return k!==-1&&S.length-k>2?S:S==="0"&&T!=="."?T:S+T});},L=c===""?"0":c,D=parseFloat(c),W=c!==""&&!isNaN(D)&&D>0;return jsxRuntime.jsxs(reactNative.View,{style:I.screen,children:[jsxRuntime.jsxs(reactNative.View,{style:I.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:I.cancelBtn,onPress:l,children:jsxRuntime.jsx(reactNative.Text,{style:I.cancelText,children:"Cancel"})}),jsxRuntime.jsx(reactNative.Text,{style:I.headerTitle,children:"Enter amount"}),jsxRuntime.jsx(reactNative.View,{style:{width:64}})]}),jsxRuntime.jsxs(reactNative.View,{style:I.amountContainer,children:[jsxRuntime.jsxs(reactNative.Text,{style:[I.amountText,L==="0"&&I.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",L]}),jsxRuntime.jsx(reactNative.Text,{style:I.currencyLabel,children:a.toUpperCase()})]}),jsxRuntime.jsx(reactNative.View,{style:I.numpad,children:en.map((T,S)=>jsxRuntime.jsx(reactNative.View,{style:I.numpadRow,children:T.map(k=>jsxRuntime.jsx(reactNative.TouchableOpacity,{style:I.numpadKey,onPress:()=>B(k),activeOpacity:.6,children:jsxRuntime.jsx(reactNative.Text,{style:k==="\u232B"?I.backspaceText:I.numpadKeyText,children:k})},k))},S))}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[I.confirmBtn,!W&&I.confirmBtnDisabled],onPress:()=>W&&o(c),disabled:!W,children:jsxRuntime.jsx(reactNative.Text,{style:[I.confirmBtnText,!W&&I.confirmBtnTextDisabled],children:"Continue"})})]})}var I=reactNative.StyleSheet.create({screen:{flex:1,backgroundColor:Zr,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:8},cancelBtn:{width:64},cancelText:{color:Bt,fontSize:16,fontWeight:"500"},headerTitle:{color:It,fontSize:17,fontWeight:"700"},amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,fontWeight:"300",color:It,letterSpacing:-2,minWidth:80,textAlign:"center"},amountPlaceholder:{color:nr},currencyLabel:{fontSize:15,color:Bt,letterSpacing:1,fontWeight:"500"},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",borderRadius:16,marginHorizontal:4},numpadKeyText:{fontSize:28,fontWeight:"400",color:It},backspaceText:{fontSize:22,color:Bt},confirmBtn:{backgroundColor:Jr,borderRadius:24,paddingVertical:18,alignItems:"center"},confirmBtnDisabled:{backgroundColor:Xr},confirmBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},confirmBtnTextDisabled:{color:nr}});var Lt="#00D924",sn="#000000",_t="#1C1C1E",or="#38383A",Nt="#FFFFFF",ct="#8E8E93",j="#636366",lt=4;function bt({initialData:e={},loading:a=false,onComplete:o,onCancel:l}){let[c,x]=react.useState(1),[B,L]=react.useState(e.firstName??""),[D,W]=react.useState(e.lastName??""),[T,S]=react.useState(e.dobMonth??""),[k,O]=react.useState(e.dobDay??""),[y,N]=react.useState(e.dobYear??""),[b,Ve]=react.useState(e.addressLine1??""),[m,ge]=react.useState(e.addressLine2??""),[te,C]=react.useState(e.city??""),[se,M]=react.useState(e.state??""),[ve,Le]=react.useState(e.postalCode??""),[Ae,Re]=react.useState(e.country??"US"),[Ee,Ne]=react.useState(e.idNumber??""),Fe=react.useRef(null),K=react.useRef(null),ze=react.useRef(null),he=react.useRef(null),_e=react.useRef(null),Ye=react.useRef(null),be=react.useRef(null),De=react.useRef(null),ae=()=>{switch(c){case 1:return B.trim().length>0&&D.trim().length>0;case 2:return T.length===2&&k.length===2&&y.length===4;case 3:return b.trim().length>0&&te.trim().length>0&&se.trim().length>0&&ve.trim().length>0;case 4:return Ee.trim().length>0;default:return false}},re=()=>{ae()&&(c<lt?x(w=>w+1):o({firstName:B,lastName:D,idNumber:Ee,dobMonth:T,dobDay:k,dobYear:y,addressLine1:b,addressLine2:m,city:te,state:se,postalCode:ve,country:Ae}));},F=()=>{c>1?x(w=>w-1):l();},h=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],U=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."];return jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:p.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:p.screen,children:[jsxRuntime.jsxs(reactNative.View,{style:p.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:p.backBtn,onPress:F,children:jsxRuntime.jsx(reactNative.Text,{style:p.backBtnText,children:"\u2039"})}),jsxRuntime.jsxs(reactNative.Text,{style:p.stepCounter,children:[c," of ",lt]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:p.closeBtn,onPress:l,children:jsxRuntime.jsx(reactNative.Text,{style:p.closeText,children:"\u2715"})})]}),jsxRuntime.jsx(reactNative.View,{style:p.progressTrack,children:Array.from({length:lt}).map((w,V)=>jsxRuntime.jsx(reactNative.View,{style:[p.progressSegment,V<c&&p.progressSegmentDone,V+1===c&&p.progressSegmentActive]},V))}),jsxRuntime.jsxs(reactNative.ScrollView,{style:p.flex,contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",children:[jsxRuntime.jsx(reactNative.Text,{style:p.title,children:h[c-1]}),jsxRuntime.jsx(reactNative.Text,{style:p.subtitle,children:U[c-1]}),c===1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Te,{label:"First name",children:jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"Jane",placeholderTextColor:j,value:B,onChangeText:L,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Fe.current?.focus()})}),jsxRuntime.jsx(Te,{label:"Last name",children:jsxRuntime.jsx(reactNative.TextInput,{ref:Fe,style:p.input,placeholder:"Doe",placeholderTextColor:j,value:D,onChangeText:W,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:re})})]}),c===2&&jsxRuntime.jsxs(reactNative.View,{style:p.dobRow,children:[jsxRuntime.jsxs(reactNative.View,{style:p.dobCol,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Month"}),jsxRuntime.jsx(reactNative.TextInput,{style:[p.input,p.dobInput],placeholder:"MM",placeholderTextColor:j,value:T,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);S(V),V.length===2&&K.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxRuntime.jsxs(reactNative.View,{style:p.dobCol,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Day"}),jsxRuntime.jsx(reactNative.TextInput,{ref:K,style:[p.input,p.dobInput],placeholder:"DD",placeholderTextColor:j,value:k,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);O(V),V.length===2&&ze.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxRuntime.jsxs(reactNative.View,{style:p.dobColWide,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Year"}),jsxRuntime.jsx(reactNative.TextInput,{ref:ze,style:[p.input,p.dobInput],placeholder:"YYYY",placeholderTextColor:j,value:y,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,4);N(V);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:re})]})]}),c===3&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Te,{label:"Street address",children:jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"123 Main St",placeholderTextColor:j,value:b,onChangeText:Ve,returnKeyType:"next",onSubmitEditing:()=>he.current?.focus()})}),jsxRuntime.jsx(Te,{label:"Apt, suite, etc. (optional)",children:jsxRuntime.jsx(reactNative.TextInput,{ref:he,style:p.input,placeholder:"Apt 2",placeholderTextColor:j,value:m,onChangeText:ge,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsxRuntime.jsx(Te,{label:"City",children:jsxRuntime.jsx(reactNative.TextInput,{ref:_e,style:p.input,placeholder:"San Francisco",placeholderTextColor:j,value:te,onChangeText:C,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Ye.current?.focus()})}),jsxRuntime.jsxs(reactNative.View,{style:p.row,children:[jsxRuntime.jsx(reactNative.View,{style:[p.flex,{marginRight:8}],children:jsxRuntime.jsx(Te,{label:"State",children:jsxRuntime.jsx(reactNative.TextInput,{ref:Ye,style:p.input,placeholder:"NY",placeholderTextColor:j,value:se,onChangeText:w=>M(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})})}),jsxRuntime.jsx(reactNative.View,{style:p.flex,children:jsxRuntime.jsx(Te,{label:"ZIP code",children:jsxRuntime.jsx(reactNative.TextInput,{ref:be,style:p.input,placeholder:"11201",placeholderTextColor:j,value:ve,onChangeText:Le,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>De.current?.focus()})})})]}),jsxRuntime.jsx(Te,{label:"Country",children:jsxRuntime.jsx(reactNative.TextInput,{ref:De,style:p.input,placeholder:"US",placeholderTextColor:j,value:Ae,onChangeText:w=>Re(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:re})})]}),c===4&&jsxRuntime.jsxs(Te,{label:"Social Security Number",children:[jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"123-45-6789",placeholderTextColor:j,value:Ee,onChangeText:Ne,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:re}),jsxRuntime.jsx(reactNative.Text,{style:p.ssnHint,children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsxRuntime.jsx(reactNative.View,{style:p.footer,children:a&&c===lt?jsxRuntime.jsx(reactNative.View,{style:p.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#000"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[p.continueBtn,!ae()&&p.continueBtnDisabled],onPress:re,disabled:!ae(),children:jsxRuntime.jsx(reactNative.Text,{style:[p.continueBtnText,!ae()&&p.continueBtnTextDisabled],children:c===lt?"Submit":"Continue"})})})]})})}function Te({label:e,children:a}){return jsxRuntime.jsxs(reactNative.View,{style:ir.container,children:[jsxRuntime.jsx(reactNative.Text,{style:ir.label,children:e}),a]})}var ir=reactNative.StyleSheet.create({container:{marginBottom:20},label:{fontSize:13,color:ct,marginBottom:8,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5}}),p=reactNative.StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:sn},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingHorizontal:20,paddingBottom:16},backBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},backBtnText:{color:Nt,fontSize:22,marginTop:-1},stepCounter:{color:ct,fontSize:15,fontWeight:"600"},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},closeText:{color:ct,fontSize:14,fontWeight:"600"},progressTrack:{flexDirection:"row",gap:4,paddingHorizontal:20,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2,backgroundColor:or},progressSegmentDone:{backgroundColor:Lt},progressSegmentActive:{backgroundColor:Lt},content:{paddingHorizontal:24,paddingBottom:16},title:{fontSize:28,fontWeight:"700",color:Nt,marginBottom:8,lineHeight:34},subtitle:{fontSize:15,color:ct,marginBottom:32,lineHeight:22},input:{backgroundColor:_t,borderRadius:12,padding:16,fontSize:17,color:Nt,borderWidth:1,borderColor:or},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{fontSize:13,color:ct,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5,textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{fontSize:12,color:j,marginTop:10,lineHeight:18},footer:{paddingHorizontal:24,paddingBottom:48,paddingTop:12},continueBtn:{backgroundColor:Lt,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:_t},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:j}});var an="https://api.unifold.io",lr,ln="pk_test_123";function cn(){return typeof __DEV__<"u"&&__DEV__&&lr?lr:an}function cr(){return cn()}function wt(){return ln}var dr="",ur;function xt(e){dr=e;}function Ct(e){ur=e;}function ce(){let e=dr||wt();return e}function de(){return ur??cr()}async function Tt(){let e=`${de()}/v1/public/onramps/headless/stripe/config`,a=ce(),o=await fetch(e,{method:"GET",headers:{"x-publishable-key":a,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`Failed to load Stripe config: ${o.status}`);let l=await o.json();if(!l?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return l.publishable_key}async function pr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!a.ok)throw new Error(`Failed to create auth intent: ${a.status}`);let o=await a.json();return o.auth_intent_id??o.id}async function mr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!a.ok)throw new Error(`Failed to exchange auth intent for tokens: ${a.status}`);return a.json()}async function fr(e,a){let o={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},l=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"},body:JSON.stringify(o)}),c=await l.text();if(!l.ok)throw new Error(`Failed to create onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function yr(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}}),l=await o.text();if(!o.ok)throw new Error(`Failed to confirm onramp session: ${o.status} ${l}`);return JSON.parse(l)}async function gr(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/customers/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp customer: ${l.status} ${c}`);return JSON.parse(c)}async function hr(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/sessions/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function _r(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}});if(!o.ok){let l=await o.text();throw new Error(`Failed to refresh quote: ${o.status} ${l}`)}return o.json()}async function br(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let a={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},o=await fetch(`${de()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to create deposit address: ${o.status}`);return o.json()}async function wr(e){let a=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),o=await fetch(`${de()}/v1/public/onramps/headless/stripe/default_token?${a.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":ce()}});if(!o.ok)throw new Error(`Failed to fetch default onramp token: ${o.status}`);return o.json()}var xr={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function St(e){let a=e?.flowOrder==="amount_first",o=a?"session_params":"email",{configure:l,hasLinkAccount:c,registerLinkUser:x,authorize:B,attachKycInfo:L,presentKycInfoVerification:D,verifyIdentity:W,registerWalletAddress:T,collectPaymentMethod:S,createCryptoPaymentToken:k}=stripeReactNative.useOnramp(),[O,y]=react.useState(o),[N,b]=react.useState(false),[Ve,m]=react.useState(""),[ge,te]=react.useState(null),[C,se]=react.useState(e?.email??""),[M,ve]=react.useState(e?.phone??""),[Le,Ae]=react.useState(""),[Re,Ee]=react.useState("US"),[Ne,Fe]=react.useState(""),[K,ze]=react.useState(""),[he,_e]=react.useState(false),[Ye,be]=react.useState(false),De=react.useRef(false),ae=react.useRef(false),re=react.useRef(""),F=react.useRef(null),[h,U]=react.useState(xr),[w,V]=react.useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[zr,Wr]=react.useState(""),[We,tt]=react.useState(e?.defaultNetwork??stripeReactNative.Onramp.CryptoNetwork.base),[Ke,Mt]=react.useState(e?.defaultSourceAmount??"100"),[ft,Yt]=react.useState(e?.defaultSourceCurrency??"usd"),[yt,Pt]=react.useState(e?.defaultDestinationCurrency??"usdc"),[we,rt]=react.useState(null),[Gt,vt]=react.useState(false),[Kr,Ur]=react.useState(false),nt=react.useRef(null),ot=react.useRef(false),Ht=react.useRef(e?.onComplete),qt=react.useRef(e?.onError),Qt=react.useRef(e?.onStepChange),Jt=react.useRef(o);react.useEffect(()=>{Ht.current=e?.onComplete;},[e?.onComplete]),react.useEffect(()=>{qt.current=e?.onError;},[e?.onError]),react.useEffect(()=>{Qt.current=e?.onStepChange;},[e?.onStepChange]);let At=react.useRef(o);react.useEffect(()=>{O!==At.current&&(Qt.current?.(O,At.current),At.current=O),Jt.current=O;},[O]);let f=react.useCallback((r,d,_)=>{let P={code:r,message:d,step:Jt.current,stripeErrorCode:_};te(P),m(""),qt.current?.(P);},[]),Zt=react.useCallback(r=>{let d={sessionId:r.id,status:r.status,sourceAmount:r.transaction_details.source_amount,sourceCurrency:r.transaction_details.source_currency,destinationAmount:r.transaction_details.destination_amount,destinationCurrency:r.transaction_details.destination_currency,destinationNetwork:r.transaction_details.destination_network,walletAddress:r.transaction_details.wallet_address,fees:{networkFee:r.transaction_details.fees.network_fee_amount,transactionFee:r.transaction_details.fees.transaction_fee_amount}};return Ht.current?.(d),d},[]),R=react.useCallback(()=>te(null),[]);react.useEffect(()=>{stripeReactNative.isPlatformPaySupported().then(Ur);},[]),react.useEffect(()=>(ot.current=false,()=>{ot.current=true,nt.current&&clearTimeout(nt.current);}),[]),react.useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||he||Ye)return;let r=false;be(true);async function d(){try{let[_,P]=await Promise.all([br({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?wr({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Y=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Y?.message),null)):Promise.resolve(null)]);if(r)return;let le=e?.destinationChainType??"ethereum",xe=_.data.find(Y=>Y.chain_type===le);if(xe?.address){let Y=xe.address.toLowerCase();V(Y),re.current=Y,xe.recipient_address&&Wr(xe.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",le,"in",_.data?.length,"wallets");let Q={base:stripeReactNative.Onramp.CryptoNetwork.base,ethereum:stripeReactNative.Onramp.CryptoNetwork.ethereum,solana:stripeReactNative.Onramp.CryptoNetwork.solana,bitcoin:stripeReactNative.Onramp.CryptoNetwork.bitcoin,polygon:stripeReactNative.Onramp.CryptoNetwork.polygon},st={8453:"base",1:"ethereum",137:"polygon"},Ge=P?.destination_network,at="none";if(Ge&&Q[Ge])tt(Q[Ge]),at=Ge+" (from default_token API)";else if(e?.destinationChainId&&st[e.destinationChainId]){let Y=st[e.destinationChainId];Q[Y]&&tt(Q[Y]),at=Y+" (from chain_id "+e.destinationChainId+")";}else Q[le]&&(tt(Q[le]),at=le+" (from chain_type fallback)");P?.destination_currency&&Pt(P.destination_currency.toLowerCase()),_e(!0),ae.current=!0;}catch(_){console.error("[useStripeOnramp] Failed to resolve wallet:",_?.message),_e(true),ae.current=true;}finally{r||be(false);}}return d(),()=>{r=true;}},[e?.publishableKey,e?.externalUserId]);let it=react.useCallback(async()=>{if(F.current)return F.current;let r=l({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(d=>(d.error&&(console.error("[useStripeOnramp] configureSDK error:",d.error.message,d.error.code),F.current=null),d)).catch(d=>{throw console.error("[useStripeOnramp] configureSDK threw:",d?.message??d),F.current=null,d});return F.current=r,r},[l,e?.merchantDisplayName]);react.useEffect(()=>{it();},[]);let Ue=react.useCallback(async r=>{b(true),R(),m("Creating auth intent...");try{let d=await pr(r);m("Waiting for authorization...");let _=await B(d);if(_?.error){f("authorization_error",_.error.message,_.error.code),y("email");return}if(_?.status==="Denied"){f("authorization_error","Authorization denied by user."),y("email");return}if(_?.status!=="Consented"||!_.customerId){f("authorization_error","Authorization was canceled."),y("email");return}m("Exchanging tokens...");let P=await mr(d),le=_.customerId,xe=P.access_token;Fe(le),ze(xe),m("Checking verification status...");try{let Q=await gr(le,xe),st=Q.verifications.find(Ce=>Ce.name==="kyc_verified"),Ge=Q.verifications.find(Ce=>Ce.name==="id_document_verified"),at=st?.status==="verified",Y=st?.status==="rejected",rr=Ge?.status==="verified",Et=Q.provided_fields.includes("first_name");if(m(""),Y&&!Et)f("kyc_error","KYC was previously rejected. Please submit with correct info."),y("kyc");else if(Y&&Et)y(rr?"wallet":"identity");else if(!at&&!Et)y("kyc");else if(!rr)y("identity");else if(ae.current&&re.current)try{let Ce=await T(re.current,We);Ce?.error?(f("wallet_error",Ce.error.message,Ce.error.code),y("wallet")):y(a?"payment_method":"session_params");}catch(Ce){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Ce?.message),y("wallet");}else y("wallet");}catch(Q){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",Q?.message),m(""),y("kyc");}}catch(d){f("authorization_error",d?.message??String(d)),y("email");}finally{b(false);}},[B,R,f,T,We,a]),$r=react.useCallback(async()=>{if(reactNative.Keyboard.dismiss(),!C){f("validation_error","Please enter an email address.");return}b(true),R(),m("");try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(C);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(C):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}},[R,it,C,f,c,Ue]),jr=react.useCallback(async()=>{if(!M){f("validation_error","Please enter your phone number.");return}b(true),R(),m("");try{m("Creating Link account...");let r=await x({email:C,phone:M,fullName:Le||C,country:Re||"US"});if(r.error){f("registration_error",r.error.message,r.error.code);return}await Ue(C);}catch(r){f("registration_error",r?.message??String(r));}finally{b(false);}},[R,Re,C,f,Le,M,x,Ue]);react.useEffect(()=>{De.current||O==="email"&&e?.email&&(De.current=true,e?.phone?(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}if(d.hasLinkAccount)await Ue(e.email);else {m("Creating Link account...");let _=await x({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(_.error){f("registration_error",_.error.message,_.error.code);return}await Ue(e.email);}}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})():(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(e.email):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})());},[O]);let Mr=react.useCallback(async r=>{b(true),R(),m(""),U(r);try{let d={firstName:r.firstName,lastName:r.lastName,idNumber:r.idNumber||void 0,dateOfBirth:{day:parseInt(r.dobDay,10),month:parseInt(r.dobMonth,10),year:parseInt(r.dobYear,10)},address:{line1:r.addressLine1,line2:r.addressLine2||void 0,city:r.city,state:r.state,postalCode:r.postalCode,country:r.country}},_=await L(d);if(_?.error){if(_.error.stripeErrorCode==="consumer_person_already_verified"){m(""),y("identity");return}f("kyc_error",_.error.message,_.error.stripeErrorCode??_.error.code),y("kyc");return}m("Please review your KYC information...");let P=await D(null);if(P?.error){f("kyc_error",P.error.message,P.error.stripeErrorCode??P.error.code),y("kyc");return}if(P?.status==="UpdateAddress"){f("kyc_error","Please update your address and resubmit."),y("kyc");return}m(""),y("identity");}catch(d){f("kyc_error",d?.message??String(d)),y("kyc");}finally{b(false);}},[L,R,f,D]),Xt=react.useCallback(async()=>{b(true),R(),m("Launching identity verification...");try{let r=await W();if(r?.error){f("identity_error",r.error.message,r.error.code);return}m(""),y("wallet");}catch(r){f("identity_error",r?.message??String(r));}finally{b(false);}},[R,f,W]);react.useEffect(()=>{O==="identity"&&!N&&Xt();},[O]);let er=react.useCallback(async()=>{if(!w){f("validation_error","Please enter a wallet address.");return}b(true),R(),m("");try{let r=await T(w.toLowerCase(),We);if(r?.error){f("wallet_error",r.error.message,r.error.code);return}m(""),y(a?"payment_method":"session_params");}catch(r){f("wallet_error",r?.message??String(r));}finally{b(false);}},[R,f,w,We,T,a]);react.useEffect(()=>{O==="wallet"&&he&&w&&!N&&er();},[O,he,w]);let Yr=react.useCallback(async(r=false)=>{if(!Ke||isNaN(Number(Ke))||Number(Ke)<=0){f("validation_error","Please enter a valid amount.");return}b(true),R(),m("");try{let d;if(r){m("Opening Apple Pay...");let xe={applePay:{merchantCountryCode:"US",currencyCode:ft.toUpperCase(),cartItems:[{paymentType:stripeReactNative.PlatformPay.PaymentType.Immediate,label:`${yt.toUpperCase()} purchase + fees`,amount:Ke||"0.00"}]}};d=await S("PlatformPay",xe);}else m("Select a payment method..."),d=await S("Card");if(d?.error){f("payment_error",d.error.message,d.error.code),y("payment_method");return}if(!d?.displayData){f("payment_error","Payment method selection was canceled."),y("payment_method");return}m("Creating payment token...");let _=await k();if(_?.error){f("payment_error",_.error.message,_.error.code),y("payment_method");return}let P=_.cryptoPaymentToken;m("Creating onramp session...");let le=await fr({cryptoCustomerId:Ne,paymentToken:P,sourceAmount:Number(Ke),sourceCurrency:ft,destinationCurrency:yt,walletAddress:w.toLowerCase(),destinationNetwork:We},K);rt(le),vt(r),m(""),y("quote");}catch(d){f("session_error",d?.message??String(d)),y("payment_method");}finally{b(false);}},[K,R,S,k,Ne,yt,f,Ke,ft,w,We]),Gr=react.useCallback(async()=>{if(we){b(true),R(),m("");try{let r=await _r(we.id,K);rt(r);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,we]),tr=react.useCallback((r,d)=>{ot.current=false;let _=async()=>{try{let P=await hr(r,d);if(ot.current)return;P.status==="fulfillment_complete"?(rt(P),y("success"),Zt(P)):nt.current=setTimeout(_,3e3);}catch(P){if(ot.current)return;console.error("[pollSessionStatus] error:",P?.message),nt.current=setTimeout(_,5e3);}};nt.current=setTimeout(_,3e3);},[Zt]),Rt=react.useCallback(async()=>{if(we){b(true),R(),m("");try{m("Confirming purchase...");let r=await yr(we.id,K);rt(r),y("processing"),m(""),tr(r.id,K);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,tr,we]);react.useEffect(()=>{O==="quote"&&Gt&&we&&!N&&(vt(false),Rt());},[O,Gt,we,N,Rt]);let Hr=react.useCallback(()=>{y(o),b(false),m(""),te(null),se(e?.email??""),ve(e?.phone??""),Ae(""),Ee("US"),Fe(""),ze(""),_e(false),be(false),U(xr),V(e?.recipientAddress??""),tt(stripeReactNative.Onramp.CryptoNetwork.ethereum),Mt(e?.defaultSourceAmount??"100"),Yt(e?.defaultSourceCurrency??"usd"),Pt(e?.defaultDestinationCurrency??"usdc"),rt(null),vt(false),De.current=false;},[e,o]);return {step:O,loading:N,status:Ve,error:ge,email:C,phone:M,fullName:Le,country:Re,customerId:Ne,accessToken:K,session:we,kycData:h,walletAddress:w,resolvedRecipientAddress:zr,walletNetwork:We,sourceAmount:Ke,sourceCurrency:ft,destinationCurrency:yt,applePaySupported:Kr,walletReady:he,walletLoading:Ye,setStep:y,setStatus:m,setEmail:se,setPhone:ve,setFullName:Ae,setCountry:Ee,setWalletAddress:V,setWalletNetwork:tt,setSourceAmount:Mt,setSourceCurrency:Yt,setDestinationCurrency:Pt,checkEmail:$r,register:jr,attachKyc:Mr,verifyIdentity:Xt,registerWallet:er,collectPaymentMethod:Yr,refreshQuote:Gr,confirmCheckout:Rt,reset:Hr,clearError:R,amountFirst:a}}function Tr({size:e=28}){return jsxRuntime.jsx(fn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsxs(fn.G,{fillRule:"evenodd",children:[jsxRuntime.jsx(fn.Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsxRuntime.jsx(fn.Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function kr({size:e=28}){return jsxRuntime.jsxs(fn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsxs(fn.G,{clipPath:"url(#eth_clip)",children:[jsxRuntime.jsx(fn.Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsxRuntime.jsx(fn.Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsxRuntime.jsx(fn.Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsxRuntime.jsx(fn.Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsxRuntime.jsx(fn.Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsxRuntime.jsx(fn.Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsxRuntime.jsx(fn.Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsxRuntime.jsx(fn.Defs,{children:jsxRuntime.jsx(fn.ClipPath,{id:"eth_clip",children:jsxRuntime.jsx(fn.Rect,{width:28,height:28,fill:"white"})})})]})}function vr({size:e=28}){return jsxRuntime.jsxs(fn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsxs(fn.G,{clipPath:"url(#btc_clip)",children:[jsxRuntime.jsx(fn.Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsxRuntime.jsx(fn.Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsxRuntime.jsx(fn.Defs,{children:jsxRuntime.jsx(fn.ClipPath,{id:"btc_clip",children:jsxRuntime.jsx(fn.Rect,{width:28,height:28,fill:"white"})})})]})}function Ar({size:e=28}){return jsxRuntime.jsxs(fn__default.default,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxRuntime.jsxs(fn.Defs,{children:[jsxRuntime.jsxs(fn.LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(fn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(fn.Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxRuntime.jsxs(fn.LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(fn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(fn.Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxRuntime.jsxs(fn.LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(fn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(fn.Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsxRuntime.jsx(fn.Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxRuntime.jsxs(fn.G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsxRuntime.jsx(fn.Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsxRuntime.jsx(fn.Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsxRuntime.jsx(fn.Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function Rr({size:e=28}){return jsxRuntime.jsx(fn__default.default,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxRuntime.jsxs(fn.G,{children:[jsxRuntime.jsx(fn.Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsxRuntime.jsx(fn.Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var q="#00D924",Br="#00D92440",zn="#000000",Oe="#1C1C1E",Be="#38383A",Pe="#FFFFFF",fe="#8E8E93",ye="#636366",Wn="#FF453A",Er=[{label:"Base",value:stripeReactNative.Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:Tr},{label:"Ethereum",value:stripeReactNative.Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:kr},{label:"Bitcoin",value:stripeReactNative.Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:vr},{label:"Solana",value:stripeReactNative.Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:Ar},{label:"Polygon",value:stripeReactNative.Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:Rr}];function Dr(e,a){let o=parseFloat(e);if(isNaN(o))return e;let l=a.toLowerCase(),c=["eth","btc"].includes(l)?4:2;return o.toFixed(c)}function Ot({config:e,onComplete:a}){let{step:o,loading:l,status:c,error:x,email:B,phone:L,session:D,kycData:W,walletAddress:T,resolvedRecipientAddress:S,walletNetwork:k,sourceAmount:O,sourceCurrency:y,destinationCurrency:N,applePaySupported:b,walletReady:Ve,walletLoading:m,setStep:ge,setEmail:te,setPhone:C,setWalletAddress:se,setWalletNetwork:M,setSourceAmount:ve,setDestinationCurrency:Le,checkEmail:Ae,register:Re,attachKyc:Ee,verifyIdentity:Ne,registerWallet:Fe,collectPaymentMethod:K,refreshQuote:ze,confirmCheckout:he,reset:_e,clearError:Ye,amountFirst:be}=St(e),De=!!e?.email,ae=!!e?.phone,re=!!e?.publishableKey&&!!e?.externalUserId,F=()=>{_e(),a?.();};if(o==="email")return De?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Enter your email"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Email address"}),jsxRuntime.jsx(reactNative.TextInput,{style:n.input,placeholder:"jane@example.com",placeholderTextColor:ye,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:B,onChangeText:te,autoFocus:true,returnKeyType:"done",onSubmitEditing:Ae})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!B&&n.continueBtnDisabled],onPress:Ae,disabled:!B,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!B&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="register")return ae?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Enter your phone"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"We'll send a verification code to confirm your number."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Phone number"}),jsxRuntime.jsx(reactNative.TextInput,{style:n.input,placeholder:"+12125551234",placeholderTextColor:ye,keyboardType:"phone-pad",value:L,onChangeText:h=>C(h.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:Re}),jsxRuntime.jsx(reactNative.Text,{style:n.hint,children:"Include country code, e.g. +12125551234"})]}),jsxRuntime.jsxs(reactNative.View,{style:n.emailRow,children:[jsxRuntime.jsx(reactNative.Text,{style:n.emailLabel,children:"Signing up as"}),jsxRuntime.jsx(reactNative.Text,{style:n.emailValue,children:B})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!L&&n.continueBtnDisabled],onPress:Re,disabled:!L,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!L&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="kyc")return jsxRuntime.jsx(bt,{initialData:W,loading:l,onComplete:Ee,onCancel:()=>ge("email")});if(o==="identity")return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Verifying identity"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:c||"Preparing identity verification..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.Text,{style:A.idIcon,children:"\u{1FAAA}"})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Identity verification"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:c||"Tap below to continue verification."})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:false})]}),!l&&jsxRuntime.jsx(reactNative.View,{style:n.footer,children:jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:Ne,children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Continue Verification"})})})]});if(o==="wallet")return re?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Your crypto wallet"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Wallet address"}),jsxRuntime.jsx(reactNative.TextInput,{style:[n.input,ke.input],placeholder:"0x...",placeholderTextColor:ye,autoCapitalize:"none",autoCorrect:false,value:T,onChangeText:se})]}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Network"}),jsxRuntime.jsx(reactNative.View,{style:ke.list,children:Er.map(h=>{let U=k===h.value;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[ke.row,U&&ke.rowSelected],onPress:()=>{M(h.value),Le(h.defaultCrypto);},children:[jsxRuntime.jsx(reactNative.View,{style:ke.iconWrap,children:jsxRuntime.jsx(h.Icon,{size:24})}),jsxRuntime.jsx(reactNative.Text,{style:[ke.rowText,U&&ke.rowTextSelected],children:h.label}),U&&jsxRuntime.jsx(reactNative.View,{style:ke.checkCircle,children:jsxRuntime.jsx(reactNative.Text,{style:ke.check,children:"\u2713"})})]},h.value)})})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!T&&n.continueBtnDisabled],onPress:Fe,disabled:!T,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!T&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="session_params")return jsxRuntime.jsx(ht,{initialAmount:O,currency:y,onConfirm:h=>{ve(h),ge(be?"email":"payment_method");},onCancel:()=>{be?F():ge("wallet");}});if(o==="payment_method"){let h=Er.find(U=>U.value===k)?.label??k;return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"How do you want to pay?"}),jsxRuntime.jsxs(reactNative.View,{style:X.summary,children:[jsxRuntime.jsxs(reactNative.View,{style:X.summaryCol,children:[jsxRuntime.jsx(reactNative.Text,{style:X.summaryLabel,children:"You spend"}),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryAmount,children:["$",O," ",jsxRuntime.jsx(reactNative.Text,{style:X.summaryCurrency,children:y.toUpperCase()})]})]}),jsxRuntime.jsx(reactNative.View,{style:X.divider}),jsxRuntime.jsxs(reactNative.View,{style:X.summaryCol,children:[jsxRuntime.jsx(reactNative.Text,{style:X.summaryLabel,children:"You receive"}),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryDest,children:[N.toUpperCase(),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryNetwork,children:[" on ",h]})]})]})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[b&&jsxRuntime.jsx(reactNative.TouchableOpacity,{style:X.applePayBtn,onPress:()=>K(true),children:jsxRuntime.jsxs(reactNative.Text,{style:X.applePayBtnText,children:["Pay with ","\uF8FF"," Pay"]})}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:()=>K(false),children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Pay with Card"})})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="quote"&&D){let h=D.transaction_details,U=new Date(h.quote_expiration*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),w=h.wallet_address.slice(0,6)+"..."+h.wallet_address.slice(-4),V=Dr(h.destination_amount,h.destination_currency);return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(reactNative.View,{style:{opacity:l?0:1},pointerEvents:l?"none":"auto",children:jsxRuntime.jsx(Ze,{onPress:F})}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Review your purchase"}),jsxRuntime.jsxs(reactNative.View,{style:E.heroBox,children:[jsxRuntime.jsx(reactNative.Text,{style:E.heroLabel,children:"You receive"}),jsxRuntime.jsxs(reactNative.Text,{style:E.heroAmount,children:[V," ",jsxRuntime.jsx(reactNative.Text,{style:E.heroCurrency,children:h.destination_currency.toUpperCase()})]}),jsxRuntime.jsx(reactNative.Text,{style:E.heroNetwork,children:h.destination_network})]}),jsxRuntime.jsxs(reactNative.View,{style:E.card,children:[jsxRuntime.jsx(Xe,{label:"You pay",value:`${h.source_amount} ${h.source_currency.toUpperCase()}`}),jsxRuntime.jsx(Xe,{label:"Network fee",value:`$${h.fees.network_fee_amount}`}),jsxRuntime.jsx(Xe,{label:"Transaction fee",value:`$${h.fees.transaction_fee_amount}`}),jsxRuntime.jsx(Xe,{label:"Wallet",value:w,mono:true}),jsxRuntime.jsx(Xe,{label:"Quote expires",value:U,last:true})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:he,children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Confirm Purchase"})}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.ghostBtn,onPress:ze,children:jsxRuntime.jsx(reactNative.Text,{style:n.ghostBtnText,children:"Refresh Quote"})})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="processing")return jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Processing your purchase"}),jsxRuntime.jsxs(reactNative.Text,{style:A.sub,children:["Your payment has been confirmed.",`
2
- `,"We're sending your crypto \u2014 this usually takes less than a minute."]})]})});if(o==="success"&&D){let h=D.transaction_details,U=Dr(h.destination_amount,h.destination_currency),w=S||e?.recipientAddress||"";return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:A.centered,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsx(reactNative.View,{style:A.checkCircle,children:jsxRuntime.jsx(reactNative.Text,{style:A.checkMark,children:"\u2713"})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Purchase complete!"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:"Your crypto is on its way to your wallet."}),jsxRuntime.jsxs(reactNative.View,{style:[E.heroBox,A.detailCard],children:[jsxRuntime.jsx(reactNative.Text,{style:E.heroLabel,children:"You received"}),jsxRuntime.jsx(reactNative.Text,{style:E.heroAmount,children:U}),jsxRuntime.jsxs(reactNative.Text,{style:E.heroCurrency,children:[h.destination_currency.toUpperCase()," (",h.destination_network,")"]})]}),jsxRuntime.jsxs(reactNative.View,{style:[E.card,A.detailCard],children:[jsxRuntime.jsx(Ir,{label:"Deposit Address",address:h.wallet_address}),w?jsxRuntime.jsx(Ir,{label:"Recipient Address",address:w,last:true}):jsxRuntime.jsx(Xe,{label:"Session",value:D.id.slice(0,8)+"..."+D.id.slice(-6),mono:true,last:true})]})]}),jsxRuntime.jsx(reactNative.View,{style:n.footer,children:jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:()=>{_e(),a?.();},children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Done"})})})]})}return null}function Ze({onPress:e}){return jsxRuntime.jsxs(reactNative.View,{style:n.header,children:[jsxRuntime.jsx(reactNative.View,{style:n.headerSpacer}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.closeBtn,onPress:e,children:jsxRuntime.jsx(reactNative.Text,{style:n.closeBtnText,children:"\u2715"})})]})}function Se({error:e,progress:a,loading:o}){return e?jsxRuntime.jsx(reactNative.Text,{style:n.errorText,children:e.message}):a&&o&&__DEV__?jsxRuntime.jsx(reactNative.Text,{style:n.progressText,children:a}):null}function Xe({label:e,value:a,mono:o,last:l}){return jsxRuntime.jsxs(reactNative.View,{style:[E.row,l&&E.rowLast],children:[jsxRuntime.jsx(reactNative.Text,{style:E.rowLabel,children:e}),jsxRuntime.jsx(reactNative.Text,{style:[E.rowValue,o&&E.rowMono],children:a})]})}function Ir({label:e,address:a,last:o}){let[l,c]=react.useState(false),x=()=>{reactNative.Clipboard.setString(a),c(true),setTimeout(()=>c(false),2e3);};return jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[E.row,o&&E.rowLast,{flexDirection:"column",alignItems:"flex-start",gap:6}],onPress:x,activeOpacity:.7,children:[jsxRuntime.jsxs(reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",width:"100%"},children:[jsxRuntime.jsx(reactNative.Text,{style:E.rowLabel,children:e}),jsxRuntime.jsx(reactNative.Text,{style:{fontSize:12,color:l?q:fe},children:l?"Copied!":"Tap to copy"})]}),jsxRuntime.jsx(reactNative.Text,{style:[E.rowValue,E.rowMono,{fontSize:12,lineHeight:18}],selectable:true,children:a})]})}var n=reactNative.StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:zn,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",justifyContent:"flex-end",paddingTop:60,paddingBottom:16},headerSpacer:{flex:1},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:Oe,alignItems:"center",justifyContent:"center"},closeBtnText:{color:fe,fontSize:14,fontWeight:"600"},content:{flex:1,paddingTop:16},title:{fontSize:28,fontWeight:"700",color:Pe,marginBottom:8},subtitle:{fontSize:15,color:fe,marginBottom:36,lineHeight:22},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:fe,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5},input:{backgroundColor:Oe,borderRadius:12,padding:16,fontSize:17,color:Pe,borderWidth:1,borderColor:Be},hint:{fontSize:12,color:ye,marginTop:8},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:Oe,paddingHorizontal:14,paddingVertical:10,borderRadius:10},emailLabel:{fontSize:13,color:ye},emailValue:{fontSize:13,color:Pe,fontWeight:"600"},footer:{gap:12},continueBtn:{backgroundColor:q,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:Oe},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:ye},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:fe,fontSize:15,fontWeight:"500"},errorText:{fontSize:14,color:Wn,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,color:ye,textAlign:"center",lineHeight:18,marginTop:24}}),E=reactNative.StyleSheet.create({heroBox:{backgroundColor:Oe,borderRadius:16,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:1,borderColor:Be,gap:4},heroLabel:{fontSize:13,color:ye,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase"},heroAmount:{fontSize:48,fontWeight:"700",color:Pe,letterSpacing:-1},heroCurrency:{fontSize:22,fontWeight:"500",color:q},heroNetwork:{fontSize:13,color:ye,marginTop:2},card:{backgroundColor:Oe,borderRadius:16,borderWidth:1,borderColor:Be,overflow:"hidden"},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderBottomWidth:1,borderBottomColor:Be},rowLast:{borderBottomWidth:0},rowLabel:{fontSize:14,color:fe},rowValue:{fontSize:14,fontWeight:"600",color:Pe},rowMono:{fontFamily:reactNative.Platform.OS==="ios"?"Menlo":"monospace",fontSize:13}}),X=reactNative.StyleSheet.create({summary:{backgroundColor:Oe,borderRadius:16,padding:20,marginTop:16,marginBottom:28,borderWidth:1,borderColor:Be,gap:16},summaryCol:{gap:4},summaryLabel:{fontSize:12,color:ye,fontWeight:"600",textTransform:"uppercase",letterSpacing:.3},summaryAmount:{fontSize:24,fontWeight:"700",color:Pe},summaryCurrency:{fontSize:14,fontWeight:"400",color:fe},summaryDest:{fontSize:24,fontWeight:"700",color:q},summaryNetwork:{fontSize:13,fontWeight:"400",color:fe},divider:{height:1,backgroundColor:Be},applePayBtn:{backgroundColor:Pe,borderRadius:24,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:"#000",fontSize:17,fontWeight:"700"}}),ke=reactNative.StyleSheet.create({input:{fontSize:14,fontFamily:reactNative.Platform.OS==="ios"?"Menlo":"monospace"},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:Be,backgroundColor:Oe},rowSelected:{borderColor:q,backgroundColor:Br},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:fe,fontWeight:"500"},rowTextSelected:{color:Pe,fontWeight:"600"},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:q,alignItems:"center",justifyContent:"center"},check:{fontSize:14,color:"#000",fontWeight:"700"}}),A=reactNative.StyleSheet.create({centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:Oe,borderWidth:1,borderColor:Be,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:Br,borderWidth:2,borderColor:q,alignItems:"center",justifyContent:"center",marginBottom:28},checkMark:{fontSize:36,color:q,fontWeight:"600"},heading:{fontSize:28,fontWeight:"700",color:Pe,textAlign:"center",marginBottom:10},sub:{fontSize:15,color:fe,textAlign:"center",lineHeight:22,marginBottom:36},detailCard:{width:"100%"}});var Gn="https://api.unifold.io",Hn="https://api-staging.unifold.io";function qn(){return typeof __DEV__<"u"&&__DEV__?Hn:Gn}function Nr({publishableKey:e,email:a,phone:o,externalUserId:l,flowOrder:c,destinationChainType:x="ethereum",destinationChainId:B="8453",destinationTokenAddress:L,recipientAddress:D,onComplete:W,onError:T,onStepChange:S,onClose:k,merchantIdentifier:O="merchant.io.unifold",urlScheme:y="unifoldOnramp"}){let N=e||wt(),[b,Ve]=react.useState("loading"),[m,ge]=react.useState(null);react.useEffect(()=>{let C=false;async function se(){try{N&&(xt(N),Ct(qn()));let M=await Tt();if(C||(await stripeReactNative.initStripe({publishableKey:M,merchantIdentifier:O,urlScheme:y}),C))return;Ve("ready");}catch(M){if(C)return;console.error("[StripeOnramp] Init failed:",M),ge(M?.message??"Failed to load Stripe configuration"),Ve("error");}}return se(),()=>{C=true;}},[N,O,y]);let te=react.useMemo(()=>{let C={publishableKey:N,externalUserId:l,destinationChainType:x,destinationChainId:B,onComplete:W,onError:T,onStepChange:S};return L&&(C.destinationTokenAddress=L),D&&(C.recipientAddress=D),a&&(C.email=a),o&&(C.phone=o),c&&(C.flowOrder=c),C},[N,l,x,B,L,D,a,o,c,W,T,S]);return b==="error"?jsxRuntime.jsxs(reactNative.View,{style:et.centered,children:[jsxRuntime.jsx(reactNative.Text,{style:et.errorText,children:"Unable to initialize"}),jsxRuntime.jsx(reactNative.Text,{style:et.errorDetail,children:m}),k&&jsxRuntime.jsx(reactNative.TouchableOpacity,{style:et.retryBtn,onPress:k,children:jsxRuntime.jsx(reactNative.Text,{style:et.retryBtnText,children:"Go Back"})})]}):b==="loading"?jsxRuntime.jsx(reactNative.View,{style:et.centered,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:"#00D924"})}):jsxRuntime.jsx(Ot,{config:te,onComplete:k})}var et=reactNative.StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function Fr(){let{configure:e}=stripeReactNative.useOnramp(),a=react.useRef(false);return react.useEffect(()=>{a.current||(a.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(o=>{o.error&&console.error("[StripeOnrampPreconfigure] error:",o.error.message);}).catch(o=>{console.error("[StripeOnrampPreconfigure] threw:",o?.message);}));},[e]),null}
3
- exports.AmountScreen=ht;exports.KYCWizardScreen=bt;exports.OnrampScreen=Ot;exports.StripeOnramp=Nr;exports.StripeOnrampPreconfigure=Fr;exports.getStripePublishableKey=Tt;exports.setStripeOnrampApiUrl=Ct;exports.setStripeOnrampPublishableKey=xt;exports.useStripeOnramp=St;
1
+ 'use strict';var react=require('react'),reactNative=require('react-native'),stripeReactNative=require('@stripe/stripe-react-native'),jsxRuntime=require('react/jsx-runtime'),gn=require('react-native-svg');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var gn__default=/*#__PURE__*/_interopDefault(gn);var Qr="__unifold_stripe_onramp__";function or(e){globalThis[Qr]=e;}var Xr="#00D924",en="#000000",tn="#1C1C1E",Bt="#FFFFFF",Vt="#8E8E93",ir="#636366",rn=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function ht({initialAmount:e="",currency:a="USD",onConfirm:o,onCancel:l}){let[c,x]=react.useState(e),B=T=>{if(T==="\u232B"){x(S=>S.slice(0,-1));return}if(T==="."){if(c.includes("."))return;x(S=>S===""?"0.":S+".");return}x(S=>{let k=S.indexOf(".");return k!==-1&&S.length-k>2?S:S==="0"&&T!=="."?T:S+T});},L=c===""?"0":c,D=parseFloat(c),W=c!==""&&!isNaN(D)&&D>0;return jsxRuntime.jsxs(reactNative.View,{style:I.screen,children:[jsxRuntime.jsxs(reactNative.View,{style:I.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:I.cancelBtn,onPress:l,children:jsxRuntime.jsx(reactNative.Text,{style:I.cancelText,children:"Cancel"})}),jsxRuntime.jsx(reactNative.Text,{style:I.headerTitle,children:"Enter amount"}),jsxRuntime.jsx(reactNative.View,{style:{width:64}})]}),jsxRuntime.jsxs(reactNative.View,{style:I.amountContainer,children:[jsxRuntime.jsxs(reactNative.Text,{style:[I.amountText,L==="0"&&I.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",L]}),jsxRuntime.jsx(reactNative.Text,{style:I.currencyLabel,children:a.toUpperCase()})]}),jsxRuntime.jsx(reactNative.View,{style:I.numpad,children:rn.map((T,S)=>jsxRuntime.jsx(reactNative.View,{style:I.numpadRow,children:T.map(k=>jsxRuntime.jsx(reactNative.TouchableOpacity,{style:I.numpadKey,onPress:()=>B(k),activeOpacity:.6,children:jsxRuntime.jsx(reactNative.Text,{style:k==="\u232B"?I.backspaceText:I.numpadKeyText,children:k})},k))},S))}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[I.confirmBtn,!W&&I.confirmBtnDisabled],onPress:()=>W&&o(c),disabled:!W,children:jsxRuntime.jsx(reactNative.Text,{style:[I.confirmBtnText,!W&&I.confirmBtnTextDisabled],children:"Continue"})})]})}var I=reactNative.StyleSheet.create({screen:{flex:1,backgroundColor:en,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:8},cancelBtn:{width:64},cancelText:{color:Vt,fontSize:16,fontWeight:"500"},headerTitle:{color:Bt,fontSize:17,fontWeight:"700"},amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,fontWeight:"300",color:Bt,letterSpacing:-2,minWidth:80,textAlign:"center"},amountPlaceholder:{color:ir},currencyLabel:{fontSize:15,color:Vt,letterSpacing:1,fontWeight:"500"},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",borderRadius:16,marginHorizontal:4},numpadKeyText:{fontSize:28,fontWeight:"400",color:Bt},backspaceText:{fontSize:22,color:Vt},confirmBtn:{backgroundColor:Xr,borderRadius:24,paddingVertical:18,alignItems:"center"},confirmBtnDisabled:{backgroundColor:tn},confirmBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},confirmBtnTextDisabled:{color:ir}});var Nt="#00D924",ln="#000000",_t="#1C1C1E",sr="#38383A",Ft="#FFFFFF",ct="#8E8E93",j="#636366",lt=4;function bt({initialData:e={},loading:a=false,onComplete:o,onCancel:l}){let[c,x]=react.useState(1),[B,L]=react.useState(e.firstName??""),[D,W]=react.useState(e.lastName??""),[T,S]=react.useState(e.dobMonth??""),[k,O]=react.useState(e.dobDay??""),[y,N]=react.useState(e.dobYear??""),[b,Ve]=react.useState(e.addressLine1??""),[m,ge]=react.useState(e.addressLine2??""),[te,C]=react.useState(e.city??""),[se,M]=react.useState(e.state??""),[ve,Le]=react.useState(e.postalCode??""),[Ae,Re]=react.useState(e.country??"US"),[Ee,Ne]=react.useState(e.idNumber??""),Fe=react.useRef(null),K=react.useRef(null),ze=react.useRef(null),he=react.useRef(null),_e=react.useRef(null),Ye=react.useRef(null),be=react.useRef(null),De=react.useRef(null),ae=()=>{switch(c){case 1:return B.trim().length>0&&D.trim().length>0;case 2:return T.length===2&&k.length===2&&y.length===4;case 3:return b.trim().length>0&&te.trim().length>0&&se.trim().length>0&&ve.trim().length>0;case 4:return Ee.trim().length>0;default:return false}},re=()=>{ae()&&(c<lt?x(w=>w+1):o({firstName:B,lastName:D,idNumber:Ee,dobMonth:T,dobDay:k,dobYear:y,addressLine1:b,addressLine2:m,city:te,state:se,postalCode:ve,country:Ae}));},F=()=>{c>1?x(w=>w-1):l();},h=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],U=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."];return jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:p.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:p.screen,children:[jsxRuntime.jsxs(reactNative.View,{style:p.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:p.backBtn,onPress:F,children:jsxRuntime.jsx(reactNative.Text,{style:p.backBtnText,children:"\u2039"})}),jsxRuntime.jsxs(reactNative.Text,{style:p.stepCounter,children:[c," of ",lt]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:p.closeBtn,onPress:l,children:jsxRuntime.jsx(reactNative.Text,{style:p.closeText,children:"\u2715"})})]}),jsxRuntime.jsx(reactNative.View,{style:p.progressTrack,children:Array.from({length:lt}).map((w,V)=>jsxRuntime.jsx(reactNative.View,{style:[p.progressSegment,V<c&&p.progressSegmentDone,V+1===c&&p.progressSegmentActive]},V))}),jsxRuntime.jsxs(reactNative.ScrollView,{style:p.flex,contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",children:[jsxRuntime.jsx(reactNative.Text,{style:p.title,children:h[c-1]}),jsxRuntime.jsx(reactNative.Text,{style:p.subtitle,children:U[c-1]}),c===1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Te,{label:"First name",children:jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"Jane",placeholderTextColor:j,value:B,onChangeText:L,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Fe.current?.focus()})}),jsxRuntime.jsx(Te,{label:"Last name",children:jsxRuntime.jsx(reactNative.TextInput,{ref:Fe,style:p.input,placeholder:"Doe",placeholderTextColor:j,value:D,onChangeText:W,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:re})})]}),c===2&&jsxRuntime.jsxs(reactNative.View,{style:p.dobRow,children:[jsxRuntime.jsxs(reactNative.View,{style:p.dobCol,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Month"}),jsxRuntime.jsx(reactNative.TextInput,{style:[p.input,p.dobInput],placeholder:"MM",placeholderTextColor:j,value:T,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);S(V),V.length===2&&K.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxRuntime.jsxs(reactNative.View,{style:p.dobCol,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Day"}),jsxRuntime.jsx(reactNative.TextInput,{ref:K,style:[p.input,p.dobInput],placeholder:"DD",placeholderTextColor:j,value:k,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);O(V),V.length===2&&ze.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxRuntime.jsxs(reactNative.View,{style:p.dobColWide,children:[jsxRuntime.jsx(reactNative.Text,{style:p.dobLabel,children:"Year"}),jsxRuntime.jsx(reactNative.TextInput,{ref:ze,style:[p.input,p.dobInput],placeholder:"YYYY",placeholderTextColor:j,value:y,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,4);N(V);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:re})]})]}),c===3&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Te,{label:"Street address",children:jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"123 Main St",placeholderTextColor:j,value:b,onChangeText:Ve,returnKeyType:"next",onSubmitEditing:()=>he.current?.focus()})}),jsxRuntime.jsx(Te,{label:"Apt, suite, etc. (optional)",children:jsxRuntime.jsx(reactNative.TextInput,{ref:he,style:p.input,placeholder:"Apt 2",placeholderTextColor:j,value:m,onChangeText:ge,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsxRuntime.jsx(Te,{label:"City",children:jsxRuntime.jsx(reactNative.TextInput,{ref:_e,style:p.input,placeholder:"San Francisco",placeholderTextColor:j,value:te,onChangeText:C,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Ye.current?.focus()})}),jsxRuntime.jsxs(reactNative.View,{style:p.row,children:[jsxRuntime.jsx(reactNative.View,{style:[p.flex,{marginRight:8}],children:jsxRuntime.jsx(Te,{label:"State",children:jsxRuntime.jsx(reactNative.TextInput,{ref:Ye,style:p.input,placeholder:"NY",placeholderTextColor:j,value:se,onChangeText:w=>M(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})})}),jsxRuntime.jsx(reactNative.View,{style:p.flex,children:jsxRuntime.jsx(Te,{label:"ZIP code",children:jsxRuntime.jsx(reactNative.TextInput,{ref:be,style:p.input,placeholder:"11201",placeholderTextColor:j,value:ve,onChangeText:Le,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>De.current?.focus()})})})]}),jsxRuntime.jsx(Te,{label:"Country",children:jsxRuntime.jsx(reactNative.TextInput,{ref:De,style:p.input,placeholder:"US",placeholderTextColor:j,value:Ae,onChangeText:w=>Re(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:re})})]}),c===4&&jsxRuntime.jsxs(Te,{label:"Social Security Number",children:[jsxRuntime.jsx(reactNative.TextInput,{style:p.input,placeholder:"123-45-6789",placeholderTextColor:j,value:Ee,onChangeText:Ne,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:re}),jsxRuntime.jsx(reactNative.Text,{style:p.ssnHint,children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsxRuntime.jsx(reactNative.View,{style:p.footer,children:a&&c===lt?jsxRuntime.jsx(reactNative.View,{style:p.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#000"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[p.continueBtn,!ae()&&p.continueBtnDisabled],onPress:re,disabled:!ae(),children:jsxRuntime.jsx(reactNative.Text,{style:[p.continueBtnText,!ae()&&p.continueBtnTextDisabled],children:c===lt?"Submit":"Continue"})})})]})})}function Te({label:e,children:a}){return jsxRuntime.jsxs(reactNative.View,{style:ar.container,children:[jsxRuntime.jsx(reactNative.Text,{style:ar.label,children:e}),a]})}var ar=reactNative.StyleSheet.create({container:{marginBottom:20},label:{fontSize:13,color:ct,marginBottom:8,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5}}),p=reactNative.StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:ln},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingHorizontal:20,paddingBottom:16},backBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},backBtnText:{color:Ft,fontSize:22,marginTop:-1},stepCounter:{color:ct,fontSize:15,fontWeight:"600"},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},closeText:{color:ct,fontSize:14,fontWeight:"600"},progressTrack:{flexDirection:"row",gap:4,paddingHorizontal:20,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2,backgroundColor:sr},progressSegmentDone:{backgroundColor:Nt},progressSegmentActive:{backgroundColor:Nt},content:{paddingHorizontal:24,paddingBottom:16},title:{fontSize:28,fontWeight:"700",color:Ft,marginBottom:8,lineHeight:34},subtitle:{fontSize:15,color:ct,marginBottom:32,lineHeight:22},input:{backgroundColor:_t,borderRadius:12,padding:16,fontSize:17,color:Ft,borderWidth:1,borderColor:sr},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{fontSize:13,color:ct,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5,textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{fontSize:12,color:j,marginTop:10,lineHeight:18},footer:{paddingHorizontal:24,paddingBottom:48,paddingTop:12},continueBtn:{backgroundColor:Nt,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:_t},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:j}});var cn="https://api.unifold.io",dr,dn="pk_test_123";function un(){return typeof __DEV__<"u"&&__DEV__&&dr?dr:cn}function ur(){return un()}function wt(){return dn}var pr="",mr;function xt(e){pr=e;}function Ct(e){mr=e;}function ce(){let e=pr||wt();return e}function de(){return mr??ur()}async function Tt(){let e=`${de()}/v1/public/onramps/headless/stripe/config`,a=ce(),o=await fetch(e,{method:"GET",headers:{"x-publishable-key":a,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`Failed to load Stripe config: ${o.status}`);let l=await o.json();if(!l?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return l.publishable_key}async function fr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!a.ok)throw new Error(`Failed to create auth intent: ${a.status}`);let o=await a.json();return o.auth_intent_id??o.id}async function yr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!a.ok)throw new Error(`Failed to exchange auth intent for tokens: ${a.status}`);return a.json()}async function gr(e,a){let o={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},l=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"},body:JSON.stringify(o)}),c=await l.text();if(!l.ok)throw new Error(`Failed to create onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function hr(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}}),l=await o.text();if(!o.ok)throw new Error(`Failed to confirm onramp session: ${o.status} ${l}`);return JSON.parse(l)}async function _r(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/customers/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp customer: ${l.status} ${c}`);return JSON.parse(c)}async function br(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/sessions/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function wr(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}});if(!o.ok){let l=await o.text();throw new Error(`Failed to refresh quote: ${o.status} ${l}`)}return o.json()}async function xr(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let a={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},o=await fetch(`${de()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to create deposit address: ${o.status}`);return o.json()}async function Cr(e){let a=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),o=await fetch(`${de()}/v1/public/onramps/headless/stripe/default_token?${a.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":ce()}});if(!o.ok)throw new Error(`Failed to fetch default onramp token: ${o.status}`);return o.json()}var Tr={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function St(e){let a=e?.flowOrder==="amount_first",o=a?"session_params":"email",{configure:l,hasLinkAccount:c,registerLinkUser:x,authorize:B,attachKycInfo:L,presentKycInfoVerification:D,verifyIdentity:W,registerWalletAddress:T,collectPaymentMethod:S,createCryptoPaymentToken:k}=stripeReactNative.useOnramp(),[O,y]=react.useState(o),[N,b]=react.useState(false),[Ve,m]=react.useState(""),[ge,te]=react.useState(null),[C,se]=react.useState(e?.email??""),[M,ve]=react.useState(e?.phone??""),[Le,Ae]=react.useState(""),[Re,Ee]=react.useState("US"),[Ne,Fe]=react.useState(""),[K,ze]=react.useState(""),[he,_e]=react.useState(false),[Ye,be]=react.useState(false),De=react.useRef(false),ae=react.useRef(false),re=react.useRef(""),F=react.useRef(null),[h,U]=react.useState(Tr),[w,V]=react.useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[Wr,Kr]=react.useState(""),[We,tt]=react.useState(e?.defaultNetwork??stripeReactNative.Onramp.CryptoNetwork.base),[Ke,Yt]=react.useState(e?.defaultSourceAmount??"100"),[ft,Gt]=react.useState(e?.defaultSourceCurrency??"usd"),[yt,vt]=react.useState(e?.defaultDestinationCurrency??"usdc"),[we,rt]=react.useState(null),[Ht,At]=react.useState(false),[Ur,$r]=react.useState(false),nt=react.useRef(null),ot=react.useRef(false),qt=react.useRef(e?.onComplete),Qt=react.useRef(e?.onError),Jt=react.useRef(e?.onStepChange),Zt=react.useRef(o);react.useEffect(()=>{qt.current=e?.onComplete;},[e?.onComplete]),react.useEffect(()=>{Qt.current=e?.onError;},[e?.onError]),react.useEffect(()=>{Jt.current=e?.onStepChange;},[e?.onStepChange]);let Rt=react.useRef(o);react.useEffect(()=>{O!==Rt.current&&(Jt.current?.(O,Rt.current),Rt.current=O),Zt.current=O;},[O]);let f=react.useCallback((r,d,_)=>{let P={code:r,message:d,step:Zt.current,stripeErrorCode:_};te(P),m(""),Qt.current?.(P);},[]),Xt=react.useCallback(r=>{let d={sessionId:r.id,status:r.status,sourceAmount:r.transaction_details.source_amount,sourceCurrency:r.transaction_details.source_currency,destinationAmount:r.transaction_details.destination_amount,destinationCurrency:r.transaction_details.destination_currency,destinationNetwork:r.transaction_details.destination_network,walletAddress:r.transaction_details.wallet_address,fees:{networkFee:r.transaction_details.fees.network_fee_amount,transactionFee:r.transaction_details.fees.transaction_fee_amount}};return qt.current?.(d),d},[]),R=react.useCallback(()=>te(null),[]);react.useEffect(()=>{stripeReactNative.isPlatformPaySupported().then($r);},[]),react.useEffect(()=>(ot.current=false,()=>{ot.current=true,nt.current&&clearTimeout(nt.current);}),[]),react.useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||he||Ye)return;let r=false;be(true);async function d(){try{let[_,P]=await Promise.all([xr({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?Cr({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Y=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Y?.message),null)):Promise.resolve(null)]);if(r)return;let le=e?.destinationChainType??"ethereum",xe=_.data.find(Y=>Y.chain_type===le);if(xe?.address){let Y=xe.address.toLowerCase();V(Y),re.current=Y,xe.recipient_address&&Kr(xe.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",le,"in",_.data?.length,"wallets");let Q={base:stripeReactNative.Onramp.CryptoNetwork.base,ethereum:stripeReactNative.Onramp.CryptoNetwork.ethereum,solana:stripeReactNative.Onramp.CryptoNetwork.solana,bitcoin:stripeReactNative.Onramp.CryptoNetwork.bitcoin,polygon:stripeReactNative.Onramp.CryptoNetwork.polygon},st={8453:"base",1:"ethereum",137:"polygon"},Ge=P?.destination_network,at="none";if(Ge&&Q[Ge])tt(Q[Ge]),at=Ge+" (from default_token API)";else if(e?.destinationChainId&&st[e.destinationChainId]){let Y=st[e.destinationChainId];Q[Y]&&tt(Q[Y]),at=Y+" (from chain_id "+e.destinationChainId+")";}else Q[le]&&(tt(Q[le]),at=le+" (from chain_type fallback)");P?.destination_currency&&vt(P.destination_currency.toLowerCase()),_e(!0),ae.current=!0;}catch(_){console.error("[useStripeOnramp] Failed to resolve wallet:",_?.message),_e(true),ae.current=true;}finally{r||be(false);}}return d(),()=>{r=true;}},[e?.publishableKey,e?.externalUserId]);let it=react.useCallback(async()=>{if(F.current)return F.current;let r=l({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(d=>(d.error&&(console.error("[useStripeOnramp] configureSDK error:",d.error.message,d.error.code),F.current=null),d)).catch(d=>{throw console.error("[useStripeOnramp] configureSDK threw:",d?.message??d),F.current=null,d});return F.current=r,r},[l,e?.merchantDisplayName]);react.useEffect(()=>{it();},[]);let Ue=react.useCallback(async r=>{b(true),R(),m("Creating auth intent...");try{let d=await fr(r);m("Waiting for authorization...");let _=await B(d);if(_?.error){f("authorization_error",_.error.message,_.error.code),y("email");return}if(_?.status==="Denied"){f("authorization_error","Authorization denied by user."),y("email");return}if(_?.status!=="Consented"||!_.customerId){f("authorization_error","Authorization was canceled."),y("email");return}m("Exchanging tokens...");let P=await yr(d),le=_.customerId,xe=P.access_token;Fe(le),ze(xe),m("Checking verification status...");try{let Q=await _r(le,xe),st=Q.verifications.find(Ce=>Ce.name==="kyc_verified"),Ge=Q.verifications.find(Ce=>Ce.name==="id_document_verified"),at=st?.status==="verified",Y=st?.status==="rejected",nr=Ge?.status==="verified",Dt=Q.provided_fields.includes("first_name");if(m(""),Y&&!Dt)f("kyc_error","KYC was previously rejected. Please submit with correct info."),y("kyc");else if(Y&&Dt)y(nr?"wallet":"identity");else if(!at&&!Dt)y("kyc");else if(!nr)y("identity");else if(ae.current&&re.current)try{let Ce=await T(re.current,We);Ce?.error?(f("wallet_error",Ce.error.message,Ce.error.code),y("wallet")):y(a?"payment_method":"session_params");}catch(Ce){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Ce?.message),y("wallet");}else y("wallet");}catch(Q){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",Q?.message),m(""),y("kyc");}}catch(d){f("authorization_error",d?.message??String(d)),y("email");}finally{b(false);}},[B,R,f,T,We,a]),jr=react.useCallback(async()=>{if(reactNative.Keyboard.dismiss(),!C){f("validation_error","Please enter an email address.");return}b(true),R(),m("");try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(C);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(C):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}},[R,it,C,f,c,Ue]),Mr=react.useCallback(async()=>{if(!M){f("validation_error","Please enter your phone number.");return}b(true),R(),m("");try{m("Creating Link account...");let r=await x({email:C,phone:M,fullName:Le||C,country:Re||"US"});if(r.error){f("registration_error",r.error.message,r.error.code);return}await Ue(C);}catch(r){f("registration_error",r?.message??String(r));}finally{b(false);}},[R,Re,C,f,Le,M,x,Ue]);react.useEffect(()=>{De.current||O==="email"&&e?.email&&(De.current=true,e?.phone?(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}if(d.hasLinkAccount)await Ue(e.email);else {m("Creating Link account...");let _=await x({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(_.error){f("registration_error",_.error.message,_.error.code);return}await Ue(e.email);}}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})():(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(e.email):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})());},[O]);let Yr=react.useCallback(async r=>{b(true),R(),m(""),U(r);try{let d={firstName:r.firstName,lastName:r.lastName,idNumber:r.idNumber||void 0,dateOfBirth:{day:parseInt(r.dobDay,10),month:parseInt(r.dobMonth,10),year:parseInt(r.dobYear,10)},address:{line1:r.addressLine1,line2:r.addressLine2||void 0,city:r.city,state:r.state,postalCode:r.postalCode,country:r.country}},_=await L(d);if(_?.error){if(_.error.stripeErrorCode==="consumer_person_already_verified"){m(""),y("identity");return}f("kyc_error",_.error.message,_.error.stripeErrorCode??_.error.code),y("kyc");return}m("Please review your KYC information...");let P=await D(null);if(P?.error){f("kyc_error",P.error.message,P.error.stripeErrorCode??P.error.code),y("kyc");return}if(P?.status==="UpdateAddress"){f("kyc_error","Please update your address and resubmit."),y("kyc");return}m(""),y("identity");}catch(d){f("kyc_error",d?.message??String(d)),y("kyc");}finally{b(false);}},[L,R,f,D]),er=react.useCallback(async()=>{b(true),R(),m("Launching identity verification...");try{let r=await W();if(r?.error){f("identity_error",r.error.message,r.error.code);return}m(""),y("wallet");}catch(r){f("identity_error",r?.message??String(r));}finally{b(false);}},[R,f,W]);react.useEffect(()=>{O==="identity"&&!N&&er();},[O]);let tr=react.useCallback(async()=>{if(!w){f("validation_error","Please enter a wallet address.");return}b(true),R(),m("");try{let r=await T(w.toLowerCase(),We);if(r?.error){f("wallet_error",r.error.message,r.error.code);return}m(""),y(a?"payment_method":"session_params");}catch(r){f("wallet_error",r?.message??String(r));}finally{b(false);}},[R,f,w,We,T,a]);react.useEffect(()=>{O==="wallet"&&he&&w&&!N&&tr();},[O,he,w]);let Gr=react.useCallback(async(r=false)=>{if(!Ke||isNaN(Number(Ke))||Number(Ke)<=0){f("validation_error","Please enter a valid amount.");return}b(true),R(),m("");try{let d;if(r){m("Opening Apple Pay...");let xe={applePay:{merchantCountryCode:"US",currencyCode:ft.toUpperCase(),cartItems:[{paymentType:stripeReactNative.PlatformPay.PaymentType.Immediate,label:`${yt.toUpperCase()} purchase + fees`,amount:Ke||"0.00"}]}};d=await S("PlatformPay",xe);}else m("Select a payment method..."),d=await S("Card");if(d?.error){f("payment_error",d.error.message,d.error.code),y("payment_method");return}if(!d?.displayData){f("payment_error","Payment method selection was canceled."),y("payment_method");return}m("Creating payment token...");let _=await k();if(_?.error){f("payment_error",_.error.message,_.error.code),y("payment_method");return}let P=_.cryptoPaymentToken;m("Creating onramp session...");let le=await gr({cryptoCustomerId:Ne,paymentToken:P,sourceAmount:Number(Ke),sourceCurrency:ft,destinationCurrency:yt,walletAddress:w.toLowerCase(),destinationNetwork:We},K);rt(le),At(r),m(""),y("quote");}catch(d){f("session_error",d?.message??String(d)),y("payment_method");}finally{b(false);}},[K,R,S,k,Ne,yt,f,Ke,ft,w,We]),Hr=react.useCallback(async()=>{if(we){b(true),R(),m("");try{let r=await wr(we.id,K);rt(r);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,we]),rr=react.useCallback((r,d)=>{ot.current=false;let _=async()=>{try{let P=await br(r,d);if(ot.current)return;P.status==="fulfillment_complete"?(rt(P),y("success"),Xt(P)):nt.current=setTimeout(_,3e3);}catch(P){if(ot.current)return;console.error("[pollSessionStatus] error:",P?.message),nt.current=setTimeout(_,5e3);}};nt.current=setTimeout(_,3e3);},[Xt]),Et=react.useCallback(async()=>{if(we){b(true),R(),m("");try{m("Confirming purchase...");let r=await hr(we.id,K);rt(r),y("processing"),m(""),rr(r.id,K);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,rr,we]);react.useEffect(()=>{O==="quote"&&Ht&&we&&!N&&(At(false),Et());},[O,Ht,we,N,Et]);let qr=react.useCallback(()=>{y(o),b(false),m(""),te(null),se(e?.email??""),ve(e?.phone??""),Ae(""),Ee("US"),Fe(""),ze(""),_e(false),be(false),U(Tr),V(e?.recipientAddress??""),tt(stripeReactNative.Onramp.CryptoNetwork.ethereum),Yt(e?.defaultSourceAmount??"100"),Gt(e?.defaultSourceCurrency??"usd"),vt(e?.defaultDestinationCurrency??"usdc"),rt(null),At(false),De.current=false;},[e,o]);return {step:O,loading:N,status:Ve,error:ge,email:C,phone:M,fullName:Le,country:Re,customerId:Ne,accessToken:K,session:we,kycData:h,walletAddress:w,resolvedRecipientAddress:Wr,walletNetwork:We,sourceAmount:Ke,sourceCurrency:ft,destinationCurrency:yt,applePaySupported:Ur,walletReady:he,walletLoading:Ye,setStep:y,setStatus:m,setEmail:se,setPhone:ve,setFullName:Ae,setCountry:Ee,setWalletAddress:V,setWalletNetwork:tt,setSourceAmount:Yt,setSourceCurrency:Gt,setDestinationCurrency:vt,checkEmail:jr,register:Mr,attachKyc:Yr,verifyIdentity:er,registerWallet:tr,collectPaymentMethod:Gr,refreshQuote:Hr,confirmCheckout:Et,reset:qr,clearError:R,amountFirst:a}}function kr({size:e=28}){return jsxRuntime.jsx(gn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsxs(gn.G,{fillRule:"evenodd",children:[jsxRuntime.jsx(gn.Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsxRuntime.jsx(gn.Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function Pr({size:e=28}){return jsxRuntime.jsxs(gn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsxs(gn.G,{clipPath:"url(#eth_clip)",children:[jsxRuntime.jsx(gn.Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsxRuntime.jsx(gn.Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsxRuntime.jsx(gn.Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsxRuntime.jsx(gn.Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsxRuntime.jsx(gn.Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsxRuntime.jsx(gn.Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsxRuntime.jsx(gn.Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsxRuntime.jsx(gn.Defs,{children:jsxRuntime.jsx(gn.ClipPath,{id:"eth_clip",children:jsxRuntime.jsx(gn.Rect,{width:28,height:28,fill:"white"})})})]})}function Rr({size:e=28}){return jsxRuntime.jsxs(gn__default.default,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsxs(gn.G,{clipPath:"url(#btc_clip)",children:[jsxRuntime.jsx(gn.Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsxRuntime.jsx(gn.Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsxRuntime.jsx(gn.Defs,{children:jsxRuntime.jsx(gn.ClipPath,{id:"btc_clip",children:jsxRuntime.jsx(gn.Rect,{width:28,height:28,fill:"white"})})})]})}function Er({size:e=28}){return jsxRuntime.jsxs(gn__default.default,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxRuntime.jsxs(gn.Defs,{children:[jsxRuntime.jsxs(gn.LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(gn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(gn.Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxRuntime.jsxs(gn.LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(gn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(gn.Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxRuntime.jsxs(gn.LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx(gn.Stop,{offset:"0",stopColor:"#00FFA3"}),jsxRuntime.jsx(gn.Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsxRuntime.jsx(gn.Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxRuntime.jsxs(gn.G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsxRuntime.jsx(gn.Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsxRuntime.jsx(gn.Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsxRuntime.jsx(gn.Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function Dr({size:e=28}){return jsxRuntime.jsx(gn__default.default,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxRuntime.jsxs(gn.G,{children:[jsxRuntime.jsx(gn.Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsxRuntime.jsx(gn.Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var q="#00D924",Lr="#00D92440",Kn="#000000",Oe="#1C1C1E",Be="#38383A",Pe="#FFFFFF",fe="#8E8E93",ye="#636366",Un="#FF453A",Ir=[{label:"Base",value:stripeReactNative.Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:kr},{label:"Ethereum",value:stripeReactNative.Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Pr},{label:"Bitcoin",value:stripeReactNative.Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:Rr},{label:"Solana",value:stripeReactNative.Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:Er},{label:"Polygon",value:stripeReactNative.Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:Dr}];function Br(e,a){let o=parseFloat(e);if(isNaN(o))return e;let l=a.toLowerCase(),c=["eth","btc"].includes(l)?4:2;return o.toFixed(c)}function Ot({config:e,onComplete:a}){let{step:o,loading:l,status:c,error:x,email:B,phone:L,session:D,kycData:W,walletAddress:T,resolvedRecipientAddress:S,walletNetwork:k,sourceAmount:O,sourceCurrency:y,destinationCurrency:N,applePaySupported:b,walletReady:Ve,walletLoading:m,setStep:ge,setEmail:te,setPhone:C,setWalletAddress:se,setWalletNetwork:M,setSourceAmount:ve,setDestinationCurrency:Le,checkEmail:Ae,register:Re,attachKyc:Ee,verifyIdentity:Ne,registerWallet:Fe,collectPaymentMethod:K,refreshQuote:ze,confirmCheckout:he,reset:_e,clearError:Ye,amountFirst:be}=St(e),De=!!e?.email,ae=!!e?.phone,re=!!e?.publishableKey&&!!e?.externalUserId,F=()=>{_e(),a?.();};if(o==="email")return De?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Enter your email"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Email address"}),jsxRuntime.jsx(reactNative.TextInput,{style:n.input,placeholder:"jane@example.com",placeholderTextColor:ye,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:B,onChangeText:te,autoFocus:true,returnKeyType:"done",onSubmitEditing:Ae})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!B&&n.continueBtnDisabled],onPress:Ae,disabled:!B,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!B&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="register")return ae?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Enter your phone"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"We'll send a verification code to confirm your number."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Phone number"}),jsxRuntime.jsx(reactNative.TextInput,{style:n.input,placeholder:"+12125551234",placeholderTextColor:ye,keyboardType:"phone-pad",value:L,onChangeText:h=>C(h.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:Re}),jsxRuntime.jsx(reactNative.Text,{style:n.hint,children:"Include country code, e.g. +12125551234"})]}),jsxRuntime.jsxs(reactNative.View,{style:n.emailRow,children:[jsxRuntime.jsx(reactNative.Text,{style:n.emailLabel,children:"Signing up as"}),jsxRuntime.jsx(reactNative.Text,{style:n.emailValue,children:B})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!L&&n.continueBtnDisabled],onPress:Re,disabled:!L,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!L&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="kyc")return jsxRuntime.jsx(bt,{initialData:W,loading:l,onComplete:Ee,onCancel:()=>ge("email")});if(o==="identity")return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Verifying identity"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:c||"Preparing identity verification..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.Text,{style:A.idIcon,children:"\u{1FAAA}"})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Identity verification"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:c||"Tap below to continue verification."})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:false})]}),!l&&jsxRuntime.jsx(reactNative.View,{style:n.footer,children:jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:Ne,children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Continue Verification"})})})]});if(o==="wallet")return re?jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})}):jsxRuntime.jsx(reactNative.KeyboardAvoidingView,{style:n.flex,behavior:reactNative.Platform.OS==="ios"?"padding":void 0,children:jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Your crypto wallet"}),jsxRuntime.jsx(reactNative.Text,{style:n.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Wallet address"}),jsxRuntime.jsx(reactNative.TextInput,{style:[n.input,ke.input],placeholder:"0x...",placeholderTextColor:ye,autoCapitalize:"none",autoCorrect:false,value:T,onChangeText:se})]}),jsxRuntime.jsxs(reactNative.View,{style:n.fieldWrap,children:[jsxRuntime.jsx(reactNative.Text,{style:n.fieldLabel,children:"Network"}),jsxRuntime.jsx(reactNative.View,{style:ke.list,children:Ir.map(h=>{let U=k===h.value;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[ke.row,U&&ke.rowSelected],onPress:()=>{M(h.value),Le(h.defaultCrypto);},children:[jsxRuntime.jsx(reactNative.View,{style:ke.iconWrap,children:jsxRuntime.jsx(h.Icon,{size:24})}),jsxRuntime.jsx(reactNative.Text,{style:[ke.rowText,U&&ke.rowTextSelected],children:h.label}),U&&jsxRuntime.jsx(reactNative.View,{style:ke.checkCircle,children:jsxRuntime.jsx(reactNative.Text,{style:ke.check,children:"\u2713"})})]},h.value)})})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsx(reactNative.TouchableOpacity,{style:[n.continueBtn,!T&&n.continueBtnDisabled],onPress:Fe,disabled:!T,children:jsxRuntime.jsx(reactNative.Text,{style:[n.continueBtnText,!T&&n.continueBtnTextDisabled],children:"Continue"})}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="session_params")return jsxRuntime.jsx(ht,{initialAmount:O,currency:y,onConfirm:h=>{ve(h),ge(be?"email":"payment_method");},onCancel:()=>{be?F():ge("wallet");}});if(o==="payment_method"){let h=Ir.find(U=>U.value===k)?.label??k;return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(Ze,{onPress:F}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"How do you want to pay?"}),jsxRuntime.jsxs(reactNative.View,{style:X.summary,children:[jsxRuntime.jsxs(reactNative.View,{style:X.summaryCol,children:[jsxRuntime.jsx(reactNative.Text,{style:X.summaryLabel,children:"You spend"}),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryAmount,children:["$",O," ",jsxRuntime.jsx(reactNative.Text,{style:X.summaryCurrency,children:y.toUpperCase()})]})]}),jsxRuntime.jsx(reactNative.View,{style:X.divider}),jsxRuntime.jsxs(reactNative.View,{style:X.summaryCol,children:[jsxRuntime.jsx(reactNative.Text,{style:X.summaryLabel,children:"You receive"}),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryDest,children:[N.toUpperCase(),jsxRuntime.jsxs(reactNative.Text,{style:X.summaryNetwork,children:[" on ",h]})]})]})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[b&&jsxRuntime.jsx(reactNative.TouchableOpacity,{style:X.applePayBtn,onPress:()=>K(true),children:jsxRuntime.jsxs(reactNative.Text,{style:X.applePayBtnText,children:["Pay with ","\uF8FF"," Pay"]})}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:()=>K(false),children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Pay with Card"})})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="quote"&&D){let h=D.transaction_details,U=new Date(h.quote_expiration*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),w=h.wallet_address.slice(0,6)+"..."+h.wallet_address.slice(-4),V=Br(h.destination_amount,h.destination_currency);return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsx(reactNative.View,{style:{opacity:l?0:1},pointerEvents:l?"none":"auto",children:jsxRuntime.jsx(Ze,{onPress:F})}),jsxRuntime.jsxs(reactNative.View,{style:n.content,children:[jsxRuntime.jsx(reactNative.Text,{style:n.title,children:"Review your purchase"}),jsxRuntime.jsxs(reactNative.View,{style:E.heroBox,children:[jsxRuntime.jsx(reactNative.Text,{style:E.heroLabel,children:"You receive"}),jsxRuntime.jsxs(reactNative.Text,{style:E.heroAmount,children:[V," ",jsxRuntime.jsx(reactNative.Text,{style:E.heroCurrency,children:h.destination_currency.toUpperCase()})]}),jsxRuntime.jsx(reactNative.Text,{style:E.heroNetwork,children:h.destination_network})]}),jsxRuntime.jsxs(reactNative.View,{style:E.card,children:[jsxRuntime.jsx(Xe,{label:"You pay",value:`${h.source_amount} ${h.source_currency.toUpperCase()}`}),jsxRuntime.jsx(Xe,{label:"Network fee",value:`$${h.fees.network_fee_amount}`}),jsxRuntime.jsx(Xe,{label:"Transaction fee",value:`$${h.fees.transaction_fee_amount}`}),jsxRuntime.jsx(Xe,{label:"Wallet",value:w,mono:true}),jsxRuntime.jsx(Xe,{label:"Quote expires",value:U,last:true})]})]}),jsxRuntime.jsxs(reactNative.View,{style:n.footer,children:[l?jsxRuntime.jsx(reactNative.View,{style:n.continueBtn,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{color:"#fff"})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:he,children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Confirm Purchase"})}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.ghostBtn,onPress:ze,children:jsxRuntime.jsx(reactNative.Text,{style:n.ghostBtnText,children:"Refresh Quote"})})]}),jsxRuntime.jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="processing")return jsxRuntime.jsx(reactNative.View,{style:n.screen,children:jsxRuntime.jsxs(reactNative.View,{style:A.centered,children:[jsxRuntime.jsx(reactNative.View,{style:A.spinnerWrap,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:q})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Processing your purchase"}),jsxRuntime.jsxs(reactNative.Text,{style:A.sub,children:["Your payment has been confirmed.",`
2
+ `,"We're sending your crypto \u2014 this usually takes less than a minute."]})]})});if(o==="success"&&D){let h=D.transaction_details,U=Br(h.destination_amount,h.destination_currency),w=S||e?.recipientAddress||"";return jsxRuntime.jsxs(reactNative.View,{style:n.screen,children:[jsxRuntime.jsxs(reactNative.ScrollView,{contentContainerStyle:A.centered,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsx(reactNative.View,{style:A.checkCircle,children:jsxRuntime.jsx(reactNative.Text,{style:A.checkMark,children:"\u2713"})}),jsxRuntime.jsx(reactNative.Text,{style:A.heading,children:"Purchase complete!"}),jsxRuntime.jsx(reactNative.Text,{style:A.sub,children:"Your crypto is on its way to your wallet."}),jsxRuntime.jsxs(reactNative.View,{style:[E.heroBox,A.detailCard],children:[jsxRuntime.jsx(reactNative.Text,{style:E.heroLabel,children:"You received"}),jsxRuntime.jsx(reactNative.Text,{style:E.heroAmount,children:U}),jsxRuntime.jsxs(reactNative.Text,{style:E.heroCurrency,children:[h.destination_currency.toUpperCase()," (",h.destination_network,")"]})]}),jsxRuntime.jsxs(reactNative.View,{style:[E.card,A.detailCard],children:[jsxRuntime.jsx(Vr,{label:"Deposit Address",address:h.wallet_address}),w?jsxRuntime.jsx(Vr,{label:"Recipient Address",address:w,last:true}):jsxRuntime.jsx(Xe,{label:"Session",value:D.id.slice(0,8)+"..."+D.id.slice(-6),mono:true,last:true})]})]}),jsxRuntime.jsx(reactNative.View,{style:n.footer,children:jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.continueBtn,onPress:()=>{_e(),a?.();},children:jsxRuntime.jsx(reactNative.Text,{style:n.continueBtnText,children:"Done"})})})]})}return null}function Ze({onPress:e}){return jsxRuntime.jsxs(reactNative.View,{style:n.header,children:[jsxRuntime.jsx(reactNative.View,{style:n.headerSpacer}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:n.closeBtn,onPress:e,children:jsxRuntime.jsx(reactNative.Text,{style:n.closeBtnText,children:"\u2715"})})]})}function Se({error:e,progress:a,loading:o}){return e?jsxRuntime.jsx(reactNative.Text,{style:n.errorText,children:e.message}):a&&o&&__DEV__?jsxRuntime.jsx(reactNative.Text,{style:n.progressText,children:a}):null}function Xe({label:e,value:a,mono:o,last:l}){return jsxRuntime.jsxs(reactNative.View,{style:[E.row,l&&E.rowLast],children:[jsxRuntime.jsx(reactNative.Text,{style:E.rowLabel,children:e}),jsxRuntime.jsx(reactNative.Text,{style:[E.rowValue,o&&E.rowMono],children:a})]})}function Vr({label:e,address:a,last:o}){let[l,c]=react.useState(false),x=()=>{reactNative.Clipboard.setString(a),c(true),setTimeout(()=>c(false),2e3);};return jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[E.row,o&&E.rowLast,{flexDirection:"column",alignItems:"flex-start",gap:6}],onPress:x,activeOpacity:.7,children:[jsxRuntime.jsxs(reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",width:"100%"},children:[jsxRuntime.jsx(reactNative.Text,{style:E.rowLabel,children:e}),jsxRuntime.jsx(reactNative.Text,{style:{fontSize:12,color:l?q:fe},children:l?"Copied!":"Tap to copy"})]}),jsxRuntime.jsx(reactNative.Text,{style:[E.rowValue,E.rowMono,{fontSize:12,lineHeight:18}],selectable:true,children:a})]})}var n=reactNative.StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:Kn,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",justifyContent:"flex-end",paddingTop:60,paddingBottom:16},headerSpacer:{flex:1},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:Oe,alignItems:"center",justifyContent:"center"},closeBtnText:{color:fe,fontSize:14,fontWeight:"600"},content:{flex:1,paddingTop:16},title:{fontSize:28,fontWeight:"700",color:Pe,marginBottom:8},subtitle:{fontSize:15,color:fe,marginBottom:36,lineHeight:22},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:fe,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5},input:{backgroundColor:Oe,borderRadius:12,padding:16,fontSize:17,color:Pe,borderWidth:1,borderColor:Be},hint:{fontSize:12,color:ye,marginTop:8},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:Oe,paddingHorizontal:14,paddingVertical:10,borderRadius:10},emailLabel:{fontSize:13,color:ye},emailValue:{fontSize:13,color:Pe,fontWeight:"600"},footer:{gap:12},continueBtn:{backgroundColor:q,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:Oe},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:ye},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:fe,fontSize:15,fontWeight:"500"},errorText:{fontSize:14,color:Un,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,color:ye,textAlign:"center",lineHeight:18,marginTop:24}}),E=reactNative.StyleSheet.create({heroBox:{backgroundColor:Oe,borderRadius:16,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:1,borderColor:Be,gap:4},heroLabel:{fontSize:13,color:ye,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase"},heroAmount:{fontSize:48,fontWeight:"700",color:Pe,letterSpacing:-1},heroCurrency:{fontSize:22,fontWeight:"500",color:q},heroNetwork:{fontSize:13,color:ye,marginTop:2},card:{backgroundColor:Oe,borderRadius:16,borderWidth:1,borderColor:Be,overflow:"hidden"},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderBottomWidth:1,borderBottomColor:Be},rowLast:{borderBottomWidth:0},rowLabel:{fontSize:14,color:fe},rowValue:{fontSize:14,fontWeight:"600",color:Pe},rowMono:{fontFamily:reactNative.Platform.OS==="ios"?"Menlo":"monospace",fontSize:13}}),X=reactNative.StyleSheet.create({summary:{backgroundColor:Oe,borderRadius:16,padding:20,marginTop:16,marginBottom:28,borderWidth:1,borderColor:Be,gap:16},summaryCol:{gap:4},summaryLabel:{fontSize:12,color:ye,fontWeight:"600",textTransform:"uppercase",letterSpacing:.3},summaryAmount:{fontSize:24,fontWeight:"700",color:Pe},summaryCurrency:{fontSize:14,fontWeight:"400",color:fe},summaryDest:{fontSize:24,fontWeight:"700",color:q},summaryNetwork:{fontSize:13,fontWeight:"400",color:fe},divider:{height:1,backgroundColor:Be},applePayBtn:{backgroundColor:Pe,borderRadius:24,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:"#000",fontSize:17,fontWeight:"700"}}),ke=reactNative.StyleSheet.create({input:{fontSize:14,fontFamily:reactNative.Platform.OS==="ios"?"Menlo":"monospace"},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:Be,backgroundColor:Oe},rowSelected:{borderColor:q,backgroundColor:Lr},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:fe,fontWeight:"500"},rowTextSelected:{color:Pe,fontWeight:"600"},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:q,alignItems:"center",justifyContent:"center"},check:{fontSize:14,color:"#000",fontWeight:"700"}}),A=reactNative.StyleSheet.create({centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:Oe,borderWidth:1,borderColor:Be,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:Lr,borderWidth:2,borderColor:q,alignItems:"center",justifyContent:"center",marginBottom:28},checkMark:{fontSize:36,color:q,fontWeight:"600"},heading:{fontSize:28,fontWeight:"700",color:Pe,textAlign:"center",marginBottom:10},sub:{fontSize:15,color:fe,textAlign:"center",lineHeight:22,marginBottom:36},detailCard:{width:"100%"}});var qn="https://api.unifold.io",Qn="https://api-staging.unifold.io";function Jn(){return typeof __DEV__<"u"&&__DEV__?Qn:qn}function Pt({publishableKey:e,email:a,phone:o,externalUserId:l,flowOrder:c,destinationChainType:x="ethereum",destinationChainId:B="8453",destinationTokenAddress:L,recipientAddress:D,onComplete:W,onError:T,onStepChange:S,onClose:k,merchantIdentifier:O="merchant.io.unifold",urlScheme:y="unifoldOnramp"}){let N=e||wt(),[b,Ve]=react.useState("loading"),[m,ge]=react.useState(null);react.useEffect(()=>{let C=false;async function se(){try{N&&(xt(N),Ct(Jn()));let M=await Tt();if(C||(await stripeReactNative.initStripe({publishableKey:M,merchantIdentifier:O,urlScheme:y}),C))return;Ve("ready");}catch(M){if(C)return;console.error("[StripeOnramp] Init failed:",M),ge(M?.message??"Failed to load Stripe configuration"),Ve("error");}}return se(),()=>{C=true;}},[N,O,y]);let te=react.useMemo(()=>{let C={publishableKey:N,externalUserId:l,destinationChainType:x,destinationChainId:B,onComplete:W,onError:T,onStepChange:S};return L&&(C.destinationTokenAddress=L),D&&(C.recipientAddress=D),a&&(C.email=a),o&&(C.phone=o),c&&(C.flowOrder=c),C},[N,l,x,B,L,D,a,o,c,W,T,S]);return b==="error"?jsxRuntime.jsxs(reactNative.View,{style:et.centered,children:[jsxRuntime.jsx(reactNative.Text,{style:et.errorText,children:"Unable to initialize"}),jsxRuntime.jsx(reactNative.Text,{style:et.errorDetail,children:m}),k&&jsxRuntime.jsx(reactNative.TouchableOpacity,{style:et.retryBtn,onPress:k,children:jsxRuntime.jsx(reactNative.Text,{style:et.retryBtnText,children:"Go Back"})})]}):b==="loading"?jsxRuntime.jsx(reactNative.View,{style:et.centered,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:"#00D924"})}):jsxRuntime.jsx(Ot,{config:te,onComplete:k})}var et=reactNative.StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function zr(){let{configure:e}=stripeReactNative.useOnramp(),a=react.useRef(false);return react.useEffect(()=>{a.current||(a.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(o=>{o.error&&console.error("[StripeOnrampPreconfigure] error:",o.error.message);}).catch(o=>{console.error("[StripeOnrampPreconfigure] threw:",o?.message);}));},[e]),null}or(Pt);
3
+ exports.AmountScreen=ht;exports.KYCWizardScreen=bt;exports.OnrampScreen=Ot;exports.StripeOnramp=Pt;exports.StripeOnrampPreconfigure=zr;exports.getStripePublishableKey=Tt;exports.setStripeOnrampApiUrl=Ct;exports.setStripeOnrampPublishableKey=xt;exports.useStripeOnramp=St;