@unifold/connect-react-native 0.1.12 → 0.1.13

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/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {createContext,useState,useEffect,useRef,useMemo,useCallback,useContext}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,View,ActivityIndicator,Text,ScrollView,Animated,Modal,TouchableWithoutFeedback,TouchableOpacity,Image,Linking,TextInput,Clipboard,Easing}from'react-native';import {QueryClientProvider,QueryClient}from'@tanstack/react-query';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Se,{Path,Line,Polyline,SvgUri,Rect,Circle,Defs,LinearGradient,Stop}from'react-native-svg';import mi from'react-native-qrcode-svg';import {WebView}from'react-native-webview';import Ar from'@react-native-async-storage/async-storage';var gr={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},fr=gr;function Bo(e,t,o){let n=o?t?.[o]:void 0,r=(i,c,a)=>{let l=n?.[i]?.[c];if(l!==void 0)return l;let k=t?.[i]?.[c];return k!==void 0?k:a};return {header:{titleColor:r("header","titleColor",e.foreground),buttonColor:r("header","buttonColor",e.foreground)},card:{backgroundColor:r("card","backgroundColor",e.card),titleColor:r("card","titleColor",e.foreground),subtitleColor:r("card","subtitleColor",e.foregroundMuted),labelColor:r("card","labelColor",e.foregroundMuted),headerColor:r("card","headerColor",e.foregroundMuted),labelRightColor:r("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:r("card","labelHighlightRightColor",e.warning),textRightColor:r("card","textRightColor",e.foreground),subtextRightColor:r("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:r("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:r("card","rowRightLabel",e.foreground),iconColor:r("card","iconColor",e.primary),iconBackgroundColor:r("card","iconBackgroundColor",e.primary+"26"),actionColor:r("card","actionColor",e.foregroundMuted),actionIcon:r("card","actionIcon",e.foregroundMuted),descriptionColor:r("card","descriptionColor",e.foregroundMuted)},input:{backgroundColor:r("input","backgroundColor",e.card),textColor:r("input","textColor",e.foreground),placeholderColor:r("input","placeholderColor",e.foregroundMuted),borderColor:r("input","borderColor",e.border)},button:{primaryBackground:r("button","primaryBackground",e.primary),primaryText:r("button","primaryText",e.primaryForeground),secondaryBackground:r("button","secondaryBackground",e.card),secondaryText:r("button","secondaryText",e.foreground)},container:{titleColor:r("container","titleColor",e.foreground),subtitleColor:r("container","subtitleColor",e.foregroundMuted),actionColor:r("container","actionColor",e.foregroundMuted),actionTitle:r("container","actionTitle",e.foregroundMuted),buttonColor:r("container","buttonColor",e.primary),buttonTitleColor:r("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:r("container","iconBackgroundColor",e.success),iconColor:r("container","iconColor",e.foreground)},search:{backgroundColor:r("search","backgroundColor",e.card),inputColor:r("search","inputColor",e.foreground),placeholderColor:r("search","placeholderColor",e.foregroundMuted)},list:{titleSectionColor:r("list","titleSectionColor",e.foregroundMuted)}}}function mr(e,t,o){let r={...gr[e]};return o&&(r.primary=o),t&&(r={...r,...t}),r}var Qr=createContext(null);function Wo({children:e,mode:t="auto",accentColor:o,theme:n,fontFamily:r,fonts:i,components:c}){let a=useColorScheme(),l=useMemo(()=>t==="auto"?a==="dark"?"dark":"light":t,[t,a]),k=useMemo(()=>{let d=n?.[l];return mr(l,d,o)},[l,n,o]),x=useMemo(()=>Bo(k,c,l),[k,c,l]),I=useMemo(()=>i?{regular:i.regular||r,medium:i.medium||r,semibold:i.semibold||r,bold:i.bold||r}:r?{regular:r,medium:r,semibold:r,bold:r}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[r,i]),y=useMemo(()=>({mode:l,colors:k,fonts:I,components:x,isDark:l==="dark"}),[l,k,I,x]);return jsx(Qr.Provider,{value:y,children:e})}function A(){let e=useContext(Qr);if(!e){let t=fr.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Bo(t,void 0,"dark"),isDark:true}}return e}var Kn="https://api.unifold.io",zo,it="pk_test_123",Eo={};function Ee(){return typeof __DEV__<"u"&&__DEV__&&zo?zo:Kn}function Ao(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),it=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(zo=e.baseUrl),e.defaultConfig&&(Eo=e.defaultConfig);}function Gr(e){typeof __DEV__<"u"&&__DEV__?zo=e:console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function gt(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function Fe(e){let t=e.startsWith("/")?e:`/${e}`;return `${Ee()}/api/public${t}`}function j(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,Ee()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${Ee()}${e}`:`${Ee()}/api/public${e}`:""}async function Wt(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Eo.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Eo.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Eo.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||it;gt(n);let r=await fetch(`${Ee()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.statusText}`);return r.json()}function Et(e,t){return e.find(o=>o.chain_type===t)}async function zt(e,t){let o=t||it;gt(o);let n=await fetch(`${Ee()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function ie(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function Co(e,t){let o=e||it;gt(o);let n=`${Ee()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let i=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});n=`${n}?${i.toString()}`;}let r=await fetch(n,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch supported deposit tokens: ${r.statusText}`);return r.json()}async function hr(e,t){let o=t||it;gt(o);let n=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),r=await fetch(`${Ee()}/v1/public/tokens/token?${n.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch token metadata: ${r.statusText}`);return r.json()}function Oo(e,t,o){return !e||e.length===0?o||"":e.find(r=>r.format===t)?.url||o||e[0]?.url||""}async function yr(e,t){let o=t||it;gt(o);let n=await fetch(`${Ee()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch onramp quotes: ${n.statusText}`);return n.json()}async function Cr(e,t){let o=t||it;gt(o);let n=await fetch(`${Ee()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create onramp session: ${n.statusText}`);return n.json()}async function kr(e,t){let o=t||it;gt(o);let n=new URLSearchParams;e.country_code&&n.append("country_code",e.country_code),e.subdivision_code&&n.append("subdivision_code",e.subdivision_code),n.append("token_address",e.token_address),n.append("chain_id",e.chain_id),n.append("chain_type",e.chain_type);let r=await fetch(`${Ee()}/v1/public/onramps/default_token?${n.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.statusText}`);return r.json()}async function wr(e){let t=e||it;gt(t);let o=await fetch(`${Ee()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}function Xt(e,t="png"){if(!e||e.length===0)return;let o=e.find(n=>n.format===t);return o?o.url:e[0]?.url}async function ko(e){let t=e||it;gt(t);let o=await fetch(`${Ee()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}async function wo(){let e=await fetch(`${Ee()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}var{height:eo}=Dimensions.get("window");function de({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:r=true,heightPercent:i,noPadding:c=false}){let{colors:a}=A(),l=useRef(new Animated.Value(eo)).current,k=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(l.setValue(eo),k.setValue(0),Animated.parallel([Animated.spring(l,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(k,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(l,{toValue:eo,useNativeDriver:true,tension:65,friction:11}),Animated.timing(k,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,l,k]);let x=()=>{n&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(View,{style:At.container,children:[jsx(TouchableWithoutFeedback,{onPress:x,children:jsx(Animated.View,{style:[At.backdrop,{backgroundColor:"#000000",opacity:k}]})}),jsxs(Animated.View,{style:[At.sheet,{backgroundColor:a.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:l}],...i&&{height:eo*i,maxHeight:eo*i},...c&&{paddingBottom:0}}],children:[r&&jsx(View,{style:At.handleContainer,children:jsx(View,{style:[At.handle,{backgroundColor:a.border}]})}),jsx(View,{style:[At.content,i&&At.contentFlex],children:o})]})]})})}var At=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:eo*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function br({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function xr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ot({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Tr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ze({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ft({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ae({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function bo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _e({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ht({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function to({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Mo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Tt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function en({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function oo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ro({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Uo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Se,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ne({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:r,badge:i}){let{colors:c,fonts:a,components:l}=A();return jsxs(View,{style:Ze.header,children:[jsx(View,{style:Ze.leftContainer,children:t&&n?jsx(TouchableOpacity,{onPress:n,style:[Ze.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Tr,{size:20,color:l.header.buttonColor,strokeWidth:2})}):jsx(View,{style:Ze.spacer})}),jsxs(View,{style:Ze.titleContainer,children:[jsx(Text,{style:[Ze.title,{color:l.header.titleColor,fontFamily:a.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[Ze.titleBadge,{backgroundColor:c.card}],children:jsx(Text,{style:[Ze.titleBadgeText,{color:c.foregroundMuted,fontFamily:a.regular}],children:i.count})})]}),jsx(View,{style:Ze.rightContainer,children:o?jsx(TouchableOpacity,{onPress:r,style:[Ze.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ze,{size:20,color:l.header.buttonColor,strokeWidth:2})}):jsx(View,{style:Ze.spacer})})]})}var Ze=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},leftContainer:{width:40,alignItems:"flex-start"},rightContainer:{width:40,alignItems:"flex-end"},titleContainer:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function St({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:r=0,borderColor:i="transparent",backgroundColor:c="transparent",style:a}){let{colors:l}=A(),[k,x]=useState(false),I=e?.toLowerCase().endsWith(".svg");useEffect(()=>{x(false);},[e]);let y=l.card;if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:y},a]});let d={width:t,height:o,borderRadius:n,borderWidth:r,borderColor:i,backgroundColor:c,overflow:"hidden",alignItems:"center",justifyContent:"center",...a},u=t-r*2,s=o-r*2;return k?jsx(View,{style:[d,{backgroundColor:c||y}]}):I?jsx(View,{style:d,children:jsx(SvgUri,{uri:e,width:u,height:s,onError:g=>{x(true);}})}):jsx(View,{style:d,children:jsx(Image,{source:{uri:e},style:{width:u,height:s},resizeMode:"contain",onError:g=>{x(true);}})})}function xo({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:r,fonts:i,components:c}=A(),a=n?[...n].sort((l,k)=>l.position-k.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[mt.container,{backgroundColor:c.card.backgroundColor}],children:[jsxs(View,{style:mt.leftContent,children:[jsx(View,{style:mt.iconContainer,children:jsx(br,{size:20,color:c.card.iconColor,strokeWidth:2})}),jsxs(View,{style:mt.textContainer,children:[jsx(Text,{style:[mt.title,{color:c.card.titleColor,fontFamily:i.regular}],children:t}),jsx(Text,{style:[mt.subtitle,{color:c.card.subtitleColor,fontFamily:i.regular}],children:o})]})]}),jsx(View,{style:mt.rightContent,children:jsx(View,{style:mt.networkIcons,children:a.map((l,k)=>{let x=l.icon_urls.find(I=>I.format==="png")?.url||l.icon_urls.find(I=>I.format==="svg")?.url;return jsx(View,{style:[mt.networkIconWrapper,{marginLeft:k===0?0:-6,zIndex:a.length-k}],children:jsx(St,{uri:j(x),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:c.card.backgroundColor})},l.name)})})})]})}var mt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function So({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{fonts:r,components:i}=A();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[It.container,{backgroundColor:i.card.backgroundColor}],children:[jsxs(View,{style:It.leftContent,children:[jsx(View,{style:It.iconContainer,children:jsx(xr,{size:20,color:i.card.iconColor,strokeWidth:2})}),jsxs(View,{style:It.textContainer,children:[jsx(Text,{style:[It.title,{color:i.card.titleColor,fontFamily:r.regular}],children:t}),jsx(Text,{style:[It.subtitle,{color:i.card.subtitleColor,fontFamily:r.regular}],children:o})]})]}),jsx(View,{style:It.rightContent,children:jsx(View,{style:It.paymentIcons,children:n?.map(c=>{let a=c.icon_urls.find(l=>l.format==="png")?.url||c.icon_urls.find(l=>l.format==="svg")?.url;return jsx(St,{uri:j(a),width:32,height:20,borderRadius:4},c.name)})})})]})}var It=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function _o({onPress:e,title:t,subtitle:o,badge:n}){let{fonts:r,components:i}=A();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[vt.container,{backgroundColor:i.card.backgroundColor}],children:jsxs(View,{style:vt.leftContent,children:[jsxs(View,{style:vt.iconContainer,children:[jsx(Ot,{size:20,color:i.card.iconColor,strokeWidth:2}),n!==void 0&&n>0&&jsx(View,{style:[vt.badge,{backgroundColor:i.card.iconColor}],children:jsx(Text,{style:[vt.badgeText,{fontFamily:r.semibold}],children:n>99?"99+":n})})]}),jsxs(View,{style:vt.textContainer,children:[jsx(Text,{style:[vt.title,{color:i.card.titleColor,fontFamily:r.regular}],children:t}),jsx(Text,{style:[vt.subtitle,{color:i.card.subtitleColor,fontFamily:r.regular}],children:o})]})]})})}var vt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function ao({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:r}){let{colors:i,isDark:c}=A(),a=c?"#1a1a1a":"#ffffff",l=c?"#ffffff":"#000000",k=r||a;return jsxs(View,{style:[ln.container,{width:t,height:t}],children:[jsx(mi,{value:e||"placeholder",size:t,backgroundColor:a,color:l,ecl:"H",quietZone:4}),o&&jsx(View,{style:[ln.logoContainer,{width:n+12,height:n+12,backgroundColor:k,borderRadius:(n+12)/2}],children:jsx(St,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var ln=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function Ii({size:e,strokeWidth:t,iconSize:o,children:n}){let r=useRef(new Animated.Value(0)).current,i=(e-t)/2,c=2*Math.PI*i,a=e/2,l=(e-o)/2;useEffect(()=>{let x=Animated.loop(Animated.timing(r,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return x.start(),()=>x.stop()},[r]);let k=r.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:{width:e,height:e},children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:k}]},children:jsxs(Se,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:"progressGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:"#F59E0B"}),jsx(Stop,{offset:"100%",stopColor:"#FBBF24"})]})}),jsx(Circle,{cx:a,cy:a,r:i,stroke:"url(#progressGradient)",strokeWidth:t,fill:"none",strokeDasharray:`${c*.75} ${c*.25}`,strokeLinecap:"round",rotation:-90,origin:`${a}, ${a}`})]})}),jsx(View,{style:{position:"absolute",top:l+1.5,left:l,width:o,height:o},children:n})]})}function pn(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function vi(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),r=e.getFullYear(),i=e.getHours(),c=e.getMinutes(),a=i>=12?"pm":"am";i=i%12,i=i||12;let l=c<10?`0${c}`:c;return `${o} ${n}, ${r} at ${i}:${l}${a}`}function lo({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:r,date:i,amountUsd:c,onClose:a}){let{colors:l,fonts:k,components:x}=A(),[I,y]=useState(false),d=t==="pending"||t==="waiting"||t==="delayed",u=t==="succeeded",s=()=>{n&&Linking.openURL(n);},g=()=>{r&&Linking.openURL(r);};return jsx(de,{visible:e,onClose:a,closeOnBackdropPress:true,showHandle:false,children:jsxs(View,{style:ue.container,children:[jsx(TouchableOpacity,{style:ue.closeButton,onPress:a,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ze,{size:20,color:x.header.buttonColor,strokeWidth:2})}),jsx(View,{style:ue.iconContainer,children:d?jsx(Ii,{size:80,strokeWidth:4,iconSize:68,children:o?jsx(Image,{source:{uri:j(o)},style:ue.tokenIconFill}):jsx(View,{style:[ue.tokenIconFill,{backgroundColor:l.cardHover}]})}):jsxs(Fragment,{children:[o?jsx(Image,{source:{uri:j(o)},style:ue.tokenIconLarge}):jsx(View,{style:[ue.tokenIconLarge,{backgroundColor:l.cardHover}]}),jsx(View,{style:[ue.statusBadge,{backgroundColor:x.container.iconBackgroundColor}],children:jsx(_e,{size:16,color:x.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[ue.title,{color:x.container.titleColor,fontFamily:k.semibold}],children:d?"Deposit Processing":"Deposit Complete"}),c!==void 0&&jsxs(Text,{style:[ue.amount,{color:x.container.titleColor,fontFamily:k.bold}],children:["$",c.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),i&&jsx(Text,{style:[ue.date,{color:x.container.subtitleColor,fontFamily:k.regular}],children:vi(i)}),jsx(Text,{style:[ue.subtitle,{color:x.container.subtitleColor,fontFamily:k.regular}],children:d?"This usually takes less than a minute.":"Your account has been credited successfully!"}),u&&(n||r)&&jsxs(View,{style:ue.detailsSection,children:[jsx(View,{style:[ue.divider,{backgroundColor:l.border}]}),jsxs(TouchableOpacity,{style:ue.detailsToggle,onPress:()=>y(!I),children:[jsx(Text,{style:[ue.detailsToggleText,{color:x.container.actionTitle,fontFamily:k.medium}],children:I?"See less":"See more details"}),I?jsx(Tt,{size:18,color:x.container.actionColor,strokeWidth:2}):jsx(Ae,{size:18,color:x.container.actionColor,strokeWidth:2})]}),I&&jsxs(View,{style:ue.txButtonsContainer,children:[n&&jsxs(TouchableOpacity,{style:[ue.txButton,{backgroundColor:x.card.backgroundColor,borderColor:l.border}],onPress:s,children:[jsx(Text,{style:[ue.txLabel,{color:x.card.titleColor,fontFamily:k.medium}],children:"Deposit tx"}),jsx(Text,{style:[ue.txHash,{color:x.card.subtitleColor,fontFamily:k.regular}],children:pn(n)}),jsx(Ht,{size:16,color:x.card.actionColor,strokeWidth:2})]}),r&&jsxs(TouchableOpacity,{style:[ue.txButton,{backgroundColor:x.card.backgroundColor,borderColor:l.border}],onPress:g,children:[jsx(Text,{style:[ue.txLabel,{color:x.card.titleColor,fontFamily:k.medium}],children:"Completion tx"}),jsx(Text,{style:[ue.txHash,{color:x.card.subtitleColor,fontFamily:k.regular}],children:pn(r)}),jsx(Ht,{size:16,color:x.card.actionColor,strokeWidth:2})]})]})]})]})})}var ue=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});var vo=(e,t)=>`${t}:${e}`,Pi=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Yo({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:r,destinationTokenAddress:i,destinationTokenSymbol:c,defaultChainType:a,defaultChainId:l,defaultTokenAddress:k,onExecutionsChange:x,onDepositSuccess:I,onDepositError:y}){let{colors:d,fonts:u,components:s}=A(),g=a&&l?`${a}:${l}`:"solana:mainnet",[E,P]=useState("USDC"),[D,v]=useState(g),[Y,f]=useState([]),[re,Z]=useState(true),[ee,ye]=useState([]),[$,ve]=useState(true),[he,Oe]=useState(false),[Qe,te]=useState(false),[we,He]=useState(false),[Pe,De]=useState(false),[be,dt]=useState([]),[bt,Gt]=useState(new Map),[rt]=useState(()=>new Date),[Lt,Ge]=useState(null),[Rt,Vt]=useState(false),[le,Yt]=useState(null),[Ve,Ye]=useState(false),ut=new Map;ee.forEach(m=>{m.chains.forEach(w=>{let R=`${w.chain_type}:${w.chain_id}`;ut.has(R)||ut.set(R,w);});});let go=Array.from(ut.values()),Je=Pi(D),Be=go.find(m=>m.chain_type===Je.chainType&&m.chain_id===Je.chainId)?.chain_type||"ethereum",Le=Et(Y,Be)?.address||"",Pt=useRef(false);useEffect(()=>{async function m(){try{ve(!0),Ge(null);let R=await Co(t,i&&r&&n?{destination_token_address:i,destination_chain_id:r,destination_chain_type:n}:void 0);if(ye(R.data),R.data.length>0&&!Pt.current){Pt.current=!0;let T,H;if(a&&l)if(k)for(let q of R.data){let Te=q.chains.find(We=>We.chain_type===a&&We.chain_id===l&&We.token_address.toLowerCase()===k.toLowerCase());if(Te){T=q,H=Te;break}}else for(let q of R.data){let Te=q.chains.find(We=>We.chain_type===a&&We.chain_id===l);if(Te){T=q,H=Te;break}}if(!T&&i)for(let q of R.data){let Te=q.chains.find(We=>We.token_address.toLowerCase()===i.toLowerCase());if(Te){T=q,H=Te;break}}T||(T=R.data.find(q=>q.symbol==="USDC"),T&&T.chains.length>0&&(H=T.chains[0])),T||(T=R.data.find(q=>q.symbol==="USDT"),T&&T.chains.length>0&&(H=T.chains[0])),T||(T=R.data[0],T.chains.length>0&&(H=T.chains[0])),T&&P(T.symbol),H&&v(vo(H.chain_id,H.chain_type));}}catch(w){console.error("Error fetching supported tokens:",w),Ge("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:w});}finally{ve(false);}}m();},[t,y,a,l,k,i,r,n]),useEffect(()=>{async function m(){try{Z(!0),Ge(null);let w=await Wt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:r,destination_token_address:i},t);f(w.data);}catch(w){console.error("Error fetching wallets:",w),Ge("Failed to load wallets"),y?.({message:"Failed to load wallets",error:w});}finally{Z(false);}}m();},[e,o,n,r,i,t,y]),useEffect(()=>{if(!e||!rt)return;let m=setInterval(async()=>{try{let w=await zt(e,t),R=null;for(let T of w.data){let H=T.created_at?new Date(T.created_at):null;if(!H||H<=rt)continue;let q=bt.get(T.id);if(!q){R=T;break}if(["pending","waiting","delayed"].includes(q)&&T.status==="succeeded"){R=T;break}}if(R){let T=R;dt(H=>{let q=H.findIndex(Te=>Te.id===T.id);if(q>=0){let Te=[...H];return Te[q]=T,Te}else return [...H,T]}),Gt(H=>{let q=new Map(H);return q.set(T.id,T.status),q}),Yt(T),Vt(!0),T.status==="succeeded"&&I?.({message:"Deposit completed successfully",executionId:T.id}),x?.([...be,T]);}}catch(w){console.error("Error polling executions:",w),y?.({message:"Failed to check deposit status",error:w});}},5e3);return ()=>clearInterval(m)},[e,t,rt,bt,be,x,I,y]),useEffect(()=>{if(!ee.length)return;let m=ee.find(R=>R.symbol===E);if(!m||m.chains.length===0)return;if(!m.chains.some(R=>vo(R.chain_id,R.chain_type)===D)){let R=m.chains[0];v(vo(R.chain_id,R.chain_type));}},[E,ee,D]);let pe=ee.find(m=>m.symbol===E),fo=pe?.chains||[],xe=fo.find(m=>vo(m.chain_id,m.chain_type)===D),Jt=async()=>{if(Le)try{Clipboard.setString(Le),Oe(!0),setTimeout(()=>Oe(!1),2e3);}catch(m){console.error("Failed to copy:",m);}},Me=xe?.estimated_price_impact_percent??0,Bt=xe?.max_slippage_percent??.25,mo=xe?.minimum_deposit_amount_usd??3;if($)return jsxs(View,{style:p.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:d.primary}),jsx(Text,{style:[p.loadingText,{color:d.foregroundMuted,fontFamily:u.regular}],children:"Loading currencies..."})]});if(Lt&&ee.length===0)return jsxs(View,{style:p.errorContainer,children:[jsx(Text,{style:[p.errorText,{color:d.error,fontFamily:u.regular}],children:Lt}),jsx(Text,{style:[p.errorHint,{color:d.foregroundMuted,fontFamily:u.regular}],children:"Please check your network connection and try again."})]});let N=()=>jsxs(de,{visible:we,onClose:()=>He(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[p.sheetHeader,{borderBottomColor:d.border}],children:[jsx(View,{style:p.sheetHeaderSpacer}),jsx(Text,{style:[p.sheetTitle,{color:s.header.titleColor,fontFamily:u.medium}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>He(false),style:p.sheetCloseButton,children:jsx(ze,{size:20,color:s.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:p.sheetList,showsVerticalScrollIndicator:false,children:ee.map(m=>jsxs(TouchableOpacity,{onPress:()=>{P(m.symbol),He(false);},style:[p.sheetItem,{backgroundColor:E===m.symbol?s.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:j(ie(m,"png"))},style:p.sheetItemIcon}),jsxs(View,{style:p.sheetItemText,children:[jsx(Text,{style:[p.sheetItemTitle,{color:s.card.titleColor,fontFamily:u.medium}],children:m.symbol}),jsxs(Text,{style:[p.sheetItemSubtitle,{color:s.card.subtitleColor,fontFamily:u.regular}],children:[m.chains.length," network",m.chains.length!==1?"s":""," available"]})]}),E===m.symbol&&jsx(_e,{size:20,color:d.primary,strokeWidth:2})]},m.symbol))})]}),se=()=>jsxs(de,{visible:Pe,onClose:()=>De(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[p.sheetHeader,{borderBottomColor:d.border}],children:[jsx(View,{style:p.sheetHeaderSpacer}),jsx(Text,{style:[p.sheetTitle,{color:s.header.titleColor,fontFamily:u.medium}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>De(false),style:p.sheetCloseButton,children:jsx(ze,{size:20,color:s.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:p.sheetList,showsVerticalScrollIndicator:false,children:fo.map(m=>{let w=vo(m.chain_id,m.chain_type),R=D===w;return jsxs(TouchableOpacity,{onPress:()=>{v(w),De(false);},style:[p.sheetItem,{backgroundColor:R?s.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:j(ie(m,"png"))},style:p.sheetItemIcon}),jsxs(View,{style:p.sheetItemText,children:[jsx(Text,{style:[p.sheetItemTitle,{color:s.card.titleColor,fontFamily:u.medium}],children:m.chain_name}),jsxs(Text,{style:[p.sheetItemSubtitle,{color:s.card.subtitleColor,fontFamily:u.regular}],children:["Min deposit: $",m.minimum_deposit_amount_usd]})]}),R&&jsx(_e,{size:20,color:d.primary,strokeWidth:2})]},w)})})]});return jsxs(View,{style:p.container,children:[jsxs(View,{style:p.selectorSection,children:[jsx(Text,{style:[p.selectorLabel,{color:s.card.labelColor,fontFamily:u.regular}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>He(true),style:[p.selector,{backgroundColor:s.card.backgroundColor}],children:[pe&&jsx(Image,{source:{uri:j(ie(pe,"png"))},style:p.selectorIcon}),jsx(Text,{style:[p.selectorText,{color:s.card.titleColor,fontFamily:u.medium}],children:E}),jsx(Ae,{size:16,color:s.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:p.selectorSection,children:[jsxs(Text,{style:[p.selectorLabel,{color:s.card.labelColor,fontFamily:u.regular}],children:["Network"," ",jsxs(Text,{style:[p.minDeposit,{fontFamily:u.regular}],children:["($",mo," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>De(true),style:[p.selector,{backgroundColor:s.card.backgroundColor}],children:[xe&&jsx(Image,{source:{uri:j(ie(xe,"png"))},style:p.selectorIcon}),jsx(Text,{style:[p.selectorText,{color:s.card.titleColor,fontFamily:u.medium}],numberOfLines:1,children:xe?.chain_name||"Select network"}),jsx(Ae,{size:16,color:s.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:p.qrContainer,children:jsx(View,{style:[p.qrWrapper,{backgroundColor:d.background,borderColor:d.border}],children:re?jsxs(View,{style:p.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.primary}),jsx(Text,{style:[p.loadingText,{color:d.foregroundMuted,fontFamily:u.regular}],children:"Loading..."})]}):Le?jsx(ao,{value:Le,size:160,logoUri:j(ie(xe,"png")||Fe("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:p.qrLoading,children:jsx(Text,{style:[p.errorText,{color:d.error,fontFamily:u.regular}],children:"No address available"})})})}),jsxs(View,{style:p.addressSection,children:[jsxs(View,{style:p.addressHeader,children:[jsx(Text,{style:[p.addressLabel,{color:s.card.labelColor,fontFamily:u.medium}],children:"Deposit Address"}),he&&jsxs(View,{style:p.copiedIndicator,children:[jsx(_e,{size:14,color:d.success,strokeWidth:2}),jsx(Text,{style:[p.copiedText,{color:d.success,fontFamily:u.regular}],children:"Copied"})]})]}),jsxs(TouchableOpacity,{onPress:Jt,disabled:!Le||re,activeOpacity:.7,style:[p.addressBox,{backgroundColor:s.card.backgroundColor}],children:[jsx(Text,{style:[p.addressText,{color:s.card.titleColor,fontFamily:u.regular}],numberOfLines:2,children:re?"Loading...":Le||"No address available"}),jsx(View,{style:p.addressCopyIcon,children:jsx(bo,{size:16,color:s.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[p.detailsCard,{backgroundColor:s.card.backgroundColor}],children:[jsxs(TouchableOpacity,{onPress:()=>te(!Qe),style:p.detailsHeader,children:[jsxs(View,{style:p.detailsRow,children:[jsx(View,{style:[p.detailIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(Ot,{size:12,color:s.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[p.detailsLabel,{color:s.card.titleColor,fontFamily:u.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:p.chevronContainer,children:Qe?jsx(Tt,{size:16,color:s.card.actionColor,strokeWidth:2}):jsx(Ae,{size:16,color:s.card.actionColor,strokeWidth:2})})]}),Qe&&jsxs(View,{style:p.detailsContent,children:[jsxs(View,{style:p.detailsRow,children:[jsx(View,{style:[p.detailIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(to,{size:12,color:s.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[p.detailsLabel,{color:s.card.titleColor,fontFamily:u.regular}],children:["Price impact: ",Me.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Ye(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(oo,{size:14,color:s.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:p.detailsRow,children:[jsx(View,{style:[p.detailIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(ro,{size:12,color:s.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[p.detailsLabel,{color:s.card.titleColor,fontFamily:u.regular}],children:["Slippage: Auto \u2022 ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Ye(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(oo,{size:14,color:s.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:p.detailsRow,children:[jsx(View,{style:[p.detailIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(Mo,{size:12,color:s.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[p.detailsLabel,{color:s.card.titleColor,fontFamily:u.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:p.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[p.termsText,{color:d.primary,fontFamily:u.regular}],children:"Terms apply"})}),N(),se(),jsxs(de,{visible:Ve,onClose:()=>Ye(false),closeOnBackdropPress:true,showHandle:true,children:[jsxs(View,{style:[p.sheetHeader,{borderBottomColor:d.border}],children:[jsx(View,{style:p.sheetHeaderSpacer}),jsx(Text,{style:[p.sheetTitle,{color:s.header.titleColor,fontFamily:u.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>Ye(false),style:p.sheetCloseButton,children:jsx(ze,{size:20,color:s.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:p.infoSheetContent,children:[jsxs(View,{style:[p.infoCard,{backgroundColor:s.card.backgroundColor}],children:[jsxs(View,{style:p.infoCardHeader,children:[jsx(View,{style:[p.infoCardIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(to,{size:16,color:s.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[p.infoCardTitle,{color:s.card.titleColor,fontFamily:u.medium}],children:"Price Impact"}),jsxs(Text,{style:[p.infoCardValue,{color:s.card.titleColor,fontFamily:u.medium}],children:[Me.toFixed(2),"%"]})]}),jsx(Text,{style:[p.infoCardDescription,{color:s.card.descriptionColor,fontFamily:u.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[p.infoCard,{backgroundColor:s.card.backgroundColor}],children:[jsxs(View,{style:p.infoCardHeader,children:[jsx(View,{style:[p.infoCardIcon,{backgroundColor:s.card.iconBackgroundColor}],children:jsx(ro,{size:16,color:s.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[p.infoCardTitle,{color:s.card.titleColor,fontFamily:u.medium}],children:"Max Slippage"}),jsxs(Text,{style:[p.infoCardValue,{color:s.card.titleColor,fontFamily:u.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[p.infoCardDescription,{color:s.card.descriptionColor,fontFamily:u.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),le&&jsx(lo,{visible:Rt,status:le.status,tokenIconUrl:le.destination_token_metadata?.icon_urls?.find(m=>m.format==="png")?.url||le.destination_token_metadata?.icon_url||ie(pe,"png"),explorerUrl:le.explorer_url,completionExplorerUrl:le.destination_explorer_url,date:le.created_at?new Date(le.created_at):void 0,amountUsd:le.source_amount_usd?parseFloat(le.source_amount_usd):void 0,onClose:()=>Vt(false)})]})}var p=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16,borderRadius:16,borderWidth:1},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{maxHeight:400,paddingTop:8},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function Jo({currency:e,isSelected:t,onSelect:o}){let{colors:n,fonts:r,components:i}=A();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[jt.container,{backgroundColor:i.card.backgroundColor}],children:[jsxs(View,{style:jt.leftContent,children:[jsx(View,{style:[jt.iconContainer,{backgroundColor:n.background}],children:jsx(Image,{source:{uri:j(ie(e,"png"))},style:jt.icon})}),jsxs(View,{style:jt.textContainer,children:[jsx(Text,{style:[jt.name,{color:i.card.titleColor,fontFamily:r.medium}],children:e.name}),jsx(Text,{style:[jt.code,{color:i.card.subtitleColor,fontFamily:r.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(_e,{size:16,color:n.primary,strokeWidth:2})]})}var jt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function Lo({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{fonts:r,components:i}=A();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:yn.headerContainer,children:jsx(Text,{style:[yn.title,{color:i.list.titleSectionColor,fontFamily:r.medium}],children:e})}),t.map(c=>jsx(Jo,{currency:c,isSelected:o.toLowerCase()===c.currency_code.toLowerCase(),onSelect:n},c.currency_code))]})}var yn=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Xo({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:r,onSelectCurrency:i}){let{colors:c,fonts:a,components:l}=A(),[k,x]=useState(""),I=n.map(P=>o.find(D=>D.currency_code.toLowerCase()===P.toLowerCase())).filter(P=>P!==void 0),y=o.filter(P=>!n.includes(P.currency_code.toLowerCase())),d=P=>{if(!k)return P;let D=k.toLowerCase();return P.filter(v=>v.name.toLowerCase().includes(D)||v.currency_code.toLowerCase().includes(D))},u=d(I),s=d(y),g=P=>{i(P),t(false),x("");},E=()=>{t(false),x("");};return jsxs(de,{visible:e,onClose:E,closeOnBackdropPress:true,showHandle:false,children:[jsx(Ne,{title:"Currency",showBack:false,onClose:E}),jsx(View,{style:Nt.searchContainer,children:jsx(TextInput,{style:[Nt.searchInput,{backgroundColor:l.search.backgroundColor,color:l.search.inputColor,fontFamily:a.regular}],value:k,onChangeText:x,placeholder:"Search",placeholderTextColor:l.search.placeholderColor})}),jsx(ScrollView,{style:Nt.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:Nt.listContent,children:[jsx(Lo,{title:"Popular currencies",currencies:u,selectedCurrency:r,onSelect:g}),u.length>0&&s.length>0&&jsx(View,{style:Nt.sectionSpacer}),jsx(Lo,{title:"All currencies",currencies:s,selectedCurrency:r,onSelect:g}),u.length===0&&s.length===0&&jsx(View,{style:Nt.noResultsContainer,children:jsx(Text,{style:[Nt.noResultsText,{color:l.container.subtitleColor,fontFamily:a.regular}],children:"No currencies found"})})]})})]})}var Nt=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Pr(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function Zo({externalUserId:e,publishableKey:t,view:o,onViewChange:n,destinationTokenSymbol:r,recipientAddress:i,destinationChainType:c,destinationChainId:a,destinationTokenAddress:l,onDepositSuccess:k,onDepositError:x}){let{colors:I,fonts:y,components:d}=A(),[u,s]=useState(""),[g,E]=useState("usd"),[P,D]=useState(false),[v,Y]=useState(false),[f,re]=useState([]),[Z,ee]=useState(false),[ye,$]=useState(null),[ve,he]=useState(null),[Oe,Qe]=useState("amount"),[te,we]=useState(null),[He,Pe]=useState(true),[De,be]=useState(null),[dt,bt]=useState(false),Gt=useRef(null),rt=useRef(false);useEffect(()=>{Gt.current=te;},[te]),useEffect(()=>{rt.current=dt;},[dt]);let[Lt,Ge]=useState([]),[Rt,Vt]=useState(true),[le,Yt]=useState(60),[Ve,Ye]=useState([]),[ut,go]=useState([]),[Je,Ft]=useState(null),[Be,ur]=useState(null),[Le,Pt]=useState(true),[pe,fo]=useState(null),[xe,Jt]=useState(false),[Me,Bt]=useState(null),[mo,N]=useState(false),[se,m]=useState(false),[w,R]=useState(false),[T,H]=useState(null),q=o??Oe,Te=useRef(null),We=Ve.find(S=>S.currency_code.toLowerCase()===g.toLowerCase()),An=useCallback(S=>{Qe(S),S==="quotes"?n?.(S,f.length):n?.(S);},[f.length,n]);useEffect(()=>{async function S(){try{let F=await wo();ur(F);}catch(F){console.error("Error fetching user IP:",F);}finally{Pt(false);}}S();},[]),useEffect(()=>{async function S(){try{let F=await Wt({external_user_id:e,recipient_address:i,destination_chain_type:c,destination_chain_id:a,destination_token_address:l},t);Ge(F.data);}catch(F){console.error("Error fetching wallets:",F),$("Failed to load wallet addresses");}finally{Vt(false);}}S();},[e,i,c,a,l,t]);let On=r||Je?.symbol.toUpperCase()||"USDC",Hn=Xt(Je?.icon_urls,"png")||Je?.icon_url,Mn=Xt(Je?.chain_icon_urls,"png")||Je?.chain_icon_url;useEffect(()=>{async function S(){try{let F=await wr(t);Ye(F.data),go(F.preferred||[]);}catch(F){console.error("Error fetching fiat currencies:",F);}}S();},[t]),useEffect(()=>{if(P||Ve.length===0||!Be?.alpha2)return;let S=Be.alpha2.toUpperCase(),F=Ve.find(ce=>ce.country_codes.includes(S));if(F)E(F.currency_code.toLowerCase()),!u&&!v&&s(F.default_amount.toString());else if(!u&&!v){let ce=Ve.find(nt=>nt.currency_code.toLowerCase()==="usd");ce&&s(ce.default_amount.toString());}},[Ve,Be,P,u,v]),useEffect(()=>{if(Ve.length!==0){if(Te.current!==null&&Te.current!==g){let S=Ve.find(F=>F.currency_code.toLowerCase()===g.toLowerCase());S&&s(S.default_amount.toString());}Te.current=g;}},[g,Ve]),useEffect(()=>{async function S(){try{let F=await hr({chain_type:c||"",chain_id:a||"",token_address:l||""},t);Ft(F);}catch(F){console.error("Error fetching supported tokens:",F);}}S();},[c,a,l,t]),useEffect(()=>{async function S(){if(!(!l||!a||!c)&&!Le){Jt(true);try{let F=await kr({country_code:Be?.alpha2?.toUpperCase()||"US",subdivision_code:Be?.state||void 0,token_address:l,chain_id:a,chain_type:c},t);fo(F);}catch(F){console.error("Error fetching default onramp token:",F);}finally{Jt(false);}}}S();},[l,a,c,Be,Le,t]),useEffect(()=>{let S=parseFloat(u);if(isNaN(S)||S<=0){re([]),he(null);return}if(!pe||xe){re([]),we(null);return}let F=Ve.find(nt=>nt.currency_code.toLowerCase()===g.toLowerCase());if(F){if(S<F.minimum_amount){re([]),we(null),he(`Minimum amount is ${Pr(g)}${F.minimum_amount.toLocaleString()}`);return}if(S>F.maximum_amount){re([]),we(null),he(`Maximum amount is ${Pr(g)}${F.maximum_amount.toLocaleString()}`);return}}he(null);let ce=setTimeout(()=>{qr(S);},500);return ()=>clearTimeout(ce)},[u,g,t,pe,xe,Ve]);let qr=async S=>{if(!pe){$("Loading token information...");return}ee(true),$(null);try{let F={country_code:Be?.alpha2?.toUpperCase()||"US",source_amount:S.toString(),source_currency:g.toLowerCase(),destination_currency:pe.destination_currency,destination_network:pe.destination_network,subdivision_code:Be?.state||void 0},ce=await yr(F,t);re(ce.data);let nt=rt.current,$r=Gt.current;if(nt&&$r){let Kt=ce.data.find(pt=>pt.service_provider===$r.service_provider);if(Kt){if(we(Kt),ce.data.length>0){let pt=ce.data.reduce((xt,ho)=>ho.destination_amount>xt.destination_amount?ho:xt);De||be(pt.service_provider),Pe(Kt.service_provider===De);}}else if(ce.data.length>0){let pt=ce.data.reduce((xt,ho)=>ho.destination_amount>xt.destination_amount?ho:xt);we(pt),be(pt.service_provider),Pe(!0),bt(!1);}}else if(ce.data.length>0){let Kt=ce.data.reduce((pt,xt)=>xt.destination_amount>pt.destination_amount?xt:pt);we(Kt),be(Kt.service_provider),Pe(!0);}Yt(60);}catch(F){console.error("Failed to fetch quotes:",F),$("Failed to fetch quotes. Please try again."),re([]);}finally{ee(false);}};useEffect(()=>{if(f.length===0)return;let S=setInterval(()=>{Yt(F=>{if(F<=1){let ce=parseFloat(u);return !isNaN(ce)&&ce>0&&qr(ce),60}return F-1});},1e3);return ()=>clearInterval(S)},[f.length,u]);let Un=S=>{(/^\d*\.?\d{0,2}$/.test(S)||S==="")&&(s(S),Y(true));},jn=S=>{s(S.toString()),Y(true);},Nn=async()=>{if(te&&pe)try{let S=pe.destination_token_metadata.chain_type,F=Et(Lt,S);if(!F?.address){$("Wallet address not available");return}let ce={service_provider:te.service_provider,country_code:te.country_code?.toUpperCase()||Be?.alpha2?.toUpperCase()||"US",source_currency:te.source_currency,source_amount:u,destination_currency:te.destination_currency,destination_network:te.destination_network,wallet_address:F.address,subdivision_code:Be?.state||void 0},nt=await Cr(ce,t);Bt({provider:te,sourceCurrency:g,sourceAmount:u,sessionUrl:nt.url}),H(nt.url),R(!0);}catch(S){console.error("Failed to create session:",S),$("Failed to start payment flow"),x?.({message:"Failed to start payment flow",error:S});}},pr=Pr(g),qn=()=>{R(false),An("onramp"),k?.({message:"Payment flow completed"});},$n=()=>jsx(Gi,{visible:w,onClose:qn,url:T,providerName:te?.service_provider_display_name||"Complete Payment",colors:I,fonts:y});return q==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:b.amountViewContainer,children:[jsxs(ScrollView,{style:b.scrollContainer,contentContainerStyle:b.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:b.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>N(true),style:[b.currencyButton,{backgroundColor:d.card.backgroundColor}],children:[We&&jsx(Image,{source:{uri:j(ie(We,"png"))},style:b.currencyIcon}),jsx(Text,{style:[b.currencyText,{color:d.card.titleColor,fontFamily:y.medium}],children:g.toUpperCase()}),jsx(Ae,{size:16,color:d.card.actionColor,strokeWidth:2})]})}),jsx(Xo,{open:mo,onOpenChange:N,currencies:Ve,preferredCurrencyCodes:ut,selectedCurrency:g,onSelectCurrency:S=>{E(S.toLowerCase()),D(true);}}),jsx(View,{style:b.amountContainer,children:jsxs(View,{style:b.amountInputRow,children:[jsx(Text,{style:[b.currencySymbol,{color:d.container.titleColor,fontFamily:y.medium}],children:pr}),jsx(TextInput,{style:[b.amountInput,{color:d.container.titleColor,fontFamily:y.medium}],value:u,onChangeText:Un,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:I.foregroundMuted})]})}),We?.suggested_amounts&&We.suggested_amounts.length>0&&jsx(View,{style:b.quickAmounts,children:We.suggested_amounts.map(S=>jsx(TouchableOpacity,{onPress:()=>jn(S),style:[b.quickAmountButton,{backgroundColor:d.card.backgroundColor},parseFloat(u)===S&&{borderColor:I.primary,borderWidth:2}],children:jsxs(Text,{style:[b.quickAmountText,{color:d.card.titleColor,fontFamily:y.medium}],children:[pr,S.toLocaleString()]})},S))}),ve&&jsx(Text,{style:[b.validationError,{color:I.error,fontFamily:y.regular}],children:ve}),jsxs(View,{style:b.providerSection,children:[jsxs(View,{style:b.providerHeader,children:[jsx(Text,{style:[b.providerLabel,{color:d.card.labelColor,fontFamily:y.medium}],children:"Provider"}),f.length>0&&!Z&&jsxs(Text,{style:[b.refreshText,{color:d.card.labelRightColor,fontFamily:y.regular}],children:["Refreshing in ",le,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>m(true),disabled:Z||f.length===0,style:[b.providerButton,{backgroundColor:d.card.backgroundColor},(Z||f.length===0)&&b.disabled],children:Z?jsxs(View,{style:b.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.container.subtitleColor}),jsx(Text,{style:[b.loadingText,{color:d.container.subtitleColor,fontFamily:y.regular}],children:"Finding best rates..."})]}):te?jsxs(View,{style:b.providerContent,children:[jsxs(View,{style:b.providerInfo,children:[He&&jsx(Text,{style:[b.autoPickedText,{color:d.container.subtitleColor,fontFamily:y.regular}],children:"Auto-picked for you"}),jsxs(View,{style:b.providerRow,children:[jsx(Image,{source:{uri:j(Oo(te.icon_urls,"png",te.icon_url))},style:b.providerIconImage},`provider-${te.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[b.providerName,{color:d.card.titleColor,fontFamily:y.medium}],children:te.service_provider_display_name}),jsxs(Text,{style:[b.bestPriceText,{color:I.success,fontFamily:y.regular}],children:["Best price \u2022 ",te.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(ft,{size:20,color:d.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[b.noProviderText,{color:d.container.subtitleColor,fontFamily:y.regular}],children:parseFloat(u)>0?"No providers available":"Enter an amount to see providers"})}),ye&&jsx(Text,{style:[b.errorText,{color:I.error,fontFamily:y.regular}],children:ye})]}),jsxs(de,{visible:se,onClose:()=>m(false),closeOnBackdropPress:true,showHandle:false,children:[jsx(Ne,{title:"Select Provider",showBack:false,onClose:()=>m(false)}),jsx(ScrollView,{style:b.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:b.quotesList,children:[...f].sort((S,F)=>F.destination_amount-S.destination_amount).map((S,F)=>{let ce=te?.service_provider===S.service_provider,nt=F===0;return jsxs(TouchableOpacity,{onPress:()=>{we(S),bt(true),Pe(S.service_provider===De),m(false);},style:[b.quoteItem,{backgroundColor:d.card.backgroundColor},ce&&{borderColor:I.primary,borderWidth:2}],children:[jsxs(View,{style:b.quoteLeft,children:[jsx(Image,{source:{uri:j(Oo(S.icon_urls,"png",S.icon_url))},style:b.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[b.quoteName,{color:d.card.titleColor,fontFamily:y.medium}],children:S.service_provider_display_name}),nt&&jsx(Text,{style:[b.bestPriceLabel,{color:I.success,fontFamily:y.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:b.quoteRight,children:[jsxs(Text,{style:[b.quoteAmount,{color:d.card.textRightColor,fontFamily:y.medium}],children:[S.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[b.quoteSource,{color:d.card.subtextRightColor,fontFamily:y.regular}],children:["Fee: ",pr,S.total_fee.toFixed(2)]})]})]},S.service_provider)})})})]})]}),jsx(View,{style:[b.continueButtonContainer,{backgroundColor:I.background}],children:jsx(TouchableOpacity,{onPress:Nn,disabled:Z||Rt||!te||parseFloat(u)<=0,style:[b.continueButton,{backgroundColor:d.container.buttonColor},(Z||Rt||!te)&&b.disabledButton],children:jsx(Text,{style:[b.continueButtonText,{color:d.container.buttonTitleColor,fontFamily:y.medium}],children:Rt?"Loading...":"Continue"})})})]}),$n()]}):q==="onramp"&&Me?jsxs(View,{style:b.onrampContainer,children:[jsx(Image,{source:{uri:j(Oo(Me.provider.icon_urls,"png",Me.provider.icon_url))},style:b.onrampProviderIcon}),jsxs(Text,{style:[b.onrampTitle,{color:d.container.titleColor,fontFamily:y.medium}],children:["Complete transaction with ",Me.provider.service_provider_display_name]}),jsx(Text,{style:[b.onrampSubtitle,{color:d.container.subtitleColor,fontFamily:y.regular}],children:"You can close this modal."}),jsxs(View,{style:[b.flowDiagram,{backgroundColor:d.card.backgroundColor}],children:[jsxs(View,{style:b.flowStep,children:[jsx(Image,{source:{uri:Fe(`/icons/currencies/png/${Me.sourceCurrency.toLowerCase()}.png`)},style:b.flowIconImage}),jsx(Text,{style:[b.flowLabel,{color:d.card.subtitleColor,fontFamily:y.regular}],children:"You use"}),jsx(Text,{style:[b.flowValue,{color:d.card.titleColor,fontFamily:y.medium}],children:Me.sourceCurrency.toUpperCase()})]}),jsx(ft,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:b.flowStep,children:[jsxs(View,{style:b.flowIconWithBadge,children:[jsx(Image,{source:{uri:Xt(pe?.destination_token_metadata?.icon_urls,"png")||pe?.destination_token_metadata?.icon_url||Fe("/icons/tokens/png/usdc.png")},style:b.flowIconImageNoBadge}),jsx(Image,{source:{uri:Xt(pe?.destination_token_metadata?.chain?.icon_urls,"png")||pe?.destination_token_metadata?.chain?.icon_url||Fe("/icons/networks/png/polygon.png")},style:[b.flowNetworkBadge,{borderColor:I.background}]})]}),jsx(Text,{style:[b.flowLabel,{color:d.card.subtitleColor,fontFamily:y.regular}],children:"You buy"}),jsx(Text,{style:[b.flowValue,{color:d.card.titleColor,fontFamily:y.medium}],children:"USDC"})]}),jsx(ft,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:b.flowStep,children:[jsxs(View,{style:b.flowIconWithBadge,children:[jsx(Image,{source:{uri:Hn||Fe("/icons/tokens/png/usdc.png")},style:b.flowIconImageNoBadge}),jsx(Image,{source:{uri:Mn||Fe("/icons/networks/png/polygon.png")},style:[b.flowNetworkBadge,{borderColor:I.background}]})]}),jsx(Text,{style:[b.flowLabel,{color:d.card.subtitleColor,fontFamily:y.regular}],children:"You receive"}),jsx(Text,{style:[b.flowValue,{color:d.card.titleColor,fontFamily:y.medium}],children:On})]})]}),jsx(View,{style:[b.onrampInfoBox,{backgroundColor:d.card.backgroundColor}],children:jsx(Text,{style:[b.onrampInfoText,{color:d.card.descriptionColor,fontFamily:y.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function Gi({visible:e,onClose:t,url:o,providerName:n,colors:r,fonts:i}){return jsxs(de,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,children:[jsxs(View,{style:qt.header,children:[jsx(TouchableOpacity,{onPress:t,style:qt.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(_e,{size:20,color:r.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[qt.headerTitle,{color:r.foreground,fontFamily:i.medium}],children:n}),jsx(View,{style:qt.headerSpacer})]}),o&&jsx(View,{style:qt.container,children:jsx(WebView,{source:{uri:o},style:qt.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:qt.loading,children:jsx(ActivityIndicator,{size:"large",color:r.primary})})})})]})}var qt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),b=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,borderRadius:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},bestPriceLabel:{fontSize:11,marginTop:2},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function Zi(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function es(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function or({execution:e,onPress:t}){let {colors:o,fonts:n,components:r}=A(),i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let a=j(ie(e.destination_token_metadata,"png")||Fe("/icons/tokens/png/usdc.png")),l=i?"Deposit Processing":"Deposit Completed",k=Zi(e.created_at||new Date().toISOString()),x=es(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[kt.container,{backgroundColor:r.card.backgroundColor}],children:[jsxs(View,{style:kt.iconContainer,children:[jsx(Image,{source:{uri:a},style:kt.tokenIcon}),jsx(View,{style:[kt.statusBadge,{backgroundColor:i?o.warning:o.success,borderColor:r.card.backgroundColor}],children:i?jsx(en,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(_e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:kt.textContainer,children:[jsx(Text,{style:[kt.title,{color:r.card.titleColor,fontFamily:n.medium}],children:l}),jsx(Text,{style:[kt.dateTime,{color:r.card.subtitleColor,fontFamily:n.regular}],children:k})]}),jsxs(View,{style:kt.rightContainer,children:[jsx(Text,{style:[kt.amount,{color:r.card.textRightColor,fontFamily:n.medium}],children:x}),jsx(ft,{size:20,color:r.card.actionColor,strokeWidth:2})]})]})}var kt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});var{height:is}=Dimensions.get("window");function Sn(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function _n(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function ss(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var In=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function vn(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function as(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function nr({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:r}){let{colors:i,fonts:c,components:a}=A(),[l,k]=useState(o),[x,I]=useState(false),[y,d]=useState(null),[u,s]=useState(false),g=useRef(null);useEffect(()=>{if(!e||!n)return;let f=async()=>{I(true);try{let ee=[...(await zt(n,r)).data].sort((ye,$)=>{let ve=ye.created_at?new Date(ye.created_at).getTime():0;return ($.created_at?new Date($.created_at).getTime():0)-ve});k(ee);}catch(Z){console.error("Failed to fetch executions:",Z),k(o);}finally{I(false);}};f();let re=setInterval(f,1e4);return ()=>clearInterval(re)},[e,n,r,o]),useEffect(()=>{o.length>0&&k(f=>{let re=new Set(f.map(ee=>ee.id)),Z=o.filter(ee=>!re.has(ee.id));return Z.length>0?[...Z,...f]:f});},[o]),useEffect(()=>{e||d(null);},[e]);let E=f=>{d(f);},P=()=>{d(null),s(false);},D=()=>{d(null),t();};return jsxs(de,{visible:e,onClose:D,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,children:[jsx(Ne,{title:y?"Deposit Details":"Deposit Tracker",onClose:D,showClose:!y,showBack:!!y,onBack:P}),y?(()=>{if(!y)return null;let f=y,re=f.status==="pending"||f.status==="waiting"||f.status==="delayed",Z=f.status==="succeeded",ee=j(ie(f.destination_token_metadata,"png")||Fe("/icons/tokens/png/usdc.png")),ye=f.provider_metadata?.details,$=ye?.currencyIn,ve=ye?.currencyOut;$?.currency?.symbol||"USDC";ve?.currency?.symbol||"USDC";let Qe=_n(f.source_amount_base_unit,f.source_token_metadata?.decimals),te=_n(f.destination_amount_base_unit,f.destination_token_metadata?.decimals),we=ss(f.source_amount_usd),He=Sn(f.source_chain_type,f.source_chain_id),Pe=Sn(f.destination_chain_type,f.destination_chain_id),De=()=>{f.explorer_url&&Linking.openURL(f.explorer_url);},be=()=>{f.destination_explorer_url&&Linking.openURL(f.destination_explorer_url);};return jsxs(ScrollView,{ref:g,style:V.scrollContainer,contentContainerStyle:V.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:V.iconSection,children:[jsxs(View,{style:V.iconWrapper,children:[jsx(Image,{source:{uri:ee},style:V.tokenIcon}),jsx(View,{style:[V.statusBadge,{backgroundColor:re?i.warning:i.success,borderColor:i.background}],children:re?jsx(Ae,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(_e,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:V.statusRow,children:[jsx(View,{style:[V.statusDot,{backgroundColor:re?i.warning:i.success}]}),jsx(Text,{style:[V.statusText,{color:a.container.titleColor,fontFamily:c.semibold}],children:re?"Processing":"Completed"})]}),jsx(Text,{style:[V.dateText,{color:a.container.subtitleColor,fontFamily:c.regular}],children:as(f.created_at||new Date().toISOString())})]}),jsxs(View,{style:[V.card,{backgroundColor:a.card.backgroundColor}],children:[jsxs(View,{style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Amount Sent"}),jsxs(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:[Qe," ",vn(f.source_currency)]})]}),jsx(View,{style:[V.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Amount Received"}),jsxs(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:[te," ",vn(f.destination_currency)]})]}),jsx(View,{style:[V.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"USD Value"}),jsx(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:we})]}),jsx(View,{style:[V.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Source Network"}),jsx(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:He})]}),jsx(View,{style:[V.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Destination Network"}),jsx(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:Pe})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let dt=!u;s(dt),dt?setTimeout(()=>{g.current?.scrollToEnd({animated:true});},100):g.current?.scrollTo({y:0,animated:true});},style:V.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[V.toggleText,{color:a.container.actionTitle,fontFamily:c.regular}],children:u?"See less":"See more details"}),u?jsx(Tt,{size:14,color:a.container.actionColor,strokeWidth:2}):jsx(Ae,{size:14,color:a.container.actionColor,strokeWidth:2})]}),u&&jsxs(View,{style:[V.card,{backgroundColor:a.card.backgroundColor}],children:[f.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:De,style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Deposit Tx"}),jsxs(View,{style:V.cardRowRight,children:[jsx(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:In(f.transaction_hash)}),jsx(Ht,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[V.cardDivider,{backgroundColor:i.border}]})]}),f.destination_explorer_url&&Z&&jsxs(TouchableOpacity,{onPress:be,style:V.cardRow,children:[jsx(Text,{style:[V.cardLabel,{color:a.card.rowLeftLabel,fontFamily:c.regular}],children:"Completion Tx"}),jsxs(View,{style:V.cardRowRight,children:[jsx(Text,{style:[V.cardValue,{color:a.card.rowRightLabel,fontFamily:c.medium}],children:In(f.destination_transaction_hashes[0])}),jsx(Ht,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:V.scrollContainer,contentContainerStyle:V.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:V.emptyContainer,children:[jsx(Text,{style:[V.emptyText,{color:a.container.titleColor,fontFamily:c.medium}],children:"No deposits yet"}),jsx(Text,{style:[V.emptySubtext,{color:a.container.subtitleColor,fontFamily:c.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:V.executionsList,children:l.map(f=>jsx(or,{execution:f,onPress:()=>E(f)},f.id))})})]})}var V=StyleSheet.create({scrollContainer:{maxHeight:is*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function Ro(e,t=true){let[o,n]=useState(null),[r,i]=useState(null),[c,a]=useState(false),[l,k]=useState(false),[x,I]=useState(null),[y,d]=useState(null);useEffect(()=>{!t||o||(a(true),wo().then(E=>{n(E),I(null);}).catch(E=>{I(E instanceof Error?E:new Error(String(E)));}).finally(()=>{a(false);}));},[t,o]),useEffect(()=>{!t||!e||r||(k(true),ko(e).then(E=>{i(E),d(null);}).catch(E=>{d(E instanceof Error?E:new Error(String(E)));}).finally(()=>{k(false);}));},[t,e,r]);let u=c||l,s=x||y||null,g=null;if(o&&r){let E=r.blocked_country_codes||[],P=o.alpha2.toUpperCase();g=!E.some(D=>D.toUpperCase()===P);}return {isAllowed:g,alpha2:o?.alpha2?.toLowerCase()??null,country:o?.country??null,isLoading:u,error:s}}var Or="unifold_recent_tokens",ds=5,Fn=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function ar(){try{let e=await Ar.getItem(Or);return e?JSON.parse(e):[]}catch{return []}}async function us(e){try{let o=(await ar()).filter(r=>!(r.symbol===e.symbol&&r.chainType===e.chainType&&r.chainId===e.chainId));o.unshift(e);let n=o.slice(0,ds);await Ar.setItem(Or,JSON.stringify(n));}catch{}}async function ps(e){try{let o=(await ar()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));return await Ar.setItem(Or,JSON.stringify(o)),o}catch{return []}}function Hr({visible:e,onClose:t,tokens:o,selectedToken:n,selectedChainKey:r,onSelect:i}){let{colors:c,fonts:a,components:l}=A(),[k,x]=useState(""),[I,y]=useState([]);useEffect(()=>{e&&ar().then(y);},[e]),useEffect(()=>{e||x("");},[e]);let d=useMemo(()=>{let D=[];return o.forEach(v=>{v.chains.forEach(Y=>{D.push({token:v,chain:Y});});}),D},[o]),u=useMemo(()=>{let D=[],v=new Set,Y=(f,re,Z,ee)=>{let ye=`${f}-${re}:${Z}`;if(v.has(ye))return;let $=o.find(he=>he.symbol===f);if(!$)return;let ve=$.chains.find(he=>he.chain_type===re&&he.chain_id===Z);ve&&(v.add(ye),D.push({token:$,chain:ve,isRecent:ee}));};return I.forEach(f=>{Y(f.symbol,f.chainType,f.chainId,true);}),Fn.forEach(f=>{Y(f.symbol,f.chainType,f.chainId,false);}),D},[o,I]),s=useMemo(()=>{if(!k.trim())return d;let D=k.toLowerCase();return d.filter(({token:v,chain:Y})=>v.symbol.toLowerCase().includes(D)||v.name.toLowerCase().includes(D)||Y.chain_name.toLowerCase().includes(D))},[d,k]),g=(D,v,Y)=>Fn.some(f=>f.symbol===D&&f.chainType===v&&f.chainId===Y),E=async(D,v)=>{let Y=`${v.chain_type}:${v.chain_id}`;if(!g(D.symbol,v.chain_type,v.chain_id)){await us({symbol:D.symbol,chainType:v.chain_type,chainId:v.chain_id});let f=await ar();y(f);}x(""),i(D.symbol,Y),t();},P=async(D,v)=>{let Y=await ps({symbol:D.symbol,chainType:v.chain_type,chainId:v.chain_id});y(Y);};return jsxs(de,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,children:[jsxs(View,{style:K.header,children:[jsx(View,{style:K.headerSpacer}),jsx(Text,{style:[K.headerTitle,{color:l.header.titleColor,fontFamily:a.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity,{onPress:t,style:K.closeButton,children:jsx(ze,{size:20,color:l.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:K.searchContainer,children:jsx(TextInput,{style:[K.searchInput,{backgroundColor:l.search.backgroundColor,color:l.search.inputColor,fontFamily:a.regular}],placeholder:"Search",placeholderTextColor:l.search.placeholderColor,value:k,onChangeText:x,autoCapitalize:"none",autoCorrect:false})}),u.length>0&&!k&&jsxs(View,{style:K.quickSelectSection,children:[jsx(Text,{style:[K.sectionLabel,{color:l.list.titleSectionColor,fontFamily:a.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:K.quickSelectScroll,children:u.map(({token:D,chain:v,isRecent:Y})=>{let f=`${v.chain_type}:${v.chain_id}`;D.symbol===n&&f===r;return jsxs(View,{children:[Y&&jsx(TouchableOpacity,{onPress:()=>P(D,v),style:K.removeButton,children:jsx(ze,{size:12,color:c.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity,{onPress:()=>E(D,v),style:[K.quickSelectItem],children:[jsxs(View,{style:K.tokenIconContainer,children:[jsx(Image,{source:{uri:j(ie(D,"png"))},style:K.quickSelectIcon}),jsx(Image,{source:{uri:j(ie(v,"png"))},style:[K.quickSelectChainBadge,{borderColor:l.card.backgroundColor}]})]}),jsxs(View,{style:K.quickSelectText,children:[jsx(Text,{style:[K.quickSelectSymbol,{color:l.card.titleColor,fontFamily:a.medium}],children:D.symbol}),jsx(Text,{style:[K.quickSelectChain,{color:l.card.subtitleColor,fontFamily:a.regular}],children:v.chain_name})]})]})]},`quick-${D.symbol}-${f}`)})})]}),jsx(Text,{style:[K.sectionLabel,{color:l.list.titleSectionColor,fontFamily:a.regular}],children:"All supported tokens"}),jsx(ScrollView,{style:K.tokenList,showsVerticalScrollIndicator:false,contentContainerStyle:K.tokenListContent,children:s.length===0?jsx(View,{style:K.emptyState,children:jsx(Text,{style:[K.emptyText,{color:c.foregroundMuted,fontFamily:a.regular}],children:"No tokens found"})}):s.map(({token:D,chain:v})=>{let Y=`${v.chain_type}:${v.chain_id}`,f=D.symbol===n&&Y===r;return jsxs(TouchableOpacity,{onPress:()=>E(D,v),style:[K.tokenItem,{backgroundColor:f?l.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:K.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:j(ie(D,"png"))},style:K.tokenIcon}),jsx(Image,{source:{uri:j(ie(v,"png"))},style:[K.tokenChainBadge,{borderColor:l.card.backgroundColor}]})]}),jsxs(View,{style:K.tokenInfo,children:[jsx(Text,{style:[K.tokenSymbol,{color:l.card.titleColor,fontFamily:a.medium}],children:D.symbol}),jsx(Text,{style:[K.tokenChainName,{color:l.card.subtitleColor,fontFamily:a.regular}],children:v.chain_name})]}),jsxs(Text,{style:[K.minDeposit,{color:l.card.labelColor,fontFamily:a.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:l.card.labelHighlightRightColor,fontFamily:a.regular},children:["$",v.minimum_deposit_amount_usd]})]})]},`${D.symbol}-${Y}`)})})]})}var K=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,borderRadius:8,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12,borderRadius:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:24,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var lr=(e,t)=>`${t}:${e}`,ys=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Mr({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:r,destinationTokenAddress:i,destinationTokenSymbol:c,defaultChainType:a,defaultChainId:l,defaultTokenAddress:k,onExecutionsChange:x,onDepositSuccess:I,onDepositError:y,wallets:d}){let{colors:u,fonts:s,components:g}=A(),E=a&&l?`${a}:${l}`:"solana:mainnet",[P,D]=useState("USDC"),[v,Y]=useState(E),[f,re]=useState([]),[Z,ee]=useState(!d?.length),ye=d?.length?d:f,[$,ve]=useState([]),[he,Oe]=useState(true),[Qe,te]=useState(false),[we,He]=useState(false),[Pe,De]=useState(false),[be,dt]=useState([]),[bt,Gt]=useState(new Map),[rt]=useState(()=>new Date),[Lt,Ge]=useState(null),[Rt,Vt]=useState(false),[le,Yt]=useState(null),[Ve,Ye]=useState(false),ut=new Map;$.forEach(N=>{N.chains.forEach(se=>{let m=`${se.chain_type}:${se.chain_id}`;ut.has(m)||ut.set(m,se);});});let go=Array.from(ut.values()),Je=ys(v),Ft=go.find(N=>N.chain_type===Je.chainType&&N.chain_id===Je.chainId),Be=Ft?.chain_type||"ethereum",Le=Et(ye,Be)?.address||"",Pt=useRef(false);useEffect(()=>{async function N(){try{Oe(!0),Ge(null);let m=await Co(t,i&&r&&n?{destination_token_address:i,destination_chain_id:r,destination_chain_type:n}:void 0);if(ve(m.data),m.data.length>0&&!Pt.current){Pt.current=!0;let w,R;if(a&&l)if(k)for(let T of m.data){let H=T.chains.find(q=>q.chain_type===a&&q.chain_id===l&&q.token_address.toLowerCase()===k.toLowerCase());if(H){w=T,R=H;break}}else for(let T of m.data){let H=T.chains.find(q=>q.chain_type===a&&q.chain_id===l);if(H){w=T,R=H;break}}if(!w&&i)for(let T of m.data){let H=T.chains.find(q=>q.token_address.toLowerCase()===i.toLowerCase());if(H){w=T,R=H;break}}w||(w=m.data.find(T=>T.symbol==="USDC"),w&&w.chains.length>0&&(R=w.chains[0])),w||(w=m.data.find(T=>T.symbol==="USDT"),w&&w.chains.length>0&&(R=w.chains[0])),w||(w=m.data[0],w.chains.length>0&&(R=w.chains[0])),w&&D(w.symbol),R&&Y(lr(R.chain_id,R.chain_type));}}catch(se){console.error("Error fetching supported tokens:",se),Ge("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:se});}finally{Oe(false);}}N();},[t,i,r,n,a,l,k,y]),useEffect(()=>{x&&x(be);},[be,x]),useEffect(()=>{if(d?.length){ee(false);return}if(f.length>0){ee(false);return}let N=null,se=false,m=async()=>{if(!se){ee(true);try{let w=await Wt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:r,destination_token_address:i},t);se||(re(w.data),Ge(null),ee(!1));}catch(w){console.error("Error fetching wallets, retrying in 5s:",w),se||(Ge(w instanceof Error?w.message:"Failed to load wallets"),ee(false),N=setTimeout(m,5e3));}}};return m(),()=>{se=true,N&&clearTimeout(N);}},[e,o,n,r,i,t,d,f.length]),useEffect(()=>{if(!e||!rt)return;let N=setInterval(async()=>{try{let se=await zt(e,t),m=null;for(let w of se.data){let R=w.created_at?new Date(w.created_at):null;if(!R||R<=rt)continue;let T=bt.get(w.id);if(!T){m=w;break}if(["pending","waiting","delayed"].includes(T)&&w.status==="succeeded"){m=w;break}}if(m){let w=m;dt(R=>{let T=R.findIndex(H=>H.id===w.id);if(T>=0){let H=[...R];return H[T]=w,H}else return [...R,w]}),Gt(R=>{let T=new Map(R);return T.set(w.id,w.status),T}),Yt(w),Vt(!0),w.status==="succeeded"&&I?.({message:"Deposit completed successfully",executionId:w.id}),x?.([...be,w]);}}catch(se){console.error("Error polling executions:",se),y?.({message:"Failed to check deposit status",error:se});}},3e3);return ()=>clearInterval(N)},[e,t,rt,bt,be,x,I,y]),useEffect(()=>{if(!$.length)return;let N=$.find(m=>m.symbol===P);if(!N||N.chains.length===0)return;if(!N.chains.some(m=>lr(m.chain_id,m.chain_type)===v)){let m=N.chains[0];Y(lr(m.chain_id,m.chain_type));}},[P,$,v]);let pe=$.find(N=>N.symbol===P),xe=(pe?.chains||[]).find(N=>lr(N.chain_id,N.chain_type)===v),Jt=async()=>{if(Le)try{Clipboard.setString(Le),te(!0),setTimeout(()=>te(!1),2e3);}catch(N){console.error("Failed to copy:",N);}},Me=xe?.estimated_price_impact_percent??0,Bt=xe?.max_slippage_percent??.25,mo=xe?.minimum_deposit_amount_usd??3;return he?jsxs(View,{style:C.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:u.primary}),jsx(Text,{style:[C.loadingText,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Loading currencies..."})]}):Lt&&$.length===0?jsxs(View,{style:C.errorContainer,children:[jsx(Text,{style:[C.errorText,{color:u.error,fontFamily:s.regular}],children:Lt}),jsx(Text,{style:[C.errorHint,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:C.container,children:[jsxs(View,{style:C.selectorSection,children:[jsx(Text,{style:[C.selectorLabel,{color:g.card.labelColor,fontFamily:s.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity,{onPress:()=>De(true),disabled:he||$.length===0,style:[C.tokenSelectorButton,{backgroundColor:g.card.backgroundColor}],activeOpacity:.7,children:he?jsxs(View,{style:C.tokenSelectorLoading,children:[jsx(View,{style:[C.loadingIcon,{backgroundColor:u.cardHover}]}),jsxs(View,{style:C.loadingTextContainer,children:[jsx(View,{style:[C.loadingLine,{backgroundColor:u.cardHover,width:60}]}),jsx(View,{style:[C.loadingLine,{backgroundColor:u.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:C.tokenIconWrapper,children:[pe&&jsx(Image,{source:{uri:j(ie(pe,"png"))},style:C.tokenMainIcon}),(xe||Ft)&&jsx(Image,{source:{uri:j(ie(xe||Ft,"png"))},style:[C.tokenChainBadge,{borderColor:g.card.backgroundColor}]})]}),jsxs(View,{style:C.tokenSelectorInfo,children:[jsx(Text,{style:[C.tokenSelectorSymbol,{color:g.card.titleColor,fontFamily:s.semibold}],children:pe?.symbol||P}),jsx(Text,{style:[C.tokenSelectorNetwork,{color:g.card.subtitleColor,fontFamily:s.regular}],numberOfLines:1,children:xe?.chain_name||Ft?.chain_name||"Select network"})]}),jsxs(View,{style:C.tokenSelectorRight,children:[jsxs(Text,{style:[C.minDepositText,{color:g.card.labelHighlightRightColor,fontFamily:s.medium}],children:["$",mo," min"]}),jsx(ft,{size:16,color:g.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Hr,{visible:Pe,onClose:()=>De(false),tokens:$,selectedToken:P,selectedChainKey:v,onSelect:(N,se)=>{D(N),Y(se);}}),jsx(View,{style:C.qrContainer,children:jsx(View,{style:[C.qrWrapper,{backgroundColor:u.background,borderColor:u.border}],children:Z?jsxs(View,{style:C.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:u.primary}),jsx(Text,{style:[C.loadingText,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Loading..."})]}):Le?jsx(ao,{value:Le,size:180,logoUri:j(ie(xe,"png")||Fe("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:C.qrLoading,children:jsx(Text,{style:[C.errorText,{color:u.error,fontFamily:s.regular}],children:"No address available"})})})}),jsxs(View,{style:C.addressSection,children:[jsxs(View,{style:C.addressHeader,children:[jsx(Text,{style:[C.addressLabel,{color:g.card.labelColor,fontFamily:s.medium}],children:"Deposit Address"}),Qe&&jsxs(View,{style:C.copiedIndicator,children:[jsx(_e,{size:14,color:u.success,strokeWidth:2}),jsx(Text,{style:[C.copiedText,{color:u.success,fontFamily:s.regular}],children:"Copied"})]})]}),jsxs(TouchableOpacity,{onPress:Jt,disabled:!Le||Z,activeOpacity:.7,style:[C.addressBox,{backgroundColor:g.card.backgroundColor}],children:[jsx(Text,{style:[C.addressText,{color:g.card.titleColor,fontFamily:s.regular}],numberOfLines:2,children:Z?"Loading...":Le||"No address available"}),jsx(View,{style:C.addressCopyIcon,children:jsx(bo,{size:16,color:g.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[C.detailsCard,{backgroundColor:g.card.backgroundColor}],children:[jsxs(TouchableOpacity,{onPress:()=>He(!we),style:C.detailsHeader,children:[jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(Ot,{size:12,color:g.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.detailsLabel,{color:g.card.titleColor,fontFamily:s.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:C.chevronContainer,children:we?jsx(Tt,{size:16,color:g.card.actionColor,strokeWidth:2}):jsx(Ae,{size:16,color:g.card.actionColor,strokeWidth:2})})]}),we&&jsxs(View,{style:C.detailsContent,children:[jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(to,{size:12,color:g.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:g.card.titleColor,fontFamily:s.regular}],children:["Price impact: ",Me.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Ye(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(oo,{size:14,color:g.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(ro,{size:12,color:g.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:g.card.titleColor,fontFamily:s.regular}],children:["Slippage: Auto \u2022 ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Ye(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(oo,{size:14,color:g.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(Mo,{size:12,color:g.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:g.card.titleColor,fontFamily:s.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:C.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[C.termsText,{color:u.primary,fontFamily:s.regular}],children:"Terms apply"})}),jsxs(de,{visible:Ve,onClose:()=>Ye(false),closeOnBackdropPress:true,showHandle:true,children:[jsxs(View,{style:[C.sheetHeader,{borderBottomColor:u.border}],children:[jsx(View,{style:C.sheetHeaderSpacer}),jsx(Text,{style:[C.sheetTitle,{color:g.header.titleColor,fontFamily:s.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>Ye(false),style:C.sheetCloseButton,children:jsx(ze,{size:20,color:g.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:C.infoSheetContent,children:[jsxs(View,{style:[C.infoCard,{backgroundColor:g.card.backgroundColor}],children:[jsxs(View,{style:C.infoCardHeader,children:[jsx(View,{style:[C.infoCardIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(to,{size:16,color:g.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.infoCardTitle,{color:g.card.titleColor,fontFamily:s.medium}],children:"Price Impact"}),jsxs(Text,{style:[C.infoCardValue,{color:g.card.titleColor,fontFamily:s.medium}],children:[Me.toFixed(2),"%"]})]}),jsx(Text,{style:[C.infoCardDescription,{color:g.card.descriptionColor,fontFamily:s.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[C.infoCard,{backgroundColor:g.card.backgroundColor}],children:[jsxs(View,{style:C.infoCardHeader,children:[jsx(View,{style:[C.infoCardIcon,{backgroundColor:g.card.iconBackgroundColor}],children:jsx(ro,{size:16,color:g.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.infoCardTitle,{color:g.card.titleColor,fontFamily:s.medium}],children:"Max Slippage"}),jsxs(Text,{style:[C.infoCardValue,{color:g.card.titleColor,fontFamily:s.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[C.infoCardDescription,{color:g.card.descriptionColor,fontFamily:s.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),le&&jsx(lo,{visible:Rt,status:le.status,tokenIconUrl:le.destination_token_metadata?.icon_urls?.find(N=>N.format==="png")?.url||le.destination_token_metadata?.icon_url||ie(pe,"png"),explorerUrl:le.explorer_url,completionExplorerUrl:le.destination_explorer_url,date:le.created_at?new Date(le.created_at):void 0,amountUsd:le.source_amount_usd?parseFloat(le.source_amount_usd):void 0,onClose:()=>Vt(false)})]})}var C=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16,borderRadius:16,borderWidth:1},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var Qt={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Ts({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:r="Deposit",destinationTokenSymbol:i,recipientAddress:c,destinationChainType:a,destinationChainId:l,destinationTokenAddress:k,defaultChainType:x,defaultChainId:I,defaultTokenAddress:y,hideDepositTracker:d=false,transferInputVariant:u="double_input",onDepositSuccess:s,onDepositError:g}){let{colors:E,fonts:P}=A(),[D,v]=useState([]),[Y,f]=useState(false),[re,Z]=useState(false),[ee,ye]=useState(false),[$,ve]=useState(null),[he,Oe]=useState("amount"),{isAllowed:Qe,isLoading:te}=Ro(n,e);useEffect(()=>{e&&!$&&ko(n).then(ve).catch(console.error);},[e,$,n]);let we=()=>{t();},He=D.filter(be=>be.status==="pending"||be.status==="waiting").length,Pe=te||e&&!$,De=Qe===false;return jsxs(de,{visible:e,onClose:we,closeOnBackdropPress:false,showHandle:false,children:[jsx(Ne,{title:r,showBack:false,onClose:we}),Pe&&jsx(View,{style:wt.centeredContainer,children:jsx(ActivityIndicator,{size:"large",color:E.primary})}),!Pe&&De&&jsxs(View,{style:wt.centeredContainer,children:[jsx(View,{style:[wt.iconContainer,{backgroundColor:E.cardHover}],children:jsx(Uo,{size:32,color:E.foreground,strokeWidth:1.5})}),jsx(Text,{style:[wt.blockedTitle,{color:E.foreground,fontFamily:P.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[wt.blockedDescription,{color:E.foreground,opacity:.7,fontFamily:P.regular}],children:"There are no supported tokens available from your current location."})]}),!Pe&&!De&&jsxs(View,{style:wt.optionsContainer,children:[jsx(xo,{onPress:()=>Z(true),title:Qt.transferCrypto.title,subtitle:Qt.transferCrypto.subtitle,featuredTokens:$?.transfer_crypto?.networks}),jsx(So,{onPress:()=>ye(true),title:Qt.depositWithCard.title,subtitle:Qt.depositWithCard.subtitle,paymentNetworks:$?.payment_networks?.networks}),!d&&jsx(_o,{onPress:()=>f(true),title:Qt.depositTracker.title,subtitle:Qt.depositTracker.subtitle,badge:He>0?He:void 0})]}),jsx(nr,{visible:Y,onClose:()=>f(false),executions:D,externalUserId:o,publishableKey:n}),jsxs(de,{visible:re,onClose:()=>Z(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(Ne,{title:Qt.transferCrypto.title,showBack:false,onClose:()=>Z(false)}),jsx(ScrollView,{style:wt.transferScrollContainer,contentContainerStyle:wt.scrollContent,showsVerticalScrollIndicator:false,children:u==="single_input"?jsx(Mr,{externalUserId:o,publishableKey:n,recipientAddress:c,destinationChainType:a,destinationChainId:l,destinationTokenAddress:k,destinationTokenSymbol:i,defaultChainType:x,defaultChainId:I,defaultTokenAddress:y,onExecutionsChange:v,onDepositSuccess:s,onDepositError:g}):jsx(Yo,{externalUserId:o,publishableKey:n,recipientAddress:c,destinationChainType:a,destinationChainId:l,destinationTokenAddress:k,destinationTokenSymbol:i,defaultChainType:x,defaultChainId:I,defaultTokenAddress:y,onExecutionsChange:v,onDepositSuccess:s,onDepositError:g})})]}),jsxs(de,{visible:ee,onClose:()=>{ye(false),Oe("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(Ne,{title:`Deposit ${i||"USDC"}`,showBack:he==="onramp",onBack:()=>Oe("amount"),onClose:()=>{ye(false),Oe("amount");}}),jsx(View,{style:wt.buyWithCardContainer,children:jsx(Zo,{externalUserId:o,publishableKey:n,destinationTokenSymbol:i,recipientAddress:c,destinationChainType:a,destinationChainId:l,destinationTokenAddress:k,onDepositSuccess:s,onDepositError:g,view:he,onViewChange:be=>Oe(be)})})]})]})}function cr({theme:e="auto",...t}){return jsx(Ts,{...t})}var wt=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Ps=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),zn=createContext(null);function Bs({children:e,publishableKey:t,config:o}){let[n]=useState(()=>Ps()),[r,i]=useState(false),[c,a]=useState(null),l=useColorScheme(),k=useRef(false);k.current||(Ao({publishableKey:t}),k.current=true);let x=useMemo(()=>{let P=o?.appearance||"dark";return P==="auto"?l==="dark"?"dark":"light":P},[o?.appearance,l]);useEffect(()=>{if(!t||t.trim()===""){console.error("Unifold: publishableKey is required. Please provide a valid publishable key.");return}!t.startsWith("pk_test_")&&!t.startsWith("pk_live_")&&console.warn('Unifold: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),Ao({publishableKey:t});},[t]);let I=useRef(null),y=useRef(null),d=useCallback(P=>{y.current&&(clearTimeout(y.current),y.current=null),I.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),I.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),I.current=null);let D=new Promise((v,Y)=>{I.current={resolve:v,reject:Y};});return a(P),i(true),D},[]),u=useCallback(()=>{I.current&&(I.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),I.current=null),i(false),y.current=setTimeout(()=>{a(null),y.current=null;},200);},[]),s=useCallback(P=>{c?.onSuccess&&c.onSuccess(P),I.current&&(I.current.resolve(P),I.current=null);},[c]),g=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),c?.onError&&c.onError(P),I.current&&(I.current.reject(P),I.current=null);},[c]),E=useMemo(()=>({publishableKey:t,beginDeposit:d,closeDeposit:u}),[t,d,u]);return jsx(QueryClientProvider,{client:n,children:jsx(zn.Provider,{value:E,children:jsxs(Wo,{mode:x,accentColor:o?.accentColor,theme:o?.theme,fontFamily:o?.fontFamily,fonts:o?.fonts,components:o?.components,children:[e,c&&jsx(cr,{visible:r,onClose:u,publishableKey:t,modalTitle:o?.modalTitle,externalUserId:c.externalUserId,destinationChainType:c.destinationChainType,destinationChainId:c.destinationChainId,destinationTokenSymbol:c.destinationTokenSymbol,recipientAddress:c.recipientAddress,destinationTokenAddress:c.destinationTokenAddress,defaultChainType:c.defaultChainType,defaultChainId:c.defaultChainId,defaultTokenAddress:c.defaultTokenAddress,hideDepositTracker:o?.hideDepositTracker,transferInputVariant:o?.transferInputVariant,onDepositSuccess:s,onDepositError:g,theme:x})]})})})}function Ws(){let e=useContext(zn);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
- export{Bs as UnifoldProvider,Gr as setDevApiUrl,Ro as useAllowedCountry,Ws as useUnifold};
1
+ import {createContext,useState,useEffect,useRef,useMemo,useCallback,useContext}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,View,ActivityIndicator,Text,ScrollView,Animated,Modal,TouchableWithoutFeedback,TouchableOpacity,Image,Linking,TextInput,Clipboard,Easing}from'react-native';import {QueryClientProvider,QueryClient}from'@tanstack/react-query';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Ie,{Path,Line,Polyline,SvgUri,Rect,Circle,Defs,LinearGradient,Stop}from'react-native-svg';import Ci from'react-native-qrcode-svg';import {WebView}from'react-native-webview';import Hr from'@react-native-async-storage/async-storage';var hr={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},yr=hr;function zo(e,t,o){let n=o?t?.[o]:void 0,r=(a,p,g)=>{let l=n?.[a]?.[p];if(l!==void 0)return l;let c=t?.[a]?.[p];return c!==void 0?c:g};return {header:{titleColor:r("header","titleColor",e.foreground),buttonColor:r("header","buttonColor",e.foreground)},card:{backgroundColor:r("card","backgroundColor",e.card),titleColor:r("card","titleColor",e.foreground),subtitleColor:r("card","subtitleColor",e.foregroundMuted),labelColor:r("card","labelColor",e.foregroundMuted),headerColor:r("card","headerColor",e.foregroundMuted),labelRightColor:r("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:r("card","labelHighlightRightColor",e.warning),textRightColor:r("card","textRightColor",e.foreground),subtextRightColor:r("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:r("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:r("card","rowRightLabel",e.foreground),iconColor:r("card","iconColor",e.primary),iconBackgroundColor:r("card","iconBackgroundColor",e.primary+"26"),actionColor:r("card","actionColor",e.foregroundMuted),actionIcon:r("card","actionIcon",e.foregroundMuted),descriptionColor:r("card","descriptionColor",e.foregroundMuted)},input:{backgroundColor:r("input","backgroundColor",e.card),textColor:r("input","textColor",e.foreground),placeholderColor:r("input","placeholderColor",e.foregroundMuted),borderColor:r("input","borderColor",e.border)},button:{primaryBackground:r("button","primaryBackground",e.primary),primaryText:r("button","primaryText",e.primaryForeground),secondaryBackground:r("button","secondaryBackground",e.card),secondaryText:r("button","secondaryText",e.foreground)},container:{titleColor:r("container","titleColor",e.foreground),subtitleColor:r("container","subtitleColor",e.foregroundMuted),actionColor:r("container","actionColor",e.foregroundMuted),actionTitle:r("container","actionTitle",e.foregroundMuted),buttonColor:r("container","buttonColor",e.primary),buttonTitleColor:r("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:r("container","iconBackgroundColor",e.success),iconColor:r("container","iconColor",e.foreground)},search:{backgroundColor:r("search","backgroundColor",e.card),inputColor:r("search","inputColor",e.foreground),placeholderColor:r("search","placeholderColor",e.foregroundMuted)},list:{titleSectionColor:r("list","titleSectionColor",e.foregroundMuted)}}}function Cr(e,t,o){let r={...hr[e]};return o&&(r.primary=o),t&&(r={...r,...t}),r}var Jr=createContext(null);function Ao({children:e,mode:t="auto",accentColor:o,theme:n,fontFamily:r,fonts:a,components:p}){let g=useColorScheme(),l=useMemo(()=>t==="auto"?g==="dark"?"dark":"light":t,[t,g]),c=useMemo(()=>{let W=n?.[l];return Cr(l,W,o)},[l,n,o]),k=useMemo(()=>zo(c,p,l),[c,p,l]),T=useMemo(()=>a?{regular:a.regular||r,medium:a.medium||r,semibold:a.semibold||r,bold:a.bold||r}:r?{regular:r,medium:r,semibold:r,bold:r}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[r,a]),_=useMemo(()=>({mode:l,colors:c,fonts:T,components:k,isDark:l==="dark"}),[l,c,T,k]);return jsx(Jr.Provider,{value:_,children:e})}function O(){let e=useContext(Jr);if(!e){let t=yr.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:zo(t,void 0,"dark"),isDark:true}}return e}var ei="https://api.unifold.io",Mo,lt="pk_test_123",Oo={};function Me(){return typeof __DEV__<"u"&&__DEV__&&Mo?Mo:ei}function Ho(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),lt=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Mo=e.baseUrl),e.defaultConfig&&(Oo=e.defaultConfig);}function Kr(e){typeof __DEV__<"u"&&__DEV__?Mo=e:console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function mt(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function Pe(e){let t=e.startsWith("/")?e:`/${e}`;return `${Me()}/api/public${t}`}function $(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,Me()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${Me()}${e}`:`${Me()}/api/public${e}`:""}async function zt(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Oo.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Oo.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Oo.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||lt;mt(n);let r=await fetch(`${Me()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.statusText}`);return r.json()}function At(e,t){return e.find(o=>o.chain_type===t)}async function Ot(e,t){let o=t||lt;mt(o);let n=await fetch(`${Me()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function ae(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function wo(e,t){let o=e||lt;mt(o);let n=`${Me()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let a=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});n=`${n}?${a.toString()}`;}let r=await fetch(n,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch supported deposit tokens: ${r.statusText}`);return r.json()}async function br(e,t){let o=t||lt;mt(o);let n=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),r=await fetch(`${Me()}/v1/public/tokens/token?${n.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch token metadata: ${r.statusText}`);return r.json()}function Uo(e,t,o){return !e||e.length===0?o||"":e.find(r=>r.format===t)?.url||o||e[0]?.url||""}async function kr(e,t){let o=t||lt;mt(o);let n=await fetch(`${Me()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch onramp quotes: ${n.statusText}`);return n.json()}async function wr(e,t){let o=t||lt;mt(o);let n=await fetch(`${Me()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create onramp session: ${n.statusText}`);return n.json()}async function Tr(e,t){let o=t||lt;mt(o);let n=new URLSearchParams;e.country_code&&n.append("country_code",e.country_code),e.subdivision_code&&n.append("subdivision_code",e.subdivision_code),n.append("token_address",e.token_address),n.append("chain_id",e.chain_id),n.append("chain_type",e.chain_type);let r=await fetch(`${Me()}/v1/public/onramps/default_token?${n.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":o}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.statusText}`);return r.json()}async function xr(e){let t=e||lt;mt(t);let o=await fetch(`${Me()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}function to(e,t="png"){if(!e||e.length===0)return;let o=e.find(n=>n.format===t);return o?o.url:e[0]?.url}async function To(e){let t=e||lt;mt(t);let o=await fetch(`${Me()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}async function xo(){let e=await fetch(`${Me()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}var{height:ro}=Dimensions.get("window");function ge({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:r=true,heightPercent:a,noPadding:p=false,borderTopLeftRadius:g=24,borderTopRightRadius:l=24}){let{colors:c}=O(),k=useRef(new Animated.Value(ro)).current,T=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(k.setValue(ro),T.setValue(0),Animated.parallel([Animated.spring(k,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(T,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(k,{toValue:ro,useNativeDriver:true,tension:65,friction:11}),Animated.timing(T,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,k,T]);let _=()=>{n&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(View,{style:Mt.container,children:[jsx(TouchableWithoutFeedback,{onPress:_,children:jsx(Animated.View,{style:[Mt.backdrop,{backgroundColor:"#000000",opacity:T}]})}),jsxs(Animated.View,{style:[Mt.sheet,{backgroundColor:c.background,borderTopLeftRadius:g,borderTopRightRadius:l,transform:[{translateY:k}],...a&&{height:ro*a,maxHeight:ro*a},...p&&{paddingBottom:0}}],children:[r&&jsx(View,{style:Mt.handleContainer,children:jsx(View,{style:[Mt.handle,{backgroundColor:c.border}]})}),jsx(View,{style:[Mt.content,a&&Mt.contentFlex],children:o})]})]})})}var Mt=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:ro*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function Sr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function _r({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ht({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ir({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function He({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ht({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ue({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function So({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Re({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ut({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function no({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function No({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function rn({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function io({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function so({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function qo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Ie,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Qe({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:r,badge:a}){let{colors:p,fonts:g,components:l}=O();return jsxs(View,{style:ot.header,children:[jsx(View,{style:ot.leftContainer,children:t&&n?jsx(TouchableOpacity,{onPress:n,style:[ot.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ir,{size:20,color:l.header.buttonColor,strokeWidth:2})}):jsx(View,{style:ot.spacer})}),jsxs(View,{style:ot.titleContainer,children:[jsx(Text,{style:[ot.title,{color:l.header.titleColor,fontFamily:g.medium}],children:e}),a&&a.count>0&&jsx(View,{style:[ot.titleBadge,{backgroundColor:p.card}],children:jsx(Text,{style:[ot.titleBadgeText,{color:p.foregroundMuted,fontFamily:g.regular}],children:a.count})})]}),jsx(View,{style:ot.rightContainer,children:o?jsx(TouchableOpacity,{onPress:r,style:[ot.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(He,{size:20,color:l.header.buttonColor,strokeWidth:2})}):jsx(View,{style:ot.spacer})})]})}var ot=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},leftContainer:{width:40,alignItems:"flex-start"},rightContainer:{width:40,alignItems:"flex-end"},titleContainer:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function It({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:r=0,borderColor:a="transparent",backgroundColor:p="transparent",style:g}){let{colors:l}=O(),[c,k]=useState(false),T=e?.toLowerCase().endsWith(".svg");useEffect(()=>{k(false);},[e]);let _=l.card;if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:_},g]});let W={width:t,height:o,borderRadius:n,borderWidth:r,borderColor:a,backgroundColor:p,overflow:"hidden",alignItems:"center",justifyContent:"center",...g},P=t-r*2,x=o-r*2;return c?jsx(View,{style:[W,{backgroundColor:p||_}]}):T?jsx(View,{style:W,children:jsx(SvgUri,{uri:e,width:P,height:x,onError:u=>{k(true);}})}):jsx(View,{style:W,children:jsx(Image,{source:{uri:e},style:{width:P,height:x},resizeMode:"contain",onError:u=>{k(true);}})})}function _o({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:r,fonts:a,components:p}=O(),g=n?[...n].sort((l,c)=>l.position-c.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[yt.container,{backgroundColor:p.card.backgroundColor}],children:[jsxs(View,{style:yt.leftContent,children:[jsx(View,{style:yt.iconContainer,children:jsx(Sr,{size:20,color:p.card.iconColor,strokeWidth:2})}),jsxs(View,{style:yt.textContainer,children:[jsx(Text,{style:[yt.title,{color:p.card.titleColor,fontFamily:a.regular}],children:t}),jsx(Text,{style:[yt.subtitle,{color:p.card.subtitleColor,fontFamily:a.regular}],children:o})]})]}),jsx(View,{style:yt.rightContent,children:jsx(View,{style:yt.networkIcons,children:g.map((l,c)=>{let k=l.icon_urls.find(T=>T.format==="png")?.url||l.icon_urls.find(T=>T.format==="svg")?.url;return jsx(View,{style:[yt.networkIconWrapper,{marginLeft:c===0?0:-6,zIndex:g.length-c}],children:jsx(It,{uri:$(k),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:p.card.backgroundColor})},l.name)})})})]})}var yt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function Ro({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{fonts:r,components:a}=O();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[vt.container,{backgroundColor:a.card.backgroundColor}],children:[jsxs(View,{style:vt.leftContent,children:[jsx(View,{style:vt.iconContainer,children:jsx(_r,{size:20,color:a.card.iconColor,strokeWidth:2})}),jsxs(View,{style:vt.textContainer,children:[jsx(Text,{style:[vt.title,{color:a.card.titleColor,fontFamily:r.regular}],children:t}),jsx(Text,{style:[vt.subtitle,{color:a.card.subtitleColor,fontFamily:r.regular}],children:o})]})]}),jsx(View,{style:vt.rightContent,children:jsx(View,{style:vt.paymentIcons,children:n?.map(p=>{let g=p.icon_urls.find(l=>l.format==="png")?.url||p.icon_urls.find(l=>l.format==="svg")?.url;return jsx(It,{uri:$(g),width:32,height:20,borderRadius:4},p.name)})})})]})}var vt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function vo({onPress:e,title:t,subtitle:o,badge:n}){let{fonts:r,components:a}=O();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Lt.container,{backgroundColor:a.card.backgroundColor}],children:jsxs(View,{style:Lt.leftContent,children:[jsxs(View,{style:Lt.iconContainer,children:[jsx(Ht,{size:20,color:a.card.iconColor,strokeWidth:2}),n!==void 0&&n>0&&jsx(View,{style:[Lt.badge,{backgroundColor:a.card.iconColor}],children:jsx(Text,{style:[Lt.badgeText,{fontFamily:r.semibold}],children:n>99?"99+":n})})]}),jsxs(View,{style:Lt.textContainer,children:[jsx(Text,{style:[Lt.title,{color:a.card.titleColor,fontFamily:r.regular}],children:t}),jsx(Text,{style:[Lt.subtitle,{color:a.card.subtitleColor,fontFamily:r.regular}],children:o})]})]})})}var Lt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function uo({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:r}){let{colors:a,isDark:p}=O(),g=p?"#1a1a1a":"#ffffff",l=p?"#ffffff":"#000000",c=r||g;return jsxs(View,{style:[un.container,{width:t,height:t}],children:[jsx(Ci,{value:e||"placeholder",size:t,backgroundColor:g,color:l,ecl:"H",quietZone:4}),o&&jsx(View,{style:[un.logoContainer,{width:n+12,height:n+12,backgroundColor:c,borderRadius:(n+12)/2}],children:jsx(It,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var un=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function Li({size:e,strokeWidth:t,iconSize:o,children:n}){let r=useRef(new Animated.Value(0)).current,a=(e-t)/2,p=2*Math.PI*a,g=e/2,l=(e-o)/2;useEffect(()=>{let k=Animated.loop(Animated.timing(r,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return k.start(),()=>k.stop()},[r]);let c=r.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:{width:e,height:e},children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:c}]},children:jsxs(Ie,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:"progressGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:"#F59E0B"}),jsx(Stop,{offset:"100%",stopColor:"#FBBF24"})]})}),jsx(Circle,{cx:g,cy:g,r:a,stroke:"url(#progressGradient)",strokeWidth:t,fill:"none",strokeDasharray:`${p*.75} ${p*.25}`,strokeLinecap:"round",rotation:-90,origin:`${g}, ${g}`})]})}),jsx(View,{style:{position:"absolute",top:l+1.5,left:l,width:o,height:o},children:n})]})}function mn(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function Di(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),r=e.getFullYear(),a=e.getHours(),p=e.getMinutes(),g=a>=12?"pm":"am";a=a%12,a=a||12;let l=p<10?`0${p}`:p;return `${o} ${n}, ${r} at ${a}:${l}${g}`}function po({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:r,date:a,amountUsd:p,onClose:g,borderTopLeftRadius:l,borderTopRightRadius:c}){let{colors:k,fonts:T,components:_}=O(),[W,P]=useState(false),x=t==="pending"||t==="waiting"||t==="delayed",u=t==="succeeded",s=()=>{n&&Linking.openURL(n);},i=()=>{r&&Linking.openURL(r);};return jsx(ge,{visible:e,onClose:g,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:c,children:jsxs(View,{style:fe.container,children:[jsx(TouchableOpacity,{style:fe.closeButton,onPress:g,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(He,{size:20,color:_.header.buttonColor,strokeWidth:2})}),jsx(View,{style:fe.iconContainer,children:x?jsx(Li,{size:80,strokeWidth:4,iconSize:68,children:o?jsx(Image,{source:{uri:$(o)},style:fe.tokenIconFill}):jsx(View,{style:[fe.tokenIconFill,{backgroundColor:k.cardHover}]})}):jsxs(Fragment,{children:[o?jsx(Image,{source:{uri:$(o)},style:fe.tokenIconLarge}):jsx(View,{style:[fe.tokenIconLarge,{backgroundColor:k.cardHover}]}),jsx(View,{style:[fe.statusBadge,{backgroundColor:_.container.iconBackgroundColor}],children:jsx(Re,{size:16,color:_.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[fe.title,{color:_.container.titleColor,fontFamily:T.semibold}],children:x?"Deposit Processing":"Deposit Complete"}),p!==void 0&&jsxs(Text,{style:[fe.amount,{color:_.container.titleColor,fontFamily:T.bold}],children:["$",p.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[fe.date,{color:_.container.subtitleColor,fontFamily:T.regular}],children:Di(a)}),jsx(Text,{style:[fe.subtitle,{color:_.container.subtitleColor,fontFamily:T.regular}],children:x?"This usually takes less than a minute.":"Your account has been credited successfully!"}),u&&(n||r)&&jsxs(View,{style:fe.detailsSection,children:[jsx(View,{style:[fe.divider,{backgroundColor:k.border}]}),jsxs(TouchableOpacity,{style:fe.detailsToggle,onPress:()=>P(!W),children:[jsx(Text,{style:[fe.detailsToggleText,{color:_.container.actionTitle,fontFamily:T.medium}],children:W?"See less":"See more details"}),W?jsx(_t,{size:18,color:_.container.actionColor,strokeWidth:2}):jsx(Ue,{size:18,color:_.container.actionColor,strokeWidth:2})]}),W&&jsxs(View,{style:fe.txButtonsContainer,children:[n&&jsxs(TouchableOpacity,{style:[fe.txButton,{backgroundColor:_.card.backgroundColor,borderColor:k.border}],onPress:s,children:[jsx(Text,{style:[fe.txLabel,{color:_.card.titleColor,fontFamily:T.medium}],children:"Deposit tx"}),jsx(Text,{style:[fe.txHash,{color:_.card.subtitleColor,fontFamily:T.regular}],children:mn(n)}),jsx(Ut,{size:16,color:_.card.actionColor,strokeWidth:2})]}),r&&jsxs(TouchableOpacity,{style:[fe.txButton,{backgroundColor:_.card.backgroundColor,borderColor:k.border}],onPress:i,children:[jsx(Text,{style:[fe.txLabel,{color:_.card.titleColor,fontFamily:T.medium}],children:"Completion tx"}),jsx(Text,{style:[fe.txHash,{color:_.card.subtitleColor,fontFamily:T.regular}],children:mn(r)}),jsx(Ut,{size:16,color:_.card.actionColor,strokeWidth:2})]})]})]})]})})}var fe=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});var Do=(e,t)=>`${t}:${e}`,Ei=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Xo({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:r,destinationTokenAddress:a,destinationTokenSymbol:p,defaultChainType:g,defaultChainId:l,defaultTokenAddress:c,onExecutionsChange:k,onDepositSuccess:T,onDepositError:_,borderTopLeftRadius:W,borderTopRightRadius:P,sheetBorderRadius:x}){let{colors:u,fonts:s,components:i}=O(),f=g&&l?`${g}:${l}`:"solana:mainnet",[q,L]=useState("USDC"),[D,H]=useState(f),[m,K]=useState([]),[le,ne]=useState(true),[ie,be]=useState([]),[X,Le]=useState(true),[We,Ee]=useState(false),[Je,oe]=useState(false),[xe,je]=useState(false),[ze,De]=useState(false),[ke,Jt]=useState([]),[xt,Kt]=useState(new Map),[st]=useState(()=>new Date),[Vt,Ke]=useState(null),[Ft,Bt]=useState(false),[ue,Xt]=useState(null),[Be,Xe]=useState(false),gt=new Map;ie.forEach(h=>{h.chains.forEach(b=>{let V=`${b.chain_type}:${b.chain_id}`;gt.has(V)||gt.set(V,b);});});let ho=Array.from(gt.values()),Ze=Ei(D),Ae=ho.find(h=>h.chain_type===Ze.chainType&&h.chain_id===Ze.chainId)?.chain_type||"ethereum",Ve=At(m,Ae)?.address||"",Wt=useRef(false);useEffect(()=>{async function h(){try{Le(!0),Ke(null);let V=await wo(t,a&&r&&n?{destination_token_address:a,destination_chain_id:r,destination_chain_type:n}:void 0);if(be(V.data),V.data.length>0&&!Wt.current){Wt.current=!0;let S,U;if(g&&l)if(c)for(let G of V.data){let _e=G.chains.find(Oe=>Oe.chain_type===g&&Oe.chain_id===l&&Oe.token_address.toLowerCase()===c.toLowerCase());if(_e){S=G,U=_e;break}}else for(let G of V.data){let _e=G.chains.find(Oe=>Oe.chain_type===g&&Oe.chain_id===l);if(_e){S=G,U=_e;break}}if(!S&&a)for(let G of V.data){let _e=G.chains.find(Oe=>Oe.token_address.toLowerCase()===a.toLowerCase());if(_e){S=G,U=_e;break}}S||(S=V.data.find(G=>G.symbol==="USDC"),S&&S.chains.length>0&&(U=S.chains[0])),S||(S=V.data.find(G=>G.symbol==="USDT"),S&&S.chains.length>0&&(U=S.chains[0])),S||(S=V.data[0],S.chains.length>0&&(U=S.chains[0])),S&&L(S.symbol),U&&H(Do(U.chain_id,U.chain_type));}}catch(b){console.error("Error fetching supported tokens:",b),Ke("Failed to load supported tokens"),_?.({message:"Failed to load supported tokens",error:b});}finally{Le(false);}}h();},[t,_,g,l,c,a,r,n]),useEffect(()=>{async function h(){try{ne(!0),Ke(null);let b=await zt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:r,destination_token_address:a},t);K(b.data);}catch(b){console.error("Error fetching wallets:",b),Ke("Failed to load wallets"),_?.({message:"Failed to load wallets",error:b});}finally{ne(false);}}h();},[e,o,n,r,a,t,_]),useEffect(()=>{if(!e||!st)return;let h=setInterval(async()=>{try{let b=await Ot(e,t),V=null;for(let S of b.data){let U=S.created_at?new Date(S.created_at):null;if(!U||U<=st)continue;let G=xt.get(S.id);if(!G){V=S;break}if(["pending","waiting","delayed"].includes(G)&&S.status==="succeeded"){V=S;break}}if(V){let S=V;Jt(U=>{let G=U.findIndex(_e=>_e.id===S.id);if(G>=0){let _e=[...U];return _e[G]=S,_e}else return [...U,S]}),Kt(U=>{let G=new Map(U);return G.set(S.id,S.status),G}),Xt(S),Bt(!0),S.status==="succeeded"&&T?.({message:"Deposit completed successfully",executionId:S.id}),k?.([...ke,S]);}}catch(b){console.error("Error polling executions:",b),_?.({message:"Failed to check deposit status",error:b});}},5e3);return ()=>clearInterval(h)},[e,t,st,xt,ke,k,T,_]),useEffect(()=>{if(!ie.length)return;let h=ie.find(V=>V.symbol===q);if(!h||h.chains.length===0)return;if(!h.chains.some(V=>Do(V.chain_id,V.chain_type)===D)){let V=h.chains[0];H(Do(V.chain_id,V.chain_type));}},[q,ie,D]);let me=ie.find(h=>h.symbol===q),yo=me?.chains||[],Se=yo.find(h=>Do(h.chain_id,h.chain_type)===D),Zt=async()=>{if(Ve)try{Clipboard.setString(Ve),Ee(!0),setTimeout(()=>Ee(!1),2e3);}catch(h){console.error("Failed to copy:",h);}},Ne=Se?.estimated_price_impact_percent??0,Et=Se?.max_slippage_percent??.25,Co=Se?.minimum_deposit_amount_usd??3;if(X)return jsxs(View,{style:d.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:u.primary}),jsx(Text,{style:[d.loadingText,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Loading currencies..."})]});if(Vt&&ie.length===0)return jsxs(View,{style:d.errorContainer,children:[jsx(Text,{style:[d.errorText,{color:u.error,fontFamily:s.regular}],children:Vt}),jsx(Text,{style:[d.errorHint,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Please check your network connection and try again."})]});let Q=()=>jsxs(ge,{visible:xe,onClose:()=>je(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:x?.tokenSelector?.borderTopLeftRadius??W,borderTopRightRadius:x?.tokenSelector?.borderTopRightRadius??P,children:[jsxs(View,{style:[d.sheetHeader,{borderBottomColor:u.border}],children:[jsx(View,{style:d.sheetHeaderSpacer}),jsx(Text,{style:[d.sheetTitle,{color:i.header.titleColor,fontFamily:s.medium}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>je(false),style:d.sheetCloseButton,children:jsx(He,{size:20,color:i.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:d.sheetList,showsVerticalScrollIndicator:false,children:ie.map(h=>jsxs(TouchableOpacity,{onPress:()=>{L(h.symbol),je(false);},style:[d.sheetItem,{backgroundColor:q===h.symbol?i.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:$(ae(h,"png"))},style:d.sheetItemIcon}),jsxs(View,{style:d.sheetItemText,children:[jsx(Text,{style:[d.sheetItemTitle,{color:i.card.titleColor,fontFamily:s.medium}],children:h.symbol}),jsxs(Text,{style:[d.sheetItemSubtitle,{color:i.card.subtitleColor,fontFamily:s.regular}],children:[h.chains.length," network",h.chains.length!==1?"s":""," available"]})]}),q===h.symbol&&jsx(Re,{size:20,color:u.primary,strokeWidth:2})]},h.symbol))})]}),ce=()=>jsxs(ge,{visible:ze,onClose:()=>De(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:x?.chainSelector?.borderTopLeftRadius??W,borderTopRightRadius:x?.chainSelector?.borderTopRightRadius??P,children:[jsxs(View,{style:[d.sheetHeader,{borderBottomColor:u.border}],children:[jsx(View,{style:d.sheetHeaderSpacer}),jsx(Text,{style:[d.sheetTitle,{color:i.header.titleColor,fontFamily:s.medium}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>De(false),style:d.sheetCloseButton,children:jsx(He,{size:20,color:i.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:d.sheetList,showsVerticalScrollIndicator:false,children:yo.map(h=>{let b=Do(h.chain_id,h.chain_type),V=D===b;return jsxs(TouchableOpacity,{onPress:()=>{H(b),De(false);},style:[d.sheetItem,{backgroundColor:V?i.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:$(ae(h,"png"))},style:d.sheetItemIcon}),jsxs(View,{style:d.sheetItemText,children:[jsx(Text,{style:[d.sheetItemTitle,{color:i.card.titleColor,fontFamily:s.medium}],children:h.chain_name}),jsxs(Text,{style:[d.sheetItemSubtitle,{color:i.card.subtitleColor,fontFamily:s.regular}],children:["Min deposit: $",h.minimum_deposit_amount_usd]})]}),V&&jsx(Re,{size:20,color:u.primary,strokeWidth:2})]},b)})})]});return jsxs(View,{style:d.container,children:[jsxs(View,{style:d.selectorSection,children:[jsx(Text,{style:[d.selectorLabel,{color:i.card.labelColor,fontFamily:s.regular}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>je(true),style:[d.selector,{backgroundColor:i.card.backgroundColor}],children:[me&&jsx(Image,{source:{uri:$(ae(me,"png"))},style:d.selectorIcon}),jsx(Text,{style:[d.selectorText,{color:i.card.titleColor,fontFamily:s.medium}],children:q}),jsx(Ue,{size:16,color:i.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:d.selectorSection,children:[jsxs(Text,{style:[d.selectorLabel,{color:i.card.labelColor,fontFamily:s.regular}],children:["Network"," ",jsxs(Text,{style:[d.minDeposit,{fontFamily:s.regular}],children:["($",Co," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>De(true),style:[d.selector,{backgroundColor:i.card.backgroundColor}],children:[Se&&jsx(Image,{source:{uri:$(ae(Se,"png"))},style:d.selectorIcon}),jsx(Text,{style:[d.selectorText,{color:i.card.titleColor,fontFamily:s.medium}],numberOfLines:1,children:Se?.chain_name||"Select network"}),jsx(Ue,{size:16,color:i.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:d.qrContainer,children:jsx(View,{style:[d.qrWrapper,{backgroundColor:u.background,borderColor:u.border}],children:le?jsxs(View,{style:d.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:u.primary}),jsx(Text,{style:[d.loadingText,{color:u.foregroundMuted,fontFamily:s.regular}],children:"Loading..."})]}):Ve?jsx(uo,{value:Ve,size:160,logoUri:$(ae(Se,"png")||Pe("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:d.qrLoading,children:jsx(Text,{style:[d.errorText,{color:u.error,fontFamily:s.regular}],children:"No address available"})})})}),jsxs(View,{style:d.addressSection,children:[jsxs(View,{style:d.addressHeader,children:[jsx(Text,{style:[d.addressLabel,{color:i.card.labelColor,fontFamily:s.medium}],children:"Deposit Address"}),We&&jsxs(View,{style:d.copiedIndicator,children:[jsx(Re,{size:14,color:u.success,strokeWidth:2}),jsx(Text,{style:[d.copiedText,{color:u.success,fontFamily:s.regular}],children:"Copied"})]})]}),jsxs(TouchableOpacity,{onPress:Zt,disabled:!Ve||le,activeOpacity:.7,style:[d.addressBox,{backgroundColor:i.card.backgroundColor}],children:[jsx(Text,{style:[d.addressText,{color:i.card.titleColor,fontFamily:s.regular}],numberOfLines:2,children:le?"Loading...":Ve||"No address available"}),jsx(View,{style:d.addressCopyIcon,children:jsx(So,{size:16,color:i.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[d.detailsCard,{backgroundColor:i.card.backgroundColor}],children:[jsxs(TouchableOpacity,{onPress:()=>oe(!Je),style:d.detailsHeader,children:[jsxs(View,{style:d.detailsRow,children:[jsx(View,{style:[d.detailIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(Ht,{size:12,color:i.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[d.detailsLabel,{color:i.card.titleColor,fontFamily:s.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:d.chevronContainer,children:Je?jsx(_t,{size:16,color:i.card.actionColor,strokeWidth:2}):jsx(Ue,{size:16,color:i.card.actionColor,strokeWidth:2})})]}),Je&&jsxs(View,{style:d.detailsContent,children:[jsxs(View,{style:d.detailsRow,children:[jsx(View,{style:[d.detailIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(no,{size:12,color:i.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[d.detailsLabel,{color:i.card.titleColor,fontFamily:s.regular}],children:["Price impact: ",Ne.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Xe(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(io,{size:14,color:i.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:d.detailsRow,children:[jsx(View,{style:[d.detailIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(so,{size:12,color:i.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[d.detailsLabel,{color:i.card.titleColor,fontFamily:s.regular}],children:["Slippage: Auto \u2022 ",Et.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Xe(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(io,{size:14,color:i.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:d.detailsRow,children:[jsx(View,{style:[d.detailIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(No,{size:12,color:i.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[d.detailsLabel,{color:i.card.titleColor,fontFamily:s.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:d.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[d.termsText,{color:u.primary,fontFamily:s.regular}],children:"Terms apply"})}),Q(),ce(),jsxs(ge,{visible:Be,onClose:()=>Xe(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:x?.infoSheet?.borderTopLeftRadius??W,borderTopRightRadius:x?.infoSheet?.borderTopRightRadius??P,children:[jsxs(View,{style:[d.sheetHeader,{borderBottomColor:u.border}],children:[jsx(View,{style:d.sheetHeaderSpacer}),jsx(Text,{style:[d.sheetTitle,{color:i.header.titleColor,fontFamily:s.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>Xe(false),style:d.sheetCloseButton,children:jsx(He,{size:20,color:i.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:d.infoSheetContent,children:[jsxs(View,{style:[d.infoCard,{backgroundColor:i.card.backgroundColor}],children:[jsxs(View,{style:d.infoCardHeader,children:[jsx(View,{style:[d.infoCardIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(no,{size:16,color:i.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[d.infoCardTitle,{color:i.card.titleColor,fontFamily:s.medium}],children:"Price Impact"}),jsxs(Text,{style:[d.infoCardValue,{color:i.card.titleColor,fontFamily:s.medium}],children:[Ne.toFixed(2),"%"]})]}),jsx(Text,{style:[d.infoCardDescription,{color:i.card.descriptionColor,fontFamily:s.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[d.infoCard,{backgroundColor:i.card.backgroundColor}],children:[jsxs(View,{style:d.infoCardHeader,children:[jsx(View,{style:[d.infoCardIcon,{backgroundColor:i.card.iconBackgroundColor}],children:jsx(so,{size:16,color:i.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[d.infoCardTitle,{color:i.card.titleColor,fontFamily:s.medium}],children:"Max Slippage"}),jsxs(Text,{style:[d.infoCardValue,{color:i.card.titleColor,fontFamily:s.medium}],children:[Et.toFixed(2),"%"]})]}),jsx(Text,{style:[d.infoCardDescription,{color:i.card.descriptionColor,fontFamily:s.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),ue&&jsx(po,{visible:Ft,status:ue.status,tokenIconUrl:ue.destination_token_metadata?.icon_urls?.find(h=>h.format==="png")?.url||ue.destination_token_metadata?.icon_url||ae(me,"png"),explorerUrl:ue.explorer_url,completionExplorerUrl:ue.destination_explorer_url,date:ue.created_at?new Date(ue.created_at):void 0,amountUsd:ue.source_amount_usd?parseFloat(ue.source_amount_usd):void 0,onClose:()=>Bt(false),borderTopLeftRadius:x?.depositStatus?.borderTopLeftRadius??W,borderTopRightRadius:x?.depositStatus?.borderTopRightRadius??P})]})}var d=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16,borderRadius:16,borderWidth:1},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{maxHeight:400,paddingTop:8},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function Zo({currency:e,isSelected:t,onSelect:o}){let{colors:n,fonts:r,components:a}=O();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[qt.container,{backgroundColor:a.card.backgroundColor}],children:[jsxs(View,{style:qt.leftContent,children:[jsx(View,{style:[qt.iconContainer,{backgroundColor:n.background}],children:jsx(Image,{source:{uri:$(ae(e,"png"))},style:qt.icon})}),jsxs(View,{style:qt.textContainer,children:[jsx(Text,{style:[qt.name,{color:a.card.titleColor,fontFamily:r.medium}],children:e.name}),jsx(Text,{style:[qt.code,{color:a.card.subtitleColor,fontFamily:r.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(Re,{size:16,color:n.primary,strokeWidth:2})]})}var qt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function Fo({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{fonts:r,components:a}=O();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:kn.headerContainer,children:jsx(Text,{style:[kn.title,{color:a.list.titleSectionColor,fontFamily:r.medium}],children:e})}),t.map(p=>jsx(Zo,{currency:p,isSelected:o.toLowerCase()===p.currency_code.toLowerCase(),onSelect:n},p.currency_code))]})}var kn=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function tr({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:r,onSelectCurrency:a,borderTopLeftRadius:p,borderTopRightRadius:g}){let{colors:l,fonts:c,components:k}=O(),[T,_]=useState(""),W=n.map(q=>o.find(L=>L.currency_code.toLowerCase()===q.toLowerCase())).filter(q=>q!==void 0),P=o.filter(q=>!n.includes(q.currency_code.toLowerCase())),x=q=>{if(!T)return q;let L=T.toLowerCase();return q.filter(D=>D.name.toLowerCase().includes(L)||D.currency_code.toLowerCase().includes(L))},u=x(W),s=x(P),i=q=>{a(q),t(false),_("");},f=()=>{t(false),_("");};return jsxs(ge,{visible:e,onClose:f,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:p,borderTopRightRadius:g,children:[jsx(Qe,{title:"Currency",showBack:false,onClose:f}),jsx(View,{style:$t.searchContainer,children:jsx(TextInput,{style:[$t.searchInput,{backgroundColor:k.search.backgroundColor,color:k.search.inputColor,fontFamily:c.regular}],value:T,onChangeText:_,placeholder:"Search",placeholderTextColor:k.search.placeholderColor})}),jsx(ScrollView,{style:$t.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:$t.listContent,children:[jsx(Fo,{title:"Popular currencies",currencies:u,selectedCurrency:r,onSelect:i}),u.length>0&&s.length>0&&jsx(View,{style:$t.sectionSpacer}),jsx(Fo,{title:"All currencies",currencies:s,selectedCurrency:r,onSelect:i}),u.length===0&&s.length===0&&jsx(View,{style:$t.noResultsContainer,children:jsx(Text,{style:[$t.noResultsText,{color:k.container.subtitleColor,fontFamily:c.regular}],children:"No currencies found"})})]})})]})}var $t=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Er(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function or({externalUserId:e,publishableKey:t,view:o,onViewChange:n,destinationTokenSymbol:r,recipientAddress:a,destinationChainType:p,destinationChainId:g,destinationTokenAddress:l,onDepositSuccess:c,onDepositError:k,borderTopLeftRadius:T,borderTopRightRadius:_,sheetBorderRadius:W}){let{colors:P,fonts:x,components:u}=O(),[s,i]=useState(""),[f,q]=useState("usd"),[L,D]=useState(false),[H,m]=useState(false),[K,le]=useState([]),[ne,ie]=useState(false),[be,X]=useState(null),[Le,We]=useState(null),[Ee,Je]=useState("amount"),[oe,xe]=useState(null),[je,ze]=useState(true),[De,ke]=useState(null),[Jt,xt]=useState(false),Kt=useRef(null),st=useRef(false);useEffect(()=>{Kt.current=oe;},[oe]),useEffect(()=>{st.current=Jt;},[Jt]);let[Vt,Ke]=useState([]),[Ft,Bt]=useState(true),[ue,Xt]=useState(60),[Be,Xe]=useState([]),[gt,ho]=useState([]),[Ze,Pt]=useState(null),[Ae,fr]=useState(null),[Ve,Wt]=useState(true),[me,yo]=useState(null),[Se,Zt]=useState(false),[Ne,Et]=useState(null),[Co,Q]=useState(false),[ce,h]=useState(false),[b,V]=useState(false),[S,U]=useState(null),G=o??Ee,_e=useRef(null),Oe=Be.find(I=>I.currency_code.toLowerCase()===f.toLowerCase()),Hn=useCallback(I=>{Je(I),I==="quotes"?n?.(I,K.length):n?.(I);},[K.length,n]);useEffect(()=>{async function I(){try{let B=await xo();fr(B);}catch(B){console.error("Error fetching user IP:",B);}finally{Wt(false);}}I();},[]),useEffect(()=>{async function I(){try{let B=await zt({external_user_id:e,recipient_address:a,destination_chain_type:p,destination_chain_id:g,destination_token_address:l},t);Ke(B.data);}catch(B){console.error("Error fetching wallets:",B),X("Failed to load wallet addresses");}finally{Bt(false);}}I();},[e,a,p,g,l,t]);let Un=r||Ze?.symbol.toUpperCase()||"USDC",jn=to(Ze?.icon_urls,"png")||Ze?.icon_url,Nn=to(Ze?.chain_icon_urls,"png")||Ze?.chain_icon_url;useEffect(()=>{async function I(){try{let B=await xr(t);Xe(B.data),ho(B.preferred||[]);}catch(B){console.error("Error fetching fiat currencies:",B);}}I();},[t]),useEffect(()=>{if(L||Be.length===0||!Ae?.alpha2)return;let I=Ae.alpha2.toUpperCase(),B=Be.find(pe=>pe.country_codes.includes(I));if(B)q(B.currency_code.toLowerCase()),!s&&!H&&i(B.default_amount.toString());else if(!s&&!H){let pe=Be.find(at=>at.currency_code.toLowerCase()==="usd");pe&&i(pe.default_amount.toString());}},[Be,Ae,L,s,H]),useEffect(()=>{if(Be.length!==0){if(_e.current!==null&&_e.current!==f){let I=Be.find(B=>B.currency_code.toLowerCase()===f.toLowerCase());I&&i(I.default_amount.toString());}_e.current=f;}},[f,Be]),useEffect(()=>{async function I(){try{let B=await br({chain_type:p||"",chain_id:g||"",token_address:l||""},t);Pt(B);}catch(B){console.error("Error fetching supported tokens:",B);}}I();},[p,g,l,t]),useEffect(()=>{async function I(){if(!(!l||!g||!p)&&!Ve){Zt(true);try{let B=await Tr({country_code:Ae?.alpha2?.toUpperCase()||"US",subdivision_code:Ae?.state||void 0,token_address:l,chain_id:g,chain_type:p},t);yo(B);}catch(B){console.error("Error fetching default onramp token:",B);}finally{Zt(false);}}}I();},[l,g,p,Ae,Ve,t]),useEffect(()=>{let I=parseFloat(s);if(isNaN(I)||I<=0){le([]),We(null);return}if(!me||Se){le([]),xe(null);return}let B=Be.find(at=>at.currency_code.toLowerCase()===f.toLowerCase());if(B){if(I<B.minimum_amount){le([]),xe(null),We(`Minimum amount is ${Er(f)}${B.minimum_amount.toLocaleString()}`);return}if(I>B.maximum_amount){le([]),xe(null),We(`Maximum amount is ${Er(f)}${B.maximum_amount.toLocaleString()}`);return}}We(null);let pe=setTimeout(()=>{Gr(I);},500);return ()=>clearTimeout(pe)},[s,f,t,me,Se,Be]);let Gr=async I=>{if(!me){X("Loading token information...");return}ie(true),X(null);try{let B={country_code:Ae?.alpha2?.toUpperCase()||"US",source_amount:I.toString(),source_currency:f.toLowerCase(),destination_currency:me.destination_currency,destination_network:me.destination_network,subdivision_code:Ae?.state||void 0},pe=await kr(B,t);le(pe.data);let at=st.current,Yr=Kt.current;if(at&&Yr){let eo=pe.data.find(ft=>ft.service_provider===Yr.service_provider);if(eo){if(xe(eo),pe.data.length>0){let ft=pe.data.reduce((St,bo)=>bo.destination_amount>St.destination_amount?bo:St);De||ke(ft.service_provider),ze(eo.service_provider===De);}}else if(pe.data.length>0){let ft=pe.data.reduce((St,bo)=>bo.destination_amount>St.destination_amount?bo:St);xe(ft),ke(ft.service_provider),ze(!0),xt(!1);}}else if(pe.data.length>0){let eo=pe.data.reduce((ft,St)=>St.destination_amount>ft.destination_amount?St:ft);xe(eo),ke(eo.service_provider),ze(!0);}Xt(60);}catch(B){console.error("Failed to fetch quotes:",B),X("Failed to fetch quotes. Please try again."),le([]);}finally{ie(false);}};useEffect(()=>{if(K.length===0)return;let I=setInterval(()=>{Xt(B=>{if(B<=1){let pe=parseFloat(s);return !isNaN(pe)&&pe>0&&Gr(pe),60}return B-1});},1e3);return ()=>clearInterval(I)},[K.length,s]);let qn=I=>{(/^\d*\.?\d{0,2}$/.test(I)||I==="")&&(i(I),m(true));},$n=I=>{i(I.toString()),m(true);},Qn=async()=>{if(oe&&me)try{let I=me.destination_token_metadata.chain_type,B=At(Vt,I);if(!B?.address){X("Wallet address not available");return}let pe={service_provider:oe.service_provider,country_code:oe.country_code?.toUpperCase()||Ae?.alpha2?.toUpperCase()||"US",source_currency:oe.source_currency,source_amount:s,destination_currency:oe.destination_currency,destination_network:oe.destination_network,wallet_address:B.address,subdivision_code:Ae?.state||void 0},at=await wr(pe,t);Et({provider:oe,sourceCurrency:f,sourceAmount:s,sessionUrl:at.url}),U(at.url),V(!0);}catch(I){console.error("Failed to create session:",I),X("Failed to start payment flow"),k?.({message:"Failed to start payment flow",error:I});}},mr=Er(f),Gn=()=>{V(false),Hn("onramp"),c?.({message:"Payment flow completed"});},Yn=()=>jsx(Ki,{visible:b,onClose:Gn,url:S,providerName:oe?.service_provider_display_name||"Complete Payment",colors:P,fonts:x,borderTopLeftRadius:W?.webView?.borderTopLeftRadius??T,borderTopRightRadius:W?.webView?.borderTopRightRadius??_});return G==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:w.amountViewContainer,children:[jsxs(ScrollView,{style:w.scrollContainer,contentContainerStyle:w.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:w.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>Q(true),style:[w.currencyButton,{backgroundColor:u.card.backgroundColor}],children:[Oe&&jsx(Image,{source:{uri:$(ae(Oe,"png"))},style:w.currencyIcon}),jsx(Text,{style:[w.currencyText,{color:u.card.titleColor,fontFamily:x.medium}],children:f.toUpperCase()}),jsx(Ue,{size:16,color:u.card.actionColor,strokeWidth:2})]})}),jsx(tr,{open:Co,onOpenChange:Q,currencies:Be,preferredCurrencyCodes:gt,selectedCurrency:f,onSelectCurrency:I=>{q(I.toLowerCase()),D(true);},borderTopLeftRadius:W?.currencyModal?.borderTopLeftRadius??T,borderTopRightRadius:W?.currencyModal?.borderTopRightRadius??_}),jsx(View,{style:w.amountContainer,children:jsxs(View,{style:w.amountInputRow,children:[jsx(Text,{style:[w.currencySymbol,{color:u.container.titleColor,fontFamily:x.medium}],children:mr}),jsx(TextInput,{style:[w.amountInput,{color:u.container.titleColor,fontFamily:x.medium}],value:s,onChangeText:qn,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:P.foregroundMuted})]})}),Oe?.suggested_amounts&&Oe.suggested_amounts.length>0&&jsx(View,{style:w.quickAmounts,children:Oe.suggested_amounts.map(I=>jsx(TouchableOpacity,{onPress:()=>$n(I),style:[w.quickAmountButton,{backgroundColor:u.card.backgroundColor},parseFloat(s)===I&&{borderColor:P.primary,borderWidth:2}],children:jsxs(Text,{style:[w.quickAmountText,{color:u.card.titleColor,fontFamily:x.medium}],children:[mr,I.toLocaleString()]})},I))}),Le&&jsx(Text,{style:[w.validationError,{color:P.error,fontFamily:x.regular}],children:Le}),jsxs(View,{style:w.providerSection,children:[jsxs(View,{style:w.providerHeader,children:[jsx(Text,{style:[w.providerLabel,{color:u.card.labelColor,fontFamily:x.medium}],children:"Provider"}),K.length>0&&!ne&&jsxs(Text,{style:[w.refreshText,{color:u.card.labelRightColor,fontFamily:x.regular}],children:["Refreshing in ",ue,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>h(true),disabled:ne||K.length===0,style:[w.providerButton,{backgroundColor:u.card.backgroundColor},(ne||K.length===0)&&w.disabled],children:ne?jsxs(View,{style:w.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:u.container.subtitleColor}),jsx(Text,{style:[w.loadingText,{color:u.container.subtitleColor,fontFamily:x.regular}],children:"Finding best rates..."})]}):oe?jsxs(View,{style:w.providerContent,children:[jsxs(View,{style:w.providerInfo,children:[je&&jsx(Text,{style:[w.autoPickedText,{color:u.container.subtitleColor,fontFamily:x.regular}],children:"Auto-picked for you"}),jsxs(View,{style:w.providerRow,children:[jsx(Image,{source:{uri:$(Uo(oe.icon_urls,"png",oe.icon_url))},style:w.providerIconImage},`provider-${oe.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[w.providerName,{color:u.card.titleColor,fontFamily:x.medium}],children:oe.service_provider_display_name}),jsxs(Text,{style:[w.bestPriceText,{color:P.success,fontFamily:x.regular}],children:["Best price \u2022 ",oe.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(ht,{size:20,color:u.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[w.noProviderText,{color:u.container.subtitleColor,fontFamily:x.regular}],children:parseFloat(s)>0?"No providers available":"Enter an amount to see providers"})}),be&&jsx(Text,{style:[w.errorText,{color:P.error,fontFamily:x.regular}],children:be})]}),jsxs(ge,{visible:ce,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:W?.providerModal?.borderTopLeftRadius??T,borderTopRightRadius:W?.providerModal?.borderTopRightRadius??_,children:[jsx(Qe,{title:"Select Provider",showBack:false,onClose:()=>h(false)}),jsx(ScrollView,{style:w.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:w.quotesList,children:[...K].sort((I,B)=>B.destination_amount-I.destination_amount).map((I,B)=>{let pe=oe?.service_provider===I.service_provider,at=B===0;return jsxs(TouchableOpacity,{onPress:()=>{xe(I),xt(true),ze(I.service_provider===De),h(false);},style:[w.quoteItem,{backgroundColor:u.card.backgroundColor},pe&&{borderColor:P.primary,borderWidth:2}],children:[jsxs(View,{style:w.quoteLeft,children:[jsx(Image,{source:{uri:$(Uo(I.icon_urls,"png",I.icon_url))},style:w.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[w.quoteName,{color:u.card.titleColor,fontFamily:x.medium}],children:I.service_provider_display_name}),at&&jsx(Text,{style:[w.bestPriceLabel,{color:P.success,fontFamily:x.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:w.quoteRight,children:[jsxs(Text,{style:[w.quoteAmount,{color:u.card.textRightColor,fontFamily:x.medium}],children:[I.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[w.quoteSource,{color:u.card.subtextRightColor,fontFamily:x.regular}],children:["Fee: ",mr,I.total_fee.toFixed(2)]})]})]},I.service_provider)})})})]})]}),jsx(View,{style:[w.continueButtonContainer,{backgroundColor:P.background}],children:jsx(TouchableOpacity,{onPress:Qn,disabled:ne||Ft||!oe||parseFloat(s)<=0,style:[w.continueButton,{backgroundColor:u.container.buttonColor},(ne||Ft||!oe)&&w.disabledButton],children:jsx(Text,{style:[w.continueButtonText,{color:u.container.buttonTitleColor,fontFamily:x.medium}],children:Ft?"Loading...":"Continue"})})})]}),Yn()]}):G==="onramp"&&Ne?jsxs(View,{style:w.onrampContainer,children:[jsx(Image,{source:{uri:$(Uo(Ne.provider.icon_urls,"png",Ne.provider.icon_url))},style:w.onrampProviderIcon}),jsxs(Text,{style:[w.onrampTitle,{color:u.container.titleColor,fontFamily:x.medium}],children:["Complete transaction with ",Ne.provider.service_provider_display_name]}),jsx(Text,{style:[w.onrampSubtitle,{color:u.container.subtitleColor,fontFamily:x.regular}],children:"You can close this modal."}),jsxs(View,{style:[w.flowDiagram,{backgroundColor:u.card.backgroundColor}],children:[jsxs(View,{style:w.flowStep,children:[jsx(Image,{source:{uri:Pe(`/icons/currencies/png/${Ne.sourceCurrency.toLowerCase()}.png`)},style:w.flowIconImage}),jsx(Text,{style:[w.flowLabel,{color:u.card.subtitleColor,fontFamily:x.regular}],children:"You use"}),jsx(Text,{style:[w.flowValue,{color:u.card.titleColor,fontFamily:x.medium}],children:Ne.sourceCurrency.toUpperCase()})]}),jsx(ht,{size:16,color:u.card.actionColor,strokeWidth:2}),jsxs(View,{style:w.flowStep,children:[jsxs(View,{style:w.flowIconWithBadge,children:[jsx(Image,{source:{uri:to(me?.destination_token_metadata?.icon_urls,"png")||me?.destination_token_metadata?.icon_url||Pe("/icons/tokens/png/usdc.png")},style:w.flowIconImageNoBadge}),jsx(Image,{source:{uri:to(me?.destination_token_metadata?.chain?.icon_urls,"png")||me?.destination_token_metadata?.chain?.icon_url||Pe("/icons/networks/png/polygon.png")},style:[w.flowNetworkBadge,{borderColor:P.background}]})]}),jsx(Text,{style:[w.flowLabel,{color:u.card.subtitleColor,fontFamily:x.regular}],children:"You buy"}),jsx(Text,{style:[w.flowValue,{color:u.card.titleColor,fontFamily:x.medium}],children:"USDC"})]}),jsx(ht,{size:16,color:u.card.actionColor,strokeWidth:2}),jsxs(View,{style:w.flowStep,children:[jsxs(View,{style:w.flowIconWithBadge,children:[jsx(Image,{source:{uri:jn||Pe("/icons/tokens/png/usdc.png")},style:w.flowIconImageNoBadge}),jsx(Image,{source:{uri:Nn||Pe("/icons/networks/png/polygon.png")},style:[w.flowNetworkBadge,{borderColor:P.background}]})]}),jsx(Text,{style:[w.flowLabel,{color:u.card.subtitleColor,fontFamily:x.regular}],children:"You receive"}),jsx(Text,{style:[w.flowValue,{color:u.card.titleColor,fontFamily:x.medium}],children:Un})]})]}),jsx(View,{style:[w.onrampInfoBox,{backgroundColor:u.card.backgroundColor}],children:jsx(Text,{style:[w.onrampInfoText,{color:u.card.descriptionColor,fontFamily:x.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function Ki({visible:e,onClose:t,url:o,providerName:n,colors:r,fonts:a,borderTopLeftRadius:p,borderTopRightRadius:g}){return jsxs(ge,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:p,borderTopRightRadius:g,children:[jsxs(View,{style:Qt.header,children:[jsx(TouchableOpacity,{onPress:t,style:Qt.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Re,{size:20,color:r.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Qt.headerTitle,{color:r.foreground,fontFamily:a.medium}],children:n}),jsx(View,{style:Qt.headerSpacer})]}),o&&jsx(View,{style:Qt.container,children:jsx(WebView,{source:{uri:o},style:Qt.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Qt.loading,children:jsx(ActivityIndicator,{size:"large",color:r.primary})})})})]})}var Qt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),w=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,borderRadius:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},bestPriceLabel:{fontSize:11,marginTop:2},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function os(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function rs(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function ir({execution:e,onPress:t}){let {colors:o,fonts:n,components:r}=O(),a=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let g=$(ae(e.destination_token_metadata,"png")||Pe("/icons/tokens/png/usdc.png")),l=a?"Deposit Processing":"Deposit Completed",c=os(e.created_at||new Date().toISOString()),k=rs(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[wt.container,{backgroundColor:r.card.backgroundColor}],children:[jsxs(View,{style:wt.iconContainer,children:[jsx(Image,{source:{uri:g},style:wt.tokenIcon}),jsx(View,{style:[wt.statusBadge,{backgroundColor:a?o.warning:o.success,borderColor:r.card.backgroundColor}],children:a?jsx(rn,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Re,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:wt.textContainer,children:[jsx(Text,{style:[wt.title,{color:r.card.titleColor,fontFamily:n.medium}],children:l}),jsx(Text,{style:[wt.dateTime,{color:r.card.subtitleColor,fontFamily:n.regular}],children:c})]}),jsxs(View,{style:wt.rightContainer,children:[jsx(Text,{style:[wt.amount,{color:r.card.textRightColor,fontFamily:n.medium}],children:k}),jsx(ht,{size:20,color:r.card.actionColor,strokeWidth:2})]})]})}var wt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});var{height:ls}=Dimensions.get("window");function Rn(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function vn(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function cs(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var Ln=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Dn(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function ds(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function ar({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:r,borderTopLeftRadius:a,borderTopRightRadius:p}){let{colors:g,fonts:l,components:c}=O(),[k,T]=useState(o),[_,W]=useState(false),[P,x]=useState(null),[u,s]=useState(false),i=useRef(null);useEffect(()=>{if(!e||!n)return;let m=async()=>{W(true);try{let ne=[...(await Ot(n,r)).data].sort((ie,be)=>{let X=ie.created_at?new Date(ie.created_at).getTime():0;return (be.created_at?new Date(be.created_at).getTime():0)-X});T(ne);}catch(le){console.error("Failed to fetch executions:",le),T(o);}finally{W(false);}};m();let K=setInterval(m,1e4);return ()=>clearInterval(K)},[e,n,r,o]),useEffect(()=>{o.length>0&&T(m=>{let K=new Set(m.map(ne=>ne.id)),le=o.filter(ne=>!K.has(ne.id));return le.length>0?[...le,...m]:m});},[o]),useEffect(()=>{e||x(null);},[e]);let f=m=>{x(m);},q=()=>{x(null),s(false);},L=()=>{x(null),t();};return jsxs(ge,{visible:e,onClose:L,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:a,borderTopRightRadius:p,children:[jsx(Qe,{title:P?"Deposit Details":"Deposit Tracker",onClose:L,showClose:!P,showBack:!!P,onBack:q}),P?(()=>{if(!P)return null;let m=P,K=m.status==="pending"||m.status==="waiting"||m.status==="delayed",le=m.status==="succeeded",ne=$(ae(m.destination_token_metadata,"png")||Pe("/icons/tokens/png/usdc.png")),ie=m.provider_metadata?.details,be=ie?.currencyIn,X=ie?.currencyOut;be?.currency?.symbol||"USDC";X?.currency?.symbol||"USDC";let Ee=vn(m.source_amount_base_unit,m.source_token_metadata?.decimals),Je=vn(m.destination_amount_base_unit,m.destination_token_metadata?.decimals),oe=cs(m.source_amount_usd),xe=Rn(m.source_chain_type,m.source_chain_id),je=Rn(m.destination_chain_type,m.destination_chain_id),ze=()=>{m.explorer_url&&Linking.openURL(m.explorer_url);},De=()=>{m.destination_explorer_url&&Linking.openURL(m.destination_explorer_url);};return jsxs(ScrollView,{ref:i,style:F.scrollContainer,contentContainerStyle:F.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:F.iconSection,children:[jsxs(View,{style:F.iconWrapper,children:[jsx(Image,{source:{uri:ne},style:F.tokenIcon}),jsx(View,{style:[F.statusBadge,{backgroundColor:K?g.warning:g.success,borderColor:g.background}],children:K?jsx(Ue,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(Re,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:F.statusRow,children:[jsx(View,{style:[F.statusDot,{backgroundColor:K?g.warning:g.success}]}),jsx(Text,{style:[F.statusText,{color:c.container.titleColor,fontFamily:l.semibold}],children:K?"Processing":"Completed"})]}),jsx(Text,{style:[F.dateText,{color:c.container.subtitleColor,fontFamily:l.regular}],children:ds(m.created_at||new Date().toISOString())})]}),jsxs(View,{style:[F.card,{backgroundColor:c.card.backgroundColor}],children:[jsxs(View,{style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Amount Sent"}),jsxs(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:[Ee," ",Dn(m.source_currency)]})]}),jsx(View,{style:[F.cardDivider,{backgroundColor:g.border}]}),jsxs(View,{style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Amount Received"}),jsxs(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:[Je," ",Dn(m.destination_currency)]})]}),jsx(View,{style:[F.cardDivider,{backgroundColor:g.border}]}),jsxs(View,{style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"USD Value"}),jsx(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:oe})]}),jsx(View,{style:[F.cardDivider,{backgroundColor:g.border}]}),jsxs(View,{style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Source Network"}),jsx(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:xe})]}),jsx(View,{style:[F.cardDivider,{backgroundColor:g.border}]}),jsxs(View,{style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Destination Network"}),jsx(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:je})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let ke=!u;s(ke),ke?setTimeout(()=>{i.current?.scrollToEnd({animated:true});},100):i.current?.scrollTo({y:0,animated:true});},style:F.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[F.toggleText,{color:c.container.actionTitle,fontFamily:l.regular}],children:u?"See less":"See more details"}),u?jsx(_t,{size:14,color:c.container.actionColor,strokeWidth:2}):jsx(Ue,{size:14,color:c.container.actionColor,strokeWidth:2})]}),u&&jsxs(View,{style:[F.card,{backgroundColor:c.card.backgroundColor}],children:[m.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:ze,style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Deposit Tx"}),jsxs(View,{style:F.cardRowRight,children:[jsx(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:Ln(m.transaction_hash)}),jsx(Ut,{size:14,color:c.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[F.cardDivider,{backgroundColor:g.border}]})]}),m.destination_explorer_url&&le&&jsxs(TouchableOpacity,{onPress:De,style:F.cardRow,children:[jsx(Text,{style:[F.cardLabel,{color:c.card.rowLeftLabel,fontFamily:l.regular}],children:"Completion Tx"}),jsxs(View,{style:F.cardRowRight,children:[jsx(Text,{style:[F.cardValue,{color:c.card.rowRightLabel,fontFamily:l.medium}],children:Ln(m.destination_transaction_hashes[0])}),jsx(Ut,{size:14,color:c.card.actionIcon,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:F.scrollContainer,contentContainerStyle:F.scrollContent,showsVerticalScrollIndicator:false,children:k.length===0?jsxs(View,{style:F.emptyContainer,children:[jsx(Text,{style:[F.emptyText,{color:c.container.titleColor,fontFamily:l.medium}],children:"No deposits yet"}),jsx(Text,{style:[F.emptySubtext,{color:c.container.subtitleColor,fontFamily:l.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:F.executionsList,children:k.map(m=>jsx(ir,{execution:m,onPress:()=>f(m)},m.id))})})]})}var F=StyleSheet.create({scrollContainer:{maxHeight:ls*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function Bo(e,t=true){let[o,n]=useState(null),[r,a]=useState(null),[p,g]=useState(false),[l,c]=useState(false),[k,T]=useState(null),[_,W]=useState(null);useEffect(()=>{!t||o||(g(true),xo().then(s=>{n(s),T(null);}).catch(s=>{T(s instanceof Error?s:new Error(String(s)));}).finally(()=>{g(false);}));},[t,o]),useEffect(()=>{!t||!e||r||(c(true),To(e).then(s=>{a(s),W(null);}).catch(s=>{W(s instanceof Error?s:new Error(String(s)));}).finally(()=>{c(false);}));},[t,e,r]);let P=p||l,x=k||_||null,u=null;if(o&&r){let s=r.blocked_country_codes||[],i=o.alpha2.toUpperCase();u=!s.some(f=>f.toUpperCase()===i);}return {isAllowed:u,alpha2:o?.alpha2?.toLowerCase()??null,country:o?.country??null,isLoading:P,error:x}}var Ur="unifold_recent_tokens",gs=5,Wn=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function dr(){try{let e=await Hr.getItem(Ur);return e?JSON.parse(e):[]}catch{return []}}async function fs(e){try{let o=(await dr()).filter(r=>!(r.symbol===e.symbol&&r.chainType===e.chainType&&r.chainId===e.chainId));o.unshift(e);let n=o.slice(0,gs);await Hr.setItem(Ur,JSON.stringify(n));}catch{}}async function ms(e){try{let o=(await dr()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));return await Hr.setItem(Ur,JSON.stringify(o)),o}catch{return []}}function jr({visible:e,onClose:t,tokens:o,selectedToken:n,selectedChainKey:r,onSelect:a,borderTopLeftRadius:p,borderTopRightRadius:g}){let{colors:l,fonts:c,components:k}=O(),[T,_]=useState(""),[W,P]=useState([]);useEffect(()=>{e&&dr().then(P);},[e]),useEffect(()=>{e||_("");},[e]);let x=useMemo(()=>{let L=[];return o.forEach(D=>{D.chains.forEach(H=>{L.push({token:D,chain:H});});}),L},[o]),u=useMemo(()=>{let L=[],D=new Set,H=(m,K,le,ne)=>{let ie=`${m}-${K}:${le}`;if(D.has(ie))return;let be=o.find(Le=>Le.symbol===m);if(!be)return;let X=be.chains.find(Le=>Le.chain_type===K&&Le.chain_id===le);X&&(D.add(ie),L.push({token:be,chain:X,isRecent:ne}));};return W.forEach(m=>{H(m.symbol,m.chainType,m.chainId,true);}),Wn.forEach(m=>{H(m.symbol,m.chainType,m.chainId,false);}),L},[o,W]),s=useMemo(()=>{if(!T.trim())return x;let L=T.toLowerCase();return x.filter(({token:D,chain:H})=>D.symbol.toLowerCase().includes(L)||D.name.toLowerCase().includes(L)||H.chain_name.toLowerCase().includes(L))},[x,T]),i=(L,D,H)=>Wn.some(m=>m.symbol===L&&m.chainType===D&&m.chainId===H),f=async(L,D)=>{let H=`${D.chain_type}:${D.chain_id}`;if(!i(L.symbol,D.chain_type,D.chain_id)){await fs({symbol:L.symbol,chainType:D.chain_type,chainId:D.chain_id});let m=await dr();P(m);}_(""),a(L.symbol,H),t();},q=async(L,D)=>{let H=await ms({symbol:L.symbol,chainType:D.chain_type,chainId:D.chain_id});P(H);};return jsxs(ge,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,borderTopLeftRadius:p,borderTopRightRadius:g,children:[jsxs(View,{style:ee.header,children:[jsx(View,{style:ee.headerSpacer}),jsx(Text,{style:[ee.headerTitle,{color:k.header.titleColor,fontFamily:c.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity,{onPress:t,style:ee.closeButton,children:jsx(He,{size:20,color:k.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:ee.searchContainer,children:jsx(TextInput,{style:[ee.searchInput,{backgroundColor:k.search.backgroundColor,color:k.search.inputColor,fontFamily:c.regular}],placeholder:"Search",placeholderTextColor:k.search.placeholderColor,value:T,onChangeText:_,autoCapitalize:"none",autoCorrect:false})}),u.length>0&&!T&&jsxs(View,{style:ee.quickSelectSection,children:[jsx(Text,{style:[ee.sectionLabel,{color:k.list.titleSectionColor,fontFamily:c.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:ee.quickSelectScroll,children:u.map(({token:L,chain:D,isRecent:H})=>{let m=`${D.chain_type}:${D.chain_id}`;L.symbol===n&&m===r;return jsxs(View,{children:[H&&jsx(TouchableOpacity,{onPress:()=>q(L,D),style:ee.removeButton,children:jsx(He,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity,{onPress:()=>f(L,D),style:[ee.quickSelectItem],children:[jsxs(View,{style:ee.tokenIconContainer,children:[jsx(Image,{source:{uri:$(ae(L,"png"))},style:ee.quickSelectIcon}),jsx(Image,{source:{uri:$(ae(D,"png"))},style:[ee.quickSelectChainBadge,{borderColor:k.card.backgroundColor}]})]}),jsxs(View,{style:ee.quickSelectText,children:[jsx(Text,{style:[ee.quickSelectSymbol,{color:k.card.titleColor,fontFamily:c.medium}],children:L.symbol}),jsx(Text,{style:[ee.quickSelectChain,{color:k.card.subtitleColor,fontFamily:c.regular}],children:D.chain_name})]})]})]},`quick-${L.symbol}-${m}`)})})]}),jsx(Text,{style:[ee.sectionLabel,{color:k.list.titleSectionColor,fontFamily:c.regular}],children:"All supported tokens"}),jsx(ScrollView,{style:ee.tokenList,showsVerticalScrollIndicator:false,contentContainerStyle:ee.tokenListContent,children:s.length===0?jsx(View,{style:ee.emptyState,children:jsx(Text,{style:[ee.emptyText,{color:l.foregroundMuted,fontFamily:c.regular}],children:"No tokens found"})}):s.map(({token:L,chain:D})=>{let H=`${D.chain_type}:${D.chain_id}`,m=L.symbol===n&&H===r;return jsxs(TouchableOpacity,{onPress:()=>f(L,D),style:[ee.tokenItem,{backgroundColor:m?k.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:ee.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:$(ae(L,"png"))},style:ee.tokenIcon}),jsx(Image,{source:{uri:$(ae(D,"png"))},style:[ee.tokenChainBadge,{borderColor:k.card.backgroundColor}]})]}),jsxs(View,{style:ee.tokenInfo,children:[jsx(Text,{style:[ee.tokenSymbol,{color:k.card.titleColor,fontFamily:c.medium}],children:L.symbol}),jsx(Text,{style:[ee.tokenChainName,{color:k.card.subtitleColor,fontFamily:c.regular}],children:D.chain_name})]}),jsxs(Text,{style:[ee.minDeposit,{color:k.card.labelColor,fontFamily:c.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:k.card.labelHighlightRightColor,fontFamily:c.regular},children:["$",D.minimum_deposit_amount_usd]})]})]},`${L.symbol}-${H}`)})})]})}var ee=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,borderRadius:8,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12,borderRadius:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:24,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var ur=(e,t)=>`${t}:${e}`,ks=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Nr({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:r,destinationTokenAddress:a,destinationTokenSymbol:p,defaultChainType:g,defaultChainId:l,defaultTokenAddress:c,onExecutionsChange:k,onDepositSuccess:T,onDepositError:_,wallets:W,borderTopLeftRadius:P,borderTopRightRadius:x,sheetBorderRadius:u}){let{colors:s,fonts:i,components:f}=O(),q=g&&l?`${g}:${l}`:"solana:mainnet",[L,D]=useState("USDC"),[H,m]=useState(q),[K,le]=useState([]),[ne,ie]=useState(!W?.length),be=W?.length?W:K,[X,Le]=useState([]),[We,Ee]=useState(true),[Je,oe]=useState(false),[xe,je]=useState(false),[ze,De]=useState(false),[ke,Jt]=useState([]),[xt,Kt]=useState(new Map),[st]=useState(()=>new Date),[Vt,Ke]=useState(null),[Ft,Bt]=useState(false),[ue,Xt]=useState(null),[Be,Xe]=useState(false),gt=new Map;X.forEach(Q=>{Q.chains.forEach(ce=>{let h=`${ce.chain_type}:${ce.chain_id}`;gt.has(h)||gt.set(h,ce);});});let ho=Array.from(gt.values()),Ze=ks(H),Pt=ho.find(Q=>Q.chain_type===Ze.chainType&&Q.chain_id===Ze.chainId),Ae=Pt?.chain_type||"ethereum",Ve=At(be,Ae)?.address||"",Wt=useRef(false);useEffect(()=>{async function Q(){try{Ee(!0),Ke(null);let h=await wo(t,a&&r&&n?{destination_token_address:a,destination_chain_id:r,destination_chain_type:n}:void 0);if(Le(h.data),h.data.length>0&&!Wt.current){Wt.current=!0;let b,V;if(g&&l)if(c)for(let S of h.data){let U=S.chains.find(G=>G.chain_type===g&&G.chain_id===l&&G.token_address.toLowerCase()===c.toLowerCase());if(U){b=S,V=U;break}}else for(let S of h.data){let U=S.chains.find(G=>G.chain_type===g&&G.chain_id===l);if(U){b=S,V=U;break}}if(!b&&a)for(let S of h.data){let U=S.chains.find(G=>G.token_address.toLowerCase()===a.toLowerCase());if(U){b=S,V=U;break}}b||(b=h.data.find(S=>S.symbol==="USDC"),b&&b.chains.length>0&&(V=b.chains[0])),b||(b=h.data.find(S=>S.symbol==="USDT"),b&&b.chains.length>0&&(V=b.chains[0])),b||(b=h.data[0],b.chains.length>0&&(V=b.chains[0])),b&&D(b.symbol),V&&m(ur(V.chain_id,V.chain_type));}}catch(ce){console.error("Error fetching supported tokens:",ce),Ke("Failed to load supported tokens"),_?.({message:"Failed to load supported tokens",error:ce});}finally{Ee(false);}}Q();},[t,a,r,n,g,l,c,_]),useEffect(()=>{k&&k(ke);},[ke,k]),useEffect(()=>{if(W?.length){ie(false);return}if(K.length>0){ie(false);return}let Q=null,ce=false,h=async()=>{if(!ce){ie(true);try{let b=await zt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:r,destination_token_address:a},t);ce||(le(b.data),Ke(null),ie(!1));}catch(b){console.error("Error fetching wallets, retrying in 5s:",b),ce||(Ke(b instanceof Error?b.message:"Failed to load wallets"),ie(false),Q=setTimeout(h,5e3));}}};return h(),()=>{ce=true,Q&&clearTimeout(Q);}},[e,o,n,r,a,t,W,K.length]),useEffect(()=>{if(!e||!st)return;let Q=setInterval(async()=>{try{let ce=await Ot(e,t),h=null;for(let b of ce.data){let V=b.created_at?new Date(b.created_at):null;if(!V||V<=st)continue;let S=xt.get(b.id);if(!S){h=b;break}if(["pending","waiting","delayed"].includes(S)&&b.status==="succeeded"){h=b;break}}if(h){let b=h;Jt(V=>{let S=V.findIndex(U=>U.id===b.id);if(S>=0){let U=[...V];return U[S]=b,U}else return [...V,b]}),Kt(V=>{let S=new Map(V);return S.set(b.id,b.status),S}),Xt(b),Bt(!0),b.status==="succeeded"&&T?.({message:"Deposit completed successfully",executionId:b.id}),k?.([...ke,b]);}}catch(ce){console.error("Error polling executions:",ce),_?.({message:"Failed to check deposit status",error:ce});}},3e3);return ()=>clearInterval(Q)},[e,t,st,xt,ke,k,T,_]),useEffect(()=>{if(!X.length)return;let Q=X.find(h=>h.symbol===L);if(!Q||Q.chains.length===0)return;if(!Q.chains.some(h=>ur(h.chain_id,h.chain_type)===H)){let h=Q.chains[0];m(ur(h.chain_id,h.chain_type));}},[L,X,H]);let me=X.find(Q=>Q.symbol===L),Se=(me?.chains||[]).find(Q=>ur(Q.chain_id,Q.chain_type)===H),Zt=async()=>{if(Ve)try{Clipboard.setString(Ve),oe(!0),setTimeout(()=>oe(!1),2e3);}catch(Q){console.error("Failed to copy:",Q);}},Ne=Se?.estimated_price_impact_percent??0,Et=Se?.max_slippage_percent??.25,Co=Se?.minimum_deposit_amount_usd??3;return We?jsxs(View,{style:C.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:s.primary}),jsx(Text,{style:[C.loadingText,{color:s.foregroundMuted,fontFamily:i.regular}],children:"Loading currencies..."})]}):Vt&&X.length===0?jsxs(View,{style:C.errorContainer,children:[jsx(Text,{style:[C.errorText,{color:s.error,fontFamily:i.regular}],children:Vt}),jsx(Text,{style:[C.errorHint,{color:s.foregroundMuted,fontFamily:i.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:C.container,children:[jsxs(View,{style:C.selectorSection,children:[jsx(Text,{style:[C.selectorLabel,{color:f.card.labelColor,fontFamily:i.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity,{onPress:()=>De(true),disabled:We||X.length===0,style:[C.tokenSelectorButton,{backgroundColor:f.card.backgroundColor}],activeOpacity:.7,children:We?jsxs(View,{style:C.tokenSelectorLoading,children:[jsx(View,{style:[C.loadingIcon,{backgroundColor:s.cardHover}]}),jsxs(View,{style:C.loadingTextContainer,children:[jsx(View,{style:[C.loadingLine,{backgroundColor:s.cardHover,width:60}]}),jsx(View,{style:[C.loadingLine,{backgroundColor:s.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:C.tokenIconWrapper,children:[me&&jsx(Image,{source:{uri:$(ae(me,"png"))},style:C.tokenMainIcon}),(Se||Pt)&&jsx(Image,{source:{uri:$(ae(Se||Pt,"png"))},style:[C.tokenChainBadge,{borderColor:f.card.backgroundColor}]})]}),jsxs(View,{style:C.tokenSelectorInfo,children:[jsx(Text,{style:[C.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:i.semibold}],children:me?.symbol||L}),jsx(Text,{style:[C.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:i.regular}],numberOfLines:1,children:Se?.chain_name||Pt?.chain_name||"Select network"})]}),jsxs(View,{style:C.tokenSelectorRight,children:[jsxs(Text,{style:[C.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:i.medium}],children:["$",Co," min"]}),jsx(ht,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(jr,{visible:ze,onClose:()=>De(false),tokens:X,selectedToken:L,selectedChainKey:H,onSelect:(Q,ce)=>{D(Q),m(ce);},borderTopLeftRadius:u?.tokenSelector?.borderTopLeftRadius??P,borderTopRightRadius:u?.tokenSelector?.borderTopRightRadius??x}),jsx(View,{style:C.qrContainer,children:jsx(View,{style:[C.qrWrapper,{backgroundColor:s.background,borderColor:s.border}],children:ne?jsxs(View,{style:C.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:s.primary}),jsx(Text,{style:[C.loadingText,{color:s.foregroundMuted,fontFamily:i.regular}],children:"Loading..."})]}):Ve?jsx(uo,{value:Ve,size:180,logoUri:$(ae(Se,"png")||Pe("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:C.qrLoading,children:jsx(Text,{style:[C.errorText,{color:s.error,fontFamily:i.regular}],children:"No address available"})})})}),jsxs(View,{style:C.addressSection,children:[jsxs(View,{style:C.addressHeader,children:[jsx(Text,{style:[C.addressLabel,{color:f.card.labelColor,fontFamily:i.medium}],children:"Deposit Address"}),Je&&jsxs(View,{style:C.copiedIndicator,children:[jsx(Re,{size:14,color:s.success,strokeWidth:2}),jsx(Text,{style:[C.copiedText,{color:s.success,fontFamily:i.regular}],children:"Copied"})]})]}),jsxs(TouchableOpacity,{onPress:Zt,disabled:!Ve||ne,activeOpacity:.7,style:[C.addressBox,{backgroundColor:f.card.backgroundColor}],children:[jsx(Text,{style:[C.addressText,{color:f.card.titleColor,fontFamily:i.regular}],numberOfLines:2,children:ne?"Loading...":Ve||"No address available"}),jsx(View,{style:C.addressCopyIcon,children:jsx(So,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[C.detailsCard,{backgroundColor:f.card.backgroundColor}],children:[jsxs(TouchableOpacity,{onPress:()=>je(!xe),style:C.detailsHeader,children:[jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(Ht,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.detailsLabel,{color:f.card.titleColor,fontFamily:i.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:C.chevronContainer,children:xe?jsx(_t,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Ue,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),xe&&jsxs(View,{style:C.detailsContent,children:[jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(no,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:f.card.titleColor,fontFamily:i.regular}],children:["Price impact: ",Ne.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Xe(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(io,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(so,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:f.card.titleColor,fontFamily:i.regular}],children:["Slippage: Auto \u2022 ",Et.toFixed(2),"%"]}),jsx(TouchableOpacity,{onPress:()=>Xe(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(io,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:C.detailsRow,children:[jsx(View,{style:[C.detailIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(No,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[C.detailsLabel,{color:f.card.titleColor,fontFamily:i.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:C.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[C.termsText,{color:s.primary,fontFamily:i.regular}],children:"Terms apply"})}),jsxs(ge,{visible:Be,onClose:()=>Xe(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:u?.infoSheet?.borderTopLeftRadius??P,borderTopRightRadius:u?.infoSheet?.borderTopRightRadius??x,children:[jsxs(View,{style:[C.sheetHeader,{borderBottomColor:s.border}],children:[jsx(View,{style:C.sheetHeaderSpacer}),jsx(Text,{style:[C.sheetTitle,{color:f.header.titleColor,fontFamily:i.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>Xe(false),style:C.sheetCloseButton,children:jsx(He,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:C.infoSheetContent,children:[jsxs(View,{style:[C.infoCard,{backgroundColor:f.card.backgroundColor}],children:[jsxs(View,{style:C.infoCardHeader,children:[jsx(View,{style:[C.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(no,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.infoCardTitle,{color:f.card.titleColor,fontFamily:i.medium}],children:"Price Impact"}),jsxs(Text,{style:[C.infoCardValue,{color:f.card.titleColor,fontFamily:i.medium}],children:[Ne.toFixed(2),"%"]})]}),jsx(Text,{style:[C.infoCardDescription,{color:f.card.descriptionColor,fontFamily:i.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[C.infoCard,{backgroundColor:f.card.backgroundColor}],children:[jsxs(View,{style:C.infoCardHeader,children:[jsx(View,{style:[C.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor}],children:jsx(so,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[C.infoCardTitle,{color:f.card.titleColor,fontFamily:i.medium}],children:"Max Slippage"}),jsxs(Text,{style:[C.infoCardValue,{color:f.card.titleColor,fontFamily:i.medium}],children:[Et.toFixed(2),"%"]})]}),jsx(Text,{style:[C.infoCardDescription,{color:f.card.descriptionColor,fontFamily:i.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),ue&&jsx(po,{visible:Ft,status:ue.status,tokenIconUrl:ue.destination_token_metadata?.icon_urls?.find(Q=>Q.format==="png")?.url||ue.destination_token_metadata?.icon_url||ae(me,"png"),explorerUrl:ue.explorer_url,completionExplorerUrl:ue.destination_explorer_url,date:ue.created_at?new Date(ue.created_at):void 0,amountUsd:ue.source_amount_usd?parseFloat(ue.source_amount_usd):void 0,onClose:()=>Bt(false),borderTopLeftRadius:u?.depositStatus?.borderTopLeftRadius??P,borderTopRightRadius:u?.depositStatus?.borderTopRightRadius??x})]})}var C=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16,borderRadius:16,borderWidth:1},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var Yt={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Is({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:r="Deposit",destinationTokenSymbol:a,recipientAddress:p,destinationChainType:g,destinationChainId:l,destinationTokenAddress:c,defaultChainType:k,defaultChainId:T,defaultTokenAddress:_,hideDepositTracker:W=false,transferInputVariant:P="double_input",onDepositSuccess:x,onDepositError:u,sheetBorderRadius:s}){let i=s?.globalBorderTopLeftRadius,f=s?.globalBorderTopRightRadius,{colors:q,fonts:L}=O(),[D,H]=useState([]),[m,K]=useState(false),[le,ne]=useState(false),[ie,be]=useState(false),[X,Le]=useState(null),[We,Ee]=useState("amount"),{isAllowed:Je,isLoading:oe}=Bo(n,e);useEffect(()=>{e&&!X&&To(n).then(Le).catch(console.error);},[e,X,n]);let xe=()=>{t();},je=D.filter(ke=>ke.status==="pending"||ke.status==="waiting").length,ze=oe||e&&!X,De=Je===false;return jsxs(ge,{visible:e,onClose:xe,closeOnBackdropPress:false,showHandle:false,borderTopLeftRadius:s?.main?.borderTopLeftRadius??i,borderTopRightRadius:s?.main?.borderTopRightRadius??f,children:[jsx(Qe,{title:r,showBack:false,onClose:xe}),ze&&jsx(View,{style:Tt.centeredContainer,children:jsx(ActivityIndicator,{size:"large",color:q.primary})}),!ze&&De&&jsxs(View,{style:Tt.centeredContainer,children:[jsx(View,{style:[Tt.iconContainer,{backgroundColor:q.cardHover}],children:jsx(qo,{size:32,color:q.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Tt.blockedTitle,{color:q.foreground,fontFamily:L.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tt.blockedDescription,{color:q.foreground,opacity:.7,fontFamily:L.regular}],children:"There are no supported tokens available from your current location."})]}),!ze&&!De&&jsxs(View,{style:Tt.optionsContainer,children:[jsx(_o,{onPress:()=>ne(true),title:Yt.transferCrypto.title,subtitle:Yt.transferCrypto.subtitle,featuredTokens:X?.transfer_crypto?.networks}),jsx(Ro,{onPress:()=>be(true),title:Yt.depositWithCard.title,subtitle:Yt.depositWithCard.subtitle,paymentNetworks:X?.payment_networks?.networks}),!W&&jsx(vo,{onPress:()=>K(true),title:Yt.depositTracker.title,subtitle:Yt.depositTracker.subtitle,badge:je>0?je:void 0})]}),jsx(ar,{visible:m,onClose:()=>K(false),executions:D,externalUserId:o,publishableKey:n,borderTopLeftRadius:s?.depositsTracker?.borderTopLeftRadius??i,borderTopRightRadius:s?.depositsTracker?.borderTopRightRadius??f}),jsxs(ge,{visible:le,onClose:()=>ne(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,borderTopLeftRadius:s?.transferCrypto?.borderTopLeftRadius??i,borderTopRightRadius:s?.transferCrypto?.borderTopRightRadius??f,children:[jsx(Qe,{title:Yt.transferCrypto.title,showBack:false,onClose:()=>ne(false)}),jsx(ScrollView,{style:Tt.transferScrollContainer,contentContainerStyle:Tt.scrollContent,showsVerticalScrollIndicator:false,children:P==="single_input"?jsx(Nr,{externalUserId:o,publishableKey:n,recipientAddress:p,destinationChainType:g,destinationChainId:l,destinationTokenAddress:c,destinationTokenSymbol:a,defaultChainType:k,defaultChainId:T,defaultTokenAddress:_,onExecutionsChange:H,onDepositSuccess:x,onDepositError:u,borderTopLeftRadius:i,borderTopRightRadius:f,sheetBorderRadius:{tokenSelector:s?.tokenSelector,infoSheet:s?.infoSheet,depositStatus:s?.depositStatus}}):jsx(Xo,{externalUserId:o,publishableKey:n,recipientAddress:p,destinationChainType:g,destinationChainId:l,destinationTokenAddress:c,destinationTokenSymbol:a,defaultChainType:k,defaultChainId:T,defaultTokenAddress:_,onExecutionsChange:H,onDepositSuccess:x,onDepositError:u,borderTopLeftRadius:i,borderTopRightRadius:f,sheetBorderRadius:{tokenSelector:s?.tokenSelector,chainSelector:s?.chainSelector,infoSheet:s?.infoSheet,depositStatus:s?.depositStatus}})})]}),jsxs(ge,{visible:ie,onClose:()=>{be(false),Ee("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,borderTopLeftRadius:s?.buyWithCard?.borderTopLeftRadius??i,borderTopRightRadius:s?.buyWithCard?.borderTopRightRadius??f,children:[jsx(Qe,{title:`Deposit ${a||"USDC"}`,showBack:We==="onramp",onBack:()=>Ee("amount"),onClose:()=>{be(false),Ee("amount");}}),jsx(View,{style:Tt.buyWithCardContainer,children:jsx(or,{externalUserId:o,publishableKey:n,destinationTokenSymbol:a,recipientAddress:p,destinationChainType:g,destinationChainId:l,destinationTokenAddress:c,onDepositSuccess:x,onDepositError:u,view:We,onViewChange:ke=>Ee(ke),borderTopLeftRadius:i,borderTopRightRadius:f,sheetBorderRadius:{providerModal:s?.providerModal,webView:s?.webView,currencyModal:s?.currencyModal}})})]})]})}function pr({theme:e="auto",...t}){return jsx(Is,{...t})}var Tt=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Es=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),Mn=createContext(null);function zs({children:e,publishableKey:t,config:o}){let[n]=useState(()=>Es()),[r,a]=useState(false),[p,g]=useState(null),l=useColorScheme(),c=useRef(false);c.current||(Ho({publishableKey:t}),c.current=true);let k=useMemo(()=>{let i=o?.appearance||"dark";return i==="auto"?l==="dark"?"dark":"light":i},[o?.appearance,l]);useEffect(()=>{if(!t||t.trim()===""){console.error("Unifold: publishableKey is required. Please provide a valid publishable key.");return}!t.startsWith("pk_test_")&&!t.startsWith("pk_live_")&&console.warn('Unifold: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),Ho({publishableKey:t});},[t]);let T=useRef(null),_=useRef(null),W=useCallback(i=>{_.current&&(clearTimeout(_.current),_.current=null),T.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),T.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),T.current=null);let f=new Promise((q,L)=>{T.current={resolve:q,reject:L};});return g(i),a(true),f},[]),P=useCallback(()=>{T.current&&(T.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),T.current=null),a(false),_.current=setTimeout(()=>{g(null),_.current=null;},200);},[]),x=useCallback(i=>{p?.onSuccess&&p.onSuccess(i),T.current&&(T.current.resolve(i),T.current=null);},[p]),u=useCallback(i=>{console.error("[UnifoldProvider] Deposit error:",i),p?.onError&&p.onError(i),T.current&&(T.current.reject(i),T.current=null);},[p]),s=useMemo(()=>({publishableKey:t,beginDeposit:W,closeDeposit:P}),[t,W,P]);return jsx(QueryClientProvider,{client:n,children:jsx(Mn.Provider,{value:s,children:jsxs(Ao,{mode:k,accentColor:o?.accentColor,theme:o?.theme,fontFamily:o?.fontFamily,fonts:o?.fonts,components:o?.components,children:[e,p&&jsx(pr,{visible:r,onClose:P,publishableKey:t,modalTitle:o?.modalTitle,externalUserId:p.externalUserId,destinationChainType:p.destinationChainType,destinationChainId:p.destinationChainId,destinationTokenSymbol:p.destinationTokenSymbol,recipientAddress:p.recipientAddress,destinationTokenAddress:p.destinationTokenAddress,defaultChainType:p.defaultChainType,defaultChainId:p.defaultChainId,defaultTokenAddress:p.defaultTokenAddress,hideDepositTracker:o?.hideDepositTracker,transferInputVariant:o?.transferInputVariant,onDepositSuccess:x,onDepositError:u,theme:k,sheetBorderRadius:o?.sheetBorderRadius})]})})})}function As(){let e=useContext(Mn);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
+ export{zs as UnifoldProvider,Kr as setDevApiUrl,Bo as useAllowedCountry,As as useUnifold};