@unifold/connect-react-native 0.1.4 → 0.1.5

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.d.mts CHANGED
@@ -23,7 +23,7 @@ interface DepositError {
23
23
  code?: string;
24
24
  }
25
25
  interface DepositConfig {
26
- userId: string;
26
+ externalUserId: string;
27
27
  destinationChainType?: "ethereum" | "solana" | "bitcoin";
28
28
  destinationChainId?: string;
29
29
  destinationTokenAddress?: string;
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ interface DepositError {
23
23
  code?: string;
24
24
  }
25
25
  interface DepositConfig {
26
- userId: string;
26
+ externalUserId: string;
27
27
  destinationChainType?: "ethereum" | "solana" | "bitcoin";
28
28
  destinationChainId?: string;
29
29
  destinationTokenAddress?: string;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),reactNative=require('react-native'),reactQuery=require('@tanstack/react-query'),jsxRuntime=require('react/jsx-runtime'),ee=require('react-native-svg'),Kr=require('react-native-qrcode-svg');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ee__default=/*#__PURE__*/_interopDefault(ee);var Kr__default=/*#__PURE__*/_interopDefault(Kr);var zo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Rr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Fo=react.createContext({colors:zo,isDark:false,mode:"auto"});function Ze({children:e,mode:t="auto"}){let o=reactNative.useColorScheme(),r=react.useMemo(()=>{let l;return t==="auto"?l=o==="dark":l=t==="dark",{colors:l?Rr:zo,isDark:l,mode:t}},[t,o]);return jsxRuntime.jsx(Fo.Provider,{value:r,children:e})}function _(){let e=react.useContext(Fo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Vr="https://api.unifold.io",Nt,_e="pk_test_123",Ht={};function ne(){return typeof __DEV__<"u"&&__DEV__&&Nt?Nt:Vr}function xt(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.'),_e=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Nt=e.baseUrl),e.defaultConfig&&(Ht=e.defaultConfig);}function Uo(e){typeof __DEV__<"u"&&__DEV__?(Nt=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oo(){return ne()}function Ae(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 le(e){let t=e.startsWith("/")?e:`/${e}`;return `${ne()}/api/public${t}`}function jo(e,t){if(!t)return le(e);let o=e.startsWith("/")?e:`/${e}`;return `${t.endsWith("/")?t.slice(0,-1):t}/api/public${o}`}function L(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ne()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ne()}${e}`:`${ne()}/api/public${e}`:""}async function mo(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||Ht.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ht.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Ht.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},r=t||_e;Ae(r);let l=await fetch(`${ne()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok)throw new Error(`Failed to create deposit address: ${l.statusText}`);return l.json()}async function Je(e,t){return mo(e?{...e,external_user_id:e.user_id}:void 0,t)}function Xe(e,t){return e.find(o=>o.chain_type===t)}var Me=(a=>(a.DELAYED="delayed",a.FAILED="failed",a.PENDING="pending",a.REFUNDED="refunded",a.SUCCEEDED="succeeded",a.WAITING="waiting",a))(Me||{}),Ho="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";async function et(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/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(!r.ok)throw new Error(`Failed to query executions: ${r.statusText}`);return r.json()}function K(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(r=>r.format===t);return o?o.url:e.icon_url}async function qt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function $t(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to fetch Meld quotes: ${r.statusText}`);return r.json()}async function Qt(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to create Meld session: ${r.statusText}`);return r.json()}async function Gt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/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 No(e,t="png"){if(!e||e.length===0)return;let o=e.find(r=>r.format===t);return o?o.url:e[0]?.url}async function Yt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/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 qo(){let e=await fetch(`${ne()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function $o(e,t,o){let r=e.find(i=>i.chain_id===o);if(r)return r.chain_name;let l=e.find(i=>i.chain_type===t);return l?l.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}var{height:wt}=reactNative.Dimensions.get("window");function Y({visible:e,onClose:t,children:o,closeOnBackdropPress:r=true,showHandle:l=true,heightPercent:i}){let{colors:a}=_(),m=react.useRef(new reactNative.Animated.Value(wt)).current,h=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{e?(m.setValue(wt),h.setValue(0),reactNative.Animated.parallel([reactNative.Animated.spring(m,{toValue:0,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(h,{toValue:.5,duration:200,useNativeDriver:true})]).start()):reactNative.Animated.parallel([reactNative.Animated.spring(m,{toValue:wt,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(h,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,m,h]);let n=()=>{r&&t();};return jsxRuntime.jsx(reactNative.Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxRuntime.jsxs(reactNative.KeyboardAvoidingView,{behavior:reactNative.Platform.OS==="ios"?"padding":"height",style:ze.container,children:[jsxRuntime.jsx(reactNative.TouchableWithoutFeedback,{onPress:n,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[ze.backdrop,{backgroundColor:"#000000",opacity:h}]})}),jsxRuntime.jsxs(reactNative.Animated.View,{style:[ze.sheet,{backgroundColor:a.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:m}],...i&&{height:wt*i}}],children:[l&&jsxRuntime.jsx(reactNative.View,{style:ze.handleContainer,children:jsxRuntime.jsx(reactNative.View,{style:[ze.handle,{backgroundColor:a.border}]})}),jsxRuntime.jsx(reactNative.View,{style:[ze.content,i&&ze.contentFlex],children:o})]})]})})}var ze=reactNative.StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...reactNative.StyleSheet.absoluteFillObject},sheet:{maxHeight:wt*.9,paddingBottom:reactNative.Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingVertical:12},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function yo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Co({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function kt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function rt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function nt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function me({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ie({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Kt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.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"}),jsxRuntime.jsx(ee.Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Zo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.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 Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.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"}),jsxRuntime.jsx(ee.Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Zt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Jt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.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 se({title:e,showBack:t=false,showClose:o=true,onBack:r,onClose:l,badge:i}){let{colors:a}=_();return jsxRuntime.jsxs(reactNative.View,{style:ue.header,children:[jsxRuntime.jsx(reactNative.View,{style:ue.leftContainer,children:t&&r?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:r,style:[ue.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(xo,{size:20,color:a.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:ue.spacer})}),jsxRuntime.jsxs(reactNative.View,{style:ue.titleContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ue.title,{color:a.foreground}],children:e}),i&&i.count>0&&jsxRuntime.jsx(reactNative.View,{style:[ue.titleBadge,{backgroundColor:a.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[ue.titleBadgeText,{color:a.foregroundMuted}],children:i.count})})]}),jsxRuntime.jsx(reactNative.View,{style:ue.rightContainer,children:o?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:l,style:[ue.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(rt,{size:20,color:a.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:ue.spacer})})]})}var ue=reactNative.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,fontWeight:"500",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 ae({uri:e,width:t,height:o,borderRadius:r=0,borderWidth:l=0,borderColor:i="transparent",backgroundColor:a="transparent",style:m}){let[h,n]=react.useState(false),V=e?.toLowerCase().endsWith(".svg");if(!e)return jsxRuntime.jsx(reactNative.View,{style:[{width:t,height:o,borderRadius:r,backgroundColor:"#374151"},m]});let w={width:t,height:o,borderRadius:r,borderWidth:l,borderColor:i,backgroundColor:a,overflow:"hidden",alignItems:"center",justifyContent:"center",...m},c=t-l*2,T=o-l*2;return h?jsxRuntime.jsx(reactNative.View,{style:[w,{backgroundColor:a||"#374151"}]}):V?jsxRuntime.jsx(reactNative.View,{style:w,children:jsxRuntime.jsx(ee.SvgUri,{uri:e,width:c,height:T,onError:N=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,N),n(true);}})}):jsxRuntime.jsx(reactNative.View,{style:w,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:{width:c,height:T},resizeMode:"contain",onError:N=>{console.log(`[RemoteIcon] Image load error for ${e}:`,N.nativeEvent.error),n(true);}})})}function at({onPress:e,title:t,subtitle:o,featuredTokens:r}){let{colors:l}=_(),i=r?[...r].sort((a,m)=>a.position-m.position):[];return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ye.container,{backgroundColor:l.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:ye.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[ye.iconContainer,{backgroundColor:l.cardHover}],children:jsxRuntime.jsx(yo,{size:20,color:l.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:ye.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ye.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[ye.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:ye.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:ye.networkIcons,children:i.map((a,m)=>{let h=a.icon_urls.find(n=>n.format==="png")?.url||a.icon_urls.find(n=>n.format==="svg")?.url;return jsxRuntime.jsx(reactNative.View,{style:[ye.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:i.length-m}],children:jsxRuntime.jsx(ae,{uri:L(h),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:l.card})},a.name)})})})]})}var ye=reactNative.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 ct({onPress:e,title:t,subtitle:o,paymentNetworks:r}){let{colors:l}=_();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Re.container,{backgroundColor:l.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Re.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Re.iconContainer,{backgroundColor:l.cardHover}],children:jsxRuntime.jsx(Co,{size:20,color:l.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:Re.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Re.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Re.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:Re.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:Re.paymentIcons,children:r?.map(i=>{let a=i.icon_urls.find(m=>m.format==="png")?.url||i.icon_urls.find(m=>m.format==="svg")?.url;return jsxRuntime.jsx(ae,{uri:L(a),width:32,height:20,borderRadius:4},i.name)})})})]})}var Re=reactNative.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 dt({onPress:e,title:t,subtitle:o,badge:r}){let{colors:l}=_();return jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Pe.container,{backgroundColor:l.card}],children:jsxRuntime.jsxs(reactNative.View,{style:Pe.leftContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[Pe.iconContainer,{backgroundColor:l.cardHover}],children:[jsxRuntime.jsx(kt,{size:20,color:l.foreground,strokeWidth:2}),r!==void 0&&r>0&&jsxRuntime.jsx(reactNative.View,{style:[Pe.badge,{backgroundColor:l.primary}],children:jsxRuntime.jsx(reactNative.Text,{style:Pe.badgeText,children:r>99?"99+":r})})]}),jsxRuntime.jsxs(reactNative.View,{style:Pe.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Pe.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Pe.subtitle,{color:l.foregroundMuted}],children:o})]})]})})}var Pe=reactNative.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 Tt({value:e,size:t=180,logoUri:o,logoSize:r=40,logoBackgroundColor:l}){let{colors:i,isDark:a}=_(),m=a?"#1a1a1a":"#ffffff",h=a?"#ffffff":"#000000",n=l||m;return jsxRuntime.jsxs(reactNative.View,{style:[sr.container,{width:t,height:t}],children:[jsxRuntime.jsx(Kr__default.default,{value:e||"placeholder",size:t,backgroundColor:m,color:h,ecl:"H",quietZone:4}),o&&jsxRuntime.jsx(reactNative.View,{style:[sr.logoContainer,{width:r+12,height:r+12,backgroundColor:n,borderRadius:(r+12)/2}],children:jsxRuntime.jsx(ae,{uri:o,width:r,height:r,borderRadius:r/2})})]})}var sr=reactNative.StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function _t({visible:e,status:t,tokenIconUrl:o,explorerUrl:r,completionExplorerUrl:l,onClose:i}){let{colors:a}=_(),m=react.useRef(new reactNative.Animated.Value(0)).current,h=t==="pending"||t==="waiting"||t==="delayed",n=t==="succeeded";react.useEffect(()=>{if(h&&e){let T=reactNative.Animated.loop(reactNative.Animated.timing(m,{toValue:1,duration:1e3,easing:reactNative.Easing.linear,useNativeDriver:true}));return T.start(),()=>T.stop()}else m.setValue(0);},[h,e,m]);let V=m.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),w=()=>{r&&reactNative.Linking.openURL(r);},c=()=>{l&&reactNative.Linking.openURL(l);};return jsxRuntime.jsx(Y,{visible:e,onClose:i,closeOnBackdropPress:true,showHandle:false,children:jsxRuntime.jsxs(reactNative.View,{style:j.container,children:[jsxRuntime.jsxs(reactNative.View,{style:j.iconContainer,children:[o?jsxRuntime.jsx(reactNative.Image,{source:{uri:L(o)},style:j.tokenIcon}):jsxRuntime.jsx(reactNative.View,{style:[j.tokenIcon,{backgroundColor:a.cardHover}]}),jsxRuntime.jsx(reactNative.View,{style:[j.statusBadge,{backgroundColor:h?"#F97316":"#22C55E"}],children:h?jsxRuntime.jsx(reactNative.Animated.View,{style:{transform:[{rotate:V}]},children:jsxRuntime.jsx(Jt,{size:16,color:"#fff",strokeWidth:2.5})}):jsxRuntime.jsx(ie,{size:16,color:"#fff",strokeWidth:3})})]}),jsxRuntime.jsx(reactNative.Text,{style:[j.title,{color:a.foreground}],children:h?"Deposit Processing":"Deposit Complete"}),jsxRuntime.jsx(reactNative.Text,{style:[j.subtitle,{color:a.foregroundMuted}],children:h?`Your deposit is being processed.
2
- This usually takes less than a minute.`:"Your account has been credited successfully!"}),h?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:i,style:[j.button,j.dismissButton],children:jsxRuntime.jsx(reactNative.Text,{style:j.buttonText,children:"Dismiss"})}):jsxRuntime.jsxs(reactNative.View,{style:j.buttonRow,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:w,style:[j.button,j.successButton,j.halfButton],children:jsxRuntime.jsx(reactNative.Text,{style:j.buttonText,children:"View deposit tx"})}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:c,style:[j.button,j.successButton,j.halfButton],children:jsxRuntime.jsx(reactNative.Text,{style:j.buttonText,children:"View completion tx"})})]}),n&&jsxRuntime.jsx(reactNative.Text,{style:[j.hint,{color:a.foregroundMuted}],children:"Opens in external browser"})]})})}var j=reactNative.StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:24,paddingBottom:20},iconContainer:{position:"relative",marginBottom:20},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",marginBottom:24,lineHeight:20},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},dismissButton:{backgroundColor:"#F97316",width:"100%"},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});var It=(e,t)=>`${t}:${e}`,sn=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function vt({userId:e,publishableKey:t,recipientAddress:o,destinationChainType:r,destinationChainId:l,destinationTokenAddress:i,onExecutionsChange:a,onDepositSuccess:m,onDepositError:h}){let{colors:n}=_(),[V,w]=react.useState("USDC"),[c,T]=react.useState("solana:mainnet"),[N,q]=react.useState([]),[B,W]=react.useState(true),[b,p]=react.useState([]),[$,U]=react.useState(true),[G,te]=react.useState(false),[oe,E]=react.useState(false),[Ne,Le]=react.useState(false),[ft,fe]=react.useState(false),[qe,gt]=react.useState([]),[Be,$e]=react.useState(new Map),[Ee]=react.useState(()=>new Date),[zt,Qe]=react.useState(null),[We,Ft]=react.useState(false),[ke,Ut]=react.useState(null),mt=new Map;b.forEach(y=>{y.chains.forEach(P=>{let M=`${P.chain_type}:${P.chain_id}`;mt.has(M)||mt.set(M,P);});});let Ge=Array.from(mt.values()),ht=sn(c),fo=Ge.find(y=>y.chain_type===ht.chainType&&y.chain_id===ht.chainId)?.chain_type||"ethereum",be=Xe(N,fo)?.address||"";react.useEffect(()=>{async function y(){try{U(!0),Qe(null);let P=await qt(t);if(p(P.data),P.data.length>0){let M=P.data[0];if(w(M.symbol),M.chains.length>0){let O=M.chains[0];T(It(O.chain_id,O.chain_type));}}}catch(P){console.error("Error fetching supported tokens:",P),Qe("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:P});}finally{U(false);}}y();},[t,h]),react.useEffect(()=>{async function y(){try{W(!0),Qe(null);let P=await Je({user_id:e,recipient_address:o,destination_chain_type:r,destination_chain_id:l,destination_token_address:i},t);q(P.data);}catch(P){console.error("Error fetching wallets:",P),Qe("Failed to load wallets"),h?.({message:"Failed to load wallets",error:P});}finally{W(false);}}y();},[e,o,r,l,i,t,h]),react.useEffect(()=>{if(!e||!Ee)return;let y=setInterval(async()=>{try{let P=await et(e,t),M=null;for(let O of P.data){let Te=O.created_at?new Date(O.created_at):null;if(!Te||Te<=Ee)continue;let Se=Be.get(O.id);if(!Se){M=O;break}if(["pending","waiting","delayed"].includes(Se)&&O.status==="succeeded"){M=O;break}}if(M){let O=M;gt(Te=>{let Se=Te.findIndex(Ct=>Ct.id===O.id);if(Se>=0){let Ct=[...Te];return Ct[Se]=O,Ct}else return [...Te,O]}),$e(Te=>{let Se=new Map(Te);return Se.set(O.id,O.status),Se}),Ut(O),Ft(!0),O.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:O.id}),a?.([...qe,O]);}}catch(P){console.error("Error polling executions:",P),h?.({message:"Failed to check deposit status",error:P});}},5e3);return ()=>clearInterval(y)},[e,t,Ee,Be,qe,a,m,h]),react.useEffect(()=>{if(!b.length)return;let y=b.find(M=>M.symbol===V);if(!y||y.chains.length===0)return;if(!y.chains.some(M=>It(M.chain_id,M.chain_type)===c)){let M=y.chains[0];T(It(M.chain_id,M.chain_type));}},[V,b,c]);let Ye=b.find(y=>y.symbol===V),Ot=Ye?.chains||[],he=Ot.find(y=>It(y.chain_id,y.chain_type)===c),Ke=async()=>{if(be)try{reactNative.Clipboard.setString(be),te(!0),setTimeout(()=>te(!1),2e3);}catch(y){console.error("Failed to copy:",y);}},f=he?.estimated_price_impact_percent??0,R=he?.max_slippage_percent??.25,re=he?.minimum_deposit_amount_usd??3;if($)return jsxRuntime.jsxs(reactNative.View,{style:s.loadingContainer,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:n.primary}),jsxRuntime.jsx(reactNative.Text,{style:[s.loadingText,{color:n.foregroundMuted}],children:"Loading currencies..."})]});if(zt&&b.length===0)return jsxRuntime.jsxs(reactNative.View,{style:s.errorContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[s.errorText,{color:n.error}],children:zt}),jsxRuntime.jsx(reactNative.Text,{style:[s.errorHint,{color:n.foregroundMuted}],children:"Please check your network connection and try again."})]});let yt=()=>jsxRuntime.jsxs(Y,{visible:Ne,onClose:()=>Le(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[s.sheetHeader,{borderBottomColor:n.border}],children:[jsxRuntime.jsx(reactNative.View,{style:s.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[s.sheetTitle,{color:n.foreground}],children:"Select Token"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Le(false),style:s.sheetCloseButton,children:jsxRuntime.jsx(rt,{size:20,color:n.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:s.sheetList,showsVerticalScrollIndicator:false,children:b.map(y=>jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{w(y.symbol),Le(false);},style:[s.sheetItem,{backgroundColor:V===y.symbol?n.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(y,"png"))},style:s.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:s.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[s.sheetItemTitle,{color:n.foreground}],children:y.symbol}),jsxRuntime.jsxs(reactNative.Text,{style:[s.sheetItemSubtitle,{color:n.foregroundMuted}],children:[y.chains.length," network",y.chains.length!==1?"s":""," available"]})]}),V===y.symbol&&jsxRuntime.jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},y.symbol))})]}),jt=()=>jsxRuntime.jsxs(Y,{visible:ft,onClose:()=>fe(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[s.sheetHeader,{borderBottomColor:n.border}],children:[jsxRuntime.jsx(reactNative.View,{style:s.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[s.sheetTitle,{color:n.foreground}],children:"Select Network"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>fe(false),style:s.sheetCloseButton,children:jsxRuntime.jsx(rt,{size:20,color:n.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:s.sheetList,showsVerticalScrollIndicator:false,children:Ot.map(y=>{let P=It(y.chain_id,y.chain_type),M=c===P;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{T(P),fe(false);},style:[s.sheetItem,{backgroundColor:M?n.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(y,"png"))},style:s.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:s.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[s.sheetItemTitle,{color:n.foreground}],children:y.chain_name}),jsxRuntime.jsxs(reactNative.Text,{style:[s.sheetItemSubtitle,{color:n.foregroundMuted}],children:["Min deposit: $",y.minimum_deposit_amount_usd]})]}),M&&jsxRuntime.jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},P)})})]});return jsxRuntime.jsxs(reactNative.View,{style:s.container,children:[jsxRuntime.jsxs(reactNative.View,{style:s.selectorSection,children:[jsxRuntime.jsx(reactNative.Text,{style:[s.selectorLabel,{color:n.foregroundMuted}],children:"Token"}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>Le(true),style:[s.selector,{backgroundColor:n.card}],children:[Ye&&jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(Ye,"png"))},style:s.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[s.selectorText,{color:n.foreground}],children:V}),jsxRuntime.jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsxs(reactNative.View,{style:s.selectorSection,children:[jsxRuntime.jsxs(reactNative.Text,{style:[s.selectorLabel,{color:n.foregroundMuted}],children:["Network"," ",jsxRuntime.jsxs(reactNative.Text,{style:s.minDeposit,children:["($",re," min)"]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>fe(true),style:[s.selector,{backgroundColor:n.card}],children:[he&&jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(he,"png"))},style:s.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[s.selectorText,{color:n.foreground}],numberOfLines:1,children:he?.chain_name||"Select network"}),jsxRuntime.jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:s.qrContainer,children:jsxRuntime.jsx(reactNative.View,{style:[s.qrWrapper,{backgroundColor:n.background,borderColor:n.border}],children:B?jsxRuntime.jsxs(reactNative.View,{style:s.qrLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:n.primary}),jsxRuntime.jsx(reactNative.Text,{style:[s.loadingText,{color:n.foregroundMuted}],children:"Loading..."})]}):be?jsxRuntime.jsx(Tt,{value:be,size:160,logoUri:L(K(he,"png")||le("/icons/networks/png/ethereum.png")),logoSize:40}):jsxRuntime.jsx(reactNative.View,{style:s.qrLoading,children:jsxRuntime.jsx(reactNative.Text,{style:[s.errorText,{color:n.error}],children:"No address available"})})})}),jsxRuntime.jsxs(reactNative.View,{style:s.addressSection,children:[jsxRuntime.jsxs(reactNative.View,{style:s.addressHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[s.addressLabel,{color:n.foregroundMuted}],children:"Deposit Address"}),G&&jsxRuntime.jsxs(reactNative.View,{style:s.copiedIndicator,children:[jsxRuntime.jsx(ie,{size:14,color:n.success,strokeWidth:2}),jsxRuntime.jsx(reactNative.Text,{style:[s.copiedText,{color:n.success}],children:"Copied"})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:Ke,disabled:!be||B,activeOpacity:.7,style:[s.addressBox,{backgroundColor:n.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[s.addressText,{color:n.foreground}],numberOfLines:2,children:B?"Loading...":be||"No address available"})})]}),jsxRuntime.jsxs(reactNative.View,{style:[s.detailsCard,{backgroundColor:n.card}],children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>E(!oe),style:s.detailsHeader,children:[jsxRuntime.jsxs(reactNative.View,{style:s.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Zo,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Price impact:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:n.foreground},children:[f.toFixed(2),"%"]})]})]}),jsxRuntime.jsx(reactNative.View,{style:s.chevronContainer,children:oe?jsxRuntime.jsx(Zt,{size:16,color:n.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})})]}),oe&&jsxRuntime.jsxs(reactNative.View,{style:s.detailsContent,children:[jsxRuntime.jsxs(reactNative.View,{style:s.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Jo,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Max slippage:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:n.foreground},children:["Auto \u2022 ",R.toFixed(2),"%"]})]})]}),jsxRuntime.jsxs(reactNative.View,{style:s.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(kt,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Processing time:"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:n.foreground},children:"< 1 min"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:s.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Xo,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Need help?"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:n.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsxRuntime.jsx(reactNative.View,{style:s.spacer}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:s.termsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[s.termsText,{color:n.foregroundMuted}],children:"Terms apply"})}),yt(),jt(),ke&&jsxRuntime.jsx(_t,{visible:We,status:ke.status,tokenIconUrl:ke.destination_token_metadata?.icon_urls?.find(y=>y.format==="png")?.url||ke.destination_token_metadata?.icon_url||K(Ye,"png"),explorerUrl:ke.explorer_url,completionExplorerUrl:ke.destination_explorer_url,onClose:()=>Ft(false)})]})}var s=reactNative.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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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,flex:1},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center",paddingVertical:16},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingBottom:12},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"600",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}});function Rt({currency:e,isSelected:t,onSelect:o}){let{colors:r}=_();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Oe.container,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Oe.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Oe.iconContainer,{backgroundColor:r.background}],children:jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(e,"png"))},style:Oe.icon})}),jsxRuntime.jsxs(reactNative.View,{style:Oe.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Oe.name,{color:r.foreground}],children:e.name}),jsxRuntime.jsx(reactNative.Text,{style:[Oe.code,{color:r.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsxRuntime.jsx(ie,{size:16,color:r.foreground,strokeWidth:2})]})}var Oe=reactNative.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 pt({title:e,currencies:t,selectedCurrency:o,onSelect:r}){let{colors:l}=_();return t.length===0?null:jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.View,{style:pr.headerContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[pr.title,{color:l.foregroundMuted}],children:e})}),t.map(i=>jsxRuntime.jsx(Rt,{currency:i,isSelected:o.toLowerCase()===i.currency_code.toLowerCase(),onSelect:r},i.currency_code))]})}var pr=reactNative.StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Pt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:r,selectedCurrency:l,onSelectCurrency:i}){let{colors:a}=_(),[m,h]=react.useState(""),n=r.map(B=>o.find(W=>W.currency_code.toLowerCase()===B.toLowerCase())).filter(B=>B!==void 0),V=o.filter(B=>!r.includes(B.currency_code.toLowerCase())),w=B=>{if(!m)return B;let W=m.toLowerCase();return B.filter(b=>b.name.toLowerCase().includes(W)||b.currency_code.toLowerCase().includes(W))},c=w(n),T=w(V),N=B=>{i(B),t(false),h("");},q=()=>{t(false),h("");};return jsxRuntime.jsxs(Y,{visible:e,onClose:q,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:"Currency",showBack:false,onClose:q}),jsxRuntime.jsx(reactNative.View,{style:je.searchContainer,children:jsxRuntime.jsx(reactNative.TextInput,{style:[je.searchInput,{backgroundColor:a.card,color:a.foreground}],value:m,onChangeText:h,placeholder:"Search",placeholderTextColor:a.foregroundMuted})}),jsxRuntime.jsx(reactNative.ScrollView,{style:je.listContainer,showsVerticalScrollIndicator:false,children:jsxRuntime.jsxs(reactNative.View,{style:je.listContent,children:[jsxRuntime.jsx(pt,{title:"Popular currencies",currencies:c,selectedCurrency:l,onSelect:N}),c.length>0&&T.length>0&&jsxRuntime.jsx(reactNative.View,{style:je.sectionSpacer}),jsxRuntime.jsx(pt,{title:"All currencies",currencies:T,selectedCurrency:l,onSelect:N}),c.length===0&&T.length===0&&jsxRuntime.jsx(reactNative.View,{style:je.noResultsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[je.noResultsText,{color:a.foregroundMuted}],children:"No currencies found"})})]})})]})}var je=reactNative.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}});var Tn=[100,500,1e3];function mr(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 Lt({userId:e,publishableKey:t,view:o,onViewChange:r,maxAmountUsd:l=5e4,destinationTokenSymbol:i="USDC",recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onDepositSuccess:V,onDepositError:w}){let{colors:c}=_(),[T,N]=react.useState("500.00"),[q,B]=react.useState("usd"),[W,b]=react.useState([]),[p,$]=react.useState(false),[U,G]=react.useState(null),[te,oe]=react.useState("amount"),[E,Ne]=react.useState(null),[Le,ft]=react.useState([]),[fe,qe]=react.useState(true),[gt,Be]=react.useState(60),[$e,Ee]=react.useState([]),[zt,Qe]=react.useState([]),[We,Ft]=react.useState(null),[ke,Ut]=react.useState(false),[mt,Ge]=react.useState(false),ht=o??te,po=$e.find(f=>f.currency_code.toLowerCase()===q.toLowerCase()),fo=react.useCallback(f=>{oe(f),f==="quotes"?r?.(f,W.length):r?.(f);},[W.length,r]);react.useEffect(()=>{async function f(){try{let R=await Je({user_id:e,recipient_address:a,destination_chain_type:m,destination_chain_id:h,destination_token_address:n},t);ft(R.data);}catch(R){console.error("Error fetching wallets:",R),G("Failed to load wallet addresses");}finally{qe(false);}}f();},[e,a,m,h,n,t]),react.useEffect(()=>{async function f(){try{let R=await Gt(t);Ee(R.data),Qe(R.preferred||[]);}catch(R){console.error("Error fetching fiat currencies:",R);}}f();},[t]),react.useEffect(()=>{let f=parseFloat(T);if(isNaN(f)||f<=0){b([]);return}if(q.toLowerCase()==="usd"&&f>l){b([]),G(`Maximum amount is ${mr("usd")}${l.toLocaleString()}`);return}let R=setTimeout(()=>{go(f);},500);return ()=>clearTimeout(R)},[T,q,l,t]);let go=async f=>{$(true),G(null);try{let R={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:f.toString(),source_currency_code:q.toLowerCase()},re=await $t(R,t);if(b(re.data),re.data.length>0){let yt=re.data.reduce((jt,y)=>y.destination_amount>jt.destination_amount?y:jt);Ne(yt);}Be(60);}catch(R){console.error("Failed to fetch quotes:",R),G("Failed to fetch quotes. Please try again."),b([]);}finally{$(false);}};react.useEffect(()=>{if(W.length===0)return;let f=setInterval(()=>{Be(R=>{if(R<=1){let re=parseFloat(T);return !isNaN(re)&&re>0&&go(re),60}return R-1});},1e3);return ()=>clearInterval(f)},[W.length,T]);let be=f=>{(/^\d*\.?\d{0,2}$/.test(f)||f==="")&&N(f);},Ye=f=>{N(f.toFixed(2));},Ot=()=>E?E.destination_amount.toFixed(2):"0.00",he=async()=>{if(E)try{let f=Xe(Le,"ethereum");if(!f?.address){G("Wallet address not available");return}let R={service_provider:E.service_provider,country_code:E.country_code.toUpperCase(),destination_currency_code:E.destination_currency_code,source_currency_code:E.source_currency_code,wallet_address:f.address,source_amount:T},re=await Qt(R,t);Ft({provider:E,sourceCurrency:q,sourceAmount:T}),reactNative.Linking.openURL(re.widget_url),fo("onramp");}catch(f){console.error("Failed to create session:",f),G("Failed to start payment flow"),w?.({message:"Failed to start payment flow",error:f});}},Ke=mr(q);return ht==="amount"?jsxRuntime.jsxs(reactNative.View,{style:u.container,children:[jsxRuntime.jsx(reactNative.View,{style:u.currencySelector,children:jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>Ut(true),style:[u.currencyButton,{backgroundColor:c.card}],children:[po&&jsxRuntime.jsx(reactNative.Image,{source:{uri:L(K(po,"png"))},style:u.currencyIcon}),jsxRuntime.jsx(reactNative.Text,{style:[u.currencyText,{color:c.foreground}],children:q.toUpperCase()}),jsxRuntime.jsx(me,{size:16,color:c.foregroundMuted,strokeWidth:2})]})}),jsxRuntime.jsx(Pt,{open:ke,onOpenChange:Ut,currencies:$e,preferredCurrencyCodes:zt,selectedCurrency:q,onSelectCurrency:f=>{B(f.toLowerCase());}}),jsxRuntime.jsxs(reactNative.View,{style:u.amountContainer,children:[jsxRuntime.jsxs(reactNative.View,{style:u.amountInputRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[u.currencySymbol,{color:c.foreground}],children:Ke}),jsxRuntime.jsx(reactNative.TextInput,{style:[u.amountInput,{color:c.foreground}],value:T,onChangeText:be,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:c.foregroundMuted})]}),p?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:c.primary}):jsxRuntime.jsxs(reactNative.Text,{style:[u.usdcPreview,{color:c.foregroundMuted}],children:["\u2248 ",Ot()," ",i]})]}),jsxRuntime.jsx(reactNative.View,{style:u.quickAmounts,children:Tn.map(f=>jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Ye(f),style:[u.quickAmountButton,{backgroundColor:c.card},parseFloat(T)===f&&{borderColor:c.primary,borderWidth:2}],children:jsxRuntime.jsxs(reactNative.Text,{style:[u.quickAmountText,{color:c.foreground}],children:[Ke,f.toLocaleString()]})},f))}),jsxRuntime.jsxs(reactNative.View,{style:u.providerSection,children:[jsxRuntime.jsxs(reactNative.View,{style:u.providerHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[u.providerLabel,{color:c.foreground}],children:"Provider"}),W.length>0&&!p&&jsxRuntime.jsxs(reactNative.Text,{style:[u.refreshText,{color:c.foregroundMuted}],children:["Refreshing in ",gt,"s"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Ge(true),disabled:p||W.length===0,style:[u.providerButton,{backgroundColor:c.card},(p||W.length===0)&&u.disabled],children:p?jsxRuntime.jsxs(reactNative.View,{style:u.providerLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:c.foregroundMuted}),jsxRuntime.jsx(reactNative.Text,{style:[u.loadingText,{color:c.foregroundMuted}],children:"Finding best rates..."})]}):E?jsxRuntime.jsxs(reactNative.View,{style:u.providerContent,children:[jsxRuntime.jsxs(reactNative.View,{style:u.providerInfo,children:[jsxRuntime.jsx(reactNative.Text,{style:[u.autoPickedText,{color:c.foregroundMuted}],children:"Auto-picked for you"}),jsxRuntime.jsxs(reactNative.View,{style:u.providerRow,children:[jsxRuntime.jsx(ae,{uri:L(E.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[u.providerName,{color:c.foreground}],children:E.service_provider_display_name}),jsxRuntime.jsxs(reactNative.Text,{style:[u.bestPriceText,{color:c.success}],children:["Best price \u2022 ",E.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsxRuntime.jsx(nt,{size:20,color:c.foregroundMuted,strokeWidth:2})]}):jsxRuntime.jsx(reactNative.Text,{style:[u.noProviderText,{color:c.foregroundMuted}],children:parseFloat(T)>0?"No providers available":"Enter an amount to see providers"})}),U&&jsxRuntime.jsx(reactNative.Text,{style:[u.errorText,{color:c.error}],children:U})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:he,disabled:p||fe||!E||parseFloat(T)<=0,style:[u.continueButton,{backgroundColor:c.primary},(p||fe||!E)&&u.disabledButton],children:jsxRuntime.jsx(reactNative.Text,{style:u.continueButtonText,children:fe?"Loading...":`Buy ${i}`})}),jsxRuntime.jsxs(Y,{visible:mt,onClose:()=>Ge(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:"Select Provider",showBack:false,onClose:()=>Ge(false),badge:W.length>0?{count:W.length}:void 0}),jsxRuntime.jsx(reactNative.ScrollView,{style:u.providerModalList,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(reactNative.View,{style:u.quotesList,children:[...W].sort((f,R)=>R.destination_amount-f.destination_amount).map((f,R)=>{let re=E?.service_provider===f.service_provider,yt=R===0;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{Ne(f),Ge(false);},style:[u.quoteItem,{backgroundColor:c.card},re&&{borderColor:c.primary,borderWidth:2}],children:[jsxRuntime.jsxs(reactNative.View,{style:u.quoteLeft,children:[jsxRuntime.jsx(ae,{uri:L(f.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[u.quoteName,{color:c.foreground}],children:f.service_provider_display_name}),yt&&jsxRuntime.jsx(reactNative.Text,{style:[u.bestPriceLabel,{color:c.success}],children:"\u2713 Best price"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:u.quoteRight,children:[jsxRuntime.jsxs(reactNative.Text,{style:[u.quoteAmount,{color:c.foreground}],children:[f.destination_amount.toFixed(2)," USDC"]}),jsxRuntime.jsxs(reactNative.Text,{style:[u.quoteSource,{color:c.foregroundMuted}],children:["Fee: ",Ke,f.total_fee.toFixed(2)]})]})]},f.service_provider)})})})]})]}):ht==="onramp"&&We?jsxRuntime.jsxs(reactNative.View,{style:[u.container,u.onrampContainer],children:[jsxRuntime.jsx(ae,{uri:L(We.provider.icon_url),width:48,height:48,borderRadius:12}),jsxRuntime.jsxs(reactNative.Text,{style:[u.onrampTitle,{color:c.foreground}],children:["Complete on ",We.provider.service_provider_display_name]}),jsxRuntime.jsx(reactNative.Text,{style:[u.onrampSubtitle,{color:c.foregroundMuted}],children:"You can close this modal. Your deposit will be processed automatically."}),jsxRuntime.jsxs(reactNative.View,{style:[u.flowDiagram,{backgroundColor:c.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:u.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:le(`/icons/currencies/png/${We.sourceCurrency.toLowerCase()}.png`)},style:u.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[u.flowLabel,{color:c.foregroundMuted}],children:"You pay"}),jsxRuntime.jsxs(reactNative.Text,{style:[u.flowValue,{color:c.foreground}],children:[Ke,We.sourceAmount]})]}),jsxRuntime.jsx(nt,{size:20,color:c.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:u.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:le("/icons/tokens/png/usdc.png")},style:u.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[u.flowLabel,{color:c.foregroundMuted}],children:"You get"}),jsxRuntime.jsx(reactNative.Text,{style:[u.flowValue,{color:c.foreground}],children:i})]})]})]}):null}var u=reactNative.StyleSheet.create({container:{padding: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"},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:8},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:16,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:{alignItems:"center",paddingTop:24},onrampIcon:{width:64,height:64,borderRadius:16,marginBottom:16},onrampTitle:{fontSize:20,fontWeight:"500",textAlign:"center",marginBottom:8},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",padding:16,borderRadius:12,width:"100%"},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 vn(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 Dn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Bt({execution:e,onPress:t}){let {colors:o}=_(),r=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let i=L(K(e.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),a=r?"Deposit Processing":"Deposit Completed",m=vn(e.created_at||new Date().toISOString()),h=Dn(e.source_amount_usd);return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:t,activeOpacity:.7,style:[we.container,{backgroundColor:o.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:we.iconContainer,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:i},style:we.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[we.statusBadge,{backgroundColor:r?"#EAB308":"#22C55E"}],children:r?jsxRuntime.jsx(Jt,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsxRuntime.jsx(ie,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxRuntime.jsxs(reactNative.View,{style:we.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[we.title,{color:o.foreground}],children:a}),jsxRuntime.jsx(reactNative.Text,{style:[we.dateTime,{color:o.foregroundMuted}],children:m})]}),jsxRuntime.jsxs(reactNative.View,{style:we.rightContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[we.amount,{color:o.foreground}],children:h}),jsxRuntime.jsx(nt,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var we=reactNative.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,borderColor:"#1C1C1E"},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:Ln}=reactNative.Dimensions.get("window");function Cr(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 xr(e,t=6){try{return e?(Number(e)/Math.pow(10,t)).toFixed(2):"0.00"}catch{return "0.00"}}function Bn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function kr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function En(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 Et({visible:e,onClose:t,executions:o,userId:r,publishableKey:l}){let{colors:i}=_(),[a,m]=react.useState(o),[h,n]=react.useState(false),[V,w]=react.useState(null),[c,T]=react.useState(false);react.useEffect(()=>{if(!e||!r)return;let p=async()=>{n(true);try{let G=[...(await et(r,l)).data].sort((te,oe)=>{let E=te.created_at?new Date(te.created_at).getTime():0;return (oe.created_at?new Date(oe.created_at).getTime():0)-E});m(G);}catch(U){console.error("Failed to fetch executions:",U),m(o);}finally{n(false);}};p();let $=setInterval(p,1e4);return ()=>clearInterval($)},[e,r,l,o]),react.useEffect(()=>{o.length>0&&m(p=>{let $=new Set(p.map(G=>G.id)),U=o.filter(G=>!$.has(G.id));return U.length>0?[...U,...p]:p});},[o]),react.useEffect(()=>{e||w(null);},[e]);let N=p=>{w(p);},q=()=>{w(null),T(false);},B=()=>{w(null),t();};return jsxRuntime.jsxs(Y,{visible:e,onClose:B,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:V?"Deposit Details":"Deposit Tracker",onClose:B,showClose:!V,showBack:!!V,onBack:q}),V?(()=>{if(!V)return null;let p=V,$=p.status==="pending"||p.status==="waiting"||p.status==="delayed",U=p.status==="succeeded",G=L(K(p.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),te=p.provider_metadata?.details,oe=te?.currencyIn,E=te?.currencyOut;oe?.currency?.symbol||"USDC";E?.currency?.symbol||"USDC";let ft=xr(p.source_amount_base_unit),fe=xr(p.destination_amount_base_unit),qe=Bn(p.source_amount_usd),gt=Cr(p.source_chain_type,p.source_chain_id),Be=Cr(p.destination_chain_type,p.destination_chain_id),$e=()=>{p.explorer_url&&reactNative.Linking.openURL(p.explorer_url);},Ee=()=>{p.destination_explorer_url&&reactNative.Linking.openURL(p.destination_explorer_url);};return jsxRuntime.jsxs(reactNative.ScrollView,{style:g.scrollContainer,contentContainerStyle:g.detailsContent,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:g.iconSection,children:[jsxRuntime.jsxs(reactNative.View,{style:g.iconWrapper,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:G},style:g.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[g.statusBadge,{backgroundColor:$?"#EAB308":"#22C55E"}],children:$?jsxRuntime.jsx(me,{size:14,color:"#FFFFFF",strokeWidth:2}):jsxRuntime.jsx(ie,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:g.statusRow,children:[jsxRuntime.jsx(reactNative.View,{style:[g.statusDot,{backgroundColor:$?"#EAB308":"#22C55E"}]}),jsxRuntime.jsx(reactNative.Text,{style:[g.statusText,{color:i.foreground}],children:$?"Processing":"Completed"})]}),jsxRuntime.jsx(reactNative.Text,{style:[g.dateText,{color:i.foregroundMuted}],children:En(p.created_at||new Date().toISOString())})]}),jsxRuntime.jsxs(reactNative.View,{style:[g.card,{backgroundColor:i.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Amount Sent"}),jsxRuntime.jsxs(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:[ft," ",kr(p.source_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Amount Received"}),jsxRuntime.jsxs(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:[fe," ",kr(p.destination_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"USD Value"}),jsxRuntime.jsx(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:qe})]}),jsxRuntime.jsx(reactNative.View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Source Network"}),jsxRuntime.jsx(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:gt})]}),jsxRuntime.jsx(reactNative.View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Destination Network"}),jsxRuntime.jsx(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:Be})]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>T(!c),style:g.toggleButton,activeOpacity:.7,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.toggleText,{color:i.foregroundMuted}],children:c?"See less":"See more details"}),c?jsxRuntime.jsx(Zt,{size:14,color:i.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(me,{size:14,color:i.foregroundMuted,strokeWidth:2})]}),c&&jsxRuntime.jsxs(reactNative.View,{style:[g.card,{backgroundColor:i.card}],children:[p.explorer_url&&jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:$e,style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Deposit Tx"}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:wr(p.transaction_hash)}),jsxRuntime.jsx(Kt,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:[g.cardDivider,{backgroundColor:i.border}]})]}),p.destination_explorer_url&&U&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:Ee,style:g.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Completion Tx"}),jsxRuntime.jsxs(reactNative.View,{style:g.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.cardValue,{color:i.foreground}],children:wr(p.destination_transaction_hashes[0])}),jsxRuntime.jsx(Kt,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsxRuntime.jsx(reactNative.ScrollView,{style:g.scrollContainer,contentContainerStyle:g.scrollContent,showsVerticalScrollIndicator:false,children:a.length===0?jsxRuntime.jsxs(reactNative.View,{style:g.emptyContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[g.emptyText,{color:i.foregroundMuted}],children:"No deposits yet"}),jsxRuntime.jsx(reactNative.Text,{style:[g.emptySubtext,{color:i.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsxRuntime.jsx(reactNative.View,{style:g.executionsList,children:a.map(p=>jsxRuntime.jsx(Bt,{execution:p,onPress:()=>N(p)},p.id))})})]})}var g=reactNative.StyleSheet.create({scrollContainer:{maxHeight:Ln*.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,borderColor:"#1C1C1E"},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}});var He={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 zn({visible:e,onClose:t,userId:o,publishableKey:r,modalTitle:l="Deposit",destinationTokenSymbol:i,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,hideDepositTracker:V=false,onDepositSuccess:w,onDepositError:c}){let[T,N]=react.useState([]),[q,B]=react.useState(false),[W,b]=react.useState(false),[p,$]=react.useState(false),[U,G]=react.useState(null);react.useEffect(()=>{e&&!U&&Yt(r).then(G).catch(console.error);},[e,U,r]);let te=()=>{t();},oe=T.filter(E=>E.status==="pending"||E.status==="waiting").length;return jsxRuntime.jsxs(Y,{visible:e,onClose:te,closeOnBackdropPress:false,showHandle:false,children:[jsxRuntime.jsx(se,{title:l,showBack:false,onClose:te}),jsxRuntime.jsxs(reactNative.View,{style:At.optionsContainer,children:[jsxRuntime.jsx(at,{onPress:()=>b(true),title:He.transferCrypto.title,subtitle:He.transferCrypto.subtitle,featuredTokens:U?.transfer_crypto?.networks}),jsxRuntime.jsx(ct,{onPress:()=>$(true),title:He.depositWithCard.title,subtitle:He.depositWithCard.subtitle,paymentNetworks:U?.payment_networks?.networks}),!V&&jsxRuntime.jsx(dt,{onPress:()=>B(true),title:He.depositTracker.title,subtitle:He.depositTracker.subtitle,badge:oe>0?oe:void 0})]}),jsxRuntime.jsx(Et,{visible:q,onClose:()=>B(false),executions:T,userId:o,publishableKey:r}),jsxRuntime.jsxs(Y,{visible:W,onClose:()=>b(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsxRuntime.jsx(se,{title:He.transferCrypto.title,showBack:false,onClose:()=>b(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:At.transferScrollContainer,contentContainerStyle:At.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(vt,{userId:o,publishableKey:r,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onExecutionsChange:N,onDepositSuccess:w,onDepositError:c})})]}),jsxRuntime.jsxs(Y,{visible:p,onClose:()=>$(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsxRuntime.jsx(se,{title:"Add Funds",showBack:false,onClose:()=>$(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:At.transferScrollContainer,contentContainerStyle:At.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(Lt,{userId:o,publishableKey:r,destinationTokenSymbol:i,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onDepositSuccess:w,onDepositError:c})})]})]})}function Mt({theme:e="auto",...t}){return jsxRuntime.jsx(Ze,{mode:e,children:jsxRuntime.jsx(zn,{...t})})}var At=reactNative.StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24}});reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});function Eo({uri:e,size:t=24,style:o,borderRadius:r}){return jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:[jn.icon,{width:t,height:t,borderRadius:r??t/2},o],resizeMode:"contain"})}var jn=reactNative.StyleSheet.create({icon:{backgroundColor:"transparent"}});var Kn=()=>new reactQuery.QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),Sr=react.createContext(null);function Zn({children:e,publishableKey:t,config:o}){let[r]=react.useState(()=>Kn()),[l,i]=react.useState(false),[a,m]=react.useState(null),h=reactNative.useColorScheme(),n=react.useRef(false);n.current||(xt({publishableKey:t}),n.current=true);let V=react.useMemo(()=>{let b=o?.appearance||"dark";return b==="auto"?h==="dark"?"dark":"light":b},[o?.appearance,h]);react.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.'),xt({publishableKey:t});},[t]);let w=react.useRef(null),c=react.useRef(null),T=react.useCallback(b=>{console.log("[UnifoldProvider] beginDeposit called with:",b),c.current&&(clearTimeout(c.current),c.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let p=new Promise(($,U)=>{w.current={resolve:$,reject:U};});return m(b),i(true),p},[]),N=react.useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),i(false),c.current=setTimeout(()=>{m(null),c.current=null;},200);},[]),q=react.useCallback(b=>{console.log("[UnifoldProvider] Deposit success:",b),a?.onSuccess&&a.onSuccess(b),w.current&&(w.current.resolve(b),w.current=null);},[a]),B=react.useCallback(b=>{console.error("[UnifoldProvider] Deposit error:",b),a?.onError&&a.onError(b),w.current&&(w.current.reject(b),w.current=null);},[a]),W=react.useMemo(()=>({publishableKey:t,beginDeposit:T,closeDeposit:N}),[t,T,N]);return jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:r,children:jsxRuntime.jsx(Sr.Provider,{value:W,children:jsxRuntime.jsxs(Ze,{mode:V,children:[e,a&&jsxRuntime.jsx(Mt,{visible:l,onClose:N,userId:a.userId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:a.destinationTokenSymbol,recipientAddress:a.recipientAddress,destinationChainId:a.destinationChainId,destinationTokenAddress:a.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:q,onDepositError:B,theme:V})]})})})}function Jn(){let e=react.useContext(Sr);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}exports.BottomSheet=Y;exports.BuyWithCard=Lt;exports.CurrencyListItem=Rt;exports.CurrencyListSection=pt;exports.CurrencyModal=Pt;exports.DepositExecutionItem=Bt;exports.DepositHeader=se;exports.DepositModal=Mt;exports.DepositStatusSheet=_t;exports.DepositTrackerButton=dt;exports.DepositWithCardButton=ct;exports.DepositsModal=Et;exports.ExecutionStatus=Me;exports.Icon=Eo;exports.QRCode=Tt;exports.RemoteIcon=ae;exports.SOLANA_USDC_ADDRESS=Ho;exports.ThemeProvider=Ze;exports.TransferCrypto=vt;exports.TransferCryptoButton=at;exports.UnifoldProvider=Zn;exports.createDepositAddress=mo;exports.createEOA=Je;exports.createMeldSession=Qt;exports.getApiBaseUrl=Oo;exports.getChainName=$o;exports.getFiatCurrencies=Gt;exports.getIconUrl=le;exports.getIconUrlWithCdn=jo;exports.getMeldQuotes=$t;exports.getPreferredIcon=K;exports.getPreferredIconUrl=No;exports.getProjectConfig=Yt;exports.getSupportedDepositTokens=qt;exports.getTokenChains=qo;exports.getWalletByChainType=Xe;exports.normalizeIconUrl=L;exports.queryExecutions=et;exports.setApiConfig=xt;exports.setDevApiUrl=Uo;exports.useTheme=_;exports.useUnifold=Jn;
1
+ 'use strict';var react=require('react'),reactNative=require('react-native'),reactQuery=require('@tanstack/react-query'),jsxRuntime=require('react/jsx-runtime'),ee=require('react-native-svg'),Jr=require('react-native-qrcode-svg');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ee__default=/*#__PURE__*/_interopDefault(ee);var Jr__default=/*#__PURE__*/_interopDefault(Jr);var zo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Pr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Fo=react.createContext({colors:zo,isDark:false,mode:"auto"});function ot({children:e,mode:t="auto"}){let o=reactNative.useColorScheme(),r=react.useMemo(()=>{let a;return t==="auto"?a=o==="dark":a=t==="dark",{colors:a?Pr:zo,isDark:a,mode:t}},[t,o]);return jsxRuntime.jsx(Fo.Provider,{value:r,children:e})}function _(){let e=react.useContext(Fo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Lr="https://api.unifold.io",Qt,Ie="pk_test_123",$t={};function ne(){return typeof __DEV__<"u"&&__DEV__&&Qt?Qt:Lr}function Tt(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.'),Ie=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Qt=e.baseUrl),e.defaultConfig&&($t=e.defaultConfig);}function Uo(e){typeof __DEV__<"u"&&__DEV__?(Qt=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oo(){return ne()}function Fe(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 le(e){let t=e.startsWith("/")?e:`/${e}`;return `${ne()}/api/public${t}`}function Ho(e,t){if(!t)return le(e);let o=e.startsWith("/")?e:`/${e}`;return `${t.endsWith("/")?t.slice(0,-1):t}/api/public${o}`}function W(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ne()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ne()}${e}`:`${ne()}/api/public${e}`:""}async function Co(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||$t.destinationChainId||"8453",destination_token_address:e?.destination_token_address||$t.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||$t.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},r=t||Ie;Fe(r);let a=await fetch(`${ne()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return a.json()}async function rt(e,t){return Co(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function nt(e,t){return e.find(o=>o.chain_type===t)}var Ue=(c=>(c.DELAYED="delayed",c.FAILED="failed",c.PENDING="pending",c.REFUNDED="refunded",c.SUCCEEDED="succeeded",c.WAITING="waiting",c))(Ue||{}),jo="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";async function it(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/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(!r.ok)throw new Error(`Failed to query executions: ${r.statusText}`);return r.json()}function J(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(r=>r.format===t);return o?o.url:e.icon_url}async function Gt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function Yt(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to fetch Meld quotes: ${r.statusText}`);return r.json()}async function Kt(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to create Meld session: ${r.statusText}`);return r.json()}async function Jt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/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 No(e,t="png"){if(!e||e.length===0)return;let o=e.find(r=>r.format===t);return o?o.url:e[0]?.url}async function Xt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/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 qo(){let e=await fetch(`${ne()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function $o(e,t,o){let r=e.find(i=>i.chain_id===o);if(r)return r.chain_name;let a=e.find(i=>i.chain_type===t);return a?a.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}var{height:St}=reactNative.Dimensions.get("window");function K({visible:e,onClose:t,children:o,closeOnBackdropPress:r=true,showHandle:a=true,heightPercent:i}){let{colors:c}=_(),m=react.useRef(new reactNative.Animated.Value(St)).current,d=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{e?(m.setValue(St),d.setValue(0),reactNative.Animated.parallel([reactNative.Animated.spring(m,{toValue:0,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(d,{toValue:.5,duration:200,useNativeDriver:true})]).start()):reactNative.Animated.parallel([reactNative.Animated.spring(m,{toValue:St,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(d,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,m,d]);let n=()=>{r&&t();};return jsxRuntime.jsx(reactNative.Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxRuntime.jsxs(reactNative.View,{style:Oe.container,children:[jsxRuntime.jsx(reactNative.TouchableWithoutFeedback,{onPress:n,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[Oe.backdrop,{backgroundColor:"#000000",opacity:d}]})}),jsxRuntime.jsxs(reactNative.Animated.View,{style:[Oe.sheet,{backgroundColor:c.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:m}],...i&&{height:St*i}}],children:[a&&jsxRuntime.jsx(reactNative.View,{style:Oe.handleContainer,children:jsxRuntime.jsx(reactNative.View,{style:[Oe.handle,{backgroundColor:c.border}]})}),jsxRuntime.jsx(reactNative.View,{style:[Oe.content,i&&Oe.contentFlex],children:o})]})]})})}var Oe=reactNative.StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...reactNative.StyleSheet.absoluteFillObject},sheet:{maxHeight:St*.9,paddingBottom:reactNative.Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingVertical:12},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function wo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ve({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ct({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function de({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ie({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function He({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.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"}),jsxRuntime.jsx(ee.Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.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 Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.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"}),jsxRuntime.jsx(ee.Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function lt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(ee.Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function eo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(ee__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(ee.Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(ee.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 se({title:e,showBack:t=false,showClose:o=true,onBack:r,onClose:a,badge:i}){let{colors:c}=_();return jsxRuntime.jsxs(reactNative.View,{style:pe.header,children:[jsxRuntime.jsx(reactNative.View,{style:pe.leftContainer,children:t&&r?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:r,style:[pe.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(ko,{size:20,color:c.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:pe.spacer})}),jsxRuntime.jsxs(reactNative.View,{style:pe.titleContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[pe.title,{color:c.foreground}],children:e}),i&&i.count>0&&jsxRuntime.jsx(reactNative.View,{style:[pe.titleBadge,{backgroundColor:c.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[pe.titleBadgeText,{color:c.foregroundMuted}],children:i.count})})]}),jsxRuntime.jsx(reactNative.View,{style:pe.rightContainer,children:o?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:a,style:[pe.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(ve,{size:20,color:c.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:pe.spacer})})]})}var pe=reactNative.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,fontWeight:"500",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 ae({uri:e,width:t,height:o,borderRadius:r=0,borderWidth:a=0,borderColor:i="transparent",backgroundColor:c="transparent",style:m}){let[d,n]=react.useState(false),D=e?.toLowerCase().endsWith(".svg");if(!e)return jsxRuntime.jsx(reactNative.View,{style:[{width:t,height:o,borderRadius:r,backgroundColor:"#374151"},m]});let w={width:t,height:o,borderRadius:r,borderWidth:a,borderColor:i,backgroundColor:c,overflow:"hidden",alignItems:"center",justifyContent:"center",...m},s=t-a*2,S=o-a*2;return d?jsxRuntime.jsx(reactNative.View,{style:[w,{backgroundColor:c||"#374151"}]}):D?jsxRuntime.jsx(reactNative.View,{style:w,children:jsxRuntime.jsx(ee.SvgUri,{uri:e,width:s,height:S,onError:U=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,U),n(true);}})}):jsxRuntime.jsx(reactNative.View,{style:w,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:{width:s,height:S},resizeMode:"contain",onError:U=>{console.log(`[RemoteIcon] Image load error for ${e}:`,U.nativeEvent.error),n(true);}})})}function pt({onPress:e,title:t,subtitle:o,featuredTokens:r}){let{colors:a}=_(),i=r?[...r].sort((c,m)=>c.position-m.position):[];return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ye.container,{backgroundColor:a.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:ye.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[ye.iconContainer,{backgroundColor:a.cardHover}],children:jsxRuntime.jsx(xo,{size:20,color:a.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:ye.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ye.title,{color:a.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[ye.subtitle,{color:a.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:ye.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:ye.networkIcons,children:i.map((c,m)=>{let d=c.icon_urls.find(n=>n.format==="png")?.url||c.icon_urls.find(n=>n.format==="svg")?.url;return jsxRuntime.jsx(reactNative.View,{style:[ye.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:i.length-m}],children:jsxRuntime.jsx(ae,{uri:W(d),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:a.card})},c.name)})})})]})}var ye=reactNative.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 ft({onPress:e,title:t,subtitle:o,paymentNetworks:r}){let{colors:a}=_();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ve.container,{backgroundColor:a.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Ve.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Ve.iconContainer,{backgroundColor:a.cardHover}],children:jsxRuntime.jsx(wo,{size:20,color:a.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:Ve.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Ve.title,{color:a.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Ve.subtitle,{color:a.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:Ve.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:Ve.paymentIcons,children:r?.map(i=>{let c=i.icon_urls.find(m=>m.format==="png")?.url||i.icon_urls.find(m=>m.format==="svg")?.url;return jsxRuntime.jsx(ae,{uri:W(c),width:32,height:20,borderRadius:4},i.name)})})})]})}var Ve=reactNative.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 ht({onPress:e,title:t,subtitle:o,badge:r}){let{colors:a}=_();return jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Le.container,{backgroundColor:a.card}],children:jsxRuntime.jsxs(reactNative.View,{style:Le.leftContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[Le.iconContainer,{backgroundColor:a.cardHover}],children:[jsxRuntime.jsx(_t,{size:20,color:a.foreground,strokeWidth:2}),r!==void 0&&r>0&&jsxRuntime.jsx(reactNative.View,{style:[Le.badge,{backgroundColor:a.primary}],children:jsxRuntime.jsx(reactNative.Text,{style:Le.badgeText,children:r>99?"99+":r})})]}),jsxRuntime.jsxs(reactNative.View,{style:Le.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Le.title,{color:a.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Le.subtitle,{color:a.foregroundMuted}],children:o})]})]})})}var Le=reactNative.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 Dt({value:e,size:t=180,logoUri:o,logoSize:r=40,logoBackgroundColor:a}){let{colors:i,isDark:c}=_(),m=c?"#1a1a1a":"#ffffff",d=c?"#ffffff":"#000000",n=a||m;return jsxRuntime.jsxs(reactNative.View,{style:[ir.container,{width:t,height:t}],children:[jsxRuntime.jsx(Jr__default.default,{value:e||"placeholder",size:t,backgroundColor:m,color:d,ecl:"H",quietZone:4}),o&&jsxRuntime.jsx(reactNative.View,{style:[ir.logoContainer,{width:r+12,height:r+12,backgroundColor:n,borderRadius:(r+12)/2}],children:jsxRuntime.jsx(ae,{uri:o,width:r,height:r,borderRadius:r/2})})]})}var ir=reactNative.StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function ar(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function sn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=e.getDate(),a=e.getFullYear(),i=e.getHours(),c=e.getMinutes(),m=i>=12?"pm":"am";i=i%12,i=i||12;let d=c<10?`0${c}`:c;return `${o} ${r}, ${a} at ${i}:${d}${m}`}function vt({visible:e,status:t,tokenIconUrl:o,explorerUrl:r,completionExplorerUrl:a,date:i,amountUsd:c,onClose:m}){let{colors:d}=_(),n=react.useRef(new reactNative.Animated.Value(0)).current,[D,w]=react.useState(false),s=t==="pending"||t==="waiting"||t==="delayed",S=t==="succeeded";react.useEffect(()=>{if(s&&e){let V=reactNative.Animated.loop(reactNative.Animated.timing(n,{toValue:1,duration:1e3,easing:reactNative.Easing.linear,useNativeDriver:true}));return V.start(),()=>V.stop()}else n.setValue(0);},[s,e,n]);let U=n.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),O=()=>{r&&reactNative.Linking.openURL(r);},P=()=>{a&&reactNative.Linking.openURL(a);};return jsxRuntime.jsx(K,{visible:e,onClose:m,closeOnBackdropPress:true,showHandle:false,children:jsxRuntime.jsxs(reactNative.View,{style:H.container,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:H.closeButton,onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(ve,{size:20,color:d.foregroundMuted,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:H.iconContainer,children:[o?jsxRuntime.jsx(reactNative.Image,{source:{uri:W(o)},style:H.tokenIcon}):jsxRuntime.jsx(reactNative.View,{style:[H.tokenIcon,{backgroundColor:d.cardHover}]}),jsxRuntime.jsx(reactNative.View,{style:[H.statusBadge,{backgroundColor:s?"#F97316":"#22C55E"}],children:s?jsxRuntime.jsx(reactNative.Animated.View,{style:{transform:[{rotate:U}]},children:jsxRuntime.jsx(eo,{size:16,color:"#fff",strokeWidth:2.5})}):jsxRuntime.jsx(ie,{size:16,color:"#fff",strokeWidth:3})})]}),jsxRuntime.jsx(reactNative.Text,{style:[H.title,{color:d.foreground}],children:s?"Deposit Processing":"Deposit Complete"}),c!==void 0&&jsxRuntime.jsxs(reactNative.Text,{style:[H.amount,{color:d.foreground}],children:["$",c.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),i&&jsxRuntime.jsx(reactNative.Text,{style:[H.date,{color:d.foregroundMuted}],children:sn(i)}),jsxRuntime.jsx(reactNative.Text,{style:[H.subtitle,{color:d.foregroundMuted}],children:s?"This usually takes less than a minute.":"Your account has been credited successfully!"}),S&&(r||a)&&jsxRuntime.jsxs(reactNative.View,{style:H.detailsSection,children:[jsxRuntime.jsx(reactNative.View,{style:[H.divider,{backgroundColor:d.border}]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:H.detailsToggle,onPress:()=>w(!D),children:[jsxRuntime.jsx(reactNative.Text,{style:[H.detailsToggleText,{color:d.foregroundMuted}],children:D?"See less":"See more details"}),D?jsxRuntime.jsx(lt,{size:18,color:d.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(de,{size:18,color:d.foregroundMuted,strokeWidth:2})]}),D&&jsxRuntime.jsxs(reactNative.View,{style:H.txButtonsContainer,children:[r&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[H.txButton,{backgroundColor:d.card,borderColor:d.border}],onPress:O,children:[jsxRuntime.jsx(reactNative.Text,{style:[H.txLabel,{color:d.foreground}],children:"Deposit tx"}),jsxRuntime.jsx(reactNative.Text,{style:[H.txHash,{color:d.foregroundMuted}],children:ar(r)}),jsxRuntime.jsx(He,{size:16,color:d.foregroundMuted,strokeWidth:2})]}),a&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[H.txButton,{backgroundColor:d.card,borderColor:d.border}],onPress:P,children:[jsxRuntime.jsx(reactNative.Text,{style:[H.txLabel,{color:d.foreground}],children:"Completion tx"}),jsxRuntime.jsx(reactNative.Text,{style:[H.txHash,{color:d.foregroundMuted}],children:ar(a)}),jsxRuntime.jsx(He,{size:16,color:d.foregroundMuted,strokeWidth:2})]})]})]})]})})}var H=reactNative.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},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 Rt=(e,t)=>`${t}:${e}`,ln=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Pt({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:r,destinationChainId:a,destinationTokenAddress:i,onExecutionsChange:c,onDepositSuccess:m,onDepositError:d}){let{colors:n}=_(),[D,w]=react.useState("USDC"),[s,S]=react.useState("solana:mainnet"),[U,O]=react.useState([]),[P,V]=react.useState(true),[b,f]=react.useState([]),[$,N]=react.useState(true),[Y,te]=react.useState(false),[oe,M]=react.useState(false),[Ye,Me]=react.useState(false),[yt,ge]=react.useState(false),[Ke,Ct]=react.useState([]),[Ee,Je]=react.useState(new Map),[Ae]=react.useState(()=>new Date),[Ot,Xe]=react.useState(null),[ze,Ht]=react.useState(false),[be,jt]=react.useState(null),xt=new Map;b.forEach(y=>{y.chains.forEach(B=>{let A=`${B.chain_type}:${B.chain_id}`;xt.has(A)||xt.set(A,B);});});let Ze=Array.from(xt.values()),wt=ln(s),mo=Ze.find(y=>y.chain_type===wt.chainType&&y.chain_id===wt.chainId)?.chain_type||"ethereum",Te=nt(U,mo)?.address||"";react.useEffect(()=>{async function y(){try{N(!0),Xe(null);let B=await Gt(t);if(f(B.data),B.data.length>0){let A=B.data[0];if(w(A.symbol),A.chains.length>0){let q=A.chains[0];S(Rt(q.chain_id,q.chain_type));}}}catch(B){console.error("Error fetching supported tokens:",B),Xe("Failed to load supported tokens"),d?.({message:"Failed to load supported tokens",error:B});}finally{N(false);}}y();},[t,d]),react.useEffect(()=>{async function y(){try{V(!0),Xe(null);let B=await rt({external_user_id:e,recipient_address:o,destination_chain_type:r,destination_chain_id:a,destination_token_address:i},t);O(B.data);}catch(B){console.error("Error fetching wallets:",B),Xe("Failed to load wallets"),d?.({message:"Failed to load wallets",error:B});}finally{V(false);}}y();},[e,o,r,a,i,t,d]),react.useEffect(()=>{if(!e||!Ae)return;let y=setInterval(async()=>{try{let B=await it(e,t),A=null;for(let q of B.data){let Se=q.created_at?new Date(q.created_at):null;if(!Se||Se<=Ae)continue;let _e=Ee.get(q.id);if(!_e){A=q;break}if(["pending","waiting","delayed"].includes(_e)&&q.status==="succeeded"){A=q;break}}if(A){let q=A;Ct(Se=>{let _e=Se.findIndex(bt=>bt.id===q.id);if(_e>=0){let bt=[...Se];return bt[_e]=q,bt}else return [...Se,q]}),Je(Se=>{let _e=new Map(Se);return _e.set(q.id,q.status),_e}),jt(q),Ht(!0),q.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:q.id}),c?.([...Ke,q]);}}catch(B){console.error("Error polling executions:",B),d?.({message:"Failed to check deposit status",error:B});}},5e3);return ()=>clearInterval(y)},[e,t,Ae,Ee,Ke,c,m,d]),react.useEffect(()=>{if(!b.length)return;let y=b.find(A=>A.symbol===D);if(!y||y.chains.length===0)return;if(!y.chains.some(A=>Rt(A.chain_id,A.chain_type)===s)){let A=y.chains[0];S(Rt(A.chain_id,A.chain_type));}},[D,b,s]);let et=b.find(y=>y.symbol===D),Nt=et?.chains||[],me=Nt.find(y=>Rt(y.chain_id,y.chain_type)===s),tt=async()=>{if(Te)try{reactNative.Clipboard.setString(Te),te(!0),setTimeout(()=>te(!1),2e3);}catch(y){console.error("Failed to copy:",y);}},g=me?.estimated_price_impact_percent??0,L=me?.max_slippage_percent??.25,re=me?.minimum_deposit_amount_usd??3;if($)return jsxRuntime.jsxs(reactNative.View,{style:l.loadingContainer,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:n.primary}),jsxRuntime.jsx(reactNative.Text,{style:[l.loadingText,{color:n.foregroundMuted}],children:"Loading currencies..."})]});if(Ot&&b.length===0)return jsxRuntime.jsxs(reactNative.View,{style:l.errorContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[l.errorText,{color:n.error}],children:Ot}),jsxRuntime.jsx(reactNative.Text,{style:[l.errorHint,{color:n.foregroundMuted}],children:"Please check your network connection and try again."})]});let kt=()=>jsxRuntime.jsxs(K,{visible:Ye,onClose:()=>Me(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[l.sheetHeader,{borderBottomColor:n.border}],children:[jsxRuntime.jsx(reactNative.View,{style:l.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[l.sheetTitle,{color:n.foreground}],children:"Select Token"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Me(false),style:l.sheetCloseButton,children:jsxRuntime.jsx(ve,{size:20,color:n.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.sheetList,showsVerticalScrollIndicator:false,children:b.map(y=>jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{w(y.symbol),Me(false);},style:[l.sheetItem,{backgroundColor:D===y.symbol?n.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(y,"png"))},style:l.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:l.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[l.sheetItemTitle,{color:n.foreground}],children:y.symbol}),jsxRuntime.jsxs(reactNative.Text,{style:[l.sheetItemSubtitle,{color:n.foregroundMuted}],children:[y.chains.length," network",y.chains.length!==1?"s":""," available"]})]}),D===y.symbol&&jsxRuntime.jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},y.symbol))})]}),qt=()=>jsxRuntime.jsxs(K,{visible:yt,onClose:()=>ge(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[l.sheetHeader,{borderBottomColor:n.border}],children:[jsxRuntime.jsx(reactNative.View,{style:l.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[l.sheetTitle,{color:n.foreground}],children:"Select Network"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>ge(false),style:l.sheetCloseButton,children:jsxRuntime.jsx(ve,{size:20,color:n.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:l.sheetList,showsVerticalScrollIndicator:false,children:Nt.map(y=>{let B=Rt(y.chain_id,y.chain_type),A=s===B;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{S(B),ge(false);},style:[l.sheetItem,{backgroundColor:A?n.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(y,"png"))},style:l.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:l.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[l.sheetItemTitle,{color:n.foreground}],children:y.chain_name}),jsxRuntime.jsxs(reactNative.Text,{style:[l.sheetItemSubtitle,{color:n.foregroundMuted}],children:["Min deposit: $",y.minimum_deposit_amount_usd]})]}),A&&jsxRuntime.jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},B)})})]});return jsxRuntime.jsxs(reactNative.View,{style:l.container,children:[jsxRuntime.jsxs(reactNative.View,{style:l.selectorSection,children:[jsxRuntime.jsx(reactNative.Text,{style:[l.selectorLabel,{color:n.foregroundMuted}],children:"Token"}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>Me(true),style:[l.selector,{backgroundColor:n.card}],children:[et&&jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(et,"png"))},style:l.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[l.selectorText,{color:n.foreground}],children:D}),jsxRuntime.jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsxs(reactNative.View,{style:l.selectorSection,children:[jsxRuntime.jsxs(reactNative.Text,{style:[l.selectorLabel,{color:n.foregroundMuted}],children:["Network"," ",jsxRuntime.jsxs(reactNative.Text,{style:l.minDeposit,children:["($",re," min)"]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>ge(true),style:[l.selector,{backgroundColor:n.card}],children:[me&&jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(me,"png"))},style:l.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[l.selectorText,{color:n.foreground}],numberOfLines:1,children:me?.chain_name||"Select network"}),jsxRuntime.jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:l.qrContainer,children:jsxRuntime.jsx(reactNative.View,{style:[l.qrWrapper,{backgroundColor:n.background,borderColor:n.border}],children:P?jsxRuntime.jsxs(reactNative.View,{style:l.qrLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:n.primary}),jsxRuntime.jsx(reactNative.Text,{style:[l.loadingText,{color:n.foregroundMuted}],children:"Loading..."})]}):Te?jsxRuntime.jsx(Dt,{value:Te,size:160,logoUri:W(J(me,"png")||le("/icons/networks/png/ethereum.png")),logoSize:40}):jsxRuntime.jsx(reactNative.View,{style:l.qrLoading,children:jsxRuntime.jsx(reactNative.Text,{style:[l.errorText,{color:n.error}],children:"No address available"})})})}),jsxRuntime.jsxs(reactNative.View,{style:l.addressSection,children:[jsxRuntime.jsxs(reactNative.View,{style:l.addressHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[l.addressLabel,{color:n.foregroundMuted}],children:"Deposit Address"}),Y&&jsxRuntime.jsxs(reactNative.View,{style:l.copiedIndicator,children:[jsxRuntime.jsx(ie,{size:14,color:n.success,strokeWidth:2}),jsxRuntime.jsx(reactNative.Text,{style:[l.copiedText,{color:n.success}],children:"Copied"})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:tt,disabled:!Te||P,activeOpacity:.7,style:[l.addressBox,{backgroundColor:n.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[l.addressText,{color:n.foreground}],numberOfLines:2,children:P?"Loading...":Te||"No address available"})})]}),jsxRuntime.jsxs(reactNative.View,{style:[l.detailsCard,{backgroundColor:n.card}],children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>M(!oe),style:l.detailsHeader,children:[jsxRuntime.jsxs(reactNative.View,{style:l.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Ko,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Price impact:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:n.foreground},children:[g.toFixed(2),"%"]})]})]}),jsxRuntime.jsx(reactNative.View,{style:l.chevronContainer,children:oe?jsxRuntime.jsx(lt,{size:16,color:n.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})})]}),oe&&jsxRuntime.jsxs(reactNative.View,{style:l.detailsContent,children:[jsxRuntime.jsxs(reactNative.View,{style:l.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Jo,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Max slippage:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:n.foreground},children:["Auto \u2022 ",L.toFixed(2),"%"]})]})]}),jsxRuntime.jsxs(reactNative.View,{style:l.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(_t,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Processing time:"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:n.foreground},children:"< 1 min"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:l.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsxRuntime.jsx(Xo,{size:12,color:n.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Need help?"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:n.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:l.termsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[l.termsText,{color:n.foregroundMuted}],children:"Terms apply"})}),kt(),qt(),be&&jsxRuntime.jsx(vt,{visible:ze,status:be.status,tokenIconUrl:be.destination_token_metadata?.icon_urls?.find(y=>y.format==="png")?.url||be.destination_token_metadata?.icon_url||J(et,"png"),explorerUrl:be.explorer_url,completionExplorerUrl:be.destination_explorer_url,onClose:()=>Ht(false)})]})}var l=reactNative.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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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,flex:1},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:"600",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}});function Lt({currency:e,isSelected:t,onSelect:o}){let{colors:r}=_();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[$e.container,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:$e.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[$e.iconContainer,{backgroundColor:r.background}],children:jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(e,"png"))},style:$e.icon})}),jsxRuntime.jsxs(reactNative.View,{style:$e.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[$e.name,{color:r.foreground}],children:e.name}),jsxRuntime.jsx(reactNative.Text,{style:[$e.code,{color:r.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsxRuntime.jsx(ie,{size:16,color:r.foreground,strokeWidth:2})]})}var $e=reactNative.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 mt({title:e,currencies:t,selectedCurrency:o,onSelect:r}){let{colors:a}=_();return t.length===0?null:jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.View,{style:pr.headerContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[pr.title,{color:a.foregroundMuted}],children:e})}),t.map(i=>jsxRuntime.jsx(Lt,{currency:i,isSelected:o.toLowerCase()===i.currency_code.toLowerCase(),onSelect:r},i.currency_code))]})}var pr=reactNative.StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Bt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:r,selectedCurrency:a,onSelectCurrency:i}){let{colors:c}=_(),[m,d]=react.useState(""),n=r.map(P=>o.find(V=>V.currency_code.toLowerCase()===P.toLowerCase())).filter(P=>P!==void 0),D=o.filter(P=>!r.includes(P.currency_code.toLowerCase())),w=P=>{if(!m)return P;let V=m.toLowerCase();return P.filter(b=>b.name.toLowerCase().includes(V)||b.currency_code.toLowerCase().includes(V))},s=w(n),S=w(D),U=P=>{i(P),t(false),d("");},O=()=>{t(false),d("");};return jsxRuntime.jsxs(K,{visible:e,onClose:O,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:"Currency",showBack:false,onClose:O}),jsxRuntime.jsx(reactNative.View,{style:Qe.searchContainer,children:jsxRuntime.jsx(reactNative.TextInput,{style:[Qe.searchInput,{backgroundColor:c.card,color:c.foreground}],value:m,onChangeText:d,placeholder:"Search",placeholderTextColor:c.foregroundMuted})}),jsxRuntime.jsx(reactNative.ScrollView,{style:Qe.listContainer,showsVerticalScrollIndicator:false,children:jsxRuntime.jsxs(reactNative.View,{style:Qe.listContent,children:[jsxRuntime.jsx(mt,{title:"Popular currencies",currencies:s,selectedCurrency:a,onSelect:U}),s.length>0&&S.length>0&&jsxRuntime.jsx(reactNative.View,{style:Qe.sectionSpacer}),jsxRuntime.jsx(mt,{title:"All currencies",currencies:S,selectedCurrency:a,onSelect:U}),s.length===0&&S.length===0&&jsxRuntime.jsx(reactNative.View,{style:Qe.noResultsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[Qe.noResultsText,{color:c.foregroundMuted}],children:"No currencies found"})})]})})]})}var Qe=reactNative.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}});var _n=[100,500,1e3];function mr(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 Mt({externalUserId:e,publishableKey:t,view:o,onViewChange:r,maxAmountUsd:a=5e4,destinationTokenSymbol:i="USDC",recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onDepositSuccess:D,onDepositError:w}){let{colors:s}=_(),[S,U]=react.useState("500.00"),[O,P]=react.useState("usd"),[V,b]=react.useState([]),[f,$]=react.useState(false),[N,Y]=react.useState(null),[te,oe]=react.useState("amount"),[M,Ye]=react.useState(null),[Me,yt]=react.useState([]),[ge,Ke]=react.useState(true),[Ct,Ee]=react.useState(60),[Je,Ae]=react.useState([]),[Ot,Xe]=react.useState([]),[ze,Ht]=react.useState(null),[be,jt]=react.useState(false),[xt,Ze]=react.useState(false),wt=o??te,ho=Je.find(g=>g.currency_code.toLowerCase()===O.toLowerCase()),mo=react.useCallback(g=>{oe(g),g==="quotes"?r?.(g,V.length):r?.(g);},[V.length,r]);react.useEffect(()=>{async function g(){try{let L=await rt({external_user_id:e,recipient_address:c,destination_chain_type:m,destination_chain_id:d,destination_token_address:n},t);yt(L.data);}catch(L){console.error("Error fetching wallets:",L),Y("Failed to load wallet addresses");}finally{Ke(false);}}g();},[e,c,m,d,n,t]),react.useEffect(()=>{async function g(){try{let L=await Jt(t);Ae(L.data),Xe(L.preferred||[]);}catch(L){console.error("Error fetching fiat currencies:",L);}}g();},[t]),react.useEffect(()=>{let g=parseFloat(S);if(isNaN(g)||g<=0){b([]);return}if(O.toLowerCase()==="usd"&&g>a){b([]),Y(`Maximum amount is ${mr("usd")}${a.toLocaleString()}`);return}let L=setTimeout(()=>{yo(g);},500);return ()=>clearTimeout(L)},[S,O,a,t]);let yo=async g=>{$(true),Y(null);try{let L={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:g.toString(),source_currency_code:O.toLowerCase()},re=await Yt(L,t);if(b(re.data),re.data.length>0){let kt=re.data.reduce((qt,y)=>y.destination_amount>qt.destination_amount?y:qt);Ye(kt);}Ee(60);}catch(L){console.error("Failed to fetch quotes:",L),Y("Failed to fetch quotes. Please try again."),b([]);}finally{$(false);}};react.useEffect(()=>{if(V.length===0)return;let g=setInterval(()=>{Ee(L=>{if(L<=1){let re=parseFloat(S);return !isNaN(re)&&re>0&&yo(re),60}return L-1});},1e3);return ()=>clearInterval(g)},[V.length,S]);let Te=g=>{(/^\d*\.?\d{0,2}$/.test(g)||g==="")&&U(g);},et=g=>{U(g.toFixed(2));},Nt=()=>M?M.destination_amount.toFixed(2):"0.00",me=async()=>{if(M)try{let g=nt(Me,"ethereum");if(!g?.address){Y("Wallet address not available");return}let L={service_provider:M.service_provider,country_code:M.country_code.toUpperCase(),destination_currency_code:M.destination_currency_code,source_currency_code:M.source_currency_code,wallet_address:g.address,source_amount:S},re=await Kt(L,t);Ht({provider:M,sourceCurrency:O,sourceAmount:S}),reactNative.Linking.openURL(re.widget_url),mo("onramp");}catch(g){console.error("Failed to create session:",g),Y("Failed to start payment flow"),w?.({message:"Failed to start payment flow",error:g});}},tt=mr(O);return wt==="amount"?jsxRuntime.jsxs(reactNative.ScrollView,{style:p.scrollContainer,contentContainerStyle:p.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsxRuntime.jsx(reactNative.View,{style:p.currencySelector,children:jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>jt(true),style:[p.currencyButton,{backgroundColor:s.card}],children:[ho&&jsxRuntime.jsx(reactNative.Image,{source:{uri:W(J(ho,"png"))},style:p.currencyIcon}),jsxRuntime.jsx(reactNative.Text,{style:[p.currencyText,{color:s.foreground}],children:O.toUpperCase()}),jsxRuntime.jsx(de,{size:16,color:s.foregroundMuted,strokeWidth:2})]})}),jsxRuntime.jsx(Bt,{open:be,onOpenChange:jt,currencies:Je,preferredCurrencyCodes:Ot,selectedCurrency:O,onSelectCurrency:g=>{P(g.toLowerCase());}}),jsxRuntime.jsxs(reactNative.View,{style:p.amountContainer,children:[jsxRuntime.jsxs(reactNative.View,{style:p.amountInputRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[p.currencySymbol,{color:s.foreground}],children:tt}),jsxRuntime.jsx(reactNative.TextInput,{style:[p.amountInput,{color:s.foreground}],value:S,onChangeText:Te,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:s.foregroundMuted})]}),f?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.primary}):jsxRuntime.jsxs(reactNative.Text,{style:[p.usdcPreview,{color:s.foregroundMuted}],children:["\u2248 ",Nt()," ",i]})]}),jsxRuntime.jsx(reactNative.View,{style:p.quickAmounts,children:_n.map(g=>jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>et(g),style:[p.quickAmountButton,{backgroundColor:s.card},parseFloat(S)===g&&{borderColor:s.primary,borderWidth:2}],children:jsxRuntime.jsxs(reactNative.Text,{style:[p.quickAmountText,{color:s.foreground}],children:[tt,g.toLocaleString()]})},g))}),jsxRuntime.jsxs(reactNative.View,{style:p.providerSection,children:[jsxRuntime.jsxs(reactNative.View,{style:p.providerHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[p.providerLabel,{color:s.foreground}],children:"Provider"}),V.length>0&&!f&&jsxRuntime.jsxs(reactNative.Text,{style:[p.refreshText,{color:s.foregroundMuted}],children:["Refreshing in ",Ct,"s"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Ze(true),disabled:f||V.length===0,style:[p.providerButton,{backgroundColor:s.card},(f||V.length===0)&&p.disabled],children:f?jsxRuntime.jsxs(reactNative.View,{style:p.providerLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:s.foregroundMuted}),jsxRuntime.jsx(reactNative.Text,{style:[p.loadingText,{color:s.foregroundMuted}],children:"Finding best rates..."})]}):M?jsxRuntime.jsxs(reactNative.View,{style:p.providerContent,children:[jsxRuntime.jsxs(reactNative.View,{style:p.providerInfo,children:[jsxRuntime.jsx(reactNative.Text,{style:[p.autoPickedText,{color:s.foregroundMuted}],children:"Auto-picked for you"}),jsxRuntime.jsxs(reactNative.View,{style:p.providerRow,children:[jsxRuntime.jsx(ae,{uri:W(M.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[p.providerName,{color:s.foreground}],children:M.service_provider_display_name}),jsxRuntime.jsxs(reactNative.Text,{style:[p.bestPriceText,{color:s.success}],children:["Best price \u2022 ",M.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsxRuntime.jsx(ct,{size:20,color:s.foregroundMuted,strokeWidth:2})]}):jsxRuntime.jsx(reactNative.Text,{style:[p.noProviderText,{color:s.foregroundMuted}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),N&&jsxRuntime.jsx(reactNative.Text,{style:[p.errorText,{color:s.error}],children:N})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:me,disabled:f||ge||!M||parseFloat(S)<=0,style:[p.continueButton,{backgroundColor:s.primary},(f||ge||!M)&&p.disabledButton],children:jsxRuntime.jsx(reactNative.Text,{style:p.continueButtonText,children:ge?"Loading...":`Buy ${i}`})}),jsxRuntime.jsxs(K,{visible:xt,onClose:()=>Ze(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:"Select Provider",showBack:false,onClose:()=>Ze(false),badge:V.length>0?{count:V.length}:void 0}),jsxRuntime.jsx(reactNative.ScrollView,{style:p.providerModalList,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(reactNative.View,{style:p.quotesList,children:[...V].sort((g,L)=>L.destination_amount-g.destination_amount).map((g,L)=>{let re=M?.service_provider===g.service_provider,kt=L===0;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{Ye(g),Ze(false);},style:[p.quoteItem,{backgroundColor:s.card},re&&{borderColor:s.primary,borderWidth:2}],children:[jsxRuntime.jsxs(reactNative.View,{style:p.quoteLeft,children:[jsxRuntime.jsx(ae,{uri:W(g.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[p.quoteName,{color:s.foreground}],children:g.service_provider_display_name}),kt&&jsxRuntime.jsx(reactNative.Text,{style:[p.bestPriceLabel,{color:s.success}],children:"\u2713 Best price"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:p.quoteRight,children:[jsxRuntime.jsxs(reactNative.Text,{style:[p.quoteAmount,{color:s.foreground}],children:[g.destination_amount.toFixed(2)," USDC"]}),jsxRuntime.jsxs(reactNative.Text,{style:[p.quoteSource,{color:s.foregroundMuted}],children:["Fee: ",tt,g.total_fee.toFixed(2)]})]})]},g.service_provider)})})})]})]}):wt==="onramp"&&ze?jsxRuntime.jsxs(reactNative.View,{style:p.onrampContainer,children:[jsxRuntime.jsx(ae,{uri:W(ze.provider.icon_url),width:48,height:48,borderRadius:12}),jsxRuntime.jsxs(reactNative.Text,{style:[p.onrampTitle,{color:s.foreground}],children:["Complete on ",ze.provider.service_provider_display_name]}),jsxRuntime.jsx(reactNative.Text,{style:[p.onrampSubtitle,{color:s.foregroundMuted}],children:"You can close this modal. Your deposit will be processed automatically."}),jsxRuntime.jsxs(reactNative.View,{style:[p.flowDiagram,{backgroundColor:s.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:p.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:le(`/icons/currencies/png/${ze.sourceCurrency.toLowerCase()}.png`)},style:p.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[p.flowLabel,{color:s.foregroundMuted}],children:"You pay"}),jsxRuntime.jsxs(reactNative.Text,{style:[p.flowValue,{color:s.foreground}],children:[tt,ze.sourceAmount]})]}),jsxRuntime.jsx(ct,{size:20,color:s.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:p.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:le("/icons/tokens/png/usdc.png")},style:p.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[p.flowLabel,{color:s.foregroundMuted}],children:"You get"}),jsxRuntime.jsx(reactNative.Text,{style:[p.flowValue,{color:s.foreground}],children:i})]})]})]}):null}var p=reactNative.StyleSheet.create({scrollContainer:{flexGrow:1},scrollContent:{padding:16,paddingBottom:32},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"},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},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:{padding:16,alignItems:"center",paddingTop:24},onrampIcon:{width:64,height:64,borderRadius:16,marginBottom:16},onrampTitle:{fontSize:20,fontWeight:"500",textAlign:"center",marginBottom:8},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",padding:16,borderRadius:12,width:"100%"},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 Rn(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 Pn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Et({execution:e,onPress:t}){let {colors:o}=_(),r=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let i=W(J(e.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),c=r?"Deposit Processing":"Deposit Completed",m=Rn(e.created_at||new Date().toISOString()),d=Pn(e.source_amount_usd);return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:t,activeOpacity:.7,style:[ke.container,{backgroundColor:o.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:ke.iconContainer,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:i},style:ke.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[ke.statusBadge,{backgroundColor:r?"#EAB308":"#22C55E"}],children:r?jsxRuntime.jsx(eo,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsxRuntime.jsx(ie,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxRuntime.jsxs(reactNative.View,{style:ke.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ke.title,{color:o.foreground}],children:c}),jsxRuntime.jsx(reactNative.Text,{style:[ke.dateTime,{color:o.foregroundMuted}],children:m})]}),jsxRuntime.jsxs(reactNative.View,{style:ke.rightContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ke.amount,{color:o.foreground}],children:d}),jsxRuntime.jsx(ct,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var ke=reactNative.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,borderColor:"#1C1C1E"},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:Wn}=reactNative.Dimensions.get("window");function xr(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 wr(e,t=6){try{return e?(Number(e)/Math.pow(10,t)).toFixed(2):"0.00"}catch{return "0.00"}}function Mn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var kr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function br(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function En(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 At({visible:e,onClose:t,executions:o,externalUserId:r,publishableKey:a}){let{colors:i}=_(),[c,m]=react.useState(o),[d,n]=react.useState(false),[D,w]=react.useState(null),[s,S]=react.useState(false);react.useEffect(()=>{if(!e||!r)return;let f=async()=>{n(true);try{let Y=[...(await it(r,a)).data].sort((te,oe)=>{let M=te.created_at?new Date(te.created_at).getTime():0;return (oe.created_at?new Date(oe.created_at).getTime():0)-M});m(Y);}catch(N){console.error("Failed to fetch executions:",N),m(o);}finally{n(false);}};f();let $=setInterval(f,1e4);return ()=>clearInterval($)},[e,r,a,o]),react.useEffect(()=>{o.length>0&&m(f=>{let $=new Set(f.map(Y=>Y.id)),N=o.filter(Y=>!$.has(Y.id));return N.length>0?[...N,...f]:f});},[o]),react.useEffect(()=>{e||w(null);},[e]);let U=f=>{w(f);},O=()=>{w(null),S(false);},P=()=>{w(null),t();};return jsxRuntime.jsxs(K,{visible:e,onClose:P,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(se,{title:D?"Deposit Details":"Deposit Tracker",onClose:P,showClose:!D,showBack:!!D,onBack:O}),D?(()=>{if(!D)return null;let f=D,$=f.status==="pending"||f.status==="waiting"||f.status==="delayed",N=f.status==="succeeded",Y=W(J(f.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),te=f.provider_metadata?.details,oe=te?.currencyIn,M=te?.currencyOut;oe?.currency?.symbol||"USDC";M?.currency?.symbol||"USDC";let yt=wr(f.source_amount_base_unit),ge=wr(f.destination_amount_base_unit),Ke=Mn(f.source_amount_usd),Ct=xr(f.source_chain_type,f.source_chain_id),Ee=xr(f.destination_chain_type,f.destination_chain_id),Je=()=>{f.explorer_url&&reactNative.Linking.openURL(f.explorer_url);},Ae=()=>{f.destination_explorer_url&&reactNative.Linking.openURL(f.destination_explorer_url);};return jsxRuntime.jsxs(reactNative.ScrollView,{style:h.scrollContainer,contentContainerStyle:h.detailsContent,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:h.iconSection,children:[jsxRuntime.jsxs(reactNative.View,{style:h.iconWrapper,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:Y},style:h.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[h.statusBadge,{backgroundColor:$?"#EAB308":"#22C55E"}],children:$?jsxRuntime.jsx(de,{size:14,color:"#FFFFFF",strokeWidth:2}):jsxRuntime.jsx(ie,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:h.statusRow,children:[jsxRuntime.jsx(reactNative.View,{style:[h.statusDot,{backgroundColor:$?"#EAB308":"#22C55E"}]}),jsxRuntime.jsx(reactNative.Text,{style:[h.statusText,{color:i.foreground}],children:$?"Processing":"Completed"})]}),jsxRuntime.jsx(reactNative.Text,{style:[h.dateText,{color:i.foregroundMuted}],children:En(f.created_at||new Date().toISOString())})]}),jsxRuntime.jsxs(reactNative.View,{style:[h.card,{backgroundColor:i.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Amount Sent"}),jsxRuntime.jsxs(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:[yt," ",br(f.source_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Amount Received"}),jsxRuntime.jsxs(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:[ge," ",br(f.destination_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"USD Value"}),jsxRuntime.jsx(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:Ke})]}),jsxRuntime.jsx(reactNative.View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Source Network"}),jsxRuntime.jsx(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:Ct})]}),jsxRuntime.jsx(reactNative.View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Destination Network"}),jsxRuntime.jsx(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:Ee})]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>S(!s),style:h.toggleButton,activeOpacity:.7,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.toggleText,{color:i.foregroundMuted}],children:s?"See less":"See more details"}),s?jsxRuntime.jsx(lt,{size:14,color:i.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(de,{size:14,color:i.foregroundMuted,strokeWidth:2})]}),s&&jsxRuntime.jsxs(reactNative.View,{style:[h.card,{backgroundColor:i.card}],children:[f.explorer_url&&jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:Je,style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Deposit Tx"}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:kr(f.transaction_hash)}),jsxRuntime.jsx(He,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:[h.cardDivider,{backgroundColor:i.border}]})]}),f.destination_explorer_url&&N&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:Ae,style:h.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Completion Tx"}),jsxRuntime.jsxs(reactNative.View,{style:h.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.cardValue,{color:i.foreground}],children:kr(f.destination_transaction_hashes[0])}),jsxRuntime.jsx(He,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsxRuntime.jsx(reactNative.ScrollView,{style:h.scrollContainer,contentContainerStyle:h.scrollContent,showsVerticalScrollIndicator:false,children:c.length===0?jsxRuntime.jsxs(reactNative.View,{style:h.emptyContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[h.emptyText,{color:i.foregroundMuted}],children:"No deposits yet"}),jsxRuntime.jsx(reactNative.Text,{style:[h.emptySubtext,{color:i.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsxRuntime.jsx(reactNative.View,{style:h.executionsList,children:c.map(f=>jsxRuntime.jsx(Et,{execution:f,onPress:()=>U(f)},f.id))})})]})}var h=reactNative.StyleSheet.create({scrollContainer:{maxHeight:Wn*.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,borderColor:"#1C1C1E"},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}});var Ge={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 Un({visible:e,onClose:t,externalUserId:o,publishableKey:r,modalTitle:a="Deposit",destinationTokenSymbol:i,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,hideDepositTracker:D=false,onDepositSuccess:w,onDepositError:s}){let[S,U]=react.useState([]),[O,P]=react.useState(false),[V,b]=react.useState(false),[f,$]=react.useState(false),[N,Y]=react.useState(null);react.useEffect(()=>{e&&!N&&Xt(r).then(Y).catch(console.error);},[e,N,r]);let te=()=>{t();},oe=S.filter(M=>M.status==="pending"||M.status==="waiting").length;return jsxRuntime.jsxs(K,{visible:e,onClose:te,closeOnBackdropPress:false,showHandle:false,children:[jsxRuntime.jsx(se,{title:a,showBack:false,onClose:te}),jsxRuntime.jsxs(reactNative.View,{style:Ft.optionsContainer,children:[jsxRuntime.jsx(pt,{onPress:()=>b(true),title:Ge.transferCrypto.title,subtitle:Ge.transferCrypto.subtitle,featuredTokens:N?.transfer_crypto?.networks}),jsxRuntime.jsx(ft,{onPress:()=>$(true),title:Ge.depositWithCard.title,subtitle:Ge.depositWithCard.subtitle,paymentNetworks:N?.payment_networks?.networks}),!D&&jsxRuntime.jsx(ht,{onPress:()=>P(true),title:Ge.depositTracker.title,subtitle:Ge.depositTracker.subtitle,badge:oe>0?oe:void 0})]}),jsxRuntime.jsx(At,{visible:O,onClose:()=>P(false),executions:S,externalUserId:o,publishableKey:r}),jsxRuntime.jsxs(K,{visible:V,onClose:()=>b(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsxRuntime.jsx(se,{title:Ge.transferCrypto.title,showBack:false,onClose:()=>b(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:Ft.transferScrollContainer,contentContainerStyle:Ft.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(Pt,{externalUserId:o,publishableKey:r,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onExecutionsChange:U,onDepositSuccess:w,onDepositError:s})})]}),jsxRuntime.jsxs(K,{visible:f,onClose:()=>$(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsxRuntime.jsx(se,{title:"Add Funds",showBack:false,onClose:()=>$(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:Ft.transferScrollContainer,contentContainerStyle:Ft.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(Mt,{externalUserId:o,publishableKey:r,destinationTokenSymbol:i,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onDepositSuccess:w,onDepositError:s})})]})]})}function Ut({theme:e="auto",...t}){return jsxRuntime.jsx(ot,{mode:e,children:jsxRuntime.jsx(Un,{...t})})}var Ft=reactNative.StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24}});reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});function Wo({uri:e,size:t=24,style:o,borderRadius:r}){return jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:[Nn.icon,{width:t,height:t,borderRadius:r??t/2},o],resizeMode:"contain"})}var Nn=reactNative.StyleSheet.create({icon:{backgroundColor:"transparent"}});var Xn=()=>new reactQuery.QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),_r=react.createContext(null);function Zn({children:e,publishableKey:t,config:o}){let[r]=react.useState(()=>Xn()),[a,i]=react.useState(false),[c,m]=react.useState(null),d=reactNative.useColorScheme(),n=react.useRef(false);n.current||(Tt({publishableKey:t}),n.current=true);let D=react.useMemo(()=>{let b=o?.appearance||"dark";return b==="auto"?d==="dark"?"dark":"light":b},[o?.appearance,d]);react.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.'),Tt({publishableKey:t});},[t]);let w=react.useRef(null),s=react.useRef(null),S=react.useCallback(b=>{console.log("[UnifoldProvider] beginDeposit called with:",b),s.current&&(clearTimeout(s.current),s.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let f=new Promise(($,N)=>{w.current={resolve:$,reject:N};});return m(b),i(true),f},[]),U=react.useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),i(false),s.current=setTimeout(()=>{m(null),s.current=null;},200);},[]),O=react.useCallback(b=>{console.log("[UnifoldProvider] Deposit success:",b),c?.onSuccess&&c.onSuccess(b),w.current&&(w.current.resolve(b),w.current=null);},[c]),P=react.useCallback(b=>{console.error("[UnifoldProvider] Deposit error:",b),c?.onError&&c.onError(b),w.current&&(w.current.reject(b),w.current=null);},[c]),V=react.useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:U}),[t,S,U]);return jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:r,children:jsxRuntime.jsx(_r.Provider,{value:V,children:jsxRuntime.jsxs(ot,{mode:D,children:[e,c&&jsxRuntime.jsx(Ut,{visible:a,onClose:U,externalUserId:c.externalUserId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:c.destinationTokenSymbol,recipientAddress:c.recipientAddress,destinationChainId:c.destinationChainId,destinationTokenAddress:c.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:O,onDepositError:P,theme:D})]})})})}function ei(){let e=react.useContext(_r);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
+ exports.BottomSheet=K;exports.BuyWithCard=Mt;exports.CurrencyListItem=Lt;exports.CurrencyListSection=mt;exports.CurrencyModal=Bt;exports.DepositExecutionItem=Et;exports.DepositHeader=se;exports.DepositModal=Ut;exports.DepositStatusSheet=vt;exports.DepositTrackerButton=ht;exports.DepositWithCardButton=ft;exports.DepositsModal=At;exports.ExecutionStatus=Ue;exports.Icon=Wo;exports.QRCode=Dt;exports.RemoteIcon=ae;exports.SOLANA_USDC_ADDRESS=jo;exports.ThemeProvider=ot;exports.TransferCrypto=Pt;exports.TransferCryptoButton=pt;exports.UnifoldProvider=Zn;exports.createDepositAddress=Co;exports.createEOA=rt;exports.createMeldSession=Kt;exports.getApiBaseUrl=Oo;exports.getChainName=$o;exports.getFiatCurrencies=Jt;exports.getIconUrl=le;exports.getIconUrlWithCdn=Ho;exports.getMeldQuotes=Yt;exports.getPreferredIcon=J;exports.getPreferredIconUrl=No;exports.getProjectConfig=Xt;exports.getSupportedDepositTokens=Gt;exports.getTokenChains=qo;exports.getWalletByChainType=nt;exports.normalizeIconUrl=W;exports.queryExecutions=it;exports.setApiConfig=Tt;exports.setDevApiUrl=Uo;exports.useTheme=_;exports.useUnifold=ei;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {createContext,useMemo,useContext,useRef,useEffect,useState,useCallback}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,Animated,Modal,KeyboardAvoidingView,TouchableWithoutFeedback,View,TouchableOpacity,Text,Image,Easing,ActivityIndicator,TextInput,ScrollView,Linking,Clipboard}from'react-native';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {jsx,jsxs}from'react/jsx-runtime';import ee,{SvgUri,Line,Polyline,Path,Rect,Circle}from'react-native-svg';import Kr from'react-native-qrcode-svg';var zo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Rr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Fo=createContext({colors:zo,isDark:false,mode:"auto"});function Ze({children:e,mode:t="auto"}){let o=useColorScheme(),r=useMemo(()=>{let l;return t==="auto"?l=o==="dark":l=t==="dark",{colors:l?Rr:zo,isDark:l,mode:t}},[t,o]);return jsx(Fo.Provider,{value:r,children:e})}function _(){let e=useContext(Fo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Vr="https://api.unifold.io",Nt,_e="pk_test_123",Ht={};function ne(){return typeof __DEV__<"u"&&__DEV__&&Nt?Nt:Vr}function xt(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.'),_e=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Nt=e.baseUrl),e.defaultConfig&&(Ht=e.defaultConfig);}function Uo(e){typeof __DEV__<"u"&&__DEV__?(Nt=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oo(){return ne()}function Ae(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 le(e){let t=e.startsWith("/")?e:`/${e}`;return `${ne()}/api/public${t}`}function jo(e,t){if(!t)return le(e);let o=e.startsWith("/")?e:`/${e}`;return `${t.endsWith("/")?t.slice(0,-1):t}/api/public${o}`}function L(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ne()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ne()}${e}`:`${ne()}/api/public${e}`:""}async function mo(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||Ht.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ht.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Ht.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},r=t||_e;Ae(r);let l=await fetch(`${ne()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok)throw new Error(`Failed to create deposit address: ${l.statusText}`);return l.json()}async function Je(e,t){return mo(e?{...e,external_user_id:e.user_id}:void 0,t)}function Xe(e,t){return e.find(o=>o.chain_type===t)}var Me=(a=>(a.DELAYED="delayed",a.FAILED="failed",a.PENDING="pending",a.REFUNDED="refunded",a.SUCCEEDED="succeeded",a.WAITING="waiting",a))(Me||{}),Ho="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";async function et(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/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(!r.ok)throw new Error(`Failed to query executions: ${r.statusText}`);return r.json()}function K(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(r=>r.format===t);return o?o.url:e.icon_url}async function qt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function $t(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to fetch Meld quotes: ${r.statusText}`);return r.json()}async function Qt(e,t){let o=t||_e;Ae(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to create Meld session: ${r.statusText}`);return r.json()}async function Gt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/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 No(e,t="png"){if(!e||e.length===0)return;let o=e.find(r=>r.format===t);return o?o.url:e[0]?.url}async function Yt(e){let t=e||_e;Ae(t);let o=await fetch(`${ne()}/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 qo(){let e=await fetch(`${ne()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function $o(e,t,o){let r=e.find(i=>i.chain_id===o);if(r)return r.chain_name;let l=e.find(i=>i.chain_type===t);return l?l.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}var{height:wt}=Dimensions.get("window");function Y({visible:e,onClose:t,children:o,closeOnBackdropPress:r=true,showHandle:l=true,heightPercent:i}){let{colors:a}=_(),m=useRef(new Animated.Value(wt)).current,h=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(m.setValue(wt),h.setValue(0),Animated.parallel([Animated.spring(m,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(h,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(m,{toValue:wt,useNativeDriver:true,tension:65,friction:11}),Animated.timing(h,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,m,h]);let n=()=>{r&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":"height",style:ze.container,children:[jsx(TouchableWithoutFeedback,{onPress:n,children:jsx(Animated.View,{style:[ze.backdrop,{backgroundColor:"#000000",opacity:h}]})}),jsxs(Animated.View,{style:[ze.sheet,{backgroundColor:a.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:m}],...i&&{height:wt*i}}],children:[l&&jsx(View,{style:ze.handleContainer,children:jsx(View,{style:[ze.handle,{backgroundColor:a.border}]})}),jsx(View,{style:[ze.content,i&&ze.contentFlex],children:o})]})]})})}var ze=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:wt*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingVertical:12},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function yo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 Co({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 kt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 rt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 nt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 me({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 ie({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 Kt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 Zo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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"})})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 Zt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 Jt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 se({title:e,showBack:t=false,showClose:o=true,onBack:r,onClose:l,badge:i}){let{colors:a}=_();return jsxs(View,{style:ue.header,children:[jsx(View,{style:ue.leftContainer,children:t&&r?jsx(TouchableOpacity,{onPress:r,style:[ue.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(xo,{size:20,color:a.foreground,strokeWidth:2})}):jsx(View,{style:ue.spacer})}),jsxs(View,{style:ue.titleContainer,children:[jsx(Text,{style:[ue.title,{color:a.foreground}],children:e}),i&&i.count>0&&jsx(View,{style:[ue.titleBadge,{backgroundColor:a.card}],children:jsx(Text,{style:[ue.titleBadgeText,{color:a.foregroundMuted}],children:i.count})})]}),jsx(View,{style:ue.rightContainer,children:o?jsx(TouchableOpacity,{onPress:l,style:[ue.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(rt,{size:20,color:a.foreground,strokeWidth:2})}):jsx(View,{style:ue.spacer})})]})}var ue=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,fontWeight:"500",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 ae({uri:e,width:t,height:o,borderRadius:r=0,borderWidth:l=0,borderColor:i="transparent",backgroundColor:a="transparent",style:m}){let[h,n]=useState(false),V=e?.toLowerCase().endsWith(".svg");if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:r,backgroundColor:"#374151"},m]});let w={width:t,height:o,borderRadius:r,borderWidth:l,borderColor:i,backgroundColor:a,overflow:"hidden",alignItems:"center",justifyContent:"center",...m},c=t-l*2,T=o-l*2;return h?jsx(View,{style:[w,{backgroundColor:a||"#374151"}]}):V?jsx(View,{style:w,children:jsx(SvgUri,{uri:e,width:c,height:T,onError:N=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,N),n(true);}})}):jsx(View,{style:w,children:jsx(Image,{source:{uri:e},style:{width:c,height:T},resizeMode:"contain",onError:N=>{console.log(`[RemoteIcon] Image load error for ${e}:`,N.nativeEvent.error),n(true);}})})}function at({onPress:e,title:t,subtitle:o,featuredTokens:r}){let{colors:l}=_(),i=r?[...r].sort((a,m)=>a.position-m.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ye.container,{backgroundColor:l.card}],children:[jsxs(View,{style:ye.leftContent,children:[jsx(View,{style:[ye.iconContainer,{backgroundColor:l.cardHover}],children:jsx(yo,{size:20,color:l.foreground,strokeWidth:2})}),jsxs(View,{style:ye.textContainer,children:[jsx(Text,{style:[ye.title,{color:l.foreground}],children:t}),jsx(Text,{style:[ye.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsx(View,{style:ye.rightContent,children:jsx(View,{style:ye.networkIcons,children:i.map((a,m)=>{let h=a.icon_urls.find(n=>n.format==="png")?.url||a.icon_urls.find(n=>n.format==="svg")?.url;return jsx(View,{style:[ye.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:i.length-m}],children:jsx(ae,{uri:L(h),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:l.card})},a.name)})})})]})}var ye=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 ct({onPress:e,title:t,subtitle:o,paymentNetworks:r}){let{colors:l}=_();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Re.container,{backgroundColor:l.card}],children:[jsxs(View,{style:Re.leftContent,children:[jsx(View,{style:[Re.iconContainer,{backgroundColor:l.cardHover}],children:jsx(Co,{size:20,color:l.foreground,strokeWidth:2})}),jsxs(View,{style:Re.textContainer,children:[jsx(Text,{style:[Re.title,{color:l.foreground}],children:t}),jsx(Text,{style:[Re.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsx(View,{style:Re.rightContent,children:jsx(View,{style:Re.paymentIcons,children:r?.map(i=>{let a=i.icon_urls.find(m=>m.format==="png")?.url||i.icon_urls.find(m=>m.format==="svg")?.url;return jsx(ae,{uri:L(a),width:32,height:20,borderRadius:4},i.name)})})})]})}var Re=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 dt({onPress:e,title:t,subtitle:o,badge:r}){let{colors:l}=_();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Pe.container,{backgroundColor:l.card}],children:jsxs(View,{style:Pe.leftContent,children:[jsxs(View,{style:[Pe.iconContainer,{backgroundColor:l.cardHover}],children:[jsx(kt,{size:20,color:l.foreground,strokeWidth:2}),r!==void 0&&r>0&&jsx(View,{style:[Pe.badge,{backgroundColor:l.primary}],children:jsx(Text,{style:Pe.badgeText,children:r>99?"99+":r})})]}),jsxs(View,{style:Pe.textContainer,children:[jsx(Text,{style:[Pe.title,{color:l.foreground}],children:t}),jsx(Text,{style:[Pe.subtitle,{color:l.foregroundMuted}],children:o})]})]})})}var Pe=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 Tt({value:e,size:t=180,logoUri:o,logoSize:r=40,logoBackgroundColor:l}){let{colors:i,isDark:a}=_(),m=a?"#1a1a1a":"#ffffff",h=a?"#ffffff":"#000000",n=l||m;return jsxs(View,{style:[sr.container,{width:t,height:t}],children:[jsx(Kr,{value:e||"placeholder",size:t,backgroundColor:m,color:h,ecl:"H",quietZone:4}),o&&jsx(View,{style:[sr.logoContainer,{width:r+12,height:r+12,backgroundColor:n,borderRadius:(r+12)/2}],children:jsx(ae,{uri:o,width:r,height:r,borderRadius:r/2})})]})}var sr=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function _t({visible:e,status:t,tokenIconUrl:o,explorerUrl:r,completionExplorerUrl:l,onClose:i}){let{colors:a}=_(),m=useRef(new Animated.Value(0)).current,h=t==="pending"||t==="waiting"||t==="delayed",n=t==="succeeded";useEffect(()=>{if(h&&e){let T=Animated.loop(Animated.timing(m,{toValue:1,duration:1e3,easing:Easing.linear,useNativeDriver:true}));return T.start(),()=>T.stop()}else m.setValue(0);},[h,e,m]);let V=m.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),w=()=>{r&&Linking.openURL(r);},c=()=>{l&&Linking.openURL(l);};return jsx(Y,{visible:e,onClose:i,closeOnBackdropPress:true,showHandle:false,children:jsxs(View,{style:j.container,children:[jsxs(View,{style:j.iconContainer,children:[o?jsx(Image,{source:{uri:L(o)},style:j.tokenIcon}):jsx(View,{style:[j.tokenIcon,{backgroundColor:a.cardHover}]}),jsx(View,{style:[j.statusBadge,{backgroundColor:h?"#F97316":"#22C55E"}],children:h?jsx(Animated.View,{style:{transform:[{rotate:V}]},children:jsx(Jt,{size:16,color:"#fff",strokeWidth:2.5})}):jsx(ie,{size:16,color:"#fff",strokeWidth:3})})]}),jsx(Text,{style:[j.title,{color:a.foreground}],children:h?"Deposit Processing":"Deposit Complete"}),jsx(Text,{style:[j.subtitle,{color:a.foregroundMuted}],children:h?`Your deposit is being processed.
2
- This usually takes less than a minute.`:"Your account has been credited successfully!"}),h?jsx(TouchableOpacity,{onPress:i,style:[j.button,j.dismissButton],children:jsx(Text,{style:j.buttonText,children:"Dismiss"})}):jsxs(View,{style:j.buttonRow,children:[jsx(TouchableOpacity,{onPress:w,style:[j.button,j.successButton,j.halfButton],children:jsx(Text,{style:j.buttonText,children:"View deposit tx"})}),jsx(TouchableOpacity,{onPress:c,style:[j.button,j.successButton,j.halfButton],children:jsx(Text,{style:j.buttonText,children:"View completion tx"})})]}),n&&jsx(Text,{style:[j.hint,{color:a.foregroundMuted}],children:"Opens in external browser"})]})})}var j=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:24,paddingBottom:20},iconContainer:{position:"relative",marginBottom:20},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",marginBottom:24,lineHeight:20},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},dismissButton:{backgroundColor:"#F97316",width:"100%"},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});var It=(e,t)=>`${t}:${e}`,sn=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function vt({userId:e,publishableKey:t,recipientAddress:o,destinationChainType:r,destinationChainId:l,destinationTokenAddress:i,onExecutionsChange:a,onDepositSuccess:m,onDepositError:h}){let{colors:n}=_(),[V,w]=useState("USDC"),[c,T]=useState("solana:mainnet"),[N,q]=useState([]),[B,W]=useState(true),[b,p]=useState([]),[$,U]=useState(true),[G,te]=useState(false),[oe,E]=useState(false),[Ne,Le]=useState(false),[ft,fe]=useState(false),[qe,gt]=useState([]),[Be,$e]=useState(new Map),[Ee]=useState(()=>new Date),[zt,Qe]=useState(null),[We,Ft]=useState(false),[ke,Ut]=useState(null),mt=new Map;b.forEach(y=>{y.chains.forEach(P=>{let M=`${P.chain_type}:${P.chain_id}`;mt.has(M)||mt.set(M,P);});});let Ge=Array.from(mt.values()),ht=sn(c),fo=Ge.find(y=>y.chain_type===ht.chainType&&y.chain_id===ht.chainId)?.chain_type||"ethereum",be=Xe(N,fo)?.address||"";useEffect(()=>{async function y(){try{U(!0),Qe(null);let P=await qt(t);if(p(P.data),P.data.length>0){let M=P.data[0];if(w(M.symbol),M.chains.length>0){let O=M.chains[0];T(It(O.chain_id,O.chain_type));}}}catch(P){console.error("Error fetching supported tokens:",P),Qe("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:P});}finally{U(false);}}y();},[t,h]),useEffect(()=>{async function y(){try{W(!0),Qe(null);let P=await Je({user_id:e,recipient_address:o,destination_chain_type:r,destination_chain_id:l,destination_token_address:i},t);q(P.data);}catch(P){console.error("Error fetching wallets:",P),Qe("Failed to load wallets"),h?.({message:"Failed to load wallets",error:P});}finally{W(false);}}y();},[e,o,r,l,i,t,h]),useEffect(()=>{if(!e||!Ee)return;let y=setInterval(async()=>{try{let P=await et(e,t),M=null;for(let O of P.data){let Te=O.created_at?new Date(O.created_at):null;if(!Te||Te<=Ee)continue;let Se=Be.get(O.id);if(!Se){M=O;break}if(["pending","waiting","delayed"].includes(Se)&&O.status==="succeeded"){M=O;break}}if(M){let O=M;gt(Te=>{let Se=Te.findIndex(Ct=>Ct.id===O.id);if(Se>=0){let Ct=[...Te];return Ct[Se]=O,Ct}else return [...Te,O]}),$e(Te=>{let Se=new Map(Te);return Se.set(O.id,O.status),Se}),Ut(O),Ft(!0),O.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:O.id}),a?.([...qe,O]);}}catch(P){console.error("Error polling executions:",P),h?.({message:"Failed to check deposit status",error:P});}},5e3);return ()=>clearInterval(y)},[e,t,Ee,Be,qe,a,m,h]),useEffect(()=>{if(!b.length)return;let y=b.find(M=>M.symbol===V);if(!y||y.chains.length===0)return;if(!y.chains.some(M=>It(M.chain_id,M.chain_type)===c)){let M=y.chains[0];T(It(M.chain_id,M.chain_type));}},[V,b,c]);let Ye=b.find(y=>y.symbol===V),Ot=Ye?.chains||[],he=Ot.find(y=>It(y.chain_id,y.chain_type)===c),Ke=async()=>{if(be)try{Clipboard.setString(be),te(!0),setTimeout(()=>te(!1),2e3);}catch(y){console.error("Failed to copy:",y);}},f=he?.estimated_price_impact_percent??0,R=he?.max_slippage_percent??.25,re=he?.minimum_deposit_amount_usd??3;if($)return jsxs(View,{style:s.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:n.primary}),jsx(Text,{style:[s.loadingText,{color:n.foregroundMuted}],children:"Loading currencies..."})]});if(zt&&b.length===0)return jsxs(View,{style:s.errorContainer,children:[jsx(Text,{style:[s.errorText,{color:n.error}],children:zt}),jsx(Text,{style:[s.errorHint,{color:n.foregroundMuted}],children:"Please check your network connection and try again."})]});let yt=()=>jsxs(Y,{visible:Ne,onClose:()=>Le(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[s.sheetHeader,{borderBottomColor:n.border}],children:[jsx(View,{style:s.sheetHeaderSpacer}),jsx(Text,{style:[s.sheetTitle,{color:n.foreground}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>Le(false),style:s.sheetCloseButton,children:jsx(rt,{size:20,color:n.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:s.sheetList,showsVerticalScrollIndicator:false,children:b.map(y=>jsxs(TouchableOpacity,{onPress:()=>{w(y.symbol),Le(false);},style:[s.sheetItem,{backgroundColor:V===y.symbol?n.card:"transparent"}],children:[jsx(Image,{source:{uri:L(K(y,"png"))},style:s.sheetItemIcon}),jsxs(View,{style:s.sheetItemText,children:[jsx(Text,{style:[s.sheetItemTitle,{color:n.foreground}],children:y.symbol}),jsxs(Text,{style:[s.sheetItemSubtitle,{color:n.foregroundMuted}],children:[y.chains.length," network",y.chains.length!==1?"s":""," available"]})]}),V===y.symbol&&jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},y.symbol))})]}),jt=()=>jsxs(Y,{visible:ft,onClose:()=>fe(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[s.sheetHeader,{borderBottomColor:n.border}],children:[jsx(View,{style:s.sheetHeaderSpacer}),jsx(Text,{style:[s.sheetTitle,{color:n.foreground}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>fe(false),style:s.sheetCloseButton,children:jsx(rt,{size:20,color:n.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:s.sheetList,showsVerticalScrollIndicator:false,children:Ot.map(y=>{let P=It(y.chain_id,y.chain_type),M=c===P;return jsxs(TouchableOpacity,{onPress:()=>{T(P),fe(false);},style:[s.sheetItem,{backgroundColor:M?n.card:"transparent"}],children:[jsx(Image,{source:{uri:L(K(y,"png"))},style:s.sheetItemIcon}),jsxs(View,{style:s.sheetItemText,children:[jsx(Text,{style:[s.sheetItemTitle,{color:n.foreground}],children:y.chain_name}),jsxs(Text,{style:[s.sheetItemSubtitle,{color:n.foregroundMuted}],children:["Min deposit: $",y.minimum_deposit_amount_usd]})]}),M&&jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},P)})})]});return jsxs(View,{style:s.container,children:[jsxs(View,{style:s.selectorSection,children:[jsx(Text,{style:[s.selectorLabel,{color:n.foregroundMuted}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>Le(true),style:[s.selector,{backgroundColor:n.card}],children:[Ye&&jsx(Image,{source:{uri:L(K(Ye,"png"))},style:s.selectorIcon}),jsx(Text,{style:[s.selectorText,{color:n.foreground}],children:V}),jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxs(View,{style:s.selectorSection,children:[jsxs(Text,{style:[s.selectorLabel,{color:n.foregroundMuted}],children:["Network"," ",jsxs(Text,{style:s.minDeposit,children:["($",re," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>fe(true),style:[s.selector,{backgroundColor:n.card}],children:[he&&jsx(Image,{source:{uri:L(K(he,"png"))},style:s.selectorIcon}),jsx(Text,{style:[s.selectorText,{color:n.foreground}],numberOfLines:1,children:he?.chain_name||"Select network"}),jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:s.qrContainer,children:jsx(View,{style:[s.qrWrapper,{backgroundColor:n.background,borderColor:n.border}],children:B?jsxs(View,{style:s.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:n.primary}),jsx(Text,{style:[s.loadingText,{color:n.foregroundMuted}],children:"Loading..."})]}):be?jsx(Tt,{value:be,size:160,logoUri:L(K(he,"png")||le("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:s.qrLoading,children:jsx(Text,{style:[s.errorText,{color:n.error}],children:"No address available"})})})}),jsxs(View,{style:s.addressSection,children:[jsxs(View,{style:s.addressHeader,children:[jsx(Text,{style:[s.addressLabel,{color:n.foregroundMuted}],children:"Deposit Address"}),G&&jsxs(View,{style:s.copiedIndicator,children:[jsx(ie,{size:14,color:n.success,strokeWidth:2}),jsx(Text,{style:[s.copiedText,{color:n.success}],children:"Copied"})]})]}),jsx(TouchableOpacity,{onPress:Ke,disabled:!be||B,activeOpacity:.7,style:[s.addressBox,{backgroundColor:n.card}],children:jsx(Text,{style:[s.addressText,{color:n.foreground}],numberOfLines:2,children:B?"Loading...":be||"No address available"})})]}),jsxs(View,{style:[s.detailsCard,{backgroundColor:n.card}],children:[jsxs(TouchableOpacity,{onPress:()=>E(!oe),style:s.detailsHeader,children:[jsxs(View,{style:s.detailsRow,children:[jsx(View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Zo,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Price impact:"," ",jsxs(Text,{style:{color:n.foreground},children:[f.toFixed(2),"%"]})]})]}),jsx(View,{style:s.chevronContainer,children:oe?jsx(Zt,{size:16,color:n.foregroundMuted,strokeWidth:2}):jsx(me,{size:16,color:n.foregroundMuted,strokeWidth:2})})]}),oe&&jsxs(View,{style:s.detailsContent,children:[jsxs(View,{style:s.detailsRow,children:[jsx(View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Jo,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Max slippage:"," ",jsxs(Text,{style:{color:n.foreground},children:["Auto \u2022 ",R.toFixed(2),"%"]})]})]}),jsxs(View,{style:s.detailsRow,children:[jsx(View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsx(kt,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Processing time:"," ",jsx(Text,{style:{color:n.foreground},children:"< 1 min"})]})]}),jsxs(View,{style:s.detailsRow,children:[jsx(View,{style:[s.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Xo,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[s.detailsLabel,{color:n.foregroundMuted}],children:["Need help?"," ",jsx(Text,{style:{color:n.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(View,{style:s.spacer}),jsx(TouchableOpacity,{style:s.termsContainer,children:jsx(Text,{style:[s.termsText,{color:n.foregroundMuted}],children:"Terms apply"})}),yt(),jt(),ke&&jsx(_t,{visible:We,status:ke.status,tokenIconUrl:ke.destination_token_metadata?.icon_urls?.find(y=>y.format==="png")?.url||ke.destination_token_metadata?.icon_url||K(Ye,"png"),explorerUrl:ke.explorer_url,completionExplorerUrl:ke.destination_explorer_url,onClose:()=>Ft(false)})]})}var s=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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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,flex:1},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center",paddingVertical:16},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingBottom:12},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"600",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}});function Rt({currency:e,isSelected:t,onSelect:o}){let{colors:r}=_();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Oe.container,{backgroundColor:r.card}],children:[jsxs(View,{style:Oe.leftContent,children:[jsx(View,{style:[Oe.iconContainer,{backgroundColor:r.background}],children:jsx(Image,{source:{uri:L(K(e,"png"))},style:Oe.icon})}),jsxs(View,{style:Oe.textContainer,children:[jsx(Text,{style:[Oe.name,{color:r.foreground}],children:e.name}),jsx(Text,{style:[Oe.code,{color:r.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(ie,{size:16,color:r.foreground,strokeWidth:2})]})}var Oe=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 pt({title:e,currencies:t,selectedCurrency:o,onSelect:r}){let{colors:l}=_();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:pr.headerContainer,children:jsx(Text,{style:[pr.title,{color:l.foregroundMuted}],children:e})}),t.map(i=>jsx(Rt,{currency:i,isSelected:o.toLowerCase()===i.currency_code.toLowerCase(),onSelect:r},i.currency_code))]})}var pr=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Pt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:r,selectedCurrency:l,onSelectCurrency:i}){let{colors:a}=_(),[m,h]=useState(""),n=r.map(B=>o.find(W=>W.currency_code.toLowerCase()===B.toLowerCase())).filter(B=>B!==void 0),V=o.filter(B=>!r.includes(B.currency_code.toLowerCase())),w=B=>{if(!m)return B;let W=m.toLowerCase();return B.filter(b=>b.name.toLowerCase().includes(W)||b.currency_code.toLowerCase().includes(W))},c=w(n),T=w(V),N=B=>{i(B),t(false),h("");},q=()=>{t(false),h("");};return jsxs(Y,{visible:e,onClose:q,closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:"Currency",showBack:false,onClose:q}),jsx(View,{style:je.searchContainer,children:jsx(TextInput,{style:[je.searchInput,{backgroundColor:a.card,color:a.foreground}],value:m,onChangeText:h,placeholder:"Search",placeholderTextColor:a.foregroundMuted})}),jsx(ScrollView,{style:je.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:je.listContent,children:[jsx(pt,{title:"Popular currencies",currencies:c,selectedCurrency:l,onSelect:N}),c.length>0&&T.length>0&&jsx(View,{style:je.sectionSpacer}),jsx(pt,{title:"All currencies",currencies:T,selectedCurrency:l,onSelect:N}),c.length===0&&T.length===0&&jsx(View,{style:je.noResultsContainer,children:jsx(Text,{style:[je.noResultsText,{color:a.foregroundMuted}],children:"No currencies found"})})]})})]})}var je=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}});var Tn=[100,500,1e3];function mr(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 Lt({userId:e,publishableKey:t,view:o,onViewChange:r,maxAmountUsd:l=5e4,destinationTokenSymbol:i="USDC",recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onDepositSuccess:V,onDepositError:w}){let{colors:c}=_(),[T,N]=useState("500.00"),[q,B]=useState("usd"),[W,b]=useState([]),[p,$]=useState(false),[U,G]=useState(null),[te,oe]=useState("amount"),[E,Ne]=useState(null),[Le,ft]=useState([]),[fe,qe]=useState(true),[gt,Be]=useState(60),[$e,Ee]=useState([]),[zt,Qe]=useState([]),[We,Ft]=useState(null),[ke,Ut]=useState(false),[mt,Ge]=useState(false),ht=o??te,po=$e.find(f=>f.currency_code.toLowerCase()===q.toLowerCase()),fo=useCallback(f=>{oe(f),f==="quotes"?r?.(f,W.length):r?.(f);},[W.length,r]);useEffect(()=>{async function f(){try{let R=await Je({user_id:e,recipient_address:a,destination_chain_type:m,destination_chain_id:h,destination_token_address:n},t);ft(R.data);}catch(R){console.error("Error fetching wallets:",R),G("Failed to load wallet addresses");}finally{qe(false);}}f();},[e,a,m,h,n,t]),useEffect(()=>{async function f(){try{let R=await Gt(t);Ee(R.data),Qe(R.preferred||[]);}catch(R){console.error("Error fetching fiat currencies:",R);}}f();},[t]),useEffect(()=>{let f=parseFloat(T);if(isNaN(f)||f<=0){b([]);return}if(q.toLowerCase()==="usd"&&f>l){b([]),G(`Maximum amount is ${mr("usd")}${l.toLocaleString()}`);return}let R=setTimeout(()=>{go(f);},500);return ()=>clearTimeout(R)},[T,q,l,t]);let go=async f=>{$(true),G(null);try{let R={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:f.toString(),source_currency_code:q.toLowerCase()},re=await $t(R,t);if(b(re.data),re.data.length>0){let yt=re.data.reduce((jt,y)=>y.destination_amount>jt.destination_amount?y:jt);Ne(yt);}Be(60);}catch(R){console.error("Failed to fetch quotes:",R),G("Failed to fetch quotes. Please try again."),b([]);}finally{$(false);}};useEffect(()=>{if(W.length===0)return;let f=setInterval(()=>{Be(R=>{if(R<=1){let re=parseFloat(T);return !isNaN(re)&&re>0&&go(re),60}return R-1});},1e3);return ()=>clearInterval(f)},[W.length,T]);let be=f=>{(/^\d*\.?\d{0,2}$/.test(f)||f==="")&&N(f);},Ye=f=>{N(f.toFixed(2));},Ot=()=>E?E.destination_amount.toFixed(2):"0.00",he=async()=>{if(E)try{let f=Xe(Le,"ethereum");if(!f?.address){G("Wallet address not available");return}let R={service_provider:E.service_provider,country_code:E.country_code.toUpperCase(),destination_currency_code:E.destination_currency_code,source_currency_code:E.source_currency_code,wallet_address:f.address,source_amount:T},re=await Qt(R,t);Ft({provider:E,sourceCurrency:q,sourceAmount:T}),Linking.openURL(re.widget_url),fo("onramp");}catch(f){console.error("Failed to create session:",f),G("Failed to start payment flow"),w?.({message:"Failed to start payment flow",error:f});}},Ke=mr(q);return ht==="amount"?jsxs(View,{style:u.container,children:[jsx(View,{style:u.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>Ut(true),style:[u.currencyButton,{backgroundColor:c.card}],children:[po&&jsx(Image,{source:{uri:L(K(po,"png"))},style:u.currencyIcon}),jsx(Text,{style:[u.currencyText,{color:c.foreground}],children:q.toUpperCase()}),jsx(me,{size:16,color:c.foregroundMuted,strokeWidth:2})]})}),jsx(Pt,{open:ke,onOpenChange:Ut,currencies:$e,preferredCurrencyCodes:zt,selectedCurrency:q,onSelectCurrency:f=>{B(f.toLowerCase());}}),jsxs(View,{style:u.amountContainer,children:[jsxs(View,{style:u.amountInputRow,children:[jsx(Text,{style:[u.currencySymbol,{color:c.foreground}],children:Ke}),jsx(TextInput,{style:[u.amountInput,{color:c.foreground}],value:T,onChangeText:be,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:c.foregroundMuted})]}),p?jsx(ActivityIndicator,{size:"small",color:c.primary}):jsxs(Text,{style:[u.usdcPreview,{color:c.foregroundMuted}],children:["\u2248 ",Ot()," ",i]})]}),jsx(View,{style:u.quickAmounts,children:Tn.map(f=>jsx(TouchableOpacity,{onPress:()=>Ye(f),style:[u.quickAmountButton,{backgroundColor:c.card},parseFloat(T)===f&&{borderColor:c.primary,borderWidth:2}],children:jsxs(Text,{style:[u.quickAmountText,{color:c.foreground}],children:[Ke,f.toLocaleString()]})},f))}),jsxs(View,{style:u.providerSection,children:[jsxs(View,{style:u.providerHeader,children:[jsx(Text,{style:[u.providerLabel,{color:c.foreground}],children:"Provider"}),W.length>0&&!p&&jsxs(Text,{style:[u.refreshText,{color:c.foregroundMuted}],children:["Refreshing in ",gt,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>Ge(true),disabled:p||W.length===0,style:[u.providerButton,{backgroundColor:c.card},(p||W.length===0)&&u.disabled],children:p?jsxs(View,{style:u.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:c.foregroundMuted}),jsx(Text,{style:[u.loadingText,{color:c.foregroundMuted}],children:"Finding best rates..."})]}):E?jsxs(View,{style:u.providerContent,children:[jsxs(View,{style:u.providerInfo,children:[jsx(Text,{style:[u.autoPickedText,{color:c.foregroundMuted}],children:"Auto-picked for you"}),jsxs(View,{style:u.providerRow,children:[jsx(ae,{uri:L(E.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[u.providerName,{color:c.foreground}],children:E.service_provider_display_name}),jsxs(Text,{style:[u.bestPriceText,{color:c.success}],children:["Best price \u2022 ",E.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(nt,{size:20,color:c.foregroundMuted,strokeWidth:2})]}):jsx(Text,{style:[u.noProviderText,{color:c.foregroundMuted}],children:parseFloat(T)>0?"No providers available":"Enter an amount to see providers"})}),U&&jsx(Text,{style:[u.errorText,{color:c.error}],children:U})]}),jsx(TouchableOpacity,{onPress:he,disabled:p||fe||!E||parseFloat(T)<=0,style:[u.continueButton,{backgroundColor:c.primary},(p||fe||!E)&&u.disabledButton],children:jsx(Text,{style:u.continueButtonText,children:fe?"Loading...":`Buy ${i}`})}),jsxs(Y,{visible:mt,onClose:()=>Ge(false),closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:"Select Provider",showBack:false,onClose:()=>Ge(false),badge:W.length>0?{count:W.length}:void 0}),jsx(ScrollView,{style:u.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:u.quotesList,children:[...W].sort((f,R)=>R.destination_amount-f.destination_amount).map((f,R)=>{let re=E?.service_provider===f.service_provider,yt=R===0;return jsxs(TouchableOpacity,{onPress:()=>{Ne(f),Ge(false);},style:[u.quoteItem,{backgroundColor:c.card},re&&{borderColor:c.primary,borderWidth:2}],children:[jsxs(View,{style:u.quoteLeft,children:[jsx(ae,{uri:L(f.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[u.quoteName,{color:c.foreground}],children:f.service_provider_display_name}),yt&&jsx(Text,{style:[u.bestPriceLabel,{color:c.success}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:u.quoteRight,children:[jsxs(Text,{style:[u.quoteAmount,{color:c.foreground}],children:[f.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[u.quoteSource,{color:c.foregroundMuted}],children:["Fee: ",Ke,f.total_fee.toFixed(2)]})]})]},f.service_provider)})})})]})]}):ht==="onramp"&&We?jsxs(View,{style:[u.container,u.onrampContainer],children:[jsx(ae,{uri:L(We.provider.icon_url),width:48,height:48,borderRadius:12}),jsxs(Text,{style:[u.onrampTitle,{color:c.foreground}],children:["Complete on ",We.provider.service_provider_display_name]}),jsx(Text,{style:[u.onrampSubtitle,{color:c.foregroundMuted}],children:"You can close this modal. Your deposit will be processed automatically."}),jsxs(View,{style:[u.flowDiagram,{backgroundColor:c.card}],children:[jsxs(View,{style:u.flowStep,children:[jsx(Image,{source:{uri:le(`/icons/currencies/png/${We.sourceCurrency.toLowerCase()}.png`)},style:u.flowIconImage}),jsx(Text,{style:[u.flowLabel,{color:c.foregroundMuted}],children:"You pay"}),jsxs(Text,{style:[u.flowValue,{color:c.foreground}],children:[Ke,We.sourceAmount]})]}),jsx(nt,{size:20,color:c.foregroundMuted,strokeWidth:2}),jsxs(View,{style:u.flowStep,children:[jsx(Image,{source:{uri:le("/icons/tokens/png/usdc.png")},style:u.flowIconImage}),jsx(Text,{style:[u.flowLabel,{color:c.foregroundMuted}],children:"You get"}),jsx(Text,{style:[u.flowValue,{color:c.foreground}],children:i})]})]})]}):null}var u=StyleSheet.create({container:{padding: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"},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:8},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:16,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:{alignItems:"center",paddingTop:24},onrampIcon:{width:64,height:64,borderRadius:16,marginBottom:16},onrampTitle:{fontSize:20,fontWeight:"500",textAlign:"center",marginBottom:8},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",padding:16,borderRadius:12,width:"100%"},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 vn(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 Dn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Bt({execution:e,onPress:t}){let {colors:o}=_(),r=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let i=L(K(e.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),a=r?"Deposit Processing":"Deposit Completed",m=vn(e.created_at||new Date().toISOString()),h=Dn(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[we.container,{backgroundColor:o.card}],children:[jsxs(View,{style:we.iconContainer,children:[jsx(Image,{source:{uri:i},style:we.tokenIcon}),jsx(View,{style:[we.statusBadge,{backgroundColor:r?"#EAB308":"#22C55E"}],children:r?jsx(Jt,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(ie,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:we.textContainer,children:[jsx(Text,{style:[we.title,{color:o.foreground}],children:a}),jsx(Text,{style:[we.dateTime,{color:o.foregroundMuted}],children:m})]}),jsxs(View,{style:we.rightContainer,children:[jsx(Text,{style:[we.amount,{color:o.foreground}],children:h}),jsx(nt,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var we=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,borderColor:"#1C1C1E"},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:Ln}=Dimensions.get("window");function Cr(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 xr(e,t=6){try{return e?(Number(e)/Math.pow(10,t)).toFixed(2):"0.00"}catch{return "0.00"}}function Bn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function kr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function En(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 Et({visible:e,onClose:t,executions:o,userId:r,publishableKey:l}){let{colors:i}=_(),[a,m]=useState(o),[h,n]=useState(false),[V,w]=useState(null),[c,T]=useState(false);useEffect(()=>{if(!e||!r)return;let p=async()=>{n(true);try{let G=[...(await et(r,l)).data].sort((te,oe)=>{let E=te.created_at?new Date(te.created_at).getTime():0;return (oe.created_at?new Date(oe.created_at).getTime():0)-E});m(G);}catch(U){console.error("Failed to fetch executions:",U),m(o);}finally{n(false);}};p();let $=setInterval(p,1e4);return ()=>clearInterval($)},[e,r,l,o]),useEffect(()=>{o.length>0&&m(p=>{let $=new Set(p.map(G=>G.id)),U=o.filter(G=>!$.has(G.id));return U.length>0?[...U,...p]:p});},[o]),useEffect(()=>{e||w(null);},[e]);let N=p=>{w(p);},q=()=>{w(null),T(false);},B=()=>{w(null),t();};return jsxs(Y,{visible:e,onClose:B,closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:V?"Deposit Details":"Deposit Tracker",onClose:B,showClose:!V,showBack:!!V,onBack:q}),V?(()=>{if(!V)return null;let p=V,$=p.status==="pending"||p.status==="waiting"||p.status==="delayed",U=p.status==="succeeded",G=L(K(p.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),te=p.provider_metadata?.details,oe=te?.currencyIn,E=te?.currencyOut;oe?.currency?.symbol||"USDC";E?.currency?.symbol||"USDC";let ft=xr(p.source_amount_base_unit),fe=xr(p.destination_amount_base_unit),qe=Bn(p.source_amount_usd),gt=Cr(p.source_chain_type,p.source_chain_id),Be=Cr(p.destination_chain_type,p.destination_chain_id),$e=()=>{p.explorer_url&&Linking.openURL(p.explorer_url);},Ee=()=>{p.destination_explorer_url&&Linking.openURL(p.destination_explorer_url);};return jsxs(ScrollView,{style:g.scrollContainer,contentContainerStyle:g.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:g.iconSection,children:[jsxs(View,{style:g.iconWrapper,children:[jsx(Image,{source:{uri:G},style:g.tokenIcon}),jsx(View,{style:[g.statusBadge,{backgroundColor:$?"#EAB308":"#22C55E"}],children:$?jsx(me,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(ie,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:g.statusRow,children:[jsx(View,{style:[g.statusDot,{backgroundColor:$?"#EAB308":"#22C55E"}]}),jsx(Text,{style:[g.statusText,{color:i.foreground}],children:$?"Processing":"Completed"})]}),jsx(Text,{style:[g.dateText,{color:i.foregroundMuted}],children:En(p.created_at||new Date().toISOString())})]}),jsxs(View,{style:[g.card,{backgroundColor:i.card}],children:[jsxs(View,{style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Amount Sent"}),jsxs(Text,{style:[g.cardValue,{color:i.foreground}],children:[ft," ",kr(p.source_currency)]})]}),jsx(View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Amount Received"}),jsxs(Text,{style:[g.cardValue,{color:i.foreground}],children:[fe," ",kr(p.destination_currency)]})]}),jsx(View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"USD Value"}),jsx(Text,{style:[g.cardValue,{color:i.foreground}],children:qe})]}),jsx(View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Source Network"}),jsx(Text,{style:[g.cardValue,{color:i.foreground}],children:gt})]}),jsx(View,{style:[g.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Destination Network"}),jsx(Text,{style:[g.cardValue,{color:i.foreground}],children:Be})]})]}),jsxs(TouchableOpacity,{onPress:()=>T(!c),style:g.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[g.toggleText,{color:i.foregroundMuted}],children:c?"See less":"See more details"}),c?jsx(Zt,{size:14,color:i.foregroundMuted,strokeWidth:2}):jsx(me,{size:14,color:i.foregroundMuted,strokeWidth:2})]}),c&&jsxs(View,{style:[g.card,{backgroundColor:i.card}],children:[p.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:$e,style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Deposit Tx"}),jsxs(View,{style:g.cardRowRight,children:[jsx(Text,{style:[g.cardValue,{color:i.foreground}],children:wr(p.transaction_hash)}),jsx(Kt,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:[g.cardDivider,{backgroundColor:i.border}]})]}),p.destination_explorer_url&&U&&jsxs(TouchableOpacity,{onPress:Ee,style:g.cardRow,children:[jsx(Text,{style:[g.cardLabel,{color:i.foregroundMuted}],children:"Completion Tx"}),jsxs(View,{style:g.cardRowRight,children:[jsx(Text,{style:[g.cardValue,{color:i.foreground}],children:wr(p.destination_transaction_hashes[0])}),jsx(Kt,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:g.scrollContainer,contentContainerStyle:g.scrollContent,showsVerticalScrollIndicator:false,children:a.length===0?jsxs(View,{style:g.emptyContainer,children:[jsx(Text,{style:[g.emptyText,{color:i.foregroundMuted}],children:"No deposits yet"}),jsx(Text,{style:[g.emptySubtext,{color:i.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsx(View,{style:g.executionsList,children:a.map(p=>jsx(Bt,{execution:p,onPress:()=>N(p)},p.id))})})]})}var g=StyleSheet.create({scrollContainer:{maxHeight:Ln*.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,borderColor:"#1C1C1E"},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}});var He={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 zn({visible:e,onClose:t,userId:o,publishableKey:r,modalTitle:l="Deposit",destinationTokenSymbol:i,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,hideDepositTracker:V=false,onDepositSuccess:w,onDepositError:c}){let[T,N]=useState([]),[q,B]=useState(false),[W,b]=useState(false),[p,$]=useState(false),[U,G]=useState(null);useEffect(()=>{e&&!U&&Yt(r).then(G).catch(console.error);},[e,U,r]);let te=()=>{t();},oe=T.filter(E=>E.status==="pending"||E.status==="waiting").length;return jsxs(Y,{visible:e,onClose:te,closeOnBackdropPress:false,showHandle:false,children:[jsx(se,{title:l,showBack:false,onClose:te}),jsxs(View,{style:At.optionsContainer,children:[jsx(at,{onPress:()=>b(true),title:He.transferCrypto.title,subtitle:He.transferCrypto.subtitle,featuredTokens:U?.transfer_crypto?.networks}),jsx(ct,{onPress:()=>$(true),title:He.depositWithCard.title,subtitle:He.depositWithCard.subtitle,paymentNetworks:U?.payment_networks?.networks}),!V&&jsx(dt,{onPress:()=>B(true),title:He.depositTracker.title,subtitle:He.depositTracker.subtitle,badge:oe>0?oe:void 0})]}),jsx(Et,{visible:q,onClose:()=>B(false),executions:T,userId:o,publishableKey:r}),jsxs(Y,{visible:W,onClose:()=>b(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsx(se,{title:He.transferCrypto.title,showBack:false,onClose:()=>b(false)}),jsx(ScrollView,{style:At.transferScrollContainer,contentContainerStyle:At.scrollContent,showsVerticalScrollIndicator:false,children:jsx(vt,{userId:o,publishableKey:r,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onExecutionsChange:N,onDepositSuccess:w,onDepositError:c})})]}),jsxs(Y,{visible:p,onClose:()=>$(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsx(se,{title:"Add Funds",showBack:false,onClose:()=>$(false)}),jsx(ScrollView,{style:At.transferScrollContainer,contentContainerStyle:At.scrollContent,showsVerticalScrollIndicator:false,children:jsx(Lt,{userId:o,publishableKey:r,destinationTokenSymbol:i,recipientAddress:a,destinationChainType:m,destinationChainId:h,destinationTokenAddress:n,onDepositSuccess:w,onDepositError:c})})]})]})}function Mt({theme:e="auto",...t}){return jsx(Ze,{mode:e,children:jsx(zn,{...t})})}var At=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});function Eo({uri:e,size:t=24,style:o,borderRadius:r}){return jsx(Image,{source:{uri:e},style:[jn.icon,{width:t,height:t,borderRadius:r??t/2},o],resizeMode:"contain"})}var jn=StyleSheet.create({icon:{backgroundColor:"transparent"}});var Kn=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),Sr=createContext(null);function Zn({children:e,publishableKey:t,config:o}){let[r]=useState(()=>Kn()),[l,i]=useState(false),[a,m]=useState(null),h=useColorScheme(),n=useRef(false);n.current||(xt({publishableKey:t}),n.current=true);let V=useMemo(()=>{let b=o?.appearance||"dark";return b==="auto"?h==="dark"?"dark":"light":b},[o?.appearance,h]);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.'),xt({publishableKey:t});},[t]);let w=useRef(null),c=useRef(null),T=useCallback(b=>{console.log("[UnifoldProvider] beginDeposit called with:",b),c.current&&(clearTimeout(c.current),c.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let p=new Promise(($,U)=>{w.current={resolve:$,reject:U};});return m(b),i(true),p},[]),N=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),i(false),c.current=setTimeout(()=>{m(null),c.current=null;},200);},[]),q=useCallback(b=>{console.log("[UnifoldProvider] Deposit success:",b),a?.onSuccess&&a.onSuccess(b),w.current&&(w.current.resolve(b),w.current=null);},[a]),B=useCallback(b=>{console.error("[UnifoldProvider] Deposit error:",b),a?.onError&&a.onError(b),w.current&&(w.current.reject(b),w.current=null);},[a]),W=useMemo(()=>({publishableKey:t,beginDeposit:T,closeDeposit:N}),[t,T,N]);return jsx(QueryClientProvider,{client:r,children:jsx(Sr.Provider,{value:W,children:jsxs(Ze,{mode:V,children:[e,a&&jsx(Mt,{visible:l,onClose:N,userId:a.userId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:a.destinationTokenSymbol,recipientAddress:a.recipientAddress,destinationChainId:a.destinationChainId,destinationTokenAddress:a.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:q,onDepositError:B,theme:V})]})})})}function Jn(){let e=useContext(Sr);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}export{Y as BottomSheet,Lt as BuyWithCard,Rt as CurrencyListItem,pt as CurrencyListSection,Pt as CurrencyModal,Bt as DepositExecutionItem,se as DepositHeader,Mt as DepositModal,_t as DepositStatusSheet,dt as DepositTrackerButton,ct as DepositWithCardButton,Et as DepositsModal,Me as ExecutionStatus,Eo as Icon,Tt as QRCode,ae as RemoteIcon,Ho as SOLANA_USDC_ADDRESS,Ze as ThemeProvider,vt as TransferCrypto,at as TransferCryptoButton,Zn as UnifoldProvider,mo as createDepositAddress,Je as createEOA,Qt as createMeldSession,Oo as getApiBaseUrl,$o as getChainName,Gt as getFiatCurrencies,le as getIconUrl,jo as getIconUrlWithCdn,$t as getMeldQuotes,K as getPreferredIcon,No as getPreferredIconUrl,Yt as getProjectConfig,qt as getSupportedDepositTokens,qo as getTokenChains,Xe as getWalletByChainType,L as normalizeIconUrl,et as queryExecutions,xt as setApiConfig,Uo as setDevApiUrl,_ as useTheme,Jn as useUnifold};
1
+ import {createContext,useMemo,useContext,useRef,useEffect,useState,useCallback}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,Animated,Modal,View,TouchableWithoutFeedback,TouchableOpacity,Text,Image,Easing,ActivityIndicator,TextInput,ScrollView,Linking,Clipboard}from'react-native';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {jsx,jsxs}from'react/jsx-runtime';import ee,{SvgUri,Line,Polyline,Path,Rect,Circle}from'react-native-svg';import Jr from'react-native-qrcode-svg';var zo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Pr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Fo=createContext({colors:zo,isDark:false,mode:"auto"});function ot({children:e,mode:t="auto"}){let o=useColorScheme(),r=useMemo(()=>{let a;return t==="auto"?a=o==="dark":a=t==="dark",{colors:a?Pr:zo,isDark:a,mode:t}},[t,o]);return jsx(Fo.Provider,{value:r,children:e})}function _(){let e=useContext(Fo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Lr="https://api.unifold.io",Qt,Ie="pk_test_123",$t={};function ne(){return typeof __DEV__<"u"&&__DEV__&&Qt?Qt:Lr}function Tt(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.'),Ie=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Qt=e.baseUrl),e.defaultConfig&&($t=e.defaultConfig);}function Uo(e){typeof __DEV__<"u"&&__DEV__?(Qt=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oo(){return ne()}function Fe(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 le(e){let t=e.startsWith("/")?e:`/${e}`;return `${ne()}/api/public${t}`}function Ho(e,t){if(!t)return le(e);let o=e.startsWith("/")?e:`/${e}`;return `${t.endsWith("/")?t.slice(0,-1):t}/api/public${o}`}function W(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ne()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ne()}${e}`:`${ne()}/api/public${e}`:""}async function Co(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||$t.destinationChainId||"8453",destination_token_address:e?.destination_token_address||$t.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||$t.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},r=t||Ie;Fe(r);let a=await fetch(`${ne()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return a.json()}async function rt(e,t){return Co(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function nt(e,t){return e.find(o=>o.chain_type===t)}var Ue=(c=>(c.DELAYED="delayed",c.FAILED="failed",c.PENDING="pending",c.REFUNDED="refunded",c.SUCCEEDED="succeeded",c.WAITING="waiting",c))(Ue||{}),jo="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";async function it(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/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(!r.ok)throw new Error(`Failed to query executions: ${r.statusText}`);return r.json()}function J(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(r=>r.format===t);return o?o.url:e.icon_url}async function Gt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function Yt(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to fetch Meld quotes: ${r.statusText}`);return r.json()}async function Kt(e,t){let o=t||Ie;Fe(o);let r=await fetch(`${ne()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to create Meld session: ${r.statusText}`);return r.json()}async function Jt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/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 No(e,t="png"){if(!e||e.length===0)return;let o=e.find(r=>r.format===t);return o?o.url:e[0]?.url}async function Xt(e){let t=e||Ie;Fe(t);let o=await fetch(`${ne()}/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 qo(){let e=await fetch(`${ne()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function $o(e,t,o){let r=e.find(i=>i.chain_id===o);if(r)return r.chain_name;let a=e.find(i=>i.chain_type===t);return a?a.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}var{height:St}=Dimensions.get("window");function K({visible:e,onClose:t,children:o,closeOnBackdropPress:r=true,showHandle:a=true,heightPercent:i}){let{colors:c}=_(),m=useRef(new Animated.Value(St)).current,d=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(m.setValue(St),d.setValue(0),Animated.parallel([Animated.spring(m,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(d,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(m,{toValue:St,useNativeDriver:true,tension:65,friction:11}),Animated.timing(d,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,m,d]);let n=()=>{r&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(View,{style:Oe.container,children:[jsx(TouchableWithoutFeedback,{onPress:n,children:jsx(Animated.View,{style:[Oe.backdrop,{backgroundColor:"#000000",opacity:d}]})}),jsxs(Animated.View,{style:[Oe.sheet,{backgroundColor:c.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:m}],...i&&{height:St*i}}],children:[a&&jsx(View,{style:Oe.handleContainer,children:jsx(View,{style:[Oe.handle,{backgroundColor:c.border}]})}),jsx(View,{style:[Oe.content,i&&Oe.contentFlex],children:o})]})]})})}var Oe=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:St*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingVertical:12},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 wo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 _t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 ve({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 ct({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 de({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 ie({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 He({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 Ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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"})})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 lt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(ee,{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 eo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(ee,{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 se({title:e,showBack:t=false,showClose:o=true,onBack:r,onClose:a,badge:i}){let{colors:c}=_();return jsxs(View,{style:pe.header,children:[jsx(View,{style:pe.leftContainer,children:t&&r?jsx(TouchableOpacity,{onPress:r,style:[pe.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ko,{size:20,color:c.foreground,strokeWidth:2})}):jsx(View,{style:pe.spacer})}),jsxs(View,{style:pe.titleContainer,children:[jsx(Text,{style:[pe.title,{color:c.foreground}],children:e}),i&&i.count>0&&jsx(View,{style:[pe.titleBadge,{backgroundColor:c.card}],children:jsx(Text,{style:[pe.titleBadgeText,{color:c.foregroundMuted}],children:i.count})})]}),jsx(View,{style:pe.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[pe.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ve,{size:20,color:c.foreground,strokeWidth:2})}):jsx(View,{style:pe.spacer})})]})}var pe=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,fontWeight:"500",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 ae({uri:e,width:t,height:o,borderRadius:r=0,borderWidth:a=0,borderColor:i="transparent",backgroundColor:c="transparent",style:m}){let[d,n]=useState(false),D=e?.toLowerCase().endsWith(".svg");if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:r,backgroundColor:"#374151"},m]});let w={width:t,height:o,borderRadius:r,borderWidth:a,borderColor:i,backgroundColor:c,overflow:"hidden",alignItems:"center",justifyContent:"center",...m},s=t-a*2,S=o-a*2;return d?jsx(View,{style:[w,{backgroundColor:c||"#374151"}]}):D?jsx(View,{style:w,children:jsx(SvgUri,{uri:e,width:s,height:S,onError:U=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,U),n(true);}})}):jsx(View,{style:w,children:jsx(Image,{source:{uri:e},style:{width:s,height:S},resizeMode:"contain",onError:U=>{console.log(`[RemoteIcon] Image load error for ${e}:`,U.nativeEvent.error),n(true);}})})}function pt({onPress:e,title:t,subtitle:o,featuredTokens:r}){let{colors:a}=_(),i=r?[...r].sort((c,m)=>c.position-m.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ye.container,{backgroundColor:a.card}],children:[jsxs(View,{style:ye.leftContent,children:[jsx(View,{style:[ye.iconContainer,{backgroundColor:a.cardHover}],children:jsx(xo,{size:20,color:a.foreground,strokeWidth:2})}),jsxs(View,{style:ye.textContainer,children:[jsx(Text,{style:[ye.title,{color:a.foreground}],children:t}),jsx(Text,{style:[ye.subtitle,{color:a.foregroundMuted}],children:o})]})]}),jsx(View,{style:ye.rightContent,children:jsx(View,{style:ye.networkIcons,children:i.map((c,m)=>{let d=c.icon_urls.find(n=>n.format==="png")?.url||c.icon_urls.find(n=>n.format==="svg")?.url;return jsx(View,{style:[ye.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:i.length-m}],children:jsx(ae,{uri:W(d),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:a.card})},c.name)})})})]})}var ye=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 ft({onPress:e,title:t,subtitle:o,paymentNetworks:r}){let{colors:a}=_();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ve.container,{backgroundColor:a.card}],children:[jsxs(View,{style:Ve.leftContent,children:[jsx(View,{style:[Ve.iconContainer,{backgroundColor:a.cardHover}],children:jsx(wo,{size:20,color:a.foreground,strokeWidth:2})}),jsxs(View,{style:Ve.textContainer,children:[jsx(Text,{style:[Ve.title,{color:a.foreground}],children:t}),jsx(Text,{style:[Ve.subtitle,{color:a.foregroundMuted}],children:o})]})]}),jsx(View,{style:Ve.rightContent,children:jsx(View,{style:Ve.paymentIcons,children:r?.map(i=>{let c=i.icon_urls.find(m=>m.format==="png")?.url||i.icon_urls.find(m=>m.format==="svg")?.url;return jsx(ae,{uri:W(c),width:32,height:20,borderRadius:4},i.name)})})})]})}var Ve=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 ht({onPress:e,title:t,subtitle:o,badge:r}){let{colors:a}=_();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Le.container,{backgroundColor:a.card}],children:jsxs(View,{style:Le.leftContent,children:[jsxs(View,{style:[Le.iconContainer,{backgroundColor:a.cardHover}],children:[jsx(_t,{size:20,color:a.foreground,strokeWidth:2}),r!==void 0&&r>0&&jsx(View,{style:[Le.badge,{backgroundColor:a.primary}],children:jsx(Text,{style:Le.badgeText,children:r>99?"99+":r})})]}),jsxs(View,{style:Le.textContainer,children:[jsx(Text,{style:[Le.title,{color:a.foreground}],children:t}),jsx(Text,{style:[Le.subtitle,{color:a.foregroundMuted}],children:o})]})]})})}var Le=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 Dt({value:e,size:t=180,logoUri:o,logoSize:r=40,logoBackgroundColor:a}){let{colors:i,isDark:c}=_(),m=c?"#1a1a1a":"#ffffff",d=c?"#ffffff":"#000000",n=a||m;return jsxs(View,{style:[ir.container,{width:t,height:t}],children:[jsx(Jr,{value:e||"placeholder",size:t,backgroundColor:m,color:d,ecl:"H",quietZone:4}),o&&jsx(View,{style:[ir.logoContainer,{width:r+12,height:r+12,backgroundColor:n,borderRadius:(r+12)/2}],children:jsx(ae,{uri:o,width:r,height:r,borderRadius:r/2})})]})}var ir=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function ar(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function sn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=e.getDate(),a=e.getFullYear(),i=e.getHours(),c=e.getMinutes(),m=i>=12?"pm":"am";i=i%12,i=i||12;let d=c<10?`0${c}`:c;return `${o} ${r}, ${a} at ${i}:${d}${m}`}function vt({visible:e,status:t,tokenIconUrl:o,explorerUrl:r,completionExplorerUrl:a,date:i,amountUsd:c,onClose:m}){let{colors:d}=_(),n=useRef(new Animated.Value(0)).current,[D,w]=useState(false),s=t==="pending"||t==="waiting"||t==="delayed",S=t==="succeeded";useEffect(()=>{if(s&&e){let V=Animated.loop(Animated.timing(n,{toValue:1,duration:1e3,easing:Easing.linear,useNativeDriver:true}));return V.start(),()=>V.stop()}else n.setValue(0);},[s,e,n]);let U=n.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),O=()=>{r&&Linking.openURL(r);},P=()=>{a&&Linking.openURL(a);};return jsx(K,{visible:e,onClose:m,closeOnBackdropPress:true,showHandle:false,children:jsxs(View,{style:H.container,children:[jsx(TouchableOpacity,{style:H.closeButton,onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ve,{size:20,color:d.foregroundMuted,strokeWidth:2})}),jsxs(View,{style:H.iconContainer,children:[o?jsx(Image,{source:{uri:W(o)},style:H.tokenIcon}):jsx(View,{style:[H.tokenIcon,{backgroundColor:d.cardHover}]}),jsx(View,{style:[H.statusBadge,{backgroundColor:s?"#F97316":"#22C55E"}],children:s?jsx(Animated.View,{style:{transform:[{rotate:U}]},children:jsx(eo,{size:16,color:"#fff",strokeWidth:2.5})}):jsx(ie,{size:16,color:"#fff",strokeWidth:3})})]}),jsx(Text,{style:[H.title,{color:d.foreground}],children:s?"Deposit Processing":"Deposit Complete"}),c!==void 0&&jsxs(Text,{style:[H.amount,{color:d.foreground}],children:["$",c.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),i&&jsx(Text,{style:[H.date,{color:d.foregroundMuted}],children:sn(i)}),jsx(Text,{style:[H.subtitle,{color:d.foregroundMuted}],children:s?"This usually takes less than a minute.":"Your account has been credited successfully!"}),S&&(r||a)&&jsxs(View,{style:H.detailsSection,children:[jsx(View,{style:[H.divider,{backgroundColor:d.border}]}),jsxs(TouchableOpacity,{style:H.detailsToggle,onPress:()=>w(!D),children:[jsx(Text,{style:[H.detailsToggleText,{color:d.foregroundMuted}],children:D?"See less":"See more details"}),D?jsx(lt,{size:18,color:d.foregroundMuted,strokeWidth:2}):jsx(de,{size:18,color:d.foregroundMuted,strokeWidth:2})]}),D&&jsxs(View,{style:H.txButtonsContainer,children:[r&&jsxs(TouchableOpacity,{style:[H.txButton,{backgroundColor:d.card,borderColor:d.border}],onPress:O,children:[jsx(Text,{style:[H.txLabel,{color:d.foreground}],children:"Deposit tx"}),jsx(Text,{style:[H.txHash,{color:d.foregroundMuted}],children:ar(r)}),jsx(He,{size:16,color:d.foregroundMuted,strokeWidth:2})]}),a&&jsxs(TouchableOpacity,{style:[H.txButton,{backgroundColor:d.card,borderColor:d.border}],onPress:P,children:[jsx(Text,{style:[H.txLabel,{color:d.foreground}],children:"Completion tx"}),jsx(Text,{style:[H.txHash,{color:d.foregroundMuted}],children:ar(a)}),jsx(He,{size:16,color:d.foregroundMuted,strokeWidth:2})]})]})]})]})})}var H=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},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 Rt=(e,t)=>`${t}:${e}`,ln=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Pt({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:r,destinationChainId:a,destinationTokenAddress:i,onExecutionsChange:c,onDepositSuccess:m,onDepositError:d}){let{colors:n}=_(),[D,w]=useState("USDC"),[s,S]=useState("solana:mainnet"),[U,O]=useState([]),[P,V]=useState(true),[b,f]=useState([]),[$,N]=useState(true),[Y,te]=useState(false),[oe,M]=useState(false),[Ye,Me]=useState(false),[yt,ge]=useState(false),[Ke,Ct]=useState([]),[Ee,Je]=useState(new Map),[Ae]=useState(()=>new Date),[Ot,Xe]=useState(null),[ze,Ht]=useState(false),[be,jt]=useState(null),xt=new Map;b.forEach(y=>{y.chains.forEach(B=>{let A=`${B.chain_type}:${B.chain_id}`;xt.has(A)||xt.set(A,B);});});let Ze=Array.from(xt.values()),wt=ln(s),mo=Ze.find(y=>y.chain_type===wt.chainType&&y.chain_id===wt.chainId)?.chain_type||"ethereum",Te=nt(U,mo)?.address||"";useEffect(()=>{async function y(){try{N(!0),Xe(null);let B=await Gt(t);if(f(B.data),B.data.length>0){let A=B.data[0];if(w(A.symbol),A.chains.length>0){let q=A.chains[0];S(Rt(q.chain_id,q.chain_type));}}}catch(B){console.error("Error fetching supported tokens:",B),Xe("Failed to load supported tokens"),d?.({message:"Failed to load supported tokens",error:B});}finally{N(false);}}y();},[t,d]),useEffect(()=>{async function y(){try{V(!0),Xe(null);let B=await rt({external_user_id:e,recipient_address:o,destination_chain_type:r,destination_chain_id:a,destination_token_address:i},t);O(B.data);}catch(B){console.error("Error fetching wallets:",B),Xe("Failed to load wallets"),d?.({message:"Failed to load wallets",error:B});}finally{V(false);}}y();},[e,o,r,a,i,t,d]),useEffect(()=>{if(!e||!Ae)return;let y=setInterval(async()=>{try{let B=await it(e,t),A=null;for(let q of B.data){let Se=q.created_at?new Date(q.created_at):null;if(!Se||Se<=Ae)continue;let _e=Ee.get(q.id);if(!_e){A=q;break}if(["pending","waiting","delayed"].includes(_e)&&q.status==="succeeded"){A=q;break}}if(A){let q=A;Ct(Se=>{let _e=Se.findIndex(bt=>bt.id===q.id);if(_e>=0){let bt=[...Se];return bt[_e]=q,bt}else return [...Se,q]}),Je(Se=>{let _e=new Map(Se);return _e.set(q.id,q.status),_e}),jt(q),Ht(!0),q.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:q.id}),c?.([...Ke,q]);}}catch(B){console.error("Error polling executions:",B),d?.({message:"Failed to check deposit status",error:B});}},5e3);return ()=>clearInterval(y)},[e,t,Ae,Ee,Ke,c,m,d]),useEffect(()=>{if(!b.length)return;let y=b.find(A=>A.symbol===D);if(!y||y.chains.length===0)return;if(!y.chains.some(A=>Rt(A.chain_id,A.chain_type)===s)){let A=y.chains[0];S(Rt(A.chain_id,A.chain_type));}},[D,b,s]);let et=b.find(y=>y.symbol===D),Nt=et?.chains||[],me=Nt.find(y=>Rt(y.chain_id,y.chain_type)===s),tt=async()=>{if(Te)try{Clipboard.setString(Te),te(!0),setTimeout(()=>te(!1),2e3);}catch(y){console.error("Failed to copy:",y);}},g=me?.estimated_price_impact_percent??0,L=me?.max_slippage_percent??.25,re=me?.minimum_deposit_amount_usd??3;if($)return jsxs(View,{style:l.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:n.primary}),jsx(Text,{style:[l.loadingText,{color:n.foregroundMuted}],children:"Loading currencies..."})]});if(Ot&&b.length===0)return jsxs(View,{style:l.errorContainer,children:[jsx(Text,{style:[l.errorText,{color:n.error}],children:Ot}),jsx(Text,{style:[l.errorHint,{color:n.foregroundMuted}],children:"Please check your network connection and try again."})]});let kt=()=>jsxs(K,{visible:Ye,onClose:()=>Me(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[l.sheetHeader,{borderBottomColor:n.border}],children:[jsx(View,{style:l.sheetHeaderSpacer}),jsx(Text,{style:[l.sheetTitle,{color:n.foreground}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>Me(false),style:l.sheetCloseButton,children:jsx(ve,{size:20,color:n.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:l.sheetList,showsVerticalScrollIndicator:false,children:b.map(y=>jsxs(TouchableOpacity,{onPress:()=>{w(y.symbol),Me(false);},style:[l.sheetItem,{backgroundColor:D===y.symbol?n.card:"transparent"}],children:[jsx(Image,{source:{uri:W(J(y,"png"))},style:l.sheetItemIcon}),jsxs(View,{style:l.sheetItemText,children:[jsx(Text,{style:[l.sheetItemTitle,{color:n.foreground}],children:y.symbol}),jsxs(Text,{style:[l.sheetItemSubtitle,{color:n.foregroundMuted}],children:[y.chains.length," network",y.chains.length!==1?"s":""," available"]})]}),D===y.symbol&&jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},y.symbol))})]}),qt=()=>jsxs(K,{visible:yt,onClose:()=>ge(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[l.sheetHeader,{borderBottomColor:n.border}],children:[jsx(View,{style:l.sheetHeaderSpacer}),jsx(Text,{style:[l.sheetTitle,{color:n.foreground}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>ge(false),style:l.sheetCloseButton,children:jsx(ve,{size:20,color:n.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:l.sheetList,showsVerticalScrollIndicator:false,children:Nt.map(y=>{let B=Rt(y.chain_id,y.chain_type),A=s===B;return jsxs(TouchableOpacity,{onPress:()=>{S(B),ge(false);},style:[l.sheetItem,{backgroundColor:A?n.card:"transparent"}],children:[jsx(Image,{source:{uri:W(J(y,"png"))},style:l.sheetItemIcon}),jsxs(View,{style:l.sheetItemText,children:[jsx(Text,{style:[l.sheetItemTitle,{color:n.foreground}],children:y.chain_name}),jsxs(Text,{style:[l.sheetItemSubtitle,{color:n.foregroundMuted}],children:["Min deposit: $",y.minimum_deposit_amount_usd]})]}),A&&jsx(ie,{size:20,color:n.primary,strokeWidth:2})]},B)})})]});return jsxs(View,{style:l.container,children:[jsxs(View,{style:l.selectorSection,children:[jsx(Text,{style:[l.selectorLabel,{color:n.foregroundMuted}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>Me(true),style:[l.selector,{backgroundColor:n.card}],children:[et&&jsx(Image,{source:{uri:W(J(et,"png"))},style:l.selectorIcon}),jsx(Text,{style:[l.selectorText,{color:n.foreground}],children:D}),jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsxs(View,{style:l.selectorSection,children:[jsxs(Text,{style:[l.selectorLabel,{color:n.foregroundMuted}],children:["Network"," ",jsxs(Text,{style:l.minDeposit,children:["($",re," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>ge(true),style:[l.selector,{backgroundColor:n.card}],children:[me&&jsx(Image,{source:{uri:W(J(me,"png"))},style:l.selectorIcon}),jsx(Text,{style:[l.selectorText,{color:n.foreground}],numberOfLines:1,children:me?.chain_name||"Select network"}),jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:l.qrContainer,children:jsx(View,{style:[l.qrWrapper,{backgroundColor:n.background,borderColor:n.border}],children:P?jsxs(View,{style:l.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:n.primary}),jsx(Text,{style:[l.loadingText,{color:n.foregroundMuted}],children:"Loading..."})]}):Te?jsx(Dt,{value:Te,size:160,logoUri:W(J(me,"png")||le("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:l.qrLoading,children:jsx(Text,{style:[l.errorText,{color:n.error}],children:"No address available"})})})}),jsxs(View,{style:l.addressSection,children:[jsxs(View,{style:l.addressHeader,children:[jsx(Text,{style:[l.addressLabel,{color:n.foregroundMuted}],children:"Deposit Address"}),Y&&jsxs(View,{style:l.copiedIndicator,children:[jsx(ie,{size:14,color:n.success,strokeWidth:2}),jsx(Text,{style:[l.copiedText,{color:n.success}],children:"Copied"})]})]}),jsx(TouchableOpacity,{onPress:tt,disabled:!Te||P,activeOpacity:.7,style:[l.addressBox,{backgroundColor:n.card}],children:jsx(Text,{style:[l.addressText,{color:n.foreground}],numberOfLines:2,children:P?"Loading...":Te||"No address available"})})]}),jsxs(View,{style:[l.detailsCard,{backgroundColor:n.card}],children:[jsxs(TouchableOpacity,{onPress:()=>M(!oe),style:l.detailsHeader,children:[jsxs(View,{style:l.detailsRow,children:[jsx(View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Ko,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Price impact:"," ",jsxs(Text,{style:{color:n.foreground},children:[g.toFixed(2),"%"]})]})]}),jsx(View,{style:l.chevronContainer,children:oe?jsx(lt,{size:16,color:n.foregroundMuted,strokeWidth:2}):jsx(de,{size:16,color:n.foregroundMuted,strokeWidth:2})})]}),oe&&jsxs(View,{style:l.detailsContent,children:[jsxs(View,{style:l.detailsRow,children:[jsx(View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Jo,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Max slippage:"," ",jsxs(Text,{style:{color:n.foreground},children:["Auto \u2022 ",L.toFixed(2),"%"]})]})]}),jsxs(View,{style:l.detailsRow,children:[jsx(View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsx(_t,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Processing time:"," ",jsx(Text,{style:{color:n.foreground},children:"< 1 min"})]})]}),jsxs(View,{style:l.detailsRow,children:[jsx(View,{style:[l.detailIcon,{backgroundColor:n.cardHover}],children:jsx(Xo,{size:12,color:n.foreground,strokeWidth:2})}),jsxs(Text,{style:[l.detailsLabel,{color:n.foregroundMuted}],children:["Need help?"," ",jsx(Text,{style:{color:n.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:l.termsContainer,children:jsx(Text,{style:[l.termsText,{color:n.foregroundMuted}],children:"Terms apply"})}),kt(),qt(),be&&jsx(vt,{visible:ze,status:be.status,tokenIconUrl:be.destination_token_metadata?.icon_urls?.find(y=>y.format==="png")?.url||be.destination_token_metadata?.icon_url||J(et,"png"),explorerUrl:be.explorer_url,completionExplorerUrl:be.destination_explorer_url,onClose:()=>Ht(false)})]})}var l=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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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,flex:1},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:"600",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}});function Lt({currency:e,isSelected:t,onSelect:o}){let{colors:r}=_();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[$e.container,{backgroundColor:r.card}],children:[jsxs(View,{style:$e.leftContent,children:[jsx(View,{style:[$e.iconContainer,{backgroundColor:r.background}],children:jsx(Image,{source:{uri:W(J(e,"png"))},style:$e.icon})}),jsxs(View,{style:$e.textContainer,children:[jsx(Text,{style:[$e.name,{color:r.foreground}],children:e.name}),jsx(Text,{style:[$e.code,{color:r.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(ie,{size:16,color:r.foreground,strokeWidth:2})]})}var $e=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 mt({title:e,currencies:t,selectedCurrency:o,onSelect:r}){let{colors:a}=_();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:pr.headerContainer,children:jsx(Text,{style:[pr.title,{color:a.foregroundMuted}],children:e})}),t.map(i=>jsx(Lt,{currency:i,isSelected:o.toLowerCase()===i.currency_code.toLowerCase(),onSelect:r},i.currency_code))]})}var pr=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Bt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:r,selectedCurrency:a,onSelectCurrency:i}){let{colors:c}=_(),[m,d]=useState(""),n=r.map(P=>o.find(V=>V.currency_code.toLowerCase()===P.toLowerCase())).filter(P=>P!==void 0),D=o.filter(P=>!r.includes(P.currency_code.toLowerCase())),w=P=>{if(!m)return P;let V=m.toLowerCase();return P.filter(b=>b.name.toLowerCase().includes(V)||b.currency_code.toLowerCase().includes(V))},s=w(n),S=w(D),U=P=>{i(P),t(false),d("");},O=()=>{t(false),d("");};return jsxs(K,{visible:e,onClose:O,closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:"Currency",showBack:false,onClose:O}),jsx(View,{style:Qe.searchContainer,children:jsx(TextInput,{style:[Qe.searchInput,{backgroundColor:c.card,color:c.foreground}],value:m,onChangeText:d,placeholder:"Search",placeholderTextColor:c.foregroundMuted})}),jsx(ScrollView,{style:Qe.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:Qe.listContent,children:[jsx(mt,{title:"Popular currencies",currencies:s,selectedCurrency:a,onSelect:U}),s.length>0&&S.length>0&&jsx(View,{style:Qe.sectionSpacer}),jsx(mt,{title:"All currencies",currencies:S,selectedCurrency:a,onSelect:U}),s.length===0&&S.length===0&&jsx(View,{style:Qe.noResultsContainer,children:jsx(Text,{style:[Qe.noResultsText,{color:c.foregroundMuted}],children:"No currencies found"})})]})})]})}var Qe=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}});var _n=[100,500,1e3];function mr(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 Mt({externalUserId:e,publishableKey:t,view:o,onViewChange:r,maxAmountUsd:a=5e4,destinationTokenSymbol:i="USDC",recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onDepositSuccess:D,onDepositError:w}){let{colors:s}=_(),[S,U]=useState("500.00"),[O,P]=useState("usd"),[V,b]=useState([]),[f,$]=useState(false),[N,Y]=useState(null),[te,oe]=useState("amount"),[M,Ye]=useState(null),[Me,yt]=useState([]),[ge,Ke]=useState(true),[Ct,Ee]=useState(60),[Je,Ae]=useState([]),[Ot,Xe]=useState([]),[ze,Ht]=useState(null),[be,jt]=useState(false),[xt,Ze]=useState(false),wt=o??te,ho=Je.find(g=>g.currency_code.toLowerCase()===O.toLowerCase()),mo=useCallback(g=>{oe(g),g==="quotes"?r?.(g,V.length):r?.(g);},[V.length,r]);useEffect(()=>{async function g(){try{let L=await rt({external_user_id:e,recipient_address:c,destination_chain_type:m,destination_chain_id:d,destination_token_address:n},t);yt(L.data);}catch(L){console.error("Error fetching wallets:",L),Y("Failed to load wallet addresses");}finally{Ke(false);}}g();},[e,c,m,d,n,t]),useEffect(()=>{async function g(){try{let L=await Jt(t);Ae(L.data),Xe(L.preferred||[]);}catch(L){console.error("Error fetching fiat currencies:",L);}}g();},[t]),useEffect(()=>{let g=parseFloat(S);if(isNaN(g)||g<=0){b([]);return}if(O.toLowerCase()==="usd"&&g>a){b([]),Y(`Maximum amount is ${mr("usd")}${a.toLocaleString()}`);return}let L=setTimeout(()=>{yo(g);},500);return ()=>clearTimeout(L)},[S,O,a,t]);let yo=async g=>{$(true),Y(null);try{let L={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:g.toString(),source_currency_code:O.toLowerCase()},re=await Yt(L,t);if(b(re.data),re.data.length>0){let kt=re.data.reduce((qt,y)=>y.destination_amount>qt.destination_amount?y:qt);Ye(kt);}Ee(60);}catch(L){console.error("Failed to fetch quotes:",L),Y("Failed to fetch quotes. Please try again."),b([]);}finally{$(false);}};useEffect(()=>{if(V.length===0)return;let g=setInterval(()=>{Ee(L=>{if(L<=1){let re=parseFloat(S);return !isNaN(re)&&re>0&&yo(re),60}return L-1});},1e3);return ()=>clearInterval(g)},[V.length,S]);let Te=g=>{(/^\d*\.?\d{0,2}$/.test(g)||g==="")&&U(g);},et=g=>{U(g.toFixed(2));},Nt=()=>M?M.destination_amount.toFixed(2):"0.00",me=async()=>{if(M)try{let g=nt(Me,"ethereum");if(!g?.address){Y("Wallet address not available");return}let L={service_provider:M.service_provider,country_code:M.country_code.toUpperCase(),destination_currency_code:M.destination_currency_code,source_currency_code:M.source_currency_code,wallet_address:g.address,source_amount:S},re=await Kt(L,t);Ht({provider:M,sourceCurrency:O,sourceAmount:S}),Linking.openURL(re.widget_url),mo("onramp");}catch(g){console.error("Failed to create session:",g),Y("Failed to start payment flow"),w?.({message:"Failed to start payment flow",error:g});}},tt=mr(O);return wt==="amount"?jsxs(ScrollView,{style:p.scrollContainer,contentContainerStyle:p.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:p.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>jt(true),style:[p.currencyButton,{backgroundColor:s.card}],children:[ho&&jsx(Image,{source:{uri:W(J(ho,"png"))},style:p.currencyIcon}),jsx(Text,{style:[p.currencyText,{color:s.foreground}],children:O.toUpperCase()}),jsx(de,{size:16,color:s.foregroundMuted,strokeWidth:2})]})}),jsx(Bt,{open:be,onOpenChange:jt,currencies:Je,preferredCurrencyCodes:Ot,selectedCurrency:O,onSelectCurrency:g=>{P(g.toLowerCase());}}),jsxs(View,{style:p.amountContainer,children:[jsxs(View,{style:p.amountInputRow,children:[jsx(Text,{style:[p.currencySymbol,{color:s.foreground}],children:tt}),jsx(TextInput,{style:[p.amountInput,{color:s.foreground}],value:S,onChangeText:Te,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:s.foregroundMuted})]}),f?jsx(ActivityIndicator,{size:"small",color:s.primary}):jsxs(Text,{style:[p.usdcPreview,{color:s.foregroundMuted}],children:["\u2248 ",Nt()," ",i]})]}),jsx(View,{style:p.quickAmounts,children:_n.map(g=>jsx(TouchableOpacity,{onPress:()=>et(g),style:[p.quickAmountButton,{backgroundColor:s.card},parseFloat(S)===g&&{borderColor:s.primary,borderWidth:2}],children:jsxs(Text,{style:[p.quickAmountText,{color:s.foreground}],children:[tt,g.toLocaleString()]})},g))}),jsxs(View,{style:p.providerSection,children:[jsxs(View,{style:p.providerHeader,children:[jsx(Text,{style:[p.providerLabel,{color:s.foreground}],children:"Provider"}),V.length>0&&!f&&jsxs(Text,{style:[p.refreshText,{color:s.foregroundMuted}],children:["Refreshing in ",Ct,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>Ze(true),disabled:f||V.length===0,style:[p.providerButton,{backgroundColor:s.card},(f||V.length===0)&&p.disabled],children:f?jsxs(View,{style:p.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:s.foregroundMuted}),jsx(Text,{style:[p.loadingText,{color:s.foregroundMuted}],children:"Finding best rates..."})]}):M?jsxs(View,{style:p.providerContent,children:[jsxs(View,{style:p.providerInfo,children:[jsx(Text,{style:[p.autoPickedText,{color:s.foregroundMuted}],children:"Auto-picked for you"}),jsxs(View,{style:p.providerRow,children:[jsx(ae,{uri:W(M.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[p.providerName,{color:s.foreground}],children:M.service_provider_display_name}),jsxs(Text,{style:[p.bestPriceText,{color:s.success}],children:["Best price \u2022 ",M.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(ct,{size:20,color:s.foregroundMuted,strokeWidth:2})]}):jsx(Text,{style:[p.noProviderText,{color:s.foregroundMuted}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),N&&jsx(Text,{style:[p.errorText,{color:s.error}],children:N})]}),jsx(TouchableOpacity,{onPress:me,disabled:f||ge||!M||parseFloat(S)<=0,style:[p.continueButton,{backgroundColor:s.primary},(f||ge||!M)&&p.disabledButton],children:jsx(Text,{style:p.continueButtonText,children:ge?"Loading...":`Buy ${i}`})}),jsxs(K,{visible:xt,onClose:()=>Ze(false),closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:"Select Provider",showBack:false,onClose:()=>Ze(false),badge:V.length>0?{count:V.length}:void 0}),jsx(ScrollView,{style:p.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:p.quotesList,children:[...V].sort((g,L)=>L.destination_amount-g.destination_amount).map((g,L)=>{let re=M?.service_provider===g.service_provider,kt=L===0;return jsxs(TouchableOpacity,{onPress:()=>{Ye(g),Ze(false);},style:[p.quoteItem,{backgroundColor:s.card},re&&{borderColor:s.primary,borderWidth:2}],children:[jsxs(View,{style:p.quoteLeft,children:[jsx(ae,{uri:W(g.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[p.quoteName,{color:s.foreground}],children:g.service_provider_display_name}),kt&&jsx(Text,{style:[p.bestPriceLabel,{color:s.success}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:p.quoteRight,children:[jsxs(Text,{style:[p.quoteAmount,{color:s.foreground}],children:[g.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[p.quoteSource,{color:s.foregroundMuted}],children:["Fee: ",tt,g.total_fee.toFixed(2)]})]})]},g.service_provider)})})})]})]}):wt==="onramp"&&ze?jsxs(View,{style:p.onrampContainer,children:[jsx(ae,{uri:W(ze.provider.icon_url),width:48,height:48,borderRadius:12}),jsxs(Text,{style:[p.onrampTitle,{color:s.foreground}],children:["Complete on ",ze.provider.service_provider_display_name]}),jsx(Text,{style:[p.onrampSubtitle,{color:s.foregroundMuted}],children:"You can close this modal. Your deposit will be processed automatically."}),jsxs(View,{style:[p.flowDiagram,{backgroundColor:s.card}],children:[jsxs(View,{style:p.flowStep,children:[jsx(Image,{source:{uri:le(`/icons/currencies/png/${ze.sourceCurrency.toLowerCase()}.png`)},style:p.flowIconImage}),jsx(Text,{style:[p.flowLabel,{color:s.foregroundMuted}],children:"You pay"}),jsxs(Text,{style:[p.flowValue,{color:s.foreground}],children:[tt,ze.sourceAmount]})]}),jsx(ct,{size:20,color:s.foregroundMuted,strokeWidth:2}),jsxs(View,{style:p.flowStep,children:[jsx(Image,{source:{uri:le("/icons/tokens/png/usdc.png")},style:p.flowIconImage}),jsx(Text,{style:[p.flowLabel,{color:s.foregroundMuted}],children:"You get"}),jsx(Text,{style:[p.flowValue,{color:s.foreground}],children:i})]})]})]}):null}var p=StyleSheet.create({scrollContainer:{flexGrow:1},scrollContent:{padding:16,paddingBottom:32},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"},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},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:{padding:16,alignItems:"center",paddingTop:24},onrampIcon:{width:64,height:64,borderRadius:16,marginBottom:16},onrampTitle:{fontSize:20,fontWeight:"500",textAlign:"center",marginBottom:8},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",padding:16,borderRadius:12,width:"100%"},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 Rn(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 Pn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Et({execution:e,onPress:t}){let {colors:o}=_(),r=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let i=W(J(e.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),c=r?"Deposit Processing":"Deposit Completed",m=Rn(e.created_at||new Date().toISOString()),d=Pn(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[ke.container,{backgroundColor:o.card}],children:[jsxs(View,{style:ke.iconContainer,children:[jsx(Image,{source:{uri:i},style:ke.tokenIcon}),jsx(View,{style:[ke.statusBadge,{backgroundColor:r?"#EAB308":"#22C55E"}],children:r?jsx(eo,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(ie,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ke.textContainer,children:[jsx(Text,{style:[ke.title,{color:o.foreground}],children:c}),jsx(Text,{style:[ke.dateTime,{color:o.foregroundMuted}],children:m})]}),jsxs(View,{style:ke.rightContainer,children:[jsx(Text,{style:[ke.amount,{color:o.foreground}],children:d}),jsx(ct,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var ke=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,borderColor:"#1C1C1E"},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:Wn}=Dimensions.get("window");function xr(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 wr(e,t=6){try{return e?(Number(e)/Math.pow(10,t)).toFixed(2):"0.00"}catch{return "0.00"}}function Mn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var kr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function br(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function En(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 At({visible:e,onClose:t,executions:o,externalUserId:r,publishableKey:a}){let{colors:i}=_(),[c,m]=useState(o),[d,n]=useState(false),[D,w]=useState(null),[s,S]=useState(false);useEffect(()=>{if(!e||!r)return;let f=async()=>{n(true);try{let Y=[...(await it(r,a)).data].sort((te,oe)=>{let M=te.created_at?new Date(te.created_at).getTime():0;return (oe.created_at?new Date(oe.created_at).getTime():0)-M});m(Y);}catch(N){console.error("Failed to fetch executions:",N),m(o);}finally{n(false);}};f();let $=setInterval(f,1e4);return ()=>clearInterval($)},[e,r,a,o]),useEffect(()=>{o.length>0&&m(f=>{let $=new Set(f.map(Y=>Y.id)),N=o.filter(Y=>!$.has(Y.id));return N.length>0?[...N,...f]:f});},[o]),useEffect(()=>{e||w(null);},[e]);let U=f=>{w(f);},O=()=>{w(null),S(false);},P=()=>{w(null),t();};return jsxs(K,{visible:e,onClose:P,closeOnBackdropPress:true,showHandle:false,children:[jsx(se,{title:D?"Deposit Details":"Deposit Tracker",onClose:P,showClose:!D,showBack:!!D,onBack:O}),D?(()=>{if(!D)return null;let f=D,$=f.status==="pending"||f.status==="waiting"||f.status==="delayed",N=f.status==="succeeded",Y=W(J(f.destination_token_metadata,"png")||le("/icons/tokens/png/usdc.png")),te=f.provider_metadata?.details,oe=te?.currencyIn,M=te?.currencyOut;oe?.currency?.symbol||"USDC";M?.currency?.symbol||"USDC";let yt=wr(f.source_amount_base_unit),ge=wr(f.destination_amount_base_unit),Ke=Mn(f.source_amount_usd),Ct=xr(f.source_chain_type,f.source_chain_id),Ee=xr(f.destination_chain_type,f.destination_chain_id),Je=()=>{f.explorer_url&&Linking.openURL(f.explorer_url);},Ae=()=>{f.destination_explorer_url&&Linking.openURL(f.destination_explorer_url);};return jsxs(ScrollView,{style:h.scrollContainer,contentContainerStyle:h.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:h.iconSection,children:[jsxs(View,{style:h.iconWrapper,children:[jsx(Image,{source:{uri:Y},style:h.tokenIcon}),jsx(View,{style:[h.statusBadge,{backgroundColor:$?"#EAB308":"#22C55E"}],children:$?jsx(de,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(ie,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:h.statusRow,children:[jsx(View,{style:[h.statusDot,{backgroundColor:$?"#EAB308":"#22C55E"}]}),jsx(Text,{style:[h.statusText,{color:i.foreground}],children:$?"Processing":"Completed"})]}),jsx(Text,{style:[h.dateText,{color:i.foregroundMuted}],children:En(f.created_at||new Date().toISOString())})]}),jsxs(View,{style:[h.card,{backgroundColor:i.card}],children:[jsxs(View,{style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Amount Sent"}),jsxs(Text,{style:[h.cardValue,{color:i.foreground}],children:[yt," ",br(f.source_currency)]})]}),jsx(View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Amount Received"}),jsxs(Text,{style:[h.cardValue,{color:i.foreground}],children:[ge," ",br(f.destination_currency)]})]}),jsx(View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"USD Value"}),jsx(Text,{style:[h.cardValue,{color:i.foreground}],children:Ke})]}),jsx(View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Source Network"}),jsx(Text,{style:[h.cardValue,{color:i.foreground}],children:Ct})]}),jsx(View,{style:[h.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Destination Network"}),jsx(Text,{style:[h.cardValue,{color:i.foreground}],children:Ee})]})]}),jsxs(TouchableOpacity,{onPress:()=>S(!s),style:h.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[h.toggleText,{color:i.foregroundMuted}],children:s?"See less":"See more details"}),s?jsx(lt,{size:14,color:i.foregroundMuted,strokeWidth:2}):jsx(de,{size:14,color:i.foregroundMuted,strokeWidth:2})]}),s&&jsxs(View,{style:[h.card,{backgroundColor:i.card}],children:[f.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:Je,style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Deposit Tx"}),jsxs(View,{style:h.cardRowRight,children:[jsx(Text,{style:[h.cardValue,{color:i.foreground}],children:kr(f.transaction_hash)}),jsx(He,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:[h.cardDivider,{backgroundColor:i.border}]})]}),f.destination_explorer_url&&N&&jsxs(TouchableOpacity,{onPress:Ae,style:h.cardRow,children:[jsx(Text,{style:[h.cardLabel,{color:i.foregroundMuted}],children:"Completion Tx"}),jsxs(View,{style:h.cardRowRight,children:[jsx(Text,{style:[h.cardValue,{color:i.foreground}],children:kr(f.destination_transaction_hashes[0])}),jsx(He,{size:14,color:i.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:h.scrollContainer,contentContainerStyle:h.scrollContent,showsVerticalScrollIndicator:false,children:c.length===0?jsxs(View,{style:h.emptyContainer,children:[jsx(Text,{style:[h.emptyText,{color:i.foregroundMuted}],children:"No deposits yet"}),jsx(Text,{style:[h.emptySubtext,{color:i.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsx(View,{style:h.executionsList,children:c.map(f=>jsx(Et,{execution:f,onPress:()=>U(f)},f.id))})})]})}var h=StyleSheet.create({scrollContainer:{maxHeight:Wn*.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,borderColor:"#1C1C1E"},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}});var Ge={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 Un({visible:e,onClose:t,externalUserId:o,publishableKey:r,modalTitle:a="Deposit",destinationTokenSymbol:i,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,hideDepositTracker:D=false,onDepositSuccess:w,onDepositError:s}){let[S,U]=useState([]),[O,P]=useState(false),[V,b]=useState(false),[f,$]=useState(false),[N,Y]=useState(null);useEffect(()=>{e&&!N&&Xt(r).then(Y).catch(console.error);},[e,N,r]);let te=()=>{t();},oe=S.filter(M=>M.status==="pending"||M.status==="waiting").length;return jsxs(K,{visible:e,onClose:te,closeOnBackdropPress:false,showHandle:false,children:[jsx(se,{title:a,showBack:false,onClose:te}),jsxs(View,{style:Ft.optionsContainer,children:[jsx(pt,{onPress:()=>b(true),title:Ge.transferCrypto.title,subtitle:Ge.transferCrypto.subtitle,featuredTokens:N?.transfer_crypto?.networks}),jsx(ft,{onPress:()=>$(true),title:Ge.depositWithCard.title,subtitle:Ge.depositWithCard.subtitle,paymentNetworks:N?.payment_networks?.networks}),!D&&jsx(ht,{onPress:()=>P(true),title:Ge.depositTracker.title,subtitle:Ge.depositTracker.subtitle,badge:oe>0?oe:void 0})]}),jsx(At,{visible:O,onClose:()=>P(false),executions:S,externalUserId:o,publishableKey:r}),jsxs(K,{visible:V,onClose:()=>b(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsx(se,{title:Ge.transferCrypto.title,showBack:false,onClose:()=>b(false)}),jsx(ScrollView,{style:Ft.transferScrollContainer,contentContainerStyle:Ft.scrollContent,showsVerticalScrollIndicator:false,children:jsx(Pt,{externalUserId:o,publishableKey:r,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onExecutionsChange:U,onDepositSuccess:w,onDepositError:s})})]}),jsxs(K,{visible:f,onClose:()=>$(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.95,children:[jsx(se,{title:"Add Funds",showBack:false,onClose:()=>$(false)}),jsx(ScrollView,{style:Ft.transferScrollContainer,contentContainerStyle:Ft.scrollContent,showsVerticalScrollIndicator:false,children:jsx(Mt,{externalUserId:o,publishableKey:r,destinationTokenSymbol:i,recipientAddress:c,destinationChainType:m,destinationChainId:d,destinationTokenAddress:n,onDepositSuccess:w,onDepositError:s})})]})]})}function Ut({theme:e="auto",...t}){return jsx(ot,{mode:e,children:jsx(Un,{...t})})}var Ft=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});function Wo({uri:e,size:t=24,style:o,borderRadius:r}){return jsx(Image,{source:{uri:e},style:[Nn.icon,{width:t,height:t,borderRadius:r??t/2},o],resizeMode:"contain"})}var Nn=StyleSheet.create({icon:{backgroundColor:"transparent"}});var Xn=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),_r=createContext(null);function Zn({children:e,publishableKey:t,config:o}){let[r]=useState(()=>Xn()),[a,i]=useState(false),[c,m]=useState(null),d=useColorScheme(),n=useRef(false);n.current||(Tt({publishableKey:t}),n.current=true);let D=useMemo(()=>{let b=o?.appearance||"dark";return b==="auto"?d==="dark"?"dark":"light":b},[o?.appearance,d]);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.'),Tt({publishableKey:t});},[t]);let w=useRef(null),s=useRef(null),S=useCallback(b=>{console.log("[UnifoldProvider] beginDeposit called with:",b),s.current&&(clearTimeout(s.current),s.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let f=new Promise(($,N)=>{w.current={resolve:$,reject:N};});return m(b),i(true),f},[]),U=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),i(false),s.current=setTimeout(()=>{m(null),s.current=null;},200);},[]),O=useCallback(b=>{console.log("[UnifoldProvider] Deposit success:",b),c?.onSuccess&&c.onSuccess(b),w.current&&(w.current.resolve(b),w.current=null);},[c]),P=useCallback(b=>{console.error("[UnifoldProvider] Deposit error:",b),c?.onError&&c.onError(b),w.current&&(w.current.reject(b),w.current=null);},[c]),V=useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:U}),[t,S,U]);return jsx(QueryClientProvider,{client:r,children:jsx(_r.Provider,{value:V,children:jsxs(ot,{mode:D,children:[e,c&&jsx(Ut,{visible:a,onClose:U,externalUserId:c.externalUserId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:c.destinationTokenSymbol,recipientAddress:c.recipientAddress,destinationChainId:c.destinationChainId,destinationTokenAddress:c.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:O,onDepositError:P,theme:D})]})})})}function ei(){let e=useContext(_r);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
+ export{K as BottomSheet,Mt as BuyWithCard,Lt as CurrencyListItem,mt as CurrencyListSection,Bt as CurrencyModal,Et as DepositExecutionItem,se as DepositHeader,Ut as DepositModal,vt as DepositStatusSheet,ht as DepositTrackerButton,ft as DepositWithCardButton,At as DepositsModal,Ue as ExecutionStatus,Wo as Icon,Dt as QRCode,ae as RemoteIcon,jo as SOLANA_USDC_ADDRESS,ot as ThemeProvider,Pt as TransferCrypto,pt as TransferCryptoButton,Zn as UnifoldProvider,Co as createDepositAddress,rt as createEOA,Kt as createMeldSession,Oo as getApiBaseUrl,$o as getChainName,Jt as getFiatCurrencies,le as getIconUrl,Ho as getIconUrlWithCdn,Yt as getMeldQuotes,J as getPreferredIcon,No as getPreferredIconUrl,Xt as getProjectConfig,Gt as getSupportedDepositTokens,qo as getTokenChains,nt as getWalletByChainType,W as normalizeIconUrl,it as queryExecutions,Tt as setApiConfig,Uo as setDevApiUrl,_ as useTheme,ei as useUnifold};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/connect-react-native",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Unifold Connect React Native SDK - Crypto deposit and onramp for React Native/Expo",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -37,7 +37,7 @@
37
37
  "@types/react-native": "^0.72.0",
38
38
  "tsup": "^8.0.0",
39
39
  "typescript": "^5.0.0",
40
- "@unifold/ui-react-native": "0.1.4"
40
+ "@unifold/ui-react-native": "0.1.5"
41
41
  },
42
42
  "keywords": [
43
43
  "unifold",